Optimize interaction menu conditions (#8037)

This commit is contained in:
Dystopian 2020-12-18 00:28:54 +04:00 committed by GitHub
parent 4058a7e42b
commit 50f740f9be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 9 deletions

View File

@ -69,11 +69,14 @@ private _recurseFnc = {
}; };
private _condition = getText (_entryCfg >> "condition"); private _condition = getText (_entryCfg >> "condition");
if (_condition == "") then {_condition = "true"};
// Add canInteract (including exceptions) and canInteractWith to condition if (configName _entryCfg == "ACE_MainActions") then {
if ((configName _entryCfg) != "ACE_MainActions") then { if (_condition isEqualTo "") then {_condition = "true"};
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")]; } else {
// Add canInteract (including exceptions) and canInteractWith to condition
private _canInteractCondition = format [QUOTE([ARR_3(ACE_player,_target,%1)] call EFUNC(common,canInteractWith)), getArray (_entryCfg >> "exceptions")];
private _conditionFormatPattern = ["%1 && {%2}", "%2"] select (_condition isEqualTo "" || {_condition == "true"});
_condition = format [_conditionFormatPattern, _condition, _canInteractCondition];
}; };
private _insertChildren = compile (getText (_entryCfg >> "insertChildren")); private _insertChildren = compile (getText (_entryCfg >> "insertChildren"));

View File

@ -45,10 +45,11 @@ private _recurseFnc = {
private _statement = compile (getText (_entryCfg >> "statement")); private _statement = compile (getText (_entryCfg >> "statement"));
private _condition = getText (_entryCfg >> "condition"); private _condition = getText (_entryCfg >> "condition");
if (_condition == "") then {_condition = "true"};
// Add canInteract (including exceptions) and canInteractWith to condition // Add canInteract (including exceptions) and canInteractWith to condition
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")]; private _canInteractCondition = format [QUOTE([ARR_3(ACE_player,_target,%1)] call EFUNC(common,canInteractWith)), getArray (_entryCfg >> "exceptions")];
private _conditionFormatPattern = ["%1 && {%2}", "%2"] select (_condition isEqualTo "" || {_condition == "true"});
_condition = compile format [_conditionFormatPattern, _condition, _canInteractCondition];
private _insertChildren = compile (getText (_entryCfg >> "insertChildren")); private _insertChildren = compile (getText (_entryCfg >> "insertChildren"));
private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction")); private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
@ -63,7 +64,6 @@ private _recurseFnc = {
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0; _runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
}; };
_condition = compile _condition;
private _children = [_entryCfg] call _recurseFnc; private _children = [_entryCfg] call _recurseFnc;
private _entry = [ private _entry = [

View File

@ -35,7 +35,11 @@ private _recurseFnc = {
private _statement = compile (getText (_entryCfg >> "statement")); private _statement = compile (getText (_entryCfg >> "statement"));
private _condition = getText (_entryCfg >> "condition"); private _condition = getText (_entryCfg >> "condition");
if (_condition == "") then {_condition = "true"}; if (_condition == "") then {
_condition = {true};
} else {
_condition = compile _condition;
};
private _insertChildren = compile (getText (_entryCfg >> "insertChildren")); private _insertChildren = compile (getText (_entryCfg >> "insertChildren"));
private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction")); private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
@ -50,7 +54,6 @@ private _recurseFnc = {
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0; _runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
}; };
private _condition = compile _condition;
private _children = [_entryCfg] call _recurseFnc; private _children = [_entryCfg] call _recurseFnc;
private _entry = [ private _entry = [