Arsenal - Add param to skip refresh animation (#9546)

* add animate param

* add refresh param

* remove param from event

* add 3DEN handling, update docs

* derp

* fix doc numbering
This commit is contained in:
Grim 2023-10-26 12:59:00 -04:00 committed by GitHub
parent 8d4eb18b80
commit bbcec5c468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 31 deletions

View File

@ -7,6 +7,7 @@
* Arguments: * Arguments:
* 0: Arsenal display <DISPLAY> * 0: Arsenal display <DISPLAY>
* 1: Tab control <CONTROL> * 1: Tab control <CONTROL>
* 2: Animate panel refresh <BOOL>
* *
* Return Value: * Return Value:
* None * None
@ -14,28 +15,30 @@
* Public: No * Public: No
*/ */
params ["_display", "_control"]; params ["_display", "_control", ["_animate", true]];
// Fade old control background // Fade old control background
if (!isNil QGVAR(currentLeftPanel)) then { if (!isNil QGVAR(currentLeftPanel)) then {
private _previousCtrlBackground = _display displayCtrl (GVAR(currentLeftPanel) - 1); private _previousCtrlBackground = _display displayCtrl (GVAR(currentLeftPanel) - 1);
_previousCtrlBackground ctrlSetFade 1; _previousCtrlBackground ctrlSetFade 1;
_previousCtrlBackground ctrlCommit FADE_DELAY; _previousCtrlBackground ctrlCommit ([0, FADE_DELAY] select _animate);
}; };
// Show new control background // Show new control background
private _ctrlIDC = ctrlIDC _control; private _ctrlIDC = ctrlIDC _control;
private _ctrlBackground = _display displayCtrl (_ctrlIDC - 1); private _ctrlBackground = _display displayCtrl (_ctrlIDC - 1);
_ctrlBackground ctrlSetFade 0; _ctrlBackground ctrlSetFade 0;
_ctrlBackground ctrlCommit FADE_DELAY; _ctrlBackground ctrlCommit ([0, FADE_DELAY] select _animate);
private _ctrlPanel = _display displayCtrl IDC_leftTabContent; private _ctrlPanel = _display displayCtrl IDC_leftTabContent;
// Force a "refresh" animation of the panel // Force a "refresh" animation of the panel
if (_animate) then {
_ctrlPanel ctrlSetFade 1; _ctrlPanel ctrlSetFade 1;
_ctrlPanel ctrlCommit 0; _ctrlPanel ctrlCommit 0;
_ctrlPanel ctrlSetFade 0; _ctrlPanel ctrlSetFade 0;
_ctrlPanel ctrlCommit FADE_DELAY; _ctrlPanel ctrlCommit FADE_DELAY;
};
_ctrlPanel lbSetCurSel -1; _ctrlPanel lbSetCurSel -1;

View File

@ -7,6 +7,7 @@
* Arguments: * Arguments:
* 0: Arsenal display <DISPLAY> * 0: Arsenal display <DISPLAY>
* 1: Tab control <CONTROL> * 1: Tab control <CONTROL>
* 2: Animate panel refresh <BOOL>
* *
* Return Value: * Return Value:
* None * None
@ -14,13 +15,13 @@
* Public: No * Public: No
*/ */
params ["_display", "_control"]; params ["_display", "_control", ["_animate", true]];
// Fade old control background // Fade old control background
if (!isNil QGVAR(currentRightPanel)) then { if (!isNil QGVAR(currentRightPanel)) then {
private _previousCtrlBackground = _display displayCtrl (GVAR(currentRightPanel) - 1); private _previousCtrlBackground = _display displayCtrl (GVAR(currentRightPanel) - 1);
_previousCtrlBackground ctrlSetFade 1; _previousCtrlBackground ctrlSetFade 1;
_previousCtrlBackground ctrlCommit FADE_DELAY; _previousCtrlBackground ctrlCommit ([0, FADE_DELAY] select _animate);
}; };
// Show new control background // Show new control background
@ -28,7 +29,7 @@ private _ctrlIDC = ctrlIDC _control;
private _ctrlBackground = _display displayCtrl (_ctrlIDC - 1); private _ctrlBackground = _display displayCtrl (_ctrlIDC - 1);
_ctrlBackground ctrlShow true; _ctrlBackground ctrlShow true;
_ctrlBackground ctrlSetFade 0; _ctrlBackground ctrlSetFade 0;
_ctrlBackground ctrlCommit FADE_DELAY; _ctrlBackground ctrlCommit ([0, FADE_DELAY] select _animate);
private _searchbarCtrl = _display displayCtrl IDC_rightSearchbar; private _searchbarCtrl = _display displayCtrl IDC_rightSearchbar;
@ -183,10 +184,12 @@ switch (GVAR(currentLeftPanel)) do {
}; };
// Force a "refresh" animation of the panel // Force a "refresh" animation of the panel
if (_animate) then {
_ctrlPanel ctrlSetFade 1; _ctrlPanel ctrlSetFade 1;
_ctrlPanel ctrlCommit 0; _ctrlPanel ctrlCommit 0;
_ctrlPanel ctrlSetFade 0; _ctrlPanel ctrlSetFade 0;
_ctrlPanel ctrlCommit FADE_DELAY; _ctrlPanel ctrlCommit FADE_DELAY;
};
// Check if the left panel is a weapon. If so, right panel will be compatible items with weapon only // Check if the left panel is a weapon. If so, right panel will be compatible items with weapon only
private _leftPanelState = GVAR(currentLeftPanel) in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon, IDC_buttonBinoculars]; private _leftPanelState = GVAR(currentLeftPanel) in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon, IDC_buttonBinoculars];

