From a9c7fc0e9051cc7fbd5cac34ec168b1c39f23d50 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 19 Sep 2023 14:06:39 +0900 Subject: [PATCH] Saving while autosaving will show appropriate message --- assets/mods/basegame/locales/en/game.json | 1 + assets/mods/basegame/locales/koKR/game.json | 1 + src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt | 7 +++++-- src/net/torvald/terrarum/modulebasegame/ui/UIItemSaving.kt | 4 +++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/assets/mods/basegame/locales/en/game.json b/assets/mods/basegame/locales/en/game.json index 35c8c3dfc..5cfa63d45 100644 --- a/assets/mods/basegame/locales/en/game.json +++ b/assets/mods/basegame/locales/en/game.json @@ -5,6 +5,7 @@ "CONTEXT_PLACE_COORDINATE": "Coordinate", "CONTEXT_WORLD_COUNT": "Worlds: ", "CONTEXT_WORLD_NEW": "New World", + "MENU_IO_WAITING_AUTOSAVE_TO_FINISH": "Waiting Autosave to finish...", "MENU_LABEL_DELETE_WORLD": "Delete World", "MENU_LABEL_MENU": "Menu", "MENU_LABEL_PREV_SAVES": "Previous Saves", diff --git a/assets/mods/basegame/locales/koKR/game.json b/assets/mods/basegame/locales/koKR/game.json index f2fb52047..7e22270b2 100644 --- a/assets/mods/basegame/locales/koKR/game.json +++ b/assets/mods/basegame/locales/koKR/game.json @@ -5,6 +5,7 @@ "CONTEXT_PLACE_COORDINATE": "좌표", "CONTEXT_WORLD_COUNT": "새계: ", "CONTEXT_WORLD_NEW": "새 세계", + "MENU_IO_WAITING_AUTOSAVE_TO_FINISH": "자동 저장이 끝나기를 기다리는 중...", "MENU_LABEL_DELETE_WORLD": "새계 삭제", "MENU_LABEL_MENU": "메뉴", "MENU_LABEL_PREV_SAVES": "이전 세이브", diff --git a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt index 2379863ca..4211066f1 100644 --- a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt +++ b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt @@ -720,7 +720,6 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { } } - private var updateAkku = 0f internal var autosaveTimer = 0f override fun render(`_`: Float) { @@ -755,7 +754,9 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { /** UPDATE CODE GOES HERE */ val dt = Gdx.graphics.deltaTime - autosaveTimer += dt + if (!uiAutosaveNotifier.isVisible) { + autosaveTimer += dt + } gameUpdateGovernor.update(dt, App.UPDATE_RATE, updateGame, renderGame) @@ -1261,8 +1262,10 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { // return to normal state uiAutosaveNotifier.setAsClose() + autosaveTimer = 0f debugTimers.put("Last Autosave Duration", System.nanoTime() - start) + printdbg(this, "Last Autosave Duration: ${(System.nanoTime() - start) / 1000000000} s") } } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIItemSaving.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIItemSaving.kt index f378167b8..d16f12e14 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIItemSaving.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIItemSaving.kt @@ -5,7 +5,9 @@ import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.graphics.g2d.SpriteBatch import net.torvald.terrarum.App import net.torvald.terrarum.CommonResourcePool +import net.torvald.terrarum.INGAME import net.torvald.terrarum.langpack.Lang +import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.serialise.WriteSavegame import net.torvald.terrarum.ui.Toolkit import net.torvald.terrarum.ui.UICanvas @@ -33,7 +35,7 @@ class UIItemSaving(parentUI: UICanvas, initialX: Int, initialY: Int) : UIItem(pa override fun render(batch: SpriteBatch, camera: OrthographicCamera) { // these things will not scroll along with the parent GUI! - val t = Lang["MENU_IO_SAVING"] + val t = if ((INGAME as TerrarumIngame).uiAutosaveNotifier.isVisible) Lang["MENU_IO_WAITING_AUTOSAVE_TO_FINISH"] else Lang["MENU_IO_SAVING"] val tlen = App.fontGame.getWidth(t) App.fontGame.draw(batch, t, (posX + (width - tlen) / 2).toFloat(), ((App.scr.height - circleSheet.tileH) / 2) - 40f)