diff --git a/src/net/torvald/terrarum/Ingame.kt b/src/net/torvald/terrarum/Ingame.kt index 744611bde..02db095cf 100644 --- a/src/net/torvald/terrarum/Ingame.kt +++ b/src/net/torvald/terrarum/Ingame.kt @@ -1459,6 +1459,9 @@ class Ingame(val batch: SpriteBatch) : Screen { uiWatchBasic.setPosition(Terrarum.WIDTH - uiWatchBasic.width, 0) uiWatchTierOne.setPosition(Terrarum.WIDTH - uiWatchTierOne.width, uiWatchBasic.height - 2) } + + + println("[Ingame] Resize event") } override fun dispose() { diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 37ff35a9e..56db3d33f 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -247,6 +247,7 @@ object Terrarum : Screen { /** Actually just a mesh of four vertices, two triangles -- not a literal glQuad */ lateinit var fullscreenQuad: Mesh; private set + private var fullscreenQuadInit = false val deltaTime: Float; get() = Gdx.graphics.rawDeltaTime @@ -321,6 +322,27 @@ object Terrarum : Screen { } val MINIMAL_GL_MAX_TEXTURE_SIZE = 4096 + private fun initFullscreenQuad() { + if (!fullscreenQuadInit) { + fullscreenQuad = Mesh( + true, 4, 6, + VertexAttribute.Position(), + VertexAttribute.ColorUnpacked(), + VertexAttribute.TexCoords(0) + ) + fullscreenQuadInit = true + } + } + private fun updateFullscreenQuad(WIDTH: Int, HEIGHT: Int) { + initFullscreenQuad() + fullscreenQuad.setVertices(floatArrayOf( + 0f, 0f, 0f, 1f, 1f, 1f, 1f, 0f, 1f, + WIDTH.toFloat(), 0f, 0f, 1f, 1f, 1f, 1f, 1f, 1f, + WIDTH.toFloat(), HEIGHT.toFloat(), 0f, 1f, 1f, 1f, 1f, 1f, 0f, + 0f, HEIGHT.toFloat(), 0f, 1f, 1f, 1f, 1f, 0f, 0f + )) + fullscreenQuad.setIndices(shortArrayOf(0, 1, 2, 2, 3, 0)) + } override fun show() { if (environment != RunningEnvironment.MOBILE) { @@ -340,23 +362,7 @@ object Terrarum : Screen { } - - fullscreenQuad = Mesh( - true, 4, 6, - VertexAttribute.Position(), - VertexAttribute.ColorUnpacked(), - VertexAttribute.TexCoords(0) - ) - - fullscreenQuad.setVertices(floatArrayOf( - 0f, 0f, 0f, 1f, 1f, 1f, 1f, 0f, 1f, - WIDTH.toFloat(), 0f, 0f, 1f, 1f, 1f, 1f, 1f, 1f, - WIDTH.toFloat(), HEIGHT.toFloat(), 0f, 1f, 1f, 1f, 1f, 1f, 0f, - 0f, HEIGHT.toFloat(), 0f, 1f, 1f, 1f, 1f, 0f, 0f - )) - fullscreenQuad.setIndices(shortArrayOf(0, 1, 2, 2, 3, 0)) - - + updateFullscreenQuad(WIDTH, HEIGHT) @@ -501,19 +507,12 @@ object Terrarum : Screen { // re-calculate fullscreen quad - fullscreenQuad.setVertices(floatArrayOf( - 0f, 0f, 0f, 1f, 1f, 1f, 1f, 0f, 1f, - Terrarum.WIDTH.toFloat(), 0f, 0f, 1f, 1f, 1f, 1f, 1f, 1f, - Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat(), 0f, 1f, 1f, 1f, 1f, 1f, 0f, - 0f, Terrarum.HEIGHT.toFloat(), 0f, 1f, 1f, 1f, 1f, 0f, 0f - )) - fullscreenQuad.setIndices(shortArrayOf(0, 1, 2, 2, 3, 0)) - + updateFullscreenQuad(screenW, screenH) //appLoader.resize(width, height) //Gdx.graphics.setWindowedMode(width, height) - println("newsize: ${Gdx.graphics.width}x${Gdx.graphics.height}") + println("[Terrarum] newsize: ${Gdx.graphics.width}x${Gdx.graphics.height} | internal: ${width}x$height") } @@ -550,8 +549,9 @@ object Terrarum : Screen { defaultSaveDir = defaultDir + "/Saves" configDir = defaultDir + "/config.json" - println("[Terrarum] os.name = $OSName") + println("[Terrarum] os.name = $OSName (with identifier $OperationSystem)") println("[Terrarum] os.version = $OSVersion") + println("[Terrarum] default directory: $defaultDir") } private fun createDirs() { diff --git a/src/net/torvald/terrarum/TerrarumAppLoader.java b/src/net/torvald/terrarum/TerrarumAppLoader.java index a0048af9a..d425e5838 100644 --- a/src/net/torvald/terrarum/TerrarumAppLoader.java +++ b/src/net/torvald/terrarum/TerrarumAppLoader.java @@ -178,7 +178,10 @@ public class TerrarumAppLoader implements ApplicationListener { public void resize(int width, int height) { //initViewPort(width, height); + Terrarum.INSTANCE.resize(width, height); if (screen != null) screen.resize(width, height); + + System.out.println("[AppLoader] Resize event"); } @Override diff --git a/src/net/torvald/terrarum/utils/JsonFetcher.kt b/src/net/torvald/terrarum/utils/JsonFetcher.kt index f40dade3d..4b381d8e8 100644 --- a/src/net/torvald/terrarum/utils/JsonFetcher.kt +++ b/src/net/torvald/terrarum/utils/JsonFetcher.kt @@ -19,26 +19,34 @@ object JsonFetcher { @Throws(java.io.IOException::class) operator fun invoke(jsonFilePath: String): com.google.gson.JsonObject { - net.torvald.terrarum.utils.JsonFetcher.jsonString = StringBuffer() // reset buffer every time it called - net.torvald.terrarum.utils.JsonFetcher.readJsonFileAsString(jsonFilePath) + jsonString = StringBuffer() // reset buffer every time it called + readJsonFileAsString(jsonFilePath) println("[JsonFetcher] Reading JSON $jsonFilePath") + if (jsonString == null) { + throw Error("[JsonFetcher] jsonString is null!") + } + val jsonParser = com.google.gson.JsonParser() - val jsonObj = jsonParser.parse(net.torvald.terrarum.utils.JsonFetcher.jsonString!!.toString()).asJsonObject + val jsonObj = jsonParser.parse(jsonString.toString()).asJsonObject return jsonObj } @Throws(java.io.IOException::class) operator fun invoke(jsonFile: java.io.File): com.google.gson.JsonObject { - net.torvald.terrarum.utils.JsonFetcher.jsonString = StringBuffer() // reset buffer every time it called - net.torvald.terrarum.utils.JsonFetcher.readJsonFileAsString(jsonFile.canonicalPath) + jsonString = StringBuffer() // reset buffer every time it called + readJsonFileAsString(jsonFile.canonicalPath) println("[JsonFetcher] Reading JSON ${jsonFile.path}") + if (jsonString == null) { + throw Error("[JsonFetcher] jsonString is null!") + } + val jsonParser = com.google.gson.JsonParser() - val jsonObj = jsonParser.parse(net.torvald.terrarum.utils.JsonFetcher.jsonString!!.toString()).asJsonObject + val jsonObj = jsonParser.parse(jsonString.toString()).asJsonObject return jsonObj } @@ -46,7 +54,7 @@ object JsonFetcher { private fun readJsonFileAsString(path: String) { try { java.nio.file.Files.lines(java.nio.file.FileSystems.getDefault().getPath(path)).forEach( - { net.torvald.terrarum.utils.JsonFetcher.jsonString!!.append(it) } + { jsonString!!.append(it) } ) // JSON does not require line break } catch (e: IOException) { diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt index e4a57ff05..53350d5b8 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt @@ -802,6 +802,10 @@ object BlocksDrawer { oldScreenW = screenW oldScreenH = screenH + + + println("[BlocksDrawerNew] Resize event") + } fun clampH(x: Int): Int { diff --git a/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt b/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt index bedcf37f9..ac9c7a94a 100644 --- a/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt +++ b/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt @@ -118,8 +118,8 @@ object LightmapRenderer { } fun fireRecalculateEvent() { - for_x_start = WorldCamera.x / TILE_SIZE - 1 // fix for premature lightmap rendering - for_y_start = WorldCamera.y / TILE_SIZE - 1 // on topmost/leftmost side + for_x_start = WorldCamera.x / TILE_SIZE // fix for premature lightmap rendering + for_y_start = WorldCamera.y / TILE_SIZE // on topmost/leftmost side for_x_end = for_x_start + WorldCamera.width / TILE_SIZE + 3 for_y_end = for_y_start + WorldCamera.height / TILE_SIZE + 2 // same fix as above @@ -565,6 +565,10 @@ object LightmapRenderer { // make sure the BlocksDrawer is resized first! lightBuffer = Pixmap(BlocksDrawer.tilesInHorizontal, BlocksDrawer.tilesInVertical, Pixmap.Format.RGBA8888) + + + + println("[LightmapRendererNew] Resize event") } diff --git a/work_files/graphics/fonts/telegraph/5x5_ibm_bcd.psd b/work_files/graphics/fonts/telegraph/5x5_ibm_bcd.psd index d4560dcae..8ccbcfa93 100644 --- a/work_files/graphics/fonts/telegraph/5x5_ibm_bcd.psd +++ b/work_files/graphics/fonts/telegraph/5x5_ibm_bcd.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ee67066a5755ccc2d9a32f9d861f9880c65b3e4e1e14827882d48458f03ee043 -size 37510 +oid sha256:aad8dc0397ab66f1e35ed417555a0a8f63a85bfcb209104d34dc6c2ad6bd9612 +size 41220