aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cc/woverflow/chattils/gui/components
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-01-03 11:12:54 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-01-03 11:12:54 +0700
commit487709996c22fb0dbcac792076be799a09865600 (patch)
tree5ab6f27a54d673fb057fd3eafd9a5e27816f898c /src/main/kotlin/cc/woverflow/chattils/gui/components
parentdf895d122a8a2ea249e686578e026c1d0a8b8c47 (diff)
downloadChatting-487709996c22fb0dbcac792076be799a09865600.tar.gz
Chatting-487709996c22fb0dbcac792076be799a09865600.tar.bz2
Chatting-487709996c22fb0dbcac792076be799a09865600.zip
Chattils -> Chatting (1.1.0)
Update images (ty Mo2men) update screenshot line tooltip (ty Mo2men)
Diffstat (limited to 'src/main/kotlin/cc/woverflow/chattils/gui/components')
-rw-r--r--src/main/kotlin/cc/woverflow/chattils/gui/components/CleanButton.kt70
-rw-r--r--src/main/kotlin/cc/woverflow/chattils/gui/components/ScreenshotButton.kt35
-rw-r--r--src/main/kotlin/cc/woverflow/chattils/gui/components/SearchButton.kt69
-rw-r--r--src/main/kotlin/cc/woverflow/chattils/gui/components/TabButton.kt19
-rw-r--r--src/main/kotlin/cc/woverflow/chattils/gui/components/TextBlock.kt41
5 files changed, 0 insertions, 234 deletions
diff --git a/src/main/kotlin/cc/woverflow/chattils/gui/components/CleanButton.kt b/src/main/kotlin/cc/woverflow/chattils/gui/components/CleanButton.kt
deleted file mode 100644
index 7011518..0000000
--- a/src/main/kotlin/cc/woverflow/chattils/gui/components/CleanButton.kt
+++ /dev/null
@@ -1,70 +0,0 @@
-package cc.woverflow.chattils.gui.components
-
-import cc.woverflow.chattils.Chattils
-import club.sk1er.patcher.config.PatcherConfig
-import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.GuiButton
-import net.minecraft.client.renderer.GlStateManager
-import java.awt.Color
-
-/**
- * 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) :
- 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.invoke()
- yPosition = y.invoke()
- 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 (!Chattils.isPatcher || !PatcherConfig.transparentChatInputField) {
- drawRect(
- xPosition,
- yPosition,
- xPosition + width,
- yPosition + height,
- if (hovered) hoveredColor else color
- )
- }
- mouseDragged(mc, mouseX, mouseY)
- var j = 14737632
- if (packedFGColour != 0) {
- j = packedFGColour
- } else if (!enabled) {
- j = 10526880
- } else if (hovered) {
- j = 16777120
- }
- drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, j)
- }
- }
-
- companion object {
- private val hoveredColor = Color(255, 255, 255, 128).rgb
- private val color = Color(0, 0, 0, 128).rgb
- }
-} \ No newline at end of file
diff --git a/src/main/kotlin/cc/woverflow/chattils/gui/components/ScreenshotButton.kt b/src/main/kotlin/cc/woverflow/chattils/gui/components/ScreenshotButton.kt
deleted file mode 100644
index 0e6f088..0000000
--- a/src/main/kotlin/cc/woverflow/chattils/gui/components/ScreenshotButton.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-package cc.woverflow.chattils.gui.components
-
-import cc.woverflow.chattils.Chattils
-import cc.woverflow.chattils.mixin.GuiNewChatAccessor
-import gg.essential.api.utils.GuiUtil
-import gg.essential.universal.UResolution
-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 - 28 }, { UResolution.scaledHeight - 27 }, 12, 12, "") {
-
- override fun onMousePress() {
- val chat = Minecraft.getMinecraft().ingameGUI.chatGUI
- if (GuiUtil.getOpenedScreen() is GuiChat) {
- Chattils.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(Chattils.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/chattils/gui/components/SearchButton.kt b/src/main/kotlin/cc/woverflow/chattils/gui/components/SearchButton.kt
deleted file mode 100644
index 04a2743..0000000
--- a/src/main/kotlin/cc/woverflow/chattils/gui/components/SearchButton.kt
+++ /dev/null
@@ -1,69 +0,0 @@
-package cc.woverflow.chattils.gui.components
-
-import cc.woverflow.chattils.Chattils
-import cc.woverflow.chattils.hook.GuiNewChatHook
-import gg.essential.universal.UResolution
-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, "") {
- val inputField = SearchTextField()
- private var chatBox = false
-
- override fun isEnabled(): Boolean {
- return chatBox
- }
-
- override fun onMousePress() {
- chatBox = !chatBox
- inputField.setEnabled(chatBox)
- inputField.isFocused = chatBox
- (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).prevText = ""
- inputField.text = ""
- }
-
- override fun drawButton(mc: Minecraft, mouseX: Int, mouseY: Int) {
- inputField.drawTextBox()
- super.drawButton(mc, mouseX, mouseY)
- if (visible) {
- mc.textureManager.bindTexture(ResourceLocation(Chattils.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 - 27,
- 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()
- }
- }
- }
-} \ No newline at end of file
diff --git a/src/main/kotlin/cc/woverflow/chattils/gui/components/TabButton.kt b/src/main/kotlin/cc/woverflow/chattils/gui/components/TabButton.kt
deleted file mode 100644
index 4770900..0000000
--- a/src/main/kotlin/cc/woverflow/chattils/gui/components/TabButton.kt
+++ /dev/null
@@ -1,19 +0,0 @@
-package cc.woverflow.chattils.gui.components
-
-import cc.woverflow.chattils.chat.ChatTab
-import cc.woverflow.chattils.chat.ChatTabs
-import gg.essential.universal.UResolution
-
-class TabButton(buttonId: Int, x: Int, widthIn: Int, heightIn: Int, private val chatTab: ChatTab) :
- CleanButton(buttonId, { x }, {
- UResolution.scaledHeight - 26
- }, widthIn, heightIn, chatTab.name) {
-
- override fun onMousePress() {
- ChatTabs.currentTab = chatTab
- }
-
- override fun isEnabled(): Boolean {
- return chatTab != ChatTabs.currentTab
- }
-} \ No newline at end of file
diff --git a/src/main/kotlin/cc/woverflow/chattils/gui/components/TextBlock.kt b/src/main/kotlin/cc/woverflow/chattils/gui/components/TextBlock.kt
deleted file mode 100644
index c83d22d..0000000
--- a/src/main/kotlin/cc/woverflow/chattils/gui/components/TextBlock.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-package cc.woverflow.chattils.gui.components
-
-import gg.essential.elementa.components.UIBlock
-import gg.essential.elementa.components.UIText
-import gg.essential.elementa.constraints.ChildBasedSizeConstraint
-import gg.essential.elementa.dsl.*
-import gg.essential.elementa.effects.OutlineEffect
-import gg.essential.elementa.state.BasicState
-import gg.essential.vigilance.gui.VigilancePalette
-import gg.essential.vigilance.gui.settings.SettingComponent
-
-/**
- * Heavily modified from Vigilance under LGPLv3 (modified to be just a text block)
- * https://github.com/Sk1erLLC/Vigilance/blob/master/LICENSE
- */
-class TextBlock(
- text: String
-) : SettingComponent() {
- private val textHolder = UIBlock() constrain {
- width = ChildBasedSizeConstraint() + 6.pixels()
- height = ChildBasedSizeConstraint() + 6.pixels()
- color = VigilancePalette.getDarkHighlight().toConstraint()
- } childOf this effect OutlineEffect(
- VigilancePalette.getDivider(),
- 1f
- ).bindColor(BasicState(VigilancePalette.getDivider()))
-
- private val text: UIText = UIText(text) constrain {
- x = 3.pixels()
- y = 3.pixels()
- }
-
- init {
- this.text childOf textHolder
-
- constrain {
- width = ChildBasedSizeConstraint()
- height = ChildBasedSizeConstraint()
- }
- }
-} \ No newline at end of file