From 70695287148cb9e4d7ad1b4711047a9e3b33f55d Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sat, 15 Sep 2018 01:08:10 +0900 Subject: [PATCH] title remocon: menu UI with no child should be displayed now --- src/net/torvald/terrarum/AppLoader.java | 42 +++++++--- src/net/torvald/terrarum/GdxColorMap.kt | 2 +- src/net/torvald/terrarum/ModMgr.kt | 12 +-- src/net/torvald/terrarum/Terrarum.kt | 24 +++--- src/net/torvald/terrarum/TitleScreen.kt | 17 ++-- .../terrarum/blockproperties/BlockCodex.kt | 3 +- .../terrarum/gameactors/ActorWBMovable.kt | 9 +- src/net/torvald/terrarum/langpack/Lang.kt | 11 ++- .../terrarum/modulebasegame/EntryPoint.kt | 7 +- .../torvald/terrarum/modulebasegame/Ingame.kt | 5 +- .../terrarum/modulebasegame/ui/UIRemoCon.kt | 83 ++++++++++--------- .../modulebasegame/ui/UITitleLanguage.kt | 3 +- .../modulebasegame/ui/UITitleWallOfText.kt | 5 +- src/net/torvald/terrarum/utils/CSVFetcher.kt | 4 +- src/net/torvald/terrarum/utils/JsonFetcher.kt | 7 +- .../terrarum/worlddrawer/BlocksDrawerNew.kt | 3 +- .../worlddrawer/LightmapRendererNew.kt | 5 +- 17 files changed, 146 insertions(+), 96 deletions(-) diff --git a/src/net/torvald/terrarum/AppLoader.java b/src/net/torvald/terrarum/AppLoader.java index f455f64b7..98f8fe55b 100644 --- a/src/net/torvald/terrarum/AppLoader.java +++ b/src/net/torvald/terrarum/AppLoader.java @@ -24,6 +24,20 @@ import java.util.Random; */ public class AppLoader implements ApplicationListener { + /** + * 0xAA_BB_XXXX + * AA: Major version + * BB: Minor version + * XXXX: Revision (Repository commits, or something arbitrary) + * + * e.g. 0x02010034 can be translated as 2.1.52 + */ + public static final int VERSION_RAW = 0x00_02_027C; + public static final boolean IS_DEVELOPMENT_BUILD = true; + + + + private static AppLoader INSTANCE = null; private AppLoader() { } @@ -66,16 +80,6 @@ public class AppLoader implements ApplicationListener { } } - - /** - * 0xAA_BB_XXXX - * AA: Major version - * BB: Minor version - * XXXX: Revision (Repository commits) - * - * e.g. 0x02010034 can be translated as 2.1.52 - */ - public static final int VERSION_RAW = 0x00_02_0270; public static final String getVERSION_STRING() { return String.format("%d.%d.%d", VERSION_RAW >>> 24, (VERSION_RAW & 0xff0000) >>> 16, VERSION_RAW & 0xFFFF); } @@ -261,7 +265,7 @@ public class AppLoader implements ApplicationListener { appConfig.width = Terrarum.INSTANCE.getWIDTH(); appConfig.height = Terrarum.INSTANCE.getHEIGHT(); - System.out.println("[AppLoader] Resize event"); + printdbg(this, "Resize event"); } @Override @@ -280,7 +284,7 @@ public class AppLoader implements ApplicationListener { } public void setScreen(Screen screen) { - System.out.println("[AppLoader] Changing screen to " + screen.getClass().getCanonicalName()); + printdbg(this, "Changing screen to " + screen.getClass().getCanonicalName()); if (this.screen != null) this.screen.hide(); this.screen = screen; @@ -289,7 +293,7 @@ public class AppLoader implements ApplicationListener { this.screen.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } - System.out.println("[AppLoader] Screen transisiton complete: " + this.screen.getClass().getCanonicalName()); + printdbg(this, "Screen transisiton complete: " + this.screen.getClass().getCanonicalName()); } private void setCameraPosition(float newX, float newY) { @@ -307,4 +311,16 @@ public class AppLoader implements ApplicationListener { }); fullscreenQuad.setIndices(new short[]{0, 1, 2, 2, 3, 0}); } + + + public static final void printdbg(Object obj, Object message) { + if (IS_DEVELOPMENT_BUILD) { + System.out.println("["+obj.getClass().getSimpleName()+"] "+message.toString()); + } + } + public static final void printdbgerr(Object obj, Object message) { + if (IS_DEVELOPMENT_BUILD) { + System.err.println("["+obj.getClass().getSimpleName()+"] "+message.toString()); + } + } } diff --git a/src/net/torvald/terrarum/GdxColorMap.kt b/src/net/torvald/terrarum/GdxColorMap.kt index 609164091..1decaad1a 100644 --- a/src/net/torvald/terrarum/GdxColorMap.kt +++ b/src/net/torvald/terrarum/GdxColorMap.kt @@ -22,7 +22,7 @@ class GdxColorMap { }) - println("[GdxColorMap] Loading colormap from ${imageFile.name()}; PixmapFormat: ${pixmap.format}; Dimension: $width x $height") + AppLoader.printdbg(this, "Loading colormap from ${imageFile.name()}; PixmapFormat: ${pixmap.format}; Dimension: $width x $height") pixmap.dispose() diff --git a/src/net/torvald/terrarum/ModMgr.kt b/src/net/torvald/terrarum/ModMgr.kt index 56a93b548..e23d5b492 100644 --- a/src/net/torvald/terrarum/ModMgr.kt +++ b/src/net/torvald/terrarum/ModMgr.kt @@ -2,6 +2,8 @@ package net.torvald.terrarum import com.badlogic.gdx.Gdx import com.badlogic.gdx.files.FileHandle +import net.torvald.terrarum.AppLoader.printdbg +import net.torvald.terrarum.AppLoader.printdbgerr import net.torvald.terrarum.utils.CSVFetcher import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.itemproperties.ItemCodex @@ -74,7 +76,7 @@ object ModMgr { loadOrder.forEachIndexed { index, it -> val moduleName = it[0] - println("[ModMgr] Loading module $moduleName") + printdbg(this, "Loading module $moduleName") try { val modMetadata = Properties() @@ -100,7 +102,7 @@ object ModMgr { val isDir = FileSystems.getDefault().getPath("$modDir/$moduleName").toFile().isDirectory moduleInfo[moduleName] = ModuleMetadata(index, isDir, properName, description, author, entryPoint, releaseDate, version, libs, dependency) - println(moduleInfo[moduleName]) + printdbg(this, moduleInfo[moduleName]) // run entry script in entry point @@ -114,13 +116,13 @@ object ModMgr { } - println("[ModMgr] $moduleName loaded successfully") + printdbg(this, "$moduleName loaded successfully") } catch (noSuchModule: FileNotFoundException) { - System.err.println("[ModMgr] No such module: $moduleName, skipping...") + printdbgerr(this, "No such module: $moduleName, skipping...") } catch (e: ClassNotFoundException) { - System.err.println("[ModMgr] $moduleName has nonexisting entry point, skipping...") + printdbgerr(this, "$moduleName has nonexisting entry point, skipping...") } } diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 993eb8c7c..9287ca5e5 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -14,6 +14,8 @@ import com.google.gson.JsonPrimitive import com.jme3.math.FastMath import net.torvald.dataclass.ArrayListMap import net.torvald.random.HQRNG +import net.torvald.terrarum.AppLoader.printdbg +import net.torvald.terrarum.AppLoader.printdbgerr import net.torvald.terrarum.gameactors.Actor import net.torvald.terrarum.gameactors.ActorID import net.torvald.terrarum.gameworld.GameWorld @@ -236,10 +238,10 @@ object Terrarum : Screen { - println("[Terrarum] os.arch = $systemArch") // debug info + printdbg(this, "os.arch = $systemArch") // debug info if (is32BitJVM) { - System.err.println("[Terrarum] 32 Bit JVM detected") + printdbgerr(this, "32 Bit JVM detected") } joypadLabelStart = when (getConfigString("joypadlabelstyle")) { @@ -303,9 +305,9 @@ object Terrarum : Screen { testTexture = Texture(Gdx.files.internal("./assets/test_texture.tga")) - println("[Terrarum] GL_VERSION = $GL_VERSION") - println("[Terrarum] GL_MAX_TEXTURE_SIZE = $GL_MAX_TEXTURE_SIZE") - println("[Terrarum] GL info:\n${Gdx.graphics.glVersion.debugVersionString}") // debug info + printdbg(this, "GL_VERSION = $GL_VERSION") + printdbg(this, "GL_MAX_TEXTURE_SIZE = $GL_MAX_TEXTURE_SIZE") + printdbg(this, "GL info:\n${Gdx.graphics.glVersion.debugVersionString}") // debug info if (GL_VERSION < MINIMAL_GL_VERSION || GL_MAX_TEXTURE_SIZE < MINIMAL_GL_MAX_TEXTURE_SIZE) { @@ -385,7 +387,7 @@ object Terrarum : Screen { AppLoader.GAME_LOCALE = getConfigString("language") - println("[Terrarum] locale = ${AppLoader.GAME_LOCALE}") + printdbg(this, "locale = ${AppLoader.GAME_LOCALE}") @@ -393,7 +395,7 @@ object Terrarum : Screen { - println("[Terrarum] all modules loaded successfully") + printdbg(this, "all modules loaded successfully") @@ -479,7 +481,7 @@ object Terrarum : Screen { //appLoader.resize(width, height) //Gdx.graphics.setWindowedMode(width, height) - println("[Terrarum] newsize: ${Gdx.graphics.width}x${Gdx.graphics.height} | internal: ${width}x$height") + printdbg(this, "newsize: ${Gdx.graphics.width}x${Gdx.graphics.height} | internal: ${width}x$height") } @@ -516,9 +518,9 @@ object Terrarum : Screen { defaultSaveDir = defaultDir + "/Saves" configDir = defaultDir + "/config.json" - println("[Terrarum] os.name = $OSName (with identifier $OperationSystem)") - println("[Terrarum] os.version = $OSVersion") - println("[Terrarum] default directory: $defaultDir") + printdbg(this, "os.name = $OSName (with identifier $OperationSystem)") + printdbg(this, "os.version = $OSVersion") + printdbg(this, "default directory: $defaultDir") } private fun createDirs() { diff --git a/src/net/torvald/terrarum/TitleScreen.kt b/src/net/torvald/terrarum/TitleScreen.kt index 4c852470a..ff0aad3e0 100644 --- a/src/net/torvald/terrarum/TitleScreen.kt +++ b/src/net/torvald/terrarum/TitleScreen.kt @@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.jme3.math.FastMath import net.torvald.random.HQRNG +import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.Actor @@ -120,7 +121,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen { private val TILE_SIZEF = TILE_SIZE.toFloat() private fun loadThingsWhileIntroIsVisible() { - println("[TitleScreen] Intro pre-load") + printdbg(this, "Intro pre-load") demoWorld = ReadLayerData(FileInputStream(ModMgr.getFile("basegame", "demoworld"))) @@ -172,7 +173,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen { } override fun show() { - println("[TitleScreen] atrniartsientsarinoetsar") + printdbg(this, "atrniartsientsarinoetsar") initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT) @@ -216,7 +217,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen { } fun updateScreen(delta: Float) { - Gdx.graphics.setTitle("WorldRenderTest" + + Gdx.graphics.setTitle(AppLoader.GAME_NAME + " — F: ${Gdx.graphics.framesPerSecond} (${Terrarum.TARGET_INTERNAL_FPS})" + " — M: ${Terrarum.memInUse}M / ${Terrarum.memTotal}M / ${Terrarum.memXmx}M" ) @@ -273,10 +274,16 @@ class TitleScreen(val batch: SpriteBatch) : Screen { COPYTING.forEachIndexed { index, s -> val textWidth = Terrarum.fontGame.getWidth(s) Terrarum.fontGame.draw(batch, s, - Terrarum.WIDTH - textWidth - 1f - 0.2f, - Terrarum.HEIGHT - Terrarum.fontGame.lineHeight * (COPYTING.size - index) - 1f + (Terrarum.WIDTH - textWidth - 1f).toInt().toFloat(), + (Terrarum.HEIGHT - Terrarum.fontGame.lineHeight * (COPYTING.size - index) - 1f).toInt().toFloat() ) } + + Terrarum.fontGame.draw(batch, "${AppLoader.GAME_NAME} ${AppLoader.getVERSION_STRING()}", + 1f.toInt().toFloat(), + (Terrarum.HEIGHT - Terrarum.fontGame.lineHeight - 1f).toInt().toFloat() + ) + } override fun pause() { diff --git a/src/net/torvald/terrarum/blockproperties/BlockCodex.kt b/src/net/torvald/terrarum/blockproperties/BlockCodex.kt index 6d6808094..ff5a9e9cd 100644 --- a/src/net/torvald/terrarum/blockproperties/BlockCodex.kt +++ b/src/net/torvald/terrarum/blockproperties/BlockCodex.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.blockproperties +import net.torvald.terrarum.AppLoader import net.torvald.terrarum.utils.CSVFetcher import net.torvald.terrarum.gameworld.MapLayer import net.torvald.terrarum.gameworld.PairedMapLayer @@ -27,7 +28,7 @@ object BlockCodex { try { val records = CSVFetcher.readFromModule(module, path) - println("[BlockCodex] Building block properties table") + AppLoader.printdbg(this, "Building block properties table") records.forEach { if (intVal(it, "id") == -1) { diff --git a/src/net/torvald/terrarum/gameactors/ActorWBMovable.kt b/src/net/torvald/terrarum/gameactors/ActorWBMovable.kt index 7a719d8a5..6eba1dbab 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWBMovable.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWBMovable.kt @@ -9,6 +9,7 @@ import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.worlddrawer.FeaturesDrawer import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.spriteanimation.SpriteAnimation +import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.worlddrawer.WorldCamera import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.BlockProp @@ -117,7 +118,7 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im if (value <= 0) throw IllegalArgumentException("mass cannot be less than or equal to zero.") else if (value < MASS_LOWEST) { - println("[ActorWBMovable] input too small; using $MASS_LOWEST instead.") + printdbg(this, "input too small; using $MASS_LOWEST instead.") actorValue[AVKey.BASEMASS] = MASS_LOWEST } @@ -130,7 +131,7 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im if (value < 0) throw IllegalArgumentException("invalid elasticity value $value; valid elasticity value is [0, 1].") else if (value >= ELASTICITY_MAX) { - println("[ActorWBMovable] Elasticity were capped to $ELASTICITY_MAX.") + printdbg(this, "Elasticity were capped to $ELASTICITY_MAX.") field = ELASTICITY_MAX } else @@ -1292,9 +1293,9 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im // warnings if (sprite == null && isVisible) - println("[ActorWBMovable] Caution: actor ${this.javaClass.simpleName} is visible but the sprite was not set.") + printdbg(this, "Caution: actor ${this.javaClass.simpleName} is visible but the sprite was not set.") else if (sprite != null && !isVisible) - println("[ActorWBMovable] Caution: actor ${this.javaClass.simpleName} is invisible but the sprite was given.") + printdbg(this, "Caution: actor ${this.javaClass.simpleName} is invisible but the sprite was given.") assertPrinted = true } diff --git a/src/net/torvald/terrarum/langpack/Lang.kt b/src/net/torvald/terrarum/langpack/Lang.kt index b29e0fa64..57132dde6 100644 --- a/src/net/torvald/terrarum/langpack/Lang.kt +++ b/src/net/torvald/terrarum/langpack/Lang.kt @@ -3,6 +3,7 @@ package net.torvald.terrarum.langpack import net.torvald.terrarum.utils.JsonFetcher import net.torvald.terrarum.Terrarum import net.torvald.terrarum.AppLoader +import net.torvald.terrarum.AppLoader.printdbg import java.io.* import java.util.* @@ -44,7 +45,7 @@ object Lang { } fun load(localesDir: String) { - println("[Lang] Loading languages from $localesDir") + printdbg(this, "Loading languages from $localesDir") val localesDir = File(localesDir) @@ -119,14 +120,16 @@ object Lang { if (key.startsWith("MENU_LABEL_PRESS_START_SYMBOL")) return ret2.replace('>', Terrarum.joypadLabelStart).capitalize() - return if (AppLoader.GAME_LOCALE.contains("bg")) - "${AppLoader.fontGame.charsetOverrideBulgarian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideNormal}" - else if (AppLoader.GAME_LOCALE.contains("sr")) + return if (key.getEndTag().contains("bg")) "${AppLoader.fontGame.charsetOverrideBulgarian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideNormal}" + else if (key.getEndTag().contains("sr")) + "${AppLoader.fontGame.charsetOverrideSerbian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideNormal}" else ret2.capitalize() } + private fun String.getEndTag() = this.split("_").last() + fun pluraliseLang(key: String, count: Int): String { return if (count > 1) get(key + "_PLURAL") else get(key) } diff --git a/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt b/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt index 585adbe98..d4f0eb2b5 100644 --- a/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt +++ b/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt @@ -1,5 +1,7 @@ package net.torvald.terrarum.modulebasegame +import net.torvald.terrarum.AppLoader.IS_DEVELOPMENT_BUILD +import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.Point2d import net.torvald.terrarum.ModMgr import net.torvald.terrarum.ModuleEntryPoint @@ -26,7 +28,7 @@ class EntryPoint : ModuleEntryPoint() { // load customised item loader // ///////////////////////////////// - println("[ModuleBaseGame.EntryPoint] recording item ID ") + printdbg(this, "recording item ID ") // blocks.csvs are loaded by ModMgr beforehand // block items (blocks and walls are the same thing basically) @@ -45,7 +47,8 @@ class EntryPoint : ModuleEntryPoint() { override val material = Material(0,0,0,0,0,0,0,0,0,0.0) init { - print("$originalID ") + if (IS_DEVELOPMENT_BUILD) + print("$originalID ") } override fun primaryUse(delta: Float): Boolean { diff --git a/src/net/torvald/terrarum/modulebasegame/Ingame.kt b/src/net/torvald/terrarum/modulebasegame/Ingame.kt index 27f668d11..d2a06b994 100644 --- a/src/net/torvald/terrarum/modulebasegame/Ingame.kt +++ b/src/net/torvald/terrarum/modulebasegame/Ingame.kt @@ -26,6 +26,7 @@ import java.util.concurrent.locks.ReentrantLock import net.torvald.random.HQRNG import net.torvald.terrarum.* +import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.modulebasegame.console.AVTracker import net.torvald.terrarum.modulebasegame.console.ActorsList import net.torvald.terrarum.console.Authenticator @@ -193,7 +194,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) { */ private fun enter(gameSaveData: GameSaveData) { if (gameInitialised) { - println("[Ingame] loaded successfully.") + printdbg(this, "loaded successfully.") } else { LoadScreen.addMessage("Loading world from save") @@ -221,7 +222,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) { */ private fun enter(worldParams: NewWorldParameters) { if (gameInitialised) { - println("[Ingame] loaded successfully.") + printdbg(this, "loaded successfully.") } else { LoadScreen.addMessage("${Terrarum.NAME} version ${AppLoader.getVERSION_STRING()}") diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIRemoCon.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIRemoCon.kt index dcbe8ab6b..46221891f 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIRemoCon.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIRemoCon.kt @@ -5,6 +5,8 @@ import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.g2d.SpriteBatch +import net.torvald.terrarum.AppLoader.printdbg +import net.torvald.terrarum.AppLoader.printdbgerr import net.torvald.terrarum.Second import net.torvald.terrarum.Terrarum import net.torvald.terrarum.ui.UICanvas @@ -22,6 +24,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { private var remoConTray: UIRemoConElement // this remocon is dynamically generated private var currentRemoConContents = treeRepresentation + private var currentlySelectedRemoConItem = treeRepresentation.data override var width: Int get() = remoConWidth // somehow NOT making this constant causes a weird issue @@ -41,12 +44,17 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { val splittedNodeName = node.data?.split(yamlSep) if (splittedNodeName?.size == 2) { - val attachedClass = loadClass(splittedNodeName[1]) + try { + val attachedClass = loadClass(splittedNodeName[1]) - attachedClass.posX = 0 - attachedClass.posY = 0 + attachedClass.posX = 0 + attachedClass.posY = 0 - screens.add((node.data ?: "(null)") to attachedClass) + screens.add((node.data ?: "(null)") to attachedClass) + } + catch (e: java.lang.ClassNotFoundException) { + printdbgerr(this, "class '${splittedNodeName[1]}' was not found, skipping") + } } } } @@ -85,6 +93,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { remoConTray.consume() currentRemoConContents = currentRemoConContents.parent!! + currentlySelectedRemoConItem = currentRemoConContents.data remoConTray = generateNewRemoCon(currentRemoConContents) } else { @@ -98,12 +107,17 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { if (currentRemoConContents.children.size > selectedIndex ?: 0x7FFFFFFF) { + + val newCurrentRemoConContents = currentRemoConContents.children[selectedIndex!!] + // only go deeper if that node has child to navigate if (currentRemoConContents.children[selectedIndex!!].children.size != 0) { remoConTray.consume() - currentRemoConContents = currentRemoConContents.children[selectedIndex!!] - remoConTray = generateNewRemoCon(currentRemoConContents) + remoConTray = generateNewRemoCon(newCurrentRemoConContents) + currentRemoConContents = newCurrentRemoConContents } + + currentlySelectedRemoConItem = newCurrentRemoConContents.data } else { throw RuntimeException("Index: $selectedIndex, Size: ${currentRemoConContents.children.size}") @@ -112,23 +126,32 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { // do something with the actual selection - println(currentRemoConContents.data) + //printdbg(this, "$currentlySelectedRemoConItem") + screens.forEach { - if (currentRemoConContents.data == it.first) { + //printdbg(this, "> ${it.first}") + + if (currentlySelectedRemoConItem == it.first) { it.second.setAsOpen() + + //printdbg(this, ">> ding - ${it.second.javaClass.canonicalName}") } else { it.second.setAsClose() } - - it.second.update(delta) // update is required anyway - // but this is not updateUI, so whenever the UI is completely hidden, - // underlying handler will block any update until the UI is open again } } + screens.forEach { + it.second.update(delta) // update is required anyway + // but this is not updateUI, so whenever the UI is completely hidden, + // underlying handler will block any update until the UI is open again + } + + + if (!Gdx.input.isButtonPressed(Input.Buttons.LEFT)) { mouseActionAvailable = true } @@ -138,9 +161,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { remoConTray.render(batch, camera) screens.forEach { - if (currentRemoConContents.data == it.first) { - it.second.render(batch, camera) // again, underlying handler will block unnecessary renders - } + it.second.render(batch, camera) // again, underlying handler will block unnecessary renders } } @@ -166,9 +187,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { override fun mouseMoved(screenX: Int, screenY: Int): Boolean { screens.forEach { - if (currentRemoConContents.data == it.first) { - it.second.mouseMoved(screenX, screenY) // again, underlying handler will block unnecessary renders - } + it.second.mouseMoved(screenX, screenY) // again, underlying handler will block unnecessary renders } return true @@ -176,9 +195,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { screens.forEach { - if (currentRemoConContents.data == it.first) { - it.second.touchDragged(screenX, screenY, pointer) // again, underlying handler will block unnecessary renders - } + it.second.touchDragged(screenX, screenY, pointer) // again, underlying handler will block unnecessary renders } return true @@ -186,9 +203,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { screens.forEach { - if (currentRemoConContents.data == it.first) { - it.second.touchDown(screenX, screenY, pointer, button) // again, underlying handler will block unnecessary renders - } + it.second.touchDown(screenX, screenY, pointer, button) // again, underlying handler will block unnecessary renders } return true @@ -196,9 +211,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { screens.forEach { - if (currentRemoConContents.data == it.first) { - it.second.touchUp(screenX, screenY, pointer, button) // again, underlying handler will block unnecessary renders - } + it.second.touchUp(screenX, screenY, pointer, button) // again, underlying handler will block unnecessary renders } return true @@ -206,9 +219,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { override fun scrolled(amount: Int): Boolean { screens.forEach { - if (currentRemoConContents.data == it.first) { - it.second.scrolled(amount) // again, underlying handler will block unnecessary renders - } + it.second.scrolled(amount) // again, underlying handler will block unnecessary renders } return true @@ -216,9 +227,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { override fun keyDown(keycode: Int): Boolean { screens.forEach { - if (currentRemoConContents.data == it.first) { - it.second.keyDown(keycode) // again, underlying handler will block unnecessary renders - } + it.second.keyDown(keycode) // again, underlying handler will block unnecessary renders } return true @@ -226,9 +235,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { override fun keyUp(keycode: Int): Boolean { screens.forEach { - if (currentRemoConContents.data == it.first) { - it.second.keyUp(keycode) // again, underlying handler will block unnecessary renders - } + it.second.keyUp(keycode) // again, underlying handler will block unnecessary renders } return true @@ -236,9 +243,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode) : UICanvas() { override fun keyTyped(character: Char): Boolean { screens.forEach { - if (currentRemoConContents.data == it.first) { - it.second.keyTyped(character) // again, underlying handler will block unnecessary renders - } + it.second.keyTyped(character) // again, underlying handler will block unnecessary renders } return true diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UITitleLanguage.kt b/src/net/torvald/terrarum/modulebasegame/ui/UITitleLanguage.kt index 87f71ea84..b8402ec68 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UITitleLanguage.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UITitleLanguage.kt @@ -59,7 +59,8 @@ class UITitleLanguage : UICanvas() { override fun updateUI(delta: Float) { textArea.update(delta) - println("should be printing indefinitely") + + //AppLoader.printdbg(this, "should be printing indefinitely") } override fun renderUI(batch: SpriteBatch, camera: Camera) { diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UITitleWallOfText.kt b/src/net/torvald/terrarum/modulebasegame/ui/UITitleWallOfText.kt index cc3342b40..4c45293e6 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UITitleWallOfText.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UITitleWallOfText.kt @@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.g2d.SpriteBatch +import net.torvald.terrarum.AppLoader import net.torvald.terrarum.CreditSingleton import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Second @@ -10,7 +11,7 @@ import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UIItemTextArea import net.torvald.terrarum.ui.UIItemTextButtonList -open class UITitleWallOfText(text: List) : UICanvas() { +open class UITitleWallOfText(private val text: List) : UICanvas() { override var openCloseTime: Second = 0f @@ -37,6 +38,8 @@ open class UITitleWallOfText(text: List) : UICanvas() { override fun renderUI(batch: SpriteBatch, camera: Camera) { batch.color = Color.WHITE textArea.render(batch, camera) + + //AppLoader.printdbg(this, "Rendering texts of length ${text.size}") } override fun doOpening(delta: Float) { diff --git a/src/net/torvald/terrarum/utils/CSVFetcher.kt b/src/net/torvald/terrarum/utils/CSVFetcher.kt index c5ef0f417..f48c960ec 100644 --- a/src/net/torvald/terrarum/utils/CSVFetcher.kt +++ b/src/net/torvald/terrarum/utils/CSVFetcher.kt @@ -1,5 +1,7 @@ package net.torvald.terrarum.utils +import net.torvald.terrarum.AppLoader +import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.ModMgr import org.apache.commons.csv.CSVFormat import org.apache.commons.csv.CSVParser @@ -21,7 +23,7 @@ object CSVFetcher { net.torvald.terrarum.utils.CSVFetcher.csvString = StringBuffer() // reset buffer every time it called net.torvald.terrarum.utils.CSVFetcher.readCSVasString(csvFilePath) - println("[CSVFetcher] Reading CSV $csvFilePath") + printdbg(this, "Reading CSV $csvFilePath") val csvParser = org.apache.commons.csv.CSVParser.parse( net.torvald.terrarum.utils.CSVFetcher.csvString!!.toString(), diff --git a/src/net/torvald/terrarum/utils/JsonFetcher.kt b/src/net/torvald/terrarum/utils/JsonFetcher.kt index 4b381d8e8..bbd61e21b 100644 --- a/src/net/torvald/terrarum/utils/JsonFetcher.kt +++ b/src/net/torvald/terrarum/utils/JsonFetcher.kt @@ -2,6 +2,7 @@ package net.torvald.terrarum.utils import com.google.gson.JsonObject import com.google.gson.JsonParser +import net.torvald.terrarum.AppLoader.printdbg import java.io.File import java.io.IOException @@ -22,7 +23,7 @@ object JsonFetcher { jsonString = StringBuffer() // reset buffer every time it called readJsonFileAsString(jsonFilePath) - println("[JsonFetcher] Reading JSON $jsonFilePath") + printdbg(this, "Reading JSON $jsonFilePath") if (jsonString == null) { throw Error("[JsonFetcher] jsonString is null!") @@ -39,7 +40,7 @@ object JsonFetcher { jsonString = StringBuffer() // reset buffer every time it called readJsonFileAsString(jsonFile.canonicalPath) - println("[JsonFetcher] Reading JSON ${jsonFile.path}") + printdbg(this, "Reading JSON ${jsonFile.path}") if (jsonString == null) { throw Error("[JsonFetcher] jsonString is null!") @@ -58,7 +59,7 @@ object JsonFetcher { ) // JSON does not require line break } catch (e: IOException) { - System.err.println("An error occurred while reading $path") + System.err.println("[JsonFetcher] An error occurred while reading $path") e.printStackTrace() } } diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt index 7081d0680..e2c0feb17 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawerNew.kt @@ -10,6 +10,7 @@ import net.torvald.terrarum.gameworld.PairedMapLayer import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.terrarum.* +import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.ceilInt import net.torvald.terrarum.gameworld.fmod import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_TILES @@ -780,7 +781,7 @@ internal object BlocksDrawer { oldScreenH = screenH - println("[BlocksDrawerNew] Resize event") + printdbg(this, "Resize event") } diff --git a/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt b/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt index 8372f937f..c7bc0c41d 100644 --- a/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt +++ b/src/net/torvald/terrarum/worlddrawer/LightmapRendererNew.kt @@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.g2d.SpriteBatch import net.torvald.terrarum.blockproperties.BlockCodex import com.jme3.math.FastMath +import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.Terrarum import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.blockproperties.Block @@ -56,7 +57,7 @@ internal object LightmapRenderer { val overscan_opaque: Int = 8 init { - println("[LightmapRenderer] Overscan open: $overscan_open; opaque: $overscan_opaque") + printdbg(this, "Overscan open: $overscan_open; opaque: $overscan_opaque") } // TODO resize(int, int) -aware @@ -607,7 +608,7 @@ internal object LightmapRenderer { - println("[LightmapRendererNew] Resize event") + printdbg(this, "Resize event") }