2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2023-07-25 06:30:49 +00:00
|
|
|
#include "..\defines.hpp"
|
|
|
|
/*
|
2023-07-25 06:41:15 +00:00
|
|
|
* Author: Brett Mayson, johnb43
|
|
|
|
* Refreshes the arsenal to show external changes.
|
2023-07-25 06:30:49 +00:00
|
|
|
*
|
2023-08-20 03:56:59 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Update current and unique items lists <BOOL> (default: true)
|
2023-10-23 17:31:21 +00:00
|
|
|
* 1: Update virtual items list <BOOL> (default: false)
|
2023-10-26 16:59:00 +00:00
|
|
|
* 2: Use panel refresh animation <BOOL> (default: false)
|
2023-08-20 03:56:59 +00:00
|
|
|
*
|
2023-07-25 06:30:49 +00:00
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
2023-08-20 03:56:59 +00:00
|
|
|
* Example:
|
|
|
|
* call ace_arsenal_fnc_refresh
|
|
|
|
*
|
|
|
|
* Public: Yes
|
2023-07-25 06:30:49 +00:00
|
|
|
*/
|
2023-10-26 16:59:00 +00:00
|
|
|
params [["_updateItems", true, [true]], ["_updateVirtualItems", false, [false]], ["_animate", false, [false]]];
|
2023-10-23 17:31:21 +00:00
|
|
|
TRACE_2("",_updateItems,_updateVirtualItems);
|
|
|
|
|
|
|
|
// Don't execute in scheduled environment
|
|
|
|
if (canSuspend) exitWith {
|
|
|
|
[{_this call FUNC(refresh)}, _this] call CBA_fnc_directCall;
|
|
|
|
};
|
2023-07-25 06:30:49 +00:00
|
|
|
|
2024-02-05 13:57:22 +00:00
|
|
|
private _display = findDisplay IDD_ace_arsenal;
|
|
|
|
|
|
|
|
// Exit quietly if no display found
|
|
|
|
if (isNull _display) exitWith {};
|
|
|
|
|
2023-08-20 03:56:59 +00:00
|
|
|
if (_updateItems) then {
|
|
|
|
// Update current item list
|
|
|
|
call FUNC(updateCurrentItemsList);
|
2023-07-25 06:30:49 +00:00
|
|
|
|
2023-08-20 03:56:59 +00:00
|
|
|
// This takes care of unique inventory items (arsenal doesn't have it whitelisted)
|
2023-10-23 17:31:21 +00:00
|
|
|
if (!_updateVirtualItems) then {
|
|
|
|
call FUNC(updateUniqueItemsList);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
private _virtualItems = GVAR(currentBox) getVariable QGVAR(virtualItems);
|
2023-10-26 16:59:00 +00:00
|
|
|
|
|
|
|
if (is3DEN) then {
|
|
|
|
_virtualItems = uiNamespace getVariable QGVAR(configItems); // GVAR(currentBox) is nil in 3DEN
|
|
|
|
_animate = true; // CBA frame functions are disabled during preInit
|
|
|
|
};
|
|
|
|
|
2023-11-16 23:54:52 +00:00
|
|
|
// Do not close an arsenal if it was opened with ignoring the existing content (see FUNC(openBox))
|
|
|
|
if (isNil "_virtualItems" && {isNil QGVAR(ignoredVirtualItems)}) exitWith {
|
2023-10-23 17:31:21 +00:00
|
|
|
[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;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_updateVirtualItems) then {
|
|
|
|
GVAR(virtualItems) = +_virtualItems;
|
|
|
|
call FUNC(updateVirtualItemsFlat);
|
|
|
|
|
|
|
|
// Gotta update this regardless of condition to prevent desync
|
2023-08-20 03:56:59 +00:00
|
|
|
call FUNC(updateUniqueItemsList);
|
|
|
|
};
|
2023-07-25 06:30:49 +00:00
|
|
|
|
2023-07-25 06:41:15 +00:00
|
|
|
// Don't refresh left panel if in loadout tab
|
|
|
|
if (!isNull findDisplay IDD_loadouts_display) exitWith {};
|
|
|
|
|
2023-10-26 16:59:00 +00:00
|
|
|
if (!_animate) then {
|
|
|
|
GVAR(refreshing) = true;
|
|
|
|
[{GVAR(refreshing) = false}, nil, 3] call CBA_fnc_execAfterNFrames;
|
|
|
|
};
|
|
|
|
|
|
|
|
[_display, _display displayCtrl GVAR(currentLeftPanel), _animate] call FUNC(fillLeftPanel);
|