x mark on save failed

This commit is contained in:
minjaesong
2021-10-10 21:31:14 +09:00
parent 3ca95e138d
commit 0925ec2580
5 changed files with 32 additions and 32 deletions

View File

@@ -7,14 +7,25 @@ The main game directory is composed of following directories:
```
.Terrarum
+ Players
- <Player Name Here>, TVDA { (-1) player JSON, (-2) spritedef, (-3) optional spritedef-glow, (-1025) sprite-bodypart-name-to-entry-number-map.properties, (1+) optional bodyparts tga.gz }
if file -1025 is not there, read bodyparts from assets directory
optionally encrypt the files other than -1
- "${PlayerName}-${UUID}", TVDA {
[-1] player JSON,
[-2] spritedef,
[-3] optional spritedef-glow,
[-1025] sprite-bodypart-name-to-entry-number-map.properties,
[1+] optional bodyparts tga.gz
}
*if file -1025 is not there, read bodyparts from assets directory
*optionally encrypt the files other than -1
+ Shared
- <e.g. Disk GUID>, TEVD { * }
- <this directory can have anything>
+ Worlds
- <World Name Here>, TVDA { (-1) WriteWorld, (actorID) actors (mainly fixtures) JSON, (0x1_0000_0000L or (layerNumber shl 24) or chunkNumber) chunk data, (-2) screenshot.tga.gz taken by the last player }
- "${WorldName}-${UUID}", TVDA {
[-1] world JSON with Player Data,
[actorID] actors (mainly fixtures) JSON,
[0x1_0000_0000L or (layerNumber shl 24) or chunkNumber] chunk data,
[-2] screenshot.tga.gz taken by the last player
}
```
(TEVD stands for Terrarum Virtual Disk spec version 3, TVDA stands for spec version 254; both have MAGIC header of `TEVd`)

View File

@@ -332,20 +332,14 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// 1. lighten the IO burden
// 2. cannot sync up the "counter" to determine whether both are finished
uiAutosaveNotifier.setAsOpen()
try {
WriteSavegame.immediate(WriteSavegame.SaveMode.PLAYER, playerDisk, getPlayerSaveFiledesc(playerSavefileName), this, false, true) {
makeSavegameBackupCopy(getPlayerSaveFiledesc(playerSavefileName))
WriteSavegame.immediate(WriteSavegame.SaveMode.PLAYER, playerDisk, getPlayerSaveFiledesc(playerSavefileName), this, false, true) {
makeSavegameBackupCopy(getPlayerSaveFiledesc(playerSavefileName))
WriteSavegame.immediate(WriteSavegame.SaveMode.WORLD, worldDisk, getWorldSaveFiledesc(worldSavefileName), this, false, true) {
makeSavegameBackupCopy(getWorldSaveFiledesc(worldSavefileName)) // don't put it on the postInit() or render(); must be called using callback
uiAutosaveNotifier.setAsClose()
}
WriteSavegame.immediate(WriteSavegame.SaveMode.WORLD, worldDisk, getWorldSaveFiledesc(worldSavefileName), this, false, true) {
makeSavegameBackupCopy(getWorldSaveFiledesc(worldSavefileName)) // don't put it on the postInit() or render(); must be called using callback
uiAutosaveNotifier.setAsClose()
}
}
catch (e: Throwable) {
e.printStackTrace()
uiAutosaveNotifier.setAsError()
}
}
/**

View File

@@ -183,13 +183,7 @@ class WorldSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: Te
WriteSavegame.savingStatus = 255
try {
callback()
}
catch (e: Throwable) {
e.printStackTrace()
ingame.uiAutosaveNotifier.setAsError()
}
callback()
}
}
@@ -208,12 +202,6 @@ class PlayerSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: T
WritePlayer(ingame.actorGamer, disk)
VDUtil.dumpToRealMachine(disk, outFile)
try {
callback()
}
catch (e: Throwable) {
e.printStackTrace()
ingame.uiAutosaveNotifier.setAsError()
}
callback()
}
}

View File

@@ -56,8 +56,15 @@ class UIAutosaveNotifier : UICanvas() {
val offY = App.scr.tvSafeGraphicsHeight + 9f // +9 to align to quickslot and watch UI
val text = if (errored) Lang["ERROR_GENERIC_TEXT"].replace(".","") else Lang["MENU_IO_SAVING"]
if (!errored) {
batch.color = normalCol
batch.draw(spin, offX, offY)
}
else {
batch.color = errorCol
batch.draw(spinner.get(0,4), offX, offY)
}
batch.color = if (errored) errorCol else normalCol
if (!errored) batch.draw(spin, offX, offY)// else RED_X_SYMBOL
App.fontGame.draw(batch, text, offX + 30f, offY)
}