aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/cc/woverflow/chatting/gui/components/ScreenshotButton.kt
blob: e72dbe12e11f92183ed22a092c2754e63cfb171e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cc.woverflow.chatting.gui.components

import cc.woverflow.chatting.Chatting
import cc.woverflow.chatting.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 - 26 }, 12, 12, "",
        { RenderType.NONE }) {

    override fun onMousePress() {
        val chat = Minecraft.getMinecraft().ingameGUI.chatGUI
        if (GuiUtil.getOpenedScreen() 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)
        }
    }
}