mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-18 19:59:47 +07:00
Better top-down trickling of information instead of relying on UncivGame.Current info
This commit is contained in:
@ -288,10 +288,10 @@ open class TileInfo {
|
|||||||
|
|
||||||
fun isRoughTerrain() = getBaseTerrain().rough || getTerrainFeature()?.rough == true
|
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 lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
||||||
val isViewableToPlayer = UncivGame.Current.viewEntireMapForDebug
|
val isViewableToPlayer = UncivGame.Current.viewEntireMapForDebug
|
||||||
|| UncivGame.Current.gameInfo.getCurrentPlayerCivilization().viewableTiles.contains(this)
|
|| viewingCiv.viewableTiles.contains(this)
|
||||||
|
|
||||||
if (isCityCenter()) {
|
if (isCityCenter()) {
|
||||||
val city = getCity()!!
|
val city = getCity()!!
|
||||||
|
@ -32,7 +32,7 @@ class CityScreenTileTable(val city: CityInfo): Table(){
|
|||||||
val stats = selectedTile.getTileStats(city, city.civInfo)
|
val stats = selectedTile.getTileStats(city, city.civInfo)
|
||||||
innerTable.pad(20f)
|
innerTable.pad(20f)
|
||||||
|
|
||||||
innerTable.add(selectedTile.toString().toLabel()).colspan(2)
|
innerTable.add(selectedTile.toString(city.civInfo).toLabel()).colspan(2)
|
||||||
innerTable.row()
|
innerTable.row()
|
||||||
innerTable.add(getTileStatsTable(stats)).row()
|
innerTable.add(getTileStatsTable(stats)).row()
|
||||||
|
|
||||||
|
@ -22,8 +22,10 @@ class TileGroupIcons(val tileGroup: TileGroup){
|
|||||||
updateResourceIcon(showResourcesAndImprovements)
|
updateResourceIcon(showResourcesAndImprovements)
|
||||||
updateImprovementIcon(showResourcesAndImprovements)
|
updateImprovementIcon(showResourcesAndImprovements)
|
||||||
|
|
||||||
civilianUnitIcon = newUnitIcon(tileGroup.tileInfo.civilianUnit, civilianUnitIcon, tileIsViewable, -20f)
|
civilianUnitIcon = newUnitIcon(tileGroup.tileInfo.civilianUnit, civilianUnitIcon,
|
||||||
militaryUnitIcon = newUnitIcon(tileGroup.tileInfo.militaryUnit, militaryUnitIcon, tileIsViewable && showMilitaryUnit, 20f)
|
tileIsViewable, -20f, viewingCiv)
|
||||||
|
militaryUnitIcon = newUnitIcon(tileGroup.tileInfo.militaryUnit, militaryUnitIcon,
|
||||||
|
tileIsViewable && showMilitaryUnit, 20f, viewingCiv)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPopulationIcon() {
|
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
|
var newImage: UnitGroup? = null
|
||||||
// The unit can change within one update - for instance, when attacking, the attacker replaces the defender!
|
// The unit can change within one update - for instance, when attacking, the attacker replaces the defender!
|
||||||
oldUnitGroup?.remove()
|
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,
|
// 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
|
// 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
|
newImage.unitBaseImage.color.a = 0.5f
|
||||||
}
|
}
|
||||||
return newImage
|
return newImage
|
||||||
|
@ -45,7 +45,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
private val topBar = WorldScreenTopBar(this)
|
private val topBar = WorldScreenTopBar(this)
|
||||||
val bottomUnitTable = UnitTable(this)
|
val bottomUnitTable = UnitTable(this)
|
||||||
val bottomTileInfoTable = TileInfoTable(this)
|
val bottomTileInfoTable = TileInfoTable(viewingCiv)
|
||||||
val battleTable = BattleTable(this)
|
val battleTable = BattleTable(this)
|
||||||
val unitActionsTable = UnitActionsTable(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.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.toLabel
|
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 {
|
init {
|
||||||
background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun updateTileTable(tile: TileInfo) {
|
internal fun updateTileTable(tile: TileInfo) {
|
||||||
clearChildren()
|
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(getStatsTable(tile))
|
||||||
add(tile.toString().toLabel()).colspan(2).pad(10f)
|
add(tile.toString(viewingCiv).toLabel()).colspan(2).pad(10f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
@ -31,7 +30,7 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBas
|
|||||||
val table = Table()
|
val table = Table()
|
||||||
table.defaults().pad(2f)
|
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() == "" }) {
|
.filterNot { it.value == 0f || it.key.toString() == "" }) {
|
||||||
table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
||||||
table.add(entry.value.toInt().toString().toLabel()).align(Align.left).padRight(10f)
|
table.add(entry.value.toInt().toString().toLabel()).align(Align.left).padRight(10f)
|
||||||
|
Reference in New Issue
Block a user