mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-23 14:19:15 +07:00
Code cleanup - when{} instead of if-else chains, toLabel() instead of Label(...)
This commit is contained in:
@ -788,6 +788,20 @@ ImprovementIcons/Quarry
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
ImprovementIcons/Railroad
|
||||
rotate: false
|
||||
xy: 818, 206
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/Default/Railroad
|
||||
rotate: false
|
||||
xy: 818, 206
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
ImprovementIcons/Road
|
||||
rotate: false
|
||||
xy: 1430, 148
|
||||
@ -1721,7 +1735,7 @@ TechIcons/Radio
|
||||
index: -1
|
||||
TechIcons/Railroad
|
||||
rotate: false
|
||||
xy: 818, 206
|
||||
xy: 920, 206
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
@ -1789,6 +1803,20 @@ TileSets/Default/CityOverlay
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/Default/CrosshatchHexagon
|
||||
rotate: false
|
||||
xy: 583, 1800
|
||||
size: 273, 236
|
||||
orig: 273, 236
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/FantasyHex/CrosshatchHexagon
|
||||
rotate: false
|
||||
xy: 583, 1800
|
||||
size: 273, 236
|
||||
orig: 273, 236
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/Default/FalloutOverlay
|
||||
rotate: false
|
||||
xy: 614, 1030
|
||||
@ -1859,37 +1887,9 @@ TileSets/Default/OasisOverlay
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/Default/Railroad
|
||||
rotate: false
|
||||
xy: 1022, 206
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
ImprovementIcons/Railroad
|
||||
rotate: false
|
||||
xy: 1022, 206
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/FantasyHex/CrosshatchHexagon
|
||||
rotate: false
|
||||
xy: 583, 1800
|
||||
size: 273, 236
|
||||
orig: 273, 236
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/Default/CrosshatchHexagon
|
||||
rotate: false
|
||||
xy: 583, 1800
|
||||
size: 273, 236
|
||||
orig: 273, 236
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/FantasyHex/Railroad
|
||||
rotate: false
|
||||
xy: 920, 206
|
||||
xy: 1022, 206
|
||||
size: 100, 100
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
@ -2985,6 +2985,20 @@ TechIcons/Writing
|
||||
orig: 100, 100
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/Default/road
|
||||
rotate: false
|
||||
xy: 614, 90
|
||||
size: 61, 11
|
||||
orig: 61, 11
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/FantasyHex/road
|
||||
rotate: false
|
||||
xy: 614, 90
|
||||
size: 61, 11
|
||||
orig: 61, 11
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/FantasyHex/Tiles/Academy
|
||||
rotate: false
|
||||
xy: 920, 13
|
||||
@ -4371,20 +4385,6 @@ TileSets/FantasyHex/Units/Work Boats
|
||||
orig: 32, 26
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/FantasyHex/road
|
||||
rotate: false
|
||||
xy: 614, 90
|
||||
size: 61, 11
|
||||
orig: 61, 11
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
TileSets/Default/road
|
||||
rotate: false
|
||||
xy: 614, 90
|
||||
size: 61, 11
|
||||
orig: 61, 11
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
UnitIcons/Stealth Bomber
|
||||
rotate: false
|
||||
xy: 104, 410
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 884 KiB After Width: | Height: | Size: 884 KiB |
@ -1,7 +1,7 @@
|
||||
Traditional_Chinese = 96
|
||||
Italian = 100
|
||||
Russian = 99
|
||||
Italian = 99
|
||||
Polish = 99
|
||||
Russian = 99
|
||||
Romanian = 48
|
||||
Korean = 93
|
||||
Simplified_Chinese = 96
|
||||
@ -11,7 +11,7 @@ Ukrainian = 99
|
||||
French = 99
|
||||
Portuguese = 83
|
||||
Indonesian = 66
|
||||
Spanish = 98
|
||||
Malay = 13
|
||||
Czech = 96
|
||||
Malay = 13
|
||||
Spanish = 98
|
||||
Dutch = 25
|
||||
|
@ -2,7 +2,6 @@ package com.unciv.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.models.translations.tr
|
||||
@ -47,12 +46,12 @@ class LanguagePickerScreen: PickerScreen(){
|
||||
|
||||
init {
|
||||
closeButton.isVisible = false
|
||||
topTable.add(Label(
|
||||
"Please note that translations are a " +
|
||||
"community-based work in progress and are INCOMPLETE! \n" +
|
||||
"The percentage shown is how much of the language is translated in-game.\n" +
|
||||
"If you want to help translating the game into your language, \n"+
|
||||
" instructions are in the Github readme! (Menu > Community > Github)",skin)).pad(10f).row()
|
||||
val translationDisclaimer = "Please note that translations are a " +
|
||||
"community-based work in progress and are INCOMPLETE! \n" +
|
||||
"The percentage shown is how much of the language is translated in-game.\n" +
|
||||
"If you want to help translating the game into your language, \n"+
|
||||
" instructions are in the Github readme! (Menu > Community > Github)"
|
||||
topTable.add(translationDisclaimer.toLabel()).pad(10f).row()
|
||||
|
||||
val languageCompletionPercentage = UncivGame.Current.translations
|
||||
.percentCompleteOfLanguages
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.unciv.ui.cityscreen
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
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.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
@ -15,12 +14,11 @@ import com.unciv.models.Tutorial
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.map.TileGroupMap
|
||||
import com.unciv.ui.tilegroups.TileSetStrings
|
||||
import com.unciv.ui.utils.*
|
||||
import com.unciv.ui.map.TileGroupMap
|
||||
import java.util.*
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.round
|
||||
|
||||
class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
||||
@ -116,39 +114,34 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
|
||||
table.defaults().pad(5f)
|
||||
table.background=ImageGetter.getBackground(Color.BLACK.cpy().apply { a=0.8f })
|
||||
val columns = Stats().toHashMap().size
|
||||
table.add(Label("{Unassigned population}:".tr()
|
||||
+city.population.getFreePopulation().toString() + "/" + city.population.population,skin))
|
||||
.colspan(columns).row()
|
||||
val unassignedPopText = "{Unassigned population}:".tr()+
|
||||
city.population.getFreePopulation().toString() + "/" + city.population.population
|
||||
table.add(unassignedPopText.toLabel()).colspan(columns).row()
|
||||
|
||||
val turnsToExpansionString : String
|
||||
if (city.cityStats.currentCityStats.culture > 0) {
|
||||
var turnsToExpansion = ceil((city.expansion.getCultureToNextTile() - city.expansion.cultureStored)
|
||||
/ city.cityStats.currentCityStats.culture).toInt()
|
||||
if (turnsToExpansion < 1) turnsToExpansion = 1
|
||||
turnsToExpansionString = "[$turnsToExpansion] turns to expansion".tr()
|
||||
} else {
|
||||
turnsToExpansionString = "Stopped expansion".tr()
|
||||
var turnsToExpansionString = when {
|
||||
city.cityStats.currentCityStats.culture > 0 -> {
|
||||
var turnsToExpansion = ceil((city.expansion.getCultureToNextTile() - city.expansion.cultureStored)
|
||||
/ city.cityStats.currentCityStats.culture).toInt()
|
||||
if (turnsToExpansion < 1) turnsToExpansion = 1
|
||||
"[$turnsToExpansion] turns to expansion".tr()
|
||||
}
|
||||
else -> "Stopped expansion".tr()
|
||||
}
|
||||
table.add(Label(turnsToExpansionString + " (" + city.expansion.cultureStored + "/" + city.expansion.getCultureToNextTile() + ")",
|
||||
skin)).colspan(columns).row()
|
||||
turnsToExpansionString += " (" + city.expansion.cultureStored + "/" + city.expansion.getCultureToNextTile() + ")"
|
||||
table.add(turnsToExpansionString.toLabel()).colspan(columns).row()
|
||||
|
||||
val turnsToPopString : String
|
||||
if (city.isGrowing()) {
|
||||
var turnsToGrowth = city.getNumTurnsToNewPopulation()
|
||||
turnsToPopString = "[$turnsToGrowth] turns to new population".tr()
|
||||
} else if (city.isStarving()) {
|
||||
var turnsToStarvation = city.getNumTurnsToStarvation()
|
||||
turnsToPopString = "[$turnsToStarvation] turns to lose population".tr()
|
||||
} else if (city.cityConstructions.currentConstruction == Constants.settler) {
|
||||
turnsToPopString = "Food converts to production".tr()
|
||||
} else {
|
||||
turnsToPopString = "Stopped population growth".tr()
|
||||
}
|
||||
table.add(Label(turnsToPopString + " (" + city.population.foodStored + "/" + city.population.getFoodToNextPopulation() + ")"
|
||||
,skin)).colspan(columns).row()
|
||||
|
||||
var turnsToPopString = when {
|
||||
city.isGrowing() -> "[${city.getNumTurnsToNewPopulation()}] turns to new population"
|
||||
city.isStarving() -> "[${city.getNumTurnsToStarvation()}] turns to lose population"
|
||||
city.cityConstructions.currentConstruction == Constants.settler -> "Food converts to production"
|
||||
else -> "Stopped population growth"
|
||||
}.tr()
|
||||
turnsToPopString += " (" + city.population.foodStored + "/" + city.population.getFoodToNextPopulation() + ")"
|
||||
table.add(turnsToPopString.toLabel()).colspan(columns).row()
|
||||
|
||||
if (city.isInResistance()) {
|
||||
table.add(Label("In resistance for another [${city.resistanceCounter}] turns".tr(),skin)).colspan(columns).row()
|
||||
table.add("In resistance for another [${city.resistanceCounter}] turns".toLabel()).colspan(columns).row()
|
||||
}
|
||||
|
||||
table.addSeparator()
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.unciv.ui.cityscreen
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.UncivGame
|
||||
@ -9,10 +8,7 @@ import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.UncivSound
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.disable
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.utils.*
|
||||
|
||||
class CityScreenTileTable(val city: CityInfo): Table(){
|
||||
val innerTable = Table()
|
||||
@ -34,14 +30,14 @@ class CityScreenTileTable(val city: CityInfo): Table(){
|
||||
val stats = selectedTile.getTileStats(city, city.civInfo)
|
||||
innerTable.pad(20f)
|
||||
|
||||
innerTable.add(Label(selectedTile.toString(), CameraStageBaseScreen.skin)).colspan(2)
|
||||
innerTable.add(selectedTile.toString().toLabel()).colspan(2)
|
||||
innerTable.row()
|
||||
|
||||
val statsTable = Table()
|
||||
statsTable.defaults().pad(2f)
|
||||
for (entry in stats.toHashMap().filterNot { it.value==0f }) {
|
||||
statsTable.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f)
|
||||
statsTable.add(Label(Math.round(entry.value).toString(), CameraStageBaseScreen.skin))
|
||||
statsTable.add(Math.round(entry.value).toString().toLabel())
|
||||
statsTable.row()
|
||||
}
|
||||
innerTable.add(statsTable).row()
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.unciv.ui.worldscreen.bottombar
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.UncivGame
|
||||
@ -12,7 +11,7 @@ import com.unciv.ui.utils.toLabel
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
|
||||
class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBaseScreen.skin) {
|
||||
init{
|
||||
init {
|
||||
background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||
}
|
||||
|
||||
@ -28,13 +27,14 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBas
|
||||
pack()
|
||||
}
|
||||
|
||||
fun getStatsTable(tile: TileInfo):Table{
|
||||
val table=Table()
|
||||
fun getStatsTable(tile: TileInfo): Table {
|
||||
val table = Table()
|
||||
table.defaults().pad(2f)
|
||||
|
||||
for (entry in tile.getTileStats(worldScreen.viewingCiv).toHashMap().filterNot { it.value == 0f||it.key.toString() == "" }) {
|
||||
for (entry in tile.getTileStats(worldScreen.viewingCiv).toHashMap()
|
||||
.filterNot { it.value == 0f || it.key.toString() == "" }) {
|
||||
table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
||||
table.add(Label(entry.value.toInt().toString(), skin)).align(Align.left).padRight(10f)
|
||||
table.add(entry.value.toInt().toString().toLabel()).align(Align.left).padRight(10f)
|
||||
table.row()
|
||||
}
|
||||
return table
|
||||
|
Reference in New Issue
Block a user