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

Interact Menu - Optimize interaction menu conditions #8037

Merged
merged 1 commit into from
Dec 17, 2020
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
11 changes: 7 additions & 4 deletions addons/interact_menu/functions/fnc_compileMenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ private _recurseFnc = {
};

private _condition = getText (_entryCfg >> "condition");
if (_condition == "") then {_condition = "true"};

// Add canInteract (including exceptions) and canInteractWith to condition
if ((configName _entryCfg) != "ACE_MainActions") then {
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
if (configName _entryCfg == "ACE_MainActions") then {
if (_condition isEqualTo "") then {_condition = "true"};
} 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"));
Expand Down
6 changes: 3 additions & 3 deletions addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ private _recurseFnc = {
private _statement = compile (getText (_entryCfg >> "statement"));

private _condition = getText (_entryCfg >> "condition");
if (_condition == "") then {_condition = "true"};

// 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 _modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
Expand All @@ -63,7 +64,6 @@ private _recurseFnc = {
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
};

_condition = compile _condition;
private _children = [_entryCfg] call _recurseFnc;

private _entry = [
Expand Down
7 changes: 5 additions & 2 deletions addons/interact_menu/functions/fnc_compileMenuZeus.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ private _recurseFnc = {
private _statement = compile (getText (_entryCfg >> "statement"));

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 _modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
Expand All @@ -50,7 +54,6 @@ private _recurseFnc = {
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
};

private _condition = compile _condition;
private _children = [_entryCfg] call _recurseFnc;

private _entry = [
Expand Down