mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
recording and retrieving timestamps for save meta and world
This commit is contained in:
@@ -65,7 +65,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private val timeNow = System.currentTimeMillis() / 1000
|
||||
|
||||
val gameWorld = GameWorld(1, 1024, 256, timeNow, timeNow, 0)
|
||||
val gameWorld = GameWorld(1, 1024, 256, timeNow, timeNow)
|
||||
|
||||
init {
|
||||
// ghetto world for building
|
||||
|
||||
@@ -295,7 +295,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
// init map as chosen size
|
||||
val timeNow = App.getTIME_T()
|
||||
world = GameWorld(1, worldParams.width, worldParams.height, timeNow, timeNow, 0) // new game, so the creation time is right now
|
||||
world = GameWorld(1, worldParams.width, worldParams.height, timeNow, timeNow) // new game, so the creation time is right now
|
||||
world.generatorSeed = worldParams.worldGenSeed
|
||||
gameworldIndices.add(world.worldIndex)
|
||||
world.extraFields["basegame.economy"] = GameEconomy()
|
||||
|
||||
@@ -18,8 +18,7 @@ import java.io.IOException
|
||||
object ExportMeta : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
try {
|
||||
val currentPlayTime_t = App.getTIME_T() - ingame!!.loadedTime_t
|
||||
val str = WriteMeta(ingame!! as TerrarumIngame, currentPlayTime_t)
|
||||
val str = WriteMeta(ingame!! as TerrarumIngame, App.getTIME_T())
|
||||
val writer = java.io.FileWriter(App.defaultDir + "/Exports/savegame.json", false)
|
||||
writer.write(str)
|
||||
writer.close()
|
||||
@@ -40,7 +39,7 @@ object ExportWorld : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
try {
|
||||
val str = WriteWorld(ingame!! as TerrarumIngame)
|
||||
val str = WriteWorld(ingame!! as TerrarumIngame, App.getTIME_T())
|
||||
val writer = java.io.FileWriter(App.defaultDir + "/Exports/${args[1]}.json", false)
|
||||
writer.write(str)
|
||||
writer.close()
|
||||
|
||||
@@ -45,8 +45,9 @@ class UILoadDemoSavefiles : UICanvas() {
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
}.sortedByDescending { (it as VirtualDisk).entries[0]!!.modificationDate }.forEachIndexed { index, disk ->
|
||||
}.filter { it != null }.sortedByDescending { (it as VirtualDisk).entries[0]!!.modificationDate }.forEachIndexed { index, disk ->
|
||||
val x = (width - UIItemDemoSaveCells.WIDTH) / 2
|
||||
val y = 144 + (24 + UIItemDemoSaveCells.HEIGHT) * index
|
||||
addUIitem(UIItemDemoSaveCells(this, x, y, disk as VirtualDisk))
|
||||
@@ -102,9 +103,21 @@ class UIItemDemoSaveCells(
|
||||
private val x = initialX.toFloat()
|
||||
private val y = initialY.toFloat()
|
||||
|
||||
private fun parseDuration(seconds: Long): String {
|
||||
val s = seconds % 60
|
||||
val m = (seconds / 60) % 60
|
||||
val h = (seconds / 3600) % 24
|
||||
val d = seconds / 86400
|
||||
return if (d == 0L)
|
||||
"${h.toString().padStart(2,'0')}h${m.toString().padStart(2,'0')}m${s.toString().padStart(2,'0')}s"
|
||||
else
|
||||
"${d}d${h.toString().padStart(2,'0')}h${m.toString().padStart(2,'0')}m${s.toString().padStart(2,'0')}s"
|
||||
}
|
||||
|
||||
private val lastPlayedTimestamp = Instant.ofEpochSecond(meta.lastplay_t)
|
||||
.atZone(TimeZone.getDefault().toZoneId())
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) +
|
||||
"/${parseDuration(meta.playtime_t)}"
|
||||
|
||||
init {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user