ACE3/addons/arsenal/functions/fnc_handleActions.sqf
BrettMayson 3edeff217a
Arsenal - Action Buttons (#9069)
* work on arsenal actions

* cycle through pages

* docs

* cleanup

* Update addons/gunbag/functions/fnc_weaponName.sqf

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>

* missing fil

* Update addons/arsenal/functions/fnc_itemInfo.sqf

* Update addons/arsenal/functions/fnc_refresh.sqf

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>

* remove CBA_loadoutSet gunbag cache

* update fnc_refresh

* fix 3den

---------

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
Co-authored-by: Salluci <salluci.lovi@gmail.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
2023-07-25 09:30:49 +03:00

142 lines
4.1 KiB
Plaintext

#include "script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Brett Mayson
* Handles the actions control group
*
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Current panel control <CONTROL>
* 2: Current panel selection <SCALAR>
* 3: Item config entry <CONFIG>
*
* Return Value:
* None
*
* Public: No
*/
params ["_display", "_control", "_curSel", "_itemCfg"];
GVAR(actionsInfo) = [_control, _curSel, _itemCfg];
private _panel = [
IDC_buttonPrimaryWeapon,
IDC_buttonHandgun,
IDC_buttonSecondaryWeapon,
IDC_buttonUniform,
IDC_buttonVest,
IDC_buttonBackpack,
IDC_buttonHeadgear,
IDC_buttonGoggles,
IDC_buttonNVG,
IDC_buttonBinoculars,
IDC_buttonMap,
IDC_buttonGPS,
IDC_buttonRadio,
IDC_buttonCompass,
IDC_buttonWatch,
IDC_buttonFace,
IDC_buttonVoice,
IDC_buttonInsignia
] find GVAR(currentLeftPanel);
private _groups = (GVAR(actionList) select _panel) select {
[GVAR(center)] call (_x select 1)
};
private _show = _groups isNotEqualTo [];
private _ctrl = _display displayCtrl IDC_actionsBox;
_ctrl ctrlShow _show;
_ctrl ctrlCommit 0.15;
if (!_show) exitWith {};
private _actionsBoxCtrl = _display displayCtrl IDC_actionsBox;
private _actionsCurrentPageCtrl = _display displayCtrl IDC_actionsCurrentPage;
private _currentPage = GVAR(currentActionPage);
private _pages = count _groups;
if (_currentPage < 0) then {
_currentPage = _pages - 1;
};
if (_currentPage >= _pages) then {
_currentPage = 0;
GVAR(currentActionPage) = _currentPage;
};
{
private _ctrl = _display displayCtrl _x;
_ctrl ctrlShow (_pages > 1);
_ctrl ctrlCommit 0;
} forEach [IDC_actionsPreviousPage, IDC_actionsNextPage];
private _group = _groups select _currentPage;
private _items = _group select 2 select {
[GVAR(center)] call (_x select 3)
};
_actionsCurrentPageCtrl ctrlSetText (_group select 0);
_actionsCurrentPageCtrl ctrlSetFade 0;
_actionsCurrentPageCtrl ctrlShow true;
_actionsCurrentPageCtrl ctrlCommit 0;
{
_x params ["_type", "_label", "_statement"];
private _idc = 9001 + _forEachIndex * 2;
private _actionTextCtrl = _display displayCtrl _idc;
private _actionButtonCtrl = _display displayCtrl (_idc + 1);
switch (_type) do {
case ACTION_TYPE_BUTTON: {
_actionButtonCtrl ctrlRemoveAllEventHandlers "ButtonClick";
_actionButtonCtrl ctrlAddEventHandler ["ButtonClick", {
if (is3DEN) exitWith {call FUNC(refresh)};
[{
call FUNC(refresh);
}] call CBA_fnc_execNextFrame;
}];
_actionButtonCtrl ctrlAddEventHandler ["ButtonClick", _statement];
_actionButtonCtrl ctrlSetText _label;
_actionButtonCtrl ctrlSetFade 0;
_actionButtonCtrl ctrlEnable true;
_actionButtonCtrl ctrlCommit 0;
_actionTextCtrl ctrlSetFade 1;
_actionTextCtrl ctrlCommit 0;
};
case ACTION_TYPE_TEXT: {
private _text = (call _statement);
if (isNil "_text") then {
_text = "";
};
_actionTextCtrl ctrlSetText _text;
_actionTextCtrl ctrlSetFade 0;
_actionTextCtrl ctrlCommit 0;
_actionButtonCtrl ctrlSetFade 1;
_actionButtonCtrl ctrlCommit 0;
};
default {
_actionTextCtrl ctrlSetFade 1;
_actionTextCtrl ctrlCommit 0;
_actionButtonCtrl ctrlSetFade 1;
_actionButtonCtrl ctrlCommit 0;
};
};
} forEach _items;
private _actionCount = count _items;
{
private _idc = 9001 + _x * 2;
private _actionTextCtrl = _display displayCtrl _idc;
private _actionButtonCtrl = _display displayCtrl (_idc + 1);
_actionTextCtrl ctrlSetFade 1;
_actionTextCtrl ctrlCommit 0;
_actionButtonCtrl ctrlSetFade 1;
_actionButtonCtrl ctrlCommit 0;
} forEach ([0, 1, 2, 3, 4] select [_actionCount, 5]);
private _pos = ctrlPosition _actionsBoxCtrl;
_pos set [3, ([11, (5 * _actionCount) + 6] select (_actionCount > 0)) * GRID_H];
_actionsBoxCtrl ctrlSetPosition _pos;
_actionsBoxCtrl ctrlCommit 0;