Better top-down trickling of information instead of relying on UncivGame.Current info
This commit is contained in:
parent
76bda5bceb
commit
848637c78c
5 changed files with 15 additions and 14 deletions
|
@ -288,10 +288,10 @@ open class TileInfo {
|
|||
|
||||
fun isRoughTerrain() = getBaseTerrain().rough || getTerrainFeature()?.rough == true
|
||||
|
||||
override fun toString(): String {
|
||||
fun toString(viewingCiv: CivilizationInfo): String {
|
||||
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
||||
val isViewableToPlayer = UncivGame.Current.viewEntireMapForDebug
|
||||
|| UncivGame.Current.gameInfo.getCurrentPlayerCivilization().viewableTiles.contains(this)
|
||||
|| viewingCiv.viewableTiles.contains(this)
|
||||
|
||||
if (isCityCenter()) {
|
||||
val city = getCity()!!
|
||||
|
|
|
@ -32,7 +32,7 @@ class CityScreenTileTable(val city: CityInfo): Table(){
|
|||
val stats = selectedTile.getTileStats(city, city.civInfo)
|
||||
innerTable.pad(20f)
|
||||
|
||||
innerTable.add(selectedTile.toString().toLabel()).colspan(2)
|
||||
innerTable.add(selectedTile.toString(city.civInfo).toLabel()).colspan(2)
|
||||
innerTable.row()
|
||||
innerTable.add(getTileStatsTable(stats)).row()
|
||||
|
||||
|
|
|
@ -22,8 +22,10 @@ class TileGroupIcons(val tileGroup: TileGroup){
|
|||
updateResourceIcon(showResourcesAndImprovements)
|
||||
updateImprovementIcon(showResourcesAndImprovements)
|
||||
|
||||
civilianUnitIcon = newUnitIcon(tileGroup.tileInfo.civilianUnit, civilianUnitIcon, tileIsViewable, -20f)
|
||||
militaryUnitIcon = newUnitIcon(tileGroup.tileInfo.militaryUnit, militaryUnitIcon, tileIsViewable && showMilitaryUnit, 20f)
|
||||
civilianUnitIcon = newUnitIcon(tileGroup.tileInfo.civilianUnit, civilianUnitIcon,
|
||||
tileIsViewable, -20f, viewingCiv)
|
||||
militaryUnitIcon = newUnitIcon(tileGroup.tileInfo.militaryUnit, militaryUnitIcon,
|
||||
tileIsViewable && showMilitaryUnit, 20f, viewingCiv)
|
||||
}
|
||||
|
||||
fun addPopulationIcon() {
|
||||
|
@ -43,7 +45,7 @@ class TileGroupIcons(val tileGroup: TileGroup){
|
|||
}
|
||||
|
||||
|
||||
fun newUnitIcon(unit: MapUnit?, oldUnitGroup: UnitGroup?, isViewable: Boolean, yFromCenter: Float): UnitGroup? {
|
||||
fun newUnitIcon(unit: MapUnit?, oldUnitGroup: UnitGroup?, isViewable: Boolean, yFromCenter: Float, viewingCiv: CivilizationInfo?): UnitGroup? {
|
||||
var newImage: UnitGroup? = null
|
||||
// The unit can change within one update - for instance, when attacking, the attacker replaces the defender!
|
||||
oldUnitGroup?.remove()
|
||||
|
@ -77,7 +79,7 @@ class TileGroupIcons(val tileGroup: TileGroup){
|
|||
|
||||
// Instead of fading out the entire unit with its background, we just fade out its central icon,
|
||||
// that way it remains much more visible on the map
|
||||
if (!unit.isIdle() && unit.civInfo == UncivGame.Current.worldScreen.viewingCiv)
|
||||
if (!unit.isIdle() && unit.civInfo == viewingCiv)
|
||||
newImage.unitBaseImage.color.a = 0.5f
|
||||
}
|
||||
return newImage
|
||||
|
|
|
@ -45,7 +45,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||
|
||||
private val topBar = WorldScreenTopBar(this)
|
||||
val bottomUnitTable = UnitTable(this)
|
||||
val bottomTileInfoTable = TileInfoTable(this)
|
||||
val bottomTileInfoTable = TileInfoTable(viewingCiv)
|
||||
val battleTable = BattleTable(this)
|
||||
val unitActionsTable = UnitActionsTable(this)
|
||||
|
||||
|
|
|
@ -4,24 +4,23 @@ import com.badlogic.gdx.graphics.Color
|
|||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.toLabel
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
|
||||
class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBaseScreen.skin) {
|
||||
class TileInfoTable(private val viewingCiv :CivilizationInfo) : Table(CameraStageBaseScreen.skin) {
|
||||
init {
|
||||
background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||
}
|
||||
|
||||
internal fun updateTileTable(tile: TileInfo) {
|
||||
clearChildren()
|
||||
val civInfo = worldScreen.viewingCiv
|
||||
|
||||
if (UncivGame.Current.viewEntireMapForDebug || civInfo.exploredTiles.contains(tile.position)) {
|
||||
if (UncivGame.Current.viewEntireMapForDebug || viewingCiv.exploredTiles.contains(tile.position)) {
|
||||
add(getStatsTable(tile))
|
||||
add(tile.toString().toLabel()).colspan(2).pad(10f)
|
||||
add(tile.toString(viewingCiv).toLabel()).colspan(2).pad(10f)
|
||||
}
|
||||
|
||||
pack()
|
||||
|
@ -31,7 +30,7 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBas
|
|||
val table = Table()
|
||||
table.defaults().pad(2f)
|
||||
|
||||
for (entry in tile.getTileStats(worldScreen.viewingCiv).toHashMap()
|
||||
for (entry in tile.getTileStats(viewingCiv).toHashMap()
|
||||
.filterNot { it.value == 0f || it.key.toString() == "" }) {
|
||||
table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
||||
table.add(entry.value.toInt().toString().toLabel()).align(Align.left).padRight(10f)
|
||||
|
|
Loading…
Reference in a new issue