mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Resolved #1493 - Added Nation information to Civilopedia
This commit is contained in:
parent
7d746df5a2
commit
09c8cf221f
@ -66,7 +66,6 @@ class UncivGame(val version: String) : Game() {
|
||||
|
||||
thread {
|
||||
ruleset = Ruleset(true)
|
||||
settings.hasCrashedRecently=true // for test
|
||||
|
||||
if(rewriteTranslationFiles) { // Yes, also when running from the Jar. Sue me.
|
||||
translations.readAllLanguagesTranslation()
|
||||
|
@ -3,6 +3,8 @@ package com.unciv.models.ruleset
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.logic.civilization.CityStateType
|
||||
import com.unciv.models.stats.INamed
|
||||
import com.unciv.models.translations.Translations
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.utils.colorFromRGB
|
||||
|
||||
enum class VictoryType{
|
||||
@ -75,4 +77,87 @@ class Nation : INamed {
|
||||
}
|
||||
|
||||
lateinit var cities: List<String>
|
||||
|
||||
|
||||
|
||||
|
||||
fun getUniqueString(ruleset: Ruleset): String {
|
||||
val textList = ArrayList<String>()
|
||||
|
||||
if (unique != null) {
|
||||
textList += unique!!.tr()
|
||||
textList += ""
|
||||
}
|
||||
|
||||
addUniqueBuildingsText(textList,ruleset)
|
||||
addUniqueUnitsText(textList,ruleset)
|
||||
addUniqueImprovementsText(textList,ruleset)
|
||||
|
||||
return textList.joinToString("\n").tr().trim()
|
||||
}
|
||||
|
||||
private fun addUniqueBuildingsText(textList: ArrayList<String>, ruleset: Ruleset) {
|
||||
for (building in ruleset.Buildings.values
|
||||
.filter { it.uniqueTo == name }) {
|
||||
val originalBuilding = ruleset.Buildings[building.replaces!!]!!
|
||||
|
||||
textList += building.name.tr() + " - {replaces} " + originalBuilding.name.tr()
|
||||
val originalBuildingStatMap = originalBuilding.toHashMap()
|
||||
for (stat in building.toHashMap())
|
||||
if (stat.value != originalBuildingStatMap[stat.key])
|
||||
textList += " " + stat.key.toString().tr() + " " + stat.value.toInt() + " vs " + originalBuildingStatMap[stat.key]!!.toInt()
|
||||
|
||||
for (unique in building.uniques.filter { it !in originalBuilding.uniques })
|
||||
textList += " " + unique.tr()
|
||||
if (building.maintenance != originalBuilding.maintenance)
|
||||
textList += " {Maintenance} " + building.maintenance + " vs " + originalBuilding.maintenance
|
||||
if (building.cost != originalBuilding.cost)
|
||||
textList += " {Cost} " + building.cost + " vs " + originalBuilding.cost
|
||||
if (building.cityStrength != originalBuilding.cityStrength)
|
||||
textList += " {City strength} " + building.cityStrength + " vs " + originalBuilding.cityStrength
|
||||
if (building.cityHealth != originalBuilding.cityHealth)
|
||||
textList += " {City health} " + building.cityHealth + " vs " + originalBuilding.cityHealth
|
||||
textList += ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun addUniqueUnitsText(textList: ArrayList<String>, ruleset: Ruleset) {
|
||||
for (unit in ruleset.Units.values
|
||||
.filter { it.uniqueTo == name }) {
|
||||
val originalUnit = ruleset.Units[unit.replaces!!]!!
|
||||
|
||||
textList += unit.name.tr() + " - {replaces} " + originalUnit.name.tr()
|
||||
if (unit.cost != originalUnit.cost)
|
||||
textList += " {Cost} " + unit.cost + " vs " + originalUnit.cost
|
||||
if (unit.strength != originalUnit.strength)
|
||||
textList += " {Strength} " + unit.strength + " vs " + originalUnit.strength
|
||||
if (unit.rangedStrength != originalUnit.rangedStrength)
|
||||
textList += " {Ranged strength} " + unit.rangedStrength + " vs " + originalUnit.rangedStrength
|
||||
if (unit.range != originalUnit.range)
|
||||
textList += " {Range} " + unit.range + " vs " + originalUnit.range
|
||||
if (unit.movement != originalUnit.movement)
|
||||
textList += " {Movement} " + unit.movement + " vs " + originalUnit.movement
|
||||
if (originalUnit.requiredResource != null && unit.requiredResource == null)
|
||||
textList += " " + "[${originalUnit.requiredResource}] not required".tr()
|
||||
for (unique in unit.uniques.filterNot { it in originalUnit.uniques })
|
||||
textList += " " + Translations.translateBonusOrPenalty(unique)
|
||||
for (unique in originalUnit.uniques.filterNot { it in unit.uniques })
|
||||
textList += " " + "Lost ability".tr() + "(vs " + originalUnit.name.tr() + "): " + Translations.translateBonusOrPenalty(unique)
|
||||
for (promotion in unit.promotions.filter { it !in originalUnit.promotions })
|
||||
textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(ruleset.UnitPromotions[promotion]!!.effect) + ")"
|
||||
|
||||
textList += ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun addUniqueImprovementsText(textList: ArrayList<String>, ruleset: Ruleset) {
|
||||
for (improvement in ruleset.TileImprovements.values
|
||||
.filter { it.uniqueTo == name }) {
|
||||
|
||||
textList += improvement.name.tr()
|
||||
textList += " "+improvement.clone().toString()
|
||||
for(unique in improvement.uniques)
|
||||
textList += " "+unique.tr()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,19 +9,7 @@ import com.unciv.ui.utils.*
|
||||
import java.util.*
|
||||
|
||||
class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() {
|
||||
class CivilopediaEntry {
|
||||
var name: String
|
||||
var description: String
|
||||
var image: Actor?=null
|
||||
|
||||
constructor(name: String, description: String, image: Actor?=null) {
|
||||
this.name = name
|
||||
this.description = description
|
||||
this.image = image
|
||||
}
|
||||
|
||||
constructor() : this("","") // Needed for GameBasics json deserializing
|
||||
}
|
||||
class CivilopediaEntry(var name: String, var description: String, var image: Actor? = null)
|
||||
|
||||
val categoryToEntries = LinkedHashMap<String, Collection<CivilopediaEntry>>()
|
||||
val categoryToButtons = LinkedHashMap<String, Button>()
|
||||
@ -84,6 +72,10 @@ class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() {
|
||||
categoryToEntries["Units"] = ruleset.Units.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(false),
|
||||
ImageGetter.getConstructionImage(it.name)) }
|
||||
categoryToEntries["Nations"] = ruleset.Nations.values
|
||||
.filter { it.isMajorCiv() }
|
||||
.map { CivilopediaEntry(it.name,it.getUniqueString(ruleset),
|
||||
ImageGetter.getNationIndicator(it,50f)) }
|
||||
categoryToEntries["Technologies"] = ruleset.Technologies.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(ruleset),
|
||||
ImageGetter.getTechIconGroup(it.name,50f)) }
|
||||
|
@ -1,12 +1,9 @@
|
||||
package com.unciv.ui.newgamescreen
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.models.ruleset.Nation
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.translations.Translations
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.toLabel
|
||||
@ -30,90 +27,12 @@ class NationTable(val nation: Nation, width:Float, ruleset: Ruleset)
|
||||
}
|
||||
else titleTable.add(leaderDisplayLabel)
|
||||
innerTable.add(titleTable).row()
|
||||
|
||||
innerTable.add(getUniqueLabel(nation,ruleset).apply { setWrap(true) }).width(width)
|
||||
val nationUniqueLabel =nation.getUniqueString(ruleset).toLabel(nation.getInnerColor())
|
||||
nationUniqueLabel.setWrap(true)
|
||||
innerTable.add(nationUniqueLabel).width(width)
|
||||
touchable = Touchable.enabled
|
||||
add(innerTable)
|
||||
}
|
||||
|
||||
private fun getUniqueLabel(nation: Nation, ruleset: Ruleset): Label {
|
||||
val textList = ArrayList<String>()
|
||||
|
||||
if (nation.unique != null) {
|
||||
textList += nation.unique!!.tr()
|
||||
textList += ""
|
||||
}
|
||||
|
||||
addUniqueBuildingsText(nation, textList,ruleset)
|
||||
addUniqueUnitsText(nation, textList,ruleset)
|
||||
addUniqueImprovementsText(nation, textList,ruleset)
|
||||
|
||||
return textList.joinToString("\n").tr().trim().toLabel(nation.getInnerColor())
|
||||
}
|
||||
|
||||
private fun addUniqueBuildingsText(nation: Nation, textList: ArrayList<String>, ruleset: Ruleset) {
|
||||
for (building in ruleset.Buildings.values
|
||||
.filter { it.uniqueTo == nation.name }) {
|
||||
val originalBuilding = ruleset.Buildings[building.replaces!!]!!
|
||||
|
||||
textList += building.name.tr() + " - {replaces} " + originalBuilding.name.tr()
|
||||
val originalBuildingStatMap = originalBuilding.toHashMap()
|
||||
for (stat in building.toHashMap())
|
||||
if (stat.value != originalBuildingStatMap[stat.key])
|
||||
textList += " " + stat.key.toString().tr() + " " + stat.value.toInt() + " vs " + originalBuildingStatMap[stat.key]!!.toInt()
|
||||
|
||||
for (unique in building.uniques.filter { it !in originalBuilding.uniques })
|
||||
textList += " " + unique.tr()
|
||||
if (building.maintenance != originalBuilding.maintenance)
|
||||
textList += " {Maintenance} " + building.maintenance + " vs " + originalBuilding.maintenance
|
||||
if (building.cost != originalBuilding.cost)
|
||||
textList += " {Cost} " + building.cost + " vs " + originalBuilding.cost
|
||||
if (building.cityStrength != originalBuilding.cityStrength)
|
||||
textList += " {City strength} " + building.cityStrength + " vs " + originalBuilding.cityStrength
|
||||
if (building.cityHealth != originalBuilding.cityHealth)
|
||||
textList += " {City health} " + building.cityHealth + " vs " + originalBuilding.cityHealth
|
||||
textList += ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun addUniqueUnitsText(nation: Nation, textList: ArrayList<String>, ruleset: Ruleset) {
|
||||
for (unit in ruleset.Units.values
|
||||
.filter { it.uniqueTo == nation.name }) {
|
||||
val originalUnit = ruleset.Units[unit.replaces!!]!!
|
||||
|
||||
textList += unit.name.tr() + " - {replaces} " + originalUnit.name.tr()
|
||||
if (unit.cost != originalUnit.cost)
|
||||
textList += " {Cost} " + unit.cost + " vs " + originalUnit.cost
|
||||
if (unit.strength != originalUnit.strength)
|
||||
textList += " {Strength} " + unit.strength + " vs " + originalUnit.strength
|
||||
if (unit.rangedStrength != originalUnit.rangedStrength)
|
||||
textList += " {Ranged strength} " + unit.rangedStrength + " vs " + originalUnit.rangedStrength
|
||||
if (unit.range != originalUnit.range)
|
||||
textList += " {Range} " + unit.range + " vs " + originalUnit.range
|
||||
if (unit.movement != originalUnit.movement)
|
||||
textList += " {Movement} " + unit.movement + " vs " + originalUnit.movement
|
||||
if (originalUnit.requiredResource != null && unit.requiredResource == null)
|
||||
textList += " " + "[${originalUnit.requiredResource}] not required".tr()
|
||||
for (unique in unit.uniques.filterNot { it in originalUnit.uniques })
|
||||
textList += " " + Translations.translateBonusOrPenalty(unique)
|
||||
for (unique in originalUnit.uniques.filterNot { it in unit.uniques })
|
||||
textList += " " + "Lost ability".tr() + "(vs " + originalUnit.name.tr() + "): " + Translations.translateBonusOrPenalty(unique)
|
||||
for (promotion in unit.promotions.filter { it !in originalUnit.promotions })
|
||||
textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(ruleset.UnitPromotions[promotion]!!.effect) + ")"
|
||||
|
||||
textList += ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun addUniqueImprovementsText(nation: Nation, textList: ArrayList<String>, ruleset: Ruleset) {
|
||||
for (improvement in ruleset.TileImprovements.values
|
||||
.filter { it.uniqueTo == nation.name }) {
|
||||
|
||||
textList += improvement.name.tr()
|
||||
textList += " "+improvement.clone().toString()
|
||||
for(unique in improvement.uniques)
|
||||
textList += " "+unique.tr()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user