mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-08 01:54:02 +07:00
UI: Show terrain icons in text
This commit is contained in:
parent
3687a277a3
commit
c20944469d
@ -9,10 +9,12 @@ import com.badlogic.gdx.math.Matrix4
|
|||||||
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.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
|
import com.unciv.ui.components.extensions.center
|
||||||
import com.unciv.ui.components.extensions.setSize
|
import com.unciv.ui.components.extensions.setSize
|
||||||
import com.unciv.ui.components.fonts.FontRulesetIcons.getPixmapFromActor
|
import com.unciv.ui.components.fonts.FontRulesetIcons.getPixmapFromActor
|
||||||
import com.unciv.ui.images.ImageGetter
|
import com.unciv.ui.images.ImageGetter
|
||||||
import com.unciv.ui.images.Portrait
|
import com.unciv.ui.images.Portrait
|
||||||
|
import com.unciv.ui.screens.civilopediascreen.CivilopediaImageGetters
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
|
|
||||||
/** Map all or most Ruleset icons as Actors to unused Char codepoints,
|
/** Map all or most Ruleset icons as Actors to unused Char codepoints,
|
||||||
@ -72,6 +74,17 @@ object FontRulesetIcons {
|
|||||||
if (!ImageGetter.imageExists(fileLocation)) continue
|
if (!ImageGetter.imageExists(fileLocation)) continue
|
||||||
addChar(policy.name, ImageGetter.getImage(fileLocation).apply { setSize(Fonts.ORIGINAL_FONT_SIZE) })
|
addChar(policy.name, ImageGetter.getImage(fileLocation).apply { setSize(Fonts.ORIGINAL_FONT_SIZE) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (terrain in ruleset.terrains.values) {
|
||||||
|
// These ensure that the font icons are correctly sized - tilegroup rendering works differently than others, to account for clickability vs rendered areas
|
||||||
|
val tileGroup = CivilopediaImageGetters.terrainImage(terrain, ruleset, Fonts.ORIGINAL_FONT_SIZE)
|
||||||
|
tileGroup.width *= 1.5f
|
||||||
|
tileGroup.height *= 1.5f
|
||||||
|
for (layer in tileGroup.children) layer.center(tileGroup)
|
||||||
|
|
||||||
|
addChar(terrain.name, tileGroup)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val frameBuffer by lazy {
|
private val frameBuffer by lazy {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package com.unciv.ui.screens.civilopediascreen
|
package com.unciv.ui.screens.civilopediascreen
|
||||||
|
|
||||||
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.Group
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Container
|
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.map.tile.Tile
|
import com.unciv.logic.map.tile.Tile
|
||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
@ -23,7 +22,7 @@ internal object CivilopediaImageGetters {
|
|||||||
private const val policyInnerSize = 0.25f
|
private const val policyInnerSize = 0.25f
|
||||||
|
|
||||||
// Todo: potential synergy with map editor
|
// Todo: potential synergy with map editor
|
||||||
private fun terrainImage(terrain: Terrain, ruleset: Ruleset, imageSize: Float): Actor {
|
internal fun terrainImage(terrain: Terrain, ruleset: Ruleset, imageSize: Float): Group {
|
||||||
val tile = Tile()
|
val tile = Tile()
|
||||||
tile.ruleset = ruleset
|
tile.ruleset = ruleset
|
||||||
val baseTerrainFromOccursOn =
|
val baseTerrainFromOccursOn =
|
||||||
@ -48,7 +47,7 @@ internal object CivilopediaImageGetters {
|
|||||||
group.isForceVisible = true
|
group.isForceVisible = true
|
||||||
group.isForMapEditorIcon = true
|
group.isForMapEditorIcon = true
|
||||||
group.update()
|
group.update()
|
||||||
return Container(group)
|
return group
|
||||||
}
|
}
|
||||||
|
|
||||||
val construction = { name: String, size: Float ->
|
val construction = { name: String, size: Float ->
|
||||||
|
Loading…
Reference in New Issue
Block a user