mirror of
https://github.com/yairm210/Unciv.git
synced 2025-10-04 17:58:32 -04:00
City construction Civilopedia-linked (#4573)
* City construction Civilopedia-linked * City construction Civilopedia-linked - EOF
This commit is contained in:
parent
92c4e4e083
commit
70a18de7cc
@ -125,9 +125,9 @@ class BaseUnit : INamed, IConstruction, CivilopediaText() {
|
|||||||
|
|
||||||
if (uniqueTo != null) {
|
if (uniqueTo != null) {
|
||||||
textList += FormattedLine()
|
textList += FormattedLine()
|
||||||
textList += FormattedLine("Unique to [$uniqueTo],", link="Nation/$uniqueTo")
|
textList += FormattedLine("Unique to [$uniqueTo]", link="Nation/$uniqueTo")
|
||||||
if (replaces != null)
|
if (replaces != null)
|
||||||
textList += FormattedLine("replaces [$replaces]", link="Unit/$replaces", indent=1)
|
textList += FormattedLine("Replaces [$replaces]", link="Unit/$replaces", indent=1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requiredTech != null || upgradesTo != null || obsoleteTech != null) textList += FormattedLine()
|
if (requiredTech != null || upgradesTo != null || obsoleteTech != null) textList += FormattedLine()
|
||||||
|
@ -64,7 +64,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
|||||||
private fun addBuildingInfo(building: Building, destinationTable: Table) {
|
private fun addBuildingInfo(building: Building, destinationTable: Table) {
|
||||||
val icon = ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f)
|
val icon = ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f)
|
||||||
val buildingNameAndIconTable = ExpanderTab(building.name, 18, icon, false, 5f) {
|
val buildingNameAndIconTable = ExpanderTab(building.name, 18, icon, false, 5f) {
|
||||||
val detailsString = building.getDescription(cityScreen.city, cityScreen.city.civInfo.gameInfo.ruleSet)
|
val detailsString = building.getDescription(cityScreen.city, cityScreen.city.getRuleset())
|
||||||
it.add(detailsString.toLabel().apply { wrap = true })
|
it.add(detailsString.toLabel().apply { wrap = true })
|
||||||
.width(cityScreen.stage.width / 4 - 2 * pad).row() // when you set wrap, then you need to manually set the size of the label
|
.width(cityScreen.stage.width / 4 - 2 * pad).row() // when you set wrap, then you need to manually set the size of the label
|
||||||
if (building.isSellable()) {
|
if (building.isSellable()) {
|
||||||
|
@ -36,7 +36,7 @@ class CityScreenTileTable(private val cityScreen: CityScreen): Table() {
|
|||||||
|
|
||||||
innerTable.add( MarkupRenderer.render(selectedTile.toMarkup(city.civInfo), noLinkImages = true) {
|
innerTable.add( MarkupRenderer.render(selectedTile.toMarkup(city.civInfo), noLinkImages = true) {
|
||||||
// Sorry, this will leave the city screen
|
// Sorry, this will leave the city screen
|
||||||
UncivGame.Current.setScreen(CivilopediaScreen(city.civInfo.gameInfo.ruleSet, link = it))
|
UncivGame.Current.setScreen(CivilopediaScreen(city.getRuleset(), link = it))
|
||||||
} )
|
} )
|
||||||
innerTable.row()
|
innerTable.row()
|
||||||
innerTable.add(getTileStatsTable(stats)).row()
|
innerTable.add(getTileStatsTable(stats)).row()
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
package com.unciv.ui.cityscreen
|
package com.unciv.ui.cityscreen
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.city.CityInfo
|
import com.unciv.logic.city.CityInfo
|
||||||
import com.unciv.logic.city.IConstruction
|
import com.unciv.logic.city.IConstruction
|
||||||
import com.unciv.logic.city.PerpetualConstruction
|
import com.unciv.logic.city.PerpetualConstruction
|
||||||
import com.unciv.models.ruleset.Building
|
import com.unciv.models.ruleset.Building
|
||||||
import com.unciv.models.ruleset.unit.BaseUnit
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
|
import com.unciv.ui.civilopedia.CivilopediaScreen
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.surroundWithCircle
|
import com.unciv.ui.utils.surroundWithCircle
|
||||||
import com.unciv.ui.utils.toLabel
|
import com.unciv.ui.utils.toLabel
|
||||||
|
|
||||||
class ConstructionInfoTable(val city: CityInfo): Table() {
|
class ConstructionInfoTable(val city: CityInfo): Table() {
|
||||||
val selectedConstructionTable = Table()
|
private val selectedConstructionTable = Table()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
selectedConstructionTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
selectedConstructionTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||||
@ -23,7 +27,6 @@ class ConstructionInfoTable(val city: CityInfo): Table() {
|
|||||||
|
|
||||||
fun update(selectedConstruction: IConstruction?) {
|
fun update(selectedConstruction: IConstruction?) {
|
||||||
selectedConstructionTable.clear()
|
selectedConstructionTable.clear()
|
||||||
selectedConstructionTable.pad(5f)
|
|
||||||
|
|
||||||
if (selectedConstruction == null) {
|
if (selectedConstruction == null) {
|
||||||
isVisible = false
|
isVisible = false
|
||||||
@ -31,42 +34,48 @@ class ConstructionInfoTable(val city: CityInfo): Table() {
|
|||||||
}
|
}
|
||||||
isVisible = true
|
isVisible = true
|
||||||
|
|
||||||
addSelectedConstructionTable(selectedConstruction)
|
updateSelectedConstructionTable(selectedConstruction)
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addSelectedConstructionTable(construction: IConstruction) {
|
private fun updateSelectedConstructionTable(construction: IConstruction) {
|
||||||
val cityConstructions = city.cityConstructions
|
val cityConstructions = city.cityConstructions
|
||||||
|
|
||||||
//val selectedConstructionTable = Table()
|
//val selectedConstructionTable = Table()
|
||||||
selectedConstructionTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
selectedConstructionTable.run {
|
||||||
selectedConstructionTable.pad(10f)
|
background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||||
|
pad(10f)
|
||||||
|
|
||||||
selectedConstructionTable.add(
|
add(ImageGetter.getConstructionImage(construction.name).surroundWithCircle(50f))
|
||||||
ImageGetter.getConstructionImage(construction.name).surroundWithCircle(50f))
|
|
||||||
.pad(5f)
|
.pad(5f)
|
||||||
|
|
||||||
|
var buildingText = construction.name.tr()
|
||||||
|
val specialConstruction = PerpetualConstruction.perpetualConstructionsMap[construction.name]
|
||||||
|
|
||||||
var buildingText = construction.name.tr()
|
buildingText += specialConstruction?.getProductionTooltip(city)
|
||||||
val specialConstruction = PerpetualConstruction.perpetualConstructionsMap[construction.name]
|
?: cityConstructions.getTurnsToConstructionString(construction.name)
|
||||||
|
|
||||||
if (specialConstruction == null) buildingText += cityConstructions.getTurnsToConstructionString(construction.name)
|
add(buildingText.toLabel()).row()
|
||||||
else buildingText += specialConstruction.getProductionTooltip(city)
|
|
||||||
|
|
||||||
selectedConstructionTable.add(buildingText.toLabel()).row()
|
val (description, link) = when (construction) {
|
||||||
|
is BaseUnit -> construction.getDescription() to "Unit/${construction.name}"
|
||||||
|
is Building -> construction.getDescription(city, city.getRuleset()) to construction.makeLink()
|
||||||
|
is PerpetualConstruction -> construction.description.replace("[rate]", "[${construction.getConversionRate(city)}]") to ""
|
||||||
|
else -> "" to "" // Should never happen
|
||||||
|
}
|
||||||
|
|
||||||
|
val descriptionLabel = description.toLabel()
|
||||||
|
descriptionLabel.wrap = true
|
||||||
|
add(descriptionLabel).colspan(2).width(stage.width / 4)
|
||||||
|
|
||||||
val description: String = when (construction) {
|
clearListeners()
|
||||||
is BaseUnit -> construction.getDescription()
|
if (link.isEmpty()) return
|
||||||
is Building -> construction.getDescription(city, city.civInfo.gameInfo.ruleSet)
|
touchable = Touchable.enabled
|
||||||
is PerpetualConstruction -> construction.description.replace("[rate]", "[${construction.getConversionRate(city)}]").tr()
|
onClick {
|
||||||
else -> "" // Should never happen
|
UncivGame.Current.setScreen(CivilopediaScreen(city.getRuleset(), link = link))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val descriptionLabel = description.toLabel()
|
|
||||||
descriptionLabel.wrap = true
|
|
||||||
selectedConstructionTable.add(descriptionLabel).colspan(2).width(stage.width / 4)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user