diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 07a549f09..23e187679 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -17,6 +17,7 @@ import net.torvald.terrarum.AppLoader.* import net.torvald.terrarum.gameactors.Actor import net.torvald.terrarum.gameactors.ActorID import net.torvald.terrarum.itemproperties.ItemCodex +import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.worlddrawer.CreateTileAtlas import net.torvald.terrarum.worlddrawer.WorldCamera import net.torvald.terrarumsansbitmap.gdx.GameFontBase @@ -26,7 +27,6 @@ import java.io.File import java.io.PrintStream import kotlin.math.absoluteValue import kotlin.math.round -import kotlin.math.roundToInt @@ -578,3 +578,48 @@ fun printStackTrace(obj: Any, out: PrintStream = System.out) { } } } + +class UIContainer { + private val data = ArrayList() + fun add(vararg things: Any) { + things.forEach { + if (it is UICanvas || it is Id_UICanvasNullable) + data.add(it) + else throw IllegalArgumentException(it.javaClass.name) } + } + + fun iterator() = object : Iterator { + private var cursor = 0 + + override fun hasNext() = cursor < data.size + + override fun next(): UICanvas? { + val it = data[cursor] + // whatever the fucking reason when() does not work + if (it is UICanvas) { + cursor += 1 + return it + } + else if (it is Id_UICanvasNullable) { + cursor += 1 + return it.get() + } + else throw IllegalArgumentException("Unacceptable type ${it.javaClass.name}, instance of ${it.javaClass.superclass.name}") + } + } + + fun forEach(operation: (UICanvas?) -> Unit) = iterator().forEach(operation) + fun countVisible(): Int { + var c = 0 + forEach { if (it?.isVisible == true) c += 1 } + return c + } + + fun contains(element: Any) = data.contains(element) + + fun map(transformation: (UICanvas?) -> T) = iterator().asSequence().map(transformation) +} + +interface Id_UICanvasNullable { + fun get(): UICanvas? +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/TitleScreen.kt b/src/net/torvald/terrarum/TitleScreen.kt index 3d8c47ca0..2abd0113a 100644 --- a/src/net/torvald/terrarum/TitleScreen.kt +++ b/src/net/torvald/terrarum/TitleScreen.kt @@ -114,7 +114,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) { private val gradWhiteBottom = Color(0xd8d8d8ff.toInt()) - val uiContainer = ArrayList() + val uiContainer = UIContainer() private lateinit var uiMenu: UICanvas private lateinit var worldFBO: FrameBuffer @@ -242,7 +242,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) { if (!demoWorld.layerTerrain.ptr.destroyed) { // FIXME q&d hack to circumvent the dangling pointer issue #26 - IngameRenderer.invoke(gamePaused = false, uisToDraw = uiContainer) + IngameRenderer.invoke(gamePaused = false, uiContainer = uiContainer) } else { printdbgerr(this, "Demoworld is already been destroyed") diff --git a/src/net/torvald/terrarum/gamecontroller/IngameController.kt b/src/net/torvald/terrarum/gamecontroller/IngameController.kt index 2fa7d8198..50eaaacff 100644 --- a/src/net/torvald/terrarum/gamecontroller/IngameController.kt +++ b/src/net/torvald/terrarum/gamecontroller/IngameController.kt @@ -113,8 +113,8 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { } } - terrarumIngame.uiContainer.forEach { it.keyDown(keycode) } // for KeyboardControlled UIcanvases - + terrarumIngame.uiContainer.forEach { it?.keyDown(keycode) } // for KeyboardControlled UIcanvases + // Debug UIs if (keycode == Input.Keys.GRAVE) { terrarumIngame.consoleHandler.toggleOpening() @@ -138,9 +138,8 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { terrarumIngame.uiQuickBar.setAsOpen() } - terrarumIngame.uiContainer.forEach { it.keyUp(keycode) } // for KeyboardControlled UIcanvases - - + terrarumIngame.uiContainer.forEach { it?.keyUp(keycode) } // for KeyboardControlled UIcanvases + // screenshot key if (keycode == Input.Keys.F12) f12Down = false @@ -149,12 +148,12 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { } override fun keyTyped(character: Char): Boolean { - terrarumIngame.uiContainer.forEach { if (it.isVisible) it.keyTyped(character) } + terrarumIngame.uiContainer.forEach { if (it?.isVisible == true) it.keyTyped(character) } return true } override fun mouseMoved(screenX: Int, screenY: Int): Boolean { - terrarumIngame.uiContainer.forEach { it.mouseMoved(screenX, screenY) } + terrarumIngame.uiContainer.forEach { it?.mouseMoved(screenX, screenY) } return true } @@ -162,7 +161,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { // don't separate Player from this! Physics will break, esp. airborne manoeuvre if (!terrarumIngame.paused) { // fire world click events; the event is defined as Ingame's (or any others') WorldClick event - if (terrarumIngame.uiContainer.map { if ((it.isOpening || it.isOpened) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right? + if (terrarumIngame.uiContainer.map { if ((it?.isOpening == true || it?.isOpened == true) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right? if ( button == AppLoader.getConfigInt("config_mouseprimary") || @@ -181,8 +180,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { terrarumIngame.uiQuickBar.setAsOpen() } - terrarumIngame.uiContainer.forEach { it.touchUp(screenX, screenY, pointer, button) } // for MouseControlled UIcanvases - + terrarumIngame.uiContainer.forEach { it?.touchUp(screenX, screenY, pointer, button) } // for MouseControlled UIcanvases return true } @@ -197,18 +195,18 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { } } - terrarumIngame.uiContainer.forEach { it.scrolled(amount) } + terrarumIngame.uiContainer.forEach { it?.scrolled(amount) } return true } override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { - terrarumIngame.uiContainer.forEach { it.touchDragged(screenX, screenY, pointer) } + terrarumIngame.uiContainer.forEach { it?.touchDragged(screenX, screenY, pointer) } return true } override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { - terrarumIngame.uiContainer.forEach { it.touchDown(screenX, screenY, pointer, button) } - + terrarumIngame.uiContainer.forEach { it?.touchDown(screenX, screenY, pointer, button) } + // pie menu if (button == AppLoader.getConfigInt("config_mousequicksel")) { terrarumIngame.uiPieMenu.setAsOpen() diff --git a/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt b/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt index 8fad920b8..ef9e91f28 100644 --- a/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt +++ b/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt @@ -116,7 +116,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) { val uiPenMenu = UIBuildingMakerPenMenu(this) - val uiContainer = ArrayList() + val uiContainer = UIContainer() private val pensMustShowSelection = arrayOf( PENMODE_MARQUEE, PENMODE_MARQUEE_ERASE @@ -392,7 +392,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) { private fun renderGame() { _testMarkerDrawCalls = 0L - IngameRenderer.invoke(false, actorsRenderOverlay = if (showSelection) actorsRenderOverlay + essentialOverlays else essentialOverlays, uisToDraw = uiContainer) + IngameRenderer.invoke(false, actorsRenderOverlay = if (showSelection) actorsRenderOverlay + essentialOverlays else essentialOverlays, uiContainer = uiContainer) AppLoader.setDebugTime("Test.MarkerDrawCalls", _testMarkerDrawCalls) } diff --git a/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt b/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt index 01da3f60e..91dd85acc 100644 --- a/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt +++ b/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt @@ -173,7 +173,7 @@ object IngameRenderer : Disposable { actorsRenderOverlay: List? = null, particlesContainer : CircularArray? = null, player: ActorWithBody? = null, - uisToDraw: List? = null + uiContainer: UIContainer? = null ) { renderingActorsCount = (actorsRenderBehind?.size ?: 0) + (actorsRenderMiddle?.size ?: 0) + @@ -182,15 +182,9 @@ object IngameRenderer : Disposable { (actorsRenderOverlay?.size ?: 0) //renderingParticleCount = particlesContainer?.size ?: 0 //renderingParticleCount = (particlesContainer?.buffer?.map { (!it.flagDespawn).toInt() } ?: listOf(0)).sum() - renderingUIsCount = ((uisToDraw?.map { (it?.isVisible ?: false).toInt() }) ?: listOf(0)).sum() - + renderingUIsCount = uiContainer?.countVisible() ?: 0 val zoom = Terrarum.ingame?.screenZoom ?: 1f - - if (uisToDraw != null) { - uiListToDraw = uisToDraw - } - invokeInit() batch.color = Color.WHITE @@ -331,7 +325,7 @@ object IngameRenderer : Disposable { batch.shader = null batch.color = Color.WHITE - uiListToDraw.forEach { + uiContainer?.forEach { it?.render(batch, camera) } } diff --git a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt index ae72fb9c4..3e3254ef9 100644 --- a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt +++ b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt @@ -4,8 +4,8 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.g2d.SpriteBatch +import com.badlogic.gdx.utils.GdxRuntimeException import net.torvald.EMDASH -import net.torvald.UnsafeHelper import net.torvald.terrarum.* import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.blockproperties.BlockPropUtil @@ -62,7 +62,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { //val actorContainerActive = ArrayList(ACTORCONTAINER_INITIAL_SIZE) //val actorContainerInactive = ArrayList(ACTORCONTAINER_INITIAL_SIZE) val particlesContainer = CircularArray(PARTICLES_MAX, true) - val uiContainer = ArrayList() + val uiContainer = UIContainer() private val actorsRenderBehind = ArrayList(ACTORCONTAINER_INITIAL_SIZE) private val actorsRenderMiddle = ArrayList(ACTORCONTAINER_INITIAL_SIZE) @@ -118,13 +118,20 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { * This will not allow multiple fixture UIs from popping up (does not prevent them actually being open) * because UI updating and rendering is whitelist-operated */ - var uiFixture: UICanvas? = null + private var uiFixture: UICanvas? = null set(value) { printdbg(this, "uiFixture change: $uiFixture -> $value") field?.let { it.setAsClose() } value?.let { uiFixturesHistory.add(it) } field = value } + + val getUIFixture = object : Id_UICanvasNullable { // quick workaround for the type erasure (you can't use lambda...) + override fun get(): UICanvas? { + return uiFixture + } + } + lateinit var uiInventoryContainer: UICanvas lateinit var uiVitalPrimary: UICanvas lateinit var uiVitalSecondary: UICanvas @@ -361,7 +368,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { // batch-process uiAliases // NOTE: UIs that should pause the game (e.g. Inventory) must have relevant codes ON THEIR SIDE - arrayListOf( + uiContainer.add( // drawn first //uiVitalPrimary, //uiVitalSecondary, @@ -373,13 +380,12 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { uiWatchTierOne, UIScreenZoom(), uiInventoryPlayer, - //uiInventoryContainer, + getUIFixture, uiTooltip, consoleHandler, uiCheatMotherfuckerNootNoot // drawn last - ).forEach { addUI(it) } - + ) ingameUpdateThread = ThreadIngameUpdate(this) @@ -605,8 +611,13 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { Gdx.graphics.setTitle(getCanonicalTitle()) filterVisibleActors() - uiContainer.forEach { it.update(Gdx.graphics.rawDeltaTime) } - uiFixture?.update(Gdx.graphics.rawDeltaTime) + uiContainer.forEach { + when (it) { + is UICanvas -> it.update(Gdx.graphics.rawDeltaTime) + is Id_UICanvasNullable -> it.get()?.update(Gdx.graphics.rawDeltaTime) + } + } + //uiFixture?.update(Gdx.graphics.rawDeltaTime) // deal with the uiFixture being closed if (uiFixture?.isClosed == true) { uiFixture = null } @@ -619,7 +630,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { visibleActorsRenderOverlay, particlesContainer, actorNowPlaying, - uiContainer + uiFixture + uiContainer// + uiFixture ) } @@ -828,7 +839,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { if (actor.referenceID == theRealGamer.referenceID || actor.referenceID == 0x51621D) // do not delete this magic throw RuntimeException("Attempted to remove player.") - val indexToDelete = actorContainerActive.searchForIndex(actor.referenceID!!) { it.referenceID!! } + val indexToDelete = actorContainerActive.searchForIndex(actor.referenceID) { it.referenceID!! } if (indexToDelete != null) { printdbg(this, "Removing actor $actor") printStackTrace(this) @@ -840,23 +851,23 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { if (actor is ActorWithBody) { when (actor.renderOrder) { Actor.RenderOrder.BEHIND -> { - val i = actorsRenderBehind.binarySearch(actor.referenceID!!) + val i = actorsRenderBehind.binarySearch(actor.referenceID) actorsRenderBehind.removeAt(i) } Actor.RenderOrder.MIDDLE -> { - val i = actorsRenderMiddle.binarySearch(actor.referenceID!!) + val i = actorsRenderMiddle.binarySearch(actor.referenceID) actorsRenderMiddle.removeAt(i) } Actor.RenderOrder.MIDTOP -> { - val i = actorsRenderMidTop.binarySearch(actor.referenceID!!) + val i = actorsRenderMidTop.binarySearch(actor.referenceID) actorsRenderMidTop.removeAt(i) } Actor.RenderOrder.FRONT -> { - val i = actorsRenderFront.binarySearch(actor.referenceID!!) + val i = actorsRenderFront.binarySearch(actor.referenceID) actorsRenderFront.removeAt(i) } Actor.RenderOrder.OVERLAY-> { - val i = actorsRenderOverlay.binarySearch(actor.referenceID!!) + val i = actorsRenderOverlay.binarySearch(actor.referenceID) actorsRenderFront.removeAt(i) } } @@ -864,7 +875,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { } } - private fun ArrayList<*>.binarySearch(actor: Actor) = this.binarySearch(actor.referenceID!!) + private fun ArrayList<*>.binarySearch(actor: Actor) = this.binarySearch(actor.referenceID) private fun ArrayList<*>.binarySearch(ID: Int): Int { // code from collections/Collections.kt @@ -892,7 +903,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { override fun addNewActor(actor: Actor?) { if (actor == null) return - if (AppLoader.IS_DEVELOPMENT_BUILD && theGameHasActor(actor.referenceID!!)) { + if (AppLoader.IS_DEVELOPMENT_BUILD && theGameHasActor(actor.referenceID)) { throw Error("The actor $actor already exists in the game") } else { @@ -924,8 +935,8 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { } fun activateDormantActor(actor: Actor) { - if (AppLoader.IS_DEVELOPMENT_BUILD && !isInactive(actor.referenceID!!)) { - if (isActive(actor.referenceID!!)) + if (AppLoader.IS_DEVELOPMENT_BUILD && !isInactive(actor.referenceID)) { + if (isActive(actor.referenceID)) throw Error("The actor $actor is already activated") else throw Error("The actor $actor already exists in the game") @@ -960,17 +971,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { particlesContainer.appendHead(particle) } - fun addUI(ui: UICanvas) { - // check for exact duplicates - if (uiContainer.contains(ui)) { - throw IllegalArgumentException( - "Exact copy of the UI already exists: The instance of ${ui.javaClass.simpleName}" - ) - } - - uiContainer.add(ui) - } - private fun insertionSortLastElemAV(arr: ArrayList) { // out-projection doesn't work, duh ReentrantLock().lock { var j = arr.lastIndex - 1 @@ -1003,7 +1003,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { } override fun hide() { - uiContainer.forEach { it.handler.dispose() } + uiContainer.forEach { it?.handler?.dispose() } } @@ -1063,15 +1063,17 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { actorsRenderOverlay.forEach { it.dispose() } uiContainer.forEach { - it.handler.dispose() - it.dispose() + it?.handler?.dispose() + it?.dispose() } uiFixturesHistory.forEach { - it.handler.dispose() - it.dispose() + try { + it.handler.dispose() + it.dispose() + } + catch (e: GdxRuntimeException) {} } super.dispose() } - } diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureStorageChest.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureStorageChest.kt index 742902215..a411c7cdc 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureStorageChest.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureStorageChest.kt @@ -44,9 +44,7 @@ internal object UIStorageChest : UICanvas(), HasInventory { override var height = 512 override var openCloseTime: Second = 0.0f - private val negotiator = object : InventoryNegotiator { - override fun getItemFilter(): List = listOf(CAT_ALL) - + private val negotiator = object : InventoryNegotiator() { override fun accept(item: GameItem, amount: Int) { TODO("Not yet implemented") } @@ -66,32 +64,38 @@ internal object UIStorageChest : UICanvas(), HasInventory { TODO("Not yet implemented") } + private lateinit var catBar: UIItemInventoryCatBar + + private lateinit var itemList: UIItemInventoryItemGrid + init { + catBar = UIItemInventoryCatBar( + this, + 100, + 50, + 500, + 500, + { itemList.rebuild(catBar.catIconsMeaning[catBar.selectedIcon]) }, + false + ) + itemList = UIItemInventoryItemGrid( + this, + catBar, + Terrarum.ingame!!.actorNowPlaying!!.inventory, // just for a placeholder... + 100, + 100, + 4, 5, + drawScrollOnRightside = true, + drawWallet = true, + listRebuildFun = { itemListUpdate() } + ) + handler.allowESCtoClose = true + + addUIitem(catBar) + addUIitem(itemList) } - private val catBar = UIItemInventoryCatBar( - this, - 100, - 50, - 500, - 500, - {}, - false - ) - - private val itemList = UIItemInventoryItemGrid( - this, - catBar, - Terrarum.ingame!!.actorNowPlaying!!.inventory, // just for a placeholder... - 100, - 100, - 4, 5, - drawScrollOnRightside = true, - drawWallet = true, - listRebuildFun = { itemListUpdate() } - ) - private fun itemListUpdate() { itemList.rebuild(catBar.catIconsMeaning[catBar.selectedIcon]) } @@ -104,6 +108,7 @@ internal object UIStorageChest : UICanvas(), HasInventory { override fun renderUI(batch: SpriteBatch, camera: Camera) { batch.color = Color.WHITE + catBar.render(batch, camera) itemList.render(batch, camera) } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/InventoryNegotiator.kt b/src/net/torvald/terrarum/modulebasegame/ui/InventoryNegotiator.kt index 718e3893e..bc927ee7e 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/InventoryNegotiator.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/InventoryNegotiator.kt @@ -1,15 +1,16 @@ package net.torvald.terrarum.modulebasegame.ui +import net.torvald.terrarum.UIItemInventoryCatBar.Companion.CAT_ALL import net.torvald.terrarum.gameitem.GameItem /** * Created by minjaesong on 2021-03-12. */ -interface InventoryNegotiator { +abstract class InventoryNegotiator { /** Retrieve item filter to be used to show only the acceptable items when player's own inventory is being displayed */ - fun getItemFilter(): List // GameItem.Category + open fun getItemFilter(): List = listOf(CAT_ALL) // GameItem.Category /** Accepts item from the player and pass it to right inventory (object), slot (UI), etc... */ - fun accept(item: GameItem, amount: Int = 1) + abstract fun accept(item: GameItem, amount: Int = 1) /** Rejects item and perhaps returns it back to the player, or make explosion, etc... */ - fun reject(item: GameItem, amount: Int = 1) + abstract fun reject(item: GameItem, amount: Int = 1) } \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt index 635314b4e..9540473f6 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIItemInventoryItemGrid.kt @@ -221,6 +221,8 @@ class UIItemInventoryItemGrid( gridModeButtons[1].highlighted = false itemPage = 0 rebuild(currentFilter) + + println("ItemGridMode 0 touchdown") } gridModeButtons[1].touchDownListener = { _, _, _, _ -> isCompactMode = true @@ -228,6 +230,8 @@ class UIItemInventoryItemGrid( gridModeButtons[1].highlighted = true itemPage = 0 rebuild(currentFilter) + + println("ItemGridMode 1 touchdown") } scrollUpButton.clickOnceListener = { _, _, _ -> diff --git a/src/net/torvald/terrarum/ui/UICanvas.kt b/src/net/torvald/terrarum/ui/UICanvas.kt index a05be8a26..f63e256df 100644 --- a/src/net/torvald/terrarum/ui/UICanvas.kt +++ b/src/net/torvald/terrarum/ui/UICanvas.kt @@ -65,10 +65,6 @@ abstract class UICanvas( */ val handler = UIHandler(toggleKeyLiteral, toggleButtonLiteral, customPositioning, doNotWarnConstant) - init { - - } - /** * In milliseconds * @@ -285,6 +281,9 @@ abstract class UICanvas( // end of handler func aliases + init { + if (uiItems.isEmpty()) println("UICanvas '${this.javaClass.name}' has no UIItem registered, just so you know...") + } companion object { const val OPENCLOSE_GENERIC = 0.2f diff --git a/src/net/torvald/terrarum/ui/UIItem.kt b/src/net/torvald/terrarum/ui/UIItem.kt index 67d201985..c4dbf0eb2 100644 --- a/src/net/torvald/terrarum/ui/UIItem.kt +++ b/src/net/torvald/terrarum/ui/UIItem.kt @@ -193,6 +193,8 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I return false } open fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + println("uiitem ${this.javaClass.name} touchdown") + var actionDone = false if (parentUI.isVisible) {