All the various clicks on the world screen can now work together as friends
This commit is contained in:
parent
6772e19981
commit
0ec0ee3d44
1 changed files with 5 additions and 6 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue