Interact Menu - Combine parent menu with single child (#8060)

* Combine parent menu with single child

* Adapt fastroping Cut ropes action for the setting

* Change setting name and description

* Fix action object when child action has different object

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Adapt quickmount Change Seat actions

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Dystopian 2021-02-04 21:01:35 +04:00 committed by GitHub
parent 091d0d2449
commit 08472f6343
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 61 additions and 18 deletions

View File

@ -9,11 +9,8 @@ class CfgVehicles {
class ACE_Chemlights {
displayName = CSTRING(Action_Chemlights);
icon = "\a3\ui_f\data\gui\cfg\Hints\chemlights_ca.paa";
condition = QUOTE(count ([ACE_player] call FUNC(getShieldComponents)) > 0);
statement = "true";
exceptions[] = {"isNotDragging", "isNotSwimming", "notOnMap", "isNotInside", "isNotSitting"};
insertChildren = QUOTE(_this call DFUNC(compileChemlightMenu));
showDisabled = 0;
insertChildren = QUOTE(call DFUNC(compileChemlightMenu));
};
};
};

View File

@ -75,8 +75,9 @@ class CfgVehicles {
};
class ACE_cutRopes {
displayName = CSTRING(Interaction_cutRopes);
condition = QUOTE(true);
statement = "";
condition = QUOTE([_target] call FUNC(canCutRopes));
// should not be empty to work with EGVAR(interact_menu,consolidateSingleChild) setting
statement = QUOTE(true);
class confirmCutRopes {
displayName = ECSTRING(common,confirm);
condition = QUOTE([_target] call FUNC(canCutRopes));

View File

@ -13,7 +13,7 @@
* Active children <ARRAY>
*
* Example:
* [bob, [array], [array], 5] call ACE_interact_menu_fnc_collectActoveActionTree
* [bob, [array], [array], 5] call ACE_interact_menu_fnc_collectActiveActionTree
*
* Public: No
*/
@ -31,7 +31,17 @@ if !((_origActionData select 10) isEqualTo {}) then {
[_target, ACE_player, _origActionData select 6, _origActionData] call (_origActionData select 10);
};
_origActionData params ["_actionName", "", "", "_statementCode", "_conditionCode", "_insertChildrenCode", "_customParams", "", "_distance"];
_origActionData params [
"_actionName",
"_displayName",
"",
"_statementCode",
"_conditionCode",
"_insertChildrenCode",
"_customParams",
"_position",
"_distance"
];
// Return nothing if the action itself is not active
if !([_target, ACE_player, _customParams] call _conditionCode) exitWith {
@ -91,5 +101,23 @@ if ((_activeChildren isEqualTo []) && {_statementCode isEqualTo {}}) exitWith {
[]
};
if (GVAR(consolidateSingleChild) && {count _activeChildren == 1} && {_statementCode isEqualTo {}}) then {
_activeChildren select 0 params ["_childActionData", "_childChildren", "_childObject"];
_childActionData params ["", "_displayNameChild", "_iconChild", "_statementChild", "", "", "_customParamsChild", "", "", "_paramsChild"];
_origActionData = [
_actionName,
format ["%1 > %2", _displayName, _displayNameChild],
_iconChild,
_statementChild,
_conditionCode,
_insertChildrenCode,
_customParamsChild,
_position,
_distance,
_paramsChild
];
_activeChildren = _childChildren;
_object = _childObject;
};
[_origActionData, _activeChildren, _object]

View File

@ -8,6 +8,14 @@
{GVAR(selectorColorHex) = _this call BIS_fnc_colorRGBtoHTML} // Stored in Hex to avoid constant conversion
] call CBA_settings_fnc_init;
[
QGVAR(consolidateSingleChild),
"CHECKBOX",
[LSTRING(consolidateSingleChild), LSTRING(consolidateSingleChild_Description)],
format ["ACE %1", LLSTRING(Category_InteractionMenu)],
false
] call CBA_fnc_addSetting;
[
QGVAR(alwaysUseCursorInteraction),
"CHECKBOX",

View File

@ -489,5 +489,13 @@
<Spanish>Selector de color</Spanish>
<Turkish>Seçici Renk</Turkish>
</Key>
<Key ID="STR_ACE_Interact_Menu_consolidateSingleChild">
<English>Consolidate single child actions</English>
<Russian>Объединять с единственным дочерним действием</Russian>
</Key>
<Key ID="STR_ACE_Interact_Menu_consolidateSingleChild_Description">
<English>Combines parent action with only one child action together.</English>
<Russian>Объединять родительское действие с единственным дочерним действием в одно.</Russian>
</Key>
</Package>
</Project>

View File

@ -5,11 +5,9 @@ class CfgVehicles {
class ACE_MapFlashlight {
displayName = CSTRING(Action_Flashlights);
icon = QUOTE(\a3\ui_f\data\IGUI\Cfg\VehicleToggles\lightsiconon_ca.paa);
condition = QUOTE(GVAR(mapIllumination) && visibleMap && {!([] isEqualTo (_player call FUNC(getUnitFlashlights)))});
statement = "true";
condition = QUOTE(GVAR(mapIllumination) && visibleMap);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
insertChildren = QUOTE(_this call DFUNC(compileFlashlightMenu));
showDisabled = 0;
insertChildren = QUOTE(call DFUNC(compileFlashlightMenu));
};
};
};

View File

@ -51,8 +51,7 @@ class CfgVehicles {
class GVAR(ChangeSeat) { \
displayName = CSTRING(ChangeSeat); \
condition = QUOTE(call DFUNC(canShowFreeSeats)); \
statement = ""; \
insertChildren = QUOTE((_this select 2) param [ARR_2(0, [])]); \
insertChildren = QUOTE(call DFUNC(addFreeSeatsActions)); \
}; \
}

View File

@ -19,7 +19,6 @@
params ["_vehicle", "_unit", "_args"];
_args set [0, []];
private _isInVehicle = _unit in _vehicle;
GVAR(enabled)
@ -40,7 +39,12 @@ GVAR(enabled)
|| {_vehicle isKindOf "Air"} // except Air
}
&& {
_isInVehicle
|| {
// because Get In action has its own statement
// we have to cache subactions in args and reuse them in insertChildren code
private _subActions = _this call FUNC(addFreeSeatsActions);
_args set [0, _subActions];
!([] isEqualTo _subActions)
}
}