Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arsenal - Action Buttons #9069

Merged
merged 15 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/arsenal/ACE_Arsenal_Actions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class GVAR(actions) {};
7 changes: 5 additions & 2 deletions addons/arsenal/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PREP(addDefaultLoadout);
PREP(addListBoxItem);
PREP(addSort);
PREP(addRightPanelButton);
PREP(addSort);
PREP(addStat);
PREP(addVirtualItems);
PREP(attributeAddCompatible);
Expand All @@ -16,6 +16,7 @@ PREP(attributeLoad);
PREP(attributeMode);
PREP(attributeSelect);
PREP(baseWeapon);
PREP(buttonActionsPage);
PREP(buttonCargo);
PREP(buttonClearAll);
PREP(buttonExport);
Expand All @@ -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);
Expand All @@ -58,6 +60,7 @@ PREP(onSelChangedRightListnBox);
PREP(open3DEN);
PREP(openBox);
PREP(portVALoadouts);
PREP(refresh);
PREP(removeBox);
PREP(removeSort);
PREP(removeStat);
Expand Down
42 changes: 29 additions & 13 deletions addons/arsenal/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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), {
Expand All @@ -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;

Expand Down
16 changes: 14 additions & 2 deletions addons/arsenal/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions addons/arsenal/functions/fnc_buttonActionsPage.sqf
Original file line number Diff line number Diff line change
@@ -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 <DISPLAY>
* 1. Actions control <CONTROL>
* 2: Previous or next <BOOL> (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;
5 changes: 2 additions & 3 deletions addons/arsenal/functions/fnc_buttonHide.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
30 changes: 0 additions & 30 deletions addons/arsenal/functions/fnc_buttonStats.sqf

This file was deleted.

98 changes: 98 additions & 0 deletions addons/arsenal/functions/fnc_compileActions.sqf
Original file line number Diff line number Diff line change
@@ -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];
Loading