Anti-Armor, negative tile yield, LoadScreen (#5018)

* Harden against negative yields, Anti-Armor

* Anti-Armor bad unitType, LoadScreen
This commit is contained in:
SomeTroglodyte
2021-08-29 10:33:20 +02:00
committed by GitHub
parent 6a3fddc757
commit 5a6a9c9759
7 changed files with 25 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -422,13 +422,14 @@
}, },
{ {
"name": "Anti-Armor I", "name": "Anti-Armor I",
"uniques": ["+[25]% vs [Armored]"], "uniques": ["+[25]% Strength vs [Armored]"],
"unitTypes:": ["Helicopter"] "unitTypes": ["Helicopter"]
}, },
{ {
"name": "Anti-Armor II", "name": "Anti-Armor II",
"uniques": ["+[25]% vs [Armored]"], "prerequisites": ["Anti-Armor I"],
"unitTypes:": ["Helicopter"] "uniques": ["+[25]% Strength vs [Armored]"],
"unitTypes": ["Helicopter"]
}, },
// Mixed // Mixed
@ -473,13 +474,13 @@
{ {
"name": "Ambush I", "name": "Ambush I",
"uniques": ["+[33]% Strength vs [Armored]"], "uniques": ["+[25]% Strength vs [Armored]"],
"unitTypes": ["Sword","Gunpowder","Fighter","Bomber"] "unitTypes": ["Sword","Gunpowder","Fighter","Bomber"]
}, },
{ {
"name": "Ambush II", "name": "Ambush II",
"prerequisites": ["Ambush I"], "prerequisites": ["Ambush I"],
"uniques": ["+[33]% Strength vs [Armored]"], "uniques": ["+[25]% Strength vs [Armored]"],
"unitTypes": ["Sword","Gunpowder","Fighter","Bomber"] "unitTypes": ["Sword","Gunpowder","Fighter","Bomber"]
}, },

View File

@ -84,8 +84,10 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
* - Skin (hence CameraStageBaseScreen.setSkin()) * - Skin (hence CameraStageBaseScreen.setSkin())
* - Font (hence Fonts.resetFont() inside setSkin()) * - Font (hence Fonts.resetFont() inside setSkin())
*/ */
ImageGetter.resetAtlases()
settings = GameSaver.getGeneralSettings() // needed for the screen settings = GameSaver.getGeneralSettings() // needed for the screen
screen = LoadingScreen() // NOT dependent on any atlas or skin
ImageGetter.resetAtlases()
ImageGetter.setNewRuleset(ImageGetter.ruleset) // This needs to come after the settings, since we may have default visual mods ImageGetter.setNewRuleset(ImageGetter.ruleset) // This needs to come after the settings, since we may have default visual mods
if(settings.tileSet !in ImageGetter.getAvailableTilesets()) { // If one of the tilesets is no longer available, default back if(settings.tileSet !in ImageGetter.getAvailableTilesets()) { // If one of the tilesets is no longer available, default back
settings.tileSet = "FantasyHex" settings.tileSet = "FantasyHex"
@ -94,8 +96,6 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
CameraStageBaseScreen.setSkin() // needs to come AFTER the Texture reset, since the buttons depend on it CameraStageBaseScreen.setSkin() // needs to come AFTER the Texture reset, since the buttons depend on it
Gdx.graphics.isContinuousRendering = settings.continuousRendering Gdx.graphics.isContinuousRendering = settings.continuousRendering
screen = LoadingScreen()
thread(name = "LoadJSON") { thread(name = "LoadJSON") {
RulesetCache.loadRulesets(printOutput = true) RulesetCache.loadRulesets(printOutput = true)
@ -206,9 +206,9 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
} }
} }
class LoadingScreen:CameraStageBaseScreen() { private class LoadingScreen : CameraStageBaseScreen() {
init { init {
val happinessImage = ImageGetter.getImage("StatIcons/Happiness") val happinessImage = ImageGetter.getExternalImage("LoadScreen.png")
happinessImage.center(stage) happinessImage.center(stage)
happinessImage.setOrigin(Align.center) happinessImage.setOrigin(Align.center)
happinessImage.addAction(Actions.sequence( happinessImage.addAction(Actions.sequence(

View File

@ -280,7 +280,8 @@ open class TileInfo {
if (stats.gold != 0f && observingCiv.goldenAges.isGoldenAge()) if (stats.gold != 0f && observingCiv.goldenAges.isGoldenAge())
stats.gold++ stats.gold++
if (stats.production < 0) stats.production = 0f for ((stat, value) in stats)
if (value < 0f) stats[stat] = 0f
return stats return stats
} }

View File

@ -19,7 +19,8 @@ class YieldGroup : HorizontalGroup() {
currentStats = stats currentStats = stats
clearChildren() clearChildren()
for ((stat, amount) in stats) { for ((stat, amount) in stats) {
addActor(getStatIconsTable(stat.name, amount.toInt())) if (amount > 0f) // Defense against upstream bugs - negatives would show as "lots"
addActor(getStatIconsTable(stat.name, amount.toInt()))
} }
pack() pack()
} }

View File

@ -3,6 +3,7 @@ package com.unciv.ui.utils
import com.badlogic.gdx.Gdx import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.Texture.TextureFilter
import com.badlogic.gdx.graphics.g2d.NinePatch import com.badlogic.gdx.graphics.g2d.NinePatch
import com.badlogic.gdx.graphics.g2d.TextureAtlas import com.badlogic.gdx.graphics.g2d.TextureAtlas
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
@ -16,7 +17,6 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
import com.badlogic.gdx.utils.Align import com.badlogic.gdx.utils.Align
import com.unciv.Constants import com.unciv.Constants
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.logic.map.TileMap
import com.unciv.models.ruleset.Era import com.unciv.models.ruleset.Era
import com.unciv.models.ruleset.Nation import com.unciv.models.ruleset.Nation
import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.Ruleset
@ -153,7 +153,12 @@ object ImageGetter {
fun getDot(dotColor: Color) = getWhiteDot().apply { color = dotColor } fun getDot(dotColor: Color) = getWhiteDot().apply { color = dotColor }
fun getExternalImage(fileName: String): Image { fun getExternalImage(fileName: String): Image {
return Image(TextureRegion(Texture("ExtraImages/$fileName"))) // Since these are not packed in an atlas, they have no scaling filter metadata and
// default to Nearest filter, anisotropic level 1. Use Linear instead, helps
// loading screen and Tutorial.WorldScreen quite a bit. More anisotropy barely helps.
val texture = Texture("ExtraImages/$fileName")
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear)
return Image(TextureRegion(texture))
} }
fun getImage(fileName: String): Image { fun getImage(fileName: String): Image {