Skip to content

Commit 527b200

Browse files
authored
Improve placement preview mouse position handling (#690)
1 parent 791e66f commit 527b200

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

addons/editor/XEH_preInit.sqf

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PREP_RECOMPILE_END;
99
#include "initSettings.sqf"
1010
#include "initKeybinds.sqf"
1111

12+
GVAR(mousePos) = [0, 0];
1213
GVAR(clipboard) = [];
1314
GVAR(includeCrew) = true;
1415

addons/editor/functions/fnc_handleLoad.sqf

+12
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ _ctrlTreeRecent ctrlAddEventHandler ["TreeSelChanged", {
110110
};
111111
}];
112112

113+
// Track mouse position from mouse area control to handle the mouse being over other UI elements
114+
// RscDisplayCurator_mousePos from base game attempts to do this but for some reason also updates when
115+
// the mouse is over the mission controls group
116+
private _fnc_updateMousePos = {
117+
params ["", "_posX", "_posY"];
118+
GVAR(mousePos) = [_posX, _posY];
119+
};
120+
121+
private _ctrlMouseArea = _display displayCtrl IDC_RSCDISPLAYCURATOR_MOUSEAREA;
122+
_ctrlMouseArea ctrlAddEventHandler ["MouseMoving", _fnc_updateMousePos];
123+
_ctrlMouseArea ctrlAddEventHandler ["MouseHolding", _fnc_updateMousePos];
124+
113125
// Initially open the map fully zoomed out and centered
114126
if (isNil QGVAR(previousMapState)) then {
115127
GVAR(previousMapState) = [1, [worldSize / 2, worldSize / 2]];

addons/placement/functions/fnc_updatePreview.sqf

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717

1818
BEGIN_COUNTER(updatePreview);
1919

20-
// Using mouse position from mouse area control to not update when mouse is over other UI elements
21-
private _mousePos = uiNamespace getVariable ["RscDisplayCurator_mousePos", [0, 0]];
22-
2320
// Get terrain position and normal
24-
private _position = AGLtoASL screenToWorld _mousePos;
21+
private _position = AGLtoASL screenToWorld EGVAR(editor,mousePos);
2522
private _vectorUp = surfaceNormal _position;
2623

2724
// Check if a surface other than the terrain exists

0 commit comments

Comments
 (0)