summaryrefslogtreecommitdiff
path: root/src/main/kotlin/gui
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-01-25 15:11:28 +0100
committerLinnea Gräf <nea@nea.moe>2025-01-25 15:11:28 +0100
commit1062594643e4bb955bb6bf4efe8983108bdbd1bb (patch)
tree64888238907c03e679846a50d7be60fd955f7f1e /src/main/kotlin/gui
parent1cae07c3df2f324205dc940278e7e702850f5ed2 (diff)
downloadultra-notifier-1062594643e4bb955bb6bf4efe8983108bdbd1bb.tar.gz
ultra-notifier-1062594643e4bb955bb6bf4efe8983108bdbd1bb.tar.bz2
ultra-notifier-1062594643e4bb955bb6bf4efe8983108bdbd1bb.zip
Filter visible chat messages
Diffstat (limited to 'src/main/kotlin/gui')
-rw-r--r--src/main/kotlin/gui/ChatUi.kt18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main/kotlin/gui/ChatUi.kt b/src/main/kotlin/gui/ChatUi.kt
index e88c375..b812b73 100644
--- a/src/main/kotlin/gui/ChatUi.kt
+++ b/src/main/kotlin/gui/ChatUi.kt
@@ -2,6 +2,8 @@ package moe.nea.ultranotifier.gui
import gg.essential.universal.UGraphics
import gg.essential.universal.UMatrixStack
+import moe.nea.ultranotifier.datamodel.ChatCategory
+import moe.nea.ultranotifier.datamodel.ChatCategoryArbiter
import moe.nea.ultranotifier.util.minecrat.MC
import moe.nea.ultranotifier.util.minecrat.accessor
import moe.nea.ultranotifier.util.render.ScreenRenderUtils
@@ -26,10 +28,9 @@ class ChatUi(val chatScreen: ChatScreen) {
return chatTop.toDouble()
}
- var selectedTab = "Bazaar"
fun iterateButtons(
onEach: (
- label: String,
+ label: ChatCategory,
isSelected: Boolean,
pos: Rect,
) -> Unit
@@ -37,9 +38,9 @@ class ChatUi(val chatScreen: ChatScreen) {
val chatTop = calculateChatTop()
var xOffset = 5
val top = chatTop - 16.0
- for (button in listOf("Socials", "Bazaar", "Slayer", "Guild", "Party", "Dungeon", "Fishing","Socials", "Bazaar", "Slayer", "Guild", "Party", "Dungeon", "Fishing")) {
- val w = ScreenRenderUtils.getTextWidth(button) + 3
- val isSelected = button == selectedTab
+ for (button in ChatCategoryArbiter.categories) {
+ val w = ScreenRenderUtils.getTextWidth(button.label) + 3
+ val isSelected = button == ChatCategoryArbiter.selectedCategory
onEach(button, isSelected, Rect(xOffset.toDouble(), top, w.toDouble(), 16.0))
xOffset += w + 5
}
@@ -65,8 +66,7 @@ class ChatUi(val chatScreen: ChatScreen) {
matrixStack: UMatrixStack,
mouseX: Double, mouseY: Double,
) {
- iterateButtons { text, isSelected, pos ->
- val w = ScreenRenderUtils.getTextWidth(text)
+ iterateButtons { button, isSelected, pos ->
UGraphics.enableBlend()
ScreenRenderUtils.fillRect(matrixStack,
pos.l, pos.t, pos.r, pos.b,
@@ -74,7 +74,7 @@ class ChatUi(val chatScreen: ChatScreen) {
UGraphics.disableBlend()
ScreenRenderUtils.renderText(matrixStack,
pos.l + 2, pos.cy - 9 / 2,
- if (isSelected) "§a$text" else "§f$text")
+ if (isSelected) "§a${button.label}" else "§f${button.label}")
}
}
@@ -82,7 +82,7 @@ class ChatUi(val chatScreen: ChatScreen) {
iterateButtons { label, isSelected, pos ->
if (pos.contains(mouseX, mouseY)) {
if (button == 0) {
- selectedTab = label
+ ChatCategoryArbiter.selectedCategoryId = label.id
}
// TODO: right click options or something
}