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