From 9e3772a58d0cedefa9e1199bcb028f3c75140d76 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 12 Jun 2018 21:28:17 +0300 Subject: [PATCH] All text is now Roboto and much sharper! Added lots of "Translatable" words Organized City Screen a little bit --- core/src/com/unciv/ui/VictoryScreen.kt | 3 +- .../src/com/unciv/ui/cityscreen/CityScreen.kt | 37 ++++++++++--------- .../com/unciv/ui/cityscreen/CityStatsTable.kt | 9 ++--- .../pickerscreens/ImprovementPickerScreen.kt | 3 +- .../unciv/ui/utils/CameraStageBaseScreen.kt | 19 ++++++++-- .../ui/worldscreen/NotificationsScroll.kt | 8 +--- .../com/unciv/ui/worldscreen/WorldScreen.kt | 11 ++---- .../ui/worldscreen/bottombar/BattleTable.kt | 3 +- .../WorldScreenDisplayOptionsTable.kt | 3 ++ .../optionstable/WorldScreenOptionsTable.kt | 17 +++++---- .../unciv/ui/worldscreen/unit/UnitTable.kt | 7 ++-- 11 files changed, 64 insertions(+), 56 deletions(-) diff --git a/core/src/com/unciv/ui/VictoryScreen.kt b/core/src/com/unciv/ui/VictoryScreen.kt index e2b50efbec..ae1e733584 100644 --- a/core/src/com/unciv/ui/VictoryScreen.kt +++ b/core/src/com/unciv/ui/VictoryScreen.kt @@ -7,6 +7,7 @@ import com.unciv.UnCivGame import com.unciv.models.gamebasics.GameBasics import com.unciv.ui.pickerscreens.PickerScreen import com.unciv.ui.utils.addClickListener +import com.unciv.ui.utils.tr class VictoryScreen : PickerScreen() { @@ -46,7 +47,7 @@ class VictoryScreen : PickerScreen() { } fun won(){ - rightSideButton.setText("Start new game") + rightSideButton.setText("Start new game".tr()) rightSideButton.isVisible=true closeButton.isVisible=false rightSideButton.addClickListener { UnCivGame.Current.startNewGame(true) } diff --git a/core/src/com/unciv/ui/cityscreen/CityScreen.kt b/core/src/com/unciv/ui/cityscreen/CityScreen.kt index 4805898a79..07c31b0f21 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreen.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreen.kt @@ -10,10 +10,7 @@ import com.unciv.logic.HexMath import com.unciv.logic.city.CityInfo import com.unciv.logic.map.TileInfo import com.unciv.models.stats.Stats -import com.unciv.ui.utils.CameraStageBaseScreen -import com.unciv.ui.utils.ImageGetter -import com.unciv.ui.utils.addClickListener -import com.unciv.ui.utils.centerX +import com.unciv.ui.utils.* import java.util.* class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { @@ -24,12 +21,10 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { private var cityStatsTable = CityStatsTable(this) private var statExplainer = Table(skin) private var cityPickerTable = Table() - private var goToWorldButton = TextButton("Exit city", CameraStageBaseScreen.skin) + private var goToWorldButton = TextButton("Exit city".tr(), CameraStageBaseScreen.skin) private var tileGroups = ArrayList() init { - Label("", CameraStageBaseScreen.skin).style.font.data.setScale(1.5f) - addTiles() stage.addActor(tileTable) @@ -119,7 +114,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { private fun updateCityPickerTable() { cityPickerTable.clear() - cityPickerTable.row().pad(20f) + cityPickerTable.row() val civInfo = city.civInfo if (civInfo.cities.size > 1) { @@ -130,13 +125,19 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { game.screen = CityScreen(civInfo.cities[indexOfNextCity]) dispose() } - cityPickerTable.add(prevCityButton) + cityPickerTable.add(prevCityButton).pad(20f) + } + + if(city.isCapital()){ + val starImage = Image(ImageGetter.getDrawable("OtherIcons/Star.png").tint(Color.LIGHT_GRAY)) + cityPickerTable.add(starImage).size(20f).padRight(5f) } val currentCityLabel = Label(city.name+" ("+city.population.population+")", CameraStageBaseScreen.skin) - currentCityLabel.setFontScale(2f) + currentCityLabel.setFont(25) cityPickerTable.add(currentCityLabel) + if (civInfo.cities.size > 1) { val nextCityButton = TextButton(">", CameraStageBaseScreen.skin) nextCityButton.addClickListener { @@ -145,20 +146,19 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { game.screen = CityScreen(civInfo.cities[indexOfNextCity]) dispose() } - cityPickerTable.add(nextCityButton) + cityPickerTable.add(nextCityButton).pad(20f) } cityPickerTable.row() - if (civInfo.cities.size > 1) cityPickerTable.add() if(!city.isBeingRazed) { - val razeCityButton = TextButton("Raze city", skin) + val razeCityButton = TextButton("Raze city".tr(), skin) razeCityButton.addClickListener { city.isBeingRazed=true; update() } - cityPickerTable.add(razeCityButton) + cityPickerTable.add(razeCityButton).colspan(cityPickerTable.columns) } else{ - val stopRazingCityButton = TextButton("Stop razing city", skin) + val stopRazingCityButton = TextButton("Stop razing city".tr(), skin) stopRazingCityButton.addClickListener { city.isBeingRazed=false; update() } - cityPickerTable.add(stopRazingCityButton) + cityPickerTable.add(stopRazingCityButton).colspan(cityPickerTable.columns) } cityPickerTable.pack() @@ -174,8 +174,9 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { dispose() } + goToWorldButton.pad(5f) goToWorldButton.setSize(goToWorldButton.prefWidth, goToWorldButton.prefHeight) - goToWorldButton.setPosition(10f, stage.height - goToWorldButton.height - 5f) + goToWorldButton.setPosition(20f, stage.height - goToWorldButton.height - 20) } private fun addTiles() { @@ -248,7 +249,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { tileTable.columnDefaults(0).padRight(10f) val cityStatsHeader = Label("Tile Stats", CameraStageBaseScreen.skin) - cityStatsHeader.setFontScale(2f) + cityStatsHeader.setFont(25) tileTable.add(cityStatsHeader).colspan(2).pad(10f) tileTable.row() diff --git a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt index 941830033d..91f7daeb35 100644 --- a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt @@ -8,10 +8,7 @@ import com.unciv.UnCivGame import com.unciv.logic.city.SpecialConstruction import com.unciv.models.gamebasics.Building import com.unciv.ui.pickerscreens.ConstructionPickerScreen -import com.unciv.ui.utils.CameraStageBaseScreen -import com.unciv.ui.utils.ImageGetter -import com.unciv.ui.utils.addClickListener -import com.unciv.ui.utils.disable +import com.unciv.ui.utils.* import java.util.* class CityStatsTable(val cityScreen: CityScreen) : Table(){ @@ -25,7 +22,7 @@ class CityStatsTable(val cityScreen: CityScreen) : Table(){ val cityStatsHeader = Label("City Stats", CameraStageBaseScreen.skin) - cityStatsHeader.setFontScale(2f) + cityStatsHeader.setFont(15) add(cityStatsHeader).colspan(2).pad(10f) row() @@ -64,7 +61,7 @@ class CityStatsTable(val cityScreen: CityScreen) : Table(){ !(construction is Building && construction.isWonder)) { row() val buildingGoldCost = construction.getGoldCost(city.civInfo.policies.getAdoptedPolicies()) - val buildingBuyButton = TextButton("Buy for \r\n$buildingGoldCost gold", CameraStageBaseScreen.skin) + val buildingBuyButton = TextButton("Buy for".tr()+"\r\n$buildingGoldCost gold", CameraStageBaseScreen.skin) buildingBuyButton.addClickListener { city.cityConstructions.purchaseBuilding(city.cityConstructions.currentConstruction) update() diff --git a/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt index b2d4f7b0c1..f89aacf299 100644 --- a/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt @@ -10,6 +10,7 @@ import com.unciv.models.gamebasics.tile.TileImprovement import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.addClickListener import com.unciv.ui.utils.setFontColor +import com.unciv.ui.utils.tr class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() { private var selectedImprovement: TileImprovement? = null @@ -35,7 +36,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() { 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) + improvementButton.add(Label(improvement.name + " - " + improvement.getTurnsToBuild(civInfo) + " "+"turns".tr(),skin) .setFontColor(Color.WHITE)).pad(10f) improvementButton.addClickListener { diff --git a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt index 0889fe54ff..e85b9de2c5 100644 --- a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt @@ -91,6 +91,9 @@ open class CameraStageBaseScreen : Screen { companion object { var skin = Skin(Gdx.files.internal("skin/flat-earth-ui.json")) + .apply { + get(TextButton.TextButtonStyle::class.java).font = getFont(20) + get(Label.LabelStyle::class.java).font = getFont(18) } internal var batch: Batch = SpriteBatch() } @@ -124,22 +127,30 @@ fun Label.setFontColor(color:Color): Label {style=Label.LabelStyle(style).apply fun String.tr(): String {return GameBasics.Translations.get(this,UnCivGame.Current.settings.language)} fun getFont(size: Int): BitmapFont { +// var screenScale = Gdx.graphics.width / 1000f // screen virtual width as defined in CameraStageBaseScreen +// if(screenScale<1) screenScale=1f + val generator = FreeTypeFontGenerator(Gdx.files.internal("skin/Roboto-Regular.ttf")) val parameter = FreeTypeFontGenerator.FreeTypeFontParameter() parameter.size = size - parameter.genMipMaps = true - parameter.minFilter = Texture.TextureFilter.MipMapLinearLinear - parameter.magFilter = Texture.TextureFilter.MipMapLinearLinear +// parameter.genMipMaps = true + parameter.minFilter = Texture.TextureFilter.Linear + parameter.magFilter = Texture.TextureFilter.Linear parameter.characters = "ABCČĆDĐEFGHIJKLMNOPQRSŠTUVWXYZŽabcčćdđefghijklmnopqrsštuvwxyzžАБВГҐДЂЕЁЄЖЗЅИІЇЙЈКЛЉМНЊОПРСТЋУЎФХЦЧЏШЩЪЫЬЭЮЯабвгґдђеёєжзѕиіїйјклљмнњопрстћуўфхцчџшщъыьэюяΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψωάΆέΈέΉίϊΐΊόΌύΰϋΎΫΏĂÂÊÔƠƯăâêôơư1234567890‘?’“!”(%)[#]{@}/&\\<-+÷×=>®©\$€£¥¢:;,.*|" + //generator.scaleForPixelHeight(size) + + val font = generator.generateFont(parameter) // font size 12 pixels +// font.data.setScale(1f/screenScale) generator.dispose() // don't forget to dispose to avoid memory leaks! return font } -fun Label.setFont(size:Int) { +fun Label.setFont(size:Int): Label { style = Label.LabelStyle(style) style.font = getFont(size) style = style // because we need it to call the SetStyle function. Yuk, I know. + return this // for chaining } fun Actor.addClickListener(function: () -> Unit) { diff --git a/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt b/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt index 121b7da091..753484d9ca 100644 --- a/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt +++ b/core/src/com/unciv/ui/worldscreen/NotificationsScroll.kt @@ -5,10 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane import com.badlogic.gdx.scenes.scene2d.ui.Table import com.unciv.logic.civilization.Notification -import com.unciv.ui.utils.CameraStageBaseScreen -import com.unciv.ui.utils.ImageGetter -import com.unciv.ui.utils.addClickListener -import com.unciv.ui.utils.setFontColor +import com.unciv.ui.utils.* import kotlin.math.min class NotificationsScroll(private val notifications: List, internal val worldScreen: WorldScreen) : ScrollPane(null) { @@ -22,8 +19,7 @@ class NotificationsScroll(private val notifications: List, interna notificationsTable.clearChildren() for (notification in notifications) { val label = Label(notification.text, CameraStageBaseScreen.skin).setFontColor(Color.BLACK) - label.setFontScale(1.2f) - + .setFont(14) val minitable = Table() minitable.add(ImageGetter.getImage("OtherIcons/Circle.png") diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 6ba633b277..d4aac2ed49 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -2,17 +2,13 @@ package com.unciv.ui.worldscreen import com.badlogic.gdx.Gdx import com.badlogic.gdx.math.Vector2 -import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.unciv.logic.GameSaver import com.unciv.logic.civilization.CivilizationInfo import com.unciv.ui.pickerscreens.GreatPersonPickerScreen import com.unciv.ui.pickerscreens.PolicyPickerScreen import com.unciv.ui.pickerscreens.TechPickerScreen -import com.unciv.ui.utils.CameraStageBaseScreen -import com.unciv.ui.utils.addClickListener -import com.unciv.ui.utils.disable -import com.unciv.ui.utils.enable +import com.unciv.ui.utils.* import com.unciv.ui.worldscreen.bottombar.WorldScreenBottomBar import com.unciv.ui.worldscreen.unit.UnitActionsTable @@ -41,7 +37,6 @@ class WorldScreen : CameraStageBaseScreen() { topBar.y - nextTurnButton.height - 10f) notificationsScroll = NotificationsScroll(gameInfo.notifications, this) notificationsScroll.width = stage.width/3 - Label("", skin).style.font.data.setScale(1.5f) minimap.setSize(stage.width/5,stage.height/5) minimap.x = stage.width - minimap.width @@ -108,7 +103,7 @@ class WorldScreen : CameraStageBaseScreen() { } private fun createNextTurnButton(): TextButton { - val nextTurnButton = TextButton("Next turn", CameraStageBaseScreen.skin) + val nextTurnButton = TextButton("Next turn".tr(), CameraStageBaseScreen.skin) nextTurnButton.addClickListener { if (civInfo.tech.freeTechs != 0) { game.screen = TechPickerScreen(true, civInfo) @@ -134,7 +129,7 @@ class WorldScreen : CameraStageBaseScreen() { shouldUpdate=true GameSaver().saveGame(game.gameInfo, "Autosave") - nextTurnButton.setText("Next turn") + nextTurnButton.setText("Next turn".tr()) nextTurnButton.enable() Gdx.input.inputProcessor = stage } diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt index cafa54db92..b981c6a0f0 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt @@ -98,7 +98,8 @@ class BattleTable(val worldScreen: WorldScreen): Table() { else if (damageToDefender>defender.getHealth()) damageToDefender=defender.getHealth() - if(attacker.isMelee() && (defender.getUnitType()==UnitType.Civilian || defender.getUnitType()==UnitType.City && defender.isDefeated())) { + if(attacker.isMelee() && (defender.getUnitType()==UnitType.Civilian + || defender.getUnitType()==UnitType.City && defender.isDefeated())) { add("") add("Captured!") } diff --git a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenDisplayOptionsTable.kt b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenDisplayOptionsTable.kt index 08e03a521d..ee1be5c805 100644 --- a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenDisplayOptionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenDisplayOptionsTable.kt @@ -8,6 +8,7 @@ import com.unciv.logic.GameSaver import com.unciv.models.gamebasics.GameBasics import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.center +import com.unciv.ui.worldscreen.WorldScreen class WorldScreenDisplayOptionsTable() : OptionsTable(){ init { @@ -35,6 +36,8 @@ class WorldScreenDisplayOptionsTable() : OptionsTable(){ override fun changed(event: ChangeEvent?, actor: Actor?) { UnCivGame.Current.settings.language = languageSelectBox.selected; GameSaver().setGeneralSettings(UnCivGame.Current.settings) + UnCivGame.Current.worldScreen = WorldScreen() + UnCivGame.Current.setWorldScreen() } }) diff --git a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt index 28d99c7387..7fe36e78cf 100644 --- a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt @@ -4,40 +4,41 @@ import com.unciv.UnCivGame import com.unciv.ui.* import com.unciv.ui.pickerscreens.PolicyPickerScreen import com.unciv.ui.utils.center +import com.unciv.ui.utils.tr class WorldScreenOptionsTable internal constructor() : OptionsTable() { init { - addButton("Civilopedia"){ + addButton("Civilopedia".tr()){ UnCivGame.Current.screen = CivilopediaScreen() remove() } - addButton("Load game"){ + addButton("Load game".tr()){ UnCivGame.Current.screen = LoadScreen() remove() } - addButton("Save game") { + addButton("Save game".tr()) { UnCivGame.Current.screen = SaveScreen() remove() } - addButton("Start new game"){ UnCivGame.Current.screen = NewGameScreen() } + addButton("Start new game".tr()){ UnCivGame.Current.screen = NewGameScreen() } - addButton("Victory status") { UnCivGame.Current.screen = VictoryScreen() } + addButton("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() } - addButton("Social Policies"){ + addButton("Social Policies".tr()){ UnCivGame.Current.screen = PolicyPickerScreen(UnCivGame.Current.gameInfo.getPlayerCivilization()) } - addButton("Display options"){ + addButton("Display options".tr()){ UnCivGame.Current.worldScreen.stage.addActor(WorldScreenDisplayOptionsTable()) remove() } - addButton("Close"){ remove() } + addButton("Close".tr()){ remove() } pack() // Needed to show the background. center(UnCivGame.Current.worldScreen.stage) diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index e7a2acbc68..8b40032eb8 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -7,6 +7,7 @@ import com.unciv.logic.map.TileInfo import com.unciv.models.gamebasics.unit.UnitType import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.addClickListener +import com.unciv.ui.utils.tr import com.unciv.ui.worldscreen.WorldScreen class UnitTable(val worldScreen: WorldScreen) : Table(){ @@ -50,12 +51,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ if(unit.health<100) nameLabelText+=" ("+unit.health+")" unitNameLabel.setText(nameLabelText) - var unitLabelText = "Movement: " + unit.getMovementString() + var unitLabelText = "Movement".tr()+": " + unit.getMovementString() if (unit.getBaseUnit().unitType != UnitType.Civilian) { - unitLabelText += "\nStrength: " + unit.getBaseUnit().strength + unitLabelText += "\n"+"Strength".tr()+": " + unit.getBaseUnit().strength } if (unit.getBaseUnit().rangedStrength!=0) - unitLabelText += "\nRanged strength: "+unit.getBaseUnit().rangedStrength + unitLabelText += "\n"+"Ranged strength".tr()+": "+unit.getBaseUnit().rangedStrength if(unit.isFortified() && unit.getFortificationTurns()>0) unitLabelText+="\n+"+unit.getFortificationTurns()*20+"% fortification"