@@ -52,7 +52,7 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) {
5252
5353 // Snapping
5454 val snapEnabled by setting(" Enable Snapping" , true , " Master toggle for HUD snapping" ).group(Group .Snapping )
55- val gridSize by setting(" Grid Size" , 16f , 2f .. 128f , 1f , " Grid step in pixels" ) { snapEnabled }.group(Group .Snapping )
55+ val gridSize by setting(" Grid Size" , 25f , 2f .. 128f , 1f , " Grid step in pixels" ) { snapEnabled }.group(Group .Snapping )
5656 val snapToEdges by setting(" Snap To Element Edges" , true ) { snapEnabled }.group(Group .Snapping )
5757 val snapToCenters by setting(" Snap To Element Centers" , true ) { snapEnabled }.group(Group .Snapping )
5858 val snapToScreenCenter by setting(" Snap To Screen Center" , true ) { snapEnabled }.group(Group .Snapping )
@@ -82,6 +82,7 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) {
8282 private val lastBounds = mutableMapOf<String , RectF >()
8383 private val pendingPositions = mutableMapOf<String , Pair <Float , Float >>()
8484 private val snapOverlays = mutableMapOf<String , SnapVisual >()
85+ private var mousePressedThisFrameGlobal = false
8586
8687 var isShownInGUI = true
8788 var isLocked = false
@@ -121,6 +122,7 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) {
121122 val mousePressedThisFrame = mouseDown && ! mouseWasDown
122123 val mouseReleasedThisFrame = ! mouseDown && mouseWasDown
123124 mouseWasDown = mouseDown
125+ mousePressedThisFrameGlobal = mousePressedThisFrame
124126
125127 if (mouseReleasedThisFrame || ! ClickGui .isEnabled || isLocked) {
126128 activeDragHudName = null
@@ -138,9 +140,8 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) {
138140 registerContextMenu(notShown)
139141
140142 if (ClickGui .isEnabled && ! isLocked) {
141- if (activeDragHudName == null && mousePressedThisFrame) { tryBeginDrag(huds) }
142- if (activeDragHudName != null && mouseDown) updateDragAndSnapping()
143- if (activeDragHudName != null ) drawDragGrid()
143+ if (activeDragHudName != null && mouseDown) updateDragAndSnapping()
144+ if (activeDragHudName != null ) drawDragGrid()
144145 }
145146
146147 huds.forEach { hud ->
@@ -176,6 +177,14 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) {
176177 val outlineWidth = if (hud.outline) hud.outlineWidth else 0f
177178 withStyleVar(ImGuiStyleVar .WindowBorderSize , outlineWidth) {
178179 window(" ##${hud.name} " , flags = hudFlags) {
180+ if (ClickGui .isEnabled && ! isLocked && activeDragHudName == null && mousePressedThisFrameGlobal && ImGui .isWindowHovered()) {
181+ val mx = io.mousePos.x
182+ val my = io.mousePos.y
183+ activeDragHudName = hud.name
184+ dragOffsetX = mx - windowPos.x
185+ dragOffsetY = my - windowPos.y
186+ }
187+
179188 val vis = snapOverlays[hud.name]
180189 if (vis != null ) {
181190 SnapManager .drawSnapLines(
@@ -218,10 +227,6 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) {
218227 isShownInGUI = ! isShownInGUI
219228 }
220229 separator()
221- menu(" HUD Settings" ) {
222- buildConfigSettingsContext(this @HudGuiLayout)
223- }
224- separator()
225230 if (notShown.isEmpty()) {
226231 textDisabled(" No hidden HUD elements" )
227232 } else {
@@ -236,20 +241,9 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) {
236241 }
237242 }
238243 }
239- }
240- }
241-
242- private fun ImGuiBuilder.tryBeginDrag (huds : List <HudModule >) {
243- val mx = io.mousePos.x
244- val my = io.mousePos.y
245- huds.forEach { hud ->
246- val r = lastBounds[hud.name] ? : return @forEach
247- val inside = mx >= r.x && mx <= r.x + r.w && my >= r.y && my <= r.y + r.h
248- if (inside) {
249- activeDragHudName = hud.name
250- dragOffsetX = mx - r.x
251- dragOffsetY = my - r.y
252- return
244+ separator()
245+ menu(" HUD Settings" ) {
246+ buildConfigSettingsContext(this @HudGuiLayout)
253247 }
254248 }
255249 }
0 commit comments