diff --git a/addons/arsenal/ACE_Arsenal_Actions.hpp b/addons/arsenal/ACE_Arsenal_Actions.hpp new file mode 100644 index 0000000000..a5b95241e2 --- /dev/null +++ b/addons/arsenal/ACE_Arsenal_Actions.hpp @@ -0,0 +1 @@ +class GVAR(actions) {}; diff --git a/addons/arsenal/XEH_PREP.hpp b/addons/arsenal/XEH_PREP.hpp index d695861f40..a891b401f4 100644 --- a/addons/arsenal/XEH_PREP.hpp +++ b/addons/arsenal/XEH_PREP.hpp @@ -1,7 +1,7 @@ PREP(addDefaultLoadout); PREP(addListBoxItem); -PREP(addSort); PREP(addRightPanelButton); +PREP(addSort); PREP(addStat); PREP(addVirtualItems); PREP(attributeAddCompatible); @@ -16,6 +16,7 @@ PREP(attributeLoad); PREP(attributeMode); PREP(attributeSelect); PREP(baseWeapon); +PREP(buttonActionsPage); PREP(buttonCargo); PREP(buttonClearAll); PREP(buttonExport); @@ -26,15 +27,16 @@ PREP(buttonLoadoutsLoad); PREP(buttonLoadoutsRename); PREP(buttonLoadoutsSave); PREP(buttonLoadoutsShare); -PREP(buttonStats); PREP(buttonStatsPage); PREP(clearSearchbar); +PREP(compileActions); PREP(compileSorts); PREP(compileStats); PREP(fillLeftPanel); PREP(fillLoadoutsList); PREP(fillRightPanel); PREP(fillSort); +PREP(handleActions); PREP(handleLoadoutsSearchbar); PREP(handleMouse); PREP(handleScrollWheel); @@ -58,6 +60,7 @@ PREP(onSelChangedRightListnBox); PREP(open3DEN); PREP(openBox); PREP(portVALoadouts); +PREP(refresh); PREP(removeBox); PREP(removeSort); PREP(removeStat); diff --git a/addons/arsenal/XEH_preInit.sqf b/addons/arsenal/XEH_preInit.sqf index 711da4a037..34299c1871 100644 --- a/addons/arsenal/XEH_preInit.sqf +++ b/addons/arsenal/XEH_preInit.sqf @@ -20,24 +20,14 @@ PREP_RECOMPILE_END; private _statsNextPageCtrl = _display displayCtrl IDC_statsNextPage; private _statsCurrentPageCtrl = _display displayCtrl IDC_statsCurrentPage; - private _statsButtonCtrl = _display displayCtrl IDC_statsButton; - private _statsButtonCloseCtrl = _display displayCtrl IDC_statsButtonClose; - { _x ctrlShow (GVAR(showStats) && {_showStats}); } forEach [ _statsCtrlGroupCtrl, _statsPreviousPageCtrl, _statsNextPageCtrl, - _statsCurrentPageCtrl, - _statsButtonCloseCtrl + _statsCurrentPageCtrl ]; - - _statsButtonCtrl ctrlShow (!GVAR(showStats) && {_showStats}) -}] call CBA_fnc_addEventHandler; - -[QGVAR(statsButton), { - _this call FUNC(buttonStats); }] call CBA_fnc_addEventHandler; [QGVAR(statsChangePage), { @@ -48,9 +38,35 @@ PREP_RECOMPILE_END; _this call FUNC(handleStats); }] call CBA_fnc_addEventHandler; -// Compile sorts and stats -call FUNC(compileStats); +[QGVAR(actionsChangePage), { + _this call FUNC(buttonActionsPage); +}] call CBA_fnc_addEventHandler; + +[QGVAR(displayActions), { + _this call FUNC(handleActions); +}] call CBA_fnc_addEventHandler; + +[QGVAR(actionsToggle), { + params ["_display", "_showActions"]; + + private _actionsCtrlGroupCtrl = _display displayCtrl IDC_actionsBox; + private _actionsPreviousPageCtrl = _display displayCtrl IDC_actionsPreviousPage; + private _actionsNextPageCtrl = _display displayCtrl IDC_actionsNextPage; + private _actionsCurrentPageCtrl = _display displayCtrl IDC_actionsCurrentPage; + + { + _x ctrlShow (GVAR(showActions) && {_showActions}); + } forEach [ + _actionsCtrlGroupCtrl, + _actionsPreviousPageCtrl, + _actionsNextPageCtrl, + _actionsCurrentPageCtrl + ]; +}] call CBA_fnc_addEventHandler; + +call FUNC(compileActions); call FUNC(compileSorts); +call FUNC(compileStats); [QUOTE(ADDON), {!isNil QGVAR(camera)}] call CBA_fnc_registerFeatureCamera; diff --git a/addons/arsenal/defines.hpp b/addons/arsenal/defines.hpp index 220a3d82c5..073d0b3d43 100644 --- a/addons/arsenal/defines.hpp +++ b/addons/arsenal/defines.hpp @@ -142,8 +142,20 @@ #define IDC_statsPreviousPage 52 #define IDC_statsNextPage 53 #define IDC_statsCurrentPage 54 -#define IDC_statsButton 55 -#define IDC_statsButtonClose 56 +#define IDC_actionsBox 90 +#define IDC_actionsText1 9001 +#define IDC_actionsButton1 9002 +#define IDC_actionsText2 9003 +#define IDC_actionsButton2 9004 +#define IDC_actionsText3 9005 +#define IDC_actionsButton3 9006 +#define IDC_actionsText4 9007 +#define IDC_actionsButton4 9008 +#define IDC_actionsText5 9009 +#define IDC_actionsButton5 9010 +#define IDC_actionsPreviousPage 91 +#define IDC_actionsNextPage 92 +#define IDC_actionsCurrentPage 93 #define IDD_loadouts_display 1127002 #define IDC_centerBox 3 diff --git a/addons/arsenal/functions/fnc_buttonActionsPage.sqf b/addons/arsenal/functions/fnc_buttonActionsPage.sqf new file mode 100644 index 0000000000..59f519799f --- /dev/null +++ b/addons/arsenal/functions/fnc_buttonActionsPage.sqf @@ -0,0 +1,26 @@ +#include "script_component.hpp" +#include "..\defines.hpp" +/* + * Author: Brett Mayson + * Handles the previous / next page buttons for actions + * + * Arguments: + * 0: Arsenal display + * 1. Actions control + * 2: Previous or next (false = previous, true = next) + * + * Return Value: + * None + * + * Public: No +*/ + +params ["_display", "_control", "_nextPage"]; + +TRACE_1("control enabled", ctrlEnabled _control); +if !(ctrlEnabled _control) exitWith {}; + +GVAR(currentActionPage) = GVAR(currentActionPage) + ([-1, 1] select _nextPage); + +GVAR(actionsInfo) params ["_panelControl", "_curSel", "_itemCfg"]; +[QGVAR(displayActions), [_display, _panelControl, _curSel, _itemCfg]] call CBA_fnc_localEvent; diff --git a/addons/arsenal/functions/fnc_buttonHide.sqf b/addons/arsenal/functions/fnc_buttonHide.sqf index 8432982f7b..6685150955 100644 --- a/addons/arsenal/functions/fnc_buttonHide.sqf +++ b/addons/arsenal/functions/fnc_buttonHide.sqf @@ -52,11 +52,10 @@ private _ctrl = controlNull; IDC_buttonCurrentMag2, IDC_iconBackgroundCurrentMag, IDC_iconBackgroundCurrentMag2, - IDC_statsButton, IDC_statsPreviousPage, IDC_statsNextPage, - IDC_statsCurrentPage, - IDC_statsButtonClose + IDC_statsCurrentPage ]; [QGVAR(statsToggle), [_display, _showToggle]] call CBA_fnc_localEvent; +[QGVAR(actionsToggle), [_display, _showToggle]] call CBA_fnc_localEvent; diff --git a/addons/arsenal/functions/fnc_buttonStats.sqf b/addons/arsenal/functions/fnc_buttonStats.sqf deleted file mode 100644 index 34dbfc608e..0000000000 --- a/addons/arsenal/functions/fnc_buttonStats.sqf +++ /dev/null @@ -1,30 +0,0 @@ -#include "script_component.hpp" -#include "..\defines.hpp" -/* - * Author: Alganthe - * Toggle the stats control group. - * - * Arguments: - * 0: Arsenal display - * - * Return Value: - * None - * - * Public: No -*/ - -params ["_display"]; - -(_display displayCtrl IDC_statsButton) ctrlShow GVAR(showStats); - -GVAR(showStats) = !GVAR(showStats); - -{ - (_display displayCtrl _x) ctrlShow GVAR(showStats); -} forEach [ - IDC_statsBox, - IDC_statsPreviousPage, - IDC_statsNextPage, - IDC_statsCurrentPage, - IDC_statsButtonClose -]; diff --git a/addons/arsenal/functions/fnc_compileActions.sqf b/addons/arsenal/functions/fnc_compileActions.sqf new file mode 100644 index 0000000000..921f7342e6 --- /dev/null +++ b/addons/arsenal/functions/fnc_compileActions.sqf @@ -0,0 +1,98 @@ +#include "script_component.hpp" +/* + * Author: Brett Mayson + * Create the internal actions arrays when needed for the first time + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public: No +*/ + +if (!isNil QGVAR(actionList)) exitWith {}; + +private _actionList = [ + [], // Primary 0 + [], // Handgun 1 + [], // Launcher 2 + [], // Uniform 3 + [], // Vests 4 + [], // Backpacks 5 + [], // Headgear 6 + [], // Goggles 7 + [], // NVGs 8 + [], // Binoculars 9 + [], // Map 10 + [], // GPS 11 + [], // Radio 12 + [], // Compass 13 + [], // Watch 14 + [], // Face 15 + [], // Voice 16 + [] // Insignia 17 +]; + +private _configGroupEntries = "true" configClasses (configFile >> QGVAR(actions)); + +{ + private _configActions = "true" configClasses _x; + + private _rootDisplayName = getText (_x >> "displayName"); + private _rootCondition = getText (_x >> "condition"); + private _rootTabs = getArray (_x >> "tabs"); + + if (_rootCondition != "") then { + _rootCondition = compile _rootCondition; + } else { + _rootCondition = {true}; + }; + + private _group = []; + + { + private _label = getText (_x >> "label"); + private _condition = getText (_x >> "condition"); + private _statement = getText (_x >> "statement"); + private _text = getText (_x >> "text"); + private _textStatement = getText (_x >> "textStatement"); + + private _type = switch (false) do { + case (_text == ""): { + _statement = format ["""%1""", _text]; + ACTION_TYPE_TEXT + }; + case (_textStatement == ""): { + _statement = _textStatement; + ACTION_TYPE_TEXT + }; + case (_statement == ""): { + _statement = _statement; + ACTION_TYPE_BUTTON + }; + default { + -1 + }; + }; + if (_type == -1) then { + continue; + }; + _statement = compile format [QUOTE([GVAR(center)] call {%1}), _statement]; + + if (_condition != "") then { + _condition = compile _condition; + } else { + _condition = {true}; + }; + + _group pushBack [_type, _label, _statement, _condition]; + } forEach _configActions; + + { + (_actionList select _x) pushBack [_rootDisplayName, _rootCondition, _group]; + } forEach _rootTabs; +} forEach _configGroupEntries; + +missionNamespace setVariable [QGVAR(actionList), _actionList]; diff --git a/addons/arsenal/functions/fnc_handleActions.sqf b/addons/arsenal/functions/fnc_handleActions.sqf new file mode 100644 index 0000000000..f8ed2d092d --- /dev/null +++ b/addons/arsenal/functions/fnc_handleActions.sqf @@ -0,0 +1,141 @@ +#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 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; diff --git a/addons/arsenal/functions/fnc_handleStats.sqf b/addons/arsenal/functions/fnc_handleStats.sqf index 95c078552d..faafa52103 100644 --- a/addons/arsenal/functions/fnc_handleStats.sqf +++ b/addons/arsenal/functions/fnc_handleStats.sqf @@ -129,13 +129,20 @@ if (!isNil "_itemCfg") then { // Resize the window [[1, 2, 3, 4, 5] select [_statsCount, 5]] call _hideUnusedFnc; + private _height = ([11, (10 * _statsCount) + 5] select (_statsCount > 0)); _statsBoxCtrl ctrlSetPosition [ (0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP, safezoneY + 1.8 * GRID_H, 47 * GRID_W, - ([11, (10 * _statsCount) + 5] select (_statsCount > 0)) * GRID_H + _height * GRID_H ]; _statsBoxCtrl ctrlCommit 0; + private _ctrl = _display displayCtrl IDC_actionsBox; + private _pos = ctrlPosition _ctrl; + _pos set [1, safezoneY + (_height + 3.6) * GRID_H]; + _ctrl ctrlSetPosition _pos; + _ctrl ctrlCommit 0; + GVAR(statsInfo) = [_leftPanel, _statsIndex, _control, _curSel, _itemCfg]; @@ -240,6 +247,11 @@ if (!isNil "_itemCfg") then { 11 * GRID_H ]; _statsBoxCtrl ctrlCommit 0; + private _ctrl = _display displayCtrl IDC_actionsBox; + private _pos = ctrlPosition _ctrl; + _pos set [1, safezoneY + (14.6) * GRID_H]; + _ctrl ctrlSetPosition _pos; + _ctrl ctrlCommit 0; { _x ctrlSetFade 1; diff --git a/addons/arsenal/functions/fnc_itemInfo.sqf b/addons/arsenal/functions/fnc_itemInfo.sqf index 710864e3e3..9dad0c0247 100644 --- a/addons/arsenal/functions/fnc_itemInfo.sqf +++ b/addons/arsenal/functions/fnc_itemInfo.sqf @@ -26,6 +26,7 @@ if (isClass _itemCfg) then { _ctrlInfo ctrlCommit FADE_DELAY; [QGVAR(displayStats), [_display, _control, _curSel, _itemCfg]] call CBA_fnc_localEvent; + [QGVAR(displayActions), [_display, _control, _curSel, _itemCfg]] call CBA_fnc_localEvent; // Name + author (_display displayCtrl IDC_infoName) ctrlSetText ([_control lbText _curSel, _control lnbText [_curSel, 1]] select (ctrlType _control == CT_LISTNBOX)); @@ -69,6 +70,7 @@ if (isClass _itemCfg) then { } else { [QGVAR(displayStats), [_display, _control, -1, nil]] call CBA_fnc_localEvent; + [QGVAR(displayActions), [_display, _control, -1, nil]] call CBA_fnc_localEvent; _ctrlInfo ctrlSetFade 1; _ctrlInfo ctrlCommit FADE_DELAY; diff --git a/addons/arsenal/functions/fnc_onArsenalClose.sqf b/addons/arsenal/functions/fnc_onArsenalClose.sqf index 38db27e196..188a1a9ded 100644 --- a/addons/arsenal/functions/fnc_onArsenalClose.sqf +++ b/addons/arsenal/functions/fnc_onArsenalClose.sqf @@ -125,6 +125,8 @@ GVAR(statsPagesLeft) = nil; GVAR(statsPagesRight) = nil; GVAR(statsInfo) = nil; +GVAR(showActions) = nil; + GVAR(center) = nil; GVAR(centerNotPlayer) = nil; diff --git a/addons/arsenal/functions/fnc_onArsenalOpen.sqf b/addons/arsenal/functions/fnc_onArsenalOpen.sqf index c4c90c2b26..ce6b81a0f3 100644 --- a/addons/arsenal/functions/fnc_onArsenalOpen.sqf +++ b/addons/arsenal/functions/fnc_onArsenalOpen.sqf @@ -88,6 +88,9 @@ GVAR(statsPagesLeft) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; GVAR(statsPagesRight) = [0, 0, 0, 0, 0, 0, 0, 0]; GVAR(statsInfo) = [true, 0, controlNull, nil, nil]; +GVAR(showActions) = true; +GVAR(currentActionPage) = 0; + // Add the items the player has to virtualItems { switch (_forEachIndex) do { @@ -223,7 +226,15 @@ _statsBoxCtrl ctrlSetPosition [ _statsBoxCtrl ctrlEnable false; _statsBoxCtrl ctrlCommit 0; -(_display displayCtrl IDC_statsButton) ctrlShow false; +// Handle actions +private _actionsBoxCtrl = _display displayCtrl IDC_actionsBox; +_actionsBoxCtrl ctrlSetPosition [ + (0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP, + safezoneY + 58.6 * GRID_H, + 47 * GRID_W, + 11 * GRID_H +]; +_actionsBoxCtrl ctrlCommit 0; // Disable import in MP if (isMultiplayer) then { diff --git a/addons/arsenal/functions/fnc_refresh.sqf b/addons/arsenal/functions/fnc_refresh.sqf new file mode 100644 index 0000000000..8f3ebab7ae --- /dev/null +++ b/addons/arsenal/functions/fnc_refresh.sqf @@ -0,0 +1,19 @@ +#include "script_component.hpp" +#include "..\defines.hpp" +/* + * Author: Brett Mayson + * Refreshes the arsenal to show external changes + * + * Return Value: + * None + * + * Public: No +*/ + +private _display = findDisplay IDD_ace_arsenal; + +call FUNC(updateCurrentItemsList); + +call FUNC(updateUniqueItemsList); + +[_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel); diff --git a/addons/arsenal/script_component.hpp b/addons/arsenal/script_component.hpp index 2eb9c3f170..0f7348b9db 100644 --- a/addons/arsenal/script_component.hpp +++ b/addons/arsenal/script_component.hpp @@ -15,3 +15,6 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" + +#define ACTION_TYPE_BUTTON 0 +#define ACTION_TYPE_TEXT 1 diff --git a/addons/arsenal/ui/RscAttributes.hpp b/addons/arsenal/ui/RscAttributes.hpp index 431869cb14..72b048f2c3 100644 --- a/addons/arsenal/ui/RscAttributes.hpp +++ b/addons/arsenal/ui/RscAttributes.hpp @@ -403,17 +403,6 @@ class GVAR(display) { }; }; }; - class statsButton: ctrlButton { - idc = IDC_statsButton; - style = 2; - text = ">"; - onButtonClick = QUOTE([ARR_2(QQGVAR(statsButton), [ctrlParent (_this select 0)])] call CBA_fnc_localEvent); - x = QUOTE((0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP); - y = QUOTE(safezoneY + 1.8 * GRID_H); - w = QUOTE(6 * GRID_W); - h = QUOTE(6 * GRID_H); - sizeEx = QUOTE(5 * GRID_H); - }; class statsPreviousPage: ctrlButton { idc = IDC_statsPreviousPage; style = 2; @@ -431,29 +420,126 @@ class GVAR(display) { idc = IDC_statsNextPage; text = ">"; onButtonClick = QUOTE([ARR_2(QQGVAR(statsChangePage),[ARR_3(ctrlParent (_this select 0), _this select 0, true)])] call CBA_fnc_localEvent); - x = QUOTE((0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP + 30 * GRID_W); + x = QUOTE((0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP + 42 * GRID_W); }; class statsCurrentPage: RscText { idc = IDC_statsCurrentPage; style = ST_CENTER; x = QUOTE((0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP + 5 * GRID_W); y = QUOTE(safezoneY + 1.8 * GRID_H); - w = QUOTE(25 * GRID_W); + w = QUOTE(37 * GRID_W); h = QUOTE(5 * GRID_H); colorBackground[] = {0,0,0,0}; shadow = 2; sizeEx = QUOTE(5 * GRID_H); text = ""; }; - class statsButtonClose: ctrlButtonPicture { - idc = IDC_statsButtonClose; - colorBackground[] = {0,0,0,0}; - text = "\a3\3DEN\Data\Displays\Display3DEN\search_end_ca.paa"; - onButtonClick = QUOTE([ARR_2(QQGVAR(statsButton), [ctrlParent (_this select 0)])] call CBA_fnc_localEvent); - x = QUOTE((0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP + 42 * GRID_W); - y = QUOTE(safezoneY + 1.8 * GRID_H); - w = QUOTE(5 * GRID_W); - h = QUOTE(5 * GRID_H); + class actionsBox: RscControlsGroupNoScrollbars { + idc = IDC_actionsBox; + x = QUOTE((0.5 - WIDTH_TOTAL / 2) + WIDTH_GAP); + y = QUOTE(safezoneY + 58.6 * GRID_H); + w = QUOTE(47 * GRID_W); + h = QUOTE(55 * GRID_H); + class controls { + class actionsStaticBackground1: ctrlStaticBackground { + idc = -1; + x = QUOTE(0); + y = QUOTE(0); + w = QUOTE(47 * GRID_W); + h = QUOTE(56 * GRID_H); + colorBackground[]={0.1,0.1,0.1,0.5}; + }; + class actionsStaticBackground2: ctrlStaticBackground { + idc = -1; + x = QUOTE(0); + y = QUOTE(0); + w = QUOTE(47 * GRID_W); + h = QUOTE(5 * GRID_H); + colorBackground[]={0.1,0.1,0.1,0.8}; + }; + class actionsText1: RscText { + idc = IDC_actionsText1; + fade = 1; + x = QUOTE(0 * GRID_W); + y = QUOTE(5 * GRID_H); + w = QUOTE(45 * GRID_W); + h = QUOTE(5 * GRID_H); + colorBackground[]={0,0,0,0}; + colorText[]={0.7,0.7,0.7,1}; + sizeEx = QUOTE(5 * GRID_H); + text = ""; + }; + class actionsButton1: ctrlButton { + idc = IDC_actionsButton1; + fade = 1; + text = ""; + x = QUOTE(1 * GRID_W); + y = QUOTE(6 * GRID_H); + w = QUOTE(45 * GRID_W); + h = QUOTE(4 * GRID_H); + }; + class actionsText2: actionsText1 { + idc = IDC_actionsText2; + y = QUOTE(10 * GRID_H); + }; + class actionsButton2: actionsButton1 { + idc = IDC_actionsButton2; + y = QUOTE(11 * GRID_H); + }; + class actionsText3: actionsText1 { + idc = IDC_actionsText3; + y = QUOTE(15 * GRID_H); + }; + class actionsButton3: actionsButton1 { + idc = IDC_actionsButton3; + y = QUOTE(16 * GRID_H); + }; + class actionsText4: actionsText1 { + idc = IDC_actionsText4; + y = QUOTE(20 * GRID_H); + }; + class actionsButton4: actionsButton1 { + idc = IDC_actionsButton4; + y = QUOTE(21 * GRID_H); + }; + class actionsText5: actionsText1 { + idc = IDC_actionsText5; + y = QUOTE(25 * GRID_H); + }; + class actionsButton5: actionsButton1 { + idc = IDC_actionsButton5; + y = QUOTE(26 * GRID_H); + }; + class actionsPreviousPage: ctrlButton { + idc = IDC_actionsPreviousPage; + style= 2; + text="<"; + colorBackground[]={0,0,0,0}; + colorBackgroundDisabled[]= {0,0,0,0}; + onButtonClick = QUOTE([ARR_2(QQGVAR(actionsChangePage),[ARR_3(ctrlParent (_this select 0), _this select 0, false)])] call CBA_fnc_localEvent); + x = QUOTE(0); + y = QUOTE(0); + w = QUOTE(5 * GRID_W); + h = QUOTE(5 * GRID_H); + sizeEx = QUOTE(5.5 * GRID_H); + }; + class actionsNextPage: actionsPreviousPage { + idc = IDC_actionsNextPage; + text = ">"; + onButtonClick = QUOTE([ARR_2(QQGVAR(actionsChangePage),[ARR_3(ctrlParent (_this select 0), _this select 0, true)])] call CBA_fnc_localEvent); + x = QUOTE(42 * GRID_W); + }; + class actionsCurrentPage: RscText { + idc = IDC_actionsCurrentPage; + style = ST_CENTER; + x = QUOTE(5 * GRID_W); + w = QUOTE(37 * GRID_W); + colorBackground[]={0,0,0,0}; + shadow=2; + sizeEx = QUOTE(5 * GRID_H); + text = ""; + }; + }; }; class mouseBlock: RscText { idc = IDC_mouseBlock; diff --git a/addons/gunbag/ACE_Arsenal_Actions.hpp b/addons/gunbag/ACE_Arsenal_Actions.hpp new file mode 100644 index 0000000000..b9d2e5f21f --- /dev/null +++ b/addons/gunbag/ACE_Arsenal_Actions.hpp @@ -0,0 +1,25 @@ +class EGVAR(arsenal,actions) { + class ADDON { + displayName = CSTRING(DisplayName); + condition = QUOTE(_this call FUNC(hasGunbag)); + tabs[] = {0,5}; + class status { + textStatement = QUOTE([_this select 0] call FUNC(weaponName)); + }; + class store { + label = CSTRING(ToGunbag); + condition = QUOTE([ARR_2(_this select 0,_this select 0)] call FUNC(canInteract) == 0); + statement = QUOTE([ARR_2(_this select 0,_this select 0)] call FUNC(toGunbagCallback)); + }; + class retrieve { + label = CSTRING(OffGunbag); + condition = QUOTE([ARR_2(_this select 0,_this select 0)] call FUNC(canInteract) == 1); + statement = QUOTE([ARR_2(_this select 0,_this select 0)] call FUNC(offGunbagCallback)); + }; + class swap { + label = CSTRING(SwapGunbag); + condition = QUOTE([ARR_2(_this select 0,_this select 0)] call FUNC(canInteract) == 2); + statement = QUOTE([ARR_2(_this select 0,_this select 0)] call FUNC(swapGunbagCallback)); + }; + }; +}; diff --git a/addons/gunbag/XEH_PREP.hpp b/addons/gunbag/XEH_PREP.hpp index 2e2c57a056..78b7be0968 100644 --- a/addons/gunbag/XEH_PREP.hpp +++ b/addons/gunbag/XEH_PREP.hpp @@ -12,3 +12,4 @@ PREP(hasGunbag); PREP(isMachineGun); PREP(BIArsenalClose); PREP(BIArsenalOpen); +PREP(weaponName); diff --git a/addons/gunbag/XEH_preInit.sqf b/addons/gunbag/XEH_preInit.sqf index 7829c58074..93e79f14a0 100644 --- a/addons/gunbag/XEH_preInit.sqf +++ b/addons/gunbag/XEH_preInit.sqf @@ -26,34 +26,11 @@ PREP_RECOMPILE_END; }, _this] call CBA_fnc_execNextFrame; }] call CBA_fnc_addClassEventHandler; -[QEGVAR(arsenal,displayOpened), { - - private _center = EGVAR(arsenal,center); - - if (_center call FUNC(hasGunBag)) then { - GVAR(arsenalCache) = (backpackContainer _center) getVariable [QGVAR(gunbagWeapon), []]; - }; -}] call CBA_fnc_addEventHandler; - -[QEGVAR(arsenal,displayClosed), { - - if (!isNil QGVAR(arsenalCache)) then { - (backpackContainer EGVAR(arsenal,center)) setVariable [QGVAR(gunbagWeapon),GVAR(arsenalCache), true]; - }; - - GVAR(arsenalCache) = nil; -}] call CBA_fnc_addEventHandler; - ["CBA_loadoutSet", { params ["_unit", "_loadout", "_extendedInfo"]; private _gunbagWeapon = _extendedInfo getOrDefault [QGVAR(gunbagWeapon), []]; if (_gunbagWeapon isNotEqualTo []) then { (backpackContainer _unit) setVariable [QGVAR(gunbagWeapon), _gunbagWeapon, true]; - - // Prevent the arsenal closed event from overwriting new info - if (!isNil QGVAR(arsenalCache)) then { - GVAR(arsenalCache) = _gunbagWeapon; - }; }; }] call CBA_fnc_addEventHandler; diff --git a/addons/gunbag/config.cpp b/addons/gunbag/config.cpp index 6efaceb5d6..037d3d5df8 100644 --- a/addons/gunbag/config.cpp +++ b/addons/gunbag/config.cpp @@ -16,3 +16,4 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" +#include "ACE_Arsenal_Actions.hpp" diff --git a/addons/gunbag/functions/fnc_weaponName.sqf b/addons/gunbag/functions/fnc_weaponName.sqf new file mode 100644 index 0000000000..6232c24685 --- /dev/null +++ b/addons/gunbag/functions/fnc_weaponName.sqf @@ -0,0 +1,26 @@ +#include "script_component.hpp" +/* + * Author: Ir0n1E, Brett Mayson + * Get gunbag weapon name + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [player] call ace_gunbag_fnc_weaponName + * + * Public: No + */ + +params ["_unit"]; + +private _state = (backpackContainer _unit) getVariable [QGVAR(gunbagWeapon), []]; + +private _name = localize LSTRING(empty); +if (_state isNotEqualTo []) then { + _name = getText (configFile >> "CfgWeapons" >> _state#0 >> "displayName"); +}; +_name diff --git a/docs/wiki/framework/arsenal-framework.md b/docs/wiki/framework/arsenal-framework.md index ceb738266e..cbe43ac113 100644 --- a/docs/wiki/framework/arsenal-framework.md +++ b/docs/wiki/framework/arsenal-framework.md @@ -382,7 +382,39 @@ For config added sorts the classname is used, for function added ones the string The same numbers are used for sorting methods as for stats (see `5.4 Stat tab numbers`). -## 7. Eventhandlers +## 7. Actions + +ACE Arsenal actions are customizable, this will show you how. + +### 7.1 Adding actions via config + +Actions use the same tab definitions as stats, found above. + +```cpp +class ace_arsenal_actions { + class TAG_myActions { + displayName = "My Actions"; + condition = QUOTE(true); + tabs[] = {0,5}; + class text { + // A simple text label + text = "My text"; + }; + class statement { + // Statement output as text + textStatement = QUOTE([_this select 0] call tag_fnc_myTextStatement); + }; + class button { + label = "My Action"; + condition = QUOTE(true); + statement = QUOTE(_this call tag_fnc_myAction); + }; + }; +}; +``` +The focused unit object is passed to the condition and statement functions. + +## 8. Eventhandlers All are local. @@ -409,9 +441,9 @@ All are local. | ace_arsenal_loadoutsTabChanged | loadouts screen display (DISPLAY), tab control (CONTROL) | 3.12.3 | | ace_arsenal_loadoutsListFilled | loadouts screen display (DISPLAY), tab control (CONTROL) | 3.12.3 | -## 8. Custom sub item categories +## 9. Custom sub item categories -### 8.1 Adding a sub item category +### 9.1 Adding a sub item category `ace_arsenal_fnc_addRightPanelButton`