@@ -29,10 +29,12 @@ import com.lambda.module.HudModule
2929import com.lambda.module.ModuleRegistry
3030import com.lambda.module.modules.client.GuiSettings
3131import com.lambda.module.modules.client.ClickGui
32+ import imgui.ImColor
3233import imgui.ImGui
3334import imgui.ImDrawList
3435import imgui.flag.ImDrawListFlags
3536import imgui.flag.ImGuiWindowFlags
37+ import imgui.flag.ImGuiStyleVar
3638import kotlin.math.PI
3739
3840object HudGuiLayout : Loadable {
@@ -98,26 +100,46 @@ object HudGuiLayout : Loadable {
98100 ImGui .setNextWindowPos(override .first, override .second)
99101 }
100102
101- val hudFlags = if (ClickGui .isEnabled) DEFAULT_HUD_FLAGS else {
102- DEFAULT_HUD_FLAGS or ImGuiWindowFlags .NoMove
103+ val bg = hud.backgroundColor
104+ val hasBg = bg.alpha > 0
105+ val baseFlags = if (hasBg) {
106+ DEFAULT_HUD_FLAGS and ImGuiWindowFlags .NoBackground .inv ()
107+ } else DEFAULT_HUD_FLAGS
108+ val hudFlags = if (! ClickGui .isEnabled) {
109+ baseFlags or ImGuiWindowFlags .NoMove
110+ } else baseFlags
111+
112+ val pushedColor = if (hasBg) {
113+ val packed = ImColor .rgba(bg.red, bg.green, bg.blue, bg.alpha)
114+ ImGui .pushStyleColor(imgui.flag.ImGuiCol .WindowBg , packed)
115+ true
116+ } else {
117+ false
103118 }
104119
105- window(" ##${hud.name} " , flags = hudFlags) {
106- val vis = snapOverlays[hud.name]
107- if (vis != null ) {
108- SnapManager .drawSnapLines(
109- foregroundDrawList,
110- vis.snapX, vis.kindX,
111- vis.snapY, vis.kindY
112- )
120+ val outlineWidth = if (hud.outline) hud.outlineWidth else 0f
121+ withStyleVar(ImGuiStyleVar .WindowBorderSize , outlineWidth) {
122+ window(" ##${hud.name} " , flags = hudFlags) {
123+ val vis = snapOverlays[hud.name]
124+ if (vis != null ) {
125+ SnapManager .drawSnapLines(
126+ foregroundDrawList,
127+ vis.snapX, vis.kindX,
128+ vis.snapY, vis.kindY
129+ )
130+ }
131+ with (hud) { buildLayout() }
132+ if (ClickGui .isEnabled) {
133+ drawHudCornerArcs(foregroundDrawList, windowPos.x, windowPos.y, windowSize.x, windowSize.y)
134+ }
135+ val rect = RectF (windowPos.x, windowPos.y, windowSize.x, windowSize.y)
136+ SnapManager .registerElement(hud.name, rect)
137+ lastBounds[hud.name] = rect
113138 }
114- with (hud) { buildLayout() }
115- if (ClickGui .isEnabled) {
116- drawHudOutline(foregroundDrawList, windowPos.x, windowPos.y, windowSize.x, windowSize.y)
117- }
118- val rect = RectF (windowPos.x, windowPos.y, windowSize.x, windowSize.y)
119- SnapManager .registerElement(hud.name, rect)
120- lastBounds[hud.name] = rect
139+ }
140+
141+ if (pushedColor) {
142+ ImGui .popStyleColor()
121143 }
122144 }
123145 }
@@ -154,7 +176,7 @@ object HudGuiLayout : Loadable {
154176 snapOverlays[id] = SnapVisual (snap.snapX, snap.snapY, snap.kindX, snap.kindY)
155177 }
156178
157- private fun ImGuiBuilder.drawHudOutline (draw : ImDrawList , x : Float , y : Float , w : Float , h : Float ) {
179+ private fun ImGuiBuilder.drawHudCornerArcs (draw : ImDrawList , x : Float , y : Float , w : Float , h : Float ) {
158180 val baseRadius = GuiSettings .hudOutlineCornerRadius
159181 val rounding = if (baseRadius > 0f ) baseRadius else style.windowRounding
160182 val inflate = GuiSettings .hudOutlineCornerInflate
0 commit comments