View File

@ -109,6 +109,7 @@ GVAR(leftTabFocus) = nil;
GVAR(rightTabFocus) = nil; GVAR(rightTabFocus) = nil;
GVAR(rightTabLnBFocus) = nil; GVAR(rightTabLnBFocus) = nil;
GVAR(ignoreFirstSortPanelCall) = nil; GVAR(ignoreFirstSortPanelCall) = nil;
GVAR(refreshing) = nil;
GVAR(selectedWeaponType) = nil; GVAR(selectedWeaponType) = nil;
GVAR(virtualItems) = nil; GVAR(virtualItems) = nil;

View File

@ -234,6 +234,7 @@ GVAR(leftTabFocus) = false;
GVAR(rightTabFocus) = false; GVAR(rightTabFocus) = false;
GVAR(rightTabLnBFocus) = false; GVAR(rightTabLnBFocus) = false;
GVAR(ignoreFirstSortPanelCall) = false; GVAR(ignoreFirstSortPanelCall) = false;
GVAR(refreshing) = false;
{ {
private _panel = _display displayCtrl _x; private _panel = _display displayCtrl _x;

View File

@ -23,8 +23,9 @@ private _display = ctrlParent _control;
private _item = [_control lbData _curSel, _control lnbData [_curSel, 0]] select (ctrlType _control == CT_LISTNBOX); private _item = [_control lbData _curSel, _control lnbData [_curSel, 0]] select (ctrlType _control == CT_LISTNBOX);
// When having chosen a new category, see if the current right panel can be kept open, otherwise take default // When having chosen a new category, see if the current right panel can be kept open, otherwise take default
private _selectCorrectPanelWeapon = [_display displayCtrl IDC_buttonOptic, _display displayCtrl GVAR(currentRightPanel)] select (!isNil QGVAR(currentRightPanel) && {GVAR(currentRightPanel) in [RIGHT_PANEL_ACC_IDCS, IDC_buttonCurrentMag, IDC_buttonCurrentMag2]}); private _currentRightPanel = _display displayCtrl GVAR(currentRightPanel);
private _selectCorrectPanelContainer = [_display displayCtrl IDC_buttonMisc, _display displayCtrl GVAR(currentRightPanel)] select (!isNil QGVAR(currentRightPanel) && {GVAR(currentRightPanel) in [RIGHT_PANEL_ITEMS_IDCS]}); private _selectCorrectPanelWeapon = [_display displayCtrl IDC_buttonOptic, _currentRightPanel] select (!isNil QGVAR(currentRightPanel) && {GVAR(currentRightPanel) in [RIGHT_PANEL_ACC_IDCS, IDC_buttonCurrentMag, IDC_buttonCurrentMag2]});
private _selectCorrectPanelContainer = [_display displayCtrl IDC_buttonMisc, _currentRightPanel] select (!isNil QGVAR(currentRightPanel) && {GVAR(currentRightPanel) in [RIGHT_PANEL_ITEMS_IDCS]});
// Remove all magazines from the current weapon that aren't compatible with the new weapon // Remove all magazines from the current weapon that aren't compatible with the new weapon
private _fnc_clearCurrentWeaponMags = { private _fnc_clearCurrentWeaponMags = {
@ -115,7 +116,7 @@ switch (GVAR(currentLeftPanel)) do {
TOGGLE_RIGHT_PANEL_WEAPON TOGGLE_RIGHT_PANEL_WEAPON
[_display, _selectCorrectPanelWeapon] call FUNC(fillRightPanel); [_display, _selectCorrectPanelWeapon, !GVAR(refreshing) && {_currentRightPanel isNotEqualTo _selectCorrectPanelWeapon}] call FUNC(fillRightPanel);
}; };
// Make unit switch to new item // Make unit switch to new item
@ -191,7 +192,7 @@ switch (GVAR(currentLeftPanel)) do {
TOGGLE_RIGHT_PANEL_WEAPON TOGGLE_RIGHT_PANEL_WEAPON
[_display, _selectCorrectPanelWeapon] call FUNC(fillRightPanel); [_display, _selectCorrectPanelWeapon, !GVAR(refreshing) && {_currentRightPanel isNotEqualTo _selectCorrectPanelWeapon}] call FUNC(fillRightPanel);
}; };
// Make unit switch to new item // Make unit switch to new item
@ -273,7 +274,7 @@ switch (GVAR(currentLeftPanel)) do {
_this call FUNC(fillRightPanel); _this call FUNC(fillRightPanel);
}, [_display, _selectCorrectPanelWeapon]] call CBA_fnc_execNextFrame; }, [_display, _selectCorrectPanelWeapon]] call CBA_fnc_execNextFrame;
} else { } else {
[_display, _selectCorrectPanelWeapon] call FUNC(fillRightPanel); [_display, _selectCorrectPanelWeapon, !GVAR(refreshing) && {_currentRightPanel isNotEqualTo _selectCorrectPanelWeapon}] call FUNC(fillRightPanel);
}; };
}; };
@ -347,7 +348,7 @@ switch (GVAR(currentLeftPanel)) do {
TOGGLE_RIGHT_PANEL_CONTAINER TOGGLE_RIGHT_PANEL_CONTAINER
[_display, _selectCorrectPanelContainer] call FUNC(fillRightPanel); [_display, _selectCorrectPanelContainer, !GVAR(refreshing) && {_currentRightPanel isNotEqualTo _selectCorrectPanelContainer}] call FUNC(fillRightPanel);
}; };
// Make unit switch to new item // Make unit switch to new item
@ -385,7 +386,7 @@ switch (GVAR(currentLeftPanel)) do {
TOGGLE_RIGHT_PANEL_CONTAINER TOGGLE_RIGHT_PANEL_CONTAINER
[_display, _selectCorrectPanelContainer] call FUNC(fillRightPanel); [_display, _selectCorrectPanelContainer, !GVAR(refreshing) && {_currentRightPanel isNotEqualTo _selectCorrectPanelContainer}] call FUNC(fillRightPanel);
}; };
// Make unit switch to new item // Make unit switch to new item
@ -423,7 +424,7 @@ switch (GVAR(currentLeftPanel)) do {
TOGGLE_RIGHT_PANEL_CONTAINER TOGGLE_RIGHT_PANEL_CONTAINER
[_display, _selectCorrectPanelContainer] call FUNC(fillRightPanel); [_display, _selectCorrectPanelContainer, !GVAR(refreshing) && {_currentRightPanel isNotEqualTo _selectCorrectPanelContainer}] call FUNC(fillRightPanel);
}; };
// Make unit switch to new item // Make unit switch to new item
@ -538,7 +539,7 @@ switch (GVAR(currentLeftPanel)) do {
TOGGLE_RIGHT_PANEL_WEAPON TOGGLE_RIGHT_PANEL_WEAPON
[_display, _selectCorrectPanelWeapon] call FUNC(fillRightPanel); [_display, _selectCorrectPanelWeapon, !GVAR(refreshing) && {_currentRightPanel isNotEqualTo _selectCorrectPanelWeapon}] call FUNC(fillRightPanel);
}; };
// Make unit switch to new item // Make unit switch to new item

