@@ -21,13 +21,21 @@ import com.lambda.gui.dsl.ImGuiBuilder
2121import com.lambda.module.HudModule
2222import com.lambda.module.tag.ModuleTag
2323import imgui.ImGui
24+ import imgui.flag.ImGuiWindowFlags
2425import java.awt.Color
2526import 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 ) =
0 commit comments