Skip to content

Commit

Permalink
Fix Orbat names and ToE
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapawingo committed May 23, 2024
1 parent 257602d commit 6b24db5
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 171 deletions.
135 changes: 68 additions & 67 deletions framework/components/organization/functions/fn_ToE.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,62 +21,60 @@
addMissionEventHandler ["Map", {
params ["_mapIsOpened"];

if (!_mapIsOpened) then {
/* Remove outdated roster */
{
player removeDiaryRecord ["cmf_toe", _x select 8]
} forEach (player allDiaryRecords "cmf_toe");
} else {
/* Add Each of the highest level groups */
private _groupHash = [GVAR(groups), side cmf_player, []] call CBA_fnc_hashGet;
private _levels = [_groupHash] call CBA_fnc_hashKeys;
if (count _levels isEqualTo 0) exitWith { cmf_player createDiaryRecord ["cmf_toe", ["No Registered Groups.", ""]] };

{
cmf_player removeDiaryRecord ["cmf_toe", _x select 8];
} forEach (cmf_player allDiaryRecords "cmf_toe");

_levels sort false;
private _topLevelGroups = [_groupHash, _levels select 0, []] call CBA_fnc_hashGet;
reverse _topLevelGroups;

FUNC(ToE_recursiveCheck) = {
params ["_group", ["_indent", ""], ["_vehicle", objNull]];
if (!_mapIsOpened) exitWith {
{ player removeDiaryRecord ["cmf_toe", _x select 8] } forEach (player allDiaryRecords "cmf_toe");
};

private _formattedString = "";
/* Add Each of the highest level groups */
private _groupHash = [GVAR(groups), side cmf_player, []] call CBA_fnc_hashGet;
private _levels = [_groupHash] call CBA_fnc_hashKeys;
if (count _levels isEqualTo 0) exitWith { cmf_player createDiaryRecord ["cmf_toe", ["No Registered Groups.", ""]] };

private _formatGroupHeader = { format ["<font face='PuristaBold'>%1</font><br/>", _this] };
{
cmf_player removeDiaryRecord ["cmf_toe", _x select 8];
} forEach (cmf_player allDiaryRecords "cmf_toe");

private _groupNames = _group getVariable [QGVAR(groupName), ["UNKNOWN", "UNKNOWN"]];
private _groupVehicle = _group getVariable [QGVAR(vehicle), objNull];
private _groupData = [_group] call FUNC(groupGetData);
private _units = units _group;
_groupData params ["_level", "_type", "", "_children"];
_levels sort false;
private _topLevelGroups = [_groupHash, _levels select 0, []] call CBA_fnc_hashGet;
reverse _topLevelGroups;

FUNC(ToE_recursiveCheck) = {
params ["_group", ["_indent", ""], ["_vehicle", objNull]];

if (count _units isNotEqualTo 0) then {
if (count _children > 0 || _level isEqualTo 1) then {
_formattedString = _formattedString + "<br/>" + _indent + ((_groupNames select 1) call _formatGroupHeader);
_indent = _indent + " ";
};
private _formattedString = "";

if (_type isEqualTo "INF") then {
_formattedString = _formattedString + _indent + ((_groupNames select 0) call _formatGroupHeader);
};
private _formatGroupHeader = { format ["<font face='PuristaBold'>%1</font><br/>", _this] };

if (_groupVehicle isNotEqualTo _vehicle) then {
private _vehicleName = [configFile >> "CfgVehicles" >> typeof _groupVehicle] call BIS_fnc_displayName;
_formattedString = _formattedString + _indent + format ["<font size='13' color='#fcba03'> %1</font><br/>", _vehicleName];
_vehicle = _groupVehicle;
};
private _groupNames = _group getVariable [QGVAR(groupName), ["UNKNOWN", "UNKNOWN"]];
private _groupVehicle = _group getVariable [QGVAR(vehicle), objNull];
private _groupData = [_group] call FUNC(groupGetData);
private _units = units _group;
_groupData params ["_level", "_type", "", "_children"];

if (_type isNotEqualTo "ZEUS") then {
if (count _children > 0 || _level isEqualTo 1) then {
_formattedString = _formattedString + "<br/>" + _indent + ((_groupNames select 1) call _formatGroupHeader);
_indent = _indent + " ";
};

if (_type isEqualTo "INF") then {
_formattedString = _formattedString + _indent + ((_groupNames select 0) call _formatGroupHeader);
};

if (_groupVehicle isNotEqualTo _vehicle) then {
private _vehicleName = [configFile >> "CfgVehicles" >> typeof _groupVehicle] call BIS_fnc_displayName;
_formattedString = _formattedString + _indent + format ["<font size='13' color='#fcba03'> %1</font><br/>", _vehicleName];
_vehicle = _groupVehicle;
};

if (count units _group isNotEqualTo 0) then {
{
if (isPlayer _x) then {
private _roleDescription = "None";
if (roleDescription _x != "") then {
_roleDescription = (roleDescription _x splitString "@") select 0;
};

_formattedString = _formattedString + _indent + format [" <font color='#fcba03'> %1</font>, %2<br/>", name _x, _roleDescription];
} else {
private _role = [_x] call EFUNC(kosherAI,getRole);
Expand All @@ -90,43 +88,46 @@
["MG", "Machinegunner"],
["MAR", "Marksman"],
["SL", "Leader"]
] getOrDefault [_role, "Rifleman"];

] getOrDefault [_role, _role];
_formattedString = _formattedString + _indent + format [" <font color='#888888'>[AI]</font><font color='#fcba03'> %1</font>, %2<br/>", name _x, _roleDescription];
};
} forEach units _group;
} else {
_formattedString = _formattedString + _indent + " <font color='#888888'>Empty</font><br/>";
};
};

/* Sort children */
_children = [_children, [], {
private _group = _x;
private _groupData = [_group] call FUNC(groupGetData);
private _groupNames = _group getVariable [QGVAR(groupName), ["UNKNOWN", "UNKNOWN"]];
_groupData params ["", "_type", "", "_children"];
/* Sort children */
_children = [_children, [], {
private _group = _x;
_groupData = [_group] call FUNC(groupGetData);
_groupNames = _group getVariable [QGVAR(groupName), ["UNKNOWN", "UNKNOWN"]];
_groupData params ["", "_type", "", "_children"];

private _childrenCount = count _children;
private _alphabetOrder = GVAR(phoneticAlphabet) findIf { (_x select [0, 1]) isEqualTo (_groupNames select [0, 1]) };
private _childrenCount = count _children;
private _alphabetOrder = GVAR(phoneticAlphabet) findIf { (_x select [0, 1]) isEqualTo (_groupNames select [0, 1]) };

([_childrenCount + 1000, _alphabetOrder] select (_type isEqualTo "INF"))
}, "DESCEND"] call BIS_fnc_sortBy;
([_childrenCount + 1000, _alphabetOrder] select (_type isEqualTo "INF"))
}, "ASCEND"] call BIS_fnc_sortBy;

{
_formattedString = _formattedString + ([_x, _indent, _vehicle] call FUNC(ToE_recursiveCheck));
} forEach _children;
{
_formattedString = _formattedString + ([_x, _indent, _vehicle] call FUNC(ToE_recursiveCheck));
} forEach _children;

_formattedString;
};
_formattedString;
};


{
private _group = _x;
private _groupNames = _group getVariable [QGVAR(groupName), ["UNKNOWN", "UNKNOWN"]];
private _formattedString = "<br/><font size='12'>";
{
private _group = _x;

_formattedString = _formattedString + ([_group] call FUNC(ToE_recursiveCheck));
private _groupNames = _group getVariable [QGVAR(groupName), ["UNKNOWN", "UNKNOWN"]];
private _formattedString = "<br/><font size='12'>";

cmf_player createDiaryRecord ["cmf_toe", [(_groupNames select 1), _formattedString]];
} forEach _topLevelGroups;
};
_formattedString = _formattedString + ([_group] call FUNC(ToE_recursiveCheck));

cmf_player createDiaryRecord ["cmf_toe", [(_groupNames select 1), _formattedString]];
} forEach _topLevelGroups;
}];
}] call CBA_fnc_waitUntilAndExecute;
102 changes: 12 additions & 90 deletions framework/components/organization/functions/fn_roster.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,108 +15,30 @@
* Public: No
*/

