Add titles to buttons
This commit is contained in:
parent
09536ddbb1
commit
0f0c4de85b
|
@ -4,15 +4,13 @@ import fr.username404.snowygui.gui.Element
|
|||
import fr.username404.snowygui.gui.SnowyScreen
|
||||
import fr.username404.snowygui.gui.elements.ClickBox
|
||||
import fr.username404.snowygui.gui.elements.ClickButton
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
|
||||
object ClickGui: SnowyScreen() {
|
||||
private var GuiDragging: Boolean = false
|
||||
override val components: MutableSet<Element> = mutableSetOf(
|
||||
ClickBox(4.0, 4.0, TranslatableComponent("snowy.clickbox.misc"), mutableListOf(
|
||||
ClickButton(color = 0x6C9E9D),
|
||||
ClickButton(color = 0x6C9E9D, Title = "Fullbright"),
|
||||
ClickButton(color = 0x6C9E9D)
|
||||
)),
|
||||
ClickBox(90.0, 4.0, TranslatableComponent("snowy.clickbox.rendering"), mutableListOf(
|
||||
|
|
|
@ -6,13 +6,15 @@ import fr.username404.snowygui.gui.ColoredElement
|
|||
import fr.username404.snowygui.gui.Renderable.Rendering.defaultRectFunc
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
|
||||
class ClickButton(
|
||||
x: Double = 0.0, y: Double = 0.0,
|
||||
width: Int = 73, height: Int = 8,
|
||||
color: Int, private val kind: Type = Type.TOGGLE,
|
||||
val action: (() -> Unit)? = null
|
||||
private val Title: String? = null,
|
||||
private val action: (() -> Unit)? = null,
|
||||
): ColoredElement(x, y, width, height, color, 0.60F), GuiEventListener {
|
||||
companion object {
|
||||
enum class Type {
|
||||
|
@ -43,9 +45,7 @@ class ClickButton(
|
|||
if (wasWithinBounds) {
|
||||
lightDown()
|
||||
execAction()
|
||||
}
|
||||
|
||||
return false
|
||||
}; return false
|
||||
}
|
||||
override fun render(poseStack: PoseStack?) {
|
||||
RenderSystem.disableTexture()
|
||||
|
@ -53,5 +53,6 @@ class ClickButton(
|
|||
defaultRectFunc()
|
||||
RenderSystem.enableTexture()
|
||||
RenderSystem.disableBlend()
|
||||
if (Title != null) Minecraft.getInstance().font.draw(poseStack, Title, x.toFloat() + 1, y.toFloat(), TransparentColor)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue