Skip to content

Commit

Permalink
Arsenal - Exit refresh early if no display is found (#9754)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike-MF <[email protected]>
  • Loading branch information
LinkIsGrim and Mike-MF authored Feb 5, 2024
1 parent 4bb9d6c commit 6c60b67
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion addons/arsenal/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ GVAR(lastSortDirectionRight) = DESCENDING;
params ["_object"];

// If the arsenal is already open, refresh arsenal display
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) isEqualTo _object}) then {
// Deliberate == check, fail on objNull
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) == _object}) then {
[true, true] call FUNC(refresh);
};
}] call CBA_fnc_addEventHandler;
Expand Down
7 changes: 5 additions & 2 deletions addons/arsenal/functions/fnc_refresh.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ if (canSuspend) exitWith {
[{_this call FUNC(refresh)}, _this] call CBA_fnc_directCall;
};

private _display = findDisplay IDD_ace_arsenal;

// Exit quietly if no display found
if (isNull _display) exitWith {};

if (_updateItems) then {
// Update current item list
call FUNC(updateCurrentItemsList);
Expand Down Expand Up @@ -65,6 +70,4 @@ if (!_animate) then {
[{GVAR(refreshing) = false}, nil, 3] call CBA_fnc_execAfterNFrames;
};

private _display = findDisplay IDD_ace_arsenal;

[_display, _display displayCtrl GVAR(currentLeftPanel), _animate] call FUNC(fillLeftPanel);
14 changes: 10 additions & 4 deletions addons/arsenal/functions/fnc_removeBox.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ if (_global && {isMultiplayer} && {!isNil "_id"}) then {
};

// If the arsenal is already open and not ignoring content (see FUNC(openBox)), close arsenal display
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) isEqualTo _object} && {isNil QGVAR(ignoredVirtualItems)}) then {
[LLSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText);
// Delay a frame in case this is running on display open
[{(findDisplay IDD_ace_arsenal) closeDisplay 0}] call CBA_fnc_execNextFrame;
// Deliberate == check, fail on objNull
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) == _object} && {isNil QGVAR(ignoredVirtualItems)}) then {
// Delay a frame in case this is running on display open/close
[{
private _display = findDisplay IDD_ace_arsenal;
if (isNull _display) exitWith {};

[LLSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText);
_display closeDisplay 0;
}] call CBA_fnc_execNextFrame;
};

0 comments on commit 6c60b67

Please sign in to comment.