aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cc/woverflow/chatting/gui
diff options
context:
space:
mode:
authorWyvest <wyvestbusiness@gmail.com>2023-11-22 08:18:19 +0900
committerWyvest <wyvestbusiness@gmail.com>2023-11-22 08:18:19 +0900
commit8b373f577d9c6dde26357ef3fc86691f1efef9b4 (patch)
treea5328e995d8f4df21a9fe94ac8e384be08833c70 /src/main/kotlin/cc/woverflow/chatting/gui
parent64230799777473246b5f98efbc596206c5bbf42d (diff)
downloadChatting-8b373f577d9c6dde26357ef3fc86691f1efef9b4.tar.gz
Chatting-8b373f577d9c6dde26357ef3fc86691f1efef9b4.tar.bz2
Chatting-8b373f577d9c6dde26357ef3fc86691f1efef9b4.zip
update PGT and relocate to org.polyfrost
Diffstat (limited to 'src/main/kotlin/cc/woverflow/chatting/gui')
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt103
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/gui/components/ClearButton.kt42
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/gui/components/RenderType.kt7
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/gui/components/ScreenshotButton.kt36
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/gui/components/SearchButton.kt70
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt46
6 files changed, 0 insertions, 304 deletions
diff --git a/src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt b/src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt
deleted file mode 100644
index de590e6..0000000
--- a/src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt
+++ /dev/null
@@ -1,103 +0,0 @@
-package cc.woverflow.chatting.gui.components
-
-import cc.polyfrost.oneconfig.renderer.TextRenderer
-import cc.woverflow.chatting.Chatting
-import cc.woverflow.chatting.config.ChattingConfig
-import cc.woverflow.chatting.hook.GuiNewChatHook
-import club.sk1er.patcher.config.PatcherConfig
-import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.GuiButton
-import net.minecraft.client.renderer.GlStateManager
-
-/**
- * Taken from ChatShortcuts under MIT License
- * https://github.com/P0keDev/ChatShortcuts/blob/master/LICENSE
- * @author P0keDev
- */
-open class CleanButton(
- buttonId: Int,
- private val x: () -> Int,
- private val y: () -> Int,
- widthIn: Int,
- heightIn: Int,
- name: String,
- private val renderType: () -> RenderType,
- private val textColor: (packedFGColour: Int, enabled: Boolean, hovered: Boolean) -> Int = { packedFGColour: Int, enabled: Boolean, hovered: Boolean ->
- var j = 14737632
- if (packedFGColour != 0) {
- j = packedFGColour
- } else if (!enabled) {
- j = 10526880
- } else if (hovered) {
- j = 16777120
- }
- j
- },
-) :
- GuiButton(buttonId, x.invoke(), 0, widthIn, heightIn, name) {
-
- open fun isEnabled(): Boolean {
- return false
- }
-
- open fun onMousePress() {
-
- }
-
- override fun mousePressed(mc: Minecraft, mouseX: Int, mouseY: Int): Boolean {
- val isPressed =
- visible && mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height
- if (isPressed) {
- onMousePress()
- }
- return isPressed
- }
-
- override fun drawButton(mc: Minecraft, mouseX: Int, mouseY: Int) {
- enabled = isEnabled()
- xPosition = x()
- yPosition = y()
- if (visible) {
- val fontrenderer = mc.fontRendererObj
- GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f)
- hovered =
- mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height
- if (!Chatting.isPatcher || !PatcherConfig.transparentChatInputField) {
- drawRect(
- xPosition,
- yPosition,
- xPosition + width,
- yPosition + height,
- getBackgroundColor(hovered)
- )
- }
- mouseDragged(mc, mouseX, mouseY)
- val j = textColor(packedFGColour, enabled, hovered)
- when (renderType()) {
- RenderType.NONE, RenderType.SHADOW -> {
- drawCenteredString(
- fontrenderer,
- displayString,
- xPosition + width / 2,
- yPosition + (height - 8) / 2,
- j
- )
- }
-
- RenderType.FULL -> {
- TextRenderer.drawBorderedText(
- displayString,
- ((xPosition + width / 2) - (fontrenderer.getStringWidth(displayString) / 2)).toFloat(),
- (yPosition + (height - 8) / 2).toFloat(),
- j,
- (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).textOpacity
- )
- }
- }
- }
- }
-
- private fun getBackgroundColor(hovered: Boolean) =
- if (hovered) ChattingConfig.chatButtonHoveredBackgroundColor.rgb
- else ChattingConfig.chatButtonBackgroundColor.rgb
-} \ No newline at end of file
diff --git a/src/main/kotlin/cc/woverflow/chatting/gui/components/ClearButton.kt b/src/main/kotlin/cc/woverflow/chatting/gui/components/ClearButton.kt
deleted file mode 100644
index 6ac3d34..0000000
--- a/src/main/kotlin/cc/woverflow/chatting/gui/components/ClearButton.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-package cc.woverflow.chatting.gui.components
-
-import cc.polyfrost.oneconfig.libs.universal.ChatColor
-import cc.polyfrost.oneconfig.libs.universal.UChat
-import cc.polyfrost.oneconfig.libs.universal.UResolution
-import cc.polyfrost.oneconfig.utils.Multithreading
-import cc.woverflow.chatting.Chatting
-import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.Gui
-import net.minecraft.client.renderer.GlStateManager
-import net.minecraft.util.ResourceLocation
-
-class ClearButton :
- CleanButton(13379014, { UResolution.scaledWidth - 28 }, { UResolution.scaledHeight - 27 }, 12, 12, "",
- { RenderType.NONE }) {
-
- var times = 0
-
- override fun onMousePress() {
- ++times
- if (times > 1) {
- times = 0
- Minecraft.getMinecraft().ingameGUI.chatGUI.clearChatMessages()
- } else {
- UChat.chat(ChatColor.RED + ChatColor.BOLD.toString() + "Click again to clear the chat!")
- Multithreading.runAsync {
- Thread.sleep(3000)
- times = 0
- }
- }
- }
-
- override fun drawButton(mc: Minecraft, mouseX: Int, mouseY: Int) {
- super.drawButton(mc, mouseX, mouseY)
- if (visible) {
- if (hovered) GlStateManager.color(1f, 1f, 160f / 255f)
- else GlStateManager.color(1f, 1f, 1f)
- mc.textureManager.bindTexture(ResourceLocation(Chatting.ID, "delete.png"))
- Gui.drawModalRectWithCustomSizedTexture(xPosition + 1, yPosition + 1, 0f, 0f, 10, 10, 10f, 10f)
- }
- }
-} \ No newline at end of file
diff --git a/src/main/kotlin/cc/woverflow/chatting/gui/components/RenderType.kt b/src/main/kotlin/cc/woverflow/chatting/gui/components/RenderType.kt
deleted file mode 100644
index 8a56d5b..0000000
--- a/src/main/kotlin/cc/woverflow/chatting/gui/components/RenderType.kt
+++ /dev/null
@@ -1,7 +0,0 @@
-package cc.woverflow.chatting.gui.components
-
-enum class RenderType {
- NONE,
- SHADOW,
- FULL
-} \ No newline at end of file
diff --git a/src/main/kotlin/cc/woverflow/chatting/gui/components/ScreenshotButton.kt b/src/main/kotlin/cc/woverflow/chatting/gui/components/ScreenshotButton.kt
deleted file mode 100644
index 4f65427..0000000
--- a/src/main/kotlin/cc/woverflow/chatting/gui/components/ScreenshotButton.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-package cc.woverflow.chatting.gui.components
-
-import cc.polyfrost.oneconfig.libs.universal.UResolution
-import cc.polyfrost.oneconfig.libs.universal.UScreen
-import cc.woverflow.chatting.Chatting
-import cc.woverflow.chatting.mixin.GuiNewChatAccessor
-import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.Gui
-import net.minecraft.client.gui.GuiChat
-import net.minecraft.client.renderer.GlStateManager
-import net.minecraft.util.ResourceLocation
-
-class ScreenshotButton :
- CleanButton(448318, { UResolution.scaledWidth - 42 }, { UResolution.scaledHeight - 27 }, 12, 12, "",
- { RenderType.NONE }) {
-
- override fun onMousePress() {
- val chat = Minecraft.getMinecraft().ingameGUI.chatGUI
- if (UScreen.currentScreen is GuiChat) {
- Chatting.screenshotChat((chat as GuiNewChatAccessor).scrollPos)
- }
- }
-
- override fun drawButton(mc: Minecraft, mouseX: Int, mouseY: Int) {
- super.drawButton(mc, mouseX, mouseY)
- if (visible) {
- if (hovered) {
- GlStateManager.color(1f, 1f, 160f / 255f)
- } else {
- GlStateManager.color(1f, 1f, 1f)
- }
- mc.textureManager.bindTexture(ResourceLocation(Chatting.ID, "screenshot.png"))
- Gui.drawModalRectWithCustomSizedTexture(xPosition + 1, yPosition + 1, 0f, 0f, 10, 10, 10f, 10f)
- }
- }
-} \ No newline at end of file
diff --git a/src/main/kotlin/cc/woverflow/chatting/gui/components/SearchButton.kt b/src/main/kotlin/cc/woverflow/chatting/gui/components/SearchButton.kt
deleted file mode 100644
index 54e9041..0000000
--- a/src/main/kotlin/cc/woverflow/chatting/gui/components/SearchButton.kt
+++ /dev/null
@@ -1,70 +0,0 @@
-package cc.woverflow.chatting.gui.components
-
-import cc.polyfrost.oneconfig.libs.universal.UResolution
-import cc.woverflow.chatting.Chatting
-import cc.woverflow.chatting.chat.ChatSearchingManager
-import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.Gui
-import net.minecraft.client.gui.GuiTextField
-import net.minecraft.client.renderer.GlStateManager
-import net.minecraft.util.ResourceLocation
-
-class SearchButton :
- CleanButton(3993935, { UResolution.scaledWidth - 14 }, { UResolution.scaledHeight - 27 }, 12, 12, "",
- { RenderType.NONE }) {
- val inputField = SearchTextField()
- private var chatBox = false
-
- override fun isEnabled(): Boolean {
- return chatBox
- }
-
- override fun onMousePress() {
- chatBox = !chatBox
- inputField.setEnabled(chatBox)
- inputField.isFocused = chatBox
- ChatSearchingManager.lastSearch = ""
- inputField.text = ""
- }
-
- override fun drawButton(mc: Minecraft, mouseX: Int, mouseY: Int) {
- inputField.drawTextBox()
- super.drawButton(mc, mouseX, mouseY)
- if (visible) {
- mc.textureManager.bindTexture(ResourceLocation(Chatting.ID, "search.png"))
- if (isEnabled()) {
- GlStateManager.color(224f / 255f, 224f / 255f, 224f / 255f)
- } else if (mouseX >= xPosition && mouseX <= xPosition + 10 && mouseY >= yPosition && mouseY <= yPosition + 10) {
- GlStateManager.color(1f, 1f, 160f / 255f)
- } else {
- GlStateManager.color(1f, 1f, 1f)
- }
- Gui.drawModalRectWithCustomSizedTexture(xPosition + 1, yPosition + 1, 0f, 0f, 10, 10, 10f, 10f)
- }
- }
-
- inner class SearchTextField : GuiTextField(
- 69420,
- Minecraft.getMinecraft().fontRendererObj,
- UResolution.scaledWidth * 4 / 5 - 60,
- UResolution.scaledHeight - 26,
- UResolution.scaledWidth / 5,
- 12
- ) {
-
- init {
- maxStringLength = 100
- enableBackgroundDrawing = true
- isFocused = false
- text = ""
- setCanLoseFocus(true)
- }
-
- override fun drawTextBox() {
- if (isEnabled()) {
- if (!isFocused) isFocused = true
- super.drawTextBox()
- }
- }
- }
-}
diff --git a/src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt b/src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt
deleted file mode 100644
index e3b96f1..0000000
--- a/src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt
+++ /dev/null
@@ -1,46 +0,0 @@
-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
-import cc.woverflow.chatting.config.ChattingConfig
-
-class TabButton(buttonId: Int, x: Int, widthIn: Int, heightIn: Int, private val chatTab: ChatTab) :
- CleanButton(buttonId, { x }, {
- UResolution.scaledHeight - 26
- }, widthIn, heightIn, chatTab.name, { RenderType.values()[ChattingConfig.textRenderType] }, { packedFGColour: Int, enabled: Boolean, hovered: Boolean ->
- var j = chatTab.color ?: color
- if (packedFGColour != 0) {
- j = packedFGColour
- } else if (!enabled) {
- j = chatTab.selectedColor ?: selectedColor
- } else if (hovered) {
- j = chatTab.hoveredColor ?: hoveredColor
- }
- j
- }) {
-
- override fun onMousePress() {
- 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 ChatTabs.currentTabs.contains(chatTab)
- }
-
- companion object {
- const val color: Int = 14737632
- const val hoveredColor: Int = 16777120
- const val selectedColor: Int = 10526880
- }
-} \ No newline at end of file