diff --git a/src/net/torvald/terrarum/IngameInstance.kt b/src/net/torvald/terrarum/IngameInstance.kt index 9eb116f1a..9d0b125d3 100644 --- a/src/net/torvald/terrarum/IngameInstance.kt +++ b/src/net/torvald/terrarum/IngameInstance.kt @@ -221,19 +221,19 @@ open class IngameInstance(val batch: FlippingSpriteBatch, val isMultiplayer: Boo open fun worldPrimaryClickEnd(actor: ActorWithBody, delta: Float) { } + // I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26 + // Nevermind: we need to distinguish picking up and using the fixture. --Torvald on 2022-08-26 /** - * I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26 - * * Event for triggering held item's `startSecondaryUse(Float)` */ - //open fun worldSecondaryClickStart(delta: Float) { } + open fun worldSecondaryClickStart(actor: ActorWithBody, delta: Float) { } - /** - * I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26 - * + // I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26 + // Nevermind: we need to distinguish picking up and using the fixture. --Torvald on 2022-08-26 + /*** * Event for triggering held item's `endSecondaryUse(Float)` */ - //open fun worldSecondaryClickEnd(delta: Float) { } + open fun worldSecondaryClickEnd(actor: ActorWithBody, delta: Float) { } /** * Event for triggering fixture update when something is placed/removed on the world. diff --git a/src/net/torvald/terrarum/gamecontroller/IngameController.kt b/src/net/torvald/terrarum/gamecontroller/IngameController.kt index d604683c5..23e60f644 100644 --- a/src/net/torvald/terrarum/gamecontroller/IngameController.kt +++ b/src/net/torvald/terrarum/gamecontroller/IngameController.kt @@ -135,9 +135,9 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { terrarumIngame.worldPrimaryClickStart(terrarumIngame.actorNowPlaying!!, App.UPDATE_RATE) worldPrimaryClickLatched = true } - /*if Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mousesecondary")) { - ingame.worldSecondaryClickStart(AppLoader.UPDATE_RATE) - }*/ + if (Gdx.input.isButtonPressed(App.getConfigInt("config_mousesecondary"))) { + terrarumIngame.worldSecondaryClickStart(terrarumIngame.actorNowPlaying!!, App.UPDATE_RATE) + } // unlatch when: // - not clicking anymore @@ -225,9 +225,9 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { button == App.getConfigInt("config_mousesecondary"))) { terrarumIngame.worldPrimaryClickEnd(terrarumIngame.actorNowPlaying!!, App.UPDATE_RATE) } - /*if (button == AppLoader.getConfigInt("config_mousesecondary")) { - ingame.worldSecondaryClickEnd(AppLoader.UPDATE_RATE) - }*/ + if (button == App.getConfigInt("config_mousesecondary")) { + terrarumIngame.worldSecondaryClickEnd(terrarumIngame.actorNowPlaying!!, App.UPDATE_RATE) + } } } diff --git a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt index 93a3123d8..3be0ade22 100644 --- a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt +++ b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt @@ -585,6 +585,9 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { }// END enter + + + // left click: use item, use fixture, use something else override fun worldPrimaryClickStart(actor: ActorWithBody, delta: Float) { //println("[Ingame] worldPrimaryClickStart $delta") @@ -606,7 +609,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { // #1. Try to open a UI under the cursor // scan for the one with non-null UI. // what if there's multiple of such fixtures? whatever, you are supposed to DISALLOW such situation. - if (itemOnGrip?.inventoryCategory != GameItem.Category.TOOL) { // don't open the UI when player's holding a tool +// if (itemOnGrip?.inventoryCategory != GameItem.Category.TOOL) { // don't open the UI when player's holding a tool for (kk in actorsUnderMouse.indices) { if (mouseInInteractableRange(actor) { actorsUnderMouse[kk].mainUI?.let { @@ -625,7 +628,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { 0L } == 0L) break } - } +// } // #2. If there is no UI under and if I'm holding an item, use it // don't want to open the UI and use the item at the same time, would ya? @@ -653,18 +656,14 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { } } - // I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26 - /*override fun worldSecondaryClickStart(delta: Float) { - val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP) - val consumptionSuccessful = ItemCodex[itemOnGrip]?.startSecondaryUse(delta) ?: false - if (consumptionSuccessful > -1) - actorNowPlaying?.inventory?.consumeItem(ItemCodex[itemOnGrip]!!, consumptionSuccessful) + // right click: pick up fixture, open debug menu (if applicable) + override fun worldSecondaryClickStart(actor: ActorWithBody, delta: Float) { +// println("Secondary click start!") } - override fun worldSecondaryClickEnd(delta: Float) { - val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP) - ItemCodex[itemOnGrip]?.endSecondaryUse(delta) - }*/ + override fun worldSecondaryClickEnd(actor: ActorWithBody, delta: Float) { +// println("Secondary click start!") + }