font update; ui remocon fix; save doc elaboration

UI RemoCon fix: RemoCon will no longer widen to the screen width when being used
This commit is contained in:
minjaesong
2018-09-14 01:14:13 +09:00
parent 0658d95b12
commit 79f3e8e28d
31 changed files with 172 additions and 42 deletions

View File

@@ -111,5 +111,5 @@ object AVKey {
const val __HISTORICAL_BORNTIME = "__borntime" // time_t
const val __HISTORICAL_DEADTIME = "__deadtime" // time_t
const val __HISTORICAL_DEADTIME = "__deadtime" // time_t, -1 if not dead
}

View File

@@ -174,7 +174,11 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
data class GameSaveData(
val world: GameWorldExtension,
val historicalFigureIDBucket: ArrayList<Int>,
val realGamePlayer: IngamePlayer
val realGamePlayer: IngamePlayer,
val rogueseed: Long,
val rogueiter: Int,
val weatherseed: Long,
val weatheriter: Int
)
data class NewWorldParameters(
@@ -203,6 +207,10 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
addNewActor(playableActor)
// set the randomisers right
RoguelikeRandomiser.loadFromSave(gameSaveData.rogueseed, gameSaveData.rogueiter)
WeatherMixer.loadFromSave(gameSaveData.weatherseed, gameSaveData.weatheriter)
//initGame()
}

View File

@@ -0,0 +1,29 @@
package net.torvald.terrarum.modulebasegame
import java.util.*
internal interface RNGConsumer {
val RNG: Random
var seed: Long
var iterations: Int
fun loadFromSave(seed: Long, iterations: Int) {
this.seed = seed
this.iterations = iterations
repeat(iterations, { RNG.nextInt() })
}
private fun incIterations() {
iterations++
if (iterations < 0) iterations = 0
}
fun getRandomLong(): Long {
iterations++
return RNG.nextLong()
}
}

View File

