Merge branch 'main' into 407-create-a-simple-plugin-to-manage-units-database

This commit is contained in:
Pax1601 2023-09-24 10:22:45 +02:00
commit 28afef8847
23 changed files with 2058 additions and 53 deletions

1989
client/@types/olympus/index.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -60,11 +60,6 @@
padding: 0;
}
.leaflet-container img.leaflet-tile {
/* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */
mix-blend-mode: plus-lighter;
}
.leaflet-container.leaflet-touch-zoom {
-ms-touch-action: pan-x pan-y;
touch-action: pan-x pan-y;
@ -651,7 +646,7 @@ svg.leaflet-image-layer.leaflet-interactive path {
}
/* Printing */
@media print {
/* Prevent printers from removing background-images of controls. */
.leaflet-control {

View File

@ -1,5 +1,6 @@
import { getApp } from "..";
import { GAME_MASTER } from "../constants/constants";
import { AirbaseChartRunwayData, AirbaseChartRunwayHeadingData } from "../interfaces";
import { Airbase } from "../mission/airbase";
import { dataPointMap } from "../other/utils";
import { Unit } from "../unit/unit";

View File

@ -10,6 +10,7 @@ import { aircraftDatabase } from "../unit/databases/aircraftdatabase";
import { helicopterDatabase } from "../unit/databases/helicopterdatabase";
import { groundUnitDatabase } from "../unit/databases/groundunitdatabase";
import { navyUnitDatabase } from "../unit/databases/navyunitdatabase";
import { UnitSpawnOptions, UnitSpawnTable } from "../interfaces";
export class UnitSpawnMenu {
#container: HTMLElement;

View File

@ -1,47 +1,51 @@
interface OlympusPlugin {
import { LatLng } from "leaflet";
import { OlympusApp } from "./app";
import { Airbase } from "./mission/airbase";
export interface OlympusPlugin {
getName: () => string;
initialize: (any) => boolean;
initialize: (app: OlympusApp) => boolean;
}
declare global {
function getOlympusPlugin(): OlympusPlugin;
}
interface ConfigurationOptions {
export interface ConfigurationOptions {
port: number;
address: string;
}
interface ContextMenuOption {
export interface ContextMenuOption {
tooltip: string;
src: string;
callback: CallableFunction;
}
interface AirbasesData {
export interface AirbasesData {
airbases: { [key: string]: any },
sessionHash: string;
time: number;
}
interface BullseyesData {
export interface BullseyesData {
bullseyes: { [key: string]: { latitude: number, longitude: number, coalition: string } },
sessionHash: string;
time: number;
}
interface MissionData {
export interface MissionData {
mission: {
theatre: string,
dateAndTime: DateAndTime;
commandModeOptions: CommandModeOptions;
coalitions: { red: string[], blue: string[] } = { };
coalitions: { red: string[], blue: string[] };
}
time: number;
sessionHash: string;
}
interface CommandModeOptions {
export interface CommandModeOptions {
commandMode: string;
restrictSpawns: boolean;
restrictToCoalition: boolean;
@ -53,33 +57,33 @@ interface CommandModeOptions {
eras: string[]
}
interface DateAndTime {
export interface DateAndTime {
date: { Year: number, Month: number, Day: number };
time: { h: number, m: number, s: number };
elapsedTime: number;
startTime: number;
}
interface LogData {
export interface LogData {
logs: { [key: string]: string },
sessionHash: string;
time: number;
}
interface ServerRequestOptions {
export interface ServerRequestOptions {
time?: number;
commandHash?: string;
}
interface UnitSpawnTable {
export interface UnitSpawnTable {
unitType: string,
location: latlng,
location: LatLng,
altitude?: number,
loadout?: string,
liveryID: string
}
interface ObjectIconOptions {
export interface ObjectIconOptions {
showState: boolean,
showVvi: boolean,
showHotgroup: boolean,
@ -92,7 +96,7 @@ interface ObjectIconOptions {
rotateToHeading: boolean
}
interface GeneralSettings {
export interface GeneralSettings {
prohibitJettison: boolean;
prohibitAA: boolean;
prohibitAG: boolean;
@ -100,20 +104,20 @@ interface GeneralSettings {
prohibitAirWpn: boolean;
}
interface TACAN {
export interface TACAN {
isOn: boolean;
channel: number;
XY: string;
callsign: string;
}
interface Radio {
export interface Radio {
frequency: number;
callsign: number;
callsignNumber: number;
}
interface Ammo {
export interface Ammo {
quantity: number,
name: string,
guidance: number,
@ -121,18 +125,18 @@ interface Ammo {
missileCategory: number
}
interface Contact {
export interface Contact {
ID: number,
detectionMethod: number
}
interface Offset {
export interface Offset {
x: number,
y: number,
z: number
}
interface UnitData {
export interface UnitData {
category: string,
ID: number;
alive: boolean;
@ -174,13 +178,13 @@ interface UnitData {
isLeader: boolean;
}
interface LoadoutItemBlueprint {
export interface LoadoutItemBlueprint {
name: string;
quantity: number;
effectiveAgainst?: string;
}
interface LoadoutBlueprint {
export interface LoadoutBlueprint {
fuel: number;
items: LoadoutItemBlueprint[];
roles: string[];
@ -188,7 +192,7 @@ interface LoadoutBlueprint {
name: string;
}
interface UnitBlueprint {
export interface UnitBlueprint {
name: string;
coalition: string;
era: string;
@ -202,7 +206,7 @@ interface UnitBlueprint {
cost?: number;
}
interface UnitSpawnOptions {
export interface UnitSpawnOptions {
roleType: string;
name: string;
latlng: LatLng;
@ -215,36 +219,36 @@ interface UnitSpawnOptions {
altitude: number | undefined;
}
interface AirbaseOptions {
export interface AirbaseOptions {
name: string,
position: L.LatLng
}
interface AirbaseChartData {
export interface AirbaseChartData {
elevation: string,
ICAO: string,
TACAN: string,
runways: AirbaseChartRunwayData[]
}
interface AirbaseChartRunwayData {
headings: AirbaseChartRunwayHeadingData[],
length: string
}
interface AirbaseChartRunwayHeadingData {
export interface AirbaseChartRunwayHeadingData {
[index: string]: {
magHeading: string,
ILS: string
}
}
interface Listener {
export interface AirbaseChartRunwayData {
headings: AirbaseChartRunwayHeadingData[],
length: string
}
export interface Listener {
callback: CallableFunction;
name?: string
}
interface ShortcutOptions {
export interface ShortcutOptions {
altKey?: boolean;
callback: CallableFunction;
ctrlKey?: boolean;
@ -252,16 +256,16 @@ interface ShortcutOptions {
shiftKey?: boolean;
}
interface KeyboardShortcutOptions extends ShortcutOptions {
export interface KeyboardShortcutOptions extends ShortcutOptions {
code: string;
event?: "keydown" | "keyup";
}
interface MouseShortcutOptions extends ShortcutOptions {
export interface MouseShortcutOptions extends ShortcutOptions {
button: number;
event: "mousedown" | "mouseup";
}
interface Manager {
export interface Manager {
add: CallableFunction;
}

View File

@ -1,6 +1,7 @@
import { DivIcon } from 'leaflet';
import { CustomMarker } from '../map/markers/custommarker';
import { SVGInjector } from '@tanem/svg-injector';
import { AirbaseChartData, AirbaseOptions } from '../interfaces';
export class Airbase extends CustomMarker {

View File

@ -10,6 +10,7 @@ import { aircraftDatabase } from "../unit/databases/aircraftdatabase";
import { helicopterDatabase } from "../unit/databases/helicopterdatabase";
import { navyUnitDatabase } from "../unit/databases/navyunitdatabase";
import { Popup } from "../popups/popup";
import { AirbasesData, BullseyesData, CommandModeOptions, DateAndTime, MissionData } from "../interfaces";
/** The MissionManager */
export class MissionManager {

View File

@ -24,6 +24,7 @@ import { aircraftDatabase } from "./unit/databases/aircraftdatabase";
import { helicopterDatabase } from "./unit/databases/helicopterdatabase";
import { groundUnitDatabase } from "./unit/databases/groundunitdatabase";
import { navyUnitDatabase } from "./unit/databases/navyunitdatabase";
import { ConfigurationOptions } from "./interfaces";
export class OlympusApp {
/* Global data */

View File

@ -8,6 +8,7 @@ import { Buffer } from "buffer";
import { ROEs, emissionsCountermeasures, reactionsToThreat, states } from "../constants/constants";
import { Dropdown } from "../controls/dropdown";
import { navyUnitDatabase } from "../unit/databases/navyunitdatabase";
import { DateAndTime, UnitBlueprint } from "../interfaces";
export function bearing(lat1: number, lon1: number, lat2: number, lon2: number) {
const φ1 = deg2rad(lat1); // φ, λ in radians

View File

@ -1,3 +1,4 @@
import { Listener } from "../interfaces";
import { EventsManager } from "../other/eventsmanager";
export class PanelEventsManager extends EventsManager {

View File

@ -8,6 +8,7 @@ import { Panel } from "./panel";
import { Switch } from "../controls/switch";
import { ROEDescriptions, ROEs, altitudeIncrements, emissionsCountermeasures, emissionsCountermeasuresDescriptions, maxAltitudeValues, maxSpeedValues, minAltitudeValues, minSpeedValues, reactionsToThreat, reactionsToThreatDescriptions, speedIncrements } from "../constants/constants";
import { ftToM, knotsToMs, mToFt, msToKnots } from "../other/utils";
import { GeneralSettings, Radio, TACAN } from "../interfaces";
export class UnitControlPanel extends Panel {
#altitudeSlider: Slider;

View File

@ -1,3 +1,4 @@
import { Ammo } from "../interfaces";
import { aircraftDatabase } from "../unit/databases/aircraftdatabase";
import { Unit } from "../unit/unit";
import { Panel } from "./panel";

View File

@ -1,6 +1,7 @@
import path from "path";
import { Manager } from "../other/manager";
import { getApp } from "..";
import { OlympusPlugin } from "../interfaces";
/** The plugins manager is responsible for loading and initializing all the plugins. Plugins are located in the public/plugins folder.
* Each plugin must be comprised of a single folder containing a index.js file. Each plugin must set the globalThis.getOlympusPlugin variable to

View File

@ -1,4 +1,5 @@
import { LatLng } from "leaflet";
import { Ammo, Contact, GeneralSettings, Offset, Radio, TACAN } from "../interfaces";
export class DataExtractor {
#seekPosition = 0;

View File

@ -5,6 +5,7 @@ import { ServerStatusPanel } from '../panels/serverstatuspanel';
import { LogPanel } from '../panels/logpanel';
import { Popup } from '../popups/popup';
import { ConnectionStatusPanel } from '../panels/connectionstatuspanel';
import { AirbasesData, BullseyesData, GeneralSettings, MissionData, Radio, ServerRequestOptions, TACAN } from '../interfaces';
export class ServerManager {
#connected: boolean = false;

View File

@ -1,3 +1,4 @@
import { KeyboardShortcutOptions, MouseShortcutOptions, ShortcutOptions } from "../interfaces";
import { keyEventWasInInput } from "../other/utils";
export abstract class Shortcut {

View File

@ -1,6 +1,7 @@
import { LatLng } from "leaflet";
import { getApp } from "../..";
import { GAME_MASTER } from "../../constants/constants";
import { UnitBlueprint } from "../../interfaces";
export class UnitDatabase {
blueprints: { [key: string]: UnitBlueprint } = {};

View File

@ -10,6 +10,7 @@ import { DataExtractor } from '../server/dataextractor';
import { groundUnitDatabase } from './databases/groundunitdatabase';
import { navyUnitDatabase } from './databases/navyunitdatabase';
import { Weapon } from '../weapon/weapon';
import { Ammo, Contact, GeneralSettings, LoadoutBlueprint, ObjectIconOptions, Offset, Radio, TACAN, UnitData } from '../interfaces';
var pathIcon = new Icon({
iconUrl: '/resources/theme/images/markers/marker-icon.png',

View File

@ -13,6 +13,7 @@ import { navyUnitDatabase } from "./databases/navyunitdatabase";
import { TemporaryUnitMarker } from "../map/markers/temporaryunitmarker";
import { Popup } from "../popups/popup";
import { HotgroupPanel } from "../panels/hotgrouppanel";
import { Contact, UnitData, UnitSpawnTable } from "../interfaces";
/** The UnitsManager handles the creation, update, and control of units. Data is strictly updated by the server ONLY. This means that any interaction from the user will always and only
* result in a command to the server, executed by means of a REST PUT request. Any subsequent change in data will be reflected only when the new data is sent back by the server. This strategy allows

View File

@ -5,6 +5,7 @@ import { CustomMarker } from '../map/markers/custommarker';
import { SVGInjector } from '@tanem/svg-injector';
import { DLINK, DataIndexes, GAME_MASTER, IRST, OPTIC, RADAR, VISUAL } from '../constants/constants';
import { DataExtractor } from '../server/dataextractor';
import { ObjectIconOptions } from '../interfaces';
export class Weapon extends CustomMarker {
ID: number;

View File

@ -1,7 +1,8 @@
import { getApp } from "..";
import { Weapon } from "./weapon";
import { DataIndexes, GAME_MASTER } from "../constants/constants";
import { DataIndexes } from "../constants/constants";
import { DataExtractor } from "../server/dataextractor";
import { Contact } from "../interfaces";
/** The WeaponsManager handles the creation and update of weapons. Data is strictly updated by the server ONLY. */
export class WeaponsManager {

View File

@ -23,14 +23,13 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"rootDirs": ["./src", "./@types"], /* Specify the root folder within your source files. */
// "rootDirs": ["./src"], /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": [
"./node_modules/@types",
"./@types"
"./node_modules/@types"
], /* Specify multiple folders that act like './node_modules/@types'. */
"types": [
"leaflet",
@ -47,11 +46,11 @@
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outFile": "./@types/olympus/index.d.ts", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
@ -102,6 +101,6 @@
},
"include": [
"src/**/*.ts",
"@types/*.d.ts"
"src/dom.d.ts"
]
}