#include "..\script_component.hpp" #include "..\defines.hpp" /* * Author: Brett Mayson * Handles the actions control group * * Arguments: * 0: Arsenal display * 1: Current panel control * 2: Current panel selection * 3: Item config entry * * 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 2) }; private _show = _groups isNotEqualTo []; private _actionsBoxCtrl = _display displayCtrl IDC_actionsBox; _actionsBoxCtrl ctrlShow _show; _actionsBoxCtrl ctrlCommit 0.15; if (!_show) exitWith {}; 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 3 select { [GVAR(center)] call (_x select 4) }; _actionsCurrentPageCtrl ctrlSetText (_group select 1); _actionsCurrentPageCtrl ctrlSetFade 0; _actionsCurrentPageCtrl ctrlShow true; _actionsCurrentPageCtrl ctrlCommit 0; private _activeCtrls = []; { _x params ["", "_type", "_label", "_statement"]; private _idc = IDC_actionsText1 + _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 {[true] call FUNC(refresh)}; [{ [true] call FUNC(refresh); }] call CBA_fnc_execNextFrame; }]; if (_activeCtrls isNotEqualTo []) then { (ctrlPosition (_activeCtrls select -1)) params ["", "_lastPosY", "", "_lastPosH"]; _actionButtonCtrl ctrlSetPositionY (_lastPosY + _lastPosH + GRID_H); } else { _actionButtonCtrl ctrlSetPositionY (6 * GRID_H); }; _actionButtonCtrl ctrlAddEventHandler ["ButtonClick", _statement]; _actionButtonCtrl ctrlSetText _label; _actionButtonCtrl ctrlSetFade 0; _actionButtonCtrl ctrlEnable true; _actionButtonCtrl ctrlCommit 0; _actionTextCtrl ctrlSetFade 1; _actionTextCtrl ctrlEnable false; _actionTextCtrl ctrlCommit 0; _activeCtrls pushBack _actionButtonCtrl; }; case ACTION_TYPE_TEXT: { private _text = call _statement; if (isNil "_text") then { _text = ""; }; if (_text isEqualType []) then { _text = _text joinString endl; }; if (_activeCtrls isNotEqualTo []) then { (ctrlPosition (_activeCtrls select -1)) params ["", "_lastPosY", "", "_lastPosH"]; _actionTextCtrl ctrlSetPositionY (_lastPosY + _lastPosH + GRID_H); } else { _actionTextCtrl ctrlSetPositionY (5 * GRID_H); }; _actionTextCtrl ctrlSetText _text; _actionTextCtrl ctrlSetPositionH (ctrlTextHeight _actionTextCtrl); _actionTextCtrl ctrlSetFade 0; _actionTextCtrl ctrlEnable false; _actionTextCtrl ctrlCommit 0; _actionButtonCtrl ctrlSetFade 1; _actionButtonCtrl ctrlEnable false; _actionButtonCtrl ctrlCommit 0; _activeCtrls pushBack _actionTextCtrl; }; default { _actionTextCtrl ctrlSetFade 1; _actionTextCtrl ctrlCommit 0; _actionButtonCtrl ctrlSetFade 1; _actionButtonCtrl ctrlEnable false; _actionButtonCtrl ctrlCommit 0; }; }; } forEach _items; private _actionCount = count _items; { private _idc = IDC_actionsText1 + _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; (ctrlPosition (_activeCtrls select -1)) params ["", "_lastPosY", "", "_lastPosH"]; private _actionsBoxHeight = _lastPosY + _lastPosH + GRID_H; _actionsBoxCtrl ctrlSetPositionH _actionsBoxHeight; _actionsBoxCtrl ctrlCommit 0; private _background = _display displayCtrl IDC_actionsBackground1; _background ctrlSetPositionH _actionsBoxHeight; _background ctrlCommit 0;