From 6c6117aee335b6648813a352e7494a39f5ffef8d Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Sun, 10 Dec 2023 18:36:25 +0100 Subject: [PATCH] Fixed minor UI problems --- .../public/stylesheets/panels/unitcontrol.css | 2 +- client/src/controls/dropdown.ts | 18 +++++++++++------- client/src/map/map.ts | 2 +- client/src/panels/unitcontrolpanel.ts | 8 ++++---- client/src/panels/unitinfopanel.ts | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/client/public/stylesheets/panels/unitcontrol.css b/client/public/stylesheets/panels/unitcontrol.css index b7039a92..da629696 100644 --- a/client/public/stylesheets/panels/unitcontrol.css +++ b/client/public/stylesheets/panels/unitcontrol.css @@ -315,7 +315,7 @@ body.feature-forceShowUnitControlPanel #unit-control-panel { #advanced-settings-div>button { background-color: var(--background-grey); - box-shadow: 0px 2px 5px #000A; + box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.25); font-size: 13px; height: 40px; padding: 0 20px; diff --git a/client/src/controls/dropdown.ts b/client/src/controls/dropdown.ts index 300d492c..1a0c4b6b 100644 --- a/client/src/controls/dropdown.ts +++ b/client/src/controls/dropdown.ts @@ -44,16 +44,20 @@ export class Dropdown { /** Set the dropdown options strings * * @param optionsList List of options. These are the keys that will always be returned on selection - * @param sort Sort method. "string" performs js default sort. "number" sorts purely by numeric value. + * @param sort Sort method. null means no sorting. "string" performs js default sort. "number" sorts purely by numeric value. * "string+number" sorts by string, unless two elements are lexicographically identical up to a numeric value (e.g. "SA-2" and "SA-3"), in which case it sorts by number. * @param labelsList (Optional) List of labels to be shown instead of the keys directly. If provided, the options will be sorted by label. */ - setOptions(optionsList: string[], sort: "" | "string" | "number" | "string+number" = "string", labelsList: string[] | undefined = undefined) { - /* If labels are provided, sort by labels, else by options */ - if (labelsList && labelsList.length == optionsList.length) - this.#sortByLabels(optionsList, sort, labelsList); - else - this.#sortByOptions(optionsList, sort); + setOptions(optionsList: string[], sort: null | "string" | "number" | "string+number" = "string", labelsList: string[] | undefined = undefined) { + if (sort != null) { + /* If labels are provided, sort by labels, else by options */ + if (labelsList && labelsList.length == optionsList.length) + this.#sortByLabels(optionsList, sort, labelsList); + else + this.#sortByOptions(optionsList, sort); + } else { + this.#optionsList = optionsList; + } /* If no options are provided, return */ if (this.#optionsList.length == 0) { diff --git a/client/src/map/map.ts b/client/src/map/map.ts index 93dc9876..be47a116 100644 --- a/client/src/map/map.ts +++ b/client/src/map/map.ts @@ -220,7 +220,7 @@ export class Map extends L.Map { this.addVisibilityOption(SHOW_UNITS_ENGAGEMENT_RINGS, true); this.addVisibilityOption(SHOW_UNITS_ACQUISITION_RINGS, true); this.addVisibilityOption(HIDE_UNITS_SHORT_RANGE_RINGS, true); - this.addVisibilityOption(FILL_SELECTED_RING, false); + /* this.addVisibilityOption(FILL_SELECTED_RING, false); Removed since currently broken: TODO fix!*/ } addVisibilityOption(option: string, defaultValue: boolean) { diff --git a/client/src/panels/unitcontrolpanel.ts b/client/src/panels/unitcontrolpanel.ts index c5b4de9a..424b36d5 100644 --- a/client/src/panels/unitcontrolpanel.ts +++ b/client/src/panels/unitcontrolpanel.ts @@ -383,7 +383,7 @@ export class UnitControlPanel extends Panel { this.#advancedSettingsDialog.toggleAttribute("data-show-tanker", isTanker); this.#advancedSettingsDialog.toggleAttribute("data-show-AWACS", isAWACS); this.#advancedSettingsDialog.toggleAttribute("data-show-TACAN", isTanker || ["Aircraft Carrier", "Super Aircraft Carrier"].includes(units[0].getType())); - this.#advancedSettingsDialog.toggleAttribute("data-show-radio", isTanker || isAWACS || ["Aircraft Carrier", "Super Aircraft Carrier"].includes(units[0].getType())); + this.#advancedSettingsDialog.toggleAttribute("data-show-radio", isTanker || isAWACS); /* Set common properties */ // Name @@ -408,11 +408,11 @@ export class UnitControlPanel extends Panel { this.#radioDecimalsDropdown.setValue("." + radioDecimals); if (isTanker) /* Set tanker specific options */ - this.#radioCallsignDropdown.setOptions(["Texaco", "Arco", "Shell"]); + this.#radioCallsignDropdown.setOptions(["Texaco", "Arco", "Shell"], null); else if (isAWACS) /* Set AWACS specific options */ - this.#radioCallsignDropdown.setOptions(["Overlord", "Magic", "Wizard", "Focus", "Darkstar"]); + this.#radioCallsignDropdown.setOptions(["Overlord", "Magic", "Wizard", "Focus", "Darkstar"], null); else - this.#radioCallsignDropdown.setOptions(["Enfield", "Springfield", "Uzi", "Colt", "Dodge", "Ford", "Chevy", "Pontiac"]); + this.#radioCallsignDropdown.setOptions(["Enfield", "Springfield", "Uzi", "Colt", "Dodge", "Ford", "Chevy", "Pontiac"], null); // This must be done after setting the options if (!this.#radioCallsignDropdown.selectValue(unit.getRadio().callsign - 1)) // Ensure the selected value is in the acceptable range diff --git a/client/src/panels/unitinfopanel.ts b/client/src/panels/unitinfopanel.ts index bbdeb13a..84e30580 100644 --- a/client/src/panels/unitinfopanel.ts +++ b/client/src/panels/unitinfopanel.ts @@ -40,7 +40,7 @@ export class UnitInfoPanel extends Panel { if (this.getElement() != null && this.getVisible() && unit.getSelected()) { /* Set the unit info */ - this.#unitLabel.innerText = aircraftDatabase.getByName(unit.getName())?.label || unit.getName(); + this.#unitLabel.innerText = unit.getDatabaseEntry()?.label || unit.getName(); this.#unitGroup.dataset.groupName = unit.getGroup()?.getName() ?? "No group"; this.#unitName.innerText = unit.getUnitName(); if (unit.getHuman())