mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Implemented basic Plugin handling
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import { OlympusApp } from "../olympusapp";
|
||||
import { Manager } from "./manager";
|
||||
|
||||
export abstract class EventsManager extends Manager {
|
||||
|
||||
constructor( olympusApp:OlympusApp ) {
|
||||
super( olympusApp );
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +1,33 @@
|
||||
import { OlympusApp } from "../olympusapp";
|
||||
|
||||
export interface IManager {
|
||||
add:CallableFunction;
|
||||
}
|
||||
|
||||
export abstract class Manager {
|
||||
|
||||
#items: {[key:string]: any } = {};
|
||||
#olympusApp: OlympusApp;
|
||||
|
||||
constructor( olympusApp:OlympusApp ) {
|
||||
|
||||
this.#olympusApp = olympusApp;
|
||||
export class Manager {
|
||||
#items: { [key: string]: any } = {};
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
add( name:string, item:any ) {
|
||||
|
||||
const regex = new RegExp( "^[a-z][a-z0-9]{2,}$", "i" );
|
||||
|
||||
if ( regex.test( name ) === false ) {
|
||||
throw new Error( `Item name "${name}" does not match regex: ${regex.toString()}.` );
|
||||
add(name: string, item: any) {
|
||||
const regex = new RegExp("^[a-z][a-z0-9]{2,}$", "i");
|
||||
if (regex.test(name) === false) {
|
||||
throw new Error(`Item name "${name}" does not match regex: ${regex.toString()}.`);
|
||||
}
|
||||
|
||||
if ( this.#items.hasOwnProperty( name ) ) {
|
||||
throw new Error( `Item with name "${name}" already exists.` );
|
||||
if (this.#items.hasOwnProperty(name)) {
|
||||
throw new Error(`Item with name "${name}" already exists.`);
|
||||
}
|
||||
|
||||
this.#items[ name ] = item;
|
||||
|
||||
this.#items[name] = item;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
get( name:string ) {
|
||||
|
||||
if ( this.#items.hasOwnProperty( name ) ) {
|
||||
return this.#items[ name ];
|
||||
get(name: string) {
|
||||
if (this.#items.hasOwnProperty(name)) {
|
||||
return this.#items[name];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getAll() {
|
||||
return this.#items;
|
||||
}
|
||||
|
||||
getOlympusApp() {
|
||||
return this.#olympusApp;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import { groundUnitDatabase } from "../unit/databases/groundunitdatabase";
|
||||
import { Buffer } from "buffer";
|
||||
import { ROEs, emissionsCountermeasures, reactionsToThreat, states } from "../constants/constants";
|
||||
import { Dropdown } from "../controls/dropdown";
|
||||
import { UnitBlueprint } from "../@types/unitdatabase";
|
||||
import { navyUnitDatabase } from "../unit/databases/navyunitdatabase";
|
||||
|
||||
export function bearing(lat1: number, lon1: number, lat2: number, lon2: number) {
|
||||
|
||||
Reference in New Issue
Block a user