Database fixes

This commit is contained in:
Pax1601 2023-10-11 15:20:24 +02:00
parent a29eb3d343
commit 4cdf82cb14
9 changed files with 32247 additions and 32186 deletions

View File

@ -196,11 +196,15 @@ declare module "constants/constants" {
export const IADSDensities: {
[key: string]: number;
};
export const SHOW_CONTACT_LINES = "Show unit contact lines";
export const HIDE_GROUP_MEMBERS = "Hide group members when zoomed out";
export const SHOW_UNIT_LABELS = "Show unit labels";
export const SHOW_UNIT_PATHS = "Show unit paths";
export const SHOW_UNIT_TARGETS = "Show unit targets";
export const SHOW_UNIT_LABELS = "Show unit labels (L)";
export const SHOW_UNITS_ENGAGEMENT_RINGS = "Show units threat range rings (Q)";
export const HIDE_UNITS_SHORT_RANGE_RINGS = "Hide short range units threat range rings (R)";
export const SHOW_UNITS_ACQUISITION_RINGS = "Show units detection range rings (E)";
export const FILL_SELECTED_RING = "Fill the threat range rings of selected units (F)";
export const SHOW_UNIT_CONTACTS = "Show selected units contact lines";
export const SHOW_UNIT_PATHS = "Show selected unit paths";
export const SHOW_UNIT_TARGETS = "Show selected unit targets";
export enum DataIndexes {
startOfData = 0,
category = 1,
@ -244,6 +248,11 @@ declare module "constants/constants" {
operateAs = 39,
endOfData = 255
}
export const MGRS_PRECISION_10KM = 2;
export const MGRS_PRECISION_1KM = 3;
export const MGRS_PRECISION_100M = 4;
export const MGRS_PRECISION_10M = 5;
export const MGRS_PRECISION_1M = 6;
}
declare module "map/markers/custommarker" {
import { Map, Marker } from "leaflet";
@ -526,9 +535,11 @@ declare module "interfaces" {
roles: string[];
code: string;
name: string;
enabled: boolean;
}
export interface UnitBlueprint {
name: string;
enabled: boolean;
coalition: string;
era: string;
label: string;
@ -623,7 +634,7 @@ declare module "unit/databases/unitdatabase" {
getCategory(): string;
getByName(name: string): UnitBlueprint | null;
getByLabel(label: string): UnitBlueprint | null;
getBlueprints(): {
getBlueprints(includeDisabled?: boolean): {
[key: string]: UnitBlueprint;
};
getRoles(): string[];
@ -699,6 +710,19 @@ declare module "other/utils" {
export const zeroPad: (num: number, places: number) => string;
export function similarity(s1: string, s2: string): number;
export function editDistance(s1: string, s2: string): any;
export type MGRS = {
bandLetter: string;
columnLetter: string;
easting: string;
groups: string[];
northing: string;
precision: number;
rowLetter: string;
string: string;
zoneNumber: string;
};
export function latLngToMGRS(lat: number, lng: number, precision?: number): MGRS | false;
export function latLngToUTM(lat: number, lng: number): any;
export function latLngToMercator(lat: number, lng: number): {
x: number;
y: number;
@ -713,6 +737,7 @@ declare module "other/utils" {
export function ftToM(ft: number): number;
export function mToFt(m: number): number;
export function mToNm(m: number): number;
export function nmToM(nm: number): number;
export function nmToFt(nm: number): number;
export function polyContains(latlng: LatLng, polygon: Polygon): boolean;
export function randomPointInPoly(polygon: Polygon): LatLng;
@ -723,7 +748,7 @@ declare module "other/utils" {
ranges?: string[];
eras?: string[];
}): UnitBlueprint | null;
export function getMarkerCategoryByName(name: string): "aircraft" | "groundunit-sam" | "groundunit-other" | "groundunit-sam-radar" | "groundunit-sam-launcher" | "groundunit-ewr" | "helicopter";
export function getMarkerCategoryByName(name: string): "aircraft" | "helicopter" | "groundunit-sam" | "groundunit-other" | "groundunit-sam-radar" | "groundunit-sam-launcher" | "groundunit-ewr";
export function getUnitDatabaseByCategory(category: string): import("unit/databases/aircraftdatabase").AircraftDatabase | import("unit/databases/helicopterdatabase").HelicopterDatabase | import("unit/databases/groundunitdatabase").GroundUnitDatabase | import("unit/databases/navyunitdatabase").NavyUnitDatabase | null;
export function base64ToBytes(base64: string): ArrayBufferLike;
export function enumToState(state: number): string;
@ -769,6 +794,8 @@ declare module "controls/unitspawnmenu" {
reset(): void;
setCountries(): void;
refreshOptions(): void;
showCirclesPreviews(): void;
clearCirclesPreviews(): void;
setAirbase(airbase: Airbase | undefined): void;
setLatLng(latlng: LatLng): void;
setMaxUnitCount(maxUnitCount: number): void;
@ -1102,6 +1129,7 @@ declare module "unit/unit" {
simulateFireFight(latlng: LatLng, targetGroundElevation: number | null): void;
scenicAAA(): void;
missOnPurpose(): void;
landAtPoint(latlng: LatLng): void;
/***********************************************/
getActions(): {
[key: string]: {
@ -1468,7 +1496,10 @@ declare module "mission/missionmanager" {
declare module "panels/connectionstatuspanel" {
import { Panel } from "panels/panel";
export class ConnectionStatusPanel extends Panel {
#private;
constructor(ID: string);
setElapsedTime(time: string): void;
setMissionTime(time: string): void;
showDisconnected(): void;
showConnected(): void;
showServerPaused(): void;
@ -1838,6 +1869,11 @@ declare module "unit/unitsmanager" {
*
*/
selectedUnitsMissOnPurpose(): void;
/** Instruct units to land at specific point
*
* @param latlng Point where to land
*/
selectedUnitsLandAtPoint(latlng: LatLng): void;
/*********************** Control operations on selected units ************************/
/** See getUnitsCategories for more info
*
@ -2027,6 +2063,7 @@ declare module "server/servermanager" {
simulateFireFight(ID: number, latlng: LatLng, altitude: number, callback?: CallableFunction): void;
scenicAAA(ID: number, coalition: string, callback?: CallableFunction): void;
missOnPurpose(ID: number, coalition: string, callback?: CallableFunction): void;
landAtPoint(ID: number, latlng: LatLng, callback?: CallableFunction): void;
setAdvacedOptions(ID: number, isTanker: boolean, isAWACS: boolean, TACAN: TACAN, radio: Radio, generalSettings: GeneralSettings, callback?: CallableFunction): void;
setCommandModeOptions(restrictSpawns: boolean, restrictToCoalition: boolean, spawnPoints: {
blue: number;

View File

@ -40,8 +40,8 @@ export class AirUnitEditor extends UnitEditor {
addStringInput(this.contentDiv2, "Name", blueprint.name, "text", (value: string) => { blueprint.name = value; }, true);
addStringInput(this.contentDiv2, "Label", blueprint.label, "text", (value: string) => { blueprint.label = value; });
addStringInput(this.contentDiv2, "Short label", blueprint.shortLabel, "text", (value: string) => { blueprint.shortLabel = value; });
addDropdownInput(this.contentDiv2, "Coalition", blueprint.coalition, ["", "blue", "red"],);
addDropdownInput(this.contentDiv2, "Era", blueprint.era, ["WW2", "Early Cold War", "Mid Cold War", "Late Cold War", "Modern"]);
addDropdownInput(this.contentDiv2, "Coalition", blueprint.coalition, ["", "blue", "red"], (value: string) => {blueprint.coalition = 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, "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; });
@ -73,7 +73,8 @@ export class AirUnitEditor extends UnitEditor {
label: "",
shortLabel: "",
era: "",
loadouts: []
loadouts: [],
enabled: true
}
this.show();
this.setBlueprint(this.database.blueprints[key]);
@ -91,7 +92,8 @@ export class AirUnitEditor extends UnitEditor {
code: "",
fuel: 1,
items: [],
roles: []
roles: [],
enabled: true
})
this.setBlueprint(this.blueprint);
}

View File

@ -30,8 +30,8 @@ export class GroundUnitEditor extends UnitEditor {
addStringInput(this.contentDiv2, "Label", blueprint.label, "text", (value: string) => {blueprint.label = value; });
addStringInput(this.contentDiv2, "Short label", blueprint.shortLabel, "text", (value: string) => {blueprint.shortLabel = value; });
addStringInput(this.contentDiv2, "Type", blueprint.type?? "", "text", (value: string) => {blueprint.type = value; });
addDropdownInput(this.contentDiv2, "Coalition", blueprint.coalition, ["", "blue", "red"],);
addDropdownInput(this.contentDiv2, "Era", blueprint.era, ["WW2", "Early Cold War", "Mid Cold War", "Late Cold War", "Modern"]);
addDropdownInput(this.contentDiv2, "Coalition", blueprint.coalition, ["", "blue", "red"], (value: string) => {blueprint.coalition = 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, "Cost", String(blueprint.cost)?? "", "number", (value: string) => {blueprint.cost = parseFloat(value); });
addStringInput(this.contentDiv2, "Acquisition range [m]", String(blueprint.acquisitionRange)?? "", "number", (value: string) => {blueprint.acquisitionRange = parseFloat(value); });
@ -54,7 +54,8 @@ export class GroundUnitEditor extends UnitEditor {
coalition: "",
label: "",
shortLabel: "",
era: ""
era: "",
enabled: true
}
this.show();
this.setBlueprint(this.database.blueprints[key]);

View File

@ -30,8 +30,8 @@ export class NavyUnitEditor extends UnitEditor {
addStringInput(this.contentDiv2, "Label", blueprint.label, "text", (value: string) => {blueprint.label = value; });
addStringInput(this.contentDiv2, "Short label", blueprint.shortLabel, "text", (value: string) => {blueprint.shortLabel = value; });
addStringInput(this.contentDiv2, "Type", blueprint.type?? "", "text", (value: string) => {blueprint.type = value; });
addDropdownInput(this.contentDiv2, "Coalition", blueprint.coalition, ["", "blue", "red"],);
addDropdownInput(this.contentDiv2, "Era", blueprint.era, ["WW2", "Early Cold War", "Mid Cold War", "Late Cold War", "Modern"]);
addDropdownInput(this.contentDiv2, "Coalition", blueprint.coalition, ["", "blue", "red"], (value: string) => {blueprint.coalition = 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, "Cost", String(blueprint.cost)?? "", "number", (value: string) => {blueprint.cost = parseFloat(value); });
addStringInput(this.contentDiv2, "Barrel height [m]", String(blueprint.barrelHeight)?? "", "number", (value: string) => {blueprint.barrelHeight = parseFloat(value); });
@ -50,7 +50,8 @@ export class NavyUnitEditor extends UnitEditor {
coalition: "",
label: "",
shortLabel: "",
era: ""
era: "",
enabled: true
}
this.show();
this.setBlueprint(this.database.blueprints[key]);

View File

@ -45,7 +45,7 @@ export abstract class UnitEditor {
* @param database The database that the editor will operate on
*/
setDatabase(database: UnitDatabase) {
this.database = JSON.parse(JSON.stringify(database));
this.database = JSON.parse(JSON.stringify({blueprints: database.getBlueprints(true)}));
}
/** Show the editor

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 options The dropdown options
*/
export function addDropdownInput(div: HTMLElement, key: string, value: string, options: string[]) {
export function addDropdownInput(div: HTMLElement, key: string, value: string, options: string[], callback: CallableFunction) {
var row = document.createElement("div");
var dt = document.createElement("dt");
var dd = document.createElement("dd");
@ -51,6 +51,7 @@ export function addDropdownInput(div: HTMLElement, key: string, value: string, o
select.appendChild(el);
});
select.value = value;
select.onchange = () => callback(select.value);
dd.appendChild(select);
row.appendChild(dt);
row.appendChild(dd);
@ -164,6 +165,15 @@ export function addBlueprintsScroll(div: HTMLElement, database: {blueprints: {[k
text.onclick = () => callback(key);
rowDiv.appendChild(text);
let checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.checked = blueprints[key].enabled;
checkbox.onclick = () => {
console.log(checkbox.checked);
blueprints[key].enabled = checkbox.checked;
}
rowDiv.appendChild(checkbox);
/* This button allows to remove an element from the list. It requires a refresh. */
var button = document.createElement("button");
button.innerText = "X";
@ -199,7 +209,16 @@ export function addLoadoutsScroll(div: HTMLElement, loadouts: LoadoutBlueprint[]
/* The "Empty loadout" can not be removed */
if (loadout.name !== "Empty loadout") {
/* This button allows to remove an element from the list. It requires a refresh. */
let checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.checked = loadout.enabled;
checkbox.onclick = () => {
console.log(checkbox.checked);
loadout.enabled = checkbox.checked;
}
rowDiv.appendChild(checkbox);
/* This button allows to remove an element from the list. It requires a refresh. */
var button = document.createElement("button");
button.innerText = "X";
button.onclick = () => {

File diff suppressed because it is too large Load Diff

View File

@ -191,6 +191,7 @@ export interface LoadoutBlueprint {
roles: string[];
code: string;
name: string;
enabled: boolean;
}
export interface UnitBlueprint {

View File

@ -63,14 +63,14 @@
<div id="tanker-on" class="switch-control">
<h4>Enable tanker</h4>
<div id="tanker-on-switch" class="ol-switch" title="Enables the ability to operate as air to air refueling tanker. A/A TACAN, radio frequency and callsign set in Settings dialog."></div>
<div>Instructs the unit to operate as AAR tanker. More options available in Settings dialog.</div>
<div id="tanker-on-switch" class="ol-switch"></div>
<div>Instructs the unit to operate as AAR tanker. A/A TACAN, radio frequency and callsign set in Settings dialog.</div>
</div>
<div id="AWACS-on" class="switch-control">
<h4>Airborne Early Warning</h4>
<div id="AWACS-on-switch" class="ol-switch" title="Enables datalink and AI radio calls. The unit will operate as Overlord. Radio frequency and callsign set in Settings dialog."></div>
<div>Instructs the unit to operate as airborne early warning. More options available in Settings dialog.</div>
<div id="AWACS-on-switch" class="ol-switch"></div>
<div>Enables datalink and AI radio calls. Radio frequency and callsign set in Settings dialog.</div>
</div>
<div id="operate-as" class="switch-control">