Research tree preview multiple scrollers
This commit is contained in:
parent
75fe096059
commit
b5f5b800cd
@ -408,6 +408,59 @@ private class AndroidResearchButton(
|
||||
}
|
||||
}
|
||||
|
||||
private enum class PreviewScrollers(
|
||||
val init: (EditablePanel, Random) -> Unit,
|
||||
val scroll: (EditablePanel, Random) -> Boolean
|
||||
) {
|
||||
LEFT_TO_RIGHT(
|
||||
init = { it, random ->
|
||||
it.xOffset = it.width
|
||||
it.yOffset = random.nextFloat(-it.boundingHeight + 18f, 0f)
|
||||
},
|
||||
|
||||
scroll = { it, _ ->
|
||||
it.xOffset -= 1f
|
||||
it.xOffset >= -it.boundingWidth
|
||||
}
|
||||
),
|
||||
|
||||
RIGHT_TO_LEFT(
|
||||
init = { it, random ->
|
||||
it.xOffset = -it.boundingWidth
|
||||
it.yOffset = random.nextFloat(-it.boundingHeight + 18f, 0f)
|
||||
},
|
||||
|
||||
scroll = { it, _ ->
|
||||
it.xOffset += 1f
|
||||
it.xOffset <= it.width
|
||||
}
|
||||
),
|
||||
|
||||
BOTTOM_TO_TOP(
|
||||
init = { it, random ->
|
||||
it.yOffset = -it.boundingHeight
|
||||
it.xOffset = random.nextFloat(-it.boundingWidth + 18f, 0f)
|
||||
},
|
||||
|
||||
scroll = { it, _ ->
|
||||
it.yOffset += 1f
|
||||
it.yOffset <= it.height
|
||||
}
|
||||
),
|
||||
|
||||
TOP_TO_BOTTOM(
|
||||
init = { it, random ->
|
||||
it.yOffset = it.height
|
||||
it.xOffset = random.nextFloat(-it.boundingWidth + 18f, 0f)
|
||||
},
|
||||
|
||||
scroll = { it, _ ->
|
||||
it.yOffset -= 1f
|
||||
it.yOffset >= it.boundingHeight
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: Inventory, p_97743_: Component) :
|
||||
MatteryScreen<AndroidStationMenu>(p_97741_, p_97742_, p_97743_) {
|
||||
|
||||
@ -416,6 +469,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
|
||||
val canvas = object : DraggableCanvasPanel(this@AndroidStationScreen, null) {
|
||||
private val random = Random()
|
||||
private var scroller: PreviewScrollers = PreviewScrollers.values().let { it[random.nextInt(it.size)] }
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
drawColor = RGBAColor.BLACK
|
||||
@ -435,11 +489,11 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
super.tick()
|
||||
|
||||
if (isPreview) {
|
||||
xOffset -= 1f
|
||||
val status = scroller.scroll.invoke(this, random)
|
||||
|
||||
if (xOffset < -boundingWidth) {
|
||||
xOffset = width
|
||||
yOffset = random.nextFloat(-boundingHeight + 18f, 0f)
|
||||
if (!status) {
|
||||
scroller = PreviewScrollers.values().let { it[random.nextInt(it.size)] }
|
||||
scroller.init.invoke(this, random)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -554,7 +608,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I
|
||||
|
||||
SlotPanel(this, stripLeft, menu.batterySlot).also {
|
||||
it.dock = Dock.TOP
|
||||
it.dockTop = 4f
|
||||
it.dockTop = 6f
|
||||
}
|
||||
|
||||
val playerStrip = EditablePanel(this, frame, height = 72f)
|
||||
|
Loading…
Reference in New Issue
Block a user