Rename scrollBar to buttonsProgressBar
This commit is contained in:
parent
5d5ea4b5ea
commit
a7e7e6e60e
|
@ -24,8 +24,9 @@ fun interface Renderable {
|
|||
|
||||
abstract class Element(
|
||||
@JvmField val xOrigin: Double, @JvmField val yOrigin: Double,
|
||||
var width: Int, var height: Int
|
||||
val originalWidth: Int, val originalHeight: Int
|
||||
): Renderable {
|
||||
open var width = originalWidth; open var height = originalHeight
|
||||
open var x = xOrigin; open var y = yOrigin
|
||||
internal fun withinBounds(coordinateX: Double, coordinateY: Double): Boolean =
|
||||
((coordinateX >= this.x) && (coordinateX <= (this.x + this.width))) and ((coordinateY >= this.y) && (coordinateY <= (this.y + this.height)))
|
||||
|
@ -49,7 +50,7 @@ abstract class Element(
|
|||
}
|
||||
}
|
||||
}
|
||||
var hidden: Boolean = false; protected set
|
||||
var hidden: Boolean = false; internal set
|
||||
}
|
||||
|
||||
abstract class ColoredElement(
|
||||
|
|
|
@ -7,6 +7,7 @@ import fr.username404.snowygui.gui.ColoredElement
|
|||
import fr.username404.snowygui.gui.Renderable.Rendering.buffer
|
||||
import fr.username404.snowygui.gui.Renderable.Rendering.defaultRectFunc
|
||||
import fr.username404.snowygui.gui.Renderable.Rendering.tessellator
|
||||
import fr.username404.snowygui.gui.elements.ClickButton.Companion.Type
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.minecraft.client.Minecraft
|
||||
|
@ -18,16 +19,16 @@ class ClickBox(
|
|||
private val name: TranslatableComponent? = null
|
||||
): ColoredElement(x, y, 80, 10, 0x6C9E9D, 0.5F) {
|
||||
val buttons = mutableMapOf<String, ClickButton>()
|
||||
fun addButtons(vararg collect: Pair<String, (() -> Unit)?>, color: Int = 0x6C9E9D): ClickBox {
|
||||
fun addButtons(vararg collect: Pair<String, (() -> Unit)?>, color: Int = 0x6C9E9D, kind: Type = Type.TOGGLE): ClickBox {
|
||||
buttons.putAll(
|
||||
collect.map {
|
||||
it.first to ClickButton(Title = it.first, action = it.second, color = color)
|
||||
it.first to ClickButton(Title = it.first, action = it.second, color = color, kind = kind)
|
||||
}
|
||||
)
|
||||
return this
|
||||
}
|
||||
@JvmField
|
||||
val scrollBar: ColoredElement = object: ColoredElement(
|
||||
val buttonsProgressBar: ColoredElement = object: ColoredElement(
|
||||
(x + width), y + height + 3,
|
||||
color = color, width = 3, height = 74,
|
||||
opacity = 0.75F
|
||||
|
@ -42,8 +43,10 @@ class ClickBox(
|
|||
}
|
||||
}
|
||||
fun scroll(supplied: Double) {
|
||||
with(scrollBar) {
|
||||
// TODO Implement scrolling
|
||||
with(buttonsProgressBar) {
|
||||
if ((height != 0 || (supplied < 0)) && ((height != originalHeight) || (supplied > 0))) {
|
||||
height -= supplied.toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +82,7 @@ class ClickBox(
|
|||
RenderSystem.disableBlend()
|
||||
|
||||
val renderButtons = if (buttons.isNotEmpty()) launch {
|
||||
scrollBar.apply {
|
||||
buttonsProgressBar.apply {
|
||||
x = this@ClickBox.x + this@ClickBox.width - 3
|
||||
y = this@ClickBox.y + this@ClickBox.height + 3
|
||||
}.display(poseStack)
|
||||
|
|
Loading…
Reference in New Issue