Skip to content

Commit

Permalink
Minor code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
diwako committed Oct 5, 2024
1 parent 6ea2597 commit 5a4e66b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
25 changes: 12 additions & 13 deletions addons/radar/functions/fnc_cacheLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ if (GVAR(syncGroup) && {isMultiplayer && {GVAR(sortType) isEqualTo "none" && {lo

// if both compass and namelist are not enabled, just remove the controls if there are any
if !(diwako_dui_enable_compass || diwako_dui_namelist) exitWith {
for "_i" from 0 to (count GVAR(namebox_lists)) do {
{
ctrlDelete ctrlParentControlsGroup (GVAR(namebox_lists) deleteAt 0);
};
} forEach GVAR(namebox_lists);
"diwako_dui_namebox" cutRsc ["diwako_dui_RscNameBox","PLAIN", 0, true];
};

_group = (group _player) getVariable [QGVAR(syncGroup), _group];
if (diwako_dui_compass_hide_blip_alone_group && {(count _group) <= 1}) then {
private _isAloneInGroup = (count _group) <= 1;
if (diwako_dui_compass_hide_blip_alone_group && {_isAloneInGroup}) then {
_group = [];
};

Expand Down Expand Up @@ -168,10 +169,10 @@ private _lists = GVAR(namebox_lists);

// delete all name list controls if not active
if (!diwako_dui_namelist || {GVAR(namelist_hideWhenLeader) && (leader _player) isEqualTo _player}) exitWith {
if ((count _lists) > 0) then {
for "_i" from (count _lists) -1 to 0 step -1 do {
ctrlDelete ctrlParentControlsGroup (_lists deleteAt _i);
};
if (_lists isNotEqualTo []) then {
{
ctrlDelete ctrlParentControlsGroup (_lists deleteAt _forEachIndex);
} forEachReversed _lists;
"diwako_dui_namebox" cutText ["","PLAIN"];
};
};
Expand Down Expand Up @@ -208,12 +209,10 @@ ctrlPosition _grpCtrl params ["", "", "", "_height"];
private _curNameListHeight = (_height / pixelH) - ((15 * _uiScale) max 15);

// no need to show any names if you are alone in the group
if (count _group <= 1) exitWith {
if ((count _lists) > 0) then {
for "_i" from (count _lists) -1 to 0 step -1 do {
ctrlDelete ctrlParentControlsGroup (_lists deleteAt _i);
};
};
if (_isAloneInGroup) exitWith {
{
ctrlDelete ctrlParentControlsGroup (_lists deleteAt _forEachIndex);
} forEachReversed _lists;
};
if !(ctrlShown _grpCtrl) then {
_grpCtrl ctrlShow true;
Expand Down
23 changes: 11 additions & 12 deletions addons/radar/functions/fnc_compassPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ if !(diwako_dui_enable_compass) exitWith {

private _player = [] call CBA_fnc_currentUnit;
private _grp = GVAR(group);
private _pointers = GVAR(pointers);

if (diwako_dui_compass_hide_alone_group && {count (units group _player) <= 1}) exitWith {
_compassCtrl ctrlShow false;
Expand Down Expand Up @@ -65,22 +64,22 @@ if ([_player] call EFUNC(main,canHudBeShown)) then {
ctrlDelete _x;
} forEach (_ctrls - _usedCtrls);

if (diwako_dui_compass_hide_blip_alone_group && { _grp isEqualTo (missionNamespace getVariable ["diwako_dui_special_track", []]) && {(count _usedCtrls) > 0}}) then {
if (diwako_dui_compass_hide_blip_alone_group && {
_grp isEqualTo (missionNamespace getVariable ["diwako_dui_special_track", []]) && {
_usedCtrls isNotEqualTo []}}) then {
_usedCtrls pushBack (([[_player], _display, _dir, _playerDir, _player, _ctrlGrp] call FUNC(displayUnitOnCompass)) select 0);
};
_ctrlGrp setVariable ["diwako_dui_ctrlArr", _usedCtrls];

if (_pointers isNotEqualTo []) then {
for "_i" from (count _pointers) -1 to 0 step -1 do {
(_pointers select _i) params [["_pointer", controlNull], "_pointerPos"];
if (isNull _pointer) then {
_pointers deleteAt _i;
} else {
_pointer ctrlSetAngle [(((_player getRelDir (_pointerPos)) - (_dir - _playerDir) ) mod 360), 0.5, 0.5, false];
_pointer ctrlCommit 0;
};
{
_x params [["_pointer", controlNull], "_pointerPos"];
if (isNull _pointer) then {
GVAR(pointers) deleteAt _forEachIndex;
} else {
_pointer ctrlSetAngle [(((_player getRelDir (_pointerPos)) - (_dir - _playerDir) ) mod 360), 0.5, 0.5, false];
_pointer ctrlCommit 0;
};
};
} forEachReversed GVAR(pointers);

if !(isNil "diwako_dui_custom_code") then {
/*
Expand Down

0 comments on commit 5a4e66b

Please sign in to comment.