mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 10:34:06 +09:00
saving wip
This commit is contained in:
@@ -68,6 +68,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
inactiveCol = Color.WHITE,
|
inactiveCol = Color.WHITE,
|
||||||
defaultSelection = null
|
defaultSelection = null
|
||||||
)
|
)
|
||||||
|
private val savingUI = UIItemSaving(this, (width - UIItemSaving.WIDTH) / 2, (height - UIItemSaving.HEIGHT) / 2)
|
||||||
|
|
||||||
private var screen = 0
|
private var screen = 0
|
||||||
|
|
||||||
@@ -76,6 +77,9 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
|
|
||||||
gameMenuButtons.selectionChangeListener = { _, new ->
|
gameMenuButtons.selectionChangeListener = { _, new ->
|
||||||
when (new) {
|
when (new) {
|
||||||
|
0 -> {
|
||||||
|
screen = 3; gameMenuButtons.deselect()
|
||||||
|
}
|
||||||
4 -> {
|
4 -> {
|
||||||
screen = 2; gameMenuButtons.deselect()
|
screen = 2; gameMenuButtons.deselect()
|
||||||
}
|
}
|
||||||
@@ -114,6 +118,10 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
},
|
},
|
||||||
{ delta: Float ->
|
{ delta: Float ->
|
||||||
areYouSureMainMenuButtons.update(delta)
|
areYouSureMainMenuButtons.update(delta)
|
||||||
|
},
|
||||||
|
{ delta: Float ->
|
||||||
|
savingUI.update(delta)
|
||||||
|
// TODO make UI not closable until saving is done
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
private val screenRenders = arrayOf(
|
private val screenRenders = arrayOf(
|
||||||
@@ -135,6 +143,9 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
|
|||||||
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
|
||||||
|
|
||||||
areYouSureMainMenuButtons.render(batch, camera)
|
areYouSureMainMenuButtons.render(batch, camera)
|
||||||
|
},
|
||||||
|
{ batch: SpriteBatch, camera: Camera ->
|
||||||
|
savingUI.render(batch, camera)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
45
src/net/torvald/terrarum/modulebasegame/ui/UIItemSaving.kt
Normal file
45
src/net/torvald/terrarum/modulebasegame/ui/UIItemSaving.kt
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Camera
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.terrarum.App
|
||||||
|
import net.torvald.terrarum.CommonResourcePool
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
import net.torvald.terrarum.ui.UIItem
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2021-09-14.
|
||||||
|
*/
|
||||||
|
class UIItemSaving(parentUI: UICanvas, initialX: Int, initialY: Int) : UIItem(parentUI, initialX, initialY) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val WIDTH = 320
|
||||||
|
const val HEIGHT = 100
|
||||||
|
}
|
||||||
|
|
||||||
|
override val width = WIDTH
|
||||||
|
override val height = HEIGHT
|
||||||
|
|
||||||
|
private val circleSheet = CommonResourcePool.getAsTextureRegionPack("loading_circle_64")
|
||||||
|
private val circles = circleSheet.horizontalCount * circleSheet.verticalCount
|
||||||
|
|
||||||
|
init {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
|
val t = Lang["MENU_IO_SAVING"]
|
||||||
|
val tlen = App.fontGame.getWidth(t)
|
||||||
|
App.fontGame.draw(batch, t, (posX + (width - tlen) / 2).toFloat(), posY.toFloat())
|
||||||
|
|
||||||
|
// -1..63
|
||||||
|
val index = (App.GLOBAL_RENDER_TIMER % 256) / 4 //((WriteSavegame.saveProgress / WriteSavegame.saveProgressMax) * circles).roundToInt() - 1
|
||||||
|
if (index >= 0) {
|
||||||
|
val sx = index % circleSheet.horizontalCount
|
||||||
|
val sy = index / circleSheet.horizontalCount
|
||||||
|
batch.draw(circleSheet.get(sx, sy), (posX + (width - circleSheet.tileW) / 2).toFloat(), posY + height.toFloat(), circleSheet.tileW.toFloat(), circleSheet.tileH * -1f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user