@@ -18,7 +18,7 @@ object ExportLayerData : ConsoleCommand {
WriteLayerData(saveDirectoryName)
Echo("Layer data exported to $saveDirectoryName/${WriteLayerData.META_FILENAME}")
Echo("Layer data exported to $saveDirectoryName/${WriteLayerData.LAYERS_FILENAME}")
}
override fun printUsage() {

View File

@@ -7,6 +7,11 @@ package net.torvald.terrarum.modulebasegame.gameactors
*
* NOTE: all canonical NPCs are must be HistoricalFigure!! (double excl mark, bitch)
*
* This interface is just a marker. Actual historical information must be contained as the Actor Value with:
*
* "__borntime" // time_t
* "__deadtime" // time_t
*
* Created by minjaesong on 2016-10-10.
*/
interface HistoricalFigure {

View File

@@ -23,7 +23,9 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
private var remoConTray: UIRemoConElement // this remocon is dynamically generated
private var currentRemoConContents = treeRepresentation
override var width = remoConWidth
override var width: Int
get() = remoConWidth // somehow NOT making this constant causes a weird issue
set(value) {} // where the remocon widens to screen width
override var height: Int
get() = remoConTray.height
set(value) {}

View File

@@ -10,7 +10,7 @@ import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemTextButtonList
class UITitleRemoConLanguage(val superMenu: UICanvas) : UICanvas() {
class UITitleLanguage : UICanvas() {
val menuLabels = arrayOf(
"MENU_LABEL_RETURN"
@@ -59,6 +59,7 @@ class UITitleRemoConLanguage(val superMenu: UICanvas) : UICanvas() {
override fun updateUI(delta: Float) {
textArea.update(delta)
println("should be printing indefinitely")
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {

View File

@@ -62,7 +62,7 @@ import net.torvald.terrarum.ui.UIItemTextButtonList
private val remoConCredits = UITitleRemoConCredits(this)
private val remoConLanguage = UITitleRemoConLanguage(this)
private val remoConLanguage = UITitleLanguage(this)
private val remoConModules = UITitleModules(this)
init {

View File

@@ -6,10 +6,12 @@ import java.util.*
object UITitleRemoConYaml {
// YAML indent with a space, separate label and class with " : " verbatim!
// YAML indent with a space, separate label and class with " : " (\x20\x3A\x20)
val menus = """
- MENU_MODE_SINGLEPLAYER
- MENU_MODE_SINGLEPLAYER : net.torvald.terrarum.modulebasegame.ui.UITitleCharactersList
- CONTEXT_CHARACTER_NEW
- CONTEXT_CHARACTER_DELETE
- MENU_LABEL_RETURN
- MENU_MODE_MULTIPLAYER
- MENU_LABEL_RETURN
@@ -20,7 +22,7 @@ object UITitleRemoConYaml {
- MENU_LABEL_RETURN
- MENU_MODULES : net.torvald.terrarum.modulebasegame.ui.UITitleModules
- MENU_LABEL_RETURN
- MENU_LABEL_LANGUAGE
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage
- MENU_LABEL_RETURN
- MENU_LABEL_CREDITS : net.torvald.terrarum.modulebasegame.ui.UITitleCredits
- MENU_LABEL_CREDITS : net.torvald.terrarum.modulebasegame.ui.UITitleCredits

View File

@@ -11,6 +11,7 @@ import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.modulebasegame.gameactors.ParticleMegaRain
import net.torvald.terrarum.gamecontroller.KeyToggler
import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.modulebasegame.RNGConsumer
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
@@ -31,7 +32,13 @@ import java.util.*
*
* Created by minjaesong on 2016-07-11.
*/
internal object WeatherMixer {
internal object WeatherMixer : RNGConsumer {
override val RNG = HQRNG()
override var seed = 0L
override var iterations = 0
var weatherList: HashMap<String, ArrayList<BaseModularWeather>>
var currentWeather: BaseModularWeather

View File

@@ -4,12 +4,13 @@ import com.badlogic.gdx.graphics.Color
import net.torvald.dataclass.IntArrayStack
import net.torvald.colourutil.Col4096
import net.torvald.random.HQRNG
import net.torvald.terrarum.modulebasegame.RNGConsumer
import java.util.*
/**
* Created by minjaesong on 2016-02-23.
*/
object RoguelikeRandomiser {
object RoguelikeRandomiser : RNGConsumer {
val POTION_PRIMARY_COLSET = intArrayOf(15, 15, 7, 7, 0, 0)
@@ -18,8 +19,8 @@ object RoguelikeRandomiser {
val coloursTaken: ArrayList<Col4096> = ArrayList()
var seed: Long = 0
private val random: Random = HQRNG()
override val RNG = HQRNG()
override var seed = 0L
private val POTION_HEAL_TIER1 = 0x00
private val POTION_HEAL_TIRE2 = 0x01
@@ -28,7 +29,7 @@ object RoguelikeRandomiser {
private val POTION_BERSERK_TIER1 = 0x20
override var iterations = 0
fun setupColours() {
@@ -59,6 +60,8 @@ object RoguelikeRandomiser {
val a = ar[index];
ar[index] = ar[i];
ar[i] = a;
iterations++
}
}
}

View File

@@ -10,6 +10,7 @@ import net.torvald.terrarum.LoadScreen
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.concurrent.ThreadParallel
import net.torvald.terrarum.modulebasegame.RNGConsumer
import net.torvald.terrarum.roundInt
import java.util.*

View File

@@ -0,0 +1,34 @@
package net.torvald.terrarum.serialise
import net.torvald.terrarum.Terrarum
import java.io.File
import java.io.FileFilter
import java.io.FileInputStream
object SavegameLedger {
private val SAVE_DIRECTORY = File(Terrarum.defaultSaveDir)
fun hasSavegameDirectory() = SAVE_DIRECTORY.exists() && SAVE_DIRECTORY.isDirectory
private fun peekFewBytes(file: File, length: Int): ByteArray {
val buffer = ByteArray(length)
val `is` = FileInputStream(file)
if (`is`.read(buffer) != buffer.size) {
throw InternalError()
}
`is`.close()
return buffer
}
private val MAGIC_TEVD = "TEVd".toByteArray()
fun getSavefileList(): List<File>? {
return if (!hasSavegameDirectory()) null
else SAVE_DIRECTORY.listFiles().filter { it.isFile && peekFewBytes(it, 4) contentEquals MAGIC_TEVD }
}
fun getSavefileCount() = getSavefileList()?.count() ?: 0
}

View File

@@ -48,7 +48,7 @@ internal object WriteCSV {
Files.copy(tempPathMat, pathMat, StandardCopyOption.REPLACE_EXISTING)
Files.deleteIfExists(tempPathMat)
println("Saved map data '${WriteLayerData.META_FILENAME}' to $saveDirectoryName.")
println("Saved map data '${WriteLayerData.LAYERS_FILENAME}' to $saveDirectoryName.")
return true
}

View File

@@ -3,7 +3,6 @@ package net.torvald.terrarum.serialise
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.console.EchoError
import net.torvald.terrarum.modulebasegame.Ingame
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
@@ -11,12 +10,14 @@ import java.nio.charset.Charset
import java.util.zip.GZIPOutputStream
/**
* TODO this one does not use TerranVirtualDisk
*
* Created by minjaesong on 2016-03-18.
*/
// internal for everything: prevent malicious module from messing up the savedata
internal object WriteLayerData {
val META_FILENAME = "worldinfo1"
val LAYERS_FILENAME = "worldinfo1"
val MAGIC = "TEMD".toByteArray(charset = Charset.forName("US-ASCII"))
@@ -24,7 +25,7 @@ internal object WriteLayerData {
internal operator fun invoke(saveDirectoryName: String): Boolean {
val path = "${Terrarum.defaultSaveDir}/$saveDirectoryName/${META_FILENAME}"
val path = "${Terrarum.defaultSaveDir}/$saveDirectoryName/${LAYERS_FILENAME}"
val tempPath = "${path}_bak"
val map = (Terrarum.ingame!!.world)
@@ -69,7 +70,7 @@ internal object WriteLayerData {
outFile.delete()
tempFile.copyTo(outFile, overwrite = true)
tempFile.delete()
println("Saved map data '$META_FILENAME' to $saveDirectoryName.")
println("Saved map data '$LAYERS_FILENAME' to $saveDirectoryName.")
return true
}

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.serialise
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
import net.torvald.terrarum.modulebasegame.worldgenerator.WorldGenerator
import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
import java.nio.charset.Charset
@@ -10,7 +11,7 @@ import java.nio.charset.Charset
// internal for everything: prevent malicious module from messing up the savedata
internal object WriteMeta {
val META_FILENAME = "world"
val META_FILENAME = "worldinfo0"
val MAGIC = "TESV".toByteArray(charset = Charset.forName("US-ASCII"))
@@ -19,6 +20,9 @@ internal object WriteMeta {
val terraseed: Long = WorldGenerator.SEED
val rogueseed: Long = RoguelikeRandomiser.seed
val rogueiter: Int = RoguelikeRandomiser.iterations
val weatherseed: Long = WeatherMixer.seed
val weatheriter: Int = WeatherMixer.iterations
/**
* Write save meta to specified directory. Returns false if something went wrong.

View File

@@ -0,0 +1,19 @@
A savegame consists of a Playable Character Information, Savegame Metadata, and other files.
A savegame is a single file in the format of TerranVirtualDisk.
Files contained the TerranVirtualDisk is as follows:
(root)
worldinfo0 -- Savegame Metadata GZipped (TESV)
worldinfo1 -- Layer Data GZipped (TEMD)
worldinfo2 -- Copy of blocks.csv GZipped -- will use this from the next load
worldinfo3 -- Copy of items.csv GZipped -- will use this from the next load
worldinfo4 -- Copy of materials.csv GZipped -- will use this from the next load
(any random number in Hex ACTORID_MIN..FFFFFFFF) -- Serialised Entity Information (including Player)
(PLAYER_REF_ID in Hex -- 91A7E2) -- Player Character Information (Serialised Entity Information)
(51621D) -- The Debug Player (Serialised Entity Information)
load_order.txt -- LoadOrder.csv
Remarks: world history is created at the load time by scanning all the actors' corresponding ActorValue

View File

@@ -15,15 +15,23 @@ Ord Hex Description
... Terrain seed (8 bytes)
... Randomiser seed (8 bytes)
... Randomiser iterations (4 bytes)
... Weather seed (8 bytes)
... Weather iterations (4 bytes)
... SHA-256 hash of worldinfo1 when not compressed (32 bytes)
... SHA-256 hash of worldinfo2 when not compressed (32 bytes)
... SHA-256 hash of worldinfo3 when not compressed (32 bytes)
... SHA-256 hash of worldinfo4 when not compressed (32 bytes)
... ReferenceID of the player (4 bytes)
... ReferenceID of the player (4 bytes, a fixed value of 91A7E2)
... Current world's time_t (the ingame time, 8 bytes)
... Creation time in time_t (6 bytes)
... Last play time in time_t (6 bytes)
... Total playtime in time_t (4 bytes) // will record 136.1 years of playtime
... Total playtime in time_t (4 bytes) // will record 136.1 years of playtime

View File

@@ -19,7 +19,7 @@ Ord Hex Description
05 Number of swatches
00 - No palette mode (using defined palette)
- 256 colours (using user-defined)
nn - Colour count (1-255)
nn - Colour count (0-255; 0 is interpreted as 256)
06 Width of the image (LSB)
07 Width of the image (MSB)
@@ -37,6 +37,6 @@ Ord Hex Description
... Palette colour 2, if any (0R)
... Palette colour 2, if any (GB)
... Colour indices
... Colour indices, each byte represents each pixel
<EOF>

Binary file not shown.