2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-01-11 19:32:51 +00:00
|
|
|
/*
|
2018-11-01 17:46:46 +00:00
|
|
|
* Author: Garth de Wet (LH), mharis001
|
|
|
|
* Shows an interaction hint for mouse buttons.
|
|
|
|
* Empty strings will hide their respective button.
|
2015-05-09 02:47:15 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2018-11-01 17:46:46 +00:00
|
|
|
* 0: Left click text <STRING>
|
|
|
|
* 1: Right click text <STRING>
|
|
|
|
* 2: Scroll text <STRING> (default: "")
|
2020-04-20 15:45:59 +00:00
|
|
|
* 3: Extra icon/text pairs <ARRAY> (default: [])
|
2015-05-09 02:47:15 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-05-09 02:47:15 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* ["Place Explosive", "Cancel"] call ace_interaction_fnc_showMouseHint
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-11 23:13:47 +00:00
|
|
|
|
2018-11-01 17:46:46 +00:00
|
|
|
params ["_textLMB", "_textRMB", ["_textMMB", ""], ["_extraIconSets", []]];
|
2015-05-09 20:14:00 +00:00
|
|
|
|
2018-11-01 17:46:46 +00:00
|
|
|
(QGVAR(RscMouseHint) call BIS_fnc_rscLayer) cutRsc [QGVAR(RscMouseHint), "PLAIN", -1, false];
|
|
|
|
private _display = uiNamespace getVariable [QGVAR(mouseHint), displayNull];
|
2015-05-09 20:14:00 +00:00
|
|
|
|
2018-11-01 17:46:46 +00:00
|
|
|
// Set text for buttons, hide if empty string
|
|
|
|
{
|
|
|
|
_x params ["_buttonText", "_iconIDC", "_textIDC"];
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2018-11-01 17:46:46 +00:00
|
|
|
if (_buttonText == "") then {
|
|
|
|
private _ctrlIcon = _display displayCtrl _iconIDC;
|
|
|
|
_ctrlIcon ctrlShow false;
|
|
|
|
} else {
|
|
|
|
private _ctrlText = _display displayCtrl _textIDC;
|
|
|
|
_ctrlText ctrlSetText _buttonText;
|
|
|
|
};
|
|
|
|
} forEach [
|
|
|
|
[_textLMB, IDC_MOUSEHINT_LMB, IDC_MOUSEHINT_LMB_TEXT],
|
|
|
|
[_textMMB, IDC_MOUSEHINT_MMB, IDC_MOUSEHINT_MMB_TEXT],
|
|
|
|
[_textRMB, IDC_MOUSEHINT_RMB, IDC_MOUSEHINT_RMB_TEXT]
|
|
|
|
];
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2018-11-01 17:46:46 +00:00
|
|
|
// Y offset for extra icon sets
|
|
|
|
private _yOffset = 19.5;
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2018-11-01 17:46:46 +00:00
|
|
|
if (_textMMB == "") then {
|
|
|
|
// Move RMB up if MMB inactive
|
|
|
|
{
|
|
|
|
private _ctrl = _display displayCtrl _x;
|
|
|
|
private _ctrlPos = ctrlPosition _ctrl;
|
|
|
|
_ctrlPos set [1, (_ctrlPos select 1) - 1.05 * GUI_GRID_H];
|
|
|
|
_ctrl ctrlSetPosition _ctrlPos;
|
|
|
|
_ctrl ctrlCommit 0;
|
|
|
|
} forEach [IDC_MOUSEHINT_RMB, IDC_MOUSEHINT_RMB_TEXT];
|
2017-09-19 19:00:22 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// Disable action menu
|
|
|
|
inGameUISetEventHandler ["PrevAction", "true"];
|
|
|
|
inGameUISetEventHandler ["NextAction", "true"];
|
|
|
|
inGameUISetEventHandler ["Action", "true"];
|
2018-11-01 17:46:46 +00:00
|
|
|
|
|
|
|
// Increase offset since MMB active
|
|
|
|
_yOffset = 20.55;
|
2015-01-11 19:32:51 +00:00
|
|
|
};
|
2015-09-26 01:16:55 +00:00
|
|
|
|
2018-11-01 17:46:46 +00:00
|
|
|
// Create extra icon sets
|
2017-09-19 19:00:22 +00:00
|
|
|
{
|
2018-11-01 17:46:46 +00:00
|
|
|
_x params [["_keyName", "", [""]], ["_keyText", "", [""]]];
|
2017-09-19 19:00:22 +00:00
|
|
|
|
2018-11-01 17:46:46 +00:00
|
|
|
// Only create extra key if both name and text are valid
|
|
|
|
if (_keyName != "" && {_keyText != ""}) then {
|
|
|
|
// Localize Ctrl, Shift, or Alt keys
|
2024-03-07 21:08:13 +00:00
|
|
|
switch (toLowerANSI _keyName) do {
|
2018-11-01 17:46:46 +00:00
|
|
|
case "ctrl";
|
|
|
|
case "control": {_keyName = format ["<%1>", toUpper localize "STR_dik_control"]};
|
|
|
|
case "shift": {_keyName = format ["<%1>", toUpper localize "STR_dik_shift"]};
|
|
|
|
case "alt": {_keyName = format ["<%1>", toUpper localize "STR_dik_alt"]};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Create extra key group and update position
|
|
|
|
private _ctrlGroup = _display ctrlCreate [QGVAR(RscExtraKey), IDC_MOUSEHINT_EXTRA];
|
|
|
|
_ctrlGroup ctrlSetPosition [0, _yOffset * GUI_GRID_H];
|
|
|
|
_ctrlGroup ctrlCommit 0;
|
|
|
|
|
|
|
|
// Set name and text
|
|
|
|
private _ctrlName = _ctrlGroup controlsGroupCtrl IDC_MOUSEHINT_EXTRA_NAME;
|
|
|
|
_ctrlName ctrlSetText _keyName;
|
2015-09-26 01:16:55 +00:00
|
|
|
|
2018-11-01 17:46:46 +00:00
|
|
|
private _ctrlText = _ctrlGroup controlsGroupCtrl IDC_MOUSEHINT_EXTRA_TEXT;
|
|
|
|
_ctrlText ctrlSetText _keyText;
|
|
|
|
|
|
|
|
_yOffset = _yOffset + 1;
|
|
|
|
};
|
|
|
|
} forEach _extraIconSets;
|