mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Controlling panels and spawn menu from context
This commit is contained in:
@@ -1,11 +1,31 @@
|
||||
export interface ContextInterface {
|
||||
|
||||
useSpawnMenu?: boolean;
|
||||
useUnitControlPanel?: boolean;
|
||||
useUnitInfoPanel?: boolean;
|
||||
}
|
||||
|
||||
export class Context {
|
||||
|
||||
constructor( config:ContextInterface ) {
|
||||
#useSpawnMenu:boolean;
|
||||
#useUnitControlPanel:boolean;
|
||||
#useUnitInfoPanel:boolean;
|
||||
|
||||
constructor( config:ContextInterface ) {
|
||||
this.#useSpawnMenu = ( config.useSpawnMenu !== false );
|
||||
this.#useUnitControlPanel = ( config.useUnitControlPanel !== false );
|
||||
this.#useUnitInfoPanel = ( config.useUnitInfoPanel !== false );
|
||||
}
|
||||
|
||||
getUseSpawnMenu() {
|
||||
return this.#useSpawnMenu;
|
||||
}
|
||||
|
||||
getUseUnitControlPanel() {
|
||||
return this.#useUnitControlPanel;
|
||||
}
|
||||
|
||||
getUseUnitInfoPanel() {
|
||||
return this.#useUnitInfoPanel;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -99,6 +99,9 @@ export class MapContextMenu extends ContextMenu {
|
||||
* @param latlng Leaflet latlng object of the mouse click
|
||||
*/
|
||||
show(x: number, y: number, latlng: LatLng) {
|
||||
if (!getApp().getCurrentContext().getUseSpawnMenu())
|
||||
return false;
|
||||
|
||||
super.show(x, y, latlng);
|
||||
|
||||
this.#aircraftSpawnMenu.setLatLng(latlng);
|
||||
|
||||
@@ -131,6 +131,10 @@ export class UnitControlPanel extends Panel {
|
||||
}
|
||||
|
||||
show() {
|
||||
const context = getApp().getCurrentContext();
|
||||
if ( !context.getUseUnitControlPanel() )
|
||||
return;
|
||||
|
||||
super.show();
|
||||
this.#speedTypeSwitch.resetExpectedValue();
|
||||
this.#altitudeTypeSwitch.resetExpectedValue();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { getApp } from "..";
|
||||
import { Ammo } from "../interfaces";
|
||||
import { aircraftDatabase } from "../unit/databases/aircraftdatabase";
|
||||
import { Unit } from "../unit/unit";
|
||||
@@ -92,4 +93,12 @@ export class UnitInfoPanel extends Panel {
|
||||
else
|
||||
this.hide();
|
||||
}
|
||||
|
||||
show() {
|
||||
const context = getApp().getCurrentContext();
|
||||
if ( !context.getUseUnitInfoPanel() )
|
||||
return;
|
||||
|
||||
super.show();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user