Skip to content

Commit

Permalink
Briefing - Make ORBAT Updatable and Trigger a Update on Safe Start En…
Browse files Browse the repository at this point in the history
…ding (#595)

* made orbat updatable

* made orbat update on end of safe start

* moved to replacing text

* updated comments

* removed part of an earlier method that was no longer used

* Removing issues with units in vehicles, unsure of reason it was set
  • Loading branch information
lambdatiger authored Nov 13, 2024
1 parent e00b6cc commit b454871
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
5 changes: 4 additions & 1 deletion addons/briefing/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ if (hasInterface) then {
if (isNull _unit || {!local _unit}) exitWith {};
[_unit] call FUNC(addIntentToZeus);
}] call CBA_fnc_addEventHandler;
["potato_safeStartOff", {
[player, 0] call FUNC(addOrbat);
}] call CBA_fnc_addEventHandler;
};
["CBA_settingsInitialized", {
INFO_2("Briefing Settings: Credits: [%1] Orbat: [%2]",GVAR(brief_addCredits),GVAR(brief_addOrbat)); // Remove Me if no problems found
Expand All @@ -27,7 +30,7 @@ if (hasInterface) then {
} forEach allGroups;
}, []] call CBA_fnc_execNextFrame;
};

["unit", {
TRACE_1("playerChanged eh",ace_player);
[
Expand Down
26 changes: 21 additions & 5 deletions addons/briefing/functions/fnc_addOrbat.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Author: PabstMirror
* Function used to add the order of battle to player's diary
* Function used to add the order of battle to player's diary, or update a
* previously added orbat.
*
* Arguments:
* 0: Unit to add to the OrBat to <OBJECT>
Expand All @@ -16,9 +17,9 @@
TRACE_1("params",_this);

_this spawn {
uiSleep 10;
params ["_unit", ["_delay", 10, [123]]];
uiSleep _delay;

params ["_unit"];
TRACE_1("",_unit);

private _diaryBuilder = [];
Expand All @@ -37,13 +38,28 @@ _this spawn {
_diaryBuilder pushBack format ["<font color='%1' size='16'>%2</font>", _color, (groupId _x)];
{
private _color = _colorSelectArray select (_unit == _x);
private _xIcon = getText (configFile >> "CfgVehicles" >> typeOf (vehicle _x) >> "icon");
private _xIcon = getText (configFile >> "CfgVehicles" >> typeOf _x >> "icon");
private _image = getText (configFile >> "CfgVehicleIcons" >> _xIcon);
_diaryBuilder pushBack format ["<img image='%1' width='16' height='16'/><font color='%2' size='14'>%3</font>", _image, _color, (name _x)];
} forEach (units _x);
};
};
} forEach allGroups;

_unit createDiaryRecord ["diary", ["ORBAT", _diaryBuilder joinString "<br/>"]];
private _diaryEntries = _unit allDiaryRecords "diary";
// find and replace existing orbat pages
private _newDiaryEntryText = _diaryBuilder joinString "<br/>";
private _noOrbatFound = true;
{
_x params ["_idx", "_title", "", "", "", "", "", "", "_record"];
if (_title == "ORBAT") then {
_unit setDiaryRecordText [["diary", _record], ["ORBAT", _newDiaryEntryText]];
_noOrbatFound = false;
};
} forEach _diaryEntries;

// if we didn't find and replace, add one
if (_noOrbatFound) then {
_unit createDiaryRecord ["diary", ["ORBAT", _newDiaryEntryText]];
};
};

0 comments on commit b454871

Please sign in to comment.