Complete the scroll function

This commit is contained in:
Username404-59 2021-05-04 18:18:48 +02:00
parent 8e444c9596
commit 2beaf74843
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 10 additions and 4 deletions

View File

@ -43,10 +43,14 @@ class ClickBox(
} }
init { height = 8 } init { height = 8 }
} }
var barStage: Int = 1; private set
fun scroll(supplied: Double) { fun scroll(supplied: Double) {
with(buttonsProgressBar) { with(buttonsProgressBar) {
if ((height != 8 || (supplied < 0)) && ((height != originalHeight) || (supplied > 0))) { if ((height != 8 || (supplied < 0)) && ((height != originalHeight) || (supplied > 0))) {
height -= supplied.toInt() height -= supplied.toInt()
if (buttons.count() != 0) (height / buttons.count()).let {
if (it > 0) barStage = it
}
} }
} }
} }
@ -87,10 +91,12 @@ class ClickBox(
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)
buttons.values.forEachIndexed { num, it -> buttons.values.forEachIndexed { num, button ->
it.apply { val fullHeight = (y + height.toDouble())..(y + height + 80.0)
it.x = this@ClickBox.x + 3 button.also {
it.y = this@ClickBox.y + 5 + height + (num * 9) it.x = x + 3
it.y = y + 3 + height + (((num + 1) - barStage) * 9)
it.hidden = if ((num + 1) <= 8) ((it.y) !in fullHeight) else ((it.y + it.height) !in fullHeight)
}.display(poseStack) }.display(poseStack)
} }
} else null } else null