|
17 | 17 |
|
18 | 18 | package com.lambda.interaction.request |
19 | 19 |
|
20 | | -import com.lambda.Lambda.mc |
21 | | -import com.lambda.gui.LambdaScreen |
22 | 20 | import com.lambda.gui.dsl.ImGuiBuilder |
23 | 21 | import com.lambda.interaction.request.LogContext.Companion.buildLogContext |
| 22 | +import com.lambda.module.hud.ManagerDebugLoggers.autoScroll |
24 | 23 | import com.lambda.module.hud.ManagerDebugLoggers.maxLogEntries |
| 24 | +import com.lambda.module.hud.ManagerDebugLoggers.showDebug |
| 25 | +import com.lambda.module.hud.ManagerDebugLoggers.showError |
| 26 | +import com.lambda.module.hud.ManagerDebugLoggers.showSuccess |
| 27 | +import com.lambda.module.hud.ManagerDebugLoggers.showSystem |
| 28 | +import com.lambda.module.hud.ManagerDebugLoggers.showWarning |
| 29 | +import com.lambda.module.hud.ManagerDebugLoggers.wrapText |
25 | 30 | import com.lambda.util.math.a |
26 | 31 | import imgui.ImGui |
27 | 32 | import imgui.flag.ImGuiCol |
28 | 33 | import imgui.flag.ImGuiWindowFlags |
29 | | -import imgui.type.ImBoolean |
30 | | -import imgui.type.ImFloat |
31 | 34 | import java.awt.Color |
32 | 35 | import java.util.* |
33 | 36 |
|
34 | 37 | class DebugLogger( |
35 | 38 | val name: String |
36 | 39 | ) { |
37 | | - private val autoScroll = ImBoolean(true) |
38 | | - private val wrapText = ImBoolean(true) |
39 | | - private val showDebug = ImBoolean(true) |
40 | | - private val showSuccess = ImBoolean(true) |
41 | | - private val showWarning = ImBoolean(true) |
42 | | - private val showError = ImBoolean(true) |
43 | | - private val showSystem = ImBoolean(true) |
44 | | - private val backgroundAlpha = ImFloat(0.3f) |
45 | | - |
46 | 40 | val logs = LinkedList<LogEntry>() |
47 | 41 |
|
48 | 42 | private fun log(message: String, logColor: LogType, extraContext: List<String?>) { |
@@ -75,25 +69,10 @@ class DebugLogger( |
75 | 69 |
|
76 | 70 | fun ImGuiBuilder.buildLayout() { |
77 | 71 | ImGui.setNextWindowSizeConstraints(300f, 400f, windowViewport.workSizeX, windowViewport.workSizeY) |
78 | | - ImGui.setNextWindowBgAlpha(backgroundAlpha.get()) |
79 | | - val noScroll = if (autoScroll.get()) ImGuiWindowFlags.NoScrollbar or ImGuiWindowFlags.NoScrollWithMouse else 0 |
80 | | - if (mc.currentScreen == LambdaScreen) { |
81 | | - checkbox("Auto-Scroll", autoScroll) |
82 | | - sameLine() |
83 | | - checkbox("Warp Text", wrapText) |
84 | | - sameLine() |
85 | | - checkbox("Show Debug", showDebug) |
86 | | - checkbox("Show Success", showSuccess) |
87 | | - sameLine() |
88 | | - checkbox("Show Warning", showWarning) |
89 | | - sameLine() |
90 | | - checkbox("Show Error", showError) |
91 | | - checkbox("Show System", showSystem) |
92 | | - slider("Background Alpha", backgroundAlpha, 0.0f, 1.0f) |
93 | | - button("Clear") { clear() } |
94 | | - } |
95 | | - child("Log Content", extraFlags = noScroll) { |
96 | | - if (wrapText.get()) ImGui.pushTextWrapPos() |
| 72 | + var flags = if (autoScroll) ImGuiWindowFlags.NoScrollbar or ImGuiWindowFlags.NoScrollWithMouse else 0 |
| 73 | + flags = flags or ImGuiWindowFlags.NoBackground |
| 74 | + child("Log Content", extraFlags = flags) { |
| 75 | + if (wrapText) ImGui.pushTextWrapPos() |
97 | 76 |
|
98 | 77 | logs.forEach { logEntry -> |
99 | 78 | if (shouldDisplay(logEntry)) { |
@@ -124,21 +103,21 @@ class DebugLogger( |
124 | 103 | } |
125 | 104 | } |
126 | 105 |
|
127 | | - if (wrapText.get()) ImGui.popTextWrapPos() |
| 106 | + if (wrapText) ImGui.popTextWrapPos() |
128 | 107 |
|
129 | | - if (autoScroll.get()) { |
| 108 | + if (autoScroll) { |
130 | 109 | ImGui.setScrollHereY(1f) |
131 | 110 | } |
132 | 111 | } |
133 | 112 | } |
134 | 113 |
|
135 | 114 | fun shouldDisplay(logEntry: LogEntry) = |
136 | 115 | when (logEntry.type) { |
137 | | - LogType.Debug -> showDebug.get() |
138 | | - LogType.Success -> showSuccess.get() |
139 | | - LogType.Warning -> showWarning.get() |
140 | | - LogType.Error -> showError.get() |
141 | | - LogType.System -> showSystem.get() |
| 116 | + LogType.Debug -> showDebug |
| 117 | + LogType.Success -> showSuccess |
| 118 | + LogType.Warning -> showWarning |
| 119 | + LogType.Error -> showError |
| 120 | + LogType.System -> showSystem |
142 | 121 | } |
143 | 122 |
|
144 | 123 | fun clear() = logs.clear() |
|
0 commit comments