mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-08 04:41:51 +09:00
working autosave chooser
This commit is contained in:
@@ -106,7 +106,7 @@ public class Principii {
|
||||
// String[] cmd = (runtime+extracmd0+userDefinedExtraCmd0+" -Xms1G -Xmx"+xmx+"G -cp ./out/TerrarumBuild.jar net.torvald.terrarum.App").split(" ");
|
||||
|
||||
List<String> extracmds = Arrays.stream(extracmd0.split(" ")).toList();
|
||||
List<String> userDefinedExtraCmds = Arrays.stream(userDefinedExtraCmd0.split(" ")).toList();
|
||||
List<String> userDefinedExtraCmds = Arrays.stream(userDefinedExtraCmd0.split(" +")).filter((it) -> !it.isBlank()).toList();
|
||||
ArrayList<String> cmd0 = new ArrayList<>();
|
||||
cmd0.add(runtime);
|
||||
cmd0.addAll(extracmds);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.gdxClearAndEnableBlend
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2023-07-08.
|
||||
*/
|
||||
object StaticLoadScreenSubstitute {
|
||||
|
||||
operator fun invoke(batch: SpriteBatch) {
|
||||
batch.end()
|
||||
|
||||
gdxClearAndEnableBlend(.094f, .094f, .094f, 0f)
|
||||
|
||||
batch.begin()
|
||||
|
||||
batch.color = Color.WHITE
|
||||
val txt = Lang["MENU_IO_LOADING"]
|
||||
App.fontGame.draw(batch, txt, (App.scr.width - App.fontGame.getWidth(txt)) / 2f, (App.scr.height - App.fontGame.lineHeight) / 2f)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +1,18 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.DiskPair
|
||||
import net.torvald.terrarum.SavegameCollectionPair
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.serialise.LoadSavegame
|
||||
import net.torvald.terrarum.savegame.ByteArray64InputStream
|
||||
import net.torvald.terrarum.savegame.EntryFile
|
||||
import net.torvald.terrarum.savegame.VDFileID
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItem
|
||||
import net.torvald.terrarum.ui.UIItemImageButton
|
||||
import net.torvald.terrarum.ui.*
|
||||
import java.time.Instant
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.*
|
||||
@@ -43,6 +39,26 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
||||
private lateinit var loadManualThumbButton: UIItemImageButton
|
||||
private lateinit var loadAutoThumbButton: UIItemImageButton
|
||||
|
||||
private val buttonXcentre = Toolkit.hdrawWidth - (full.buttonWidth / 2)
|
||||
private val buttonRowY = full.drawY + 480 - full.buttonHeight
|
||||
|
||||
private var mode = 0
|
||||
private val MODE_INIT = 0
|
||||
private val MODE_LOAD = 256 // is needed to make the static loading screen
|
||||
|
||||
private lateinit var selectedGame: DiskPair
|
||||
|
||||
private val mainBackButton = UIItemTextButton(this,
|
||||
{ Lang["MENU_LABEL_BACK"] }, buttonXcentre, buttonRowY, full.buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
it.clickOnceListener = { _,_ ->
|
||||
full.changePanelTo(1)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
addUIitem(mainBackButton)
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
super.show()
|
||||
|
||||
@@ -62,10 +78,8 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
||||
).also {
|
||||
it.extraDrawOp = getDrawTextualInfoFun(loadables.getManualSave()!!)
|
||||
it.clickOnceListener = { _,_ ->
|
||||
loadables.getManualSave()!!.let {
|
||||
// UILoadGovernor.playerDisk = it.player
|
||||
// UILoadGovernor.worldDisk = it.world
|
||||
}
|
||||
selectedGame = loadables.getManualSave()!!
|
||||
mode = MODE_LOAD
|
||||
}
|
||||
}
|
||||
loadAutoThumbButton = UIItemImageButton(this, autoThumb,
|
||||
@@ -80,10 +94,8 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
||||
).also {
|
||||
it.extraDrawOp = getDrawTextualInfoFun(loadables.getAutoSave()!!)
|
||||
it.clickOnceListener = { _,_ ->
|
||||
loadables.getAutoSave()!!.let {
|
||||
// UILoadGovernor.playerDisk = it.player
|
||||
// UILoadGovernor.worldDisk = it.world
|
||||
}
|
||||
selectedGame = loadables.getAutoSave()!!
|
||||
mode = MODE_LOAD
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,18 +104,30 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
||||
override fun updateUI(delta: Float) {
|
||||
if (::loadAutoThumbButton.isInitialized) loadAutoThumbButton.update(delta)
|
||||
if (::loadManualThumbButton.isInitialized) loadManualThumbButton.update(delta)
|
||||
mainBackButton.update(delta)
|
||||
}
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
// "The Autosave is more recent than the manual save"
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["GAME_MORE_RECENT_AUTOSAVE1"], Toolkit.drawWidth, 0, altSelDrawY)
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["GAME_MORE_RECENT_AUTOSAVE2"], Toolkit.drawWidth, 0, altSelDrawY + 24)
|
||||
// Manual Save Autosave
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_IO_MANUAL_SAVE"], altSelHdrawW, (Toolkit.drawWidth - altSelDrawW)/2, altSelDrawY + 80)
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_IO_AUTOSAVE"], altSelHdrawW, Toolkit.drawWidth/2, altSelDrawY + 80)
|
||||
private var loadFiredFrameCounter = 0
|
||||
|
||||
if (::loadAutoThumbButton.isInitialized) loadAutoThumbButton.render(batch, camera)
|
||||
if (::loadManualThumbButton.isInitialized) loadManualThumbButton.render(batch, camera)
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
if (mode == MODE_INIT) {
|
||||
// "The Autosave is more recent than the manual save"
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["GAME_MORE_RECENT_AUTOSAVE1"], Toolkit.drawWidth, 0, altSelDrawY)
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["GAME_MORE_RECENT_AUTOSAVE2"], Toolkit.drawWidth, 0, altSelDrawY + 24)
|
||||
// Manual Save Autosave
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_IO_MANUAL_SAVE"], altSelHdrawW, (Toolkit.drawWidth - altSelDrawW)/2, altSelDrawY + 80)
|
||||
Toolkit.drawTextCentered(batch, App.fontGame, Lang["MENU_IO_AUTOSAVE"], altSelHdrawW, Toolkit.drawWidth/2, altSelDrawY + 80)
|
||||
|
||||
if (::loadAutoThumbButton.isInitialized) loadAutoThumbButton.render(batch, camera)
|
||||
if (::loadManualThumbButton.isInitialized) loadManualThumbButton.render(batch, camera)
|
||||
|
||||
mainBackButton.render(batch, camera)
|
||||
}
|
||||
else if (mode == MODE_LOAD) {
|
||||
loadFiredFrameCounter += 1
|
||||
StaticLoadScreenSubstitute(batch)
|
||||
if (loadFiredFrameCounter == 2) LoadSavegame(selectedGame)
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
|
||||
@@ -19,11 +19,11 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
||||
override var width: Int = Toolkit.drawWidth
|
||||
override var height: Int = App.scr.height
|
||||
|
||||
private val buttonHeight = 24
|
||||
private val buttonGap = 10
|
||||
private val buttonWidth = 180
|
||||
private val drawX = (Toolkit.drawWidth - 480) / 2
|
||||
private val drawY = (App.scr.height - 480) / 2
|
||||
private val buttonHeight = full.buttonHeight
|
||||
private val buttonGap = full.buttonGap
|
||||
private val buttonWidth = full.buttonWidth
|
||||
private val drawX = full.drawX
|
||||
private val drawY = full.drawY
|
||||
private val hx = Toolkit.hdrawWidth
|
||||
|
||||
private val buttonX1third = hx - (buttonWidth * 1.5).toInt() - buttonGap
|
||||
@@ -37,18 +37,20 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
||||
private val buttonRowY2 = buttonRowY - buttonHeight - buttonGap
|
||||
|
||||
private val mainGoButton = UIItemTextButton(this,
|
||||
{ Lang["MENU_IO_LOAD_GAME"] }, buttonX1third, buttonRowY, buttonWidth * 3 + buttonGap * 2, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
{ Lang["MENU_IO_LOAD_GAME"] }, buttonX1third, buttonRowY2, buttonWidth * 3 + buttonGap * 2, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
it.clickOnceListener = { _,_ ->
|
||||
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
|
||||
|
||||
if (full.loadables.moreRecentAutosaveAvailable()) {
|
||||
TODO()
|
||||
full.bringAutosaveSelectorUp()
|
||||
full.changePanelTo(2)
|
||||
}
|
||||
else if (full.loadables.saveAvaliable()) {
|
||||
if (full.loadables.newerSaveIsDamaged) {
|
||||
UILoadGovernor.previousSaveWasLoaded = true
|
||||
}
|
||||
|
||||
full.takeAutosaveSelectorDown()
|
||||
full.loadManageSelectedGame = full.loadables.getLoadableSave()!!
|
||||
|
||||
mode = MODE_LOAD
|
||||
@@ -56,23 +58,23 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
||||
}
|
||||
}
|
||||
private val mainNoGoButton = UIItemTextButton(this,
|
||||
{ Lang["ERROR_SAVE_CORRUPTED"].replace(".","") }, buttonX1third, buttonRowY, buttonWidth * 3 + buttonGap * 2, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
{ Lang["ERROR_SAVE_CORRUPTED"].replace(".","") }, buttonX1third, buttonRowY2, buttonWidth * 3 + buttonGap * 2, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
it.isEnabled = false
|
||||
}
|
||||
private val mainReturnButton = UIItemTextButton(this,
|
||||
{ Lang["MENU_LABEL_BACK"] }, buttonX1third, buttonRowY2, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
it.clickOnceListener = { _,_ ->
|
||||
full.changePanelTo(0)
|
||||
}
|
||||
}
|
||||
private val mainRenameButton = UIItemTextButton(this,
|
||||
{ Lang["MENU_LABEL_RENAME"] }, buttonXcentre, buttonRowY2, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
{ Lang["MENU_LABEL_RENAME"] }, buttonX1third, buttonRowY, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
it.clickOnceListener = { _,_ ->
|
||||
mode = MODE_RENAME
|
||||
}
|
||||
}
|
||||
private val mainBackButton = UIItemTextButton(this,
|
||||
{ Lang["MENU_LABEL_BACK"] }, buttonXcentre, buttonRowY, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true).also {
|
||||
it.clickOnceListener = { _,_ ->
|
||||
full.changePanelTo(0)
|
||||
}
|
||||
}
|
||||
private val mainDeleteButton = UIItemTextButton(this,
|
||||
{ Lang["CONTEXT_CHARACTER_DELETE"] }, buttonX3third, buttonRowY2, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD).also {
|
||||
{ Lang["CONTEXT_CHARACTER_DELETE"] }, buttonX3third, buttonRowY, buttonWidth, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true, inactiveCol = Toolkit.Theme.COL_RED, activeCol = Toolkit.Theme.COL_REDD).also {
|
||||
it.clickOnceListener = { _,_ ->
|
||||
mode = MODE_DELETE
|
||||
}
|
||||
@@ -101,8 +103,8 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
||||
|
||||
private var mode = 0
|
||||
|
||||
private var mainButtons0 = listOf(mainGoButton, mainReturnButton, mainRenameButton, mainDeleteButton)
|
||||
private var mainButtons1 = listOf(mainNoGoButton, mainReturnButton, mainRenameButton, mainDeleteButton)
|
||||
private var mainButtons0 = listOf(mainGoButton, mainBackButton, mainRenameButton, mainDeleteButton)
|
||||
private var mainButtons1 = listOf(mainNoGoButton, mainBackButton, mainRenameButton, mainDeleteButton)
|
||||
private var delButtons = listOf(confirmCancelButton, confirmDeleteButton)
|
||||
|
||||
private val mainButtons: List<UIItemTextButton>
|
||||
@@ -154,20 +156,8 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
||||
}
|
||||
MODE_LOAD -> {
|
||||
loadFiredFrameCounter += 1
|
||||
// to hide the "flipped skybox" artefact
|
||||
batch.end()
|
||||
|
||||
gdxClearAndEnableBlend(.094f, .094f, .094f, 0f)
|
||||
|
||||
batch.begin()
|
||||
|
||||
batch.color = Color.WHITE
|
||||
val txt = Lang["MENU_IO_LOADING"]
|
||||
App.fontGame.draw(batch, txt, (App.scr.width - App.fontGame.getWidth(txt)) / 2f, (App.scr.height - App.fontGame.lineHeight) / 2f)
|
||||
|
||||
if (loadFiredFrameCounter == 2) {
|
||||
LoadSavegame(full.loadManageSelectedGame)
|
||||
}
|
||||
StaticLoadScreenSubstitute(batch)
|
||||
if (loadFiredFrameCounter == 2) LoadSavegame(full.loadManageSelectedGame)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,10 +181,10 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
||||
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
when (mode) {
|
||||
MODE_INIT -> {
|
||||
mainButtons.forEach { it.touchDown(screenX, screenY, pointer, button) }
|
||||
mainButtons.forEach { it.touchUp(screenX, screenY, pointer, button) }
|
||||
}
|
||||
MODE_DELETE -> {
|
||||
delButtons.forEach { it.touchDown(screenX, screenY, pointer, button) }
|
||||
delButtons.forEach { it.touchUp(screenX, screenY, pointer, button) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,25 +73,16 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
||||
|
||||
internal var playerButtonSelected: UIItemPlayerCells? = null
|
||||
|
||||
private val goButtonWidth = 180
|
||||
private val drawX = (Toolkit.drawWidth - 480) / 2
|
||||
private val drawY = (App.scr.height - 480) / 2
|
||||
private val buttonRowY = drawY + 480 - 24
|
||||
|
||||
internal lateinit var loadables: SavegameCollectionPair // will be used and modified by subUIs
|
||||
|
||||
internal lateinit var loadManageSelectedGame: DiskPair
|
||||
|
||||
/*private val altSelDrawW = 640
|
||||
private val altSelHdrawW = altSelDrawW / 2
|
||||
private val altSelDrawH = 480
|
||||
private val imageButtonW = 300
|
||||
private val imageButtonH = 240
|
||||
private val altSelDrawY = ((App.scr.height - altSelDrawH)/2)
|
||||
private val altSelQdrawW = altSelDrawW / 4
|
||||
private val altSelQQQdrawW = altSelDrawW * 3 / 4*/
|
||||
|
||||
// internal var hasNewerAutosave = false
|
||||
internal val buttonHeight = 24
|
||||
internal val buttonGap = 10
|
||||
internal val buttonWidth = 180
|
||||
internal val drawX = (Toolkit.drawWidth - 480) / 2
|
||||
internal val drawY = (App.scr.height - 480) / 2
|
||||
|
||||
private val transitionalListing = UILoadList(this)
|
||||
private val transitionalAutosave = UILoadAutosave(this)
|
||||
|
||||
Reference in New Issue
Block a user