From c984704af149ad9e316597301116c95f96e12949 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 25 May 2018 13:04:31 +0300 Subject: [PATCH] The "Construct improvement" action is now disabled when the unit has no movement or there are no improvements to pick --- android/build.gradle | 4 ++-- .../com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt | 6 +++++- core/src/com/unciv/ui/utils/ImageGetter.kt | 1 + core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt | 5 +++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 2c755939e9..4b747e074f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.game" minSdkVersion 14 targetSdkVersion 26 - versionCode 63 - versionName "2.2.4" + versionCode 64 + versionName "2.2.5" } buildTypes { release { diff --git a/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt index ec4407530f..fcb08f8764 100644 --- a/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt @@ -30,7 +30,11 @@ class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() { if (!tileInfo.canBuildImprovement(improvement, civInfo) || improvement.name == tileInfo.improvement) continue val improvementButton = Button(skin) - improvementButton.add(ImageGetter.getImprovementIcon(improvement.name)).size(30f).pad(10f) + + if(improvement.name.startsWith("Remove")) + improvementButton.add(ImageGetter.getImage("OtherIcons/Stop.png")).size(30f).pad(10f) + else improvementButton.add(ImageGetter.getImprovementIcon(improvement.name)).size(30f).pad(10f) + improvementButton.add(Label(improvement.name + " - " + improvement.getTurnsToBuild(civInfo) + " turns",skin) .setFontColor(Color.WHITE)).pad(10f) diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 982b62a9cd..676d8c4f01 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -31,6 +31,7 @@ object ImageGetter { textureRegionByFileName[fileName] = TextureRegion(texture) } } catch (ex: Exception) { + return getTextureRegion(WhiteDot) throw Exception("File $fileName not found!",ex) } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 7b9e45ff7b..bab25627fd 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -64,8 +64,9 @@ class UnitActions { if (unit.name == "Worker") { actionList += UnitAction("Construct improvement", { worldScreen.game.screen = ImprovementPickerScreen(tile) }, - unit.currentMovement != 0f && - !tile.isCityCenter() || GameBasics.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }) + unit.currentMovement != 0f + && !tile.isCityCenter() + && GameBasics.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }) if("automation" == unit.action){ actionList += UnitAction("Stop automation",