From 6d7903eb93db50da1c838b730b489f8ca41c9280 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 25 Aug 2020 00:24:09 +0300 Subject: [PATCH] Resolved #2844 - Can now immediately move units in Desktop with right-click --- .../unciv/ui/worldscreen/WorldMapHolder.kt | 19 +++++++++++++++++++ docs/Credits.md | 1 + 2 files changed, 20 insertions(+) diff --git a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt index e24d8729..c4367b5d 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt @@ -1,12 +1,14 @@ package com.unciv.ui.worldscreen import com.badlogic.gdx.Gdx +import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.math.Interpolation import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.scenes.scene2d.* import com.badlogic.gdx.scenes.scene2d.actions.FloatAction import com.badlogic.gdx.scenes.scene2d.ui.Table +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener import com.unciv.Constants import com.unciv.UncivGame import com.unciv.logic.automation.BattleHelper @@ -47,6 +49,23 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap onTileClicked(tileGroup.tileInfo) } tileGroup.onClick { onTileClicked(tileGroup.tileInfo) } + + // Right mouse click listener + tileGroup.addListener(object : ClickListener() { + init { + button = Input.Buttons.RIGHT + } + override fun clicked(event: InputEvent?, x: Float, y: Float) { + val unit = worldScreen.bottomUnitTable.selectedUnit + if (unit == null) return + thread { + val canUnitReachTile = unit.movement.canReach(tileGroup.tileInfo) + if (canUnitReachTile) { + UnitContextMenu(this@WorldMapHolder, unit, tileGroup.tileInfo).onMoveButtonClick() + } + } + } + }) } actor = allTiles diff --git a/docs/Credits.md b/docs/Credits.md index 9082c035..0a99b611 100644 --- a/docs/Credits.md +++ b/docs/Credits.md @@ -518,6 +518,7 @@ Unless otherwise specified, all the following are from [the Noun Project](https: * [Puppet](https://thenounproject.com/search/?q=puppet&i=285735) By Ben Davis for puppeted cities * [City](https://thenounproject.com/search/?q=city&i=1765370) By Muhajir ila Robbi in the Icon center * [Lock](https://thenounproject.com/search/?q=lock&i=3217613) by Vadim Solomakhin for locked tiles +* [Turn](https://thenounproject.com/search/?q=turn&i=2829863) by Adrien Coquet for the 'Turn' icon ## Main menu