mirror of
https://github.com/yairm210/Unciv.git
synced 2025-10-03 08:56:17 -04:00
improved overview city screen
- dynamic layout - cities and units sorted by name - jump-to buttons for cities - rounded values in statistics
This commit is contained in:
parent
c3f700ddc6
commit
6bd06474bd
@ -2997,12 +2997,6 @@
|
|||||||
German:"Nächstgelegene Stadt"
|
German:"Nächstgelegene Stadt"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Go to unit":{
|
|
||||||
Italian:"Vai a unità"
|
|
||||||
Simplified_Chinese:"跳转至所在地图位置"
|
|
||||||
Portuguese:"Ir para a unidade"
|
|
||||||
}
|
|
||||||
|
|
||||||
"Defeated":{
|
"Defeated":{
|
||||||
Italian:"Sconfitto"
|
Italian:"Sconfitto"
|
||||||
Russian:"побежденный"
|
Russian:"побежденный"
|
||||||
|
@ -3,9 +3,7 @@ package com.unciv.ui
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
import com.badlogic.gdx.scenes.scene2d.Group
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.logic.HexMath
|
import com.unciv.logic.HexMath
|
||||||
@ -36,7 +34,6 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
centerTable.add(getCityInfoTable())
|
centerTable.add(getCityInfoTable())
|
||||||
centerTable.pack()
|
centerTable.pack()
|
||||||
centerTable.center(stage)
|
|
||||||
}
|
}
|
||||||
setCities()
|
setCities()
|
||||||
setCityInfoButton.onClick(setCities)
|
setCityInfoButton.onClick(setCities)
|
||||||
@ -45,11 +42,14 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
val setStatsInfoButton = TextButton("Stats".tr(),skin)
|
val setStatsInfoButton = TextButton("Stats".tr(),skin)
|
||||||
setStatsInfoButton.onClick {
|
setStatsInfoButton.onClick {
|
||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
centerTable.add(getHappinessTable())
|
centerTable.add(ScrollPane(HorizontalGroup().apply {
|
||||||
centerTable.add(getGoldTable()).row()
|
space(20f)
|
||||||
centerTable.add(getGreatPeopleTable())
|
top()
|
||||||
|
addActor(getHappinessTable())
|
||||||
|
addActor(getGoldTable())
|
||||||
|
addActor(getGreatPeopleTable())
|
||||||
|
}))
|
||||||
centerTable.pack()
|
centerTable.pack()
|
||||||
centerTable.center(stage)
|
|
||||||
}
|
}
|
||||||
topTable.add(setStatsInfoButton)
|
topTable.add(setStatsInfoButton)
|
||||||
|
|
||||||
@ -58,7 +58,6 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
centerTable.add(ScrollPane(getTradesTable())).height(stage.height*0.8f) // so it doesn't cover the naviagation buttons
|
centerTable.add(ScrollPane(getTradesTable())).height(stage.height*0.8f) // so it doesn't cover the naviagation buttons
|
||||||
centerTable.pack()
|
centerTable.pack()
|
||||||
centerTable.center(stage)
|
|
||||||
}
|
}
|
||||||
topTable.add(setCurrentTradesButton)
|
topTable.add(setCurrentTradesButton)
|
||||||
|
|
||||||
@ -67,7 +66,6 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
centerTable.add(ScrollPane(getUnitTable())).height(stage.height*0.8f)
|
centerTable.add(ScrollPane(getUnitTable())).height(stage.height*0.8f)
|
||||||
centerTable.pack()
|
centerTable.pack()
|
||||||
centerTable.center(stage)
|
|
||||||
}
|
}
|
||||||
topTable.add(setUnitsButton )
|
topTable.add(setUnitsButton )
|
||||||
|
|
||||||
@ -77,16 +75,17 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
centerTable.add(createDiplomacyGroup()).height(stage.height*0.8f)
|
centerTable.add(createDiplomacyGroup()).height(stage.height*0.8f)
|
||||||
centerTable.pack()
|
centerTable.pack()
|
||||||
centerTable.center(stage)
|
|
||||||
}
|
}
|
||||||
topTable.add(setDiplomacyButton )
|
topTable.add(setDiplomacyButton )
|
||||||
|
|
||||||
topTable.pack()
|
topTable.pack()
|
||||||
topTable.width = stage.width
|
|
||||||
topTable.y = stage.height-topTable.height
|
|
||||||
|
|
||||||
stage.addActor(topTable)
|
val table = Table()
|
||||||
stage.addActor(centerTable)
|
table.add(topTable).row()
|
||||||
|
table.add(centerTable).expand().row()
|
||||||
|
table.setFillParent(true)
|
||||||
|
stage.addActor(table)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTradesTable(): Table {
|
private fun getTradesTable(): Table {
|
||||||
@ -128,10 +127,10 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
happinessTable.addSeparator()
|
happinessTable.addSeparator()
|
||||||
for (entry in currentPlayerCivInfo.getHappinessForNextTurn()) {
|
for (entry in currentPlayerCivInfo.getHappinessForNextTurn()) {
|
||||||
happinessTable.add(entry.key.tr())
|
happinessTable.add(entry.key.tr())
|
||||||
happinessTable.add(entry.value.toString()).row()
|
happinessTable.add(entry.value.roundToInt().toString()).row()
|
||||||
}
|
}
|
||||||
happinessTable.add("Total".tr())
|
happinessTable.add("Total".tr())
|
||||||
happinessTable.add(currentPlayerCivInfo.getHappinessForNextTurn().values.sum().toString())
|
happinessTable.add(currentPlayerCivInfo.getHappinessForNextTurn().values.sum().roundToInt().toString())
|
||||||
happinessTable.pack()
|
happinessTable.pack()
|
||||||
return happinessTable
|
return happinessTable
|
||||||
}
|
}
|
||||||
@ -145,11 +144,11 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
for (entry in currentPlayerCivInfo.getStatMapForNextTurn()) {
|
for (entry in currentPlayerCivInfo.getStatMapForNextTurn()) {
|
||||||
if(entry.value.gold==0f) continue
|
if(entry.value.gold==0f) continue
|
||||||
goldTable.add(entry.key.tr())
|
goldTable.add(entry.key.tr())
|
||||||
goldTable.add(entry.value.gold.toString()).row()
|
goldTable.add(entry.value.gold.roundToInt().toString()).row()
|
||||||
total += entry.value.gold
|
total += entry.value.gold
|
||||||
}
|
}
|
||||||
goldTable.add("Total".tr())
|
goldTable.add("Total".tr())
|
||||||
goldTable.add(total.toString())
|
goldTable.add(total.roundToInt().toString())
|
||||||
goldTable.pack()
|
goldTable.pack()
|
||||||
return goldTable
|
return goldTable
|
||||||
}
|
}
|
||||||
@ -206,8 +205,13 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
val cityInfoTableDetails = Table(skin)
|
val cityInfoTableDetails = Table(skin)
|
||||||
cityInfoTableDetails.defaults().pad(padding).minWidth(iconSize).align(Align.left)//we need the min width so we can align the different tables
|
cityInfoTableDetails.defaults().pad(padding).minWidth(iconSize).align(Align.left)//we need the min width so we can align the different tables
|
||||||
|
|
||||||
for (city in currentPlayerCivInfo.cities) {
|
for (city in currentPlayerCivInfo.cities.sortedBy { it.name }) {
|
||||||
cityInfoTableDetails.add(city.name)
|
val button = Button(Label(city.name, skin), skin)
|
||||||
|
button.onClick {
|
||||||
|
UnCivGame.Current.setWorldScreen()
|
||||||
|
UnCivGame.Current.worldScreen.tileMapHolder.setCenterPosition(city.ccenterTile.position)
|
||||||
|
}
|
||||||
|
cityInfoTableDetails.add(button)
|
||||||
cityInfoTableDetails.add(city.cityConstructions.getCityProductionTextForCityButton()).actor!!.setAlignment(Align.left)
|
cityInfoTableDetails.add(city.cityConstructions.getCityProductionTextForCityButton()).actor!!.setAlignment(Align.left)
|
||||||
cityInfoTableDetails.add(city.population.population.toString()).actor!!.setAlignment(Align.center)
|
cityInfoTableDetails.add(city.population.population.toString()).actor!!.setAlignment(Align.center)
|
||||||
cityInfoTableDetails.add(city.cityStats.currentCityStats.food.roundToInt().toString()).actor!!.setAlignment(Align.center)
|
cityInfoTableDetails.add(city.cityStats.currentCityStats.food.roundToInt().toString()).actor!!.setAlignment(Align.center)
|
||||||
@ -245,8 +249,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
table.defaults().pad(padding).align(Align.right)
|
table.defaults().pad(padding).align(Align.right)
|
||||||
|
|
||||||
table.add(cityInfoTableIcons).row()
|
table.add(cityInfoTableIcons).row()
|
||||||
val height = if(cityInfoTableDetails.rows > 0) cityInfoTableDetails.getRowHeight(0)*4f else 100f //if there are no cities, set the height of the scroll pane to 100
|
table.add(cityInfoScrollPane).width(cityInfoTableDetails.width).row()
|
||||||
table.add(cityInfoScrollPane).width(cityInfoTableDetails.width).height(height).row()
|
|
||||||
table.add(cityInfoTableTotal)
|
table.add(cityInfoTableTotal)
|
||||||
table.pack()
|
table.pack()
|
||||||
|
|
||||||
@ -260,24 +263,22 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
table.add("Ranged strength".tr())
|
table.add("Ranged strength".tr())
|
||||||
table.add("Movement".tr())
|
table.add("Movement".tr())
|
||||||
table.add("Closest city".tr())
|
table.add("Closest city".tr())
|
||||||
table.add("Go to unit".tr())
|
|
||||||
table.row()
|
table.row()
|
||||||
table.addSeparator()
|
table.addSeparator()
|
||||||
|
|
||||||
for(unit in currentPlayerCivInfo.getCivUnits()){
|
for(unit in currentPlayerCivInfo.getCivUnits().sortedBy { it.name }){
|
||||||
val baseUnit = unit.baseUnit()
|
val baseUnit = unit.baseUnit()
|
||||||
table.add(unit.name.tr())
|
val button = TextButton(unit.name.tr(), skin)
|
||||||
|
button.onClick {
|
||||||
|
UnCivGame.Current.setWorldScreen()
|
||||||
|
UnCivGame.Current.worldScreen.tileMapHolder.setCenterPosition(unit.currentTile.position)
|
||||||
|
}
|
||||||
|
table.add(button).left()
|
||||||
if(baseUnit.strength>0) table.add(baseUnit.strength.toString()) else table.add()
|
if(baseUnit.strength>0) table.add(baseUnit.strength.toString()) else table.add()
|
||||||
if(baseUnit.rangedStrength>0) table.add(baseUnit.rangedStrength.toString()) else table.add()
|
if(baseUnit.rangedStrength>0) table.add(baseUnit.rangedStrength.toString()) else table.add()
|
||||||
table.add(DecimalFormat("0.#").format(unit.currentMovement)+"/"+unit.getMaxMovement())
|
table.add(DecimalFormat("0.#").format(unit.currentMovement)+"/"+unit.getMaxMovement())
|
||||||
val closestCity = unit.getTile().getTilesInDistance(3).firstOrNull{it.isCityCenter()}
|
val closestCity = unit.getTile().getTilesInDistance(3).firstOrNull{it.isCityCenter()}
|
||||||
if (closestCity!=null) table.add(closestCity.getCity()!!.name) else table.add()
|
if (closestCity!=null) table.add(closestCity.getCity()!!.name) else table.add()
|
||||||
val goToUnitButton = TextButton("Go to unit".tr(),skin)
|
|
||||||
goToUnitButton.onClick {
|
|
||||||
UnCivGame.Current.setWorldScreen()
|
|
||||||
UnCivGame.Current.worldScreen.tileMapHolder.setCenterPosition(unit.currentTile.position)
|
|
||||||
}
|
|
||||||
table.add(goToUnitButton)
|
|
||||||
table.row()
|
table.row()
|
||||||
}
|
}
|
||||||
table.pack()
|
table.pack()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user