removing auto/manual save selection: is practically useless

This commit is contained in:
minjaesong
2023-07-12 10:40:21 +09:00
parent 4eb7a8a77e
commit c77f1ffd23
6 changed files with 91 additions and 27 deletions

View File

@@ -161,18 +161,71 @@ fun DiskSkimmer.getThumbnailPixmap(width: Int, height: Int, shrinkage: Double) =
class SavegameCollectionPair(private val player: SavegameCollection?, private val world: SavegameCollection?) {
private var manualPlayer: DiskSkimmer? = null
private var manualWorld: DiskSkimmer? = null
private var autoPlayer: DiskSkimmer? = null
private var autoWorld: DiskSkimmer? = null
// private var manualPlayer: DiskSkimmer? = null
// private var manualWorld: DiskSkimmer? = null
// private var autoPlayer: 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
private set
var newerSaveIsDamaged = false // only when most recent save is corrupted
private set
val newerSaveIsDamaged: Boolean // only when most recent save is corrupted
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)")
if (player != null && world != null) {
@@ -219,8 +272,11 @@ class SavegameCollectionPair(private val player: SavegameCollection?, private va
pc += 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
}
}
}
}
@@ -247,7 +303,7 @@ class SavegameCollectionPair(private val player: SavegameCollection?, private va
printdbg(this, "autoWorld = ${autoWorld?.diskFile?.path}")
printdbg(this, "status = $status")
}
}
} */
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 saveAvaliable() = (status > 0)
fun getManualSave(): DiskPair? {
/*fun getManualSave(): DiskPair? {
if (status == 0) return null
return DiskPair(manualPlayer!!, manualWorld!!)
}
@@ -278,6 +334,11 @@ class SavegameCollectionPair(private val player: SavegameCollection?, private va
DiskPair(manualPlayer!!, manualWorld!!)
else
DiskPair(autoPlayer!!, autoWorld!!)
}*/
fun getLoadableSave(): DiskPair? {
return if (status == 0) null
else DiskPair(playerDisk!!, worldDisk!!)
}
}

View File

@@ -21,7 +21,7 @@ import java.util.zip.GZIPInputStream
/**
* 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 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)
}
}
}
}*/

View File

@@ -513,8 +513,9 @@ class UIItemPlayerCells(
lateinit var worldUUID: UUID; private set
private val savegameStatus: Int
internal val pixmapManual: Pixmap?
internal val pixmapAuto: Pixmap?
// internal val pixmapManual: Pixmap?
// internal val pixmapAuto: Pixmap?
internal val savegameThumbnailPixmap: Pixmap?
init {
App.savegamePlayers[playerUUID]!!.loadable().getFile(SAVEGAMEINFO)?.bytes?.let {
@@ -537,8 +538,9 @@ class UIItemPlayerCells(
val savegamePair = SavegameCollectionPair(App.savegamePlayers[playerUUID], App.savegameWorlds[worldUUID])
savegameStatus = savegamePair.status
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)
// 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)
savegameThumbnailPixmap = savegamePair.getLoadableSave()?.player?.getThumbnailPixmap(SAVE_THUMBNAIL_MAIN_WIDTH, SAVE_THUMBNAIL_MAIN_HEIGHT, 2.0)
}
private fun parseDuration(seconds: Long): String {
@@ -710,8 +712,9 @@ class UIItemPlayerCells(
override fun dispose() {
sprite?.texture?.dispose()
pixmapManual?.dispose()
pixmapAuto?.dispose()
// pixmapManual?.dispose()
// pixmapAuto?.dispose()
savegameThumbnailPixmap?.dispose()
}

View File

@@ -70,7 +70,7 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
full.loadables = SavegameCollectionPair(App.savegamePlayers[UILoadGovernor.playerUUID], App.savegameWorlds[UILoadGovernor.worldUUID])
full.queueUpManageScr()
full.takeAutosaveSelectorDown()
// full.takeAutosaveSelectorDown()
full.changePanelTo(1)
}

View File

@@ -45,16 +45,16 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
it.clickOnceListener = { _,_ ->
App.printdbg(this, "Load playerUUID: ${UILoadGovernor.playerUUID}, worldUUID: ${UILoadGovernor.worldUUID}")
if (full.loadables.moreRecentAutosaveAvailable()) {
/*if (full.loadables.moreRecentAutosaveAvailable()) {
full.bringAutosaveSelectorUp()
full.changePanelTo(2)
}
else if (full.loadables.saveAvaliable()) {
else */if (full.loadables.saveAvaliable()) {
if (full.loadables.newerSaveIsDamaged) {
UILoadGovernor.previousSaveWasLoaded = true
}
full.takeAutosaveSelectorDown()
// full.takeAutosaveSelectorDown()
full.loadManageSelectedGame = full.loadables.getLoadableSave()!!
mode = MODE_LOAD
@@ -131,7 +131,7 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
full.playerButtonSelected?.forceUnhighlight = true
full.playerButtonSelected?.let { button ->
screencap?.texture?.tryDispose()
(button.pixmapAuto ?: button.pixmapManual)?.let {
button.savegameThumbnailPixmap?.let {
screencap = TextureRegion(Texture(it))
}
}

View File

@@ -73,7 +73,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
internal val drawY = (App.scr.height - 480) / 2
private val transitionalListing = UILoadList(this)
private val transitionalAutosave = UILoadAutosave(this)
// private val transitionalAutosave = UILoadAutosave(this)
private val transitionalManage = UILoadManage(this)
private val transitionalNewCharacter = UINewCharacter(remoCon)
private val transitionPanel = UIItemHorizontalFadeSlide(
@@ -85,14 +85,14 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
0f,
listOf(transitionalListing),
listOf(transitionalManage, transitionalNewCharacter),
listOf(NullUI, transitionalAutosave)
listOf(NullUI/*, transitionalAutosave*/)
)
internal fun queueUpManageScr() { transitionPanel.setCentreUIto(0) }
internal fun queueUpNewCharScr() { transitionPanel.setCentreUIto(1) }
internal fun bringAutosaveSelectorUp() { transitionPanel.setRightUIto(1) }
internal fun takeAutosaveSelectorDown() { transitionPanel.setRightUIto(0) }
// internal fun bringAutosaveSelectorUp() { transitionPanel.setRightUIto(1) }
// internal fun takeAutosaveSelectorDown() { transitionPanel.setRightUIto(0) }
internal fun changePanelTo(index: Int) {
transitionPanel.requestTransition(index)
@@ -109,7 +109,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
}
override fun show() {
takeAutosaveSelectorDown()
// takeAutosaveSelectorDown()
transitionPanel.show()
}