mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Arsenal Actions - Add support for multiline text & updating on cargo event (#9771)
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
This commit is contained in:
parent
8de0740e94
commit
e69ffb6f21
@ -36,6 +36,15 @@ call FUNC(compileStats);
|
|||||||
EGVAR(common,blockItemReplacement) = false;
|
EGVAR(common,blockItemReplacement) = false;
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
[QGVAR(cargoChanged), {
|
||||||
|
params ["_display"];
|
||||||
|
// Only update actions if necessary, this can get performance-intensive using the arrow keys
|
||||||
|
if (!GVAR(updateActionsOnCargoChange)) exitWith {};
|
||||||
|
private _actionInfo = [_display];
|
||||||
|
_actionInfo append GVAR(actionInfo);
|
||||||
|
[QGVAR(displayActions), _actionInfo] call CBA_fnc_localEvent;
|
||||||
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
// Setup Tools tab
|
// Setup Tools tab
|
||||||
[keys (uiNamespace getVariable [QGVAR(configItemsTools), createHashMap]), LLSTRING(toolsTab), TOOLS_TAB_ICON, -1, true] call FUNC(addRightPanelButton);
|
[keys (uiNamespace getVariable [QGVAR(configItemsTools), createHashMap]), LLSTRING(toolsTab), TOOLS_TAB_ICON, -1, true] call FUNC(addRightPanelButton);
|
||||||
|
|
||||||
|
@ -155,6 +155,8 @@
|
|||||||
#define IDC_statsNextPage 53
|
#define IDC_statsNextPage 53
|
||||||
#define IDC_statsCurrentPage 54
|
#define IDC_statsCurrentPage 54
|
||||||
#define IDC_actionsBox 90
|
#define IDC_actionsBox 90
|
||||||
|
#define IDC_actionsBackground1 90010
|
||||||
|
#define IDC_actionsBackground2 90011
|
||||||
#define IDC_actionsText1 9001
|
#define IDC_actionsText1 9001
|
||||||
#define IDC_actionsButton1 9002
|
#define IDC_actionsButton1 9002
|
||||||
#define IDC_actionsText2 9003
|
#define IDC_actionsText2 9003
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
* 3: Actions <ARRAY of ARRAYS>
|
* 3: Actions <ARRAY of ARRAYS>
|
||||||
* 4: Condition <CODE> (default: {true})
|
* 4: Condition <CODE> (default: {true})
|
||||||
* 5: Scope editor <NUMBER> (default: 2)
|
* 5: Scope editor <NUMBER> (default: 2)
|
||||||
|
* 6: Update when cargo content changes <BOOL> (default: false)
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* 0: Array of IDs <ARRAY of STRINGS>
|
* 0: Array of IDs <ARRAY of STRINGS>
|
||||||
@ -30,7 +31,8 @@ params [
|
|||||||
["_title", "", [""]],
|
["_title", "", [""]],
|
||||||
["_actions", [], [[]]],
|
["_actions", [], [[]]],
|
||||||
["_rootCondition", {true}, [{}]],
|
["_rootCondition", {true}, [{}]],
|
||||||
["_scopeEditor", 2, [0]]
|
["_scopeEditor", 2, [0]],
|
||||||
|
["_updateOnCargoChange", false, [false]]
|
||||||
];
|
];
|
||||||
|
|
||||||
// Compile actions from config (in case this is called before preInit)
|
// Compile actions from config (in case this is called before preInit)
|
||||||
@ -119,4 +121,8 @@ private _group = [];
|
|||||||
};
|
};
|
||||||
} forEach _tabs;
|
} forEach _tabs;
|
||||||
|
|
||||||
|
if (_updateOnCargoChange) then {
|
||||||
|
GVAR(updateActionsOnCargoChange) = true;
|
||||||
|
};
|
||||||
|
|
||||||
_return
|
_return
|
||||||
|
@ -37,6 +37,8 @@ private _actionList = [
|
|||||||
|
|
||||||
private _configGroupEntries = "true" configClasses (configFile >> QGVAR(actions));
|
private _configGroupEntries = "true" configClasses (configFile >> QGVAR(actions));
|
||||||
|
|
||||||
|
GVAR(updateActionsOnCargoChange) = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
private _scopeEditor = getNumber (_x >> "scopeEditor");
|
private _scopeEditor = getNumber (_x >> "scopeEditor");
|
||||||
|
|
||||||
@ -48,6 +50,10 @@ private _configGroupEntries = "true" configClasses (configFile >> QGVAR(actions)
|
|||||||
private _rootDisplayName = getText (_x >> "displayName");
|
private _rootDisplayName = getText (_x >> "displayName");
|
||||||
private _rootCondition = getText (_x >> "condition");
|
private _rootCondition = getText (_x >> "condition");
|
||||||
private _rootTabs = getArray (_x >> "tabs");
|
private _rootTabs = getArray (_x >> "tabs");
|
||||||
|
private _updateOnCargoChanged = getNumber (_x >> "updateOnCargoChanged");
|
||||||
|
if (_updateOnCargoChanged > 0) then {
|
||||||
|
GVAR(updateActionsOnCargoChange) = true;
|
||||||
|
};
|
||||||
|
|
||||||
if (_rootCondition != "") then {
|
if (_rootCondition != "") then {
|
||||||
_rootCondition = compile _rootCondition;
|
_rootCondition = compile _rootCondition;
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
params ["_display", "_control", "_curSel", "_itemCfg"];
|
params ["_display", "_control", "_curSel", "_itemCfg"];
|
||||||
|
|
||||||
GVAR(actionsInfo) = [_control, _curSel, _itemCfg];
|
GVAR(actionsInfo) = [_control, _curSel, _itemCfg];
|
||||||
@ -46,13 +45,12 @@ private _groups = (GVAR(actionList) select _panel) select {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private _show = _groups isNotEqualTo [];
|
private _show = _groups isNotEqualTo [];
|
||||||
private _ctrl = _display displayCtrl IDC_actionsBox;
|
private _actionsBoxCtrl = _display displayCtrl IDC_actionsBox;
|
||||||
_ctrl ctrlShow _show;
|
_actionsBoxCtrl ctrlShow _show;
|
||||||
_ctrl ctrlCommit 0.15;
|
_actionsBoxCtrl ctrlCommit 0.15;
|
||||||
|
|
||||||
if (!_show) exitWith {};
|
if (!_show) exitWith {};
|
||||||
|
|
||||||
private _actionsBoxCtrl = _display displayCtrl IDC_actionsBox;
|
|
||||||
private _actionsCurrentPageCtrl = _display displayCtrl IDC_actionsCurrentPage;
|
private _actionsCurrentPageCtrl = _display displayCtrl IDC_actionsCurrentPage;
|
||||||
|
|
||||||
private _currentPage = GVAR(currentActionPage);
|
private _currentPage = GVAR(currentActionPage);
|
||||||
@ -83,10 +81,11 @@ _actionsCurrentPageCtrl ctrlSetFade 0;
|
|||||||
_actionsCurrentPageCtrl ctrlShow true;
|
_actionsCurrentPageCtrl ctrlShow true;
|
||||||
_actionsCurrentPageCtrl ctrlCommit 0;
|
_actionsCurrentPageCtrl ctrlCommit 0;
|
||||||
|
|
||||||
|
private _activeCtrls = [];
|
||||||
{
|
{
|
||||||
_x params ["", "_type", "_label", "_statement"];
|
_x params ["", "_type", "_label", "_statement"];
|
||||||
|
|
||||||
private _idc = 9001 + _forEachIndex * 2;
|
private _idc = IDC_actionsText1 + _forEachIndex * 2;
|
||||||
private _actionTextCtrl = _display displayCtrl _idc;
|
private _actionTextCtrl = _display displayCtrl _idc;
|
||||||
private _actionButtonCtrl = _display displayCtrl (_idc + 1);
|
private _actionButtonCtrl = _display displayCtrl (_idc + 1);
|
||||||
|
|
||||||
@ -99,13 +98,23 @@ _actionsCurrentPageCtrl ctrlCommit 0;
|
|||||||
[true] call FUNC(refresh);
|
[true] call FUNC(refresh);
|
||||||
}] call CBA_fnc_execNextFrame;
|
}] 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 ctrlAddEventHandler ["ButtonClick", _statement];
|
||||||
_actionButtonCtrl ctrlSetText _label;
|
_actionButtonCtrl ctrlSetText _label;
|
||||||
_actionButtonCtrl ctrlSetFade 0;
|
_actionButtonCtrl ctrlSetFade 0;
|
||||||
_actionButtonCtrl ctrlEnable true;
|
_actionButtonCtrl ctrlEnable true;
|
||||||
_actionButtonCtrl ctrlCommit 0;
|
_actionButtonCtrl ctrlCommit 0;
|
||||||
_actionTextCtrl ctrlSetFade 1;
|
_actionTextCtrl ctrlSetFade 1;
|
||||||
|
_actionTextCtrl ctrlEnable false;
|
||||||
_actionTextCtrl ctrlCommit 0;
|
_actionTextCtrl ctrlCommit 0;
|
||||||
|
_activeCtrls pushBack _actionButtonCtrl;
|
||||||
};
|
};
|
||||||
case ACTION_TYPE_TEXT: {
|
case ACTION_TYPE_TEXT: {
|
||||||
private _text = call _statement;
|
private _text = call _statement;
|
||||||
@ -113,13 +122,25 @@ _actionsCurrentPageCtrl ctrlCommit 0;
|
|||||||
if (isNil "_text") then {
|
if (isNil "_text") then {
|
||||||
_text = "";
|
_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 ctrlSetText _text;
|
||||||
|
_actionTextCtrl ctrlSetPositionH (ctrlTextHeight _actionTextCtrl);
|
||||||
_actionTextCtrl ctrlSetFade 0;
|
_actionTextCtrl ctrlSetFade 0;
|
||||||
|
_actionTextCtrl ctrlEnable false;
|
||||||
_actionTextCtrl ctrlCommit 0;
|
_actionTextCtrl ctrlCommit 0;
|
||||||
_actionButtonCtrl ctrlSetFade 1;
|
_actionButtonCtrl ctrlSetFade 1;
|
||||||
_actionButtonCtrl ctrlEnable false;
|
_actionButtonCtrl ctrlEnable false;
|
||||||
_actionButtonCtrl ctrlCommit 0;
|
_actionButtonCtrl ctrlCommit 0;
|
||||||
|
_activeCtrls pushBack _actionTextCtrl;
|
||||||
};
|
};
|
||||||
default {
|
default {
|
||||||
_actionTextCtrl ctrlSetFade 1;
|
_actionTextCtrl ctrlSetFade 1;
|
||||||
@ -134,7 +155,7 @@ _actionsCurrentPageCtrl ctrlCommit 0;
|
|||||||
private _actionCount = count _items;
|
private _actionCount = count _items;
|
||||||
|
|
||||||
{
|
{
|
||||||
private _idc = 9001 + _x * 2;
|
private _idc = IDC_actionsText1 + _x * 2;
|
||||||
private _actionTextCtrl = _display displayCtrl _idc;
|
private _actionTextCtrl = _display displayCtrl _idc;
|
||||||
private _actionButtonCtrl = _display displayCtrl (_idc + 1);
|
private _actionButtonCtrl = _display displayCtrl (_idc + 1);
|
||||||
|
|
||||||
@ -145,6 +166,11 @@ private _actionCount = count _items;
|
|||||||
} forEach ([0, 1, 2, 3, 4] select [_actionCount, 5]);
|
} forEach ([0, 1, 2, 3, 4] select [_actionCount, 5]);
|
||||||
|
|
||||||
private _pos = ctrlPosition _actionsBoxCtrl;
|
private _pos = ctrlPosition _actionsBoxCtrl;
|
||||||
_pos set [3, ([11, (5 * _actionCount) + 6] select (_actionCount > 0)) * GRID_H];
|
(ctrlPosition (_activeCtrls select -1)) params ["", "_lastPosY", "", "_lastPosH"];
|
||||||
_actionsBoxCtrl ctrlSetPosition _pos;
|
private _actionsBoxHeight = _lastPosY + _lastPosH + GRID_H;
|
||||||
|
_actionsBoxCtrl ctrlSetPositionH _actionsBoxHeight;
|
||||||
_actionsBoxCtrl ctrlCommit 0;
|
_actionsBoxCtrl ctrlCommit 0;
|
||||||
|
|
||||||
|
private _background = _display displayCtrl IDC_actionsBackground1;
|
||||||
|
_background ctrlSetPositionH _actionsBoxHeight;
|
||||||
|
_background ctrlCommit 0;
|
||||||
|
@ -450,22 +450,22 @@ class GVAR(display) {
|
|||||||
h = QUOTE(55 * GRID_H);
|
h = QUOTE(55 * GRID_H);
|
||||||
class controls {
|
class controls {
|
||||||
class actionsStaticBackground1: ctrlStaticBackground {
|
class actionsStaticBackground1: ctrlStaticBackground {
|
||||||
idc = -1;
|
idc = IDC_actionsBackground1;
|
||||||
x = QUOTE(0);
|
x = QUOTE(0);
|
||||||
y = QUOTE(0);
|
y = QUOTE(0);
|
||||||
w = QUOTE(47 * GRID_W);
|
w = QUOTE(47 * GRID_W);
|
||||||
h = QUOTE(56 * GRID_H);
|
h = QUOTE(55 * GRID_H);
|
||||||
colorBackground[]={0.1,0.1,0.1,0.5};
|
colorBackground[]={0.1,0.1,0.1,0.5};
|
||||||
};
|
};
|
||||||
class actionsStaticBackground2: ctrlStaticBackground {
|
class actionsStaticBackground2: ctrlStaticBackground {
|
||||||
idc = -1;
|
idc = IDC_actionsBackground2;
|
||||||
x = QUOTE(0);
|
x = QUOTE(0);
|
||||||
y = QUOTE(0);
|
y = QUOTE(0);
|
||||||
w = QUOTE(47 * GRID_W);
|
w = QUOTE(47 * GRID_W);
|
||||||
h = QUOTE(5 * GRID_H);
|
h = QUOTE(5 * GRID_H);
|
||||||
colorBackground[]={0.1,0.1,0.1,0.8};
|
colorBackground[]={0.1,0.1,0.1,0.8};
|
||||||
};
|
};
|
||||||
class actionsText1: RscText {
|
class actionsText1: RscTextMulti {
|
||||||
idc = IDC_actionsText1;
|
idc = IDC_actionsText1;
|
||||||
fade = 1;
|
fade = 1;
|
||||||
x = QUOTE(0 * GRID_W);
|
x = QUOTE(0 * GRID_W);
|
||||||
@ -479,6 +479,7 @@ class GVAR(display) {
|
|||||||
};
|
};
|
||||||
class actionsButton1: ctrlButton {
|
class actionsButton1: ctrlButton {
|
||||||
idc = IDC_actionsButton1;
|
idc = IDC_actionsButton1;
|
||||||
|
onMouseEnter = QUOTE(ctrlSetFocus (_this select 0));
|
||||||
fade = 1;
|
fade = 1;
|
||||||
text = "";
|
text = "";
|
||||||
x = QUOTE(1 * GRID_W);
|
x = QUOTE(1 * GRID_W);
|
||||||
|
@ -402,6 +402,8 @@ For actions involving frame delays or timers, a second call of the `ace_arsenal_
|
|||||||
|
|
||||||
Since CBA frame functions are deactivated during preInit as of Oct 24th 2023, the refresh function is executed immediatelly after the action code is executed. Take note of this information and the comment below if you'd like your actions to be usable in 3DEN.
|
Since CBA frame functions are deactivated during preInit as of Oct 24th 2023, the refresh function is executed immediatelly after the action code is executed. Take note of this information and the comment below if you'd like your actions to be usable in 3DEN.
|
||||||
|
|
||||||
|
By default actions are updated whenever the arsenal is refreshed (`ace_arsenal_fnc_refresh`) and whenever item info (the bottom right GUI element that shows item name and author) is updated. If any action with the `updateOnCargoChanged` property is added, then actions will also be updated on container inventory changes.
|
||||||
|
|
||||||
### 7.1 Adding actions via config
|
### 7.1 Adding actions via config
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@ -410,6 +412,7 @@ class ace_arsenal_actions {
|
|||||||
displayName = "My Actions";
|
displayName = "My Actions";
|
||||||
condition = QUOTE(true);
|
condition = QUOTE(true);
|
||||||
scopeEditor = 2; // Only actions with scopeEditor = 2 are shown in 3DEN. Actions working with variables should take object variables being reset between editor view and mission start into account.
|
scopeEditor = 2; // Only actions with scopeEditor = 2 are shown in 3DEN. Actions working with variables should take object variables being reset between editor view and mission start into account.
|
||||||
|
updateOnCargoChanged = 1; // See comment above.
|
||||||
tabs[] = {0,5};
|
tabs[] = {0,5};
|
||||||
class text {
|
class text {
|
||||||
// A simple text label
|
// A simple text label
|
||||||
@ -417,6 +420,7 @@ class ace_arsenal_actions {
|
|||||||
};
|
};
|
||||||
class statement {
|
class statement {
|
||||||
// Statement output as text
|
// Statement output as text
|
||||||
|
// Return can be string or array of strings: for array each entry is automatically displayed on a separate line
|
||||||
textStatement = QUOTE([_this select 0] call tag_fnc_myTextStatement);
|
textStatement = QUOTE([_this select 0] call tag_fnc_myTextStatement);
|
||||||
};
|
};
|
||||||
class button {
|
class button {
|
||||||
@ -441,6 +445,7 @@ The focused unit object is passed to the condition and statement functions.
|
|||||||
3 | Actions | Array of arrays | Required
|
3 | Actions | Array of arrays | Required
|
||||||
4 | Condition | Code | Optional (default: `{true}`)
|
4 | Condition | Code | Optional (default: `{true}`)
|
||||||
5 | Scope editor | Number | Optional (default: `2`)
|
5 | Scope editor | Number | Optional (default: `2`)
|
||||||
|
6 | Update on cargo change | Boolean | Optional (default: `false`)
|
||||||
|
|
||||||
Return Value:
|
Return Value:
|
||||||
- Array of action IDs
|
- Array of action IDs
|
||||||
|
Loading…
Reference in New Issue
Block a user