From ce70c72cd6878e49f86d1b41081a6b048d892f61 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 7 Apr 2015 22:44:41 -0500 Subject: [PATCH] wip1 --- addons/interact_menu/config.cpp | 6 ++++++ addons/interact_menu/functions/fnc_keyDown.sqf | 9 ++++++++- addons/interact_menu/functions/fnc_renderIcon.sqf | 9 ++++++++- addons/interact_menu/functions/fnc_renderSelector.sqf | 9 ++++++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/addons/interact_menu/config.cpp b/addons/interact_menu/config.cpp index 17900c2f6b..998098470e 100644 --- a/addons/interact_menu/config.cpp +++ b/addons/interact_menu/config.cpp @@ -22,5 +22,11 @@ class ACE_Settings { typeName = "BOOL"; isClientSetable = 1; displayName = "$STR_ACE_Interact_Menu_AlwaysUseCursorSelfInteraction"; + }; + class GVAR(cursorKeepCentered) { + value = 0; + typeName = "BOOL"; + isClientSetable = 1; + displayName = "Keep cursor centered"; }; }; diff --git a/addons/interact_menu/functions/fnc_keyDown.sqf b/addons/interact_menu/functions/fnc_keyDown.sqf index faa5b0f453..291c675260 100644 --- a/addons/interact_menu/functions/fnc_keyDown.sqf +++ b/addons/interact_menu/functions/fnc_keyDown.sqf @@ -39,8 +39,15 @@ if (GVAR(useCursorMenu)) then { // uiNamespace getVariable QGVAR(dlgCursorMenu); // uiNamespace getVariable QGVAR(cursorMenuOpened); ctrlEnable [91921, true]; + GVAR(cursorPos) = [0.5,0.5,0]; ((finddisplay 91919) displayctrl 91921) ctrlAddEventHandler ["MouseMoving", { - GVAR(cursorPos) = [_this select 1, _this select 2, 0]; + + if (GVAR(cursorKeepCentered)) then { + GVAR(cursorPos) = GVAR(cursorPos) vectorAdd [_this select 1, _this select 2, 0] vectorDiff [0.5, 0.5, 0]; + setMousePosition [0.5, 0.5]; + } else { + GVAR(cursorPos) = [_this select 1, _this select 2, 0]; + }; }]; setMousePosition [0.5, 0.5]; }; diff --git a/addons/interact_menu/functions/fnc_renderIcon.sqf b/addons/interact_menu/functions/fnc_renderIcon.sqf index 1cfc13923e..e48847cbb9 100644 --- a/addons/interact_menu/functions/fnc_renderIcon.sqf +++ b/addons/interact_menu/functions/fnc_renderIcon.sqf @@ -37,6 +37,13 @@ if(_icon == "") then { }; _text = format ["
%4", _icon, _color, _color, _text]; _ctrl ctrlSetStructuredText (parseText _text); -_ctrl ctrlSetPosition [(_sPos select 0)-(0.125*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.25*SafeZoneW, 0.1*SafeZoneW]; +_pos = [(_sPos select 0)-(0.125*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.25*SafeZoneW, 0.1*SafeZoneW]; + +if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then { + _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 ctrlSetBackgroundColor [1, 0, 0, 0.1]; _ctrl ctrlCommit 0; diff --git a/addons/interact_menu/functions/fnc_renderSelector.sqf b/addons/interact_menu/functions/fnc_renderSelector.sqf index 44ed15e9c4..e397b40994 100644 --- a/addons/interact_menu/functions/fnc_renderSelector.sqf +++ b/addons/interact_menu/functions/fnc_renderSelector.sqf @@ -25,6 +25,13 @@ _ctrl = GVAR(iconCtrls) select GVAR(iconCount); GVAR(iconCount) = GVAR(iconCount) + 1; _ctrl ctrlSetStructuredText (parseText format ["", _icon]); -_ctrl ctrlSetPosition [(_sPos select 0)-(0.05*SafeZoneW), (_sPos select 1)-(0.014*SafeZoneW), 0.1*SafeZoneW, 0.035*SafeZoneW]; +_pos = [(_sPos select 0)-(0.05*SafeZoneW), (_sPos select 1)-(0.014*SafeZoneW), 0.1*SafeZoneW, 0.035*SafeZoneW]; + +if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then { + _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 ctrlSetBackgroundColor [1, 0, 0, 0.1]; _ctrl ctrlCommit 0;