Skip to content

Commit 5e80a86

Browse files
committed
background
1 parent 52f3af1 commit 5e80a86

File tree

3 files changed

+34
-25
lines changed

3 files changed

+34
-25
lines changed

src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ object HudGuiLayout : Loadable {
3838
.filterIsInstance<HudModule>()
3939
.filter { it.isEnabled }
4040
.forEach { hud ->
41-
window("##${hud.name}", flags = DEFAULT_HUD_FLAGS) {
42-
with(hud) { buildLayout() }
43-
}
41+
if (!hud.customWindow)
42+
window("##${hud.name}", flags = DEFAULT_HUD_FLAGS) {
43+
with(hud) { buildLayout() }
44+
}
45+
else with(hud) { buildLayout() }
4446
}
4547
}
4648
}

src/main/kotlin/com/lambda/interaction/request/DebugLogger.kt

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ import com.lambda.gui.dsl.ImGuiBuilder
2121
import com.lambda.module.HudModule
2222
import com.lambda.module.tag.ModuleTag
2323
import imgui.ImGui
24+
import imgui.flag.ImGuiWindowFlags
2425
import java.awt.Color
2526
import java.util.*
2627

27-
abstract class DebugLogger(name: String, description: String) : HudModule(name, description, ModuleTag.HUD) {
28+
abstract class DebugLogger(
29+
name: String,
30+
description: String
31+
) : HudModule(
32+
name,
33+
description,
34+
ModuleTag.HUD,
35+
customWindow = true
36+
) {
2837
private val logs = LinkedList<LogEntry>()
2938

30-
private val autoScroll by setting("Auto-Scroll", true, "Automatically scrolls to the bottom of the log")
3139
private val wrapText by setting("Wrap Text", false, "Wraps the text to the next line if it gets too long")
3240
private val showDebug by setting("Show Debug", true, "Shows debug logs")
3341
private val showSuccess by setting("Show Success", true, "Shows success logs")
@@ -55,31 +63,29 @@ abstract class DebugLogger(name: String, description: String) : HudModule(name,
5563
fun error(message: String) = log(message, LogType.Error)
5664

5765
override fun ImGuiBuilder.buildLayout() {
58-
child("Log Content") {
59-
if (wrapText) ImGui.pushTextWrapPos()
60-
61-
logs.forEach { logEntry ->
62-
if (shouldDisplay(logEntry)) {
63-
when (val type = logEntry.type) {
64-
LogType.Debug -> textColored("[DEBUG]", type.color)
65-
LogType.Success -> textColored("[SUCCESS]", type.color)
66-
LogType.Warning -> textColored("[WARNING]", type.color)
67-
LogType.Error -> textColored("[ERROR]", type.color)
66+
ImGui.setNextWindowSizeConstraints(300f, 400f, windowViewport.workSizeX, windowViewport.workSizeY)
67+
window(name, flags = ImGuiWindowFlags.NoTitleBar) {
68+
child("Log Content") {
69+
if (wrapText) ImGui.pushTextWrapPos()
70+
71+
logs.forEach { logEntry ->
72+
if (shouldDisplay(logEntry)) {
73+
when (val type = logEntry.type) {
74+
LogType.Debug -> textColored("[DEBUG]", type.color)
75+
LogType.Success -> textColored("[SUCCESS]", type.color)
76+
LogType.Warning -> textColored("[WARNING]", type.color)
77+
LogType.Error -> textColored("[ERROR]", type.color)
78+
}
79+
80+
sameLine()
81+
textColored(logEntry.message, logEntry.type.color)
6882
}
69-
70-
sameLine()
71-
textColored(logEntry.message, logEntry.type.color)
7283
}
73-
}
7484

75-
if (wrapText) ImGui.popTextWrapPos()
76-
77-
if (autoScroll) {
78-
ImGui.setScrollHereY(1f)
85+
if (wrapText) ImGui.popTextWrapPos()
7986
}
87+
button("Clear") { clear() }
8088
}
81-
82-
button("Clear") { clear() }
8389
}
8490

8591
fun shouldDisplay(logEntry: LogEntry) =

src/main/kotlin/com/lambda/module/HudModule.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ abstract class HudModule(
2525
name: String,
2626
description: String = "",
2727
tag: ModuleTag,
28+
val customWindow: Boolean = false,
2829
alwaysListening: Boolean = false,
2930
enabledByDefault: Boolean = false,
3031
defaultKeybind: KeyCode = KeyCode.UNBOUND,

0 commit comments

Comments
 (0)