2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-02-21 20:11:03 +00:00
|
|
|
/*
|
2018-05-31 15:57:46 +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>
|
2018-05-31 15:57:46 +00:00
|
|
|
* 1: Icon file path or Array of icon file path and hex color <STRING|ARRAY>
|
2015-03-23 21:08:31 +00:00
|
|
|
* 2: 2d position <ARRAY>
|
2015-04-30 04:37:52 +00:00
|
|
|
* 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
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
2018-05-31 15:57:46 +00:00
|
|
|
* ["text", "icon", [5, 6], "text"] call ace_interact_menu_fnc_renderIcon
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
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)
|
2015-08-04 22:46:57 +00:00
|
|
|
|
|
|
|
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);
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
|
2016-09-04 14:44:22 +00:00
|
|
|
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 {
|
2016-09-04 14:44:22 +00:00
|
|
|
((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
|
|
|
};
|
2015-03-23 21:08:31 +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
|
|
|
|
2018-05-31 15:57:46 +00:00
|
|
|
_icon params [["_iconFile", "", [""]], ["_iconColor", "#FFFFFF", [""]]];
|
|
|
|
if (_iconFile isEqualTo "") then {
|
|
|
|
_iconFile = DEFAULT_ICON;
|
2015-01-18 18:38:27 +00:00
|
|
|
};
|
2015-04-12 03:21:05 +00:00
|
|
|
|
2019-12-08 01:44:04 +00:00
|
|
|
_text = if ([GVAR(useListMenu), GVAR(useListMenuSelf)] select GVAR(keyDownSelfAction)) then {
|
2018-05-31 15:57:46 +00:00
|
|
|
format ["<img image='%1' align='left' color='%2'/><t %3>%4</t>", _iconFile, _iconColor, _textSettings, _text]
|
2015-04-12 04:15:38 +00:00
|
|
|
} else {
|
2018-05-31 15:57:46 +00:00
|
|
|
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-12 04:15:38 +00:00
|
|
|
};
|
2015-04-12 03:21:05 +00:00
|
|
|
|
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
|
|
|
|
2019-12-08 01:44:04 +00:00
|
|
|
private _pos = if ([GVAR(useListMenu), GVAR(useListMenuSelf)] select GVAR(keyDownSelfAction)) then {
|
2016-09-04 14:44:22 +00:00
|
|
|
[(_sPos select 0) - (0.0095 * SafeZoneW), (_sPos select 1) - (0.0095 * SafeZoneW), 0.20 * SafeZoneW, 0.035 * SafeZoneW]
|
2015-04-12 04:15:38 +00:00
|
|
|
} else {
|
2016-09-04 14:44:22 +00:00
|
|
|
[(_sPos select 0) - (0.0750 * SafeZoneW), (_sPos select 1) - (0.0095 * SafeZoneW), 0.15 * SafeZoneW, 0.100 * SafeZoneW]
|
2015-04-12 04:15:38 +00:00
|
|
|
};
|
2015-04-08 03:44:41 +00:00
|
|
|
|
2019-12-08 01:44:04 +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)];
|
|
|
|
};
|
|
|
|
|
2015-04-28 19:02:03 +00:00
|
|
|
_ctrl ctrlSetPosition _pos;
|
2015-03-23 21:08:31 +00:00
|
|
|
_ctrl ctrlCommit 0;
|