Expanded translation for new game screen and overview screen

This commit is contained in:
Yair Morgenstern
2018-08-04 21:36:08 +03:00
parent 5b26974752
commit ec0ebc73f0
14 changed files with 86 additions and 49 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@ -2545,6 +2545,35 @@
Romanian:"Mare" Romanian:"Mare"
} }
// New game screen
"Civilization":{}
"World size":{}
"Number of enemies":{}
"Difficulty":{}
"Diplomacy":{}
// Overview screen
"Overview":{}
"Cities":{}
"Total":{}
"Stats":{}
"Policies":{}
"Base happiness":{}
"Buildings":{}
"Population":{}
"Luxury resources":{}
"Tile yields":{}
"Trade routes":{}
"Maintenance":[}
"Transportation upkeep":{}
"Unit upkeep":{}
"Trades":{}
"Units":{}
"Name":{}
"Closest city":{}
} }

View File

@ -6,6 +6,7 @@ import com.badlogic.gdx.utils.Json
import com.unciv.logic.GameInfo import com.unciv.logic.GameInfo
import com.unciv.logic.GameSaver import com.unciv.logic.GameSaver
import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.GameBasics
import com.unciv.ui.LanguagePickerScreen
import com.unciv.ui.worldscreen.WorldScreen import com.unciv.ui.worldscreen.WorldScreen
class UnCivGame : Game() { class UnCivGame : Game() {
@ -33,7 +34,7 @@ class UnCivGame : Game() {
startNewGame() startNewGame()
} }
} }
else startNewGame() else screen=LanguagePickerScreen() //startNewGame()
} }
fun loadGame(gameInfo:GameInfo){ fun loadGame(gameInfo:GameInfo){

View File

@ -216,7 +216,7 @@ class CityStats {
.add(Stat.Production, cityInfo.population.getFreePopulation().toFloat()) .add(Stat.Production, cityInfo.population.getFreePopulation().toFloat())
baseStatList["Tile yields"] = getStatsFromTiles() baseStatList["Tile yields"] = getStatsFromTiles()
baseStatList["Specialists"] = getStatsFromSpecialists(cityInfo.population.getSpecialists(), civInfo.policies.adoptedPolicies) baseStatList["Specialists"] = getStatsFromSpecialists(cityInfo.population.getSpecialists(), civInfo.policies.adoptedPolicies)
baseStatList["Trade route"] = getStatsFromTradeRoute() baseStatList["Trade routes"] = getStatsFromTradeRoute()
baseStatList["Buildings"] = cityInfo.cityConstructions.getStats() baseStatList["Buildings"] = cityInfo.cityConstructions.getStats()
baseStatList["Policies"] = getStatsFromPolicies(civInfo.policies.adoptedPolicies) baseStatList["Policies"] = getStatsFromPolicies(civInfo.policies.adoptedPolicies)

View File

@ -24,7 +24,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
closeButton.y = stage.height - closeButton.height - 5 closeButton.y = stage.height - closeButton.height - 5
topTable.add(closeButton) topTable.add(closeButton)
val setCityInfoButton = TextButton("Cities",skin) val setCityInfoButton = TextButton("Cities".tr(),skin)
val setCities = { val setCities = {
centerTable.clear() centerTable.clear()
centerTable.add(getCityInfoTable()) centerTable.add(getCityInfoTable())
@ -35,7 +35,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
setCityInfoButton.addClickListener(setCities) setCityInfoButton.addClickListener(setCities)
topTable.add(setCityInfoButton) topTable.add(setCityInfoButton)
val setStatsInfoButton = TextButton("Stats",skin) val setStatsInfoButton = TextButton("Stats".tr(),skin)
setStatsInfoButton.addClickListener { setStatsInfoButton.addClickListener {
centerTable.clear() centerTable.clear()
centerTable.add(getHappinessTable()) centerTable.add(getHappinessTable())
@ -45,7 +45,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
} }
topTable.add(setStatsInfoButton) topTable.add(setStatsInfoButton)
val setCurrentTradesButton = TextButton("Trades",skin) val setCurrentTradesButton = TextButton("Trades".tr(),skin)
setCurrentTradesButton.addClickListener { setCurrentTradesButton.addClickListener {
centerTable.clear() centerTable.clear()
centerTable.add(getTradesTable()) centerTable.add(getTradesTable())
@ -54,7 +54,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
} }
topTable.add(setCurrentTradesButton) topTable.add(setCurrentTradesButton)
val setUnitsButton = TextButton("Units",skin) val setUnitsButton = TextButton("Units".tr(),skin)
setUnitsButton .addClickListener { setUnitsButton .addClickListener {
centerTable.clear() centerTable.clear()
centerTable.add(getUnitTable()) centerTable.add(getUnitTable())
@ -86,10 +86,10 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
table.defaults().pad(10f) table.defaults().pad(10f)
table.add(civInfo.civName) table.add(civInfo.civName)
table.add(civName).row() table.add(civName).row()
val ourOffersStrings = trade.ourOffers.map { it.amount.toString()+" "+it.name + val ourOffersStrings = trade.ourOffers.map { it.amount.toString()+" "+it.name.tr() +
(if (it.duration==0) "" else " ("+it.duration+" turns)") } (if (it.duration==0) "" else " ("+it.duration+" {turns})".tr()) }
val theirOffersStrings = trade.theirOffers.map { it.amount.toString()+" "+it.name + val theirOffersStrings = trade.theirOffers.map { it.amount.toString()+" "+it.name.tr() +
(if (it.duration==0) "" else " ("+it.duration+" turns)") } (if (it.duration==0) "" else " ("+it.duration+" {turns})".tr()) }
for(i in 0 until max(trade.ourOffers.size,trade.theirOffers.size)){ for(i in 0 until max(trade.ourOffers.size,trade.theirOffers.size)){
if(ourOffersStrings.size>i) table.add(ourOffersStrings[i]) if(ourOffersStrings.size>i) table.add(ourOffersStrings[i])
else table.add() else table.add()
@ -103,12 +103,12 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
private fun getHappinessTable(): Table { private fun getHappinessTable(): Table {
val happinessTable = Table(skin) val happinessTable = Table(skin)
happinessTable.defaults().pad(5f) happinessTable.defaults().pad(5f)
happinessTable.add(Label("Happiness", skin).setFont(24)).colspan(2).row() happinessTable.add(Label("Happiness".tr(), skin).setFont(24)).colspan(2).row()
for (entry in civInfo.getHappinessForNextTurn()) { for (entry in civInfo.getHappinessForNextTurn()) {
happinessTable.add(entry.key) happinessTable.add(entry.key.tr())
happinessTable.add(entry.value.toString()).row() happinessTable.add(entry.value.toString()).row()
} }
happinessTable.add("Total") happinessTable.add("Total".tr())
happinessTable.add(civInfo.getHappinessForNextTurn().values.sum().toString()) happinessTable.add(civInfo.getHappinessForNextTurn().values.sum().toString())
happinessTable.pack() happinessTable.pack()
return happinessTable return happinessTable
@ -117,15 +117,15 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
private fun getGoldTable(): Table { private fun getGoldTable(): Table {
val goldTable = Table(skin) val goldTable = Table(skin)
goldTable.defaults().pad(5f) goldTable.defaults().pad(5f)
goldTable.add(Label("Gold", skin).setFont(24)).colspan(2).row() goldTable.add(Label("Gold".tr(), skin).setFont(24)).colspan(2).row()
var total=0f var total=0f
for (entry in civInfo.getStatMapForNextTurn()) { for (entry in civInfo.getStatMapForNextTurn()) {
if(entry.value.gold==0f) continue if(entry.value.gold==0f) continue
goldTable.add(entry.key) goldTable.add(entry.key.tr())
goldTable.add(entry.value.gold.toString()).row() goldTable.add(entry.value.gold.toString()).row()
total += entry.value.gold total += entry.value.gold
} }
goldTable.add("Total") goldTable.add("Total".tr())
goldTable.add(total.toString()) goldTable.add(total.toString())
goldTable.pack() goldTable.pack()
return goldTable return goldTable
@ -138,7 +138,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
val cityInfoTableIcons = Table(skin) val cityInfoTableIcons = Table(skin)
cityInfoTableIcons.defaults().pad(padding).align(Align.center) cityInfoTableIcons.defaults().pad(padding).align(Align.center)
cityInfoTableIcons.add(Label("Cities", skin).setFont(24)).colspan(8).align(Align.center).row() cityInfoTableIcons.add(Label("Cities".tr(), skin).setFont(24)).colspan(8).align(Align.center).row()
cityInfoTableIcons.add() cityInfoTableIcons.add()
cityInfoTableIcons.add(ImageGetter.getStatIcon("Population")).size(iconSize) cityInfoTableIcons.add(ImageGetter.getStatIcon("Population")).size(iconSize)
cityInfoTableIcons.add(ImageGetter.getStatIcon("Food")).size(iconSize) cityInfoTableIcons.add(ImageGetter.getStatIcon("Food")).size(iconSize)
@ -173,7 +173,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
val cityInfoTableTotal = Table(skin) val cityInfoTableTotal = Table(skin)
cityInfoTableTotal.defaults().pad(padding).minWidth(iconSize)//we need the min width so we can align the different tables cityInfoTableTotal.defaults().pad(padding).minWidth(iconSize)//we need the min width so we can align the different tables
cityInfoTableTotal.add("Total") cityInfoTableTotal.add("Total".tr())
cityInfoTableTotal.add(civInfo.cities.sumBy { it.population.population }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(civInfo.cities.sumBy { it.population.population }.toString()).actor!!.setAlignment(Align.center)
cityInfoTableTotal.add()//an intended empty space cityInfoTableTotal.add()//an intended empty space
cityInfoTableTotal.add(civInfo.cities.sumBy { it.cityStats.currentCityStats.gold.toInt() }.toString()).actor!!.setAlignment(Align.center) cityInfoTableTotal.add(civInfo.cities.sumBy { it.cityStats.currentCityStats.gold.toInt() }.toString()).actor!!.setAlignment(Align.center)
@ -201,11 +201,11 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
fun getUnitTable(): Table { fun getUnitTable(): Table {
val table=Table(skin).apply { defaults().pad(5f) } val table=Table(skin).apply { defaults().pad(5f) }
table.add("Name") table.add("Name".tr())
table.add("Combat strength") table.add("Strength".tr())
table.add("Ranged strength") table.add("Ranged strength".tr())
table.add("Movement") table.add("Movement".tr())
table.add("Closest city") table.add("Closest city".tr())
table.row() table.row()
for(unit in civInfo.getCivUnits()){ for(unit in civInfo.getCivUnits()){
val baseUnit = unit.getBaseUnit() val baseUnit = unit.getBaseUnit()

View File

@ -1,10 +1,10 @@
package com.unciv.ui package com.unciv.ui
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Skin import com.badlogic.gdx.scenes.scene2d.ui.Skin
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.UnCivGame import com.unciv.UnCivGame
import com.unciv.logic.GameSaver
import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.GameBasics
import com.unciv.ui.pickerscreens.PickerScreen import com.unciv.ui.pickerscreens.PickerScreen
import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.ImageGetter
@ -20,13 +20,17 @@ class LanguageTable(val language:String,skin: Skin):Table(skin){
init{ init{
pad(10f) pad(10f)
defaults().pad(10f) defaults().pad(10f)
add(ImageGetter.getImage("Flags/$language.png")) add(ImageGetter.getImage("FlagIcons/$language.png")).size(40f)
add(language) add(language)
update("")
touchable = Touchable.enabled // so click listener is activated when any part is clicked, not only children
pack() pack()
} }
fun update(chosenLanguage:String){ fun update(chosenLanguage:String){
background = ImageGetter.getBackground( if(chosenLanguage==language) blue else darkBlue) background = ImageGetter.getBackground( if(chosenLanguage==language) blue else darkBlue)
} }
} }
class LanguagePickerScreen: PickerScreen(){ class LanguagePickerScreen: PickerScreen(){
@ -47,7 +51,7 @@ class LanguagePickerScreen: PickerScreen(){
rightSideButton.enable() rightSideButton.enable()
update() update()
} }
topTable.add(languageTable).row() topTable.add(languageTable).pad(10f).row()
languageTables.add(languageTable) languageTables.add(languageTable)
} }

View File

@ -2,6 +2,7 @@ package com.unciv.ui
import com.badlogic.gdx.Gdx import com.badlogic.gdx.Gdx
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
import com.badlogic.gdx.scenes.scene2d.ui.Skin
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Array import com.badlogic.gdx.utils.Array
import com.unciv.GameStarter import com.unciv.GameStarter
@ -20,28 +21,21 @@ class NewGameScreen: PickerScreen(){
table.skin= skin table.skin= skin
table.add("Civilization:".tr()) table.add("{Civilization}:".tr())
val civSelectBox = SelectBox<String>(skin) val civSelectBox = TranslatedSelectBox(GameBasics.Civilizations.keys.filterNot { it=="Barbarians" },
val civArray = Array<String>() "Babylon",skin)
GameBasics.Civilizations.keys.filterNot { it=="Barbarians" }.forEach{civArray.add(it)}
civSelectBox.setItems(civArray)
civSelectBox.selected = civSelectBox.items.first()
table.add(civSelectBox).pad(10f).row() table.add(civSelectBox).pad(10f).row()
table.add("World size:".tr()) table.add("{World size}:".tr())
val worldSizeToRadius=LinkedHashMap<String,Int>() val worldSizeToRadius=LinkedHashMap<String,Int>()
worldSizeToRadius["Small"] = 10 worldSizeToRadius["Small"] = 10
worldSizeToRadius["Medium"] = 20 worldSizeToRadius["Medium"] = 20
worldSizeToRadius["Large"] = 30 worldSizeToRadius["Large"] = 30
val worldSizeSelectBox = SelectBox<String>(skin) val worldSizeSelectBox = TranslatedSelectBox(worldSizeToRadius.keys,"Medium",skin)
val worldSizeArray = Array<String>()
worldSizeToRadius.keys.forEach{worldSizeArray.add(it)}
worldSizeSelectBox.items = worldSizeArray
worldSizeSelectBox.selected = "Medium"
table.add(worldSizeSelectBox).pad(10f).row() table.add(worldSizeSelectBox).pad(10f).row()
table.add("Number of enemies:".tr()) table.add("{Number of enemies}:".tr())
val enemiesSelectBox = SelectBox<Int>(skin) val enemiesSelectBox = SelectBox<Int>(skin)
val enemiesArray=Array<Int>() val enemiesArray=Array<Int>()
(1..5).forEach { enemiesArray.add(it) } (1..5).forEach { enemiesArray.add(it) }
@ -50,12 +44,8 @@ class NewGameScreen: PickerScreen(){
table.add(enemiesSelectBox).pad(10f).row() table.add(enemiesSelectBox).pad(10f).row()
table.add("Difficulty:".tr()) table.add("{Difficulty}:".tr())
val difficultySelectBox = SelectBox<String>(skin) val difficultySelectBox = TranslatedSelectBox(GameBasics.Difficulties.keys, "Chieftain", skin)
val difficultyArray = Array<String>()
GameBasics.Difficulties.keys.forEach{difficultyArray.add(it)}
difficultySelectBox.items = difficultyArray
difficultySelectBox.selected = "Chieftain"
table.add(difficultySelectBox).pad(10f).row() table.add(difficultySelectBox).pad(10f).row()
@ -68,8 +58,8 @@ class NewGameScreen: PickerScreen(){
kotlin.concurrent.thread { // Creating a new game can tke a while and we don't want ANRs kotlin.concurrent.thread { // Creating a new game can tke a while and we don't want ANRs
newGame = GameStarter().startNewGame( newGame = GameStarter().startNewGame(
worldSizeToRadius[worldSizeSelectBox.selected]!!, enemiesSelectBox.selected, worldSizeToRadius[worldSizeSelectBox.selected.value]!!, enemiesSelectBox.selected,
civSelectBox.selected, difficultySelectBox.selected ) civSelectBox.selected.value, difficultySelectBox.selected.value )
} }
} }
@ -87,4 +77,17 @@ class NewGameScreen: PickerScreen(){
} }
super.render(delta) super.render(delta)
} }
}
class TranslatedSelectBox(values : Collection<String>, default:String, skin: Skin) : SelectBox<TranslatedSelectBox.TranslatedString>(skin){
class TranslatedString(val value: String){
val translation = value.tr()
override fun toString()=translation
}
init {
val array = Array<TranslatedString>()
values.forEach{array.add(TranslatedString(it))}
items = array
selected = array.first { it.value==default }
}
} }

View File

@ -114,7 +114,7 @@ class WorldScreen : CameraStageBaseScreen() {
if(civInfo.diplomacy.values.map { it.otherCiv() } if(civInfo.diplomacy.values.map { it.otherCiv() }
.filterNot { it.isDefeated() || it.isPlayerCivilization() || it.isBarbarianCivilization() } .filterNot { it.isDefeated() || it.isPlayerCivilization() || it.isBarbarianCivilization() }
.any()) { .any()) {
val btn = TextButton("Diplomacy", skin) val btn = TextButton("Diplomacy".tr(), skin)
btn.addClickListener { UnCivGame.Current.screen = DiplomacyScreen() } btn.addClickListener { UnCivGame.Current.screen = DiplomacyScreen() }
diplomacyButtonWrapper.add(btn) diplomacyButtonWrapper.add(btn)
} }