mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 18:44:05 +09:00
still wip
This commit is contained in:
@@ -684,6 +684,8 @@ fun AppUpdateListOfSavegames() {
|
|||||||
App.savegamePlayers.clear()
|
App.savegamePlayers.clear()
|
||||||
App.savegameWorlds.clear()
|
App.savegameWorlds.clear()
|
||||||
|
|
||||||
|
println("listing savegames...")
|
||||||
|
|
||||||
// create list of worlds
|
// create list of worlds
|
||||||
(File(App.worldsDir).listFiles().filter { !it.isDirectory && !it.name.contains('.') }.map { file ->
|
(File(App.worldsDir).listFiles().filter { !it.isDirectory && !it.name.contains('.') }.map { file ->
|
||||||
try {
|
try {
|
||||||
@@ -695,8 +697,12 @@ fun AppUpdateListOfSavegames() {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
}.filter { it != null }.sortedByDescending { it!!.diskFile.lastModified() } as List<DiskSkimmer>).forEach {
|
}.filter { it != null }.sortedByDescending { it!!.diskFile.lastModified() } as List<DiskSkimmer>).forEach {
|
||||||
|
println(it.diskFile.absolutePath)
|
||||||
|
it.rebuild() // disk skimmer was created without initialisation, so do it now
|
||||||
|
|
||||||
// TODO write simple and dumb SAX parser for JSON
|
// TODO write simple and dumb SAX parser for JSON
|
||||||
val json = JsonReader().parse(ByteArray64Reader(it.getFile(-1L)!!.bytes, Common.CHARSET).readText())
|
val jsonFile = it.getFile(-1L)!!
|
||||||
|
val json = JsonReader().parse(ByteArray64Reader(jsonFile.bytes, Common.CHARSET).readText())
|
||||||
val worldUUID = UUID.fromString(json.get("worldIndex")!!.asString())
|
val worldUUID = UUID.fromString(json.get("worldIndex")!!.asString())
|
||||||
App.savegameWorlds[worldUUID] = it
|
App.savegameWorlds[worldUUID] = it
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ object TerrarumAppConfiguration {
|
|||||||
// CONFIGURATION FOR THE APP ITSELF //
|
// CONFIGURATION FOR THE APP ITSELF //
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
const val GAME_NAME = "Terrarum"
|
const val GAME_NAME = "Terrarum"
|
||||||
const val COPYRIGHT_DATE_NAME = "Copyright 2013-2021 CuriousTorvald (minjaesong)"
|
const val COPYRIGHT_DATE_NAME = "Copyright 2013-2021 CuriousToꝛvald (minjaesong)"
|
||||||
val COPYRIGHT_LICENSE: String; get() = Lang["COPYRIGHT_GNU_GPL_3"]
|
val COPYRIGHT_LICENSE: String; get() = Lang["COPYRIGHT_GNU_GPL_3"]
|
||||||
const val COPYRIGHT_LICENSE_ENGLISH = "Distributed under GNU GPL 3"
|
const val COPYRIGHT_LICENSE_ENGLISH = "Distributed under GNU GPL 3"
|
||||||
const val COPYRIGHT_LICENSE_TERMS_SHORT = """
|
const val COPYRIGHT_LICENSE_TERMS_SHORT = """
|
||||||
|
|||||||
@@ -234,8 +234,8 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
// load list of savegames
|
// load list of savegames
|
||||||
println("[TitleScreen] update list of savegames")
|
println("[TitleScreen] update list of savegames")
|
||||||
// TODO to show "Continue" and "Load" on the titlescreen, uncomment this line
|
// to show "Continue" and "Load" on the titlescreen, uncomment this line
|
||||||
// App.updateListOfSavegames()
|
App.updateListOfSavegames()
|
||||||
|
|
||||||
|
|
||||||
loadThingsWhileIntroIsVisible()
|
loadThingsWhileIntroIsVisible()
|
||||||
|
|||||||
@@ -72,7 +72,10 @@ object ThreadExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun killAll() {
|
fun killAll() {
|
||||||
executor.shutdownNow()
|
try {
|
||||||
|
executor.shutdownNow()
|
||||||
|
}
|
||||||
|
catch (e: UninitializedPropertyAccessException) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class GameWorldTitleScreen : GameWorld() {
|
|||||||
|
|
||||||
open class GameWorld() : Disposable {
|
open class GameWorld() : Disposable {
|
||||||
|
|
||||||
var worldName: String = "New World"
|
// var worldName: String = "New World"
|
||||||
var worldIndex: UUID = UUID.randomUUID() // should not be immutable as JSON loader will want to overwrite it
|
var worldIndex: UUID = UUID.randomUUID() // should not be immutable as JSON loader will want to overwrite it
|
||||||
var worldCreator: UUID = UUID(0L,0L) // TODO record a value to this
|
var worldCreator: UUID = UUID(0L,0L) // TODO record a value to this
|
||||||
var width: Int = 999; private set
|
var width: Int = 999; private set
|
||||||
@@ -55,14 +55,17 @@ open class GameWorld() : Disposable {
|
|||||||
val randSeeds = LongArray(256) // stores 128 128-bit numbers
|
val randSeeds = LongArray(256) // stores 128 128-bit numbers
|
||||||
|
|
||||||
/** Creation time for this world, NOT the entire savegame */
|
/** Creation time for this world, NOT the entire savegame */
|
||||||
internal var creationTime: Long = App.getTIME_T()
|
internal var creationTime = -1L
|
||||||
internal set
|
internal set
|
||||||
/** Creation time for this world, NOT the entire savegame */
|
/** Creation time for this world, NOT the entire savegame */
|
||||||
internal var lastPlayTime: Long = App.getTIME_T()
|
internal var lastPlayTime = -1L
|
||||||
internal set // there's a case of save-and-continue-playing
|
internal set // there's a case of save-and-continue-playing
|
||||||
/** Creation time for this world, NOT the entire savegame */
|
/** Creation time for this world, NOT the entire savegame */
|
||||||
internal var totalPlayTime = 0L // cumulative value for this very world
|
internal var totalPlayTime = 0L // cumulative value for this very world
|
||||||
|
|
||||||
|
init {
|
||||||
|
creationTime = App.getTIME_T()
|
||||||
|
}
|
||||||
|
|
||||||
//layers
|
//layers
|
||||||
@Transient lateinit open var layerWall: BlockLayer
|
@Transient lateinit open var layerWall: BlockLayer
|
||||||
|
|||||||
@@ -1,22 +1,9 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.console
|
package net.torvald.terrarum.modulebasegame.console
|
||||||
|
|
||||||
import net.torvald.ELLIPSIS
|
|
||||||
import net.torvald.terrarum.App
|
|
||||||
import net.torvald.terrarum.ccC
|
|
||||||
import net.torvald.terrarum.ccG
|
|
||||||
import net.torvald.terrarum.ccR
|
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
|
||||||
import net.torvald.terrarum.console.Echo
|
|
||||||
import net.torvald.terrarum.tvda.VDUtil
|
|
||||||
import net.torvald.terrarum.serialise.*
|
|
||||||
import java.io.File
|
|
||||||
import java.io.IOException
|
|
||||||
import java.util.logging.Level
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2021-08-30.
|
* Created by minjaesong on 2021-08-30.
|
||||||
*/
|
*/
|
||||||
object Load : ConsoleCommand {
|
/*object Load : ConsoleCommand {
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 2) {
|
if (args.size == 2) {
|
||||||
@@ -43,4 +30,4 @@ object Load : ConsoleCommand {
|
|||||||
Echo("Usage: load <filename>")
|
Echo("Usage: load <filename>")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}*/
|
||||||
@@ -14,14 +14,15 @@ import net.torvald.terrarum.*
|
|||||||
import net.torvald.terrarum.App.printdbg
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.serialise.Common
|
import net.torvald.terrarum.serialise.Common
|
||||||
import net.torvald.terrarum.serialise.LoadSavegame
|
import net.torvald.terrarum.tvda.ByteArray64InputStream
|
||||||
import net.torvald.terrarum.tvda.*
|
import net.torvald.terrarum.tvda.ByteArray64Reader
|
||||||
|
import net.torvald.terrarum.tvda.DiskSkimmer
|
||||||
|
import net.torvald.terrarum.tvda.EntryFile
|
||||||
import net.torvald.terrarum.ui.*
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.logging.Level
|
|
||||||
import java.util.zip.GZIPInputStream
|
import java.util.zip.GZIPInputStream
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@@ -404,7 +405,7 @@ class UIItemWorldCells(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override var clickOnceListener: ((Int, Int, Int) -> Unit)? = { _: Int, _: Int, _: Int ->
|
override var clickOnceListener: ((Int, Int, Int) -> Unit)? = { _: Int, _: Int, _: Int ->
|
||||||
LoadSavegame(VDUtil.readDiskArchive(skimmer.diskFile, Level.INFO))
|
TODO()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var hasTexture = false
|
internal var hasTexture = false
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ object UITitleRemoConYaml {
|
|||||||
|
|
||||||
|
|
||||||
operator fun invoke(hasSave: Boolean) =
|
operator fun invoke(hasSave: Boolean) =
|
||||||
Yaml((if (!hasSave) menuWithSavefile else menuNewGame) + menuBase).parse()
|
//Yaml((if (hasSave) menuWithSavefile else menuNewGame) + menuBase).parse()
|
||||||
|
Yaml((if (true) menuWithSavefile else menuNewGame) + menuBase).parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ import net.torvald.terrarum.modulebasegame.IngameRenderer
|
|||||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
|
import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
|
||||||
import net.torvald.terrarum.realestate.LandUtil
|
import net.torvald.terrarum.realestate.LandUtil
|
||||||
import net.torvald.terrarum.tvda.ByteArray64
|
import net.torvald.terrarum.tvda.*
|
||||||
import net.torvald.terrarum.tvda.ByteArray64Reader
|
|
||||||
import net.torvald.terrarum.tvda.SimpleFileSystem
|
|
||||||
import net.torvald.terrarum.tvda.VirtualDisk
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.Reader
|
import java.io.Reader
|
||||||
|
|
||||||
@@ -128,12 +125,17 @@ object LoadSavegame {
|
|||||||
fun getFileBytes(disk: SimpleFileSystem, id: Long): ByteArray64 = disk.getFile(id)!!.bytes
|
fun getFileBytes(disk: SimpleFileSystem, id: Long): ByteArray64 = disk.getFile(id)!!.bytes
|
||||||
fun getFileReader(disk: SimpleFileSystem, id: Long): Reader = ByteArray64Reader(getFileBytes(disk, id), Common.CHARSET)
|
fun getFileReader(disk: SimpleFileSystem, id: Long): Reader = ByteArray64Reader(getFileBytes(disk, id), Common.CHARSET)
|
||||||
|
|
||||||
operator fun invoke(playerDisk: SimpleFileSystem) {
|
/**
|
||||||
|
* @param playerDisk DiskSkimmer representing the Player.
|
||||||
|
* @param worldDisk0 DiskSkimmer representing the World to be loaded.
|
||||||
|
* If unset, last played world for the Player will be loaded.
|
||||||
|
*/
|
||||||
|
operator fun invoke(playerDisk: DiskSkimmer, worldDisk0: DiskSkimmer? = null) {
|
||||||
val newIngame = TerrarumIngame(App.batch)
|
val newIngame = TerrarumIngame(App.batch)
|
||||||
val player = ReadActor.invoke(playerDisk, ByteArray64Reader(playerDisk.getFile(-1L)!!.bytes, Common.CHARSET)) as IngamePlayer
|
val player = ReadActor.invoke(playerDisk, ByteArray64Reader(playerDisk.getFile(-1L)!!.bytes, Common.CHARSET)) as IngamePlayer
|
||||||
|
|
||||||
val currentWorldId = player.worldCurrentlyPlaying
|
val currentWorldId = player.worldCurrentlyPlaying
|
||||||
val worldDisk = App.savegameWorlds[currentWorldId]!!
|
val worldDisk = worldDisk0 ?: App.savegameWorlds[currentWorldId]!!
|
||||||
val world = ReadWorld(ByteArray64Reader(worldDisk.getFile(-1L)!!.bytes, Common.CHARSET))
|
val world = ReadWorld(ByteArray64Reader(worldDisk.getFile(-1L)!!.bytes, Common.CHARSET))
|
||||||
|
|
||||||
world.layerTerrain = BlockLayer(world.width, world.height)
|
world.layerTerrain = BlockLayer(world.width, world.height)
|
||||||
|
|||||||
@@ -188,6 +188,8 @@ removefile:
|
|||||||
* @return DiskEntry if the entry exists on the disk, `null` otherwise.
|
* @return DiskEntry if the entry exists on the disk, `null` otherwise.
|
||||||
*/
|
*/
|
||||||
fun requestFile(entryID: EntryID): DiskEntry? {
|
fun requestFile(entryID: EntryID): DiskEntry? {
|
||||||
|
if (!initialised) throw IllegalStateException("File entries not built! Initialise the Skimmer by executing rebuild()")
|
||||||
|
|
||||||
entryToOffsetTable[entryID].let { offset ->
|
entryToOffsetTable[entryID].let { offset ->
|
||||||
if (offset == null) {
|
if (offset == null) {
|
||||||
debugPrintln("[DiskSkimmer.requestFile] entry $entryID does not exist on the table")
|
debugPrintln("[DiskSkimmer.requestFile] entry $entryID does not exist on the table")
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import javax.swing.text.DefaultCaret
|
|||||||
class VirtualDiskCracker(val sysCharset: Charset = Charsets.UTF_8) : JFrame() {
|
class VirtualDiskCracker(val sysCharset: Charset = Charsets.UTF_8) : JFrame() {
|
||||||
|
|
||||||
|
|
||||||
private val annoyHackers = true // Jar build settings. Intended for Terrarum proj.
|
private val annoyHackers = false // Jar build settings. Intended for Terrarum proj.
|
||||||
|
|
||||||
|
|
||||||
private val PREVIEW_MAX_BYTES = 4L * 1024 // 4 kBytes
|
private val PREVIEW_MAX_BYTES = 4L * 1024 // 4 kBytes
|
||||||
|
|||||||
Reference in New Issue
Block a user