seemingly working world teleporter (no saving... ui tho)

This commit is contained in:
minjaesong
2023-07-03 00:10:46 +09:00
parent 9c396e7b8d
commit fcaf4c97f1
7 changed files with 37 additions and 14 deletions

View File

@@ -431,6 +431,8 @@ object IngameRenderer : Disposable {
fun requestScreencap() {
screencapRequested = true
screencapBusy = true
printdbg(this, "requestScreencap called from:")
printStackTrace(this)
}
private fun drawToRGB(

View File

@@ -880,9 +880,15 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
if ((!paused && !App.isScreenshotRequested()) && newWorldLoadedLatch) newWorldLoadedLatch = false
if (saveRequested != null) {
doForceSave(saveRequested!!)
saveRequested = null
if (saveRequested) {
saveRequested = false
doForceSave()
}
if (doThingsAfterSave) {
saveRequested = false
doThingsAfterSave = false
saveCallback!!()
}
}
@@ -920,22 +926,25 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
)
}
private var saveRequested: (() -> Unit)? = null
private var saveRequested = false
private var saveCallback: (() -> Unit)? = null
private var doThingsAfterSave = false
override fun requestForceSave(callback: () -> Unit) {
saveRequested = callback
saveCallback = callback
saveRequested = true
}
internal fun doForceSave(callback: () -> Unit) {
internal fun doForceSave() {
// TODO show appropriate UI
saveTheGame({ // onSuccessful
System.gc()
autosaveTimer = 0f
// TODO hide appropriate UI
callback()
doThingsAfterSave = true
}, { // onError
// TODO show failure message

View File

@@ -78,9 +78,10 @@ class FixtureWorldPortal : Electric {
val jobAfterSave: () -> Unit
if (it.worldDiskToLoad != null) {
UILoadGovernor.worldDisk = it.worldDiskToLoad
UILoadGovernor.playerDisk = App.savegamePlayers[player.uuid]!!.getBaseFile()
UILoadGovernor.playerDisk = App.savegamePlayers[player.uuid]!!.files[0]
jobAfterSave = {
LoadSavegame(UILoadGovernor.worldDisk!!, UILoadGovernor.playerDisk)
UILoadGovernor.playerDisk!!.rebuild()
LoadSavegame(UILoadGovernor.playerDisk!!, UILoadGovernor.worldDisk!!)
}
}
// create new

View File

@@ -57,6 +57,7 @@ class PlayerSavingThread(
val gzout = GZIPOutputStream(tgaout)
PixmapIO2._writeTGA(gzout, IngameRenderer.fboRGBexport, true, true)
IngameRenderer.fboRGBexport.dispose()
// App.disposables.add(IngameRenderer.fboRGBexport)
val thumbContent = EntryFile(tgaout.toByteArray64())
val thumb =
DiskEntry(VDFileID.PLAYER_SCREENSHOT, VDFileID.ROOT, ingame.world.creationTime, time_t, thumbContent)

View File

@@ -151,8 +151,16 @@ object ReadPlayer {
object ReadActor {
operator fun invoke(disk: SimpleFileSystem, dataStream: Reader): Actor =
Common.jsoner.fromJson<Actor?>(null, dataStream).also {
fillInDetails(disk, it)
try {
Common.jsoner.fromJson<Actor?>(null, dataStream).also {
fillInDetails(disk, it)
}
}
catch (e: ClassCastException) {
System.err.println(e.message)
System.err.println("The JSON:")
System.err.println(dataStream.readText())
throw e
}
private fun fillInDetails(disk: SimpleFileSystem, actor: Actor) {

View File

@@ -191,6 +191,8 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
var h = 0
var thumb: TextureRegion? = null
disk.rebuild()
JsonFetcher.readFromJsonString(ByteArray64Reader(disk!!.requestFile(-1)!!.contents.getContent() as ByteArray64, Common.CHARSET)).let {
JsonFetcher.forEachSiblings(it) { name, value ->
if (name == "width") w = value.asInt()

View File

@@ -221,7 +221,7 @@ removefile:
fa.read(4).toIntBig().toLong()
}
DiskEntry.SYMLINK -> 8L
else -> throw UnsupportedOperationException("Unsupported entry type: $fileFlag") // FIXME no support for compressed file
else -> throw UnsupportedOperationException("Unsupported entry type: $fileFlag for entryID $entryID at offset $offset") // FIXME no support for compressed file
}
@@ -251,7 +251,7 @@ removefile:
EntrySymlink(target)
}
else -> throw UnsupportedOperationException("Unsupported entry type: $fileFlag") // FIXME no support for compressed file
else -> throw UnsupportedOperationException("Unsupported entry type: $fileFlag for entryID $entryID at offset $offset") // FIXME no support for compressed file
}
return DiskEntry(entryID, parent, creationTime, modifyTime, entryContent)