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

Minor code improvements and optimizations #226

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD
#define VERSION_PLUGIN MAJOR.MINOR.PATCHLVL.BUILD

#define REQUIRED_VERSION 2.16
#define REQUIRED_VERSION 2.18

#ifdef COMPONENT_BEAUTIFIED
#define COMPONENT_NAME QUOTE(DUI - COMPONENT_BEAUTIFIED)
Expand Down
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));
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
2 changes: 1 addition & 1 deletion tools/sqf_linter_LogChecker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import os

defaultFalsePositives = 38 # Change 0 to Current number of false positives
defaultFalsePositives = 42 # Change 0 to Current number of false positives
def main():
f = open("sqf.log", "r")
log = f.readlines()
Expand Down