WIP: add asset diary pages

This commit is contained in:
2024-02-02 01:06:43 -08:00
parent 1e4a5a79a8
commit 3f5c6c5a59
19 changed files with 682 additions and 56 deletions

View File

@@ -0,0 +1,119 @@
// create diary records
private _vehiclesByBase = call milsim_fbcb2_assets_fnc_getAssetsByBase;
if (count _vehiclesByBase isEqualTo 0) exitWith {false};
private _vehicles = [];
{
_vehicles append (_x#1);
} forEach _vehiclesByBase;
if (count _vehicles isEqualTo 0) exitWith {false};
private _distinctVehiclesClassNames = [];
{
_distinctVehiclesClassNames pushBackUnique (typeOf _x);
} forEach _vehicles;
// ForEach unique vehicle class name, we'll find the first and gather its info
{
private _className = _x;
private _vehiclesOfThisKind = _vehicles select {typeOf _x isEqualTo _className};
// This should never happen, but...
if (count _vehiclesOfThisKind isEqualTo 0) then {continue};
// Take the first vehicle as a representative
private _representativeVehicle = _vehiclesOfThisKind#0;
private _vehicleCfg = configOf _representativeVehicle;
// Process the vehicle for extended info
// Exclusion list for display names
if (
((configOf _representativeVehicle) call BIS_fnc_displayName)
in ["Helicopter"]
) then {continue};
// Get the vehicle data
private _processed = [_representativeVehicle] call milsim_fbcb2_assets_fnc_getVehicleData;
if (isNil "_processed") then {continue};
_processed params ["_vehicleCfg", "_displayName", "_diaryTextSections"];
_diaryTextSections params [
"_title",
"_image",
"_info",
"_capacity"
// "_weapons",
// "_pylonWeapons",
// "_inventory"
];
// Create the diary record
private _recordText = [];
// Add the title and image
_recordText pushBack _title;
_recordText pushBack _image;
_recordText pushBack "<br/>";
_recordText pushBack format[
"COUNT ACTIVE: %1",
count _vehiclesOfThisKind
];
// Here, we'll create a link to show markers on the map for all vehicles of this kind
private _randomColor = selectRandom [
["ColorRed", "#FF0000", "Red"],
["ColorGreen", "#00FF00", "Green"],
["ColorBlue", "#0000FF", "Blue"],
["ColorYellow", "#FFFF00", "Yellow"],
["ColorWhite", "#FFFFFF", "White"]
];
private _vehicleCfg = configFile >> "CfgVehicles" >> _className;
// get 'picture' for record
private _icon = getText(_vehicleCfg >> "picture");
// determine marker type
private _markerType = "mil_dot";
switch (true) do {
case (_representativeVehicle isKindOf "Helicopter"): {
_markerType = "loc_heli";
};
case (_representativeVehicle isKindOf "Air"): {
_markerType = "loc_plane";
};
default {
_markerType = "loc_truck";
};
};
_recordText pushBack format[
"<execute expression='[""%1"",""%2"",""%3"",%4] call milsim_fbcb2_assets_fnc_showMarkersOnMap'>SHOW MARKERS at vehicle positions</execute> (in %5)",
_className,
_markerType,
_randomColor#0,
(_vehiclesOfThisKind apply {getPosASL _x}),
format["<font color='%1'>%2</font>", _randomColor#1, _randomColor#2]
];
// Link to hide markers
_recordText pushBack "<execute expression=""call milsim_fbcb2_assets_fnc_removeMarkersOnMap"">REMOVE ALL MARKERS showing asset positions</execute>" + "<br/>";
// Link to update asset diary entries
_recordText pushBack "<execute expression=""call milsim_fbcb2_assets_fnc_updateAssetDiary"">UPDATE ENTRIES for all assets</execute>" + "<br/>";
// Add info and capacity sections
_recordText pushBack _info;
_recordText pushBack _capacity;
[
milsim_fbcb2_subjectAssetsID,
format[
"%1x %2",
count _vehiclesOfThisKind,
(configOf _representativeVehicle) call BIS_fnc_displayName
],
_recordText joinString "<br/>",
_icon
] call milsim_fnc_createOrUpdateDiaryRecord;
// "\A3\ui_f\data\igui\cfg\simpleTasks\types\car_ca.paa"
} forEach _distinctVehiclesClassNames;
true;