Merge pull request #456 from Pax1601/small-issues

Removed preferCanvas option for map
This commit is contained in:
Pax1601
2023-10-13 12:49:12 +02:00
committed by GitHub
12 changed files with 47095 additions and 47006 deletions

View File

@@ -545,7 +545,6 @@ declare module "interfaces" {
label: string; label: string;
shortLabel: string; shortLabel: string;
type?: string; type?: string;
rangeType?: string;
loadouts?: LoadoutBlueprint[]; loadouts?: LoadoutBlueprint[];
filename?: string; filename?: string;
liveries?: { liveries?: {
@@ -563,8 +562,8 @@ declare module "interfaces" {
abilities?: string; abilities?: string;
acquisitionRange?: number; acquisitionRange?: number;
engagementRange?: number; engagementRange?: number;
refuelsFrom?: string; canTargetPoint?: boolean;
refuellingType?: string; canRearm?: boolean;
} }
export interface UnitSpawnOptions { export interface UnitSpawnOptions {
roleType: string; roleType: string;
@@ -640,7 +639,6 @@ declare module "unit/databases/unitdatabase" {
getRoles(): string[]; getRoles(): string[];
getTypes(): string[]; getTypes(): string[];
getEras(): string[]; getEras(): string[];
getRanges(): string[];
getByRange(range: string): UnitBlueprint[]; getByRange(range: string): UnitBlueprint[];
getByType(type: string): UnitBlueprint[]; getByType(type: string): UnitBlueprint[];
getByRole(role: string): UnitBlueprint[]; getByRole(role: string): UnitBlueprint[];
@@ -1097,6 +1095,8 @@ declare module "unit/unit" {
getLeader(): Unit | null; getLeader(): Unit | null;
canFulfillRole(roles: string | string[]): boolean; canFulfillRole(roles: string | string[]): boolean;
isInViewport(): boolean; isInViewport(): boolean;
canTargetPoint(): boolean;
canRearm(): boolean;
/********************** Unit commands *************************/ /********************** Unit commands *************************/
addDestination(latlng: L.LatLng): void; addDestination(latlng: L.LatLng): void;
clearDestinations(): void; clearDestinations(): void;

View File

@@ -1,7 +1,8 @@
const { random } = require('@turf/turf');
var basicAuth = require('express-basic-auth') var basicAuth = require('express-basic-auth')
var enc = new TextEncoder(); var enc = new TextEncoder();
const DEMO_UNIT_DATA = { var DEMO_UNIT_DATA = {
["1"]:{ category: "Aircraft", alive: true, human: false, controlled: true, coalition: 2, country: 0, name: "KC-135", unitName: "Cool guy 1-1 who also has a very long name", groupName: "Cool group 1", state: 1, task: "Being cool!", ["1"]:{ category: "Aircraft", alive: true, human: false, controlled: true, coalition: 2, country: 0, name: "KC-135", unitName: "Cool guy 1-1 who also has a very long name", groupName: "Cool group 1", state: 1, task: "Being cool!",
hasTask: true, position: { lat: 37, lng: -116, alt: 1000 }, speed: 200, heading: 45, isTanker: true, isAWACS: false, onOff: true, followRoads: false, fuel: 50, hasTask: true, position: { lat: 37, lng: -116, alt: 1000 }, speed: 200, heading: 45, isTanker: true, isAWACS: false, onOff: true, followRoads: false, fuel: 50,
desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0, desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0,
@@ -141,6 +142,27 @@ class DemoDataGenerator {
}, },
})) }))
for (let i = 8; i < 100; i++) {
var randomUnit = { category: "Aircraft", alive: true, human: false, controlled: true, coalition: 2, country: 0, name: "KC-135", unitName: "Cool guy 1-1 who also has a very long name", groupName: "Cool group 1", state: 1, task: "Being cool!",
hasTask: true, position: { lat: 37 + Math.random(), lng: -116 + Math.random(), alt: 1000 }, speed: 200, heading: 45, isTanker: true, isAWACS: false, onOff: true, followRoads: false, fuel: 50,
desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0,
formationOffset: { x: 0, y: 0, z: 0 },
targetID: 0,
targetPosition: { lat: 0, lng: 0, alt: 0 },
ROE: 1,
reactionToThreat: 1,
emissionsCountermeasures: 1,
TACAN: { isOn: false, XY: 'Y', callsign: 'TKR', channel: 40 },
radio: { frequency: 124000000, callsign: 1, callsignNumber: 1 },
generalSettings: { prohibitAA: false, prohibitAfterburner: false, prohibitAG: false, prohibitAirWpn: false, prohibitJettison: false },
ammo: [{ quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 }, { quantity: 2, name: "A cool missile with a longer name\0Ciao", guidance: 0, category: 0, missileCategory: 0 }, { quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 } , { quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 } , { quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 } , { quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 } , { quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 } , { quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 } , { quantity: 2, name: "A cool missile\0Ciao", guidance: 0, category: 0, missileCategory: 0 } ],
contacts: [{ID: 2, detectionMethod: 1}, {ID: 3, detectionMethod: 4}, {ID: 4, detectionMethod: 1}],
activePath: []
}
DEMO_UNIT_DATA[i.toString()] = randomUnit;
}
this.startTime = Date.now(); this.startTime = Date.now();
} }

View File

@@ -1,7 +1,7 @@
import { LoadoutBlueprint, UnitBlueprint } from "interfaces"; import { LoadoutBlueprint, UnitBlueprint } from "interfaces";
import { UnitEditor } from "./uniteditor"; import { UnitEditor } from "./uniteditor";
import { LoadoutEditor } from "./loadouteditor"; import { LoadoutEditor } from "./loadouteditor";
import { addDropdownInput, addLoadoutsScroll, addNewElementInput, addStringInput } from "./utils"; import { addCheckboxInput, addDropdownInput, addLoadoutsScroll, addNewElementInput, addStringInput } from "./utils";
/** Database editor for Air Units, both Aircraft and Helicopter since they are identical in terms of datbase entries. /** Database editor for Air Units, both Aircraft and Helicopter since they are identical in terms of datbase entries.
* *
@@ -44,8 +44,9 @@ export class AirUnitEditor extends UnitEditor {
addDropdownInput(this.contentDiv2, "Era", blueprint.era, ["WW2", "Early Cold War", "Mid Cold War", "Late Cold War", "Modern"], (value: string) => {blueprint.era = value; }); addDropdownInput(this.contentDiv2, "Era", blueprint.era, ["WW2", "Early Cold War", "Mid Cold War", "Late Cold War", "Modern"], (value: string) => {blueprint.era = value; });
addStringInput(this.contentDiv2, "Filename", blueprint.filename ?? "", "text", (value: string) => { blueprint.filename = value; }); addStringInput(this.contentDiv2, "Filename", blueprint.filename ?? "", "text", (value: string) => { blueprint.filename = value; });
addStringInput(this.contentDiv2, "Cost", String(blueprint.cost) ?? "", "number", (value: string) => { blueprint.cost = parseFloat(value); }); addStringInput(this.contentDiv2, "Cost", String(blueprint.cost) ?? "", "number", (value: string) => { blueprint.cost = parseFloat(value); });
addStringInput(this.contentDiv2, "Rufels from", String(blueprint.refuelsFrom) ?? "", "text", (value: string) => { blueprint.refuelsFrom = value; }); addCheckboxInput(this.contentDiv2, "Can target point", blueprint.canTargetPoint ?? false, (value: boolean) => {blueprint.canTargetPoint = value;})
addStringInput(this.contentDiv2, "Refuelling type", String(blueprint.refuellingType) ?? "", "text", (value: string) => { blueprint.refuellingType = value; }); addStringInput(this.contentDiv2, "Description", blueprint.description ?? "", "text", (value: string) => {blueprint.description = value; });
addStringInput(this.contentDiv2, "Abilities", blueprint.abilities ?? "", "text", (value: string) => {blueprint.abilities = value; });
/* Add a scrollable list of loadouts that the user can edit */ /* Add a scrollable list of loadouts that the user can edit */
var title = document.createElement("label"); var title = document.createElement("label");

View File

@@ -1,6 +1,6 @@
import { UnitBlueprint } from "interfaces"; import { UnitBlueprint } from "interfaces";
import { UnitEditor } from "./uniteditor"; import { UnitEditor } from "./uniteditor";
import { addDropdownInput, addStringInput } from "./utils"; import { addCheckboxInput, addDropdownInput, addStringInput } from "./utils";
/** Database editor for ground units /** Database editor for ground units
* *
@@ -40,6 +40,10 @@ export class GroundUnitEditor extends UnitEditor {
addStringInput(this.contentDiv2, "Muzzle velocity [m/s]", String(blueprint.muzzleVelocity)?? "", "number", (value: string) => {blueprint.muzzleVelocity = parseFloat(value); }); addStringInput(this.contentDiv2, "Muzzle velocity [m/s]", String(blueprint.muzzleVelocity)?? "", "number", (value: string) => {blueprint.muzzleVelocity = parseFloat(value); });
addStringInput(this.contentDiv2, "Aim time [s]", String(blueprint.aimTime)?? "", "number", (value: string) => {blueprint.aimTime = parseFloat(value); }); addStringInput(this.contentDiv2, "Aim time [s]", String(blueprint.aimTime)?? "", "number", (value: string) => {blueprint.aimTime = parseFloat(value); });
addStringInput(this.contentDiv2, "Burst quantity", String(blueprint.shotsToFire)?? "", "number", (value: string) => {blueprint.shotsToFire = Math.round(parseFloat(value)); }); addStringInput(this.contentDiv2, "Burst quantity", String(blueprint.shotsToFire)?? "", "number", (value: string) => {blueprint.shotsToFire = Math.round(parseFloat(value)); });
addCheckboxInput(this.contentDiv2, "Can target point", blueprint.canTargetPoint ?? false, (value: boolean) => {blueprint.canTargetPoint = value;})
addCheckboxInput(this.contentDiv2, "Can rearm", blueprint.canRearm ?? false, (value: boolean) => {blueprint.canRearm = value;})
addStringInput(this.contentDiv2, "Description", blueprint.description ?? "", "text", (value: string) => {blueprint.description = value; });
addStringInput(this.contentDiv2, "Abilities", blueprint.abilities ?? "", "text", (value: string) => {blueprint.abilities = value; });
} }
} }

View File

@@ -1,5 +1,5 @@
import { LoadoutBlueprint } from "interfaces"; import { LoadoutBlueprint } from "interfaces";
import { addLoadoutItemsEditor, addStringInput } from "./utils"; import { addLoadoutItemsEditor, addStringInput, arrayToString, stringToArray } from "./utils";
/** The LoadoutEditor allows the user to edit a loadout /** The LoadoutEditor allows the user to edit a loadout
* *
@@ -40,6 +40,7 @@ export class LoadoutEditor {
var laodout = this.#loadout; var laodout = this.#loadout;
addStringInput(this.#contentDiv, "Name", laodout.name, "text", (value: string) => {laodout.name = value; this.#contentDiv.dispatchEvent(new Event("refresh"));}); addStringInput(this.#contentDiv, "Name", laodout.name, "text", (value: string) => {laodout.name = value; this.#contentDiv.dispatchEvent(new Event("refresh"));});
addStringInput(this.#contentDiv, "Code", laodout.code, "text", (value: string) => {laodout.code = value; }); addStringInput(this.#contentDiv, "Code", laodout.code, "text", (value: string) => {laodout.code = value; });
addStringInput(this.#contentDiv, "Roles", arrayToString(laodout.roles), "text", (value: string) => {laodout.roles = stringToArray(value);});
addLoadoutItemsEditor(this.#contentDiv, this.#loadout); addLoadoutItemsEditor(this.#contentDiv, this.#loadout);
} }
} }

View File

@@ -38,7 +38,7 @@ export function addStringInput(div: HTMLElement, key: string, value: string, typ
* @param value The initial value of the input * @param value The initial value of the input
* @param options The dropdown options * @param options The dropdown options
*/ */
export function addDropdownInput(div: HTMLElement, key: string, value: string, options: string[], callback: CallableFunction) { export function addDropdownInput(div: HTMLElement, key: string, value: string, options: string[], callback: CallableFunction, disabled?: boolean) {
var row = document.createElement("div"); var row = document.createElement("div");
var dt = document.createElement("dt"); var dt = document.createElement("dt");
var dd = document.createElement("dd"); var dd = document.createElement("dd");
@@ -51,6 +51,7 @@ export function addDropdownInput(div: HTMLElement, key: string, value: string, o
select.appendChild(el); select.appendChild(el);
}); });
select.value = value; select.value = value;
select.disabled = disabled?? false;
select.onchange = () => callback(select.value); select.onchange = () => callback(select.value);
dd.appendChild(select); dd.appendChild(select);
row.appendChild(dt); row.appendChild(dt);
@@ -59,6 +60,31 @@ export function addDropdownInput(div: HTMLElement, key: string, value: string, o
div.appendChild(row); div.appendChild(row);
} }
/** Add a checkbox input in the form of String: [ value ]
*
* @param div The HTMLElement that will contain the input
* @param key The key of the input, which will be used as label
* @param value The initial value of the input
* @param callback Callback called when the user enters a new value
* @param disabled If true, the input will be disabled and read only
*/
export function addCheckboxInput(div: HTMLElement, key: string, value: boolean, callback: CallableFunction, disabled?: boolean) {
var row = document.createElement("div");
var dt = document.createElement("dt");
var dd = document.createElement("dd");
dt.innerText = key;
var input = document.createElement("input");
input.checked = value;
input.type = "checkbox";
input.disabled = disabled?? false;
input.onchange = () => callback(input.checked);
dd.appendChild(input);
row.appendChild(dt);
row.appendChild(dd);
row.classList.add("input-row");
div.appendChild(row);
}
/** Create a loadout items editor. This editor allows to add or remove loadout items, as well as changing their name and quantity /** Create a loadout items editor. This editor allows to add or remove loadout items, as well as changing their name and quantity
* *
* @param div The HTMLElement that will contain the editor * @param div The HTMLElement that will contain the editor
@@ -231,3 +257,31 @@ export function addLoadoutsScroll(div: HTMLElement, loadouts: LoadoutBlueprint[]
div.appendChild(loadoutsEl); div.appendChild(loadoutsEl);
} }
/** Converts an array of string into a single string like [val1, val2, val3]
*
* @param array The input array of strings
* @returns The string
*/
export function arrayToString(array: string[]) {
var value = "[";
var firstRole = true;
array.forEach((role: string) => {
value += firstRole? "": ", ";
firstRole = false;
value += role;
})
value += "]";
return value;
}
export function stringToArray(input: string) {
input = input.replace("[", "").replace("]", "");
var values = input.split(",");
var result: string[] = [];
values.forEach((value: string) => {
result.push(value.trim());
})
return result;
}

