diff options
Diffstat (limited to 'src/main/kotlin/cc/woverflow/chatting/gui/components')
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt | 27 | ||||
-rw-r--r-- | src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt | 18 |
2 files changed, 32 insertions, 13 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 index 9863936..1d8d8ce 100644 --- a/src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt +++ b/src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt @@ -14,7 +14,17 @@ import java.awt.Color * 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) : +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 { @@ -36,8 +46,8 @@ open class CleanButton(buttonId: Int, private val x: () -> Int, private val y: ( override fun drawButton(mc: Minecraft, mouseX: Int, mouseY: Int) { enabled = isEnabled() - xPosition = x.invoke() - yPosition = y.invoke() + xPosition = x() + yPosition = y() if (visible) { val fontrenderer = mc.fontRendererObj GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f) @@ -53,15 +63,8 @@ open class CleanButton(buttonId: Int, private val x: () -> Int, private val y: ( ) } mouseDragged(mc, mouseX, mouseY) - var j = 14737632 - if (packedFGColour != 0) { - j = packedFGColour - } else if (!enabled) { - j = 10526880 - } else if (hovered) { - j = 16777120 - } - when (renderType.invoke()) { + val j = textColor(packedFGColour, enabled, hovered) + when (renderType()) { RenderType.NONE, RenderType.SHADOW -> { drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, j) } 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 25190e1..da20eed 100644 --- a/src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt +++ b/src/main/kotlin/cc/woverflow/chatting/gui/components/TabButton.kt @@ -8,7 +8,17 @@ 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, { RenderType.values()[ChattingConfig.textRenderType] }) { + }, 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() { ChatTabs.currentTab = chatTab @@ -17,4 +27,10 @@ class TabButton(buttonId: Int, x: Int, widthIn: Int, heightIn: Int, private val override fun isEnabled(): Boolean { return chatTab != ChatTabs.currentTab } + + companion object { + const val color: Int = 14737632 + const val hoveredColor: Int = 16777120 + const val selectedColor: Int = 10526880 + } }
\ No newline at end of file |