diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-03-12 15:43:15 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-03-12 15:43:15 +0700 |
commit | eece3cb994280498d2a9c259030cc79a4be3fce3 (patch) | |
tree | e23c8d6a1c2553d2511630012f275ffa15ebf532 /src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt | |
parent | 380e0adb5ef1401dd8cbf70b2ef7bc121c371c42 (diff) | |
download | Chatting-eece3cb994280498d2a9c259030cc79a4be3fce3.tar.gz Chatting-eece3cb994280498d2a9c259030cc79a4be3fce3.tar.bz2 Chatting-eece3cb994280498d2a9c259030cc79a4be3fce3.zip |
color property
Diffstat (limited to 'src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt')
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt index ec9dfc8..99a8999 100644 --- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt +++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt @@ -1,6 +1,7 @@ package cc.woverflow.chatting.chat import cc.woverflow.chatting.Chatting +import cc.woverflow.chatting.gui.components.TabButton import com.google.gson.GsonBuilder import com.google.gson.JsonArray import com.google.gson.JsonObject @@ -43,16 +44,26 @@ object ChatTabs { chatTabJson.tabs.forEach { applyVersion2Changes(it.asJsonObject) applyVersion3Changes(it.asJsonObject) + applyVersion4Changes(it.asJsonObject) } - chatTabJson.version = 3 + chatTabJson.version = ChatTabsJson.VERSION tabFile.writeText(chatTabJson.toString()) } 2 -> { - // ver 2 adds `enabled` + // ver 3 adds ignore_ chatTabJson.tabs.forEach { applyVersion3Changes(it.asJsonObject) + applyVersion4Changes(it.asJsonObject) + } + chatTabJson.version = ChatTabsJson.VERSION + tabFile.writeText(chatTabJson.toString()) + } + 3 -> { + // ver 4 adds color options + chatTabJson.tabs.forEach { + applyVersion4Changes(it.asJsonObject) } - chatTabJson.version = 3 + chatTabJson.version = ChatTabsJson.VERSION tabFile.writeText(chatTabJson.toString()) } } @@ -86,6 +97,12 @@ object ChatTabs { json.add("ignore_regex", JsonArray()) } + private fun applyVersion4Changes(json: JsonObject) { + json.addProperty("color", TabButton.color) + json.addProperty("hovered_color", TabButton.hoveredColor) + json.addProperty("selected_color", TabButton.selectedColor) + } + fun shouldRender(message: IChatComponent): Boolean { return currentTab?.shouldRender(message) ?: true } @@ -95,12 +112,30 @@ object ChatTabs { val jsonObject = JsonObject() val defaultTabs = generateDefaultTabs() jsonObject.add("tabs", defaultTabs) - jsonObject.addProperty("version", 3) + jsonObject.addProperty("version", ChatTabsJson.VERSION) tabFile.writeText(jsonObject.toString()) } private fun generateDefaultTabs(): JsonArray { - val all = ChatTab(true, "ALL", false, null, null, null, null, null, null, null, null, null, null, "") + val all = ChatTab( + true, + "ALL", + false, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + TabButton.color, + TabButton.hoveredColor, + TabButton.selectedColor, + "" + ) val party = ChatTab( true, "PARTY", @@ -164,6 +199,9 @@ object ChatTabs { null, null, null, + TabButton.color, + TabButton.hoveredColor, + TabButton.selectedColor, "/pc " ) val guild = ChatTab( @@ -180,6 +218,9 @@ object ChatTabs { null, null, null, + TabButton.color, + TabButton.hoveredColor, + TabButton.selectedColor, "/gc " ) val pm = ChatTab( @@ -196,6 +237,9 @@ object ChatTabs { null, null, null, + TabButton.color, + TabButton.hoveredColor, + TabButton.selectedColor, "/r " ) tabs.add(all) |