From 445c3708159bac15e5a535e095da324666894c07 Mon Sep 17 00:00:00 2001 From: kilo <39413400+kil0byt3@users.noreply.github.com> Date: Sun, 8 Sep 2024 22:47:35 -0700 Subject: [PATCH] Update fnc_addOrbat.sqf --- addons/briefing/functions/fnc_addOrbat.sqf | 104 ++++++++++++--------- 1 file changed, 61 insertions(+), 43 deletions(-) diff --git a/addons/briefing/functions/fnc_addOrbat.sqf b/addons/briefing/functions/fnc_addOrbat.sqf index ba7f7659f..90133ec34 100644 --- a/addons/briefing/functions/fnc_addOrbat.sqf +++ b/addons/briefing/functions/fnc_addOrbat.sqf @@ -1,48 +1,66 @@ /* - * Author: PabstMirror - * Function used to add the order of battle to player's diary - * - * Arguments: - * 0: Unit to add to the OrBat to - * - * Examples: - * [player] call potato_briefing_fnc_addOrbat; + * Author: McKendrick @ SIA + * Adds "ORBAT" tab to briefing that displays a list of players by their squad and roles. Execute locally. * * Public: Yes */ -#include "script_component.hpp" - -TRACE_1("params",_this); - -_this spawn { - uiSleep 10; - - params ["_unit"]; - TRACE_1("",_unit); - - private _diaryBuilder = []; - _diaryBuilder pushBack "Only accurate at mission start."; - - { - if (({isPlayer _x} count (units _x)) > 0) then { - if (((side _x) getFriend playerSide) >= 0.6) then { - private _color = switch (side _x) do { - case (west): { "#0088EE" }; // use profile colors here - case (east): { "#DD0000" }; - case (resistance): { "#00DD00" }; - case (civilian): { "#880099" }; - default { "#FFFFFF" }; - }; - _diaryBuilder pushBack format ["%2", _color, (groupId _x)]; - { - private _xIcon = getText (configFile >> "CfgVehicles" >> typeOf (vehicle _x) >> "icon"); - private _image = getText (configFile >> "CfgVehicleIcons" >> _xIcon); - _diaryBuilder pushBack format ["%2", _image, (name _x)]; - } forEach (units _x); - }; - }; - } forEach allGroups; - - _unit createDiaryRecord ["diary", ["ORBAT", _diaryBuilder joinString "
"]]; -}; + #include "script_component.hpp" + +if (!hasInterface) exitWith {}; // Exit if not a player. + + +if (!isNil "orbat") then { player removeDiaryRecord ["Diary", orbat] }; // If diary entry already exists, then erase it. + +private _allGroupsWithPlayers = []; +{ if (side _x == side player) then { _allGroupsWithPlayers pushBackUnique group _x } } forEach (call BIS_fnc_listPlayers); // Create array with all player groups matching the player's side +//{ if (side _x == side player) then { _allGroupsWithPlayers pushBackUnique _x } } forEach allGroups; // DEBUG FOR SINGLEPLAYER +_allGroupsWithPlayers = [_allGroupsWithPlayers, [], { groupId _x }] call BIS_fnc_sortBy; // Sort array by group callsigns in alphabetical order + +// Init variables +private _str = ""; +private _teamColor = ''; +private _roleColor = ''; + +{ + private _sideColor = [side _x] call BIS_fnc_sideColor; // Get RGBA color value of group's side. + _sideColor = (_sideColor apply { _x * 2 }) call BIS_fnc_colorRGBAtoHTML; // Brighten the color and convert it to HEX/HTML. + _str = _str + format ["%1", groupId _x, _sideColor] + "
"; // Format group callsign with side color. + + { + private _role = roleDescription _x; + if (_role == "") then { // If roleDescription is set, then truncate. Else use config name. + _role = (getText(configFile >> "CfgVehicles" >> (typeOf vehicle _x) >> "displayName")); + } else { + _role = (_role splitString "@") select 0; + }; + + if (_x == player) then { _roleColor = '#B21A00' /* red */ } else { _roleColor = '#ffffff' /* white */ }; // Set color of player's name to red + + // Get unit's team and associated color + if (group _x == group player) then { + _teamColor = switch (assignedTeam _x) do { + case "RED": {"#FEAAAA"}; // pink + case "GREEN": {"#AAFEAA"}; // light-green + case "BLUE": {"#AAAAFE"}; // purple-blue + case "YELLOW": {"#FEFEAA"}; // beige-yellow + default {"#FFFFFF"}; // white + }; + } else { + _teamColor = '#FFB84C'; // If unit not in player's group, then set color to Koromiko (yellow/orange) + }; + + _roleIcon = format ["", _teamColor]; // Get icon of units' role from config. + _str = _str + + " " + + _roleIcon + + " " + + format ["%1: ", _role, _roleColor, 'PuristaBold'] + + format ["%1", (name _x), _teamColor, 'PuristaLight'] + + " " + + "
"; // Combine images, role, and name into one string. + } forEach ([leader _x] + (units _x - [leader _x])); // Do for all units in group, starting with the group lead. + _str = _str + "
" // Add extra line break after each group. +} forEach _allGroupsWithPlayers; + +orbat = player createDiaryRecord ["Diary", ["ORBAT", "Refresh



" + _str]]; // Add ORBAT text to diary along with "Refresh" button.