Skip to content

Commit

Permalink
optimize nametags a tiny bit
Browse files Browse the repository at this point in the history
  • Loading branch information
diwako committed Oct 6, 2024
1 parent b1afafd commit 0fb87b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
2 changes: 0 additions & 2 deletions addons/nametags/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

if !(hasInterface) exitWith {};

GVAR(targetedFade) = 1;

call FUNC(cacheLoop);

player setVariable [QGVAR(name), name player];
Expand Down
23 changes: 6 additions & 17 deletions addons/nametags/functions/fnc_onDraw.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ if ((ctrlPosition _ctrl) isNotEqualTo _pos) then {

private _target = cursorObject;
private _player = call CBA_fnc_currentUnit;
private _targetedFade = 1;

if (GVAR(useLIS)) then {
private _skipVicCheck = (netId _target) isEqualTo "1:0"; // only ever true when cursorObject returns the weapon of a
Expand Down Expand Up @@ -42,10 +43,7 @@ if (GVAR(useLIS)) then {
} forEach _lis;
};

if (isNull _target || {!(player call EFUNC(main,canHudBeShown)) || {unitIsUAV _target}}) then {
GVAR(targetedFade) = 1;
} else {

if !(isNull _target || {!(player call EFUNC(main,canHudBeShown)) || {unitIsUAV _target}}) then {
private _effectiveCommander = effectiveCommander _target;
if !(isNull _effectiveCommander) then {
_target = _effectiveCommander;
Expand All @@ -59,8 +57,8 @@ if (isNull _target || {!(player call EFUNC(main,canHudBeShown)) || {unitIsUAV _t
_targetSide isEqualTo _playerSide;
};
if (_target isKindOf "AllVehicles" && {_areFriendly}) then {
GVAR(targetedFade) = [_target, _player] call FUNC(calculateFadeValue);
if (GVAR(targetedFade) < 1) then {
_targetedFade = (([_target, _player] call FUNC(calculateFadeValue)) min 1) max 0;
if (_targetedFade < 1) then {
private _color = EGVAR(main,colors_custom) getVariable ["otherName", "#33FF00"]; // Other Group Default Color
private _colorGroup = EGVAR(main,colors_custom) getVariable ["otherGroup", "#99D999"]; // Other Group Default Color
if ((group _target) isEqualTo (group _player)) then {
Expand Down Expand Up @@ -93,17 +91,8 @@ if (isNull _target || {!(player call EFUNC(main,canHudBeShown)) || {unitIsUAV _t
// TODO(joko): Add Extra Fade for Group?
_ctrl ctrlSetStructuredText parseText (_data joinString "");
};
} else {
GVAR(targetedFade) = 1;
};
};

GVAR(targetedFade) = (GVAR(targetedFade) min 1) max 0;

private _fadeIn = GVAR(targetedFade) <= ctrlFade _ctrl;
_ctrl ctrlSetFade GVAR(targetedFade);
if (_fadeIn) then {
_ctrl ctrlCommit GVAR(fadeInTime);
} else {
_ctrl ctrlCommit GVAR(fadeOutTime);
};
_ctrl ctrlSetFade _targetedFade;
_ctrl ctrlCommit ([GVAR(fadeOutTime), GVAR(fadeInTime)] select (_targetedFade <= ctrlFade _ctrl));

0 comments on commit 0fb87b0

Please sign in to comment.