// @TODO: also get unassigned players from outside the dynamic group system
[{ !isNull player && { alive player } }, {
player createDiarySubject ["cmf_roster", "Player Roster"];

addMissionEventHandler ["Map", {
params ["_mapIsOpened"];

if (!_mapIsOpened) then {
/* Remove outdated roster */
{
player removeDiaryRecord ["cmf_roster", _x select 8]
} forEach (player allDiaryRecords "cmf_roster");
} else {
/* Add Each of the highest level groups */
private _groupHash = [GVAR(groups), side cmf_player, []] call CBA_fnc_hashGet;
private _levels = [_groupHash] call CBA_fnc_hashKeys;
if (count _levels isEqualTo 0) exitWith { cmf_player createDiaryRecord ["cmf_roster", ["No Registered Groups.", ""]] };

{
cmf_player removeDiaryRecord ["cmf_roster", _x select 8];
} forEach (cmf_player allDiaryRecords "cmf_roster");

_levels sort false;
private "_topLevelGroups";
{
private _groups = [_groupHash, _x, []] call CBA_fnc_hashGet;

if (_groups findIf { units _x findIf { isPlayer _x } > -1 } > -1) exitWith {
_topLevelGroups = _groups;
};
} forEach _levels;

if (isNil "_topLevelGroups") exitWith { cmf_player createDiaryRecord ["cmf_roster", ["No Registered Groups.", ""]] };

reverse _topLevelGroups;

FUNC(ToE_recursiveCheck) = {
params ["_group", ["_indent", ""]];

private _formattedString = "";

private _formatGroupHeader = { format ["<font face='PuristaBold'>%1</font><br/>", _this] };

private _groupNames = _group getVariable [QGVAR(groupName), ["UNKNOWN", "UNKNOWN"]];
private _groupData = [_group] call FUNC(groupGetData);
private _units = units _group;
_groupData params ["_level", "", "", "_children"];

if (count _units isNotEqualTo 0) then {
if (count _children > 0) then {
_formattedString = _formattedString + "<br/>" + _indent + ((_groupNames select 1) call _formatGroupHeader);
_indent = _indent + " ";
};

if (!_mapIsOpened) exitWith {
{ player removeDiaryRecord ["cmf_roster", _x select 8] } forEach (player allDiaryRecords "cmf_roster");
};

_formattedString = _formattedString + _indent + ((_groupNames select 0) call _formatGroupHeader);
{
if (isPlayer _x) then {
private _roleDescription = "None";
if (roleDescription _x != "") then {
_roleDescription = (roleDescription _x splitString "@") select 0;
};
private _formattedString = "<font size='12'><br/><br/><font face='PuristaBold'>Player Roster</font><br/>";

_formattedString = _formattedString + _indent + format [" <font color='#fcba03'> %1</font>, %2<br/>", name _x, _roleDescription];
};
} forEach units _group;
{
if (isPlayer _x) then {
private _roleDescription = "None";
if (roleDescription _x != "") then {
_roleDescription = (roleDescription _x splitString "@") select 0;
};

/* Sort children */
_children = [_children, [], {
private _group = _x;
private _groupData = [_group] call FUNC(groupGetData);
private _groupNames = _group getVariable [QGVAR(groupName), ["UNKNOWN", "UNKNOWN"]];
_groupData params ["", "_type", "", "_children"];

private _childrenCount = count _children;
private _alphabetOrder = GVAR(phoneticAlphabet) findIf { (_x select [0, 1]) isEqualTo (_groupNames select [0, 1]) };

_childrenCount + ([1000, -_alphabetOrder] select (_type isEqualTo "INF"))
}, "DESCEND"] call BIS_fnc_sortBy;

{
if (units _x findIf { isPlayer _x } > -1) then {
_formattedString = _formattedString + ([_x, _indent] call FUNC(ToE_recursiveCheck));
}
} forEach _children;

_formattedString;
_formattedString = _formattedString + format [" <font color='#fcba03'> %1</font>, %2<br/>", name _x, _roleDescription];
};
} forEach allPlayers;


{
private _group = _x;
if (units _group findIf { isPlayer _x } > -1) then {
private _groupNames = _group getVariable [QGVAR(groupName), ["UNKNOWN", "UNKNOWN"]];
private _formattedString = "<br/><font size='12'>";

_formattedString = _formattedString + ([_group] call FUNC(ToE_recursiveCheck));

cmf_player createDiaryRecord ["cmf_roster", [(_groupNames select 1), _formattedString]];
}
} forEach _topLevelGroups;
};
cmf_player createDiaryRecord ["cmf_roster", ["Player Roster", _formattedString]];
}];
}] call CBA_fnc_waitUntilAndExecute;
Loading

0 comments on commit 6b24db5

Please sign in to comment.