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

CBA UI - params support in code exec #48

Merged
merged 1 commit into from
Jun 2, 2015
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
29 changes: 21 additions & 8 deletions addons/ui/flexiMenu/fnc_execute.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
//-----------------------------------------------------------------------------
#include "\x\cba\addons\ui\script_component.hpp"

private["_action", "_subMenu", "_multiReselect", "_useListBox", "_subMenuSource", "_params", "_pathName"];
private["_arrayID", "_actionData", "_action", "_subMenu", "_multiReselect", "_useListBox", "_subMenuSource", "_params", "_pathName", "_actionCode", "_actionParams"];

_action = _this select 0;
_subMenu = _this select 1;
_multiReselect = _this select 2;
_arrayID = _this;
_actionData = GVAR(menuActionData) select _arrayID;

_action = _actionData select 0;
_subMenu = _actionData select 1;
_multiReselect = _actionData select 2;
//-----------------------------------------------------------------------------
// indicates an option/button was selected, (to allow menu to close upon release of interact key), except if _multiReselect enabled.
if (_multiReselect == 0) then {
Expand Down Expand Up @@ -36,11 +39,21 @@ if (_useListBox == 0 && {_multiReselect == 0}) then { // if using embedded listB
};
//-----------------------------------------------------------------------------
// execute main menu action (unless submenu)
if (typeName _action == "CODE") then {
call _action
if (typeName _action == typename []) then {
_actionParams = _action select 0;
_actionCode = _action select 1;
} else {
_actionParams = 1;
_actionCode = _action;
};

if (typeName _actionCode == typename {}) then {
_actionParams call _actionCode
} else {
if (_action != "") then {
call compile _action;
if (typename _actionCode == typename "") then {
if(_actionCode != "") then {
_actionParams call compile _actionCode;
};
};
};

Expand Down
6 changes: 4 additions & 2 deletions addons/ui/flexiMenu/fnc_getMenuOption.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
private["_menuDefs0", "_menuDef", "_fastPartialResult",
"_result", "_caption", "_action", "_actionOptions", "_icon", "_tooltip", "_subMenu", "_shortcut_DIK", "_visible", "_enabled",
"_array", "_index", "_containCaret", "_asciiKey", "_iconFolder", "_multiReselect",
"_keyName", "_offset"];
"_keyName", "_offset", "_arrayID"];

_menuDefs0 = _this select 0;
_menuDef = _this select 1;
Expand Down Expand Up @@ -156,10 +156,12 @@ if (!_fastPartialResult && {_icon != ""}) then {
};
//-----------------------------------------------------------------------------
if (_caption != "") then {
_arrayID = count GVAR(menuActionData);
_actionOptions = [_action, _subMenu, _multiReselect];
GVAR(menuActionData) set [_arrayID, _actionOptions];

// TODO: Consider changing _action array item from string to type code.
_action = format ["%1 call %2", _actionOptions, QUOTE(FUNC(execute))];
_action = format ["%1 call %2", _arrayID, QUOTE(FUNC(execute))];
};
//-----------------------------------------------------------------------------
_result = [];
Expand Down
1 change: 1 addition & 0 deletions addons/ui/flexiMenu/fnc_menu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ if (GVAR(hotKeyColor) == "") then {
};

//-----------------------------------------------------------------------------
GVAR(menuActionData) = [];
_commitList = [];
{ // forEach
if (count _x >= 2) then { // all essential array items exist
Expand Down