aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cc/woverflow/chatting
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/cc/woverflow/chatting')
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt26
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt6
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt14
3 files changed, 33 insertions, 13 deletions
diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
index cb95c53..c2329b4 100644
--- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
@@ -16,15 +16,16 @@ object ChatTabs {
private val GSON = GsonBuilder().setPrettyPrinting().create()
private val PARSER = JsonParser()
val tabs = arrayListOf<ChatTab>()
- var currentTab: ChatTab? = null
- set(value) {
- if (value != null) {
- field = value
- if (Minecraft.getMinecraft().theWorld != null) {
- Minecraft.getMinecraft().ingameGUI.chatGUI.refreshChat()
- }
+ var currentTabs: ArrayList<ChatTab?> = object : ArrayList<ChatTab?>() {
+ override fun add(element: ChatTab?): Boolean {
+ if (element == null) return false
+ val returnValue = super.add(element)
+ if (Minecraft.getMinecraft().theWorld != null && returnValue) {
+ Minecraft.getMinecraft().ingameGUI.chatGUI.refreshChat()
}
+ return returnValue
}
+ }
private var initialized = false
private val tabFile = ConfigUtils.getProfileFile("chattabs.json")
@@ -49,7 +50,8 @@ object ChatTabs {
tabs.forEach {
it.initialize()
}
- currentTab = tabs[0]
+ currentTabs.clear()
+ currentTabs.add(tabs[0])
}
private fun handleFile() {
@@ -171,7 +173,13 @@ object ChatTabs {
}
fun shouldRender(message: IChatComponent): Boolean {
- return currentTab?.shouldRender(message) ?: true
+ if (currentTabs.isEmpty()) return true
+ for (tab in currentTabs) {
+ if (tab?.shouldRender(message) == true) {
+ return true
+ }
+ }
+ return false
}
private fun generateNewFile() {
diff --git a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt
index ab52eb9..86db2cc 100644
--- a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt
@@ -222,9 +222,11 @@ object ChattingConfig : Config(
prefix = ""
)
dummy.initialize()
- ChatTabs.currentTab = dummy
+ ChatTabs.currentTabs.clear()
+ ChatTabs.currentTabs.add(dummy)
} else {
- ChatTabs.currentTab = ChatTabs.tabs[0]
+ ChatTabs.currentTabs.clear()
+ ChatTabs.currentTabs.add(ChatTabs.tabs[0])
}
}
addListener("chatShortcuts") {
diff --git a/src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt b/src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt
index f320925..e3b96f1 100644
--- a/src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt
@@ -1,5 +1,6 @@
package cc.woverflow.chatting.gui.components
+import cc.polyfrost.oneconfig.libs.universal.UKeyboard
import cc.polyfrost.oneconfig.libs.universal.UResolution
import cc.woverflow.chatting.chat.ChatTab
import cc.woverflow.chatting.chat.ChatTabs
@@ -21,11 +22,20 @@ class TabButton(buttonId: Int, x: Int, widthIn: Int, heightIn: Int, private val
}) {
override fun onMousePress() {
- ChatTabs.currentTab = chatTab
+ if (UKeyboard.isShiftKeyDown()) {
+ if (ChatTabs.currentTabs.contains(chatTab)) {
+ ChatTabs.currentTabs.remove(chatTab)
+ } else {
+ ChatTabs.currentTabs.add(chatTab)
+ }
+ } else {
+ ChatTabs.currentTabs.clear()
+ ChatTabs.currentTabs.add(chatTab)
+ }
}
override fun isEnabled(): Boolean {
- return chatTab != ChatTabs.currentTab
+ return ChatTabs.currentTabs.contains(chatTab)
}
companion object {