All 'Turn' and 'Turns' texts changed to a turns icon, much cleaner!

This commit is contained in:
Yair Morgenstern 2020-08-24 19:45:53 +03:00
parent 879c416e30
commit 1f3b77d038
15 changed files with 920 additions and 861 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 869 KiB

After

Width:  |  Height:  |  Size: 880 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 477 KiB

After

Width:  |  Height:  |  Size: 481 KiB

View File

@ -73,7 +73,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
val table = Table().apply { defaults().pad(10f) } val table = Table().apply { defaults().pad(10f) }
val autosaveGame = GameSaver.getSave(autosave, false) val autosaveGame = GameSaver.getSave(autosave, false)
if (autosaveGame.exists()) { if (autosaveGame.exists()) {
val resumeTable = getTableBlock("Resume", "OtherIcons/Resume") { autoLoadGame() } val resumeTable = getTableBlock("Resume","OtherIcons/Resume") { autoLoadGame() }
table.add(resumeTable).row() table.add(resumeTable).row()
} }

View File

@ -4,6 +4,7 @@ import com.unciv.Constants
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.models.stats.INamed import com.unciv.models.stats.INamed
import com.unciv.models.translations.tr import com.unciv.models.translations.tr
import com.unciv.ui.utils.Fonts
import kotlin.math.roundToInt import kotlin.math.roundToInt
interface IConstruction : INamed { interface IConstruction : INamed {
@ -23,7 +24,7 @@ open class PerpetualConstruction(override var name: String, val description: Str
return isBuildable(cityConstructions) return isBuildable(cityConstructions)
} }
open fun getProductionTooltip(cityInfo: CityInfo) : String open fun getProductionTooltip(cityInfo: CityInfo) : String
= "\r\n${(cityInfo.cityStats.currentCityStats.production / CONVERSION_RATE).roundToInt()}/${"{turn}".tr()}" = "\r\n${(cityInfo.cityStats.currentCityStats.production / CONVERSION_RATE).roundToInt()}/${Fonts.turn}"
open fun getConversionRate(cityInfo: CityInfo) : Int open fun getConversionRate(cityInfo: CityInfo) : Int
= CONVERSION_RATE = CONVERSION_RATE
@ -34,7 +35,7 @@ open class PerpetualConstruction(override var name: String, val description: Str
return cityConstructions.cityInfo.civInfo.tech.getTechUniques().contains("Enables conversion of city production to science") return cityConstructions.cityInfo.civInfo.tech.getTechUniques().contains("Enables conversion of city production to science")
} }
override fun getProductionTooltip(cityInfo: CityInfo): String { override fun getProductionTooltip(cityInfo: CityInfo): String {
return "\r\n${(cityInfo.cityStats.currentCityStats.production / getConversionRate(cityInfo)).roundToInt()}/${"{turn}".tr()}" return "\r\n${(cityInfo.cityStats.currentCityStats.production / getConversionRate(cityInfo)).roundToInt()}/${Fonts.turn}"
} }
override fun getConversionRate(cityInfo: CityInfo) = (1/cityInfo.cityStats.getScienceConversionRate()).roundToInt() override fun getConversionRate(cityInfo: CityInfo) = (1/cityInfo.cityStats.getScienceConversionRate()).roundToInt()
} }

View File

