From 0925ec25805b4814e8d98b8beb69ba7dbeddde31 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 10 Oct 2021 21:31:14 +0900 Subject: [PATCH] x mark on save failed --- SAVE_FORMAT.md | 19 +++++++++++++++---- .../graphics/gui/inline_loading_spinner.tga | 4 ++-- .../terrarum/modulebasegame/TerrarumIngame.kt | 16 +++++----------- .../terrarum/serialise/GameSavingThread.kt | 16 ++-------------- .../torvald/terrarum/ui/UIAutosaveNotifier.kt | 9 ++++++++- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/SAVE_FORMAT.md b/SAVE_FORMAT.md index 3019a5c03..e5ae9314b 100644 --- a/SAVE_FORMAT.md +++ b/SAVE_FORMAT.md @@ -7,14 +7,25 @@ The main game directory is composed of following directories: ``` .Terrarum + Players - - , 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 - , TEVD { * } - + Worlds - - , 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`) diff --git a/assets/graphics/gui/inline_loading_spinner.tga b/assets/graphics/gui/inline_loading_spinner.tga index 80ca0c319..aa3a11564 100644 --- a/assets/graphics/gui/inline_loading_spinner.tga +++ b/assets/graphics/gui/inline_loading_spinner.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e860a0d99b26e6f501bc69bb1641c1c22a6709690e0eb4548f16a270dacbe8bb -size 51218 +oid sha256:4134fd7c261ce0ba1bfd4628447aa5bac71542b3890f9c44df0064a4b8db1240 +size 102418 diff --git a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt index 06da057c8..611df1510 100644 --- a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt +++ b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt @@ -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() - } } /** diff --git a/src/net/torvald/terrarum/serialise/GameSavingThread.kt b/src/net/torvald/terrarum/serialise/GameSavingThread.kt index f96f0bc88..4b9afec89 100644 --- a/src/net/torvald/terrarum/serialise/GameSavingThread.kt +++ b/src/net/torvald/terrarum/serialise/GameSavingThread.kt @@ -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() } } diff --git a/src/net/torvald/terrarum/ui/UIAutosaveNotifier.kt b/src/net/torvald/terrarum/ui/UIAutosaveNotifier.kt index 6626f2a06..bc6926293 100644 --- a/src/net/torvald/terrarum/ui/UIAutosaveNotifier.kt +++ b/src/net/torvald/terrarum/ui/UIAutosaveNotifier.kt @@ -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) }