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)
demoWorld.worldTime.timeDelta = 0// 100
demoWorld.worldTime.timeDelta = 0//60
IngameRenderer.setRenderedWorld(demoWorld)

View File

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

View File

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

View File

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

View File

@@ -138,6 +138,15 @@ class UIInventoryFull(
"$gamepadLabelStart ${Lang["GAME_ACTION_CLOSE"]}$SP" +
"$gamepadLabelLT ${Lang["GAME_INVENTORY"]}"
private var panelTransitionLocked = false
fun lockTransition() {
panelTransitionLocked = true
}
fun unlockTransition() {
panelTransitionLocked = false
}
val catBar = UIItemInventoryCatBar(
this,
(App.scr.width - catBarWidth) / 2,
@@ -145,7 +154,7 @@ class UIInventoryFull(
internalWidth,
catBarWidth,
true,
{ i -> requestTransition(i) }
{ i -> if (!panelTransitionLocked) requestTransition(i) }
)
@@ -167,9 +176,11 @@ class UIInventoryFull(
addUIitem(catBar)
addUIitem(transitionPanel)
catBar.selectionChangeListener = { old, new ->
rebuildList()
transitionalItemCells.resetStatusAsCatChanges(old, new)
catBar.selectionChangeListener = { old, new ->
if (!panelTransitionLocked) {
rebuildList()
transitionalItemCells.resetStatusAsCatChanges(old, new)
}
}
@@ -190,7 +201,7 @@ class UIInventoryFull(
rebuildList()
}
catBar.update(delta)
if (!panelTransitionLocked) catBar.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 //
actorsList.forEach {
actorsList.forEachIndexed { count, it ->
Echo("Writing actors... ${count+1}/${actorsList.size}")
val actorContent = EntryFile(WriteActor.encodeToByteArray64(it))
val actor = DiskEntry(it.referenceID.toLong(), 0, creation_t, time_t, actorContent)
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
// entry zero MUST NOT be used to get lastPlayDate, but we'll update it anyway
// use entry -1 for that purpose!

View File

@@ -47,7 +47,7 @@ class UIItemTextArea(
}
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 < 0) scrollPos = 0