Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORBAT Improvements (courtesy of SIA/McKendrick) #542

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 61 additions & 43 deletions addons/briefing/functions/fnc_addOrbat.sqf
Original file line number Diff line number Diff line change
@@ -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 <OBJECT>
*
* 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
*/
Comment on lines 1 to 6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is public and we completely break API. There are a handful of files this is not compatible with (see). any "public" function must maintain and work as expected between API versions


#include "script_component.hpp"

TRACE_1("params",_this);

_this spawn {
uiSleep 10;

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

private _diaryBuilder = [];
_diaryBuilder pushBack "<font size='8'>Only accurate at mission start.</font>";

{
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 ["<font color='%1' size='16'>%2</font>", _color, (groupId _x)];
{
private _xIcon = getText (configFile >> "CfgVehicles" >> typeOf (vehicle _x) >> "icon");
private _image = getText (configFile >> "CfgVehicleIcons" >> _xIcon);
_diaryBuilder pushBack format ["<img image='%1' width='16' height='16'/><font size='14'>%2</font>", _image, (name _x)];
} forEach (units _x);
};
};
} forEach allGroups;

_unit createDiaryRecord ["diary", ["ORBAT", _diaryBuilder joinString "<br/>"]];
};
#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 = '';
Comment on lines +21 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all should be '' or "", no mixing


{
private _sideColor = [side _x] call BIS_fnc_sideColor; // Get RGBA color value of group's side.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side _x -> side _x

_sideColor = (_sideColor apply { _x * 2 }) call BIS_fnc_colorRGBAtoHTML; // Brighten the color and convert it to HEX/HTML.
_str = _str + format ["<font face='PuristaMedium' size='16' color='%2'>%1</font>", groupId _x, _sideColor] + "<br />"; // 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

player -> ACE_PLAYER? in general all of these requests are because I don't know if we want remote-controlled units to be the side for the ORBAT. If not, ignore

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (_x == player) then { _roleColor = '#B21A00' /* red */ } else { _roleColor = '#ffffff' /* white */ }; // Set color of player's name to red
if (_x == player) then { _roleColor = '#B21A00' /* red */ } else { _roleColor = '#A9A9A9' /* dark medium gray */ }; // Set color of player's name to red

Change color for better contrast with player names


// Get unit's team and associated color
if (group _x == group player) then {
_teamColor = switch (assignedTeam _x) do {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we follow from this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pure colors (as done in those arrays) doesn't have good contrast on the briefing screen, I would recommend derivatives of the side color, but maybe softened a bit.

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 ["<img color='%1' image='\A3\Ui_F\Data\Map\VehicleIcons\"+ (getText(configFile >> "CfgVehicles" >> (typeOf _x) >> "icon")) + "_ca.paa' width='15' height='15'/>", _teamColor]; // Get icon of units' role from config.
_str = _str +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format please

" " +
_roleIcon +
" " +
format ["<font color='%2' face='%3'>%1: </font>", _role, _roleColor, 'PuristaBold'] +
format ["<font color='%2' face='%3'>%1</font>", (name _x), _teamColor, 'PuristaLight'] +

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
format ["<font color='%2' face='%3'>%1</font>", (name _x), _teamColor, 'PuristaLight'] +
format ["<font color='%2' face='%3'>%1 : </font>", (name _x), _teamColor, 'PuristaLight'] +
format ["<font color='%2' face='%3'>%1</font>", _role, _roleColor, 'PuristaMedium'] +

Reorder to follow chesh's suggestion [name] : [role], and font change for better contrast with player names

" " +
" <br />"; // 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 + "<br />" // Add extra line break after each group.
} forEach _allGroupsWithPlayers;

orbat = player createDiaryRecord ["Diary", ["ORBAT", "<execute expression='call potato_briefing_fnc_addOrbat;'>Refresh</execute><br></br><br></br>" + _str]]; // Add ORBAT text to diary along with "Refresh" button.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is gross, i think we can use macros to make it better? Something like this should work? (Untested)

"<execute expression='call potato_briefing_fnc_addOrbat;'>Refresh</execute><br></br><br></br>" -> QUOTE(<execute expression='call FUNC(addOrbat);'>Refresh</execute><br></br><br></br>)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use a global orbat variable? we should try to avoid in every case, especially non-GVARd ones