diff --git a/assets/graphics/test_loading_arrow_atlas.tga b/assets/graphics/test_loading_arrow_atlas.tga index d8c5fd252..2dba54bb5 100644 --- a/assets/graphics/test_loading_arrow_atlas.tga +++ b/assets/graphics/test_loading_arrow_atlas.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0fda36e66bfb1d4e11e0d79e0a35f6c080a6f6baaed998805421453ddd84d716 -size 4532 +oid sha256:843a39db2575dfe5fca2290fedc31d4487b97b755678c4605fa241bd9bd8b089 +size 6028 diff --git a/lib/TerrarumSansBitmap.jar b/lib/TerrarumSansBitmap.jar index d9efad0a2..2fc6dadc8 100644 Binary files a/lib/TerrarumSansBitmap.jar and b/lib/TerrarumSansBitmap.jar differ diff --git a/src/net/torvald/terrarum/Ingame.kt b/src/net/torvald/terrarum/Ingame.kt index 088dfbc96..f198a38dd 100644 --- a/src/net/torvald/terrarum/Ingame.kt +++ b/src/net/torvald/terrarum/Ingame.kt @@ -35,6 +35,7 @@ import net.torvald.random.HQRNG import net.torvald.terrarum.ui.* import net.torvald.terrarum.worldgenerator.RoguelikeRandomiser import net.torvald.terrarum.worldgenerator.WorldGenerator +import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack /** @@ -197,6 +198,7 @@ class Ingame(val batch: SpriteBatch) : Screen { override fun show() { initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT) + // gameLoadMode and gameLoadInfoPayload must be set beforehand!! when (gameLoadMode) { @@ -223,7 +225,7 @@ class Ingame(val batch: SpriteBatch) : Screen { */ private fun enter(gameSaveData: GameSaveData) { if (gameFullyLoaded) { - Error("You are doing things horribly wrong, fucknugget.") + Error("You are doing horribly wrong, fucknugget.") } world = gameSaveData.world @@ -1474,6 +1476,7 @@ class Ingame(val batch: SpriteBatch) : Screen { } override fun hide() { + dispose() } /** @@ -1524,6 +1527,7 @@ class Ingame(val batch: SpriteBatch) : Screen { override fun dispose() { worldDrawFrameBuffer.dispose() worldGlowFrameBuffer.dispose() + worldBlendFrameBuffer.dispose() lightmapFboA.dispose() lightmapFboB.dispose() } diff --git a/src/net/torvald/terrarum/LoadScreen.kt b/src/net/torvald/terrarum/LoadScreen.kt index dc68a10fb..044db2e04 100644 --- a/src/net/torvald/terrarum/LoadScreen.kt +++ b/src/net/torvald/terrarum/LoadScreen.kt @@ -1,8 +1,14 @@ package net.torvald.terrarum +import com.badlogic.gdx.Gdx import com.badlogic.gdx.Screen import com.badlogic.gdx.ScreenAdapter +import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.graphics.GL20 +import com.badlogic.gdx.graphics.OrthographicCamera import net.torvald.dataclass.HistoryArray +import net.torvald.terrarum.langpack.Lang +import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack /** * Created by minjaesong on 2017-07-13. @@ -12,21 +18,99 @@ object LoadScreen : ScreenAdapter() { private lateinit var actualSceneToBeLoaded: Screen private lateinit var sceneLoadingThread: Thread + private val messages = HistoryArray(20) - - - - fun setMessage(msg: String) { messages.add(msg) } - override fun show() { + + private var arrowObjPos = 0f // 0 means at starting position, regardless of screen position + private var arrowObjGlideOffsetX = 0f + private var arrowObjGlideSize = 0f + private var arrowGlideSpeed = Terrarum.WIDTH * 1.2f // pixels per sec + private lateinit var arrowObjTex: TextureRegionPack + private var glideTimer = 0f + private var glideDispY = 0f + private var arrowColours = arrayOf( + Color(0xff847fff.toInt()), + Color(0xffc87fff.toInt()), + Color(0xbffff2ff.toInt()), + Color(0x7fcaffff) + ) + + + var camera = OrthographicCamera(Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat()) + + fun initViewPort(width: Int, height: Int) { + //val width = if (width % 1 == 1) width + 1 else width + //val height = if (height % 1 == 1) height + 1 else width + + // Set Y to point downwards + camera.setToOrtho(true, width.toFloat(), height.toFloat()) + + // Update camera matrix + camera.update() + + // Set viewport to restrict drawing + Gdx.gl20.glViewport(0, 0, width, height) } + + + override fun show() { + initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT) + + arrowObjTex = TextureRegionPack(Gdx.files.internal("assets/graphics/test_loading_arrow_atlas.tga"), 22, 17) + arrowObjGlideOffsetX = -arrowObjTex.texture.width.toFloat() + arrowObjGlideSize = arrowObjTex.texture.width + 1.5f * Terrarum.WIDTH + glideDispY = Terrarum.HEIGHT - 140f + } + + + + private val textColour = Color(0xeeeeeeff.toInt()) + override fun render(delta: Float) { + Gdx.gl.glClearColor(.157f, .157f, .157f, 0f) + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) + + + glideTimer += delta + if (glideTimer >= arrowObjGlideSize / arrowGlideSpeed) { + glideTimer -= arrowObjGlideSize / arrowGlideSpeed + } + arrowObjPos = glideTimer * arrowGlideSpeed + + + Terrarum.batch.inUse { + it.projectionMatrix = camera.combined + + + it.color = textColour + val textWidth = Terrarum.fontGame.getWidth(Lang["MENU_IO_LOADING"]) + Terrarum.fontGame.draw(it, Lang["MENU_IO_LOADING"], (Terrarum.WIDTH - 2.5f * textWidth).round(), glideDispY - 2f) + + + arrowColours.forEachIndexed { index, color -> + it.color = color + it.draw(arrowObjTex.get(index, 0), arrowObjPos + arrowObjGlideOffsetX + 22 * index, glideDispY) + } + } } + + override fun dispose() { + arrowObjTex.dispose() + } + + override fun hide() { + dispose() + } + + override fun resize(width: Int, height: Int) { + initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT) + } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index fd4cf69c8..4219782e9 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -82,12 +82,6 @@ object Terrarum : Game() { // GLOBAL IMMUTABLE CONFIGS // ////////////////////////////// - val RENDER_FPS = getConfigInt("displayfps") - val USE_VSYNC = getConfigBoolean("usevsync") - var VSYNC = USE_VSYNC - val VSYNC_TRIGGER_THRESHOLD = 56 - - val WIDTH: Int get() = if (screenW!! % 2 == 0) screenW!! else screenW!! + 1 val HEIGHT: Int @@ -252,6 +246,16 @@ object Terrarum : Game() { init { + getDefaultDirectory() + createDirs() + + + // read config i guess...? + val readFromDisk = readConfigJson() + if (!readFromDisk) readConfigJson() // what's this for? + + + println("[Terrarum] os.arch = $systemArch") // debug info if (is32BitJVM) { @@ -273,12 +277,6 @@ object Terrarum : Game() { - getDefaultDirectory() - createDirs() - - val readFromDisk = readConfigJson() - if (!readFromDisk) readConfigJson() - environment = try { Controllers.getController(0) // test if controller exists if (getConfigString("pcgamepadenv") == "console") @@ -289,8 +287,16 @@ object Terrarum : Game() { catch (e: IndexOutOfBoundsException) { RunningEnvironment.PC } + } + + val RENDER_FPS = getConfigInt("displayfps") + val USE_VSYNC = getConfigBoolean("usevsync") + var VSYNC = USE_VSYNC + val VSYNC_TRIGGER_THRESHOLD = 56 + + override fun create() { TextureRegionPack.globalFlipY = true // !! TO MAKE LEGACY CODE RENDER ON ITS POSITION !! Gdx.graphics.isContinuousRendering = true @@ -330,6 +336,11 @@ object Terrarum : Game() { + gameLocale = getConfigString("language") + println("[Terrarum] locale = $gameLocale") + + + ModMgr // invoke Module Manager, will also invoke BlockCodex ItemCodex // invoke Item Codex @@ -340,7 +351,8 @@ object Terrarum : Game() { ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(8192, 2048, HQRNG().nextLong()) ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW - super.setScreen(ingame) + //super.setScreen(ingame) + super.setScreen(LoadScreen) } override fun render() { @@ -498,20 +510,37 @@ object Terrarum : Game() { return cfg as IntArray } + /** + * Get config from config file. If the entry does not exist, get from defaults; if the entry is not in the default, NullPointerException will be thrown + */ + private val defaultConfig = DefaultConfig.fetch() + private fun getConfigMaster(key: String): Any { - var cfg: Any? = null - try { - cfg = gameConfig[key.toLowerCase()]!! + val config = try { + gameConfig[key] } catch (e: NullPointerException) { - try { - cfg = DefaultConfig.fetch()[key.toLowerCase()] + null + } + + val defaults = try { + defaultConfig.get(key) + } + catch (e: NullPointerException) { + null + } + + if (config == null) { + if (defaults == null) { + throw NullPointerException("key not found: '$key'") } - catch (e1: NullPointerException) { - e.printStackTrace() + else { + return defaults } } - return cfg!! + else { + return config + } } fun setConfig(key: String, value: Any) { diff --git a/src/net/torvald/terrarum/itemproperties/ItemCodex.kt b/src/net/torvald/terrarum/itemproperties/ItemCodex.kt index 65d636356..4b3d63a51 100644 --- a/src/net/torvald/terrarum/itemproperties/ItemCodex.kt +++ b/src/net/torvald/terrarum/itemproperties/ItemCodex.kt @@ -36,6 +36,9 @@ object ItemCodex { init { + + println("[ItemCodex] recording item ID ") + // blocks.csvs are loaded by ModMgr beforehand // block items (blocks and walls are the same thing basically) for (i in ITEM_TILES + ITEM_WALLS) { @@ -53,7 +56,7 @@ object ItemCodex { override val material = Material(0,0,0,0,0,0,0,0,0,0.0) init { - println("[ItemCodex] recording item ID $originalID") + print("$originalID ") } override fun primaryUse(delta: Float): Boolean { @@ -165,6 +168,10 @@ object ItemCodex { // read from save (if applicable) and fill dynamicItemDescription + + + + println() } /** diff --git a/work_files/graphics/nowloading_arrow.psd b/work_files/graphics/nowloading_arrow.psd index 1b18200f3..1d317715b 100644 --- a/work_files/graphics/nowloading_arrow.psd +++ b/work_files/graphics/nowloading_arrow.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b76b67a7d98f7d2f52caf9b975af839ed1d2f2e435926b5293a789750f86c0a -size 41682 +oid sha256:3ebda967858468d97a372cc69aa49e68e63fac0f424704aad5ed030a36f7d7cc +size 43700