mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added more code to handle loadouts
This commit is contained in:
parent
28afef8847
commit
099cbfdf75
14
client/.vscode/launch.json
vendored
14
client/.vscode/launch.json
vendored
@ -4,17 +4,6 @@
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Attach to Chrome",
|
||||
"port": 9222,
|
||||
"urlFilter": "http://localhost:3000/*",
|
||||
"request": "attach",
|
||||
"type": "chrome",
|
||||
"webRoot": "${workspaceFolder}/public/",
|
||||
"sourceMapPathOverrides": {
|
||||
"src/*": "${workspaceFolder}/src/*"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
@ -24,7 +13,8 @@
|
||||
"sourceMapPathOverrides": {
|
||||
"src/*": "${workspaceFolder}/src/*"
|
||||
},
|
||||
"preLaunchTask": "server"
|
||||
"preLaunchTask": "server",
|
||||
"port": 9222
|
||||
}
|
||||
]
|
||||
}
|
||||
32
client/@types/olympus/index.d.ts
vendored
32
client/@types/olympus/index.d.ts
vendored
@ -1,7 +1,3 @@
|
||||
declare module "index" {
|
||||
import { OlympusApp } from "app";
|
||||
export function getApp(): OlympusApp;
|
||||
}
|
||||
declare module "map/boxselect" {
|
||||
export var BoxSelect: (new (...args: any[]) => any) & typeof import("leaflet").Class;
|
||||
}
|
||||
@ -338,7 +334,7 @@ declare module "mission/airbase" {
|
||||
}
|
||||
declare module "interfaces" {
|
||||
import { LatLng } from "leaflet";
|
||||
import { OlympusApp } from "app";
|
||||
import { OlympusApp } from "olympusapp";
|
||||
import { Airbase } from "mission/airbase";
|
||||
export interface OlympusPlugin {
|
||||
getName: () => string;
|
||||
@ -1947,7 +1943,7 @@ declare module "server/servermanager" {
|
||||
getPaused(): boolean;
|
||||
}
|
||||
}
|
||||
declare module "app" {
|
||||
declare module "olympusapp" {
|
||||
import { Map } from "map/map";
|
||||
import { MissionManager } from "mission/missionmanager";
|
||||
import { PluginsManager } from "plugin/pluginmanager";
|
||||
@ -1979,6 +1975,26 @@ declare module "app" {
|
||||
* @returns The active coalition
|
||||
*/
|
||||
getActiveCoalition(): string;
|
||||
/**
|
||||
*
|
||||
* @returns The aircraft database
|
||||
*/
|
||||
getAircraftDatabase(): import("unit/databases/aircraftdatabase").AircraftDatabase;
|
||||
/**
|
||||
*
|
||||
* @returns The helicopter database
|
||||
*/
|
||||
getHelicopterDatabase(): import("unit/databases/helicopterdatabase").HelicopterDatabase;
|
||||
/**
|
||||
*
|
||||
* @returns The ground unit database
|
||||
*/
|
||||
getGroundUnitDatabase(): import("unit/databases/groundunitdatabase").GroundUnitDatabase;
|
||||
/**
|
||||
*
|
||||
* @returns The navy unit database
|
||||
*/
|
||||
getNavyUnitDatabase(): import("unit/databases/navyunitdatabase").NavyUnitDatabase;
|
||||
/** Set a message in the login splash screen
|
||||
*
|
||||
* @param status The message to show in the login splash screen
|
||||
@ -1987,3 +2003,7 @@ declare module "app" {
|
||||
start(): void;
|
||||
}
|
||||
}
|
||||
declare module "index" {
|
||||
import { OlympusApp } from "olympusapp";
|
||||
export function getApp(): OlympusApp;
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
"version": "v0.4.4-alpha",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"emit-declarations": "tsc --project tsconfig.json --declaration --emitDeclarationOnly --outfile ./@types/olympus/index.d.ts",
|
||||
"copy": "copy.bat",
|
||||
"start": "npm run copy & concurrently --kill-others \"npm run watch\" \"nodemon ./bin/www\"",
|
||||
"watch": "watchify .\\src\\index.ts --debug -o .\\public\\javascripts\\bundle.js -t [ babelify --global true --presets [ @babel/preset-env ] --extensions '.js'] -p [ tsify --noImplicitAny ]"
|
||||
|
||||
20
client/plugins/databasemanager/.vscode/launch.json
vendored
Normal file
20
client/plugins/databasemanager/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Attach to Chrome",
|
||||
"port": 9222,
|
||||
"urlFilter": "http://localhost:3000/*",
|
||||
"request": "attach",
|
||||
"type": "chrome",
|
||||
"webRoot": "${workspaceFolder}../../public/",
|
||||
"sourceMapPathOverrides": {
|
||||
"src/*": "src/*"
|
||||
},
|
||||
"preLaunchTask": "start"
|
||||
}
|
||||
]
|
||||
}
|
||||
13
client/plugins/databasemanager/.vscode/tasks.json
vendored
Normal file
13
client/plugins/databasemanager/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "start",
|
||||
"type": "shell",
|
||||
"command": "npm run start",
|
||||
"isBackground": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,5 +1,4 @@
|
||||
mkdir .\\..\\..\\public\\plugins\\databasemanager
|
||||
|
||||
copy .\\index.js .\\..\\..\\public\\plugins\\databasemanager\\index.js
|
||||
copy .\\plugin.json .\\..\\..\\public\\plugins\\databasemanager\\plugin.json
|
||||
copy .\\style.css .\\..\\..\\public\\plugins\\databasemanager\\style.css
|
||||
File diff suppressed because one or more lines are too long
161
client/plugins/databasemanager/package-lock.json
generated
161
client/plugins/databasemanager/package-lock.json
generated
@ -1,162 +1,13 @@
|
||||
{
|
||||
"name": "DatabaseManagerPlugin",
|
||||
"version": "v0.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"any-promise": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
|
||||
"integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A=="
|
||||
},
|
||||
"convert-source-map": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz",
|
||||
"integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A=="
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
|
||||
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
|
||||
},
|
||||
"error-ex": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
|
||||
"integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==",
|
||||
"requires": {
|
||||
"is-arrayish": "^0.2.1"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
},
|
||||
"is-arrayish": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
|
||||
"integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg=="
|
||||
},
|
||||
"is-utf8": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
|
||||
"integrity": "sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q=="
|
||||
},
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ=="
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="
|
||||
},
|
||||
"parse-json": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
|
||||
"integrity": "sha512-QR/GGaKCkhwk1ePQNYDRKYZ3mwU9ypsKhB0XyFnLQdomyEqk3e8wpW3V5Jp88zbxK4n5ST1nqo+g9juTpownhQ==",
|
||||
"requires": {
|
||||
"error-ex": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.8",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
|
||||
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"semver": {
|
||||
"version": "6.3.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"strip-bom": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
|
||||
"integrity": "sha512-kwrX1y7czp1E69n2ajbG65mIo9dqvJ+8aBQXOGVxqwvNbsXdFM6Lq37dLAY3mknUwru8CfcCbfOLL/gMo+fi3g==",
|
||||
"requires": {
|
||||
"is-utf8": "^0.2.0"
|
||||
}
|
||||
},
|
||||
"strip-json-comments": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
|
||||
"integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ=="
|
||||
},
|
||||
"through2": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
|
||||
"integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
|
||||
"requires": {
|
||||
"readable-stream": "~2.3.6",
|
||||
"xtend": "~4.0.1"
|
||||
}
|
||||
},
|
||||
"tsconfig": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-5.0.3.tgz",
|
||||
"integrity": "sha512-Cq65A3kVp6BbsUgg9DRHafaGmbMb9EhAc7fjWvudNWKjkbWrt43FnrtZt6awshH1R0ocfF2Z0uxock3lVqEgOg==",
|
||||
"requires": {
|
||||
"any-promise": "^1.3.0",
|
||||
"parse-json": "^2.2.0",
|
||||
"strip-bom": "^2.0.0",
|
||||
"strip-json-comments": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"tsify": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmjs.org/tsify/-/tsify-5.0.4.tgz",
|
||||
"integrity": "sha512-XAZtQ5OMPsJFclkZ9xMZWkSNyMhMxEPsz3D2zu79yoKorH9j/DT4xCloJeXk5+cDhosEibu4bseMVjyPOAyLJA==",
|
||||
"requires": {
|
||||
"convert-source-map": "^1.1.0",
|
||||
"fs.realpath": "^1.0.0",
|
||||
"object-assign": "^4.1.0",
|
||||
"semver": "^6.1.0",
|
||||
"through2": "^2.0.0",
|
||||
"tsconfig": "^5.0.3"
|
||||
}
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
||||
},
|
||||
"xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "DatabaseManagerPlugin",
|
||||
"version": "v0.0.1",
|
||||
"devDependencies": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,10 @@
|
||||
"version": "v0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "browserify ./src/index.ts -p [ tsify --noImplicitAny] > index.js && copy.bat"
|
||||
"build": "browserify ./src/index.ts -p [ tsify --noImplicitAny] > index.js && copy.bat",
|
||||
"start": "npm run copy & concurrently --kill-others \"npm run watch\"",
|
||||
"copy": "copy.bat",
|
||||
"watch": "watchify ./src/index.ts --debug -o ../../public/plugins/databasemanager/index.js -t [ babelify --global true --presets [ @babel/preset-env ] --extensions '.js'] -p [ tsify --noImplicitAny ]"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {}
|
||||
|
||||
41
client/plugins/databasemanager/src/airuniteditor.ts
Normal file
41
client/plugins/databasemanager/src/airuniteditor.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { LoadoutBlueprint, UnitBlueprint } from "interfaces";
|
||||
import { UnitEditor } from "./uniteditor";
|
||||
import { LoadoutEditor } from "./loadouteditor";
|
||||
|
||||
export class AirUnitEditor extends UnitEditor {
|
||||
#loadoutEditor: LoadoutEditor | null = null;
|
||||
|
||||
constructor(scrollDiv: HTMLElement, contentDiv1: HTMLElement, contentDiv2: HTMLElement) {
|
||||
super(scrollDiv, contentDiv1, contentDiv2);
|
||||
this.#loadoutEditor = new LoadoutEditor(this.contentDiv2);
|
||||
}
|
||||
|
||||
setContent(blueprint: UnitBlueprint) {
|
||||
this.contentDiv1.replaceChildren();
|
||||
|
||||
this.addStringInput("Name", blueprint.name);
|
||||
this.addStringInput("Label", blueprint.label);
|
||||
this.addStringInput("Short label", blueprint.shortLabel);
|
||||
this.addDropdownInput("Coalition", blueprint.coalition, ["", "blue", "red"]);
|
||||
this.addDropdownInput("Era", blueprint.era, ["WW2", "Early Cold War", "Mid Cold War", "Late Cold War", "Modern"]);
|
||||
this.addStringInput("Filename", blueprint.filename?? "");
|
||||
this.addStringInput("Cost", String(blueprint.cost)?? "", "number");
|
||||
|
||||
this.addLoadoutList(blueprint.loadouts?? []);
|
||||
}
|
||||
|
||||
addLoadoutList(loadouts: LoadoutBlueprint[]) {
|
||||
var loadoutsEl = document.createElement("div");
|
||||
loadoutsEl.classList.add("dc-scroll-container", "dc-loadout-container")
|
||||
loadouts.forEach((loadout: LoadoutBlueprint) => {
|
||||
var div = document.createElement("div");
|
||||
loadoutsEl.appendChild(div);
|
||||
div.textContent = loadout.name;
|
||||
div.onclick = () => {
|
||||
this.#loadoutEditor?.setLoadout(loadout);
|
||||
this.#loadoutEditor?.show();
|
||||
};
|
||||
});
|
||||
this.contentDiv1.appendChild(loadoutsEl);
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,16 @@
|
||||
const SHOW_CONTROL_TIPS = "Show control tips"
|
||||
import { OlympusPlugin } from "interfaces";
|
||||
import { AirUnitEditor } from "./airuniteditor";
|
||||
import { OlympusApp } from "olympusapp";
|
||||
|
||||
export class DatabaseManagerPlugin implements OlympusPlugin {
|
||||
#app: OlympusApp | null = null;
|
||||
|
||||
#element: HTMLElement;
|
||||
#app: any;
|
||||
#scrollDiv: HTMLElement;
|
||||
#contentDiv: HTMLElement;
|
||||
#contentDiv1: HTMLElement;
|
||||
#contentDiv2: HTMLElement;
|
||||
|
||||
#aircraftEditor: AirUnitEditor;
|
||||
|
||||
constructor() {
|
||||
this.#element = document.createElement("div");
|
||||
@ -17,9 +23,15 @@ export class DatabaseManagerPlugin implements OlympusPlugin {
|
||||
this.#scrollDiv.classList.add("dc-scroll-container");
|
||||
this.#element.appendChild(this.#scrollDiv);
|
||||
|
||||
this.#contentDiv = document.createElement("div");
|
||||
this.#contentDiv.classList.add("dc-content-container");
|
||||
this.#element.appendChild(this.#contentDiv);
|
||||
this.#contentDiv1 = document.createElement("div");
|
||||
this.#contentDiv1.classList.add("dc-content-container");
|
||||
this.#element.appendChild(this.#contentDiv1);
|
||||
|
||||
this.#contentDiv2 = document.createElement("div");
|
||||
this.#contentDiv2.classList.add("dc-content-container");
|
||||
this.#element.appendChild(this.#contentDiv2);
|
||||
|
||||
this.#aircraftEditor = new AirUnitEditor(this.#scrollDiv, this.#contentDiv1, this.#contentDiv2);
|
||||
}
|
||||
|
||||
getName() {
|
||||
@ -29,15 +41,11 @@ export class DatabaseManagerPlugin implements OlympusPlugin {
|
||||
initialize(app: any) {
|
||||
this.#app = app;
|
||||
|
||||
var aircraftDatabase = this.#app.getAircraftDatabase();
|
||||
var blueprints: {[key: string]: UnitBlueprint} = aircraftDatabase.getBlueprints();
|
||||
|
||||
for (let key in blueprints) {
|
||||
var div = document.createElement("div");
|
||||
this.#scrollDiv.appendChild(div);
|
||||
div.textContent = key;
|
||||
div.onclick = () => this.#setContent(blueprints[key]);
|
||||
}
|
||||
var aircraftDatabase = this.#app?.getAircraftDatabase();
|
||||
if (aircraftDatabase != null) {
|
||||
this.#aircraftEditor.setDatabase(aircraftDatabase);
|
||||
this.#aircraftEditor.show();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -49,23 +57,4 @@ export class DatabaseManagerPlugin implements OlympusPlugin {
|
||||
toggle(bool?: boolean) {
|
||||
this.getElement().classList.toggle("hide", bool);
|
||||
}
|
||||
|
||||
#setContent(blueprint: UnitBlueprint) {
|
||||
this.#contentDiv.replaceChildren();
|
||||
|
||||
for (var key in blueprint) {
|
||||
if (typeof blueprint[key as keyof UnitBlueprint] === "string")
|
||||
{
|
||||
var dt = document.createElement("dt");
|
||||
var dd = document.createElement("dd");
|
||||
dt.innerText = key;
|
||||
var input = document.createElement("input");
|
||||
input.value = blueprint[key as keyof UnitBlueprint] as string;
|
||||
input.textContent = blueprint[key as keyof UnitBlueprint] as string;
|
||||
dd.appendChild(input);
|
||||
this.#contentDiv.appendChild(dt);
|
||||
this.#contentDiv.appendChild(dd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
client/plugins/databasemanager/src/loadouteditor.ts
Normal file
45
client/plugins/databasemanager/src/loadouteditor.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { LoadoutBlueprint, LoadoutItemBlueprint } from "interfaces";
|
||||
|
||||
export class LoadoutEditor {
|
||||
#contentDiv: HTMLElement;
|
||||
#loadout: LoadoutBlueprint | null = null;
|
||||
|
||||
constructor(contentDiv: HTMLElement) {
|
||||
this.#contentDiv = contentDiv;
|
||||
}
|
||||
|
||||
setLoadout(loadout: LoadoutBlueprint) {
|
||||
this.#loadout = loadout;
|
||||
}
|
||||
|
||||
show() {
|
||||
this.#contentDiv.replaceChildren();
|
||||
|
||||
if (this.#loadout) {
|
||||
this.addStringInput("Name", this.#loadout.name);
|
||||
this.addStringInput("Code", this.#loadout.code);
|
||||
|
||||
var itemsEl = document.createElement("div");
|
||||
itemsEl.classList.add("dc-scroll-container", "dc-items-container");
|
||||
this.#loadout.items.forEach((item: LoadoutItemBlueprint) => {
|
||||
var div = document.createElement("div");
|
||||
itemsEl.appendChild(div);
|
||||
div.textContent = item.name;
|
||||
})
|
||||
this.#contentDiv.appendChild(itemsEl);
|
||||
}
|
||||
}
|
||||
|
||||
addStringInput(key: string, value: string, type?: string) {
|
||||
var dt = document.createElement("dt");
|
||||
var dd = document.createElement("dd");
|
||||
dt.innerText = key;
|
||||
var input = document.createElement("input");
|
||||
input.value = value;
|
||||
input.textContent = value;
|
||||
input.type = type?? "text";
|
||||
dd.appendChild(input);
|
||||
this.#contentDiv.appendChild(dt);
|
||||
this.#contentDiv.appendChild(dd);
|
||||
}
|
||||
}
|
||||
65
client/plugins/databasemanager/src/uniteditor.ts
Normal file
65
client/plugins/databasemanager/src/uniteditor.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import { LoadoutBlueprint, UnitBlueprint } from "interfaces";
|
||||
import { UnitDatabase } from "unit/databases/unitdatabase";
|
||||
|
||||
export abstract class UnitEditor {
|
||||
database: UnitDatabase | null = null;
|
||||
scrollDiv: HTMLElement;
|
||||
contentDiv1: HTMLElement;
|
||||
contentDiv2: HTMLElement;
|
||||
|
||||
constructor(scrollDiv: HTMLElement, contentDiv1: HTMLElement, contentDiv2: HTMLElement) {
|
||||
this.scrollDiv = scrollDiv;
|
||||
this.contentDiv1 = contentDiv1;
|
||||
this.contentDiv2 = contentDiv2;
|
||||
}
|
||||
|
||||
setDatabase(database: any) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
show() {
|
||||
if (this.database !== null) {
|
||||
var blueprints: {[key: string]: UnitBlueprint} = this.database.getBlueprints();
|
||||
|
||||
for (let key in blueprints) {
|
||||
var div = document.createElement("div");
|
||||
this.scrollDiv.appendChild(div);
|
||||
div.textContent = key;
|
||||
div.onclick = () => this.setContent(blueprints[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addStringInput(key: string, value: string, type?: string) {
|
||||
var dt = document.createElement("dt");
|
||||
var dd = document.createElement("dd");
|
||||
dt.innerText = key;
|
||||
var input = document.createElement("input");
|
||||
input.value = value;
|
||||
input.textContent = value;
|
||||
input.type = type?? "text";
|
||||
dd.appendChild(input);
|
||||
this.contentDiv1.appendChild(dt);
|
||||
this.contentDiv1.appendChild(dd);
|
||||
}
|
||||
|
||||
addDropdownInput(key: string, value: string, options: string[]) {
|
||||
var dt = document.createElement("dt");
|
||||
var dd = document.createElement("dd");
|
||||
dt.innerText = key;
|
||||
var select = document.createElement("select");
|
||||
options.forEach((option: string) => {
|
||||
var el = document.createElement("option");
|
||||
el.value = option;
|
||||
el.innerText = option;
|
||||
select.appendChild(el);
|
||||
});
|
||||
select.value = value;
|
||||
dd.appendChild(select);
|
||||
this.contentDiv1.appendChild(dt);
|
||||
this.contentDiv1.appendChild(dd);
|
||||
}
|
||||
|
||||
abstract setContent(blueprint: UnitBlueprint): void;
|
||||
|
||||
}
|
||||
@ -1,12 +1,12 @@
|
||||
#database-control-panel {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.dc-scroll-container {
|
||||
overflow-y: scroll;
|
||||
max-height: 600px;
|
||||
width: 300px;
|
||||
margin: 10px;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
@ -27,7 +27,6 @@
|
||||
}
|
||||
|
||||
.dc-content-container {
|
||||
width: 300px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
@ -35,3 +34,12 @@
|
||||
width: 100%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.dc-loadout-container {
|
||||
max-height: 200px;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.dc-items-container {
|
||||
max-height: 200px;
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
// "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. */
|
||||
@ -98,7 +98,6 @@
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
},
|
||||
"include": [
|
||||
"src/*.ts",
|
||||
"../../@types/*.d.ts"
|
||||
"src/*.ts"
|
||||
]
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
import { LatLng } from "leaflet";
|
||||
import { OlympusApp } from "./app";
|
||||
import { OlympusApp } from "./olympusapp";
|
||||
import { Airbase } from "./mission/airbase";
|
||||
|
||||
export interface OlympusPlugin {
|
||||
|
||||
@ -48,9 +48,9 @@
|
||||
/* Emit */
|
||||
"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": "./@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. */
|
||||
//"outFile": "./@types/olympus/index.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. */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user