diff --git a/addons/explosives/functions/fnc_setupExplosive.sqf b/addons/explosives/functions/fnc_setupExplosive.sqf index 8bc4343430..a85580f672 100644 --- a/addons/explosives/functions/fnc_setupExplosive.sqf +++ b/addons/explosives/functions/fnc_setupExplosive.sqf @@ -118,14 +118,15 @@ GVAR(TweakedAngle) = 0; private _virtualPosASL = _basePosASL vectorAdd (_lookDirVector vectorMultiply _distanceFromBase); - //Update mouse hint: + // Update mouse hint + private _ctrlTextLMB = (uiNamespace getVariable [QEGVAR(interaction,mouseHint), displayNull]) displayCtrl 2420; if (_badPosition) then { - ((uiNamespace getVariable ["ACE_Helper_Display", objNull]) displayCtrl 1000) ctrlSetText localize LSTRING(BlockedAction); + _ctrlTextLMB ctrlSetText localize LSTRING(BlockedAction); } else { if (isNull _attachVehicle) then { - ((uiNamespace getVariable ["ACE_Helper_Display", objNull]) displayCtrl 1000) ctrlSetText localize LSTRING(PlaceAction); + _ctrlTextLMB ctrlSetText localize LSTRING(PlaceAction); } else { - ((uiNamespace getVariable ["ACE_Helper_Display", objNull]) displayCtrl 1000) ctrlSetText localize LSTRING(AttachAction); + _ctrlTextLMB ctrlSetText localize LSTRING(AttachAction); }; }; diff --git a/addons/interaction/RscTitles.hpp b/addons/interaction/RscTitles.hpp index ee4783da30..b619ed594c 100644 --- a/addons/interaction/RscTitles.hpp +++ b/addons/interaction/RscTitles.hpp @@ -1,7 +1,3 @@ - -#define HSPACE 0.5-2.0/16/2 -#define VSPACE 0.5-0.3/9/2 - class ACE_Interaction_Button_Base { tooltip = ""; //action = "ACE_Interaction_isMousePressed = true;(findDisplay 1713999) closeDisplay 1;_action = ACE_Interaction_Buttons select ACE_Interaction_SelectedButton;ACE_Interaction_SelectedButton = -1; if (call (_action select 2)) then {call (_action select 1)};"; @@ -41,9 +37,11 @@ class ACE_Interaction_Button_Base { soundEscape[] = {"\A3\ui_f\data\sound\RscButton\soundEscape",0.09,1}; }; -class RscListbox; class IGUIBack; +class RscListbox; class RscText; +class RscPicture; +class RscControlsGroupNoScrollbars; #define X_OFFSET 0.2 @@ -131,75 +129,78 @@ class RscACE_SelectAnItem { }; }; -#define GUI_GRID_W (0.025) -#define GUI_GRID_H (0.04) - -class RscPicture; -class RscInteractionIcon: RscPicture { - x = 19.25 * GUI_GRID_W; - y = 15.75 * GUI_GRID_H; - w = 2*GUI_GRID_H; - h = 2*GUI_GRID_H; -}; - -class RscInteractionHelperIcon: RscInteractionIcon { - x = 20 * GUI_GRID_W; - y = 16 * GUI_GRID_H; - w = GUI_GRID_H; - h = GUI_GRID_H; -}; - -class RscInteractionText: RscText{ - x = 21 * GUI_GRID_W; - y = 16 * GUI_GRID_H; - w = 24 * GUI_GRID_W; - h = 1.5 * GUI_GRID_H; -}; -class RscInteractionText_right: RscText{ - style = 1; // right aligned text -}; - class RscTitles { - class GVAR(InteractionHelper) { - idd = 9930; + class GVAR(RscMouseHint) { + idd = IDD_MOUSEHINT; + fadeIn = 0; + fadeOut = 0; + duration = 999999; enableSimulation = 1; - movingEnable = 0; - fadeIn=0.5; - fadeOut=0.5; - duration = 10e10; - onLoad = "uiNamespace setVariable ['ACE_Helper_Display', _this select 0];"; - + onLoad = QUOTE(uiNamespace setVariable [ARR_2(QQGVAR(mouseHint),_this select 0)]); class controls { - class SelectIcon: RscInteractionHelperIcon{ - idc = 1200; + class IconLMB: RscPicture { + idc = IDC_MOUSEHINT_LMB; text = QPATHTOF(UI\mouse_left_ca.paa); + x = 20 * GUI_GRID_W + GUI_GRID_CENTER_X; y = 17.5 * GUI_GRID_H; + w = GUI_GRID_H; + h = GUI_GRID_H; }; - class SelectText: RscInteractionText{ - idc = 1000; - y = 17 * GUI_GRID_H; - text = CSTRING(MakeSelection); + class TextLMB: RscText { + idc = IDC_MOUSEHINT_LMB_TEXT; + text = ""; + x = 21.1 * GUI_GRID_W + GUI_GRID_CENTER_X; + y = 17.45 * GUI_GRID_H; + w = 24 * GUI_GRID_W; + h = GUI_GRID_H; + sizeEx = GUI_GRID_H; }; - class GoBackIcon: RscInteractionHelperIcon{ - idc = 1201; - text = QPATHTOF(UI\mouse_right_ca.paa); - y = 19.5 * GUI_GRID_H; - }; - class GoBackText: RscInteractionText{ - idc = 1001; - y = 19 * GUI_GRID_H; - text = CSTRING(Back); - }; - class ScrollIcon: RscInteractionHelperIcon{ - idc = 1202; + class IconMMB: IconLMB { + idc = IDC_MOUSEHINT_MMB; text = QPATHTOF(UI\mouse_scroll_ca.paa); + y = 18.55 * GUI_GRID_H; + }; + class TextMMB: TextLMB { + idc = IDC_MOUSEHINT_MMB_TEXT; y = 18.5 * GUI_GRID_H; }; - class ScrollText: RscInteractionText{ - idc = 1002; - y = 18 * GUI_GRID_H; - text = CSTRING(ScrollHint); + class IconRMB: IconLMB { + idc = IDC_MOUSEHINT_RMB; + text = QPATHTOF(UI\mouse_right_ca.paa); + y = 19.6 * GUI_GRID_H; + }; + class TextRMB: TextLMB { + idc = IDC_MOUSEHINT_RMB_TEXT; + y = 19.55 * GUI_GRID_H; }; }; }; }; + +class GVAR(RscExtraKey): RscControlsGroupNoScrollbars { + idc = IDC_MOUSEHINT_EXTRA; + x = 0; + y = 0; + w = 40 * GUI_GRID_W; + h = GUI_GRID_H; + class controls { + class Name: RscText { + idc = IDC_MOUSEHINT_EXTRA_NAME; + style = 1; + x = 0; + y = 0; + w = 21.5 * GUI_GRID_W + GUI_GRID_CENTER_X; + h = GUI_GRID_H; + sizeEx = GUI_GRID_H; + font = "EtelkaMonospaceProBold"; + }; + class Text: RscText { + idc = IDC_MOUSEHINT_EXTRA_TEXT; + x = 21.1 * GUI_GRID_W + GUI_GRID_CENTER_X; + y = 0; + w = 24 * GUI_GRID_W; + h = GUI_GRID_H; + sizeEx = GUI_GRID_H; + }; + }; +}; diff --git a/addons/interaction/functions/fnc_hideMouseHint.sqf b/addons/interaction/functions/fnc_hideMouseHint.sqf index 155f732eab..8daa6d6e09 100644 --- a/addons/interaction/functions/fnc_hideMouseHint.sqf +++ b/addons/interaction/functions/fnc_hideMouseHint.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: Garth de Wet (LH) - * Hides the interaction helper text with the mouse buttons at the bottom middle of the screen + * Hides the interaction hint for mouse buttons. * * Arguments: * None @@ -10,14 +10,12 @@ * None * * Example: - * call ace_interaction_fnc_hideMouseHint + * [] call ace_interaction_fnc_hideMouseHint * * Public: No */ -if (isNull (uiNamespace getVariable ["ACE_Helper_Display", objNull])) exitWith {}; - -(QGVAR(InteractionHelper) call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; +(QGVAR(RscMouseHint) call BIS_fnc_rscLayer) cutFadeOut 0.2; // Re-enable action menu inGameUISetEventHandler ["PrevAction", "false"]; diff --git a/addons/interaction/functions/fnc_showMouseHint.sqf b/addons/interaction/functions/fnc_showMouseHint.sqf index 7e9cb6110f..b56d053eaa 100644 --- a/addons/interaction/functions/fnc_showMouseHint.sqf +++ b/addons/interaction/functions/fnc_showMouseHint.sqf @@ -1,13 +1,14 @@ #include "script_component.hpp" /* - * Author: Garth de Wet (LH) - * Shows the interaction helper text with the mouse buttons at the bottom middle of the screen. + * Author: Garth de Wet (LH), mharis001 + * Shows an interaction hint for mouse buttons. + * Empty strings will hide their respective button. * * Arguments: - * 0: Left Click Text - * 1: Right Click Text - * 2: Scroll Text (default: "") - * 2: Extra Icon/Text pairs (default: []) + * 0: Left click text + * 1: Right click text + * 2: Scroll text (default: "") + * 2: Extra icon/text pairs (default: []) * * Return Value: * None @@ -18,63 +19,77 @@ * Public: No */ -#define GUI_GRID_W (0.025) -#define GUI_GRID_H (0.04) +params ["_textLMB", "_textRMB", ["_textMMB", ""], ["_extraIconSets", []]]; -params ["_leftClick", "_rightClick", ["_scroll", ""], ["_extraIconSets", []]]; +(QGVAR(RscMouseHint) call BIS_fnc_rscLayer) cutRsc [QGVAR(RscMouseHint), "PLAIN", -1, false]; +private _display = uiNamespace getVariable [QGVAR(mouseHint), displayNull]; -(QGVAR(InteractionHelper) call BIS_fnc_rscLayer) cutRsc [QGVAR(InteractionHelper), "PLAIN", 0.5, false]; +// Set text for buttons, hide if empty string +{ + _x params ["_buttonText", "_iconIDC", "_textIDC"]; -disableSerialization; + 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] +]; -private _display = uiNamespace getVariable ["ACE_Helper_Display", objNull]; +// Y offset for extra icon sets +private _yOffset = 19.5; -if (isNull _display) exitWith {WARNING("Display was null");}; +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]; -(_display displayCtrl 1000) ctrlSetText _leftClick; -(_display displayCtrl 1001) ctrlSetText _rightClick; - -(_display displayCtrl 1000) ctrlShow (_leftClick != ""); -(_display displayCtrl 1200) ctrlShow (_leftClick != ""); -(_display displayCtrl 1001) ctrlShow (_rightClick != ""); -(_display displayCtrl 1201) ctrlShow (_rightClick != ""); - -private _offset = 19; - -if (_scroll == "") then { - (_display displayCtrl 1002) ctrlShow false; - (_display displayCtrl 1202) ctrlShow false; - (_display displayCtrl 1001) ctrlSetPosition [21 * GUI_GRID_W, 18 * GUI_GRID_H, 24 * GUI_GRID_W, 1.5 * GUI_GRID_H]; - (_display displayCtrl 1201) ctrlSetPosition [20 * GUI_GRID_W, 18.5 * GUI_GRID_H, 1.5 * GUI_GRID_W, 1 * GUI_GRID_H]; - (_display displayCtrl 1001) ctrlCommit 0; - (_display displayCtrl 1201) ctrlCommit 0; } else { - _offset = _offset + 1; - (_display displayCtrl 1002) ctrlSetText _scroll; - // Disable action menu inGameUISetEventHandler ["PrevAction", "true"]; inGameUISetEventHandler ["NextAction", "true"]; inGameUISetEventHandler ["Action", "true"]; + + // Increase offset since MMB active + _yOffset = 20.55; }; +// Create extra icon sets { - _x params [["_xKeyName", "", [""]], ["_xText", "", [""]]]; - switch (toLower _xKeyName) do { - case ("alt"): {_xKeyName = format ["<%1>", toUpper localize "str_dik_alt"];}; - case ("control"); - case ("ctrl"): {_xKeyName = format ["<%1>", toUpper localize "str_dik_control"];}; - case ("shift"): {_xKeyName = format ["<%1>", toUpper localize "str_dik_shift"];}; + _x params [["_keyName", "", [""]], ["_keyText", "", [""]]]; + + // Only create extra key if both name and text are valid + if (_keyName != "" && {_keyText != ""}) then { + // Localize Ctrl, Shift, or Alt keys + switch (toLower _keyName) do { + 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; + + private _ctrlText = _ctrlGroup controlsGroupCtrl IDC_MOUSEHINT_EXTRA_TEXT; + _ctrlText ctrlSetText _keyText; + + _yOffset = _yOffset + 1; }; - - private _keyNameCtrl = _display ctrlCreate ["RscInteractionText_right", -1]; - private _textCtrl = _display ctrlCreate ["RscInteractionText", -1]; - _keyNameCtrl ctrlSetText _xKeyName; - _textCtrl ctrlSetText _xText; - _keyNameCtrl ctrlSetPosition [0 * GUI_GRID_W, _offset * GUI_GRID_H, 21.4 * GUI_GRID_W, 1.5 * GUI_GRID_H]; - _textCtrl ctrlSetPosition [21 * GUI_GRID_W, _offset * GUI_GRID_H, 24 * GUI_GRID_W, 1.5 * GUI_GRID_H]; - _keyNameCtrl ctrlCommit 0; - _textCtrl ctrlCommit 0; - _offset = _offset + 1; } forEach _extraIconSets; - diff --git a/addons/interaction/script_component.hpp b/addons/interaction/script_component.hpp index e94733c456..8114dc37a2 100644 --- a/addons/interaction/script_component.hpp +++ b/addons/interaction/script_component.hpp @@ -16,6 +16,20 @@ #include "\z\ace\addons\main\script_macros.hpp" +#include "\a3\ui_f\hpp\defineCommonGrids.inc" + +#define IDD_MOUSEHINT 2400 +#define IDC_MOUSEHINT_LMB 2410 +#define IDC_MOUSEHINT_LMB_TEXT 2420 +#define IDC_MOUSEHINT_MMB 2430 +#define IDC_MOUSEHINT_MMB_TEXT 2450 +#define IDC_MOUSEHINT_RMB 2460 +#define IDC_MOUSEHINT_RMB_TEXT 2470 + +#define IDC_MOUSEHINT_EXTRA 2500 +#define IDC_MOUSEHINT_EXTRA_NAME 2510 +#define IDC_MOUSEHINT_EXTRA_TEXT 2520 + #define MACRO_DOOR_REACH_DISTANCE (AGLToASL positionCameraToWorld [0,0,0] vectorDistance AGLToASL (ACE_player modelToWorld (ACE_player selectionPosition "Head"))) + 2 #define DISABLED_LAMP_DAMAGE 0.95