mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Split client into frontend website and server
This commit is contained in:
44
frontend/website/src/context/context.ts
Normal file
44
frontend/website/src/context/context.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
export interface ContextInterface {
|
||||
allowUnitCopying?: boolean;
|
||||
allowUnitPasting?: boolean;
|
||||
useSpawnMenu?: boolean;
|
||||
useUnitControlPanel?: boolean;
|
||||
useUnitInfoPanel?: boolean;
|
||||
}
|
||||
|
||||
export class Context {
|
||||
#allowUnitCopying: boolean;
|
||||
#allowUnitPasting: boolean;
|
||||
#useSpawnMenu: boolean;
|
||||
#useUnitControlPanel: boolean;
|
||||
#useUnitInfoPanel: boolean;
|
||||
|
||||
constructor(config: ContextInterface) {
|
||||
this.#allowUnitCopying = (config.allowUnitCopying !== false);
|
||||
this.#allowUnitPasting = (config.allowUnitPasting !== false);
|
||||
this.#useSpawnMenu = (config.useSpawnMenu !== false);
|
||||
this.#useUnitControlPanel = (config.useUnitControlPanel !== false);
|
||||
this.#useUnitInfoPanel = (config.useUnitInfoPanel !== false);
|
||||
}
|
||||
|
||||
getAllowUnitCopying() {
|
||||
return this.#allowUnitCopying;
|
||||
}
|
||||
|
||||
getAllowUnitPasting() {
|
||||
return this.#allowUnitPasting;
|
||||
}
|
||||
|
||||
getUseSpawnMenu() {
|
||||
return this.#useSpawnMenu;
|
||||
}
|
||||
|
||||
getUseUnitControlPanel() {
|
||||
return this.#useUnitControlPanel;
|
||||
}
|
||||
|
||||
getUseUnitInfoPanel() {
|
||||
return this.#useUnitInfoPanel;
|
||||
}
|
||||
|
||||
}
|
||||
40
frontend/website/src/context/contextmanager.ts
Normal file
40
frontend/website/src/context/contextmanager.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Manager } from "../other/manager";
|
||||
import { Context, ContextInterface } from "./context";
|
||||
|
||||
export class ContextManager extends Manager {
|
||||
#currentContext!: string;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
add(name: string, contextConfig: ContextInterface) {
|
||||
super.add(name, new Context(contextConfig));
|
||||
|
||||
if (Object.values(this.getAll()).length === 1) {
|
||||
this.#currentContext = name;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
currentContextIs(contextName: string) {
|
||||
return contextName === this.#currentContext;
|
||||
}
|
||||
|
||||
getCurrentContext() {
|
||||
const contexts = this.getAll();
|
||||
|
||||
return (contexts.hasOwnProperty(this.#currentContext)) ? contexts[this.#currentContext] : false;
|
||||
}
|
||||
|
||||
setContext(contextName: string) {
|
||||
if (!this.get(contextName)) {
|
||||
console.error(`setContext(): context name "${contextName}" does not exist.`);
|
||||
return false;
|
||||
}
|
||||
this.#currentContext = contextName;
|
||||
|
||||
console.log(`Setting context to "${this.#currentContext}".`);
|
||||
}
|
||||
}
|
||||
15
frontend/website/src/context/contextmenumanager.ts
Normal file
15
frontend/website/src/context/contextmenumanager.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ContextMenu } from "../contextmenus/contextmenu";
|
||||
import { Manager } from "../other/manager";
|
||||
|
||||
export class ContextMenuManager extends Manager {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
add( name:string, contextMenu:ContextMenu ) {
|
||||
super.add( name, contextMenu );
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user