From 0ec0ee3d440e762b174d4f0b98f7b2572c311a80 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 21 Nov 2019 10:53:08 +0200 Subject: [PATCH] All the various clicks on the world screen can now work together as friends --- core/src/com/unciv/ui/worldscreen/TileMapHolder.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index 977b1c28f6..34899c010d 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -9,6 +9,7 @@ import com.badlogic.gdx.scenes.scene2d.actions.FloatAction import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener import com.unciv.Constants import com.unciv.UnCivGame import com.unciv.logic.automation.UnitAutomation @@ -55,6 +56,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: tileGroup.cityButtonLayerGroup.onClick("") { onTileClicked(tileGroup.tileInfo) } + tileGroup.onClick { onTileClicked(tileGroup.tileInfo) } } actor = allTiles @@ -114,12 +116,6 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: return null } - override fun tap(event: InputEvent, x: Float, y: Float, count: Int, button: Int) { - val tileGroup = toTileGroup(Vector2(event.stageX, event.stageY)) - if (tileGroup != null) onTileClicked(tileGroup.tileInfo) - } - - override fun longPress(actor: Actor, x: Float, y: Float): Boolean { if (!worldScreen.isPlayersTurn) return false // no long click when it's not your turn // otherwise it activates, @@ -259,6 +255,9 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: if (selectedUnit != null) { addOverlayOnTileGroup(tileInfo, UnitContextMenu(this, selectedUnit, tileInfo)) + // don't activate the regular tile click after a long-press, + // that makes the long-press basically worthless + (tileGroups[tileInfo]!!.listeners.first { it is ClickListener }!! as ClickListener).cancel() return true }