186 lines
5.0 KiB
Plaintext
186 lines
5.0 KiB
Plaintext
#include "..\script_component.hpp"
|
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
// create diary records
|
|
|
|
// remove any existing asset map markers
|
|
call FUNC(removeMarkersOnMap);
|
|
|
|
// remove existing asset records
|
|
call FUNC(removeAssetDiaryRecords);
|
|
|
|
// get all vehicles by base
|
|
private _vehiclesByBase = call FUNC(getAssetsByBase);
|
|
if (count _vehiclesByBase isEqualTo 0) exitWith {false};
|
|
|
|
// put vehicles from each base into a single array
|
|
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;
|
|
private _vehicleCallsign = toUpper (
|
|
_representativeVehicle getVariable [
|
|
QGVAR(callsign),
|
|
"NONE ASSIGNED"
|
|
]
|
|
);
|
|
|
|
// 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 FUNC(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[
|
|
"CALLSIGN: %1",
|
|
_vehicleCallsign
|
|
];
|
|
_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";
|
|
};
|
|
case (_representativeVehicle isKindOf "Ship"): {
|
|
_markerType = "loc_boat";
|
|
};
|
|
case (_representativeVehicle isKindOf "Car"): {
|
|
_markerType = "loc_car";
|
|
};
|
|
default {
|
|
_markerType = "loc_truck";
|
|
};
|
|
};
|
|
|
|
// Link to show markers
|
|
private _showMarkersText = format[
|
|
"<execute expression='[""%1"",""%2"",""%3"",%4] call FUNC(showMarkersOnMap'>SHOW MARKERS at vehicle positions</execute> (in %5)",
|
|
_className,
|
|
_markerType,
|
|
_randomColor#0,
|
|
(_vehiclesOfThisKind apply {
|
|
format["%1", _x call BIS_fnc_netId]
|
|
}),
|
|
format["<font color='%1'>%2</font>", _randomColor#1, _randomColor#2]
|
|
];
|
|
_recordText pushBack _showMarkersText;
|
|
|
|
// Link to hide markers
|
|
_recordText pushBack "<execute expression=""call FUNC(removeMarkersOnMap"">REMOVE ALL MARKERS showing asset positions</execute>";
|
|
|
|
// Link to update asset diary entries
|
|
_recordText pushBack "<execute expression=""call FUNC(updateAssetDiary"">UPDATE ENTRIES for all assets</execute>";
|
|
|
|
_recordText pushBack format[
|
|
"<font size='10' color='#777777'>%1</font>",
|
|
"Notes:<br/>
|
|
- Markers are only displayed on your local machine.<br/>
|
|
- The REMOVE ALL option will remove all assets' markers from the map.<br/>
|
|
- UPDATE ENTRIES will update the asset diary with the latest information (~5 minutes at most)."
|
|
];
|
|
|
|
|
|
|
|
// Add info and capacity sections
|
|
_recordText pushBack _info;
|
|
_recordText pushBack _capacity;
|
|
|
|
|
|
private _subjectID = "";
|
|
switch (true) do {
|
|
case (_representativeVehicle isKindOf "Helicopter"): {
|
|
_subjectID = EGVAR(fbcb2,subjectAssetsRotaryID);
|
|
};
|
|
case (_representativeVehicle isKindOf "Air"): {
|
|
_subjectID = EGVAR(fbcb2,subjectAssetsFixedWingID);
|
|
};
|
|
default {
|
|
_subjectID = EGVAR(fbcb2,subjectAssetsGroundID);
|
|
};
|
|
};
|
|
|
|
[
|
|
_subjectID,
|
|
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;
|
|
|
|
// log to RPT
|
|
[
|
|
QUOTE(COMPONENT),
|
|
"UPDATED ASSET DIARY",
|
|
[
|
|
["assetCount", count _vehicles],
|
|
["distinctAssetCount", count _distinctVehiclesClassNames]
|
|
]
|
|
] call EFUNC(util,log);
|
|
|
|
true; |