Merge branch '498-set-ucp-and-uip-toggles-into-olympus-context' into 500-log-in-form-needs-to-submit-when-pressing-enterreturn

This commit is contained in:
PeekabooSteam
2023-11-05 13:08:24 +00:00
5 changed files with 94 additions and 4 deletions

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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();

View File

@@ -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();
}
}