Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove snap guides when hud is disabled
  • Loading branch information
Avanatiker committed Sep 7, 2025
commit cbe18f47da10486c9baa14ed2654103997440f25
18 changes: 6 additions & 12 deletions src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ object HudGuiLayout : Loadable {
pendingPositions.clear()
snapOverlays.clear()

val huds = ModuleRegistry.modules
val (huds, notShown) = ModuleRegistry.modules
.filterIsInstance<HudModule>()
.filter { it.isEnabled }
.partition { it.isEnabled }

notShown.forEach { SnapManager.unregisterElement(it.name) }

if (ClickGui.isEnabled && activeDragHudName == null && mousePressedThisFrame) {
tryBeginDrag(huds)
Expand All @@ -106,17 +108,9 @@ object HudGuiLayout : Loadable {
}
with(hud) { buildLayout() }
if (ClickGui.isEnabled) {
drawHudOutline(
draw = foregroundDrawList,
x = windowPos.x,
y = windowPos.y,
w = windowSize.x,
h = windowSize.y
)
drawHudOutline(foregroundDrawList, windowPos.x, windowPos.y, windowSize.x, windowSize.y)
}
val p = windowPos
val s = windowSize
val rect = RectF(p.x, p.y, s.x, s.y)
val rect = RectF(windowPos.x, windowPos.y, windowSize.x, windowSize.y)
SnapManager.registerElement(hud.name, rect)
lastBounds[hud.name] = rect
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/com/lambda/gui/snap/SnapManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ object SnapManager {
elementRects[id] = rect
}

fun unregisterElement(id: String) {
elementRects.remove(id)
}

private fun addElementGuides(sourceId: String, r: RectF) {
if (snapEnabled && snapToEdges) {
frameGuides += SnapGuide(Guide(Guide.Orientation.Vertical, r.left, 100, Guide.Kind.ElementEdge), sourceId)
Expand Down