@ -10,6 +10,7 @@ import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.tile.* import com.unciv.models.ruleset.tile.*
import com.unciv.models.stats.Stats import com.unciv.models.stats.Stats
import com.unciv.models.translations.tr import com.unciv.models.translations.tr
import com.unciv.ui.utils.Fonts
import kotlin.math.abs import kotlin.math.abs
open class TileInfo { open class TileInfo {
@ -372,7 +373,7 @@ open class TileInfo {
if (roadStatus !== RoadStatus.None && !isCityCenter()) lineList += roadStatus.toString().tr() if (roadStatus !== RoadStatus.None && !isCityCenter()) lineList += roadStatus.toString().tr()
if (improvement != null) lineList += improvement!!.tr() if (improvement != null) lineList += improvement!!.tr()
if (improvementInProgress != null && isViewableToPlayer) if (improvementInProgress != null && isViewableToPlayer)
lineList += "{$improvementInProgress}\r\n $turnsToImprovement {turns}".tr() // todo change to [] translation notation lineList += "{$improvementInProgress}\r\n $turnsToImprovement ${Fonts.turn}".tr() // todo change to [] translation notation
if (civilianUnit != null && isViewableToPlayer) if (civilianUnit != null && isViewableToPlayer)
lineList += civilianUnit!!.name.tr() + " - " + civilianUnit!!.civInfo.civName.tr() lineList += civilianUnit!!.name.tr() + " - " + civilianUnit!!.civInfo.civName.tr()
if (militaryUnit != null && isViewableToPlayer) { if (militaryUnit != null && isViewableToPlayer) {

View File

@ -8,6 +8,7 @@ import com.unciv.logic.city.PerpetualConstruction
import com.unciv.models.ruleset.Building import com.unciv.models.ruleset.Building
import com.unciv.models.ruleset.unit.BaseUnit import com.unciv.models.ruleset.unit.BaseUnit
import com.unciv.models.translations.tr import com.unciv.models.translations.tr
import com.unciv.ui.utils.Fonts
import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.ImageGetter
import com.unciv.ui.utils.surroundWithCircle import com.unciv.ui.utils.surroundWithCircle
import com.unciv.ui.utils.toLabel import com.unciv.ui.utils.toLabel
@ -80,6 +81,6 @@ class ConstructionInfoTable(val city: CityInfo): Table() {
} }
companion object { companion object {
internal fun turnOrTurns(turns: Int): String = "\r\n$turns ${(if (turns > 1) " {turns}" else " {turn}").tr()}" internal fun turnOrTurns(turns: Int): String = "\r\n$turns ${Fonts.turn}"
} }
} }

View File

@ -157,7 +157,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
} }
if (!civTech.isResearched(techName) || techName == Constants.futureTech) if (!civTech.isResearched(techName) || techName == Constants.futureTech)
text += "\r\n" + turnsToTech[techName] + " {turns}".tr() text += "\r\n" + turnsToTech[techName] + " ${Fonts.turn}".tr()
techButton.text.setText(text) techButton.text.setText(text)
} }

View File

@ -130,7 +130,7 @@ class LoadGameScreen(previousScreen:CameraStageBaseScreen) : PickerScreen() {
val game = GameSaver.loadGameFromFile(save) val game = GameSaver.loadGameFromFile(save)
val playerCivNames = game.civilizations.filter { it.isPlayerCivilization() }.joinToString { it.civName.tr() } val playerCivNames = game.civilizations.filter { it.isPlayerCivilization() }.joinToString { it.civName.tr() }
textToSet += "\n" + playerCivNames + textToSet += "\n" + playerCivNames +
", " + game.difficulty.tr() + ", {Turn} ".tr() + game.turns ", " + game.difficulty.tr() + ", ${Fonts.turn} ".tr() + game.turns
} catch (ex: Exception) { } catch (ex: Exception) {
textToSet += "\n{Could not load game}!".tr() textToSet += "\n{Could not load game}!".tr()
} }

View File

