mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 03:18:18 +07:00
Resolved #1312 - More obvious division between promotion 'pick now' and description
Civilopedia redone! Now with simpler picking and images!
This commit is contained in:
parent
a94a3f9d2e
commit
c6b550e43d
Binary file not shown.
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 611 B |
Binary file not shown.
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
@ -1,10 +1,9 @@
|
||||
package com.unciv.logic.city
|
||||
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.ICivilopedia
|
||||
import com.unciv.models.stats.INamed
|
||||
|
||||
interface IConstruction : INamed, ICivilopedia {
|
||||
interface IConstruction : INamed {
|
||||
fun getProductionCost(civInfo: CivilizationInfo): Int
|
||||
fun getGoldCost(civInfo: CivilizationInfo): Int
|
||||
fun isBuildable(construction: CityConstructions): Boolean
|
||||
@ -15,7 +14,7 @@ interface IConstruction : INamed, ICivilopedia {
|
||||
|
||||
|
||||
|
||||
open class SpecialConstruction(override var name: String, override val description: String) : IConstruction{
|
||||
open class SpecialConstruction(override var name: String, val description: String) : IConstruction{
|
||||
override fun shouldBeDisplayed(construction: CityConstructions): Boolean {
|
||||
return isBuildable(construction)
|
||||
}
|
||||
|
@ -12,9 +12,6 @@ import kotlin.math.pow
|
||||
|
||||
class Building : NamedStats(), IConstruction{
|
||||
|
||||
override val description: String
|
||||
get() = getDescription(false, null)
|
||||
|
||||
var requiredTech: String? = null
|
||||
|
||||
var cost: Int = 0
|
||||
|
@ -2,11 +2,10 @@ package com.unciv.models.gamebasics.tech
|
||||
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ICivilopedia
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import java.util.*
|
||||
|
||||
class Technology : ICivilopedia {
|
||||
class Technology {
|
||||
|
||||
lateinit var name: String
|
||||
|
||||
@ -18,61 +17,60 @@ class Technology : ICivilopedia {
|
||||
var row: Int = 0
|
||||
var quote=""
|
||||
|
||||
override val description: String
|
||||
get() {
|
||||
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
||||
for (unique in uniques) lineList += unique.tr()
|
||||
fun getDescription(): String {
|
||||
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
||||
for (unique in uniques) lineList += unique.tr()
|
||||
|
||||
val improvedImprovements = GameBasics.TileImprovements.values
|
||||
.filter { it.improvingTech == name }.groupBy { it.improvingTechStats.toString() }
|
||||
for (improvement in improvedImprovements) {
|
||||
val impimpString = improvement.value.joinToString { it.name.tr() } +
|
||||
" {provide" + (if (improvement.value.size == 1) "s" else "") + "} " + improvement.key
|
||||
lineList += impimpString.tr()
|
||||
}
|
||||
|
||||
val viewingCiv = UnCivGame.Current.worldScreen.viewingCiv
|
||||
var enabledUnits = GameBasics.Units.values.filter {
|
||||
it.requiredTech == name &&
|
||||
(it.uniqueTo == null || it.uniqueTo == viewingCiv.civName)
|
||||
}
|
||||
val replacedUnits = enabledUnits.mapNotNull { it.replaces }
|
||||
enabledUnits = enabledUnits.filter { it.name !in replacedUnits }
|
||||
if (enabledUnits.isNotEmpty()) {
|
||||
lineList += "{Units enabled}: "
|
||||
for (unit in enabledUnits)
|
||||
lineList += " * " + unit.name.tr() + " (" + unit.getShortDescription() + ")"
|
||||
}
|
||||
|
||||
var enabledBuildings = GameBasics.Buildings.values.filter {
|
||||
it.requiredTech == name &&
|
||||
(it.uniqueTo == null || it.uniqueTo == viewingCiv.civName)
|
||||
}
|
||||
val replacedBuildings = enabledBuildings.mapNotNull { it.replaces }
|
||||
enabledBuildings = enabledBuildings.filter { it.name !in replacedBuildings }
|
||||
val regularBuildings = enabledBuildings.filter { !it.isWonder && !it.isNationalWonder }
|
||||
if (regularBuildings.isNotEmpty()) {
|
||||
lineList += "{Buildings enabled}: "
|
||||
for (building in regularBuildings)
|
||||
lineList += "* " + building.name.tr() + " (" + building.getShortDescription() + ")"
|
||||
}
|
||||
val wonders = enabledBuildings.filter { it.isWonder || it.isNationalWonder }
|
||||
if (wonders.isNotEmpty()) {
|
||||
lineList += "{Wonders enabled}: "
|
||||
for (wonder in wonders)
|
||||
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription() + ")"
|
||||
}
|
||||
|
||||
val revealedResource = GameBasics.TileResources.values.filter { it.revealedBy == name }.map { it.name }.firstOrNull() // can only be one
|
||||
if (revealedResource != null) lineList += "Reveals [$revealedResource] on the map".tr()
|
||||
|
||||
val tileImprovements = GameBasics.TileImprovements.values.filter { it.techRequired == name }
|
||||
if (tileImprovements.isNotEmpty())
|
||||
lineList += "{Tile improvements enabled}: " + tileImprovements.joinToString { it.name.tr() }
|
||||
|
||||
return lineList.joinToString("\n") { it.tr() }
|
||||
val improvedImprovements = GameBasics.TileImprovements.values
|
||||
.filter { it.improvingTech == name }.groupBy { it.improvingTechStats.toString() }
|
||||
for (improvement in improvedImprovements) {
|
||||
val impimpString = improvement.value.joinToString { it.name.tr() } +
|
||||
" {provide" + (if (improvement.value.size == 1) "s" else "") + "} " + improvement.key
|
||||
lineList += impimpString.tr()
|
||||
}
|
||||
|
||||
val viewingCiv = UnCivGame.Current.worldScreen.viewingCiv
|
||||
var enabledUnits = GameBasics.Units.values.filter {
|
||||
it.requiredTech == name &&
|
||||
(it.uniqueTo == null || it.uniqueTo == viewingCiv.civName)
|
||||
}
|
||||
val replacedUnits = enabledUnits.mapNotNull { it.replaces }
|
||||
enabledUnits = enabledUnits.filter { it.name !in replacedUnits }
|
||||
if (enabledUnits.isNotEmpty()) {
|
||||
lineList += "{Units enabled}: "
|
||||
for (unit in enabledUnits)
|
||||
lineList += " * " + unit.name.tr() + " (" + unit.getShortDescription() + ")"
|
||||
}
|
||||
|
||||
var enabledBuildings = GameBasics.Buildings.values.filter {
|
||||
it.requiredTech == name &&
|
||||
(it.uniqueTo == null || it.uniqueTo == viewingCiv.civName)
|
||||
}
|
||||
val replacedBuildings = enabledBuildings.mapNotNull { it.replaces }
|
||||
enabledBuildings = enabledBuildings.filter { it.name !in replacedBuildings }
|
||||
val regularBuildings = enabledBuildings.filter { !it.isWonder && !it.isNationalWonder }
|
||||
if (regularBuildings.isNotEmpty()) {
|
||||
lineList += "{Buildings enabled}: "
|
||||
for (building in regularBuildings)
|
||||
lineList += "* " + building.name.tr() + " (" + building.getShortDescription() + ")"
|
||||
}
|
||||
val wonders = enabledBuildings.filter { it.isWonder || it.isNationalWonder }
|
||||
if (wonders.isNotEmpty()) {
|
||||
lineList += "{Wonders enabled}: "
|
||||
for (wonder in wonders)
|
||||
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription() + ")"
|
||||
}
|
||||
|
||||
val revealedResource = GameBasics.TileResources.values.filter { it.revealedBy == name }.map { it.name }.firstOrNull() // can only be one
|
||||
if (revealedResource != null) lineList += "Reveals [$revealedResource] on the map".tr()
|
||||
|
||||
val tileImprovements = GameBasics.TileImprovements.values.filter { it.techRequired == name }
|
||||
if (tileImprovements.isNotEmpty())
|
||||
lineList += "{Tile improvements enabled}: " + tileImprovements.joinToString { it.name.tr() }
|
||||
|
||||
return lineList.joinToString("\n") { it.tr() }
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return name
|
||||
}
|
||||
|
@ -2,42 +2,31 @@ package com.unciv.models.gamebasics.tile
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ICivilopedia
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.stats.NamedStats
|
||||
import com.unciv.ui.utils.colorFromRGB
|
||||
import com.unciv.models.gamebasics.tr
|
||||
|
||||
class Terrain : NamedStats(), ICivilopedia {
|
||||
override val description: String
|
||||
get(){
|
||||
val sb = StringBuilder()
|
||||
sb.appendln(this.clone().toString())
|
||||
val terrainsCanBeBuiltOnString:ArrayList<String> = arrayListOf()
|
||||
if(occursOn!=null) {
|
||||
occursOn.forEach {
|
||||
terrainsCanBeBuiltOnString.add(it.tr())
|
||||
}
|
||||
sb.appendln("Occurs on [${terrainsCanBeBuiltOnString!!.joinToString(", ")}]".tr())
|
||||
}
|
||||
val resourcesFoundString:ArrayList<String> = arrayListOf()
|
||||
val resourcesFound = GameBasics.TileResources.values.filter { it.terrainsCanBeFoundOn.contains(name)}
|
||||
if(resourcesFound.isNotEmpty()) {
|
||||
for (i in resourcesFound) {
|
||||
resourcesFoundString.add(i.toString().tr())
|
||||
}
|
||||
sb.appendln("May contain [${resourcesFoundString!!.joinToString(", ")}]".tr())
|
||||
}
|
||||
sb.appendln("{Movement cost}: $movementCost".tr())
|
||||
if(defenceBonus!=0f){
|
||||
sb.appendln("{Defence bonus}: ".tr()+(defenceBonus*100).toInt()+"%")
|
||||
}
|
||||
|
||||
if(rough)
|
||||
sb.appendln("Rough Terrain".tr())
|
||||
|
||||
return sb.toString()
|
||||
class Terrain : NamedStats() {
|
||||
fun getDescription(): String {
|
||||
val sb = StringBuilder()
|
||||
sb.appendln(this.clone().toString())
|
||||
if (occursOn != null) {
|
||||
sb.appendln("Occurs on [${occursOn.joinToString(", ")}]".tr())
|
||||
}
|
||||
val resourcesFound = GameBasics.TileResources.values.filter { it.terrainsCanBeFoundOn.contains(name) }
|
||||
if (resourcesFound.isNotEmpty()) {
|
||||
sb.appendln("May contain [${resourcesFound.joinToString(", ") { it.name.tr() }}]".tr())
|
||||
}
|
||||
sb.appendln("{Movement cost}: $movementCost".tr())
|
||||
if (defenceBonus != 0f) {
|
||||
sb.appendln("{Defence bonus}: ".tr() + (defenceBonus * 100).toInt() + "%")
|
||||
}
|
||||
|
||||
if (rough) sb.appendln("Rough Terrain".tr())
|
||||
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
lateinit var type: TerrainType
|
||||
|
||||
var overrideStats = false
|
||||
|
@ -2,13 +2,12 @@ package com.unciv.models.gamebasics.tile
|
||||
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ICivilopedia
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.stats.NamedStats
|
||||
import com.unciv.models.stats.Stats
|
||||
import java.util.*
|
||||
|
||||
class TileImprovement : NamedStats(), ICivilopedia {
|
||||
class TileImprovement : NamedStats() {
|
||||
|
||||
var terrainsCanBeBuiltOn: Collection<String> = ArrayList()
|
||||
var techRequired: String? = null
|
||||
@ -30,31 +29,30 @@ class TileImprovement : NamedStats(), ICivilopedia {
|
||||
return Math.round(realTurnsToBuild)
|
||||
}
|
||||
|
||||
override val description: String
|
||||
get() {
|
||||
val stringBuilder = StringBuilder()
|
||||
if (this.clone().toString().isNotEmpty()) stringBuilder.appendln(this.clone().toString())
|
||||
if (!terrainsCanBeBuiltOn.isEmpty()) {
|
||||
val terrainsCanBeBuiltOnString:ArrayList<String> = arrayListOf()
|
||||
for (i in terrainsCanBeBuiltOn) {
|
||||
terrainsCanBeBuiltOnString.add(i.tr())
|
||||
}
|
||||
stringBuilder.appendln("Can be built on ".tr() + terrainsCanBeBuiltOnString.joinToString(", "))//language can be changed when setting changes.
|
||||
fun getDescription(): String {
|
||||
val stringBuilder = StringBuilder()
|
||||
if (this.clone().toString().isNotEmpty()) stringBuilder.appendln(this.clone().toString())
|
||||
if (!terrainsCanBeBuiltOn.isEmpty()) {
|
||||
val terrainsCanBeBuiltOnString: ArrayList<String> = arrayListOf()
|
||||
for (i in terrainsCanBeBuiltOn) {
|
||||
terrainsCanBeBuiltOnString.add(i.tr())
|
||||
}
|
||||
val statsToResourceNames = HashMap<String, ArrayList<String>>()
|
||||
for (tr: TileResource in GameBasics.TileResources.values.filter { it.improvement == name }) {
|
||||
val statsString = tr.improvementStats.toString()
|
||||
if (!statsToResourceNames.containsKey(statsString))
|
||||
statsToResourceNames[statsString] = ArrayList()
|
||||
statsToResourceNames[statsString]!!.add(tr.name.tr())
|
||||
}
|
||||
statsToResourceNames.forEach {
|
||||
stringBuilder.appendln(it.key + " for ".tr() + it.value.joinToString(", "))
|
||||
}
|
||||
|
||||
if (techRequired != null) stringBuilder.appendln("Required tech: [$techRequired]".tr())
|
||||
|
||||
return stringBuilder.toString()
|
||||
stringBuilder.appendln("Can be built on ".tr() + terrainsCanBeBuiltOnString.joinToString(", "))//language can be changed when setting changes.
|
||||
}
|
||||
val statsToResourceNames = HashMap<String, ArrayList<String>>()
|
||||
for (tr: TileResource in GameBasics.TileResources.values.filter { it.improvement == name }) {
|
||||
val statsString = tr.improvementStats.toString()
|
||||
if (!statsToResourceNames.containsKey(statsString))
|
||||
statsToResourceNames[statsString] = ArrayList()
|
||||
statsToResourceNames[statsString]!!.add(tr.name.tr())
|
||||
}
|
||||
statsToResourceNames.forEach {
|
||||
stringBuilder.appendln(it.key + " for ".tr() + it.value.joinToString(", "))
|
||||
}
|
||||
|
||||
if (techRequired != null) stringBuilder.appendln("Required tech: [$techRequired]".tr())
|
||||
|
||||
return stringBuilder.toString()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,13 @@ package com.unciv.models.gamebasics.tile
|
||||
|
||||
import com.unciv.models.gamebasics.Building
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ICivilopedia
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.stats.NamedStats
|
||||
import com.unciv.models.stats.Stats
|
||||
import java.util.*
|
||||
|
||||
class TileResource : NamedStats(), ICivilopedia {
|
||||
override val description: String
|
||||
get(){
|
||||
class TileResource : NamedStats() {
|
||||
fun getDescription(): String {
|
||||
val stringBuilder = StringBuilder()
|
||||
stringBuilder.appendln(this.clone().toString())
|
||||
val terrainsCanBeBuiltOnString:ArrayList<String> = arrayListOf()
|
||||
|
@ -6,7 +6,6 @@ import com.unciv.logic.city.IConstruction
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ICivilopedia
|
||||
import com.unciv.models.gamebasics.Translations
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.stats.INamed
|
||||
@ -15,7 +14,7 @@ import com.unciv.models.stats.INamed
|
||||
|
||||
/** This is the basic info of the units, as specified in Units.json,
|
||||
in contrast to MapUnit, which is a specific unit of a certain type that appears on the map */
|
||||
class BaseUnit : INamed, IConstruction, ICivilopedia {
|
||||
class BaseUnit : INamed, IConstruction {
|
||||
|
||||
override lateinit var name: String
|
||||
var cost: Int = 0
|
||||
@ -37,12 +36,6 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
||||
var uniqueTo:String?=null
|
||||
var attackSound:String?=null
|
||||
|
||||
override val description: String
|
||||
get(){
|
||||
return getDescription(false)
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun getShortDescription(): String {
|
||||
val infoList= mutableListOf<String>()
|
||||
|
@ -1,44 +1,48 @@
|
||||
package com.unciv.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.List
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.models.gamebasics.BasicHelp
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ICivilopedia
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.Tutorials
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.utils.toLabel
|
||||
import com.unciv.ui.utils.*
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
|
||||
class CivilopediaScreen : CameraStageBaseScreen() {
|
||||
class CivilopediaEntry {
|
||||
var name: String
|
||||
var description: String
|
||||
var image: Actor?=null
|
||||
|
||||
val categoryToInfos = LinkedHashMap<String, Collection<ICivilopedia>>()
|
||||
constructor(name: String, description: String, image: Actor?=null) {
|
||||
this.name = name
|
||||
this.description = description
|
||||
this.image = image
|
||||
}
|
||||
|
||||
constructor() : this("","") // Needed for GameBAsics json deserializing
|
||||
}
|
||||
|
||||
val categoryToEntries = LinkedHashMap<String, Collection<CivilopediaEntry>>()
|
||||
val categoryToButtons = LinkedHashMap<String, Button>()
|
||||
val civPediaEntries = Array<ICivilopedia>()
|
||||
|
||||
val nameList = List<String>(skin)
|
||||
val entrySelectTable = Table().apply { defaults().pad(5f) }
|
||||
val description = "".toLabel()
|
||||
|
||||
fun select(category: String, entry: String? = null) {
|
||||
val nameItems=Array<String>()
|
||||
civPediaEntries.clear()
|
||||
for (civilopediaEntry in categoryToInfos[category]!!.sortedBy { it.toString().tr() }){ // Alphabetical order of localized names
|
||||
civPediaEntries.add(civilopediaEntry)
|
||||
nameItems.add(civilopediaEntry.toString().tr())
|
||||
fun select(category: String) {
|
||||
entrySelectTable.clear()
|
||||
for (entry in categoryToEntries[category]!!
|
||||
.sortedBy { it.name.tr() }){ // Alphabetical order of localized names
|
||||
val entryButton = Button(skin)
|
||||
if(entry.image!=null)
|
||||
entryButton.add(entry.image).size(50f).padRight(10f)
|
||||
entryButton.add(entry.name.toLabel())
|
||||
entryButton.onClick {
|
||||
description.setText(entry.description)
|
||||
}
|
||||
entrySelectTable.add(entryButton).row()
|
||||
}
|
||||
nameList.setItems(nameItems)
|
||||
val index = max(0, nameList.items.indexOf(entry?.tr()))
|
||||
nameList.selected = nameList.items.get(index)
|
||||
description.setText(civPediaEntries.get(index).description)
|
||||
for (btn in categoryToButtons.values) btn.isChecked = false
|
||||
categoryToButtons[category]?.isChecked = true
|
||||
}
|
||||
|
||||
init {
|
||||
@ -67,39 +71,41 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
||||
val basicHelpFileName = if(Gdx.files.internal("jsons/BasicHelp/BasicHelp_$language.json").exists())"BasicHelp/BasicHelp_$language"
|
||||
else "BasicHelp/BasicHelp"
|
||||
|
||||
categoryToInfos["Basics"] = GameBasics.getFromJson(kotlin.Array<BasicHelp>::class.java, basicHelpFileName).toList()
|
||||
categoryToInfos["Buildings"] = GameBasics.Buildings.values
|
||||
categoryToInfos["Resources"] = GameBasics.TileResources.values
|
||||
categoryToInfos["Terrains"] = GameBasics.Terrains.values
|
||||
categoryToInfos["Tile Improvements"] = GameBasics.TileImprovements.values
|
||||
categoryToInfos["Units"] = GameBasics.Units.values
|
||||
categoryToInfos["Technologies"] = GameBasics.Technologies.values
|
||||
|
||||
class Tutorial(var name:String, override var description:String):ICivilopedia{
|
||||
override fun toString() = name
|
||||
}
|
||||
categoryToInfos["Tutorials"] = Tutorials().getTutorialsOfLanguage("English").keys
|
||||
categoryToEntries["Basics"] = GameBasics.getFromJson(kotlin.Array<CivilopediaEntry>::class.java, basicHelpFileName).toList()
|
||||
categoryToEntries["Buildings"] = GameBasics.Buildings.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(false, null),
|
||||
ImageGetter.getConstructionImage(it.name)) }
|
||||
categoryToEntries["Resources"] = GameBasics.TileResources.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(),
|
||||
ImageGetter.getResourceImage(it.name,50f)) }
|
||||
categoryToEntries["Terrains"] = GameBasics.Terrains.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription()) }
|
||||
categoryToEntries["Tile Improvements"] = GameBasics.TileImprovements.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(),
|
||||
ImageGetter.getImprovementIcon(it.name,50f)) }
|
||||
categoryToEntries["Units"] = GameBasics.Units.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(false),
|
||||
ImageGetter.getConstructionImage(it.name)) }
|
||||
categoryToEntries["Technologies"] = GameBasics.Technologies.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(),
|
||||
ImageGetter.getTechIconGroup(it.name,50f)) }
|
||||
|
||||
categoryToEntries["Tutorials"] = Tutorials().getTutorialsOfLanguage("English").keys
|
||||
.filter { !it.startsWith("_") }
|
||||
.map { Tutorial(it.replace("_"," "),
|
||||
Tutorials().getTutorials(it, UnCivGame.Current.settings.language).joinToString("\n\n")) }
|
||||
.map { CivilopediaEntry(it.replace("_"," "),
|
||||
Tutorials().getTutorials(it, UnCivGame.Current.settings.language)
|
||||
.joinToString("\n\n")) }
|
||||
|
||||
nameList.onClick {
|
||||
if(nameList.selected!=null) description.setText(civPediaEntries.get(nameList.selectedIndex).description)
|
||||
}
|
||||
nameList.style = List.ListStyle(nameList.style)
|
||||
nameList.style.fontColorSelected = Color.BLACK
|
||||
|
||||
for (category in categoryToInfos.keys) {
|
||||
for (category in categoryToEntries.keys) {
|
||||
val button = TextButton(category.tr(), skin)
|
||||
button.style = TextButton.TextButtonStyle(button.style)
|
||||
button.style.checkedFontColor = Color.YELLOW
|
||||
categoryToButtons[category] = button
|
||||
button.onClick { select(category) }
|
||||
buttonTable.add(button)
|
||||
}
|
||||
select("Basics")
|
||||
|
||||
val sp = ScrollPane(nameList)
|
||||
val sp = ScrollPane(entrySelectTable)
|
||||
sp.setupOverscroll(5f, 1f, 200f)
|
||||
entryTable.add(sp).width(Value.percentWidth(0.25f, entryTable)).height(Value.percentHeight(0.7f, entryTable))
|
||||
.pad(Value.percentWidth(0.02f, entryTable))
|
||||
|
@ -199,7 +199,9 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
description = construction.getDescription(true)
|
||||
else if (construction is Building)
|
||||
description = construction.getDescription(true, city.civInfo)
|
||||
else description = construction.description.tr()
|
||||
else if(construction is SpecialConstruction)
|
||||
description = construction.description.tr()
|
||||
else description="" // Should never happen
|
||||
|
||||
val descriptionLabel = description.toLabel()
|
||||
descriptionLabel.setWrap(true)
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.unciv.ui.pickerscreens
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
@ -10,7 +9,10 @@ import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.TileImprovement
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.*
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.addSeparatorVertical
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.utils.toLabel
|
||||
|
||||
class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerScreen() {
|
||||
private var selectedImprovement: TileImprovement? = null
|
||||
@ -44,10 +46,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
||||
|
||||
val group = Table()
|
||||
|
||||
val image = if(improvement.name.startsWith("Remove"))
|
||||
ImageGetter.getImage("OtherIcons/Stop")
|
||||
else
|
||||
ImageGetter.getImprovementIcon(improvement.name,30f)
|
||||
val image = ImageGetter.getImprovementIcon(improvement.name,30f)
|
||||
|
||||
group.add(image).size(30f).pad(10f)
|
||||
|
||||
@ -64,7 +63,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
||||
group.onClick {
|
||||
selectedImprovement = improvement
|
||||
pick(improvement.name.tr())
|
||||
descriptionLabel.setText(improvement.description)
|
||||
descriptionLabel.setText(improvement.getDescription())
|
||||
}
|
||||
|
||||
val pickNow = "Pick now!".toLabel()
|
||||
|
@ -48,13 +48,11 @@ class PromotionPickerScreen(val mapUnit: MapUnit) : PickerScreen() {
|
||||
val isPromotionAvailable = promotion in unitAvailablePromotions
|
||||
val unitHasPromotion = mapUnit.promotions.promotions.contains(promotion.name)
|
||||
|
||||
val group = Table()
|
||||
|
||||
group.add(ImageGetter.getPromotionIcon(promotion.name)).size(30f).pad(10f)
|
||||
group.add(promotion.name.toLabel()).pad(10f).padRight(20f)
|
||||
|
||||
group.touchable = Touchable.enabled
|
||||
group.onClick {
|
||||
val selectPromotionButton = Button(skin)
|
||||
selectPromotionButton.add(ImageGetter.getPromotionIcon(promotion.name)).size(30f).pad(10f)
|
||||
selectPromotionButton.add(promotion.name.toLabel()).pad(10f).padRight(20f)
|
||||
selectPromotionButton.touchable = Touchable.enabled
|
||||
selectPromotionButton.onClick {
|
||||
selectedPromotion = promotion
|
||||
rightSideButton.setText(promotion.name.tr())
|
||||
if(isPromotionAvailable && !unitHasPromotion) rightSideButton.enable()
|
||||
@ -73,26 +71,22 @@ class PromotionPickerScreen(val mapUnit: MapUnit) : PickerScreen() {
|
||||
descriptionLabel.setText(descriptionText)
|
||||
}
|
||||
|
||||
val pickNow = "Pick now!".toLabel()
|
||||
pickNow.setAlignment(Align.center)
|
||||
pickNow.onClick {
|
||||
acceptPromotion(promotion)
|
||||
}
|
||||
val promotionTable = Table()
|
||||
promotionTable.add(selectPromotionButton)
|
||||
|
||||
|
||||
val promotionButton = Button(skin)
|
||||
promotionButton.add(group).fillY()
|
||||
|
||||
if(isPromotionAvailable) {
|
||||
promotionButton.addSeparatorVertical()
|
||||
promotionButton.add(pickNow).padLeft(10f).fillY()
|
||||
val pickNow = "Pick now!".toLabel()
|
||||
pickNow.setAlignment(Align.center)
|
||||
pickNow.onClick {
|
||||
acceptPromotion(promotion)
|
||||
}
|
||||
promotionTable.add(pickNow).padLeft(10f).fillY()
|
||||
}
|
||||
else promotionButton.color= Color.GRAY
|
||||
|
||||
if(unitHasPromotion) promotionButton.color = Color.GREEN
|
||||
availablePromotionsGroup.addActor(promotionButton)
|
||||
|
||||
else if(unitHasPromotion) selectPromotionButton.color= Color.GREEN
|
||||
else selectPromotionButton.color= Color.GRAY
|
||||
|
||||
availablePromotionsGroup.addActor(promotionTable)
|
||||
}
|
||||
topTable.add(availablePromotionsGroup)
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, switchfromWorldSc
|
||||
private fun selectTechnology(tech: Technology?, center: Boolean = false, switchfromWorldScreen: Boolean = true) {
|
||||
|
||||
selectedTech = tech
|
||||
descriptionLabel.setText(tech?.description)
|
||||
descriptionLabel.setText(tech?.getDescription())
|
||||
|
||||
if (!switchfromWorldScreen)
|
||||
return
|
||||
|
@ -106,6 +106,8 @@ object ImageGetter {
|
||||
val productionCircleColor = Color.BROWN.cpy().lerp(Color.WHITE,0.5f)!!
|
||||
val goldCircleColor = Color.GOLD.cpy().lerp(Color.WHITE,0.5f)!!
|
||||
fun getImprovementIcon(improvementName:String, size:Float=20f):Actor{
|
||||
if(improvementName.startsWith("Remove"))
|
||||
return getImage("OtherIcons/Stop")
|
||||
if(improvementName.startsWith("StartingLocation ")){
|
||||
val nationName = improvementName.removePrefix("StartingLocation ")
|
||||
val nation = GameBasics.Nations[nationName]!!
|
||||
|
@ -167,7 +167,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
val centerTable = Table()
|
||||
centerTable.add(tech.quote.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
|
||||
centerTable.add(ImageGetter.getTechIconGroup(tech.name,100f)).pad(20f)
|
||||
centerTable.add(tech.description.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
|
||||
centerTable.add(tech.getDescription().toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
|
||||
add(centerTable).row()
|
||||
add(getCloseButton("Close"))
|
||||
}
|
||||
|
@ -6,13 +6,11 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.battle.CityCombatant
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.CivilopediaScreen
|
||||
import com.unciv.ui.utils.*
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
|
||||
@ -46,19 +44,6 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
deselectUnitButton.touchable = Touchable.enabled
|
||||
deselectUnitButton.onClick { selectedUnit=null; selectedCity=null; worldScreen.shouldUpdate=true;this@UnitTable.isVisible=false }
|
||||
addActor(deselectUnitButton)
|
||||
|
||||
helpUnitButton.add(Label("?",CameraStageBaseScreen.skin)).pad(10f)
|
||||
helpUnitButton.pack()
|
||||
helpUnitButton.touchable = Touchable.enabled
|
||||
helpUnitButton.onClick {
|
||||
val pedia = CivilopediaScreen()
|
||||
if (selectedUnit != null) {
|
||||
pedia.select("Units", selectedUnit?.name)
|
||||
}
|
||||
UnCivGame.Current.setScreen(pedia)
|
||||
}
|
||||
addActor(helpUnitButton)
|
||||
|
||||
}).left()
|
||||
|
||||
add(Table().apply {
|
||||
|
Loading…
Reference in New Issue
Block a user