Add customString and customInteger to Unit data model

Introduced customString and customInteger fields to the Unit class in both backend (C++) and frontend (TypeScript/React). Updated data indexes, interfaces, and API handling to support setting and retrieving these custom fields. Also added UI elements in the unit control menu to display and handle these new properties.
This commit is contained in:
Pax1601
2025-09-27 18:07:37 +02:00
parent 3eef91fb24
commit a257afca4b
13 changed files with 3946 additions and 2350 deletions

View File

@@ -549,6 +549,8 @@ export enum DataIndexes {
airborne,
cargoWeight,
drawingArguments,
customString,
customInteger,
endOfData = 255,
}

View File

@@ -293,6 +293,8 @@ export interface UnitData {
airborne: boolean;
cargoWeight: number;
drawingArguments: DrawingArgument[];
customString: string;
customInteger: number;
}
export interface LoadoutItemBlueprint {

File diff suppressed because it is too large Load Diff

View File

@@ -161,6 +161,8 @@ export abstract class Unit extends CustomMarker {
#airborne: boolean = false;
#cargoWeight: number = 0;
#drawingArguments: DrawingArgument[] = [];
#customString: string = "";
#customInteger: number = 0;
/* Other members used to draw the unit, mostly ancillary stuff like targets, ranges and so on */
#blueprint: UnitBlueprint | null = null;
@@ -414,6 +416,12 @@ export abstract class Unit extends CustomMarker {
getDrawingArguments() {
return this.#drawingArguments;
}
getCustomString() {
return this.#customString;
}
getCustomInteger() {
return this.#customInteger;
}
static getConstructor(type: string) {
if (type === "GroundUnit") return GroundUnit;
@@ -811,6 +819,12 @@ export abstract class Unit extends CustomMarker {
case DataIndexes.drawingArguments:
this.#drawingArguments = dataExtractor.extractDrawingArguments();
break;
case DataIndexes.customString:
this.#customString = dataExtractor.extractString();
break;
case DataIndexes.customInteger:
this.#customInteger = dataExtractor.extractUInt32();
break;
default:
break;
}
@@ -936,6 +950,8 @@ export abstract class Unit extends CustomMarker {
airborne: this.#airborne,
cargoWeight: this.#cargoWeight,
drawingArguments: this.#drawingArguments,
customString: this.#customString,
customInteger: this.#customInteger
};
}