Fixed error in spawn menu

This commit is contained in:
Pax1601
2023-03-24 17:06:50 +01:00
parent d549898428
commit a6eaacea11

View File

@@ -60,7 +60,7 @@ export class MapContextMenu extends ContextMenu {
} }
show(x: number, y: number, latlng: LatLng) { show(x: number, y: number, latlng: LatLng) {
this.#spawnOptions = {role: "", type: "", latlng: new LatLng(0, 0), loadout: null, coalition: "blue", airbaseName: null}; this.#spawnOptions.airbaseName = null;
super.show(x, y, latlng); super.show(x, y, latlng);
this.#spawnOptions.latlng = latlng; this.#spawnOptions.latlng = latlng;
this.showUpperBar(); this.showUpperBar();
@@ -89,13 +89,11 @@ export class MapContextMenu extends ContextMenu {
this.getContainer()?.querySelector("#upper-bar")?.classList.toggle("hide", true); this.getContainer()?.querySelector("#upper-bar")?.classList.toggle("hide", true);
} }
setAirbaseName(airbaseName: string) setAirbaseName(airbaseName: string) {
{
this.#spawnOptions.airbaseName = airbaseName; this.#spawnOptions.airbaseName = airbaseName;
} }
setLatLng(latlng: LatLng) setLatLng(latlng: LatLng) {
{
this.#spawnOptions.latlng = latlng; this.#spawnOptions.latlng = latlng;
} }
@@ -109,8 +107,7 @@ export class MapContextMenu extends ContextMenu {
} }
/********* Aircraft spawn menu *********/ /********* Aircraft spawn menu *********/
#setAircraftRole(role: string) #setAircraftRole(role: string) {
{
this.#spawnOptions.role = role; this.#spawnOptions.role = role;
this.#resetAircraftType(); this.#resetAircraftType();
this.#aircraftTypeDropdown.setOptions(aircraftDatabase.getByRole(role).map((blueprint) => { return blueprint.label })); this.#aircraftTypeDropdown.setOptions(aircraftDatabase.getByRole(role).map((blueprint) => { return blueprint.label }));
@@ -127,12 +124,10 @@ export class MapContextMenu extends ContextMenu {
this.clip(); this.clip();
} }
#setAircraftType(label: string) #setAircraftType(label: string) {
{
this.#resetAircraftType(); this.#resetAircraftType();
var type = aircraftDatabase.getByLabel(label)?.name || null; var type = aircraftDatabase.getByLabel(label)?.name || null;
if (type != null) if (type != null) {
{
this.#spawnOptions.type = type; this.#spawnOptions.type = type;
this.#aircraftLoadoutDropdown.setOptions(aircraftDatabase.getLoadoutNamesByRole(type, this.#spawnOptions.role)); this.#aircraftLoadoutDropdown.setOptions(aircraftDatabase.getLoadoutNamesByRole(type, this.#spawnOptions.role));
this.#aircraftLoadoutDropdown.selectValue(0); this.#aircraftLoadoutDropdown.selectValue(0);
@@ -152,11 +147,9 @@ export class MapContextMenu extends ContextMenu {
this.clip(); this.clip();
} }
#setAircraftLoadout(loadoutName: string) #setAircraftLoadout(loadoutName: string) {
{
var loadout = aircraftDatabase.getLoadoutByName(this.#spawnOptions.type, loadoutName); var loadout = aircraftDatabase.getLoadoutByName(this.#spawnOptions.type, loadoutName);
if (loadout) if (loadout) {
{
this.#spawnOptions.loadout = loadout.code; this.#spawnOptions.loadout = loadout.code;
(<HTMLButtonElement>this.getContainer()?.querySelector("#aircraft-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = false; (<HTMLButtonElement>this.getContainer()?.querySelector("#aircraft-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = false;
var items = loadout.items.map((item: any) => { return `${item.quantity}x ${item.name}`; }); var items = loadout.items.map((item: any) => { return `${item.quantity}x ${item.name}`; });
@@ -173,8 +166,7 @@ export class MapContextMenu extends ContextMenu {
} }
/********* Ground unit spawn menu *********/ /********* Ground unit spawn menu *********/
#setGroundUnitRole(role: string) #setGroundUnitRole(role: string) {
{
this.#spawnOptions.role = role; this.#spawnOptions.role = role;
this.#resetGroundUnitRole(); this.#resetGroundUnitRole();
this.#groundUnitTypeDropdown.setOptions(groundUnitsDatabase.getByRole(role).map((blueprint) => { return blueprint.label })); this.#groundUnitTypeDropdown.setOptions(groundUnitsDatabase.getByRole(role).map((blueprint) => { return blueprint.label }));
@@ -191,12 +183,10 @@ export class MapContextMenu extends ContextMenu {
this.clip(); this.clip();
} }
#setGroundUnitType(label: string) #setGroundUnitType(label: string) {
{
this.#resetGroundUnitType(); this.#resetGroundUnitType();
var type = groundUnitsDatabase.getByLabel(label)?.name || null; var type = groundUnitsDatabase.getByLabel(label)?.name || null;
if (type != null) if (type != null) {
{
this.#spawnOptions.type = type; this.#spawnOptions.type = type;
(<HTMLButtonElement>this.getContainer()?.querySelector("#ground-unit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = false; (<HTMLButtonElement>this.getContainer()?.querySelector("#ground-unit-spawn-menu")?.querySelector(".deploy-unit-button")).disabled = false;
} }