2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2023-07-25 06:30:49 +00:00
|
|
|
#include "..\defines.hpp"
|
|
|
|
/*
|
|
|
|
* Author: Brett Mayson
|
|
|
|
* Handles the actions control group
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Arsenal display <DISPLAY>
|
|
|
|
* 1: Current panel control <CONTROL>
|
2024-01-22 22:33:30 +00:00
|
|
|
* 2: Current panel selection <NUMBER>
|
2023-07-25 06:30:49 +00:00
|
|
|
* 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 {
|
2023-08-18 16:33:56 +00:00
|
|
|
[GVAR(center)] call (_x select 2)
|
2023-07-25 06:30:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private _show = _groups isNotEqualTo [];
|
2024-02-06 23:34:52 +00:00
|
|
|
private _actionsBoxCtrl = _display displayCtrl IDC_actionsBox;
|
|
|
|
_actionsBoxCtrl ctrlShow _show;
|
2024-02-11 22:23:44 +00:00
|
|
|
_actionsBoxCtrl ctrlCommit FADE_DELAY;
|
2023-07-25 06:30:49 +00:00
|
|
|
|
|
|
|
if (!_show) exitWith {};
|
|
|
|
|
|
|
|
private _actionsCurrentPageCtrl = _display displayCtrl IDC_actionsCurrentPage;
|
|
|
|
|
|
|
|
private _currentPage = GVAR(currentActionPage);
|
|
|
|
private _pages = count _groups;
|
2023-08-18 16:33:56 +00:00
|
|
|
|
2023-07-25 06:30:49 +00:00
|
|
|
if (_currentPage < 0) then {
|
|
|
|
_currentPage = _pages - 1;
|
|
|
|
};
|
2023-08-18 16:33:56 +00:00
|
|
|
|
2023-07-25 06:30:49 +00:00
|
|
|
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;
|
2023-08-18 16:33:56 +00:00
|
|
|
private _items = _group select 3 select {
|
|
|
|
[GVAR(center)] call (_x select 4)
|
2023-07-25 06:30:49 +00:00
|
|
|
};
|
|
|
|
|
2023-08-18 16:33:56 +00:00
|
|
|
_actionsCurrentPageCtrl ctrlSetText (_group select 1);
|
2023-07-25 06:30:49 +00:00
|
|
|
_actionsCurrentPageCtrl ctrlShow true;
|
|
|
|
_actionsCurrentPageCtrl ctrlCommit 0;
|
|
|
|
|
2024-02-06 23:34:52 +00:00
|
|
|
private _activeCtrls = [];
|
2023-07-25 06:30:49 +00:00
|
|
|
{
|
2023-08-18 16:33:56 +00:00
|
|
|
_x params ["", "_type", "_label", "_statement"];
|
|
|
|
|
2024-02-11 22:23:44 +00:00
|
|
|
private _idc = IDC_actionsText1 + _type + _forEachIndex * 2;
|
|
|
|
private _actionCtrl = _display displayCtrl _idc;
|
2023-08-18 16:33:56 +00:00
|
|
|
|
2023-07-25 06:30:49 +00:00
|
|
|
switch (_type) do {
|
|
|
|
case ACTION_TYPE_BUTTON: {
|
2024-02-11 22:23:44 +00:00
|
|
|
_actionCtrl ctrlRemoveAllEventHandlers "ButtonClick";
|
|
|
|
_actionCtrl ctrlAddEventHandler ["ButtonClick", {
|
2023-08-20 03:56:59 +00:00
|
|
|
if (is3DEN) exitWith {[true] call FUNC(refresh)};
|
2023-07-25 06:30:49 +00:00
|
|
|
[{
|
2023-08-20 03:56:59 +00:00
|
|
|
[true] call FUNC(refresh);
|
2023-07-25 06:30:49 +00:00
|
|
|
}] call CBA_fnc_execNextFrame;
|
|
|
|
}];
|
2024-02-06 23:34:52 +00:00
|
|
|
|
2024-02-11 22:23:44 +00:00
|
|
|
_actionCtrl ctrlAddEventHandler ["ButtonClick", _statement];
|
|
|
|
_actionCtrl ctrlSetText _label;
|
|
|
|
_actionCtrl ctrlEnable true;
|
2023-07-25 06:30:49 +00:00
|
|
|
};
|
|
|
|
case ACTION_TYPE_TEXT: {
|
2023-08-18 16:33:56 +00:00
|
|
|
private _text = call _statement;
|
|
|
|
|
2023-07-25 06:30:49 +00:00
|
|
|
if (isNil "_text") then {
|
|
|
|
_text = "";
|
|
|
|
};
|
2024-02-06 23:34:52 +00:00
|
|
|
if (_text isEqualType []) then {
|
|
|
|
_text = _text joinString endl;
|
|
|
|
};
|
2023-08-18 16:33:56 +00:00
|
|
|
|
2024-02-11 22:23:44 +00:00
|
|
|
_actionCtrl ctrlSetText _text;
|
|
|
|
_actionCtrl ctrlSetPositionH (ctrlTextHeight _actionCtrl);
|
|
|
|
_actionCtrl ctrlEnable false;
|
2023-07-25 06:30:49 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-02-11 22:23:44 +00:00
|
|
|
if (_activeCtrls isNotEqualTo []) then {
|
|
|
|
(ctrlPosition (_activeCtrls select -1)) params ["", "_lastPosY", "", "_lastPosH"];
|
|
|
|
_actionCtrl ctrlSetPositionY (_lastPosY + _lastPosH + GRID_H);
|
|
|
|
} else {
|
|
|
|
_actionCtrl ctrlSetPositionY ((5 + _type) * GRID_H);
|
|
|
|
};
|
|
|
|
|
|
|
|
_actionCtrl ctrlShow true;
|
|
|
|
_actionCtrl ctrlCommit 0;
|
|
|
|
_activeCtrls pushBack _actionCtrl;
|
|
|
|
} forEach _items;
|
2023-07-25 06:30:49 +00:00
|
|
|
|
|
|
|
{
|
2024-02-11 22:23:44 +00:00
|
|
|
private _idc = ctrlIDC _x;
|
|
|
|
if (_idc < IDC_actionsText1 || _idc > IDC_actionsButton5) then {continue};
|
2023-08-18 16:33:56 +00:00
|
|
|
|
2024-02-11 22:23:44 +00:00
|
|
|
_x ctrlShow false;
|
|
|
|
_x ctrlEnable false;
|
|
|
|
_x ctrlSetPositionY 0;
|
|
|
|
_x ctrlCommit 0;
|
|
|
|
} forEach ((allControls _actionsBoxCtrl) select {!(_x in _activeCtrls)});
|
2023-07-25 06:30:49 +00:00
|
|
|
|
2024-02-06 23:34:52 +00:00
|
|
|
(ctrlPosition (_activeCtrls select -1)) params ["", "_lastPosY", "", "_lastPosH"];
|
|
|
|
private _actionsBoxHeight = _lastPosY + _lastPosH + GRID_H;
|
|
|
|
_actionsBoxCtrl ctrlSetPositionH _actionsBoxHeight;
|
2023-07-25 06:30:49 +00:00
|
|
|
_actionsBoxCtrl ctrlCommit 0;
|
2024-02-06 23:34:52 +00:00
|
|
|
|
|
|
|
private _background = _display displayCtrl IDC_actionsBackground1;
|
|
|
|
_background ctrlSetPositionH _actionsBoxHeight;
|
|
|
|
_background ctrlCommit 0;
|