mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added airbase icons, started airbase spawn menu (WiP)
Added unit action menu
This commit is contained in:
@@ -10,41 +10,28 @@ export interface AirbaseOptions
|
||||
export class Airbase extends L.Marker
|
||||
{
|
||||
#name: string = "";
|
||||
#coalitionID: number = -1;
|
||||
#coalition: string = "";
|
||||
|
||||
constructor(options: AirbaseOptions)
|
||||
{
|
||||
super(options.position, { riseOnHover: true });
|
||||
|
||||
this.#name = options.name;
|
||||
|
||||
var icon = new L.DivIcon({
|
||||
html: `<table class="airbase-marker-container" id="container">
|
||||
<tr>
|
||||
<td>
|
||||
<img class="airbase-marker-image" id="icon" src="${options.src}">
|
||||
<div class="airbase-marker-name" id="name">${options.name}</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>`,
|
||||
className: 'airbase-marker'}); // Set the marker, className must be set to avoid white square
|
||||
html: ` <div class="airbase" data-object="airbase" data-coalition="red">
|
||||
<div class="airbase-marker"> </div>
|
||||
</div>`,
|
||||
className: 'leaflet-airbase-marker',
|
||||
iconSize: [63, 63]
|
||||
}); // Set the marker, className must be set to avoid white square
|
||||
this.setIcon(icon);
|
||||
|
||||
}
|
||||
|
||||
setCoalitionID(coalitionID: number)
|
||||
setCoalition(coalition: string)
|
||||
{
|
||||
this.#coalitionID = coalitionID;
|
||||
var element = this.getElement();
|
||||
if (element != null)
|
||||
{
|
||||
var img = element.querySelector("#icon");
|
||||
if (img != null)
|
||||
{
|
||||
img.classList.toggle("blue", this.#coalitionID == 2);
|
||||
img.classList.toggle("red", this.#coalitionID == 1);
|
||||
img.classList.toggle("neutral", this.#coalitionID == 0);
|
||||
}
|
||||
}
|
||||
this.#coalition = coalition;
|
||||
this.getElement()?.setAttribute("data-coalition", this.#coalition);
|
||||
}
|
||||
|
||||
getName()
|
||||
@@ -52,8 +39,8 @@ export class Airbase extends L.Marker
|
||||
return this.#name;
|
||||
}
|
||||
|
||||
getCoalitionID()
|
||||
getCoalition()
|
||||
{
|
||||
return this.#coalitionID;
|
||||
return this.#coalition;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Marker, LatLng, Icon } from "leaflet";
|
||||
import { getMap, getUnitsManager } from "..";
|
||||
import { SpawnEvent } from "../map/map";
|
||||
import { Airbase } from "./airbase";
|
||||
|
||||
var bullseyeIcons = [
|
||||
@@ -71,7 +70,8 @@ export class MissionHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
this.#airbasesMarkers[idx].setCoalitionID(airbase.coalition);
|
||||
this.#airbasesMarkers[idx].setLatLng(new LatLng(airbase.lat, airbase.lng));
|
||||
this.#airbasesMarkers[idx].setCoalition(airbase.coalition);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,20 +84,21 @@ export class MissionHandler
|
||||
else
|
||||
options = ["Spawn unit"];
|
||||
|
||||
getMap().showAirbaseContextMenu(e);
|
||||
//getMap().showContextMenu(e.originalEvent, e.sourceTarget.getName(),
|
||||
// options.map((option) => {return {tooltip: option, src: "", callback: (label: string) => {this.#onAirbaseOptionSelection(e, label)}}}, false)
|
||||
//)
|
||||
}
|
||||
|
||||
#onAirbaseOptionSelection(e: any, option: string) {
|
||||
if (option === "Spawn unit") {
|
||||
var spawnEvent: SpawnEvent = {x: e.originalEvent.x, y: e.originalEvent.y, latlng: e.latlng, airbaseName: e.sourceTarget.getName(), coalitionID: e.sourceTarget.getCoalitionID()};
|
||||
getMap().spawnFromAirbase(spawnEvent);
|
||||
}
|
||||
else if (option === "Land here")
|
||||
{
|
||||
getMap().hideContextMenu();
|
||||
getUnitsManager().selectedUnitsLandAt(e.latlng);
|
||||
}
|
||||
//if (option === "Spawn unit") {
|
||||
// var spawnEvent: SpawnEvent = {x: e.originalEvent.x, y: e.originalEvent.y, latlng: e.latlng, airbaseName: e.sourceTarget.getName(), coalitionID: e.sourceTarget.getCoalitionID()};
|
||||
// getMap().spawnFromAirbase(spawnEvent);
|
||||
//}
|
||||
//else if (option === "Land here")
|
||||
//{
|
||||
// getMap().hideContextMenu();
|
||||
// getUnitsManager().selectedUnitsLandAt(e.latlng);
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user