mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
removing auto/manual save selection: is practically useless
This commit is contained in:
@@ -161,18 +161,71 @@ fun DiskSkimmer.getThumbnailPixmap(width: Int, height: Int, shrinkage: Double) =
|
|||||||
|
|
||||||
class SavegameCollectionPair(private val player: SavegameCollection?, private val world: SavegameCollection?) {
|
class SavegameCollectionPair(private val player: SavegameCollection?, private val world: SavegameCollection?) {
|
||||||
|
|
||||||
private var manualPlayer: DiskSkimmer? = null
|
// private var manualPlayer: DiskSkimmer? = null
|
||||||
private var manualWorld: DiskSkimmer? = null
|
// private var manualWorld: DiskSkimmer? = null
|
||||||
private var autoPlayer: DiskSkimmer? = null
|
// private var autoPlayer: DiskSkimmer? = null
|
||||||
private var autoWorld: DiskSkimmer? = null
|
// private var autoWorld: DiskSkimmer? = null
|
||||||
|
|
||||||
|
/* removing auto/manual discrimination: on Local Asynchronous Multiplayer, if newer autosave is available, there is
|
||||||
|
* no choice but loading one to preserve the data; then why bother having two? */
|
||||||
|
private var playerDisk: DiskSkimmer? = null; private set
|
||||||
|
private var worldDisk: DiskSkimmer? = null; private set
|
||||||
|
|
||||||
var status = 0 // 0: none available, 1: loadable manual save is newer than loadable auto; 2: loadable autosave is newer than loadable manual
|
var status = 0 // 0: none available, 1: loadable manual save is newer than loadable auto; 2: loadable autosave is newer than loadable manual
|
||||||
private set
|
private set
|
||||||
|
|
||||||
var newerSaveIsDamaged = false // only when most recent save is corrupted
|
val newerSaveIsDamaged: Boolean // only when most recent save is corrupted
|
||||||
private set
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
if (player != null && world != null) {
|
||||||
|
printdbg(this, "player files: " + player.files.joinToString { it.diskFile.name })
|
||||||
|
printdbg(this, "world files:" + world.files.joinToString { it.diskFile.name })
|
||||||
|
|
||||||
|
var pc = 0
|
||||||
|
var wc = 0
|
||||||
|
|
||||||
|
playerDisk = player.files[pc]
|
||||||
|
worldDisk = world.files[wc]
|
||||||
|
|
||||||
|
while (pc < player.files.size && wc < world.files.size) {
|
||||||
|
// 0b pw
|
||||||
|
val dmgflag = playerDiskNotDamaged(playerDisk!!).toInt(1) or worldDiskNotDamaged(worldDisk!!).toInt()
|
||||||
|
|
||||||
|
when (dmgflag) {
|
||||||
|
3 -> break
|
||||||
|
2 -> {
|
||||||
|
worldDisk = world.files[++wc]
|
||||||
|
}
|
||||||
|
1 -> {
|
||||||
|
playerDisk = player.files[++pc]
|
||||||
|
}
|
||||||
|
0 -> {
|
||||||
|
worldDisk = world.files[++wc]
|
||||||
|
playerDisk = player.files[++pc]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if it's time to exit the loop and all tested saves were damaged:
|
||||||
|
if (pc == player.files.size) playerDisk = null
|
||||||
|
if (wc == world.files.size) worldDisk = null
|
||||||
|
}
|
||||||
|
|
||||||
|
newerSaveIsDamaged = (pc + wc > 0)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newerSaveIsDamaged = false
|
||||||
|
}
|
||||||
|
|
||||||
|
status = if (playerDisk != null && worldDisk != null && (playerDisk!!.isAutosaved() || worldDisk!!.isAutosaved()))
|
||||||
|
2
|
||||||
|
else (player != null && world != null).toInt()
|
||||||
|
|
||||||
|
printdbg(this, "playerDisk = ${playerDisk?.diskFile?.path}")
|
||||||
|
printdbg(this, "worldDisk = ${worldDisk?.diskFile?.path}")
|
||||||
|
printdbg(this, "status = $status")
|
||||||
|
}
|
||||||
|
|
||||||
|
/*init {
|
||||||
printdbg(this, "init ($player, $world)")
|
printdbg(this, "init ($player, $world)")
|
||||||
|
|
||||||
if (player != null && world != null) {
|
if (player != null && world != null) {
|
||||||
@@ -219,8 +272,11 @@ class SavegameCollectionPair(private val player: SavegameCollection?, private va
|
|||||||
pc += 1
|
pc += 1
|
||||||
wc += 1
|
wc += 1
|
||||||
}
|
}
|
||||||
else
|
// world is modified after another player playing on the same world but only left an autosave
|
||||||
|
// there is no choice but loading the autosave in such scenario to preserve the data
|
||||||
|
else {
|
||||||
wc += 1
|
wc += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,7 +303,7 @@ class SavegameCollectionPair(private val player: SavegameCollection?, private va
|
|||||||
printdbg(this, "autoWorld = ${autoWorld?.diskFile?.path}")
|
printdbg(this, "autoWorld = ${autoWorld?.diskFile?.path}")
|
||||||
printdbg(this, "status = $status")
|
printdbg(this, "status = $status")
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
|
||||||
private fun DiskSkimmer.isAutosaved() = this.getSaveMode().and(0b0000_0010) != 0
|
private fun DiskSkimmer.isAutosaved() = this.getSaveMode().and(0b0000_0010) != 0
|
||||||
|
|
||||||
@@ -262,7 +318,7 @@ class SavegameCollectionPair(private val player: SavegameCollection?, private va
|
|||||||
fun moreRecentAutosaveAvailable() = (status == 2)
|
fun moreRecentAutosaveAvailable() = (status == 2)
|
||||||
fun saveAvaliable() = (status > 0)
|
fun saveAvaliable() = (status > 0)
|
||||||
|
|
||||||
fun getManualSave(): DiskPair? {
|
/*fun getManualSave(): DiskPair? {
|
||||||
if (status == 0) return null
|
if (status == 0) return null
|
||||||
return DiskPair(manualPlayer!!, manualWorld!!)
|
return DiskPair(manualPlayer!!, manualWorld!!)
|
||||||
}
|
}
|
||||||
@@ -278,6 +334,11 @@ class SavegameCollectionPair(private val player: SavegameCollection?, private va
|
|||||||
DiskPair(manualPlayer!!, manualWorld!!)
|
DiskPair(manualPlayer!!, manualWorld!!)
|
||||||
else
|
else
|
||||||
DiskPair(autoPlayer!!, autoWorld!!)
|
DiskPair(autoPlayer!!, autoWorld!!)
|
||||||
|
}*/
|
||||||
|
|
||||||
|
fun getLoadableSave(): DiskPair? {
|
||||||
|
return if (status == 0) null
|
||||||
|
else DiskPair(playerDisk!!, worldDisk!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.util.zip.GZIPInputStream
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2023-07-05.
|
* Created by minjaesong on 2023-07-05.
|
||||||
*/
|
*/
|
||||||
class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
/*class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
||||||
|
|
||||||
override var width: Int = Toolkit.drawWidth
|
override var width: Int = Toolkit.drawWidth
|
||||||
override var height: Int = App.scr.height
|
override var height: Int = App.scr.height
|
||||||
@@ -171,4 +171,4 @@ class UILoadAutosave(val full: UILoadSavegame) : UICanvas() {
|
|||||||
App.fontSmallNumbers.draw(batch, lastPlayedStamp, item.posX + 5f, item.posY + 3f)
|
App.fontSmallNumbers.draw(batch, lastPlayedStamp, item.posX + 5f, item.posY + 3f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
@@ -513,8 +513,9 @@ class UIItemPlayerCells(
|
|||||||
lateinit var worldUUID: UUID; private set
|
lateinit var worldUUID: UUID; private set
|
||||||
|
|
||||||
private val savegameStatus: Int
|
private val savegameStatus: Int
|
||||||
internal val pixmapManual: Pixmap?
|
// internal val pixmapManual: Pixmap?
|
||||||
internal val pixmapAuto: Pixmap?
|
// internal val pixmapAuto: Pixmap?
|
||||||
|
internal val savegameThumbnailPixmap: Pixmap?
|
||||||
|
|
||||||
init {
|
init {
|
||||||
App.savegamePlayers[playerUUID]!!.loadable().getFile(SAVEGAMEINFO)?.bytes?.let {
|
App.savegamePlayers[playerUUID]!!.loadable().getFile(SAVEGAMEINFO)?.bytes?.let {
|
||||||
@@ -537,8 +538,9 @@ class UIItemPlayerCells(
|
|||||||
|
|
||||||
val savegamePair = SavegameCollectionPair(App.savegamePlayers[playerUUID], App.savegameWorlds[worldUUID])
|
val savegamePair = SavegameCollectionPair(App.savegamePlayers[playerUUID], App.savegameWorlds[worldUUID])
|
||||||
savegameStatus = savegamePair.status
|
savegameStatus = savegamePair.status
|
||||||
pixmapManual = savegamePair.getManualSave()?.player?.getThumbnailPixmap(SAVE_THUMBNAIL_MAIN_WIDTH, SAVE_THUMBNAIL_MAIN_HEIGHT, 2.0)
|
// pixmapManual = savegamePair.getManualSave()?.player?.getThumbnailPixmap(SAVE_THUMBNAIL_MAIN_WIDTH, SAVE_THUMBNAIL_MAIN_HEIGHT, 2.0)
|
||||||
pixmapAuto = savegamePair.getAutoSave()?.player?.getThumbnailPixmap(SAVE_THUMBNAIL_MAIN_WIDTH, SAVE_THUMBNAIL_MAIN_HEIGHT, 2.0)
|
// pixmapAuto = savegamePair.getAutoSave()?.player?.getThumbnailPixmap(SAVE_THUMBNAIL_MAIN_WIDTH, SAVE_THUMBNAIL_MAIN_HEIGHT, 2.0)
|
||||||
|
savegameThumbnailPixmap = savegamePair.getLoadableSave()?.player?.getThumbnailPixmap(SAVE_THUMBNAIL_MAIN_WIDTH, SAVE_THUMBNAIL_MAIN_HEIGHT, 2.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseDuration(seconds: Long): String {
|
private fun parseDuration(seconds: Long): String {
|
||||||
@@ -710,8 +712,9 @@ class UIItemPlayerCells(
|
|||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
sprite?.texture?.dispose()
|
sprite?.texture?.dispose()
|
||||||
pixmapManual?.dispose()
|
// pixmapManual?.dispose()
|
||||||
pixmapAuto?.dispose()
|
// pixmapAuto?.dispose()
|
||||||
|
savegameThumbnailPixmap?.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
|
|||||||
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
|
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
|
||||||
full.loadables = SavegameCollectionPair(App.savegamePlayers[UILoadGovernor.playerUUID], App.savegameWorlds[UILoadGovernor.worldUUID])
|
full.loadables = SavegameCollectionPair(App.savegamePlayers[UILoadGovernor.playerUUID], App.savegameWorlds[UILoadGovernor.worldUUID])
|
||||||
full.queueUpManageScr()
|
full.queueUpManageScr()
|
||||||
full.takeAutosaveSelectorDown()
|
// full.takeAutosaveSelectorDown()
|
||||||
full.changePanelTo(1)
|
full.changePanelTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,16 +45,16 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
|||||||
it.clickOnceListener = { _,_ ->
|
it.clickOnceListener = { _,_ ->
|
||||||
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
|
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
|
||||||
|
|
||||||
if (full.loadables.moreRecentAutosaveAvailable()) {
|
/*if (full.loadables.moreRecentAutosaveAvailable()) {
|
||||||
full.bringAutosaveSelectorUp()
|
full.bringAutosaveSelectorUp()
|
||||||
full.changePanelTo(2)
|
full.changePanelTo(2)
|
||||||
}
|
}
|
||||||
else if (full.loadables.saveAvaliable()) {
|
else */if (full.loadables.saveAvaliable()) {
|
||||||
if (full.loadables.newerSaveIsDamaged) {
|
if (full.loadables.newerSaveIsDamaged) {
|
||||||
UILoadGovernor.previousSaveWasLoaded = true
|
UILoadGovernor.previousSaveWasLoaded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
full.takeAutosaveSelectorDown()
|
// full.takeAutosaveSelectorDown()
|
||||||
full.loadManageSelectedGame = full.loadables.getLoadableSave()!!
|
full.loadManageSelectedGame = full.loadables.getLoadableSave()!!
|
||||||
|
|
||||||
mode = MODE_LOAD
|
mode = MODE_LOAD
|
||||||
@@ -131,7 +131,7 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
|
|||||||
full.playerButtonSelected?.forceUnhighlight = true
|
full.playerButtonSelected?.forceUnhighlight = true
|
||||||
full.playerButtonSelected?.let { button ->
|
full.playerButtonSelected?.let { button ->
|
||||||
screencap?.texture?.tryDispose()
|
screencap?.texture?.tryDispose()
|
||||||
(button.pixmapAuto ?: button.pixmapManual)?.let {
|
button.savegameThumbnailPixmap?.let {
|
||||||
screencap = TextureRegion(Texture(it))
|
screencap = TextureRegion(Texture(it))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
internal val drawY = (App.scr.height - 480) / 2
|
internal val drawY = (App.scr.height - 480) / 2
|
||||||
|
|
||||||
private val transitionalListing = UILoadList(this)
|
private val transitionalListing = UILoadList(this)
|
||||||
private val transitionalAutosave = UILoadAutosave(this)
|
// private val transitionalAutosave = UILoadAutosave(this)
|
||||||
private val transitionalManage = UILoadManage(this)
|
private val transitionalManage = UILoadManage(this)
|
||||||
private val transitionalNewCharacter = UINewCharacter(remoCon)
|
private val transitionalNewCharacter = UINewCharacter(remoCon)
|
||||||
private val transitionPanel = UIItemHorizontalFadeSlide(
|
private val transitionPanel = UIItemHorizontalFadeSlide(
|
||||||
@@ -85,14 +85,14 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
0f,
|
0f,
|
||||||
listOf(transitionalListing),
|
listOf(transitionalListing),
|
||||||
listOf(transitionalManage, transitionalNewCharacter),
|
listOf(transitionalManage, transitionalNewCharacter),
|
||||||
listOf(NullUI, transitionalAutosave)
|
listOf(NullUI/*, transitionalAutosave*/)
|
||||||
)
|
)
|
||||||
|
|
||||||
internal fun queueUpManageScr() { transitionPanel.setCentreUIto(0) }
|
internal fun queueUpManageScr() { transitionPanel.setCentreUIto(0) }
|
||||||
internal fun queueUpNewCharScr() { transitionPanel.setCentreUIto(1) }
|
internal fun queueUpNewCharScr() { transitionPanel.setCentreUIto(1) }
|
||||||
|
|
||||||
internal fun bringAutosaveSelectorUp() { transitionPanel.setRightUIto(1) }
|
// internal fun bringAutosaveSelectorUp() { transitionPanel.setRightUIto(1) }
|
||||||
internal fun takeAutosaveSelectorDown() { transitionPanel.setRightUIto(0) }
|
// internal fun takeAutosaveSelectorDown() { transitionPanel.setRightUIto(0) }
|
||||||
|
|
||||||
internal fun changePanelTo(index: Int) {
|
internal fun changePanelTo(index: Int) {
|
||||||
transitionPanel.requestTransition(index)
|
transitionPanel.requestTransition(index)
|
||||||
@@ -109,7 +109,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun show() {
|
override fun show() {
|
||||||
takeAutosaveSelectorDown()
|
// takeAutosaveSelectorDown()
|
||||||
transitionPanel.show()
|
transitionPanel.show()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user