Interaction Menu - Ability to modify icon color (#6290)

* Add ability to modify icon color

* Add config support for icon color
This commit is contained in:
mharis001 2018-05-31 11:57:46 -04:00 committed by PabstMirror
parent ac3642d074
commit 3d31b6395c
5 changed files with 25 additions and 12 deletions

View File

@ -37,7 +37,11 @@ private _recurseFnc = {
private _distance = _parentDistance; private _distance = _parentDistance;
if (isNumber (_entryCfg >> "distance")) then {_distance = getNumber (_entryCfg >> "distance");}; if (isNumber (_entryCfg >> "distance")) then {_distance = getNumber (_entryCfg >> "distance");};
// if (_distance < _parentDistance) then {WARNING_3("[%1] distance %2 less than parent %3", configName _entryCfg, _distance, _parentDistance);}; // if (_distance < _parentDistance) then {WARNING_3("[%1] distance %2 less than parent %3", configName _entryCfg, _distance, _parentDistance);};
private _icon = getText (_entryCfg >> "icon"); private _icon = if (isArray (_entryCfg >> "icon")) then {
getArray (_entryCfg >> "icon");
} else {
[getText (_entryCfg >> "icon"), "#FFFFFF"];
};
private _statement = compile (getText (_entryCfg >> "statement")); private _statement = compile (getText (_entryCfg >> "statement"));
// If the position entry is present, compile it // If the position entry is present, compile it

View File

@ -37,7 +37,11 @@ private _recurseFnc = {
if(isClass _entryCfg) then { if(isClass _entryCfg) then {
private _displayName = getText (_entryCfg >> "displayName"); private _displayName = getText (_entryCfg >> "displayName");
private _icon = getText (_entryCfg >> "icon"); private _icon = if (isArray (_entryCfg >> "icon")) then {
getArray (_entryCfg >> "icon");
} else {
[getText (_entryCfg >> "icon"), "#FFFFFF"];
};
private _statement = compile (getText (_entryCfg >> "statement")); private _statement = compile (getText (_entryCfg >> "statement"));
private _condition = getText (_entryCfg >> "condition"); private _condition = getText (_entryCfg >> "condition");

View File

@ -27,7 +27,11 @@ private _recurseFnc = {
if(isClass _entryCfg) then { if(isClass _entryCfg) then {
private _displayName = getText (_entryCfg >> "displayName"); private _displayName = getText (_entryCfg >> "displayName");
private _icon = getText (_entryCfg >> "icon"); private _icon = if (isArray (_entryCfg >> "icon")) then {
getArray (_entryCfg >> "icon");
} else {
[getText (_entryCfg >> "icon"), "#FFFFFF"];
};
private _statement = compile (getText (_entryCfg >> "statement")); private _statement = compile (getText (_entryCfg >> "statement"));
private _condition = getText (_entryCfg >> "condition"); private _condition = getText (_entryCfg >> "condition");

View File

@ -6,7 +6,7 @@
* Arguments: * Arguments:
* 0: Action name <STRING> * 0: Action name <STRING>
* 1: Name of the action shown in the menu <STRING> * 1: Name of the action shown in the menu <STRING>
* 2: Icon <STRING> * 2: Icon file path or Array of icon file path and hex color ("" for default icon) <STRING|ARRAY>
* 3: Statement <CODE> * 3: Statement <CODE>
* 4: Condition <CODE> * 4: Condition <CODE>
* 5: Insert children code <CODE> (Optional) * 5: Insert children code <CODE> (Optional)

View File

@ -1,10 +1,10 @@
/* /*
* Author: NouberNou and esteldunedain * Author: NouberNou, esteldunedain, mharis001
* Render a single interaction icon * Render a single interaction icon.
* *
* Arguments: * Arguments:
* 0: Text <STRING> * 0: Text <STRING>
* 1: Icon <STRING> * 1: Icon file path or Array of icon file path and hex color <STRING|ARRAY>
* 2: 2d position <ARRAY> * 2: 2d position <ARRAY>
* 3: Text Settings <STRING> * 3: Text Settings <STRING>
* *
@ -12,7 +12,7 @@
* None * None
* *
* Example: * Example:
* ["text", "icon", [5, 6], "text"] call ACE_interact_menu_fnc_renderIcon * ["text", "icon", [5, 6], "text"] call ace_interact_menu_fnc_renderIcon
* *
* Public: No * Public: No
*/ */
@ -33,14 +33,15 @@ if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
}; };
private _ctrl = GVAR(iconCtrls) select GVAR(iconCount); private _ctrl = GVAR(iconCtrls) select GVAR(iconCount);
if(_icon == "") then { _icon params [["_iconFile", "", [""]], ["_iconColor", "#FFFFFF", [""]]];
_icon = DEFAULT_ICON; if (_iconFile isEqualTo "") then {
_iconFile = DEFAULT_ICON;
}; };
_text = if (GVAR(UseListMenu)) then { _text = if (GVAR(UseListMenu)) then {
format ["<img image='%1' align='left'/><t %2>%3</t>", _icon, _textSettings, _text] format ["<img image='%1' align='left' color='%2'/><t %3>%4</t>", _iconFile, _iconColor, _textSettings, _text]
} else { } else {
format ["<img image='%1' align='center'/><br/><t %2 align='center'>%3</t>", _icon, _textSettings, "ace_break_line" callExtension _text]; format ["<img image='%1' align='center' color='%2'/><br/><t %3 align='center'>%4</t>", _iconFile, _iconColor, _textSettings, "ace_break_line" callExtension _text];
}; };
[_ctrl, GVAR(iconCount), _text] call FUNC(ctrlSetParsedTextCached); [_ctrl, GVAR(iconCount), _text] call FUNC(ctrlSetParsedTextCached);