diff --git a/android/Images.ConstructionIcons/OtherIcons/ConstructionCircle.png b/android/Images.ConstructionIcons/OtherIcons/ConstructionCircle.png new file mode 100644 index 0000000000000..3d919503e924b Binary files /dev/null and b/android/Images.ConstructionIcons/OtherIcons/ConstructionCircle.png differ diff --git a/android/Images.Tech/TechIcons/Circle.png b/android/Images.Tech/TechIcons/Circle.png new file mode 100644 index 0000000000000..3d919503e924b Binary files /dev/null and b/android/Images.Tech/TechIcons/Circle.png differ diff --git a/android/assets/ConstructionIcons.atlas b/android/assets/ConstructionIcons.atlas index 08a9f1171b63a..622762fc32e64 100644 --- a/android/assets/ConstructionIcons.atlas +++ b/android/assets/ConstructionIcons.atlas @@ -1621,6 +1621,13 @@ UnitIcons/Circle orig: 178, 178 offset: 0, 0 index: -1 +OtherIcons/ConstructionCircle + rotate: false + xy: 4, 1362 + size: 178, 178 + orig: 178, 178 + offset: 0, 0 + index: -1 UnitIcons/Companion Cavalry rotate: false xy: 406, 732 diff --git a/android/assets/Tech.atlas b/android/assets/Tech.atlas index 8f4276907555c..a54b174c1b461 100644 --- a/android/assets/Tech.atlas +++ b/android/assets/Tech.atlas @@ -6,581 +6,588 @@ filter: MipMapLinearLinear, MipMapLinearLinear repeat: none TechIcons/Acoustics rotate: false - xy: 4, 868 + xy: 4, 652 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Advanced Ballistics rotate: false - xy: 4, 760 + xy: 190, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Agriculture rotate: false - xy: 112, 868 + xy: 4, 544 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Animal Husbandry rotate: false - xy: 4, 652 + xy: 298, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Archaeology rotate: false - xy: 112, 760 + xy: 4, 436 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Archery rotate: false - xy: 220, 868 + xy: 406, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Architecture rotate: false - xy: 4, 544 + xy: 4, 328 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Astronomy rotate: false - xy: 112, 652 + xy: 514, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Atomic Theory rotate: false - xy: 220, 760 + xy: 4, 220 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Ballistics rotate: false - xy: 328, 868 + xy: 622, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Banking rotate: false - xy: 4, 436 + xy: 4, 112 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Biology rotate: false - xy: 112, 544 + xy: 730, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Bronze Working rotate: false - xy: 220, 652 + xy: 4, 4 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Calendar rotate: false - xy: 328, 760 + xy: 838, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Chemistry rotate: false - xy: 436, 868 + xy: 946, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Chivalry rotate: false - xy: 4, 328 + xy: 1054, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 +TechIcons/Circle + rotate: false + xy: 4, 760 + size: 178, 178 + orig: 178, 178 + offset: 0, 0 + index: -1 TechIcons/Civil Service rotate: false - xy: 112, 436 + xy: 1162, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Combined Arms rotate: false - xy: 220, 544 + xy: 1270, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Combustion rotate: false - xy: 328, 652 + xy: 1378, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Compass rotate: false - xy: 436, 760 + xy: 1486, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Computers rotate: false - xy: 544, 868 + xy: 1594, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Construction rotate: false - xy: 4, 220 + xy: 1702, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Currency rotate: false - xy: 112, 328 + xy: 1810, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Drama and Poetry rotate: false - xy: 220, 436 + xy: 1918, 838 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Dynamite rotate: false - xy: 328, 544 + xy: 112, 652 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Ecology rotate: false - xy: 436, 652 + xy: 112, 544 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Economics rotate: false - xy: 544, 760 + xy: 112, 436 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Education rotate: false - xy: 652, 868 + xy: 112, 328 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Electricity rotate: false - xy: 4, 112 + xy: 112, 220 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Electronics rotate: false - xy: 112, 220 + xy: 112, 112 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Engineering rotate: false - xy: 220, 328 + xy: 112, 4 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Fallback rotate: false - xy: 328, 436 + xy: 220, 730 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Fertilizer rotate: false - xy: 436, 544 + xy: 220, 622 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Flight rotate: false - xy: 544, 652 + xy: 328, 730 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Future Tech rotate: false - xy: 652, 760 + xy: 220, 514 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Globalization rotate: false - xy: 760, 868 + xy: 328, 622 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Guilds rotate: false - xy: 4, 4 + xy: 436, 730 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Gunpowder rotate: false - xy: 112, 112 + xy: 220, 406 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Horseback Riding rotate: false - xy: 220, 220 + xy: 328, 514 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Industrialization rotate: false - xy: 328, 328 + xy: 436, 622 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Iron Working rotate: false - xy: 436, 436 + xy: 544, 730 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Lasers rotate: false - xy: 544, 544 + xy: 220, 298 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Machinery rotate: false - xy: 652, 652 + xy: 328, 406 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Masonry rotate: false - xy: 760, 760 + xy: 436, 514 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Mass Media rotate: false - xy: 868, 868 + xy: 544, 622 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Mathematics rotate: false - xy: 112, 4 + xy: 652, 730 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Metal Casting rotate: false - xy: 220, 112 + xy: 220, 190 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Metallurgy rotate: false - xy: 328, 220 + xy: 328, 298 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Military Science rotate: false - xy: 436, 328 + xy: 436, 406 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Mining rotate: false - xy: 544, 436 + xy: 544, 514 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Mobile Tactics rotate: false - xy: 652, 544 + xy: 652, 622 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Nanotechnology rotate: false - xy: 760, 652 + xy: 760, 730 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Navigation rotate: false - xy: 868, 760 + xy: 220, 82 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Nuclear Fission rotate: false - xy: 976, 868 + xy: 328, 190 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Nuclear Fusion rotate: false - xy: 220, 4 + xy: 436, 298 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Optics rotate: false - xy: 328, 112 + xy: 544, 406 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Particle Physics rotate: false - xy: 436, 220 + xy: 652, 514 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Pharmaceuticals rotate: false - xy: 544, 328 + xy: 760, 622 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Philosophy rotate: false - xy: 652, 436 + xy: 868, 730 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Physics rotate: false - xy: 760, 544 + xy: 328, 82 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Plastics rotate: false - xy: 868, 652 + xy: 436, 190 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Pottery rotate: false - xy: 976, 760 + xy: 544, 298 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Printing Press rotate: false - xy: 1084, 868 + xy: 652, 406 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Radar rotate: false - xy: 328, 4 + xy: 760, 514 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Radio rotate: false - xy: 436, 112 + xy: 868, 622 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Railroads rotate: false - xy: 544, 220 + xy: 976, 730 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Refrigeration rotate: false - xy: 652, 328 + xy: 436, 82 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Replaceable Parts rotate: false - xy: 760, 436 + xy: 544, 190 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Rifling rotate: false - xy: 868, 544 + xy: 652, 298 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Robotics rotate: false - xy: 976, 652 + xy: 760, 406 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Rocketry rotate: false - xy: 1084, 760 + xy: 868, 514 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Sailing rotate: false - xy: 1192, 868 + xy: 976, 622 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Satellites rotate: false - xy: 436, 4 + xy: 1084, 730 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Scientific Theory rotate: false - xy: 544, 112 + xy: 544, 82 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Stealth rotate: false - xy: 652, 220 + xy: 652, 190 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Steam Power rotate: false - xy: 760, 328 + xy: 760, 298 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Steel rotate: false - xy: 868, 436 + xy: 868, 406 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Telecommunications rotate: false - xy: 976, 544 + xy: 976, 514 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Telegraph rotate: false - xy: 1084, 652 + xy: 1084, 622 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/The Wheel rotate: false - xy: 1192, 760 + xy: 1192, 730 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Theology rotate: false - xy: 1300, 868 + xy: 652, 82 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Trapping rotate: false - xy: 544, 4 + xy: 760, 190 size: 100, 100 orig: 100, 100 offset: 0, 0 index: -1 TechIcons/Writing rotate: false - xy: 652, 112 + xy: 868, 298 size: 100, 100 orig: 100, 100 offset: 0, 0 diff --git a/android/assets/Tech.png b/android/assets/Tech.png index 682867070779c..cf491fcc9159a 100644 Binary files a/android/assets/Tech.png and b/android/assets/Tech.png differ diff --git a/buildSrc/src/main/kotlin/BuildConfig.kt b/buildSrc/src/main/kotlin/BuildConfig.kt index 52ef9189f24ac..fc4fb7e55bf41 100644 --- a/buildSrc/src/main/kotlin/BuildConfig.kt +++ b/buildSrc/src/main/kotlin/BuildConfig.kt @@ -4,8 +4,8 @@ package com.unciv.build object BuildConfig { const val kotlinVersion = "1.9.24" const val appName = "Unciv" - const val appCodeNumber = 1090 - const val appVersion = "4.15.2" + const val appCodeNumber = 1091 + const val appVersion = "4.15.2-patch1" const val gdxVersion = "1.13.1" const val ktorVersion = "2.3.12" diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index 1b2abd0f70b8a..f8b165daf53a6 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -487,7 +487,7 @@ open class UncivGame(val isConsoleMode: Boolean = false) : Game(), PlatformSpeci companion object { //region AUTOMATICALLY GENERATED VERSION DATA - DO NOT CHANGE THIS REGION, INCLUDING THIS COMMENT - val VERSION = Version("4.15.2", 1090) + val VERSION = Version("4.15.2-patch1", 1091) //endregion /** Global reference to the one Gdx.Game instance created by the platform launchers - do not use without checking [isCurrentInitialized] first. */ diff --git a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt index 37ce4aa011708..733e2cccd9bb1 100644 --- a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt @@ -84,7 +84,7 @@ class WorkerAutomation( val tileToWork = findTileToWork(unit, dangerousTiles, localUniqueCache) if (tileToWork != currentTile && tileToWork != null) { - headTowardsTileToWork(unit, tileToWork) + headTowardsTileToWork(unit, tileToWork, localUniqueCache) return } @@ -160,6 +160,7 @@ class WorkerAutomation( private fun headTowardsTileToWork( unit: MapUnit, tileToWork: Tile, + localUniqueCache: LocalUniqueCache ) { debug("WorkerAutomation: %s -> head towards %s", unit.toString(), tileToWork) val currentTile = unit.getTile() @@ -194,7 +195,8 @@ class WorkerAutomation( // tileRankings is updated in getBasePriority, which is only called if isAutomationWorkableTile is true // Meaning, there are tiles we can't/shouldn't work, and they won't even be in tileRankings - if (unit.currentTile in tileRankings) startWorkOnCurrentTile(unit) + if (tileHasWorkToDo(unit.currentTile, unit, localUniqueCache)) + startWorkOnCurrentTile(unit) } diff --git a/core/src/com/unciv/logic/map/mapgenerator/mapregions/RegionStartFinder.kt b/core/src/com/unciv/logic/map/mapgenerator/mapregions/RegionStartFinder.kt index 5f1c9d5dc3335..5bcb013f653ac 100644 --- a/core/src/com/unciv/logic/map/mapgenerator/mapregions/RegionStartFinder.kt +++ b/core/src/com/unciv/logic/map/mapgenerator/mapregions/RegionStartFinder.kt @@ -227,4 +227,4 @@ object RegionStartFinder { tileData[outerTile]!!.addCloseStartPenalty(penalty) } } -} \ No newline at end of file +} diff --git a/core/src/com/unciv/logic/map/mapgenerator/resourceplacement/StrategicBonusResourcePlacementLogic.kt b/core/src/com/unciv/logic/map/mapgenerator/resourceplacement/StrategicBonusResourcePlacementLogic.kt index c96ac9939bcdc..f179bf5d96829 100644 --- a/core/src/com/unciv/logic/map/mapgenerator/resourceplacement/StrategicBonusResourcePlacementLogic.kt +++ b/core/src/com/unciv/logic/map/mapgenerator/resourceplacement/StrategicBonusResourcePlacementLogic.kt @@ -352,4 +352,4 @@ object StrategicBonusResourcePlacementLogic { } return ruleLists } -} \ No newline at end of file +} diff --git a/core/src/com/unciv/ui/images/ImageGetter.kt b/core/src/com/unciv/ui/images/ImageGetter.kt index 20ca0e7e5c451..ab42883a43021 100644 --- a/core/src/com/unciv/ui/images/ImageGetter.kt +++ b/core/src/com/unciv/ui/images/ImageGetter.kt @@ -5,6 +5,7 @@ import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture.TextureFilter +import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.graphics.g2d.NinePatch import com.badlogic.gdx.graphics.g2d.TextureAtlas import com.badlogic.gdx.graphics.g2d.TextureRegion @@ -358,6 +359,8 @@ object ImageGetter { setSize(width, height) } + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) + fun setLabel(color: Color, text: String, fontSize: Int = Constants.defaultFontSize) : ProgressBar { label = text.toLabel() label?.setAlignment(Align.center) diff --git a/core/src/com/unciv/ui/images/Portrait.kt b/core/src/com/unciv/ui/images/Portrait.kt index 4a521943a8752..4f2e65e8ad747 100644 --- a/core/src/com/unciv/ui/images/Portrait.kt +++ b/core/src/com/unciv/ui/images/Portrait.kt @@ -1,6 +1,7 @@ package com.unciv.ui.images import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.scenes.scene2d.Group import com.badlogic.gdx.scenes.scene2d.ui.Image import com.badlogic.gdx.scenes.scene2d.ui.Table @@ -95,6 +96,9 @@ open class Portrait(val type: Type, val imageName: String, val size: Float, val else -> getDefaultImage().apply { color = getDefaultImageTint() } } } + + // Overridable so portraits can use circle images from their texture to minimize texture swapping + protected open fun getCircleImage() = ImageGetter.getCircle() /** Border / background */ private fun getMainBackground() : Group { @@ -105,14 +109,16 @@ open class Portrait(val type: Type, val imageName: String, val size: Float, val val ratioH = image.height / backgroundImage.height image.setSize((size + borderSize)*ratioW, (size + borderSize)*ratioH) return backgroundImage.toGroup(size + borderSize) - } else { image.setSize(size*0.75f, size*0.75f) - val bg = Group().apply { isTransform = false } + val bg = object: Group(){ + init { apply { isTransform = false } } + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) + } - val circleInner = ImageGetter.getCircle() - val circleOuter = ImageGetter.getCircle() + val circleInner = getCircleImage() + val circleOuter = getCircleImage() circleInner.setSize(size, size) circleOuter.setSize(size + borderSize, size + borderSize) @@ -159,20 +165,29 @@ class PortraitResource(name: String, size: Float, amount: Int = 0) : Portrait(Ty override fun getDefaultInnerBackgroundTint(): Color = ruleset.tileResources[imageName]?.resourceType?.getColor() ?: Color.WHITE + + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) } class PortraitTech(name: String, size: Float) : Portrait(Type.Tech, name, size) { override fun getDefaultOuterBackgroundTint(): Color = getDefaultImageTint() override fun getDefaultImageTint(): Color = ruleset.eras[ruleset.technologies[imageName]?.era()]?.getColor()?.darken(0.6f) ?: ImageGetter.CHARCOAL + + override fun getCircleImage(): Image = ImageGetter.getImage("TechIcons/Circle") + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) } class PortraitUnit(name: String, size: Float) : Portrait(Type.Unit, name, size) { override fun getDefaultImageTint(): Color = Color.BLACK + override fun getCircleImage() = ImageGetter.getImage("OtherIcons/ConstructionCircle") + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) } class PortraitBuilding(name: String, size: Float) : Portrait(Type.Building, name, size) { override fun getDefaultImageTint(): Color = Color.BLACK + override fun getCircleImage() = ImageGetter.getImage("OtherIcons/ConstructionCircle") + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) } class PortraitUnavailableWonderForTechTree(name: String, size: Float) : Portrait(Type.Building, name, size) { @@ -218,6 +233,8 @@ class PortraitImprovement(name: String, size: Float, dim: Boolean = false, isPil return getColorFromStats(improvement) return Color.WHITE } + + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) } class PortraitNation(name: String, size: Float) : Portrait(Type.Nation, name, size, size*0.1f) { diff --git a/core/src/com/unciv/ui/screens/pickerscreens/TechButton.kt b/core/src/com/unciv/ui/screens/pickerscreens/TechButton.kt index 6b2b3ea426600..37d7b8aedb429 100644 --- a/core/src/com/unciv/ui/screens/pickerscreens/TechButton.kt +++ b/core/src/com/unciv/ui/screens/pickerscreens/TechButton.kt @@ -1,6 +1,7 @@ package com.unciv.ui.screens.pickerscreens import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.scenes.scene2d.Touchable import com.badlogic.gdx.scenes.scene2d.ui.Image import com.badlogic.gdx.scenes.scene2d.ui.Table @@ -42,10 +43,11 @@ class TechButton( val path = "TechPickerScreen/TechButton" val default = BaseScreen.skinStrings.roundedEdgeRectangleMidShape - backgroundImage = Image(BaseScreen.skinStrings.getUiBackground(path, default)) + backgroundImage = object : Image(BaseScreen.skinStrings.getUiBackground(path, default)){ + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) + } background = BaseScreen.skinStrings.getUiBackground(path, default, Color.WHITE.darken(0.3f)) - backgroundImage.toBack() addActor(backgroundImage) pad(5f, 5f, 5f, 0f) @@ -67,7 +69,9 @@ class TechButton( add(progressBar.addBorder(1f, Color.GRAY.cpy())).padLeft(0f).padRight(5f) } - val rightSide = Table() + val rightSide = object : Table() { + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) + } rightSide.add(text).width(140f).top().left().padRight(15f) rightSide.add(turns).width(40f).top().left().padRight(10f).row() @@ -76,6 +80,10 @@ class TechButton( rightSide.centerY(this) add(rightSide).expandX().left() + + // Render both Skin images adjacently to reduce a texture swap between them + rightSide.toBack() + backgroundImage.toBack() pack() backgroundImage.setSize(width - 3f, height - 3f) @@ -91,7 +99,10 @@ class TechButton( } private fun addTechEnabledIcons(techName: String, rightSide: Table) { - val techEnabledIcons = Table().align(Align.left) + val techEnabledIcons = object : Table(){ + init { align(Align.left) } + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) + } techEnabledIcons.background = BaseScreen.skinStrings.getUiBackground( "TechPickerScreen/TechButtonIconsOutline", BaseScreen.skinStrings.roundedEdgeRectangleSmallShape, @@ -113,6 +124,10 @@ class TechButton( .prefWidth(195f) .maxWidth(195f) .expandX().left().row() + + techEnabledIcons.toBack() // First thing in the table to render so the 2 skin textures are rendered back to back } + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) + } diff --git a/core/src/com/unciv/ui/screens/pickerscreens/TechPickerScreen.kt b/core/src/com/unciv/ui/screens/pickerscreens/TechPickerScreen.kt index cd9299a041ce5..f25093999cf6c 100644 --- a/core/src/com/unciv/ui/screens/pickerscreens/TechPickerScreen.kt +++ b/core/src/com/unciv/ui/screens/pickerscreens/TechPickerScreen.kt @@ -1,6 +1,7 @@ package com.unciv.ui.screens.pickerscreens import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.scenes.scene2d.ui.Image import com.badlogic.gdx.scenes.scene2d.ui.Label @@ -52,7 +53,9 @@ class TechPickerScreen( * Having this be a separate table allows us to leave the TopTable as is (that is: auto-width to fit the scrollPane) * leaving us the juicy small tech tree right in the center. */ - private val techTable = Table() + private val techTable = object : Table(){ + override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) + } // All these are to counter performance problems when updating buttons for all techs. private var researchableTechs = ruleset.technologies.keys @@ -463,5 +466,4 @@ class TechPickerScreen( rightSideButton.disable() } } - }