diff --git a/client/public/stylesheets/olympus.css b/client/public/stylesheets/olympus.css index d32ccc42..2bce5980 100644 --- a/client/public/stylesheets/olympus.css +++ b/client/public/stylesheets/olympus.css @@ -165,7 +165,7 @@ form>div { align-items: center; background-color: var(--background-grey); border-radius: var(--border-radius-sm); - height: 32px; + height: 40px; overflow: hidden; padding-left: 20px; padding-right: 30px; @@ -225,7 +225,7 @@ form>div { box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25); display: flex; justify-content: left; - padding: 2px 10px; + padding: 2px 15px; width: 100%; } @@ -251,8 +251,9 @@ form>div { border-radius: var(--border-radius-sm); color: white; display: block; - font-size: 12px; + font-size: 13px; font-weight: normal; + height: 32px; padding: 6px 2px; padding: 5px; text-align: left; diff --git a/client/src/controls/dropdown.ts b/client/src/controls/dropdown.ts index 01aae36e..502f1481 100644 --- a/client/src/controls/dropdown.ts +++ b/client/src/controls/dropdown.ts @@ -33,8 +33,8 @@ export class Dropdown { this.#options.classList.add("ol-scrollable"); } - setOptions(optionsList: string[]) { - this.#optionsList = optionsList; + setOptions(optionsList: string[], sortAlphabetically: boolean = true) { + this.#optionsList = optionsList.sort(); this.#options.replaceChildren(...optionsList.map((option: string, idx: number) => { var div = document.createElement("div"); var button = document.createElement("button"); @@ -70,6 +70,7 @@ export class Dropdown { var el = document.createElement("div"); el.classList.add("ol-ellipsed"); el.innerText = option; + this.#value.replaceChildren(); this.#value.appendChild(el); this.#index = idx; this.#close(); diff --git a/client/src/controls/mapcontextmenu.ts b/client/src/controls/mapcontextmenu.ts index c8c98b40..f381ca79 100644 --- a/client/src/controls/mapcontextmenu.ts +++ b/client/src/controls/mapcontextmenu.ts @@ -188,8 +188,6 @@ export class MapContextMenu extends ContextMenu { this.#resetGroundUnitType(); const types = groundUnitsDatabase.getByRole(role).map((blueprint) => { return blueprint.label }); - types.sort(); - this.#groundUnitTypeDropdown.setOptions(types); this.#groundUnitTypeDropdown.selectValue(0); this.clip(); @@ -202,8 +200,6 @@ export class MapContextMenu extends ContextMenu { this.#groundUnitTypeDropdown.reset(); const roles = groundUnitsDatabase.getRoles(); - roles.sort(); - this.#groundUnitRoleDropdown.setOptions(roles); this.clip(); } diff --git a/client/src/panels/logpanel.ts b/client/src/panels/logpanel.ts index 44a8d5ea..367a23c0 100644 --- a/client/src/panels/logpanel.ts +++ b/client/src/panels/logpanel.ts @@ -18,7 +18,7 @@ export class LogPanel extends Panel if (parseInt(idx) >= this.#logs.length) { this.#logs.push(logs[idx]); var el = document.createElement("div"); - el.innerHTML = logs[idx]; + el.innerText = logs[idx]; el.classList.add("js-log-element", "ol-log-element"); this.getElement().appendChild(el); this.getElement().scrollTop = this.getElement().scrollHeight; diff --git a/client/views/atc/addflight.ejs b/client/views/atc/addflight.ejs index 73f7c9f4..818869f0 100644 --- a/client/views/atc/addflight.ejs +++ b/client/views/atc/addflight.ejs @@ -1,5 +1,5 @@
\ No newline at end of file diff --git a/src/core/include/unit.h b/src/core/include/unit.h index 37e456f3..2d6d6bcf 100644 --- a/src/core/include/unit.h +++ b/src/core/include/unit.h @@ -4,6 +4,7 @@ #include "dcstools.h" #include "luatools.h" #include "measure.h" +#include "logger.h" namespace State { @@ -93,7 +94,7 @@ public: void setFuel(double newFuel) { fuel = newFuel; addMeasure(L"fuel", json::value(newFuel));} void setAmmo(json::value newAmmo) { ammo = newAmmo; addMeasure(L"ammo", json::value(newAmmo));} void setTargets(json::value newTargets) {targets = newTargets; addMeasure(L"targets", json::value(newTargets));} - void setHasTask(bool newHasTask) { hasTask = newHasTask; addMeasure(L"hasTask", json::value(newHasTask));} + void setHasTask(bool newHasTask) { hasTask = newHasTask; addMeasure(L"hasTask", json::value(newHasTask)); } void setCoalitionID(int newCoalitionID); void setFlags(json::value newFlags) { flags = newFlags; addMeasure(L"flags", json::value(newFlags));} double getFuel() { return fuel; } diff --git a/src/core/src/airunit.cpp b/src/core/src/airunit.cpp index f40f65be..78d87cdf 100644 --- a/src/core/src/airunit.cpp +++ b/src/core/src/airunit.cpp @@ -20,9 +20,8 @@ AirUnit::AirUnit(json::value json, int ID) : Unit(json, ID) void AirUnit::setState(int newState) { - if (state != newState) - { - /************ Perform any action required when LEAVING a certain state ************/ + /************ Perform any action required when LEAVING a certain state ************/ + if (newState != state) { switch (state) { case State::IDLE: { break; @@ -47,58 +46,58 @@ void AirUnit::setState(int newState) default: break; } - - /************ Perform any action required when ENTERING a certain state ************/ - switch (newState) { - case State::IDLE: { - clearActivePath(); - resetActiveDestination(); - addMeasure(L"currentState", json::value(L"Idle")); - break; - } - case State::REACH_DESTINATION: { - resetActiveDestination(); - addMeasure(L"currentState", json::value(L"Reach destination")); - break; - } - case State::ATTACK: { - if (isTargetAlive()) { - Unit* target = unitsManager->getUnit(targetID); - Coords targetPosition = Coords(target->getLatitude(), target->getLongitude(), 0); - clearActivePath(); - pushActivePathFront(targetPosition); - resetActiveDestination(); - addMeasure(L"currentState", json::value(L"Attack")); - } - break; - } - case State::FOLLOW: { - clearActivePath(); - resetActiveDestination(); - addMeasure(L"currentState", json::value(L"Follow")); - break; - } - case State::LAND: { - resetActiveDestination(); - addMeasure(L"currentState", json::value(L"Land")); - break; - } - case State::REFUEL: { - initialFuel = fuel; - clearActivePath(); - resetActiveDestination(); - addMeasure(L"currentState", json::value(L"Refuel")); - break; - } - default: - break; - } - - resetTask(); - - log(unitName + L" setting state from " + to_wstring(state) + L" to " + to_wstring(newState)); - state = newState; } + + /************ Perform any action required when ENTERING a certain state ************/ + switch (newState) { + case State::IDLE: { + clearActivePath(); + resetActiveDestination(); + addMeasure(L"currentState", json::value(L"Idle")); + break; + } + case State::REACH_DESTINATION: { + resetActiveDestination(); + addMeasure(L"currentState", json::value(L"Reach destination")); + break; + } + case State::ATTACK: { + if (isTargetAlive()) { + Unit* target = unitsManager->getUnit(targetID); + Coords targetPosition = Coords(target->getLatitude(), target->getLongitude(), 0); + clearActivePath(); + pushActivePathFront(targetPosition); + resetActiveDestination(); + addMeasure(L"currentState", json::value(L"Attack")); + } + break; + } + case State::FOLLOW: { + clearActivePath(); + resetActiveDestination(); + addMeasure(L"currentState", json::value(L"Follow")); + break; + } + case State::LAND: { + resetActiveDestination(); + addMeasure(L"currentState", json::value(L"Land")); + break; + } + case State::REFUEL: { + initialFuel = fuel; + clearActivePath(); + resetActiveDestination(); + addMeasure(L"currentState", json::value(L"Refuel")); + break; + } + default: + break; + } + + resetTask(); + + log(unitName + L" setting state from " + to_wstring(state) + L" to " + to_wstring(newState)); + state = newState; } bool AirUnit::isDestinationReached() @@ -158,7 +157,7 @@ void AirUnit::goToDestination(wstring enrouteTask) { Command* command = dynamic_cast