diff --git a/src/net/torvald/terrarum/DefaultConfig.kt b/src/net/torvald/terrarum/DefaultConfig.kt index fbfe1d9c4..b63517c15 100644 --- a/src/net/torvald/terrarum/DefaultConfig.kt +++ b/src/net/torvald/terrarum/DefaultConfig.kt @@ -3,7 +3,6 @@ package net.torvald.terrarum import com.badlogic.gdx.Input import com.google.gson.JsonArray import com.google.gson.JsonObject -import net.torvald.terrarum.gamecontroller.Key /** * Keys must be all lowercase @@ -52,14 +51,14 @@ object DefaultConfig { jsonObject.addProperty("keydown", Input.Keys.D) jsonObject.addProperty("keyright", Input.Keys.F) - jsonObject.addProperty("keymovementaux", Input.Keys.A) // movement-auxiliary, or hookshot - jsonObject.addProperty("keyinventory", Input.Keys.W) + jsonObject.addProperty("keymovementaux", Input.Keys.W) // movement-auxiliary, or hookshot + jsonObject.addProperty("keyinventory", Input.Keys.Q) jsonObject.addProperty("keyinteract", Input.Keys.R) jsonObject.addProperty("keyclose", Input.Keys.C) jsonObject.addProperty("keygamemenu", Input.Keys.TAB) - jsonObject.addProperty("keyquicksel", Key.CAPS_LOCK) // pie menu - val keyquickselalt = JsonArray(); keyquickselalt.add(Input.Keys.BACKSPACE); keyquickselalt.add(Key.L_COMMAND); keyquickselalt.add(Input.Keys.CONTROL_LEFT) + jsonObject.addProperty("keyquicksel", Input.Keys.A) // pie menu (A) because GDX does not read CapsLock + val keyquickselalt = JsonArray(); keyquickselalt.add(Input.Keys.BACKSPACE); keyquickselalt.add(Input.Keys.CONTROL_LEFT) // Colemak, Workman and some typers use CapsLock as Backspace, Apple-JIS and HHKB has Control in place of CapsLock and often re-assigned to Command // so these keys are treated as the same. // FOR ~~FUCKS~~ERGONOMICS' SAKE DON'T USE CTRL AND ALT AS A KEY! diff --git a/src/net/torvald/terrarum/StateInGameGDX.kt b/src/net/torvald/terrarum/StateInGameGDX.kt index e29df2ce1..aa10a67f2 100644 --- a/src/net/torvald/terrarum/StateInGameGDX.kt +++ b/src/net/torvald/terrarum/StateInGameGDX.kt @@ -1,6 +1,7 @@ package net.torvald.terrarum import com.badlogic.gdx.Gdx +import com.badlogic.gdx.Input import com.badlogic.gdx.Screen import com.badlogic.gdx.graphics.* import com.badlogic.gdx.graphics.g2d.SpriteBatch @@ -14,7 +15,6 @@ import net.torvald.terrarum.console.* import net.torvald.terrarum.gameactors.* import net.torvald.terrarum.gameactors.physicssolver.CollisionSolver import net.torvald.terrarum.gamecontroller.GameController -import net.torvald.terrarum.gamecontroller.Key import net.torvald.terrarum.gamecontroller.KeyToggler import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.WorldSimulator @@ -31,7 +31,6 @@ import java.util.concurrent.locks.ReentrantLock import javax.swing.JOptionPane import com.badlogic.gdx.graphics.OrthographicCamera -import com.badlogic.gdx.graphics.glutils.ShapeRenderer import net.torvald.random.HQRNG import net.torvald.terrarum.ui.* import net.torvald.terrarum.worldgenerator.RoguelikeRandomiser @@ -82,8 +81,8 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen { private val useShader: Boolean = false private val shaderProgram = 0 - val KEY_LIGHTMAP_RENDER = Key.F7 - val KEY_LIGHTMAP_SMOOTH = Key.F8 + val KEY_LIGHTMAP_RENDER = Input.Keys.F7 + val KEY_LIGHTMAP_SMOOTH = Input.Keys.F8 @@ -181,6 +180,9 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen { fun enter() { + Gdx.input.inputProcessor = GameController + + initViewPort(Gdx.graphics.width, Gdx.graphics.height, Gdx.graphics.width.toFloat() / Gdx.graphics.height.toFloat()) @@ -498,9 +500,6 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen { } - println("Player: (${player?.hitbox?.centeredX}, ${player?.hitbox?.centeredY})") - - ///////////////////////////// // draw map related stuffs // diff --git a/src/net/torvald/terrarum/UIItemInventoryElem.kt b/src/net/torvald/terrarum/UIItemInventoryElem.kt index 5c97cccd9..9f5a73624 100644 --- a/src/net/torvald/terrarum/UIItemInventoryElem.kt +++ b/src/net/torvald/terrarum/UIItemInventoryElem.kt @@ -1,11 +1,10 @@ package net.torvald.terrarum +import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Color -import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.TextureRegion import net.torvald.colourutil.CIELabUtil.darkerLab -import net.torvald.terrarum.gamecontroller.Key import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.ui.UIInventory import net.torvald.terrarum.ui.UIItem @@ -122,10 +121,10 @@ class UIItemInventoryElem( } } - override fun keyPressed(key: Int, c: Char) { - if (item != null && TerrarumGDX.ingame != null && key in Key.NUM_1..Key.NUM_0) { + override fun keyDown(keycode: Int): Boolean { + if (item != null && TerrarumGDX.ingame != null && keycode in Input.Keys.NUM_1..Input.Keys.NUM_0) { val inventory = TerrarumGDX.ingame!!.player?.inventory - val slot = key - Key.NUM_1 + val slot = if (keycode == Input.Keys.NUM_0) 9 else keycode - Input.Keys.NUM_1 val currentSlotItem = inventory?.getQuickBar(slot) @@ -145,18 +144,24 @@ class UIItemInventoryElem( } } } + + return true } - override fun keyReleased(key: Int, c: Char) { + override fun keyUp(keycode: Int): Boolean { + return false } - override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { + override fun mouseMoved(screenX: Int, screenY: Int): Boolean { + return false } - override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { + override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + return false } - override fun mousePressed(button: Int, x: Int, y: Int) { + + override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { if (item != null && TerrarumGDX.ingame != null) { // equip da shit @@ -172,17 +177,16 @@ class UIItemInventoryElem( } inventoryUI.rebuildList() + + return true } - override fun mouseReleased(button: Int, x: Int, y: Int) { + + override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + return false } - override fun mouseWheelMoved(change: Int) { - } - - override fun controllerButtonPressed(controller: Int, button: Int) { - } - - override fun controllerButtonReleased(controller: Int, button: Int) { + override fun scrolled(amount: Int): Boolean { + return false } } diff --git a/src/net/torvald/terrarum/gameactors/ActorHumanoid.kt b/src/net/torvald/terrarum/gameactors/ActorHumanoid.kt index 2181676d1..752ee133f 100644 --- a/src/net/torvald/terrarum/gameactors/ActorHumanoid.kt +++ b/src/net/torvald/terrarum/gameactors/ActorHumanoid.kt @@ -333,14 +333,19 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null) } - override fun keyPressed(key: Int, c: Char) { + override fun keyDown(keycode: Int): Boolean { // quickslot (quickbar) val quickbarKeys = TerrarumGDX.getConfigIntArray("keyquickbars") - if (key in quickbarKeys) { - actorValue[AVKey.__PLAYER_QUICKSLOTSEL] = quickbarKeys.indexOf(key) + if (keycode in quickbarKeys) { + actorValue[AVKey.__PLAYER_QUICKSLOTSEL] = quickbarKeys.indexOf(keycode) } + + + return true } + + /** * This code directly controls VELOCITY for walking, called walkX and walkY. * diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index 3d67228bb..da92261d5 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -12,5 +12,5 @@ abstract class ActorWithBody(renderOrder: RenderOrder) : Actor(renderOrder) { open val hitbox = Hitbox(0.0, 0.0, 0.0, 0.0) abstract fun drawBody(batch: SpriteBatch) abstract fun drawGlow(batch: SpriteBatch) - open var tooltipText = "" + open var tooltipText: String? = null // null: display nothing } \ No newline at end of file diff --git a/src/net/torvald/terrarum/gameactors/ActorWithPhysics.kt b/src/net/torvald/terrarum/gameactors/ActorWithPhysics.kt index 9e706bcae..e6f98729a 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithPhysics.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithPhysics.kt @@ -541,11 +541,11 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean fun debug1(wut: Any?) { // vvvvv set it true to make debug print work - if (true) println(wut) + if (false) println(wut) } fun debug2(wut: Any?) { // vvvvv set it true to make debug print work - if (true) println(wut) + if (false) println(wut) } fun debug3(wut: Any?) { // vvvvv set it true to make debug print work @@ -553,7 +553,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean } fun debug4(wut: Any?) { // vvvvv set it true to make debug print work - if (true) println(wut) + if (false) println(wut) } fun Double.modTile() = this.toInt().div(TILE_SIZE).times(TILE_SIZE) fun Double.modTileDelta() = this - this.modTile() @@ -616,7 +616,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean } // collision detected else { - println("== Collision step: $collidingStep / $ccdSteps") + debug1("== Collision step: $collidingStep / $ccdSteps") val newHitbox = hitbox.reassign(sixteenStep[collidingStep]) @@ -629,14 +629,14 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean // fixme UP and RIGHT && LEFT and DOWN bug - println("Collision type: $selfCollisionStatus") + debug1("Collision type: $selfCollisionStatus") affectingTiles.forEach { val tileCoord = LandUtil.resolveBlockAddr(it) - println("affectign tile: ${tileCoord.first}, ${tileCoord.second}") + debug1("affectign tile: ${tileCoord.first}, ${tileCoord.second}") } when (selfCollisionStatus) { - 0 -> { println("[ActorWithPhysics] Contradiction -- collision detected by CCD, but isWalled() says otherwise") } + 0 -> { debug1("[ActorWithPhysics] Contradiction -- collision detected by CCD, but isWalled() says otherwise") } 5 -> { zeroX = true } 10 -> { zeroY = true } 15 -> { newHitbox.reassign(sixteenStep[0]); zeroX = true; zeroY = true } @@ -647,13 +647,13 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean 2, 7 -> { newHitbox.translatePosY( - newHitbox.endY.modTileDelta()) ; bounceY = true } // two-side collision 3 -> { - println("translateX: ${(TILE_SIZE - newHitbox.startX.modTileDelta()).rem(TILE_SIZE)}") + debug1("translateX: ${(TILE_SIZE - newHitbox.startX.modTileDelta()).rem(TILE_SIZE)}") newHitbox.translatePosX((TILE_SIZE - newHitbox.startX.modTileDelta()).rem(TILE_SIZE)) newHitbox.translatePosY( - newHitbox.endY.modTileDelta()) bounceX = true; bounceY = true } 6 -> { - println("translateX: ${( - newHitbox.endX.modTileDelta())}") + debug1("translateX: ${( - newHitbox.endX.modTileDelta())}") newHitbox.translatePosX( - newHitbox.endX.modTileDelta()) newHitbox.translatePosY( - newHitbox.endY.modTileDelta()) bounceX = true; bounceY = true @@ -664,7 +664,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean bounceX = true; bounceY = true } 12 -> { - println("translateY: ${(TILE_SIZE - newHitbox.startY.modTileDelta()).rem(TILE_SIZE)}") + debug1("translateY: ${(TILE_SIZE - newHitbox.startY.modTileDelta()).rem(TILE_SIZE)}") newHitbox.translatePosX( - newHitbox.endX.modTileDelta()) newHitbox.translatePosY((TILE_SIZE - newHitbox.startY.modTileDelta()).rem(TILE_SIZE)) bounceX = true; bounceY = true @@ -672,7 +672,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean } if (selfCollisionStatus in listOf(3,6,9,12)) { - println("twoside collision $selfCollisionStatus") + debug1("twoside collision $selfCollisionStatus") } @@ -702,7 +702,8 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean // vvvv hack (supposed to be 1.0) vvv 50% hack val collisionDamage = mass * (vectorSum.magnitude / (10.0 / TerrarumGDX.TARGET_FPS).sqr()) / fallDamageDampening.sqr() * GAME_TO_SI_ACC // kg * m / s^2 (mass * acceleration), acceleration -> (vectorMagn / (0.01)^2).gameToSI() - if (collisionDamage != 0.0) println("Collision damage: $collisionDamage N") + if (collisionDamage != 0.0) debug1("Collision damage: $collisionDamage N") + // FIXME instead of 0.5mv^2, we can model after "change of velocity (aka accel)", just as in real-life; big change of accel on given unit time is what kills // grounded = true diff --git a/src/net/torvald/terrarum/gameactors/Controllable.kt b/src/net/torvald/terrarum/gameactors/Controllable.kt index 5a779c3f1..9154e4ff5 100644 --- a/src/net/torvald/terrarum/gameactors/Controllable.kt +++ b/src/net/torvald/terrarum/gameactors/Controllable.kt @@ -9,7 +9,6 @@ package net.torvald.terrarum.gameactors interface Controllable { fun processInput(delta: Float) - - fun keyPressed(key: Int, c: Char) + fun keyDown(keycode: Int): Boolean } \ No newline at end of file diff --git a/src/net/torvald/terrarum/gameactors/TapestryObject.kt b/src/net/torvald/terrarum/gameactors/TapestryObject.kt index 035761a40..5fd722864 100644 --- a/src/net/torvald/terrarum/gameactors/TapestryObject.kt +++ b/src/net/torvald/terrarum/gameactors/TapestryObject.kt @@ -33,5 +33,5 @@ class TapestryObject(pixmap: Pixmap, val artName: String, val artAuthor: String) super.drawBody(batch) } - override var tooltipText: String = "$artName\n$artAuthor" + override var tooltipText: String? = "$artName\n$artAuthor" } diff --git a/src/net/torvald/terrarum/gamecontroller/GameController.kt b/src/net/torvald/terrarum/gamecontroller/GameController.kt index ae2b40bff..1c96a903e 100644 --- a/src/net/torvald/terrarum/gamecontroller/GameController.kt +++ b/src/net/torvald/terrarum/gamecontroller/GameController.kt @@ -1,6 +1,9 @@ package net.torvald.terrarum.gamecontroller import com.badlogic.gdx.Gdx +import com.badlogic.gdx.InputAdapter +import com.badlogic.gdx.scenes.scene2d.InputEvent +import com.badlogic.gdx.scenes.scene2d.InputListener import net.torvald.terrarum.worlddrawer.FeaturesDrawer import net.torvald.terrarum.TerrarumGDX import net.torvald.terrarum.gameactors.* @@ -10,7 +13,9 @@ import net.torvald.terrarum.worlddrawer.WorldCamera /** * Created by minjaesong on 15-12-31. */ -object GameController { +object GameController : InputAdapter() { + + private val ingame = TerrarumGDX.ingame!! @@ -83,48 +88,48 @@ object GameController { ///////////////////// } - fun keyPressed(key: Int, c: Char) { + override fun keyDown(keycode: Int): Boolean { - - - if (ingame.canPlayerControl) { - ingame.player?.keyPressed(key, c) + ingame.player?.keyDown(keycode) } - if (TerrarumGDX.getConfigIntArray("keyquickselalt").contains(key) - || key == TerrarumGDX.getConfigInt("keyquicksel")) { + if (TerrarumGDX.getConfigIntArray("keyquickselalt").contains(keycode) + || keycode == TerrarumGDX.getConfigInt("keyquicksel")) { ingame.uiPieMenu.setAsOpen() ingame.uiQuickBar.setAsClose() } - ingame.uiContainer.forEach { it.keyPressed(key, c) } // for KeyboardControlled UIcanvases + ingame.uiContainer.forEach { it.keyDown(keycode) } // for KeyboardControlled UIcanvases + + + return true } - fun keyReleased(key: Int, c: Char) { - - if (TerrarumGDX.getConfigIntArray("keyquickselalt").contains(key) - || key == TerrarumGDX.getConfigInt("keyquicksel")) { + override fun keyUp(keycode: Int): Boolean { + if (TerrarumGDX.getConfigIntArray("keyquickselalt").contains(keycode) + || keycode == TerrarumGDX.getConfigInt("keyquicksel")) { ingame.uiPieMenu.setAsClose() ingame.uiQuickBar.setAsOpen() } - ingame.uiContainer.forEach { it.keyReleased(key, c) } // for KeyboardControlled UIcanvases + ingame.uiContainer.forEach { it.keyUp(keycode) } // for KeyboardControlled UIcanvases + + + return true } - fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { - ingame.uiContainer.forEach { it.mouseMoved(oldx, oldy, newx, newy) } // for MouseControlled UIcanvases + override fun keyTyped(character: Char): Boolean { + ingame.uiContainer.forEach { it.keyTyped(character) } + return true } - fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { - ingame.uiContainer.forEach { it.mouseDragged(oldx, oldy, newx, newy) } // for MouseControlled UIcanvases + override fun mouseMoved(screenX: Int, screenY: Int): Boolean { + ingame.uiContainer.forEach { it.mouseMoved(screenX, screenY) } + return true } - fun mousePressed(button: Int, x: Int, y: Int) { - ingame.uiContainer.forEach { it.mousePressed(button, x, y) } // for MouseControlled UIcanvases - } - - fun mouseReleased(button: Int, x: Int, y: Int) { + override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { if (TerrarumGDX.ingame != null) { val ingame = TerrarumGDX.ingame!! // don't separate Player from this! Physics will break, esp. airborne manoeuvre @@ -142,39 +147,25 @@ object GameController { } - ingame.uiContainer.forEach { it.mouseReleased(button, x, y) } // for MouseControlled UIcanvases + ingame.uiContainer.forEach { it.touchUp(screenX, screenY, pointer, button) } // for MouseControlled UIcanvases } + + return true } - fun mouseWheelMoved(change: Int) { - ingame.uiContainer.forEach { it.mouseWheelMoved(change) } // for MouseControlled UIcanvases + override fun scrolled(amount: Int): Boolean { + ingame.uiContainer.forEach { it.scrolled(amount) } + return true } - fun controllerButtonPressed(controller: Int, button: Int) { - ingame.uiContainer.forEach { it.controllerButtonPressed(controller, button) } // for GamepadControlled UIcanvases + override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + ingame.uiContainer.forEach { it.touchDragged(screenX, screenY, pointer) } + return true } - fun controllerButtonReleased(controller: Int, button: Int) { - ingame.uiContainer.forEach { it.controllerButtonReleased(controller, button) } // for GamepadControlled UIcanvases + override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + ingame.uiContainer.forEach { it.touchDown(screenX, screenY, pointer, button) } + return true } + } - -/* // Use TerrarumGDX.* -/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise) */ -val GameContainer.mouseX: Double - get() = GameController.mouseX.toDouble() -/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise) */ -val GameContainer.mouseY: Double - get() = GameController.mouseY.toDouble() -/** currently pointing tile coordinate */ -val GameContainer.mouseTileX: Int - get() = GameController.mouseTileX -/** currently pointing tile coordinate */ -val GameContainer.mouseTileY: Int - get() = GameController.mouseTileY -val GameContainer.mouseScreenX: Int - get() = Terrarum.appgc.input.mouseX -val GameContainer.mouseScreenY: Int - get() = Terrarum.appgc.input.mouseY*/ - - diff --git a/src/net/torvald/terrarum/gamecontroller/Key.kt b/src/net/torvald/terrarum/gamecontroller/Key.kt index 9b82416a1..611f9bf7e 100644 --- a/src/net/torvald/terrarum/gamecontroller/Key.kt +++ b/src/net/torvald/terrarum/gamecontroller/Key.kt @@ -4,7 +4,7 @@ package net.torvald.terrarum.gamecontroller * Created by minjaesong on 16-01-15. */ @Deprecated("Use Gdx.Input.Keys") -object Key { +object DeprecatedAsFuckKey { val RETURN = 28 val BACKSPACE = 14 @@ -44,16 +44,16 @@ object Key { val F11 = 87 val F12 = 88 - val NUM_1 = 2 - val NUM_2 = 3 - val NUM_3 = 4 - val NUM_4 = 5 - val NUM_5 = 6 - val NUM_6 = 7 - val NUM_7 = 8 - val NUM_8 = 9 - val NUM_9 = 10 - val NUM_0 = 11 + val NUM_1 = 8 + val NUM_2 = 9 + val NUM_3 = 10 + val NUM_4 = 11 + val NUM_5 = 12 + val NUM_6 = 13 + val NUM_7 = 14 + val NUM_8 = 15 + val NUM_9 = 16 + val NUM_0 = 7 // JInput is QWERTY-based val Q = 16 diff --git a/src/net/torvald/terrarum/ui/ConsoleWindow.kt b/src/net/torvald/terrarum/ui/ConsoleWindow.kt index beb348fcc..6b9097567 100644 --- a/src/net/torvald/terrarum/ui/ConsoleWindow.kt +++ b/src/net/torvald/terrarum/ui/ConsoleWindow.kt @@ -1,6 +1,7 @@ package net.torvald.terrarum.ui import com.badlogic.gdx.Gdx +import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.g2d.SpriteBatch import net.torvald.dataclass.HistoryArray @@ -9,7 +10,6 @@ import net.torvald.terrarum.TerrarumGDX import net.torvald.terrarum.console.Authenticator import net.torvald.terrarum.console.CommandInterpreter import net.torvald.terrarum.fillRect -import net.torvald.terrarum.gamecontroller.Key /** @@ -80,60 +80,59 @@ class ConsoleWindow : UICanvas, KeyControlled { } - override fun keyPressed(key: Int, c: Char) { + override fun keyDown(key: Int): Boolean { // history - if (key == Key.UP && historyIndex < commandHistory.history.size) + if (key == Input.Keys.UP && historyIndex < commandHistory.history.size) historyIndex++ - else if (key == Key.DOWN && historyIndex >= 0) + else if (key == Input.Keys.DOWN && historyIndex >= 0) historyIndex-- - else if (key != Key.UP && key != Key.DOWN) + else if (key != Input.Keys.UP && key != Input.Keys.DOWN) historyIndex = -1 // execute - if (key == Key.RETURN && commandInputPool!!.isNotEmpty()) { + if (key == Input.Keys.ENTER && commandInputPool!!.isNotEmpty()) { commandHistory.add(commandInputPool!!.toString()) executeCommand() commandInputPool = StringBuilder() } // erase last letter - else if (key == Key.BACKSPACE && commandInputPool!!.isNotEmpty()) { + else if (key == Input.Keys.BACKSPACE && commandInputPool!!.isNotEmpty()) { commandInputPool!!.deleteCharAt(commandInputPool!!.length - 1) } - // append acceptable letter - else if (key >= 2 && key <= 13 - || key >= 16 && key <= 27 - || key >= 30 && key <= 40 - || key >= 44 && key <= 53 - || commandInputPool!!.length > 0 && key == 57) { - commandInputPool!!.append(c) - inputCursorPos += 1 - } // scroll - else if (key == Key.UP || key == Key.DOWN) { + else if (key == Input.Keys.UP || key == Input.Keys.DOWN) { // create new stringbuilder commandInputPool = StringBuilder() if (historyIndex >= 0) // just leave blank if index is -1 commandInputPool!!.append(commandHistory[historyIndex] ?: "") } // delete input - else if (key == Key.DELETE) { + else if (key == Input.Keys.BACKSPACE) { commandInputPool = StringBuilder() } // message scroll up - else if (key == Key.PGUP) { + else if (key == Input.Keys.PAGE_UP) { setDisplayPos(-MESSAGES_DISPLAY_COUNT + 1) } // message scroll down - else if (key == Key.PGDN) { + else if (key == Input.Keys.PAGE_DOWN) { setDisplayPos(MESSAGES_DISPLAY_COUNT - 1) } + + + return true } - override fun keyReleased(key: Int, c: Char) { + override fun keyTyped(character: Char): Boolean { + commandInputPool!!.append(character) + inputCursorPos += 1 + return true } - + override fun keyUp(keycode: Int): Boolean { + return false + } private fun executeCommand() { CommandInterpreter.execute(commandInputPool!!.toString()) @@ -205,12 +204,6 @@ class ConsoleWindow : UICanvas, KeyControlled { openingTimeCounter = 0f } - override fun controllerButtonPressed(controller: Int, button: Int) { - } - - override fun controllerButtonReleased(controller: Int, button: Int) { - } - override fun processInput(delta: Float) { } } diff --git a/src/net/torvald/terrarum/ui/KeyControlled.kt b/src/net/torvald/terrarum/ui/KeyControlled.kt index ebe72cdc3..da553903d 100644 --- a/src/net/torvald/terrarum/ui/KeyControlled.kt +++ b/src/net/torvald/terrarum/ui/KeyControlled.kt @@ -4,8 +4,7 @@ package net.torvald.terrarum.ui * Created by minjaesong on 16-03-06. */ interface KeyControlled { - fun keyPressed(key: Int, c: Char) - fun keyReleased(key: Int, c: Char) - fun controllerButtonPressed(controller: Int, button: Int) - fun controllerButtonReleased(controller: Int, button: Int) + fun keyDown(keycode: Int): Boolean + fun keyUp(keycode: Int): Boolean + fun keyTyped(character: Char): Boolean } \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/MouseControlled.kt b/src/net/torvald/terrarum/ui/MouseControlled.kt index 80e04a378..e04c80ddc 100644 --- a/src/net/torvald/terrarum/ui/MouseControlled.kt +++ b/src/net/torvald/terrarum/ui/MouseControlled.kt @@ -4,9 +4,9 @@ package net.torvald.terrarum.ui * Created by minjaesong on 16-03-06. */ interface MouseControlled { - fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) - fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) - fun mousePressed(button: Int, x: Int, y: Int) - fun mouseReleased(button: Int, x: Int, y: Int) - fun mouseWheelMoved(change: Int) + fun mouseMoved(screenX: Int, screenY: Int): Boolean + fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean + fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean + fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean + fun scrolled(amount: Int): Boolean } \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/UIHandler.kt b/src/net/torvald/terrarum/ui/UIHandler.kt index 13de4406f..c768d736e 100644 --- a/src/net/torvald/terrarum/ui/UIHandler.kt +++ b/src/net/torvald/terrarum/ui/UIHandler.kt @@ -209,58 +209,66 @@ class UIHandler(val UI: UICanvas, } } - fun keyPressed(key: Int, c: Char) { + fun keyDown(keycode: Int): Boolean { if (isVisible && UI is KeyControlled) { - UI.keyPressed(key, c) + return UI.keyDown(keycode) } + + return false } - fun keyReleased(key: Int, c: Char) { + fun keyUp(keycode: Int): Boolean { if (isVisible && UI is KeyControlled) { - UI.keyReleased(key, c) + return UI.keyUp(keycode) } + + return false } - fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { - if (isVisible && UI is MouseControlled) { - UI.mouseMoved(oldx, oldy, newx, newy) - } - } - - fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { - if (isVisible && UI is MouseControlled) { - UI.mouseDragged(oldx, oldy, newx, newy) - } - } - - fun mousePressed(button: Int, x: Int, y: Int) { - if (isVisible && UI is MouseControlled) { - UI.mousePressed(button, x, y) - } - } - - fun mouseReleased(button: Int, x: Int, y: Int) { - if (isVisible && UI is MouseControlled) { - UI.mouseReleased(button, x, y) - } - } - - fun mouseWheelMoved(change: Int) { - if (isVisible && UI is MouseControlled) { - UI.mouseWheelMoved(change) - } - } - - fun controllerButtonPressed(controller: Int, button: Int) { + fun keyTyped(char: Char): Boolean { if (isVisible && UI is KeyControlled) { - UI.controllerButtonPressed(controller, button) + return UI.keyTyped(char) + } + + return false + } + + fun mouseMoved(screenX: Int, screenY: Int) { + if (isVisible && UI is MouseControlled) { + UI.mouseMoved(screenX, screenY) } } - fun controllerButtonReleased(controller: Int, button: Int) { - if (isVisible && UI is KeyControlled) { - UI.controllerButtonReleased(controller, button) + fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + if (isVisible && UI is MouseControlled) { + UI.touchDragged(screenX, screenY, pointer) } + + return false + } + + fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + if (isVisible && UI is MouseControlled) { + UI.touchDown(screenX, screenY, pointer, button) + } + + return false + } + + fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + if (isVisible && UI is MouseControlled) { + UI.touchUp(screenX, screenY, pointer, button) + } + + return false + } + + fun scrolled(amount: Int): Boolean { + if (isVisible && UI is MouseControlled) { + UI.scrolled(amount) + } + + return false } // constant UI can't take control diff --git a/src/net/torvald/terrarum/ui/UIInventory.kt b/src/net/torvald/terrarum/ui/UIInventory.kt index 41e28b668..66e250cf3 100644 --- a/src/net/torvald/terrarum/ui/UIInventory.kt +++ b/src/net/torvald/terrarum/ui/UIInventory.kt @@ -315,40 +315,47 @@ class UIInventory( UICanvas.endClosingPopOut(handler, UICanvas.Companion.Position.LEFT) } - override fun keyPressed(key: Int, c: Char) { - items.forEach { if (it.mouseUp) it.keyPressed(key, c) } + override fun mouseMoved(screenX: Int, screenY: Int): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun keyDown(keycode: Int): Boolean { + items.forEach { if (it.mouseUp) it.keyDown(keycode) } shutUpAndRebuild() + + return true } - override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { - } - - override fun keyReleased(key: Int, c: Char) { - items.forEach { if (it.mouseUp) it.keyReleased(key, c) } + override fun keyUp(keycode: Int): Boolean { + items.forEach { if (it.mouseUp) it.keyUp(keycode) } shutUpAndRebuild() + + return true } - override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { + override fun keyTyped(character: Char): Boolean { + return false } - override fun controllerButtonPressed(controller: Int, button: Int) { - items.forEach { if (it.mouseUp) it.controllerButtonPressed(controller, button) } - shutUpAndRebuild() + override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + return false } - override fun mousePressed(button: Int, x: Int, y: Int) { - items.forEach { if (it.mouseUp) it.mousePressed(button, x, y) } + override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + items.forEach { if (it.mouseUp) it.touchDown(screenX, screenY, pointer, button) } + + return true } - override fun controllerButtonReleased(controller: Int, button: Int) { - items.forEach { if (it.mouseUp) it.controllerButtonReleased(controller, button) } - shutUpAndRebuild() + override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + items.forEach { if (it.mouseUp) it.touchUp(screenX, screenY, pointer, button) } + + return true } - override fun mouseReleased(button: Int, x: Int, y: Int) { - items.forEach { if (it.mouseUp) it.mouseReleased(button, x, y) } + override fun scrolled(amount: Int): Boolean { + return false } - override fun mouseWheelMoved(change: Int) { - } + } diff --git a/src/net/torvald/terrarum/ui/UIItem.kt b/src/net/torvald/terrarum/ui/UIItem.kt index 6cd9973cf..eede22ec9 100644 --- a/src/net/torvald/terrarum/ui/UIItem.kt +++ b/src/net/torvald/terrarum/ui/UIItem.kt @@ -32,17 +32,14 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI abstract fun render(batch: SpriteBatch) // keyboard controlled - abstract fun keyPressed(key: Int, c: Char) - abstract fun keyReleased(key: Int, c: Char) + abstract fun keyDown(keycode: Int): Boolean + abstract fun keyUp(keycode: Int): Boolean // mouse controlled - abstract fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) - abstract fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) - abstract fun mousePressed(button: Int, x: Int, y: Int) - abstract fun mouseReleased(button: Int, x: Int, y: Int) - abstract fun mouseWheelMoved(change: Int) + abstract fun mouseMoved(screenX: Int, screenY: Int): Boolean + abstract fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean + abstract fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean + abstract fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean + abstract fun scrolled(amount: Int): Boolean - // gamepad controlled - abstract fun controllerButtonPressed(controller: Int, button: Int) - abstract fun controllerButtonReleased(controller: Int, button: Int) } diff --git a/src/net/torvald/terrarum/ui/UIItemImageGallery.kt b/src/net/torvald/terrarum/ui/UIItemImageGallery.kt index b4e190fdf..85260ed02 100644 --- a/src/net/torvald/terrarum/ui/UIItemImageGallery.kt +++ b/src/net/torvald/terrarum/ui/UIItemImageGallery.kt @@ -42,39 +42,31 @@ class UIItemImageGallery( } } - override fun keyPressed(key: Int, c: Char) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun keyDown(keycode: Int): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } - override fun keyReleased(key: Int, c: Char) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun keyUp(keycode: Int): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } - override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun mouseMoved(screenX: Int, screenY: Int): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } - override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } - override fun mousePressed(button: Int, x: Int, y: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } - override fun mouseReleased(button: Int, x: Int, y: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } - override fun mouseWheelMoved(change: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun controllerButtonPressed(controller: Int, button: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun controllerButtonReleased(controller: Int, button: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun scrolled(amount: Int): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/UIItemTextButton.kt b/src/net/torvald/terrarum/ui/UIItemTextButton.kt index 5b18c037f..ed01ca795 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButton.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButton.kt @@ -82,30 +82,31 @@ class UIItemTextButton( } } - override fun keyPressed(key: Int, c: Char) { + override fun keyDown(keycode: Int): Boolean { + return false } - override fun keyReleased(key: Int, c: Char) { + override fun keyUp(keycode: Int): Boolean { + return false } - override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { + override fun mouseMoved(screenX: Int, screenY: Int): Boolean { + return false } - override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { + override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + return false } - override fun mousePressed(button: Int, x: Int, y: Int) { + override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + return false } - override fun mouseReleased(button: Int, x: Int, y: Int) { + override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + return false } - override fun mouseWheelMoved(change: Int) { - } - - override fun controllerButtonPressed(controller: Int, button: Int) { - } - - override fun controllerButtonReleased(controller: Int, button: Int) { + override fun scrolled(amount: Int): Boolean { + return false } } diff --git a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt index 1836194dd..156fda112 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt @@ -169,30 +169,31 @@ class UIItemTextButtonList( } } - override fun keyPressed(key: Int, c: Char) { + override fun keyDown(keycode: Int): Boolean { + return false } - override fun keyReleased(key: Int, c: Char) { + override fun keyUp(keycode: Int): Boolean { + return false } - override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { + override fun mouseMoved(screenX: Int, screenY: Int): Boolean { + return false } - override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { + override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + return false } - override fun mousePressed(button: Int, x: Int, y: Int) { + override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + return false } - override fun mouseReleased(button: Int, x: Int, y: Int) { + override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + return false } - override fun mouseWheelMoved(change: Int) { - } - - override fun controllerButtonPressed(controller: Int, button: Int) { - } - - override fun controllerButtonReleased(controller: Int, button: Int) { + override fun scrolled(amount: Int): Boolean { + return false } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/UIQuickBar.kt b/src/net/torvald/terrarum/ui/UIQuickBar.kt index 5419c3658..cb29c05e4 100644 --- a/src/net/torvald/terrarum/ui/UIQuickBar.kt +++ b/src/net/torvald/terrarum/ui/UIQuickBar.kt @@ -89,22 +89,29 @@ class UIQuickBar : UICanvas, MouseControlled { handler!!.opacity = 0f } - override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { + override fun mouseMoved(screenX: Int, screenY: Int): Boolean { + return false } - override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { + override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + return false } - override fun mousePressed(button: Int, x: Int, y: Int) { + override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + return false } - override fun mouseReleased(button: Int, x: Int, y: Int) { + override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + return false } - override fun mouseWheelMoved(change: Int) { - selection = selection.plus(if (change > 1) 1 else if (change < -1) -1 else 0).fmod(SLOT_COUNT) + override fun scrolled(amount: Int): Boolean { + selection = selection.plus(if (amount > 1) 1 else if (amount < -1) -1 else 0).fmod(SLOT_COUNT) + + return true } + companion object { val finalOpacity = 0.8f diff --git a/src/net/torvald/terrarum/virtualcomputer/luaapi/Input.kt b/src/net/torvald/terrarum/virtualcomputer/luaapi/Input.kt index 89ec9cd96..10a4b45bf 100644 --- a/src/net/torvald/terrarum/virtualcomputer/luaapi/Input.kt +++ b/src/net/torvald/terrarum/virtualcomputer/luaapi/Input.kt @@ -5,7 +5,6 @@ import org.luaj.vm2.Globals import org.luaj.vm2.LuaTable import org.luaj.vm2.LuaValue import org.luaj.vm2.lib.OneArgFunction -import net.torvald.terrarum.gamecontroller.Key import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer /** @@ -13,38 +12,5 @@ import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer */ class Input(globals: Globals, computer: TerrarumComputer) { - init { - globals["input"] = LuaTable() - globals["input"]["isKeyDown"] = IsKeyDown(computer) - // input.readLine defined in ROMLIB - } - companion object { - val keys_alt = intArrayOf(Key.L_ALT, Key.L_COMMAND) - val keys_caps = intArrayOf(Key.CAPS_LOCK, Key.BACKSPACE, Key.L_CONTROL) - } - - class IsKeyDown(val host: TerrarumComputer) : OneArgFunction() { - override fun call(keyCode: LuaValue): LuaValue { - val key = keyCode.checkint() - - // L_Alt and L_COMMAND are homogeneous - if (keys_alt.contains(key)) { - for (k in keys_alt) { - val down = Gdx.input.isKeyPressed(k) - if (down) return LuaValue.valueOf(true) - } - } - - // Caps, Backspace, L_Control, for Colemak and HHKB - if (keys_caps.contains(key)) { - for (k in keys_caps) { - val down = Gdx.input.isKeyPressed(k) - if (down) return LuaValue.valueOf(true) - } - } - - return LuaValue.valueOf(Gdx.input.isKeyPressed(keyCode.checkint())) - } - } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt b/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt index 98790864c..bd6fd423d 100644 --- a/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt +++ b/src/net/torvald/terrarum/virtualcomputer/terminal/GraphicsTerminal.kt @@ -3,7 +3,6 @@ package net.torvald.terrarum.virtualcomputer.terminal import net.torvald.terrarum.blendMul import net.torvald.terrarum.gameactors.DecodeTapestry import net.torvald.terrarum.gameactors.abs -import net.torvald.terrarum.gamecontroller.Key import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer import java.util.* diff --git a/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt b/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt index 1e8c9b5e3..4a9328ee2 100644 --- a/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt +++ b/src/net/torvald/terrarum/virtualcomputer/worldobject/ui/UITextTerminal.kt @@ -10,40 +10,43 @@ import net.torvald.terrarum.virtualcomputer.terminal.Terminal * Created by minjaesong on 16-09-08. */ class UITextTerminal(val terminal: Terminal) : UICanvas, KeyControlled, MouseControlled { - override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + + override fun keyDown(keycode: Int): Boolean { + return false } - override fun keyPressed(key: Int, c: Char) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun mouseMoved(screenX: Int, screenY: Int): Boolean { + return false } - override fun keyReleased(key: Int, c: Char) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun keyUp(keycode: Int): Boolean { + return false } - override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean { + return false } - override fun controllerButtonPressed(controller: Int, button: Int) { + override fun keyTyped(character: Char): Boolean { + return false } - override fun controllerButtonReleased(controller: Int, button: Int) { + override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + return false + } + + override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean { + return false + } + + override fun scrolled(amount: Int): Boolean { + return false } override var width: Int = terminal.displayW// + some override var height: Int = terminal.displayH// + frame - override fun mousePressed(button: Int, x: Int, y: Int) { - // monitor on/off, reset switch - } - - override fun mouseReleased(button: Int, x: Int, y: Int) { - } - - override fun mouseWheelMoved(change: Int) { - } + /** * Usage: (in StateInGame:) uiHandlerField.ui.handler = uiHandlerField diff --git a/src/net/torvald/terrarum/weather/WeatherMixer.kt b/src/net/torvald/terrarum/weather/WeatherMixer.kt index 4996267b6..1cc677ad8 100644 --- a/src/net/torvald/terrarum/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/weather/WeatherMixer.kt @@ -1,6 +1,7 @@ package net.torvald.terrarum.weather import com.badlogic.gdx.Gdx +import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.g2d.SpriteBatch @@ -10,7 +11,6 @@ import net.torvald.colourutil.* import net.torvald.random.HQRNG import net.torvald.terrarum.* import net.torvald.terrarum.gameactors.ParticleTestRain -import net.torvald.terrarum.gamecontroller.Key import net.torvald.terrarum.gamecontroller.KeyToggler import net.torvald.terrarum.gameworld.WorldTime import java.io.File @@ -78,7 +78,7 @@ object WeatherMixer { if (TerrarumGDX.ingame!!.player != null) { // test rain toggled by F2 - if (KeyToggler.isOn(Key.F2)) { + if (KeyToggler.isOn(Input.Keys.F2)) { val playerPos = TerrarumGDX.ingame!!.player!!.centrePosPoint kotlin.repeat(4) { // 4 seems good diff --git a/work_files/graphics/fonts/devanagari_bengali_variable.psd b/work_files/graphics/fonts/devanagari_bengali_variable.psd index 193ed2286..36460e67d 100644 --- a/work_files/graphics/fonts/devanagari_bengali_variable.psd +++ b/work_files/graphics/fonts/devanagari_bengali_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3e45393ca0948479eef602c3a060dd35b4195b220ba554d0d67001aa8d9405f9 -size 267667 +oid sha256:6c18acefbb452ad6b5f557f02ab12f8d7a3b5e5efd1a39780e7a12e197ca7084 +size 268463