Added code to show spawn menu from airbase spawn

This commit is contained in:
dpassoni
2023-03-14 17:30:16 +01:00
parent 4e46819839
commit 16b5e89a3e
4 changed files with 51 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
import { getUnitsManager } from "..";
import { getMap, getUnitsManager, setActiveCoalition } from "..";
import { Airbase } from "../missionhandler/airbase";
import { ContextMenu } from "./contextmenu";
@@ -8,6 +8,9 @@ export class AirbaseContextMenu extends ContextMenu {
constructor(id: string)
{
super(id);
document.addEventListener("contextMenuSpawnAirbase", (e: any) => {
this.showSpawnMenu();
})
}
setAirbase(airbase: Airbase)
@@ -53,6 +56,16 @@ export class AirbaseContextMenu extends ContextMenu {
enableLandButton(enableLandButton: boolean)
{
this.getContainer()?.querySelector("#land-here-button")?.classList.toggle("hide", !enableLandButton);
}
showSpawnMenu()
{
if (this.#airbase != null)
{
setActiveCoalition(this.#airbase.getCoalition());
getMap().showMapContextMenu({originalEvent: {x: this.getX(), y: this.getY(), latlng: this.getLatLng()}});
getMap().getMapContextMenu().hideUpperBar();
getMap().getMapContextMenu().showSubMenu("aircraft");
}
}
}