mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
seemingly working world teleporter (no saving... ui tho)
This commit is contained in:
@@ -431,6 +431,8 @@ object IngameRenderer : Disposable {
|
|||||||
fun requestScreencap() {
|
fun requestScreencap() {
|
||||||
screencapRequested = true
|
screencapRequested = true
|
||||||
screencapBusy = true
|
screencapBusy = true
|
||||||
|
printdbg(this, "requestScreencap called from:")
|
||||||
|
printStackTrace(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun drawToRGB(
|
private fun drawToRGB(
|
||||||
|
|||||||
@@ -880,9 +880,15 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
if ((!paused && !App.isScreenshotRequested()) && newWorldLoadedLatch) newWorldLoadedLatch = false
|
if ((!paused && !App.isScreenshotRequested()) && newWorldLoadedLatch) newWorldLoadedLatch = false
|
||||||
|
|
||||||
if (saveRequested != null) {
|
if (saveRequested) {
|
||||||
doForceSave(saveRequested!!)
|
saveRequested = false
|
||||||
saveRequested = null
|
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) {
|
override fun requestForceSave(callback: () -> Unit) {
|
||||||
saveRequested = callback
|
saveCallback = callback
|
||||||
|
saveRequested = true
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun doForceSave(callback: () -> Unit) {
|
internal fun doForceSave() {
|
||||||
// TODO show appropriate UI
|
// TODO show appropriate UI
|
||||||
|
|
||||||
saveTheGame({ // onSuccessful
|
saveTheGame({ // onSuccessful
|
||||||
System.gc()
|
System.gc()
|
||||||
autosaveTimer = 0f
|
autosaveTimer = 0f
|
||||||
|
|
||||||
// TODO hide appropriate UI
|
// TODO hide appropriate UI
|
||||||
|
|
||||||
callback()
|
doThingsAfterSave = true
|
||||||
}, { // onError
|
}, { // onError
|
||||||
// TODO show failure message
|
// TODO show failure message
|
||||||
|
|
||||||
|
|||||||
@@ -78,9 +78,10 @@ class FixtureWorldPortal : Electric {
|
|||||||
val jobAfterSave: () -> Unit
|
val jobAfterSave: () -> Unit
|
||||||
if (it.worldDiskToLoad != null) {
|
if (it.worldDiskToLoad != null) {
|
||||||
UILoadGovernor.worldDisk = it.worldDiskToLoad
|
UILoadGovernor.worldDisk = it.worldDiskToLoad
|
||||||
UILoadGovernor.playerDisk = App.savegamePlayers[player.uuid]!!.getBaseFile()
|
UILoadGovernor.playerDisk = App.savegamePlayers[player.uuid]!!.files[0]
|
||||||
jobAfterSave = {
|
jobAfterSave = {
|
||||||
LoadSavegame(UILoadGovernor.worldDisk!!, UILoadGovernor.playerDisk)
|
UILoadGovernor.playerDisk!!.rebuild()
|
||||||
|
LoadSavegame(UILoadGovernor.playerDisk!!, UILoadGovernor.worldDisk!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create new
|
// create new
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class PlayerSavingThread(
|
|||||||
val gzout = GZIPOutputStream(tgaout)
|
val gzout = GZIPOutputStream(tgaout)
|
||||||
PixmapIO2._writeTGA(gzout, IngameRenderer.fboRGBexport, true, true)
|
PixmapIO2._writeTGA(gzout, IngameRenderer.fboRGBexport, true, true)
|
||||||
IngameRenderer.fboRGBexport.dispose()
|
IngameRenderer.fboRGBexport.dispose()
|
||||||
|
// App.disposables.add(IngameRenderer.fboRGBexport)
|
||||||
val thumbContent = EntryFile(tgaout.toByteArray64())
|
val thumbContent = EntryFile(tgaout.toByteArray64())
|
||||||
val thumb =
|
val thumb =
|
||||||
DiskEntry(VDFileID.PLAYER_SCREENSHOT, VDFileID.ROOT, ingame.world.creationTime, time_t, thumbContent)
|
DiskEntry(VDFileID.PLAYER_SCREENSHOT, VDFileID.ROOT, ingame.world.creationTime, time_t, thumbContent)
|
||||||
|
|||||||
@@ -151,8 +151,16 @@ object ReadPlayer {
|
|||||||
object ReadActor {
|
object ReadActor {
|
||||||
|
|
||||||
operator fun invoke(disk: SimpleFileSystem, dataStream: Reader): Actor =
|
operator fun invoke(disk: SimpleFileSystem, dataStream: Reader): Actor =
|
||||||
Common.jsoner.fromJson<Actor?>(null, dataStream).also {
|
try {
|
||||||
fillInDetails(disk, it)
|
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) {
|
private fun fillInDetails(disk: SimpleFileSystem, actor: Actor) {
|
||||||
|
|||||||
@@ -191,6 +191,8 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
|||||||
var h = 0
|
var h = 0
|
||||||
var thumb: TextureRegion? = null
|
var thumb: TextureRegion? = null
|
||||||
|
|
||||||
|
disk.rebuild()
|
||||||
|
|
||||||
JsonFetcher.readFromJsonString(ByteArray64Reader(disk!!.requestFile(-1)!!.contents.getContent() as ByteArray64, Common.CHARSET)).let {
|
JsonFetcher.readFromJsonString(ByteArray64Reader(disk!!.requestFile(-1)!!.contents.getContent() as ByteArray64, Common.CHARSET)).let {
|
||||||
JsonFetcher.forEachSiblings(it) { name, value ->
|
JsonFetcher.forEachSiblings(it) { name, value ->
|
||||||
if (name == "width") w = value.asInt()
|
if (name == "width") w = value.asInt()
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ removefile:
|
|||||||
fa.read(4).toIntBig().toLong()
|
fa.read(4).toIntBig().toLong()
|
||||||
}
|
}
|
||||||
DiskEntry.SYMLINK -> 8L
|
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)
|
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)
|
return DiskEntry(entryID, parent, creationTime, modifyTime, entryContent)
|
||||||
|
|||||||
Reference in New Issue
Block a user