View File

@ -7,6 +7,7 @@
* Arguments: * Arguments:
* 0: Update current and unique items lists <BOOL> (default: true) * 0: Update current and unique items lists <BOOL> (default: true)
* 1: Update virtual items list <BOOL> (default: false) * 1: Update virtual items list <BOOL> (default: false)
* 2: Use panel refresh animation <BOOL> (default: false)
* *
* Return Value: * Return Value:
* None * None
@ -16,8 +17,7 @@
* *
* Public: Yes * Public: Yes
*/ */
params [["_updateItems", true, [true]], ["_updateVirtualItems", false, [false]]]; params [["_updateItems", true, [true]], ["_updateVirtualItems", false, [false]], ["_animate", false, [false]]];
TRACE_2("",_updateItems,_updateVirtualItems); TRACE_2("",_updateItems,_updateVirtualItems);
// Don't execute in scheduled environment // Don't execute in scheduled environment
@ -36,6 +36,12 @@ if (_updateItems) then {
}; };
private _virtualItems = GVAR(currentBox) getVariable QGVAR(virtualItems); private _virtualItems = GVAR(currentBox) getVariable QGVAR(virtualItems);
if (is3DEN) then {
_virtualItems = uiNamespace getVariable QGVAR(configItems); // GVAR(currentBox) is nil in 3DEN
_animate = true; // CBA frame functions are disabled during preInit
};
if (isNil "_virtualItems") exitWith { if (isNil "_virtualItems") exitWith {
[LLSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText); [LLSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText);
// Delay a frame in case this is running on display open // Delay a frame in case this is running on display open
@ -53,6 +59,11 @@ if (_updateVirtualItems) then {
// Don't refresh left panel if in loadout tab // Don't refresh left panel if in loadout tab
if (!isNull findDisplay IDD_loadouts_display) exitWith {}; if (!isNull findDisplay IDD_loadouts_display) exitWith {};
if (!_animate) then {
GVAR(refreshing) = true;
[{GVAR(refreshing) = false}, nil, 3] call CBA_fnc_execAfterNFrames;
};
private _display = findDisplay IDD_ace_arsenal; private _display = findDisplay IDD_ace_arsenal;
[_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel); [_display, _display displayCtrl GVAR(currentLeftPanel), _animate] call FUNC(fillLeftPanel);

View File

@ -395,7 +395,12 @@ The same numbers are used for sorting methods as for stats (see `5.4 Stat tab nu
## 7. Actions ## 7. Actions
ACE Arsenal actions are customizable, this will show you how. Actions are a way to execute mission/addon-maker defined scripting from a user-interactable control. They can be used to, for example, equip earplugs, modify weapons, or interact with an equipped gunbag directly from the arsenal.
When an action is executed (i.e. the button is clicked), the action's code is executed, and the arsenal display is refreshed on the following frame to take external changes into account.
For actions involving frame delays or timers, a second call of the `ace_arsenal_fnc_refresh` function may be required.
Since CBA frame functions are deactivated during preInit as of Oct 24th 2023, the refresh function is executed immediatelly after the action code is executed. Take note of this information and the comment below if you'd like your actions to be usable in 3DEN.
### 7.1 Adding actions via config ### 7.1 Adding actions via config
@ -424,7 +429,7 @@ class ace_arsenal_actions {
``` ```
The focused unit object is passed to the condition and statement functions. The focused unit object is passed to the condition and statement functions.
### 7.2 Adding sorting methods via a function ### 7.2 Adding actions via scripting
`ace_arsenal_fnc_addAction` `ace_arsenal_fnc_addAction`
@ -459,7 +464,7 @@ The example above returns:
If an action already exists (so same class ID and tab within an action), it will ignore the new addition. If an action already exists (so same class ID and tab within an action), it will ignore the new addition.
### 7.3 Removing actions via a function ### 7.3 Removing actions via scripting
`ace_arsenal_fnc_removeAction` `ace_arsenal_fnc_removeAction`
@ -552,7 +557,7 @@ private _items = [cursorObject] call ace_arsenal_fnc_getVirtualItems
systemChat str _items systemChat str _items
``` ```
### 10.1 Blacklist items from all arsenals ### 10.2 Blacklist items from all arsenals
The following code can be used to remove items from any arsenal a player opens. Modify the `TAG_my_arsenal_blacklist` variable with a list of classnames you'd like to remove. The following code can be used to remove items from any arsenal a player opens. Modify the `TAG_my_arsenal_blacklist` variable with a list of classnames you'd like to remove.
The code will only have effect on clients where it is executed. It can placed in a mission's `initPlayerLocal.sqf` file or any object's init box in the editor. Do not add more than once. The code will only have effect on clients where it is executed. It can placed in a mission's `initPlayerLocal.sqf` file or any object's init box in the editor. Do not add more than once.
@ -565,7 +570,7 @@ TAG_my_arsenal_blacklist = ["arifle_AK12_F", "LMG_03_F"]; // modify this
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
``` ```
### 10.2 Making items available to all arsenals ### 10.3 Making items available to all arsenals
Same as above, but instead of `ace_arsenal_fnc_removeVirtualItems`, use `ace_arsenal_fnc_addVirtualItems`. Same as above, but instead of `ace_arsenal_fnc_removeVirtualItems`, use `ace_arsenal_fnc_addVirtualItems`.