From 931b1ea537ce976fbdaffbfc58d01bdbcfc065c6 Mon Sep 17 00:00:00 2001 From: PeekabooSteam Date: Wed, 8 Mar 2023 09:00:46 +0000 Subject: [PATCH] Added feature switch to force showing of unit control panel. --- client/public/stylesheets/layout.css | 28 +++++++++++++++------------ client/src/FeatureSwitches.ts | 29 +++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/client/public/stylesheets/layout.css b/client/public/stylesheets/layout.css index 3809990c..70e428fd 100644 --- a/client/public/stylesheets/layout.css +++ b/client/public/stylesheets/layout.css @@ -25,8 +25,8 @@ body { #map-container { height: 100%; - width: 100%; min-width: 820px; + width: 100%; } #primary-toolbar { @@ -41,33 +41,37 @@ body { } #unit-control-panel { + height: fit-content; + left: 10px; position: absolute; top: 80px; - height: fit-content; width: 250px; - left: 10px; z-index: 1000; } +body.forceShowUnitControlPanel #unit-control-panel { + display:block !important; +} + .content #unit-control-panel { position: static; } #connection-status-panel { - position: absolute; - height: 30px; - width: 160px; bottom: 20px; + height: 30px; + position: absolute; right: 10px; + width: 160px; z-index: 1000; } #mouse-info-panel { - position: absolute; - height: fit-content; - width: 160px; bottom: 60px; + height: fit-content; + position: absolute; right: 10px; + width: 160px; z-index: 1000; } @@ -78,10 +82,10 @@ body { #log-panel { - position: absolute; height: 200px; - width: 400px; - top: 60px; left: 10px; + position: absolute; + top: 60px; + width: 400px; z-index: 1000; } diff --git a/client/src/FeatureSwitches.ts b/client/src/FeatureSwitches.ts index a39b8530..84474ef7 100644 --- a/client/src/FeatureSwitches.ts +++ b/client/src/FeatureSwitches.ts @@ -3,6 +3,7 @@ export interface FeatureSwitchInterface { "label": string, "masterSwitch": boolean, // on/off regardless of user preference "name": string, + "onEnabled"?: CallableFunction, "options"?: object, "removeArtifactsIfDisabled"?: boolean } @@ -15,6 +16,7 @@ class FeatureSwitch { label; masterSwitch; name; + onEnabled; removeArtifactsIfDisabled = true; // Self-set @@ -27,6 +29,7 @@ class FeatureSwitch { this.label = config.label; this.masterSwitch = config.masterSwitch; this.name = config.name; + this.onEnabled = config.onEnabled; this.userPreference = this.getUserPreference(); @@ -77,6 +80,16 @@ export class FeatureSwitches { "label": "ATC", "masterSwitch": true, "name": "atc" + }), + + new FeatureSwitch({ + "defaultEnabled": false, + "label": "Force show unit control panel", + "masterSwitch": true, + "name": "forceShowUnitControlPanel", + "onEnabled": function() { + document.body.classList.add( "forceShowUnitControlPanel" ); + } }) ]; @@ -84,7 +97,7 @@ export class FeatureSwitches { constructor() { - this.#removeArtifacts(); + this.#testSwitches(); this.savePreferences(); @@ -98,10 +111,20 @@ export class FeatureSwitches { } - #removeArtifacts() { + #testSwitches() { for ( const featureSwitch of this.#featureSwitches ) { - if ( !featureSwitch.isEnabled() ) { + + if ( featureSwitch.isEnabled() ) { + + if ( typeof featureSwitch.onEnabled === "function" ) { + + featureSwitch.onEnabled(); + + } + + + } else { document.querySelectorAll( "[data-feature-switch='" + featureSwitch.name + "']" ).forEach( el => {