mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Range rings only showing when necessary
This commit is contained in:
parent
8e545346e6
commit
1691b0b30c
@ -18,6 +18,7 @@ export class MapContextMenu extends ContextMenu {
|
||||
#groundUnitSpawnMenu: GroundUnitSpawnMenu;
|
||||
#navyUnitSpawnMenu: NavyUnitSpawnMenu;
|
||||
#coalitionArea: CoalitionArea | null = null;
|
||||
#selectedUnitCategory: string = "";
|
||||
|
||||
/**
|
||||
*
|
||||
@ -39,9 +40,10 @@ export class MapContextMenu extends ContextMenu {
|
||||
|
||||
/* Event listeners */
|
||||
document.addEventListener("mapContextMenuShow", (e: any) => {
|
||||
if (this.getVisibleSubMenu() !== e.detail.type)
|
||||
if (this.getVisibleSubMenu() !== e.detail.type) {
|
||||
this.#showSubMenu(e.detail.type);
|
||||
else
|
||||
this.#selectedUnitCategory = e.detail.type;
|
||||
} else
|
||||
this.#hideSubMenus(e.detail.type);
|
||||
});
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ export class UnitSpawnMenu {
|
||||
/* Range circle previews */
|
||||
#engagementCircle: Circle;
|
||||
#acquisitionCircle: Circle;
|
||||
protected showRangeCircles: boolean = false;
|
||||
|
||||
constructor(ID: string, unitDatabase: UnitDatabase, orderByRole: boolean) {
|
||||
this.#container = document.getElementById(ID) as HTMLElement;
|
||||
@ -244,6 +245,10 @@ export class UnitSpawnMenu {
|
||||
return this.#container;
|
||||
}
|
||||
|
||||
getVisible() {
|
||||
return !this.getContainer().classList.contains( "hide" );
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.#deployUnitButtonEl.disabled = true;
|
||||
this.#unitRoleTypeDropdown.reset();
|
||||
@ -286,11 +291,15 @@ export class UnitSpawnMenu {
|
||||
|
||||
showCirclesPreviews() {
|
||||
this.clearCirclesPreviews();
|
||||
|
||||
if ( !this.showRangeCircles || this.spawnOptions.name === "" || !this.getVisible() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var acquisitionRange = this.#unitDatabase.getByName(this.spawnOptions.name)?.acquisitionRange ?? 0;
|
||||
var engagementRange = this.#unitDatabase.getByName(this.spawnOptions.name)?.engagementRange ?? 0;
|
||||
|
||||
if ( engagementRange === 0 && acquisitionRange === 0 ) {
|
||||
if ( acquisitionRange === 0 && engagementRange === 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -576,6 +585,9 @@ export class HelicopterSpawnMenu extends UnitSpawnMenu {
|
||||
}
|
||||
|
||||
export class GroundUnitSpawnMenu extends UnitSpawnMenu {
|
||||
|
||||
protected showRangeCircles: boolean = true;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ID - the ID of the HTML element which will contain the context menu
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user