ACE3/addons/interact_menu/functions/fnc_renderIcon.sqf

64 lines
2.6 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
2015-02-21 20:11:03 +00:00
/*
* Author: NouberNou, esteldunedain, mharis001
* Render a single interaction icon.
2015-02-21 20:11:03 +00:00
*
2016-06-18 09:50:41 +00:00
* Arguments:
2015-02-21 20:11:03 +00:00
* 0: Text <STRING>
* 1: Icon file path or Array of icon file path and hex color <STRING|ARRAY>
* 2: 2d position <ARRAY>
* 3: Text Settings <STRING>
2015-02-21 20:11:03 +00:00
*
2016-06-18 09:50:41 +00:00
* Return Value:
2015-02-21 20:11:03 +00:00
* None
*
* Example:
* ["text", "icon", [5, 6], "text"] call ace_interact_menu_fnc_renderIcon
*
2015-02-21 20:11:03 +00:00
* Public: No
*/
2015-01-18 18:38:27 +00:00
#define DEFAULT_ICON QUOTE(\z\ace\addons\interaction\ui\dot_ca.paa)
params ["_text", "_icon", "_sPos", "_textSettings"];
2015-02-21 20:11:03 +00:00
2016-01-08 04:43:37 +00:00
TRACE_2("Icon",_text,_sPos);
if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
private _displayNum = [[46, 12] select visibleMap, 91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021 + GVAR(iconCount)]);
2015-05-02 04:33:28 +00:00
if (GVAR(useCursorMenu)) then {
((finddisplay _displayNum) displayctrl (54021 + GVAR(iconCount))) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)];
((finddisplay _displayNum) displayctrl (54021 + GVAR(iconCount))) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)];
2015-05-02 04:33:28 +00:00
};
};
2016-01-08 04:43:37 +00:00
private _ctrl = GVAR(iconCtrls) select GVAR(iconCount);
2015-05-01 03:32:16 +00:00
_icon params [["_iconFile", "", [""]], ["_iconColor", "#FFFFFF", [""]]];
if (_iconFile isEqualTo "") then {
_iconFile = DEFAULT_ICON;
2015-01-18 18:38:27 +00:00
};
_text = if ([GVAR(useListMenu), GVAR(useListMenuSelf)] select GVAR(keyDownSelfAction)) then {
format ["<img image='%1' align='left' color='%2'/><t %3>%4</t>", _iconFile, _iconColor, _textSettings, _text]
} else {
format ["<img image='%1' align='center' color='%2'/><br/><t %3 align='center'>%4</t>", _iconFile, _iconColor, _textSettings, "ace_break_line" callExtension _text];
};
2015-04-25 11:28:21 +00:00
[_ctrl, GVAR(iconCount), _text] call FUNC(ctrlSetParsedTextCached);
2015-05-01 03:32:16 +00:00
GVAR(iconCount) = GVAR(iconCount) + 1;
2015-04-25 12:34:09 +00:00
private _pos = if ([GVAR(useListMenu), GVAR(useListMenuSelf)] select GVAR(keyDownSelfAction)) then {
[(_sPos select 0) - (0.0095 * SafeZoneW), (_sPos select 1) - (0.0095 * SafeZoneW), 0.20 * SafeZoneW, 0.035 * SafeZoneW]
} else {
[(_sPos select 0) - (0.0750 * SafeZoneW), (_sPos select 1) - (0.0095 * SafeZoneW), 0.15 * SafeZoneW, 0.100 * SafeZoneW]
};
2015-04-08 03:44:41 +00:00
if (([GVAR(cursorKeepCentered), GVAR(cursorKeepCenteredSelfInteraction)] select GVAR(keyDownSelfAction)) && {uiNamespace getVariable [QGVAR(cursorMenuOpened),false]}) then {
2015-04-08 03:44:41 +00:00
_pos set [0, ((_pos select 0) - (GVAR(cursorPos) select 0) + 0.5)];
_pos set [1, ((_pos select 1) - (GVAR(cursorPos) select 1) + 0.5)];
};
_ctrl ctrlSetPosition _pos;
_ctrl ctrlCommit 0;