All the various clicks on the world screen can now work together as friends

This commit is contained in:
Yair Morgenstern 2019-11-21 10:53:08 +02:00
parent 6772e19981
commit 0ec0ee3d44

View file

@ -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.ScrollPane
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UnCivGame import com.unciv.UnCivGame
import com.unciv.logic.automation.UnitAutomation import com.unciv.logic.automation.UnitAutomation
@ -55,6 +56,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
tileGroup.cityButtonLayerGroup.onClick("") { tileGroup.cityButtonLayerGroup.onClick("") {
onTileClicked(tileGroup.tileInfo) onTileClicked(tileGroup.tileInfo)
} }
tileGroup.onClick { onTileClicked(tileGroup.tileInfo) }
} }
actor = allTiles actor = allTiles
@ -114,12 +116,6 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
return null 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 { override fun longPress(actor: Actor, x: Float, y: Float): Boolean {
if (!worldScreen.isPlayersTurn) return false // no long click when it's not your turn if (!worldScreen.isPlayersTurn) return false // no long click when it's not your turn
// otherwise it activates, // otherwise it activates,
@ -259,6 +255,9 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
if (selectedUnit != null) { if (selectedUnit != null) {
addOverlayOnTileGroup(tileInfo, UnitContextMenu(this, selectedUnit, tileInfo)) 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 return true
} }