diff --git a/android/build.gradle b/android/build.gradle index 1bd3d15636..1112f3a8e3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.game" minSdkVersion 14 targetSdkVersion 26 - versionCode 55 - versionName "2.1.5" + versionCode 57 + versionName "2.1.7" } buildTypes { release { diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index 69adc4eb50..5564552b7a 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -24,6 +24,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) { } fun getDistanceToTilesWithinTurn(origin: Vector2, unitMovement: Float): HashMap { + if(unitMovement==0f) return hashMapOf() val distanceToTiles = HashMap() val unitTile = tileMap[origin] distanceToTiles[unitTile] = 0f diff --git a/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.kt index bb8f9b4e07..4d61d21981 100644 --- a/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.kt @@ -9,16 +9,16 @@ import com.unciv.ui.cityscreen.addClickListener import com.unciv.ui.utils.CameraStageBaseScreen class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() { - private var selectedProduction: String?=null + private var selectedProduction: String? = null private fun getProductionButton(production: String, buttonText: String, description: String?, rightSideButtonText: String): TextButton { val productionTextButton = TextButton(buttonText, CameraStageBaseScreen.skin) productionTextButton.addClickListener { - selectedProduction = production - pick(rightSideButtonText) - descriptionLabel.setText(description) - } + selectedProduction = production + pick(rightSideButtonText) + descriptionLabel.setText(description) + } return productionTextButton } @@ -27,17 +27,17 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() { closeButton.clearListeners() // Don't go back to the world screen, unlike the other picker screens! closeButton.addClickListener { - game.screen = CityScreen(this@ConstructionPickerScreen.city) - dispose() - } + game.screen = CityScreen(this@ConstructionPickerScreen.city) + dispose() + } rightSideButton.setText("Pick building") rightSideButton.addClickListener { - city.cityConstructions.currentConstruction = selectedProduction!! - city.cityStats.update() // Because maybe we set/removed the science or gold production options. - game.screen = CityScreen(this@ConstructionPickerScreen.city) - dispose() - } + city.cityConstructions.currentConstruction = selectedProduction!! + city.cityStats.update() // Because maybe we set/removed the science or gold production options. + game.screen = CityScreen(this@ConstructionPickerScreen.city) + dispose() + } val cityConstructions = city.cityConstructions val regularBuildings = VerticalGroup().space(10f) @@ -57,7 +57,7 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() { regularBuildings.addActor(productionTextButton) } - for (unit in GameBasics.Units.values.filter { it.isBuildable(cityConstructions)}) { + for (unit in GameBasics.Units.values.filter { it.isBuildable(cityConstructions) }) { units.addActor(getProductionButton(unit.name, unit.name + "\r\n" + cityConstructions.turnsToConstruction(unit.name) + " turns", unit.getDescription(true), "Train " + unit.name)) diff --git a/core/src/com/unciv/ui/pickerscreens/PickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/PickerScreen.kt index ff8a6e1c10..c0c87c73e7 100644 --- a/core/src/com/unciv/ui/pickerscreens/PickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/PickerScreen.kt @@ -34,11 +34,12 @@ open class PickerScreen : CameraStageBaseScreen() { bottomTable.add(descriptionLabel).pad(5f).width(stage.width / 2) rightSideButton = TextButton("", CameraStageBaseScreen.skin) + rightSideButton.disable() rightSideGroup.addActor(rightSideButton) + bottomTable.add(rightSideGroup).width(stage.width / 4) bottomTable.height = stage.height * (1 - screenSplit) bottomTable.align(Align.center) - rightSideButton.disable() topTable = Table() val scrollPane = ScrollPane(topTable) diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 78d608e2e8..f202bc6cf7 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -88,27 +88,37 @@ open class TileGroup(var tileInfo: TileInfo) : Group() { if (tileInfo.getOwner() != null) { for (neighbor in tileInfo.neighbors.filter { it.getOwner() != tileInfo.getOwner() }) { - val image = ImageGetter.getImage(ImageGetter.WhiteDot) + val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position) val relativeWorldPosition = HexMath.Hex2WorldCoords(relativeHexPosition) // This is some crazy voodoo magic so I'll explain. - image.setSize(35f, 2f) - image.moveBy(width / 2 - image.width / 2, // center - height / 2 - image.height / 2) - // in addTiles, we set the position of groups by relative world position *0.8*groupSize, filter groupSize = 50 - // Here, we want to have the borders start HALFWAY THERE and extend towards the tiles, so we give them a position of 0.8*25. - // BUT, we don't actually want it all the way out there, because we want to display the borders of 2 different civs! - // So we set it to 0.75 - image.moveBy(-relativeWorldPosition.x * 0.75f * 25f, -relativeWorldPosition.y * 0.75f * 25f) + for(i in -2..2) { + val image = ImageGetter.getImage("UnitIcons/Circle.png") + image.setSize(5f, 5f) + image.moveBy(width / 2 - image.width / 2, // center + height / 2 - image.height / 2) + // in addTiles, we set the position of groups by relative world position *0.8*groupSize, filter groupSize = 50 + // Here, we want to have the borders start HALFWAY THERE and extend towards the tiles, so we give them a position of 0.8*25. + // BUT, we don't actually want it all the way out there, because we want to display the borders of 2 different civs! + // So we set it to 0.75 + image.moveBy(-relativeWorldPosition.x * 0.75f * 25f, -relativeWorldPosition.y * 0.75f * 25f) + + // And now, move it within the hexagon side according to i. + // Remember, if from the center of the heagon to the middle of the side is an (a,b) vecctor, + // Then within the side, which is of course perpendicular to the (a,b) vector, + // we can move with multiples of (b,-a) which is perpendicular to (a,b) + image.moveBy(relativeWorldPosition.y*i * 4, -relativeWorldPosition.x*i * 4) + + image.color = tileInfo.getOwner()!!.getCivilization().getColor() + //image.setOrigin(image.width / 2, image.height / 2) // This is so that the rotation is calculated from the middle of the road and not the edge + //image.rotation = (90 + 180 / Math.PI * Math.atan2(relativeWorldPosition.y.toDouble(), relativeWorldPosition.x.toDouble())).toFloat() + addActor(image) + borderImages.add(image) + } - image.color = tileInfo.getOwner()!!.getCivilization().getColor() - image.setOrigin(image.width / 2, image.height / 2) // This is so that the rotation is calculated from the middle of the road and not the edge - image.rotation = (90 + 180 / Math.PI * Math.atan2(relativeWorldPosition.y.toDouble(), relativeWorldPosition.x.toDouble())).toFloat() - addActor(image) - borderImages.add(image) } } @@ -238,6 +248,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() { fun showCircle(color:Color){ circleImage.isVisible = true + val color = Color(color) color.a = 0.3f circleImage.color = color } diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index b838ba3a7d..80326d2f14 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -98,11 +98,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: } } - if(worldScreen.unitTable.currentlyExecutingAction!=null) - for(tile: TileInfo in worldScreen.unitTable.getTilesForCurrentlyExecutingAction()) - tileGroups[tile]!!.showCircle(Color(0f,120/255f,215/255f,1f)) - - else if(worldScreen.unitTable.selectedUnit!=null){ + if(worldScreen.unitTable.selectedUnit!=null){ val unit = worldScreen.unitTable.selectedUnit!! tileGroups[unit.getTile()]!!.addWhiteCircleAroundUnit() val attackableTiles:List @@ -113,9 +109,16 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: UnitType.City -> throw Exception("How are you attacking with a city?") } + for(tile: TileInfo in unit.getDistanceToTiles().keys) + tileGroups[tile]!!.showCircle(Color().fromRGB(0,120,215)) + for (tile in attackableTiles.filter { it.unit!=null && it.unit!!.owner != unit.owner && civViewableTiles.contains(it)}) tileGroups[tile]!!.showCircle(Color().fromRGB(237,41,57)) } + + if(selectedTile!=null) + tileGroups[selectedTile!!]!!.showCircle(Color.WHITE) + } fun setCenterPosition(vector: Vector2) { diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index 0c0514e8ca..2494a4cf33 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -80,10 +80,4 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ selectedUnit= selectedTile.unit } - fun getTilesForCurrentlyExecutingAction(): Set - { - if(currentlyExecutingAction == "moveTo") - return selectedUnit!!.getDistanceToTiles().keys - return emptySet() - } }