Minor fixes

This commit is contained in:
Pax1601 2023-05-24 15:15:44 +02:00
parent 5f2f2a83dd
commit ec872e181d
7 changed files with 70 additions and 72 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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();
}

View File

@ -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;

View File

@ -1,5 +1,5 @@
<form class="ol-strip-board-add-flight">
<div class="ol-auto-suggest"></div>
<input type="text" name="unitName" placeholder="Flight search" />
<button class="add-flight-by-click" title="Add unit via click"><img src="/images/icons/bullseye-solid.svg" /></button>
<button class="add-flight-by-click" title="Add unit via click"><img src="/resources/theme/images/icons/bullseye-solid.svg" /></button>
</form>

View File

@ -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; }

View File

@ -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<Command*>(new Move(ID, activeDestination, getTargetSpeed(), getTargetAltitude(), enrouteTask));
scheduler->appendCommand(command);
hasTask = true;
setHasTask(true);
}
else
log(unitName + L" error, no active destination!");
@ -211,17 +210,17 @@ void AirUnit::AIloop()
if (activeDestination == NULL || !hasTask)
{
setActiveDestination();
goToDestination(enrouteTask);
if (!setActiveDestination())
setState(State::IDLE);
else
goToDestination(enrouteTask);
}
else {
if (isDestinationReached()) {
if (updateActivePath(looping) && setActiveDestination())
goToDestination(enrouteTask);
else {
else
setState(State::IDLE);
break;
}
}
}
break;