View File

@@ -169,6 +169,7 @@
.input-row>dd { .input-row>dd {
width: 100%; width: 100%;
text-align: right;
} }
.input-row>dd>* { .input-row>dd>* {
@@ -176,6 +177,11 @@
font-weight: bold; font-weight: bold;
} }
.input-row>dd>*[type="checkbox"] {
width: 20px;
font-weight: bold;
}
.dm-loadout-container { .dm-loadout-container {
max-height: 100%; max-height: 100%;
max-width: 500px; max-width: 500px;

File diff suppressed because it is too large Load Diff

View File

@@ -8586,8 +8586,8 @@
"name": "FuSe-65", "name": "FuSe-65",
"coalition": "", "coalition": "",
"era": "", "era": "",
"label": "EWR FuSe-65 W\u00c3\u00bcrzburg-Riese", "label": "EWR FuSe-65 Würzburg-Riese",
"shortLabel": "EWR FuSe-65 W\u00c3\u00bcrzburg-Riese", "shortLabel": "EWR FuSe-65 Würzburg-Riese",
"type": "EW Radar", "type": "EW Radar",
"enabled": false, "enabled": false,
"liveries": {}, "liveries": {},

View File

@@ -704,7 +704,7 @@
"IND" "IND"
] ]
}, },
"jgsdf\u2014\u20141st_combat_helicopter_unit": { "jgsdf——1st_combat_helicopter_unit": {
"name": "1st Combat Helicopter Unit, Japanese Ground SDF", "name": "1st Combat Helicopter Unit, Japanese Ground SDF",
"countries": [ "countries": [
"JPN" "JPN"
@@ -3859,7 +3859,7 @@
] ]
}, },
"italy e.i. 4b regg. altair": { "italy e.i. 4b regg. altair": {
"name": "E.I. 4\u0412\u00b0 Regg. ALTAIR", "name": "E.I. 4В° Regg. ALTAIR",
"countries": [ "countries": [
"ITA" "ITA"
] ]
@@ -3901,7 +3901,7 @@
] ]
}, },
"italy 15b stormo s.a.r -soccorso": { "italy 15b stormo s.a.r -soccorso": {
"name": "15\u0412\u00b0 Stormo S.A.R -Soccorso", "name": "15В° Stormo S.A.R -Soccorso",
"countries": [ "countries": [
"ITA" "ITA"
] ]

View File

@@ -94,7 +94,7 @@ export class Map extends L.Map {
super(ID, { super(ID, {
zoomSnap: 0, zoomSnap: 0,
zoomDelta: 0.25, zoomDelta: 0.25,
preferCanvas: true, preferCanvas: false,
doubleClickZoom: false, doubleClickZoom: false,
zoomControl: false, zoomControl: false,
boxZoom: false, boxZoom: false,