game save ui completely locked while saving in progress

This commit is contained in:
minjaesong
2021-09-15 11:34:13 +09:00
parent 22190be6d8
commit ae29f7ebea
7 changed files with 33 additions and 14 deletions

View File

@@ -166,7 +166,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
cameraPlayer = CameraPlayer(demoWorld, cameraAI) cameraPlayer = CameraPlayer(demoWorld, cameraAI)
demoWorld.worldTime.timeDelta = 0// 100 demoWorld.worldTime.timeDelta = 0//60
IngameRenderer.setRenderedWorld(demoWorld) IngameRenderer.setRenderedWorld(demoWorld)

View File

@@ -1,6 +1,8 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.App.csi0
import net.torvald.terrarum.App.csiG
import net.torvald.terrarum.ui.ConsoleWindow import net.torvald.terrarum.ui.ConsoleWindow
/** /**
@@ -16,15 +18,15 @@ internal object Echo : ConsoleCommand {
val sb = StringBuilder() val sb = StringBuilder()
for (ch in single_line) { for (ch in single_line) {
if (ch == '\n') { if (ch == '\n') {
(Terrarum.ingame!!.consoleHandler as ConsoleWindow).sendMessage(sb.toString()) Terrarum.ingame!!.consoleHandler.sendMessage(sb.toString())
println(sb.toString()) println("[Echo] $csiG$sb$csi0")
sb.delete(0, sb.length - 1) sb.delete(0, sb.length - 1)
} }
else else
sb.append(ch) sb.append(ch)
} }
(Terrarum.ingame!!.consoleHandler as ConsoleWindow).sendMessage(sb.toString()) Terrarum.ingame!!.consoleHandler.sendMessage(sb.toString())
println(sb.toString()) println("[Echo] $csiG$sb$csi0")
} }
operator fun invoke(args: Array<String>) = execute(args) operator fun invoke(args: Array<String>) = execute(args)

View File

@@ -744,7 +744,7 @@ object IngameRenderer : Disposable {
fboRGBexport.dispose() fboRGBexport.dispose()
} }
catch (e: UninitializedPropertyAccessException) {} catch (e: UninitializedPropertyAccessException) {}
catch (e: Throwable) { e.printStackTrace() } catch (e: Throwable) { e.printStackTrace(System.out) }
} }
private fun worldCamToRenderPos(): Pair<Float, Float> { private fun worldCamToRenderPos(): Pair<Float, Float> {

View File

@@ -84,11 +84,14 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
0 -> { 0 -> {
screen = 3; gameMenuButtons.deselect() screen = 3; gameMenuButtons.deselect()
full.handler.lockToggle() full.handler.lockToggle()
full.lockTransition()
// save the game // save the game
WriteSavegame(Terrarum.ingame!!.savegameArchive, File(App.defaultSaveDir, "${App.getTIME_T()}"), Terrarum.ingame!! as TerrarumIngame) { WriteSavegame(Terrarum.ingame!!.savegameArchive, File(App.defaultSaveDir, "${App.getTIME_T()}"), Terrarum.ingame!! as TerrarumIngame) {
// callback: // callback:
System.gc()
screen = 0 screen = 0
full.handler.unlockToggle() full.handler.unlockToggle()
full.unlockTransition()
} }
} }
4 -> { 4 -> {

View File

@@ -138,6 +138,15 @@ class UIInventoryFull(
"$gamepadLabelStart ${Lang["GAME_ACTION_CLOSE"]}$SP" + "$gamepadLabelStart ${Lang["GAME_ACTION_CLOSE"]}$SP" +
"$gamepadLabelLT ${Lang["GAME_INVENTORY"]}" "$gamepadLabelLT ${Lang["GAME_INVENTORY"]}"
private var panelTransitionLocked = false
fun lockTransition() {
panelTransitionLocked = true
}
fun unlockTransition() {
panelTransitionLocked = false
}
val catBar = UIItemInventoryCatBar( val catBar = UIItemInventoryCatBar(
this, this,
(App.scr.width - catBarWidth) / 2, (App.scr.width - catBarWidth) / 2,
@@ -145,7 +154,7 @@ class UIInventoryFull(
internalWidth, internalWidth,
catBarWidth, catBarWidth,
true, true,
{ i -> requestTransition(i) } { i -> if (!panelTransitionLocked) requestTransition(i) }
) )
@@ -167,9 +176,11 @@ class UIInventoryFull(
addUIitem(catBar) addUIitem(catBar)
addUIitem(transitionPanel) addUIitem(transitionPanel)
catBar.selectionChangeListener = { old, new -> catBar.selectionChangeListener = { old, new ->
rebuildList() if (!panelTransitionLocked) {
transitionalItemCells.resetStatusAsCatChanges(old, new) rebuildList()
transitionalItemCells.resetStatusAsCatChanges(old, new)
}
} }
@@ -190,7 +201,7 @@ class UIInventoryFull(
rebuildList() rebuildList()
} }
catBar.update(delta) if (!panelTransitionLocked) catBar.update(delta)
transitionPanel.update(delta) transitionPanel.update(delta)
} }

View File

@@ -131,10 +131,11 @@ class GameSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: Ter
} }
} }
Echo("Writing actors...")
// Write Actors // // Write Actors //
actorsList.forEach { actorsList.forEachIndexed { count, it ->
Echo("Writing actors... ${count+1}/${actorsList.size}")
val actorContent = EntryFile(WriteActor.encodeToByteArray64(it)) val actorContent = EntryFile(WriteActor.encodeToByteArray64(it))
val actor = DiskEntry(it.referenceID.toLong(), 0, creation_t, time_t, actorContent) val actor = DiskEntry(it.referenceID.toLong(), 0, creation_t, time_t, actorContent)
addFile(disk, actor) addFile(disk, actor)
@@ -143,6 +144,8 @@ class GameSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: Ter
} }
Echo("Writing file to disk...")
disk.entries[0]!!.modificationDate = time_t disk.entries[0]!!.modificationDate = time_t
// entry zero MUST NOT be used to get lastPlayDate, but we'll update it anyway // entry zero MUST NOT be used to get lastPlayDate, but we'll update it anyway
// use entry -1 for that purpose! // use entry -1 for that purpose!

View File

@@ -47,7 +47,7 @@ class UIItemTextArea(
} }
override fun scrolled(amountX: Float, amountY: Float): Boolean { override fun scrolled(amountX: Float, amountY: Float): Boolean {
scrollPos += Math.round(amountX * 3) scrollPos += Math.round(amountY * 5)
if (scrollPos > entireText.size - lineCount) scrollPos = entireText.size - lineCount if (scrollPos > entireText.size - lineCount) scrollPos = entireText.size - lineCount
if (scrollPos < 0) scrollPos = 0 if (scrollPos < 0) scrollPos = 0