@ -3,12 +3,14 @@ package com.unciv.ui.utils
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.TextureData
import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData import com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData
import com.badlogic.gdx.graphics.g2d.BitmapFont.Glyph import com.badlogic.gdx.graphics.g2d.BitmapFont.Glyph
import com.badlogic.gdx.graphics.g2d.GlyphLayout import com.badlogic.gdx.graphics.g2d.GlyphLayout
import com.badlogic.gdx.graphics.g2d.PixmapPacker import com.badlogic.gdx.graphics.g2d.PixmapPacker
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.scenes.scene2d.ui.Image
import com.badlogic.gdx.utils.Array import com.badlogic.gdx.utils.Array
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import com.unciv.UncivGame import com.unciv.UncivGame
@ -54,7 +56,14 @@ class NativeBitmapFontData(val fontImplementation: NativeFontImplementation) : B
override fun getGlyph(ch: Char): Glyph { override fun getGlyph(ch: Char): Glyph {
var glyph: Glyph? = super.getGlyph(ch) var glyph: Glyph? = super.getGlyph(ch)
if (glyph == null) { if (glyph == null) {
val charPixmap = fontImplementation.getCharPixmap(ch) if(ch == '\uD83D' || ch == '\uD83C' ) return Glyph() // This is the 'first character' of an emoji - empty space
val charPixmap =
when (ch) {
Fonts.food[1] -> Fonts.extractPixmapFromTextureRegion(ImageGetter.getDrawable("EmojiIcons/Food").region)
Fonts.gold[1] -> Fonts.extractPixmapFromTextureRegion(ImageGetter.getDrawable("StatIcons/Gold").region)
Fonts.turn -> Fonts.extractPixmapFromTextureRegion(ImageGetter.getDrawable("EmojiIcons/Turn").region)
else -> fontImplementation.getCharPixmap(ch)
}
glyph = Glyph() glyph = Glyph()
glyph.id = ch.toInt() glyph.id = ch.toInt()
@ -100,4 +109,31 @@ object Fonts {
font.setOwnsTexture(true) font.setOwnsTexture(true)
font font
} }
// From https://stackoverflow.com/questions/29451787/libgdx-textureregion-to-pixmap
fun extractPixmapFromTextureRegion(textureRegion:TextureRegion):Pixmap {
val textureData = textureRegion.texture.textureData
if (!textureData.isPrepared) {
textureData.prepare()
}
val pixmap = Pixmap(
textureRegion.regionWidth,
textureRegion.regionHeight,
textureData.format
)
pixmap.drawPixmap(
textureData.consumePixmap(), // The other Pixmap
0, // The target x-coordinate (top left corner)
0, // The target y-coordinate (top left corner)
textureRegion.regionX, // The source x-coordinate (top left corner)
textureRegion.regionY, // The source y-coordinate (top left corner)
textureRegion.regionWidth, // The width of the area from the other Pixmap in pixels
textureRegion.regionHeight // The height of the area from the other Pixmap in pixels
)
return pixmap
}
const val food = "\uD83C\uDF4E"
const val gold = "\uD83D\uDCB0"
const val turn = '⏳'
} }

View File

@ -445,8 +445,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
innerButton.color = colorFromRGB(7, 46, 43) innerButton.color = colorFromRGB(7, 46, 43)
techButtonHolder.add(innerButton) techButtonHolder.add(innerButton)
val turnsToTech = viewingCiv.tech.turnsToTech(currentTech) val turnsToTech = viewingCiv.tech.turnsToTech(currentTech)
innerButton.text.setText(currentTech.tr() + "\r\n" + turnsToTech innerButton.text.setText(currentTech.tr() + "\r\n" + turnsToTech + " "+ Fonts.turn)
+ (if (turnsToTech > 1) " {turns}".tr() else " {turn}".tr()))
} else if (viewingCiv.tech.canResearchTech() || viewingCiv.tech.researchedTechnologies.any()) { } else if (viewingCiv.tech.canResearchTech() || viewingCiv.tech.researchedTechnologies.any()) {
val buttonPic = Table() val buttonPic = Table()
buttonPic.background = ImageGetter.getRoundedEdgeTableBackground(colorFromRGB(7, 46, 43)) buttonPic.background = ImageGetter.getRoundedEdgeTableBackground(colorFromRGB(7, 46, 43))

View File

@ -182,7 +182,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
val year = getYear(civInfo.gameInfo.gameParameters.gameSpeed, civInfo.gameInfo.turns).toInt() val year = getYear(civInfo.gameInfo.gameParameters.gameSpeed, civInfo.gameInfo.turns).toInt()
val yearText = "[" + abs(year) + "] " + if (year < 0) "BC" else "AD" val yearText = "[" + abs(year) + "] " + if (year < 0) "BC" else "AD"
turnsLabel.setText("Turn".tr() + " " + civInfo.gameInfo.turns + " | " + yearText.tr()) turnsLabel.setText(Fonts.turn + " " + civInfo.gameInfo.turns + " | " + yearText.tr())
turnsLabel.onClick { worldScreen.game.setScreen(VictoryScreen(worldScreen)) } turnsLabel.onClick { worldScreen.game.setScreen(VictoryScreen(worldScreen)) }
val nextTurnStats = civInfo.statsForNextTurn val nextTurnStats = civInfo.statsForNextTurn