mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
One high-stakes, no-holds-barred, to-the-death profiling later, and we're left with a much less laggy main screen and a much more profile-able citybutton/
This commit is contained in:
parent
ae9a026201
commit
3bf045d354
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 899 KiB After Width: | Height: | Size: 1.5 MiB |
Binary file not shown.
Before Width: | Height: | Size: 501 KiB |
@ -1,5 +1,6 @@
|
|||||||
package com.unciv.ui.map
|
package com.unciv.ui.map
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import com.badlogic.gdx.scenes.scene2d.Group
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
import com.unciv.logic.HexMath
|
import com.unciv.logic.HexMath
|
||||||
@ -71,4 +72,10 @@ class TileGroupMap<T: TileGroup>(val tileGroups: Collection<T>, val padding: Flo
|
|||||||
.sub(groupSize.toFloat() / 2f, groupSize.toFloat() / 2f)
|
.sub(groupSize.toFloat() / 2f, groupSize.toFloat() / 2f)
|
||||||
.scl(1f / trueGroupSize)
|
.scl(1f / trueGroupSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// For debugging purposes
|
||||||
|
override fun draw(batch: Batch?, parentAlpha: Float) {
|
||||||
|
super.draw(batch, parentAlpha)
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.tilegroups
|
package com.unciv.ui.tilegroups
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
import com.badlogic.gdx.math.Interpolation
|
import com.badlogic.gdx.math.Interpolation
|
||||||
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
|
||||||
@ -178,7 +179,10 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||||||
|
|
||||||
private fun getIconTable(): Table {
|
private fun getIconTable(): Table {
|
||||||
val secondaryColor = city.civInfo.nation.getInnerColor()
|
val secondaryColor = city.civInfo.nation.getInnerColor()
|
||||||
val iconTable = Table()
|
class IconTable:Table(){
|
||||||
|
override fun draw(batch: Batch?, parentAlpha: Float) { super.draw(batch, parentAlpha) }
|
||||||
|
}
|
||||||
|
val iconTable = IconTable()
|
||||||
iconTable.touchable=Touchable.enabled
|
iconTable.touchable=Touchable.enabled
|
||||||
iconTable.background = ImageGetter.getRoundedEdgeTableBackground(city.civInfo.nation.getOuterColor())
|
iconTable.background = ImageGetter.getRoundedEdgeTableBackground(city.civInfo.nation.getOuterColor())
|
||||||
|
|
||||||
@ -256,9 +260,13 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||||||
private fun getPopulationGroup(showGrowth: Boolean): Group {
|
private fun getPopulationGroup(showGrowth: Boolean): Group {
|
||||||
val growthGreen = Color(0.0f, 0.5f, 0.0f, 1.0f)
|
val growthGreen = Color(0.0f, 0.5f, 0.0f, 1.0f)
|
||||||
|
|
||||||
val group = Group()
|
|
||||||
|
|
||||||
val populationLabel = city.population.population.toString().toLabel()
|
class PopulationGroup:Group() { // for recognition in the profiler
|
||||||
|
override fun draw(batch: Batch?, parentAlpha: Float) { super.draw(batch, parentAlpha) }
|
||||||
|
}
|
||||||
|
val group = PopulationGroup().apply { isTransform=false }
|
||||||
|
|
||||||
|
val populationLabel = city.population.population.toLabel()
|
||||||
populationLabel.color = city.civInfo.nation.getInnerColor()
|
populationLabel.color = city.civInfo.nation.getInnerColor()
|
||||||
|
|
||||||
group.addActor(populationLabel)
|
group.addActor(populationLabel)
|
||||||
@ -288,31 +296,13 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||||||
when {
|
when {
|
||||||
city.isGrowing() -> {
|
city.isGrowing() -> {
|
||||||
val turnsToGrowth = city.getNumTurnsToNewPopulation()
|
val turnsToGrowth = city.getNumTurnsToNewPopulation()
|
||||||
turnLabel = if (turnsToGrowth != null) {
|
turnLabel = if (turnsToGrowth != null && turnsToGrowth < 100) turnsToGrowth.toString().toLabel() else "∞".toLabel()
|
||||||
if (turnsToGrowth < 100) {
|
|
||||||
turnsToGrowth.toString().toLabel()
|
|
||||||
} else {
|
|
||||||
"∞".toLabel()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
"∞".toLabel()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
city.isStarving() -> {
|
city.isStarving() -> {
|
||||||
val turnsToStarvation = city.getNumTurnsToStarvation()
|
val turnsToStarvation = city.getNumTurnsToStarvation()
|
||||||
turnLabel = if (turnsToStarvation != null) {
|
turnLabel = if (turnsToStarvation != null && turnsToStarvation < 100) turnsToStarvation.toString().toLabel() else "∞".toLabel()
|
||||||
if (turnsToStarvation < 100) {
|
|
||||||
turnsToStarvation.toString().toLabel()
|
|
||||||
} else {
|
|
||||||
"∞".toLabel()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
"∞".toLabel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
turnLabel = "∞".toLabel()
|
|
||||||
}
|
}
|
||||||
|
else -> turnLabel = "∞".toLabel()
|
||||||
}
|
}
|
||||||
turnLabel.color = city.civInfo.nation.getInnerColor()
|
turnLabel.color = city.civInfo.nation.getInnerColor()
|
||||||
turnLabel.setFontSize(14)
|
turnLabel.setFontSize(14)
|
||||||
@ -329,7 +319,14 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||||||
|
|
||||||
private fun getConstructionGroup(cityConstructions: CityConstructions): Group {
|
private fun getConstructionGroup(cityConstructions: CityConstructions): Group {
|
||||||
val cityCurrentConstruction = cityConstructions.getCurrentConstruction()
|
val cityCurrentConstruction = cityConstructions.getCurrentConstruction()
|
||||||
val group= Group()
|
|
||||||
|
class ConstructionGroup : Group() { // for recognition in the profiler
|
||||||
|
override fun draw(batch: Batch?, parentAlpha: Float) {
|
||||||
|
super.draw(batch, parentAlpha)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val group = ConstructionGroup().apply { isTransform = false }
|
||||||
val groupHeight = 25f
|
val groupHeight = 25f
|
||||||
val groupWidth = if (cityCurrentConstruction is PerpetualConstruction) 15f else 40f
|
val groupWidth = if (cityCurrentConstruction is PerpetualConstruction) 15f else 40f
|
||||||
group.setSize(groupWidth, groupHeight)
|
group.setSize(groupWidth, groupHeight)
|
||||||
@ -412,7 +409,10 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||||||
return barPiece
|
return barPiece
|
||||||
}
|
}
|
||||||
|
|
||||||
val influenceBar = Table().apply {
|
class InfluenceTable:Table() { // for recognition in the profiler
|
||||||
|
override fun draw(batch: Batch?, parentAlpha: Float) { super.draw(batch, parentAlpha) }
|
||||||
|
}
|
||||||
|
val influenceBar = InfluenceTable().apply {
|
||||||
defaults().pad(1f)
|
defaults().pad(1f)
|
||||||
setSize(width, height)
|
setSize(width, height)
|
||||||
background = ImageGetter.getBackground(Color.BLACK)
|
background = ImageGetter.getBackground(Color.BLACK)
|
||||||
@ -425,4 +425,9 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For debugging purposes
|
||||||
|
override fun draw(batch: Batch?, parentAlpha: Float) {
|
||||||
|
super.draw(batch, parentAlpha)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.tilegroups
|
package com.unciv.ui.tilegroups
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
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.Touchable
|
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||||
@ -31,7 +32,11 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
|||||||
Circle, Crosshair, Fog layer
|
Circle, Crosshair, Fog layer
|
||||||
City name
|
City name
|
||||||
*/
|
*/
|
||||||
val baseLayerGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize) }
|
|
||||||
|
// For recognizing the group in the profiler
|
||||||
|
class BaseLayerGroupClass:Group()
|
||||||
|
val baseLayerGroup = BaseLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize) }
|
||||||
|
|
||||||
protected var tileBaseImages: ArrayList<Image> = ArrayList()
|
protected var tileBaseImages: ArrayList<Image> = ArrayList()
|
||||||
/** List of ;-delimited image locations comprising the layers -
|
/** List of ;-delimited image locations comprising the layers -
|
||||||
* for instance, "desert+flood plains" might have an improvment for which there is a certain image eg "desert+flood plains+farm"
|
* for instance, "desert+flood plains" might have an improvment for which there is a certain image eg "desert+flood plains+farm"
|
||||||
@ -43,8 +48,9 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
|||||||
protected var baseTerrainOverlayImage: Image? = null
|
protected var baseTerrainOverlayImage: Image? = null
|
||||||
protected var baseTerrain: String = ""
|
protected var baseTerrain: String = ""
|
||||||
|
|
||||||
|
class TerrainFeatureLayerGroupClass:Group()
|
||||||
val terrainFeatureLayerGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize) }
|
val terrainFeatureLayerGroup = TerrainFeatureLayerGroupClass()
|
||||||
|
.apply { isTransform = false; setSize(groupSize, groupSize) }
|
||||||
|
|
||||||
// These are for OLD tiles - for instance the "forest" symbol on the forest
|
// These are for OLD tiles - for instance the "forest" symbol on the forest
|
||||||
protected var terrainFeatureOverlayImage: Image? = null
|
protected var terrainFeatureOverlayImage: Image? = null
|
||||||
@ -57,7 +63,9 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
|||||||
protected var pixelCivilianUnitImageLocation = ""
|
protected var pixelCivilianUnitImageLocation = ""
|
||||||
protected var pixelCivilianUnitGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize) }
|
protected var pixelCivilianUnitGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize) }
|
||||||
|
|
||||||
val miscLayerGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize) }
|
class MiscLayerGroupClass:Group()
|
||||||
|
val miscLayerGroup = MiscLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize) }
|
||||||
|
|
||||||
var resourceImage: Actor? = null
|
var resourceImage: Actor? = null
|
||||||
var resource: String? = null
|
var resource: String? = null
|
||||||
private val roadImages = HashMap<TileInfo, RoadImage>()
|
private val roadImages = HashMap<TileInfo, RoadImage>()
|
||||||
@ -65,7 +73,8 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
|||||||
|
|
||||||
val icons = TileGroupIcons(this)
|
val icons = TileGroupIcons(this)
|
||||||
|
|
||||||
val unitLayerGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize);touchable = Touchable.disabled }
|
class UnitLayerGroupClass:Group()
|
||||||
|
val unitLayerGroup = UnitLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize);touchable = Touchable.disabled }
|
||||||
|
|
||||||
val cityButtonLayerGroup = Group().apply { isTransform = true; setSize(groupSize, groupSize);
|
val cityButtonLayerGroup = Group().apply { isTransform = true; setSize(groupSize, groupSize);
|
||||||
touchable = Touchable.childrenOnly; setOrigin(Align.center) }
|
touchable = Touchable.childrenOnly; setOrigin(Align.center) }
|
||||||
@ -162,7 +171,6 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
|||||||
if (ImageGetter.imageExists(terrainAndCity))
|
if (ImageGetter.imageExists(terrainAndCity))
|
||||||
return listOf(terrainAndCity)
|
return listOf(terrainAndCity)
|
||||||
|
|
||||||
// val cityWithEra = tileSetStrings.getCityTile()
|
|
||||||
if (ImageGetter.imageExists(tileSetStrings.cityTile))
|
if (ImageGetter.imageExists(tileSetStrings.cityTile))
|
||||||
return listOf(tileSetStrings.cityTile)
|
return listOf(tileSetStrings.cityTile)
|
||||||
}
|
}
|
||||||
@ -677,4 +685,9 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
|||||||
fun hideCircle() {
|
fun hideCircle() {
|
||||||
circleImage.isVisible = false
|
circleImage.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** This exists so we can easily find the TileGroup draw method in the android profiling, otherwise it's just a mass of Group.draw->drawChildren->Group.draw etc. */
|
||||||
|
override fun draw(batch: Batch?, parentAlpha: Float) {
|
||||||
|
super.draw(batch, parentAlpha)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.unciv.ui.tilegroups
|
package com.unciv.ui.tilegroups
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.city.CityInfo
|
import com.unciv.logic.city.CityInfo
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
@ -61,4 +62,5 @@ class WorldTileGroup(internal val worldScreen: WorldScreen, tileInfo: TileInfo,
|
|||||||
if (city == null) return false
|
if (city == null) return false
|
||||||
return worldScreen.bottomUnitTable.citySelected(city)
|
return worldScreen.bottomUnitTable.citySelected(city)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.worldscreen
|
package com.unciv.ui.worldscreen
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import com.badlogic.gdx.scenes.scene2d.Group
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
@ -161,4 +162,10 @@ class MinimapHolder(mapHolder: WorldMapHolder): Table(){
|
|||||||
isVisible = UncivGame.Current.settings.showMinimap
|
isVisible = UncivGame.Current.settings.showMinimap
|
||||||
minimap.update(civInfo)
|
minimap.update(civInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// For debugging purposes
|
||||||
|
override fun draw(batch: Batch?, parentAlpha: Float) {
|
||||||
|
super.draw(batch, parentAlpha)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.ui.worldscreen
|
|||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
import com.badlogic.gdx.math.Interpolation
|
import com.badlogic.gdx.math.Interpolation
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import com.badlogic.gdx.scenes.scene2d.*
|
import com.badlogic.gdx.scenes.scene2d.*
|
||||||
@ -445,4 +446,9 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
|
|||||||
for(tileGroup in tileGroups.values)
|
for(tileGroup in tileGroups.values)
|
||||||
tileGroup.cityButtonLayerGroup.setScale(scale)
|
tileGroup.cityButtonLayerGroup.setScale(scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For debugging purposes
|
||||||
|
override fun draw(batch: Batch?, parentAlpha: Float) {
|
||||||
|
super.draw(batch, parentAlpha)
|
||||||
|
}
|
||||||
}
|
}
|
@ -118,8 +118,19 @@ internal object DesktopLauncher {
|
|||||||
// Apparently some chipsets, like NVIDIA Tegra 3 graphics chipset (used in Asus TF700T tablet),
|
// Apparently some chipsets, like NVIDIA Tegra 3 graphics chipset (used in Asus TF700T tablet),
|
||||||
// don't support non-power-of-two texture sizes - kudos @yuroller!
|
// don't support non-power-of-two texture sizes - kudos @yuroller!
|
||||||
// https://github.com/yairm210/UnCiv/issues/1340
|
// https://github.com/yairm210/UnCiv/issues/1340
|
||||||
settings.maxWidth = 2048
|
|
||||||
settings.maxHeight = 2048
|
/**
|
||||||
|
* These should be as big as possible in order to accommodate ALL the images together in one bug file.
|
||||||
|
* Why? Because the rendering function of the main screen renders all the images consecutively, and every time it needs to switch between textures,
|
||||||
|
* this causes a delay, leading to horrible lag if there are enough switches.
|
||||||
|
* The cost of this specific solution is that the entire game.png needs be be kept in-memory constantly.
|
||||||
|
* It's currently only 1.5MB so it should be okay, but it' an important point to remember for the future.
|
||||||
|
* Sidenode: Modded tilesets don't have this problem, since all the images are included in the mod's single PNG.
|
||||||
|
* Probably. Unless they have some truly huge images.
|
||||||
|
*/
|
||||||
|
settings.maxWidth = 4096
|
||||||
|
settings.maxHeight = 4096
|
||||||
|
|
||||||
settings.combineSubdirectories = true
|
settings.combineSubdirectories = true
|
||||||
settings.pot = true
|
settings.pot = true
|
||||||
settings.fast = true
|
settings.fast = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user