More ruleSet-shouldnt-come-from-static fixes

This commit is contained in:
Yair Morgenstern 2019-12-05 20:39:57 +02:00
parent 51a0d7727a
commit b9487c1800
13 changed files with 66 additions and 60 deletions

View File

@ -4,11 +4,12 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.* import com.badlogic.gdx.scenes.scene2d.ui.*
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.models.gamebasics.RuleSet
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
import com.unciv.ui.utils.* import com.unciv.ui.utils.*
import java.util.* import java.util.*
class CivilopediaScreen : CameraStageBaseScreen() { class CivilopediaScreen(ruleSet: RuleSet) : CameraStageBaseScreen() {
class CivilopediaEntry { class CivilopediaEntry {
var name: String var name: String
var description: String var description: String
@ -70,24 +71,23 @@ class CivilopediaScreen : CameraStageBaseScreen() {
val basicHelpFileName = if(Gdx.files.internal("jsons/BasicHelp/BasicHelp_$language.json").exists())"BasicHelp/BasicHelp_$language" val basicHelpFileName = if(Gdx.files.internal("jsons/BasicHelp/BasicHelp_$language.json").exists())"BasicHelp/BasicHelp_$language"
else "BasicHelp/BasicHelp" else "BasicHelp/BasicHelp"
val gameBasics = game.ruleSet categoryToEntries["Basics"] = ruleSet.getFromJson(Array<CivilopediaEntry>::class.java, basicHelpFileName).toList()
categoryToEntries["Basics"] = gameBasics.getFromJson(Array<CivilopediaEntry>::class.java, basicHelpFileName).toList() categoryToEntries["Buildings"] = ruleSet.Buildings.values
categoryToEntries["Buildings"] = gameBasics.Buildings.values .map { CivilopediaEntry(it.name,it.getDescription(false, null,ruleSet),
.map { CivilopediaEntry(it.name,it.getDescription(false, null,gameBasics),
ImageGetter.getConstructionImage(it.name)) } ImageGetter.getConstructionImage(it.name)) }
categoryToEntries["Resources"] = gameBasics.TileResources.values categoryToEntries["Resources"] = ruleSet.TileResources.values
.map { CivilopediaEntry(it.name,it.getDescription(), .map { CivilopediaEntry(it.name,it.getDescription(),
ImageGetter.getResourceImage(it.name,50f)) } ImageGetter.getResourceImage(it.name,50f)) }
categoryToEntries["Terrains"] = gameBasics.Terrains.values categoryToEntries["Terrains"] = ruleSet.Terrains.values
.map { CivilopediaEntry(it.name,it.getDescription(gameBasics)) } .map { CivilopediaEntry(it.name,it.getDescription(ruleSet)) }
categoryToEntries["Tile Improvements"] = gameBasics.TileImprovements.values categoryToEntries["Tile Improvements"] = ruleSet.TileImprovements.values
.map { CivilopediaEntry(it.name,it.getDescription(gameBasics), .map { CivilopediaEntry(it.name,it.getDescription(ruleSet),
ImageGetter.getImprovementIcon(it.name,50f)) } ImageGetter.getImprovementIcon(it.name,50f)) }
categoryToEntries["Units"] = gameBasics.Units.values categoryToEntries["Units"] = ruleSet.Units.values
.map { CivilopediaEntry(it.name,it.getDescription(false), .map { CivilopediaEntry(it.name,it.getDescription(false),
ImageGetter.getConstructionImage(it.name)) } ImageGetter.getConstructionImage(it.name)) }
categoryToEntries["Technologies"] = gameBasics.Technologies.values categoryToEntries["Technologies"] = ruleSet.Technologies.values
.map { CivilopediaEntry(it.name,it.getDescription(gameBasics), .map { CivilopediaEntry(it.name,it.getDescription(ruleSet),
ImageGetter.getTechIconGroup(it.name,50f)) } ImageGetter.getTechIconGroup(it.name,50f)) }
categoryToEntries["Tutorials"] = Tutorials().getTutorialsOfLanguage("English").keys categoryToEntries["Tutorials"] = Tutorials().getTutorialsOfLanguage("English").keys

View File

@ -3,17 +3,18 @@ package com.unciv.ui
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.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Skin
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.models.gamebasics.RuleSet
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
import com.unciv.ui.pickerscreens.PickerScreen import com.unciv.ui.pickerscreens.PickerScreen
import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.ImageGetter
import com.unciv.ui.utils.enable import com.unciv.ui.utils.enable
import com.unciv.ui.utils.onClick import com.unciv.ui.utils.onClick
import com.unciv.ui.utils.toLabel
class LanguageTable(val language:String,skin: Skin):Table(skin){ class LanguageTable(val language:String, ruleSet: RuleSet):Table(){
private val blue = ImageGetter.getBlue() private val blue = ImageGetter.getBlue()
private val darkBlue = blue.cpy().lerp(Color.BLACK,0.5f)!! private val darkBlue = blue.cpy().lerp(Color.BLACK,0.5f)!!
val percentComplete: Int val percentComplete: Int
@ -23,14 +24,14 @@ class LanguageTable(val language:String,skin: Skin):Table(skin){
defaults().pad(10f) defaults().pad(10f)
if(ImageGetter.imageExists("FlagIcons/$language")) if(ImageGetter.imageExists("FlagIcons/$language"))
add(ImageGetter.getImage("FlagIcons/$language")).size(40f) add(ImageGetter.getImage("FlagIcons/$language")).size(40f)
val translations = UncivGame.Current.ruleSet.Translations val translations = ruleSet.Translations
val availableTranslations = translations.filter { it.value.containsKey(language) } val availableTranslations = translations.filter { it.value.containsKey(language) }
if(language=="English") percentComplete = 100 if(language=="English") percentComplete = 100
else percentComplete = (availableTranslations.size*100 / translations.size) - 5 else percentComplete = (availableTranslations.size*100 / translations.size) - 5
val spaceSplitLang = language.replace("_"," ") val spaceSplitLang = language.replace("_"," ")
add("$spaceSplitLang ($percentComplete%)") add("$spaceSplitLang ($percentComplete%)".toLabel())
update("") update("")
touchable = Touchable.enabled // so click listener is activated when any part is clicked, not only children touchable = Touchable.enabled // so click listener is activated when any part is clicked, not only children
pack() pack()
@ -60,7 +61,8 @@ class LanguagePickerScreen: PickerScreen(){
"If you want to help translating the game into your language, \n"+ "If you want to help translating the game into your language, \n"+
" instructions are in the Github readme! (Menu > Community > Github)",skin)).pad(10f).row() " instructions are in the Github readme! (Menu > Community > Github)",skin)).pad(10f).row()
languageTables.addAll(UncivGame.Current.ruleSet.Translations.getLanguages().map { LanguageTable(it,skin) } val ruleSet = UncivGame.Current.ruleSet
languageTables.addAll(ruleSet.Translations.getLanguages().map { LanguageTable(it,ruleSet) }
.sortedByDescending { it.percentComplete } ) .sortedByDescending { it.percentComplete } )
languageTables.forEach { languageTables.forEach {

View File

@ -3,6 +3,7 @@ package com.unciv.ui.mapeditor
import com.badlogic.gdx.scenes.scene2d.actions.Actions import com.badlogic.gdx.scenes.scene2d.actions.Actions
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.UncivGame
import com.unciv.logic.MapSaver import com.unciv.logic.MapSaver
import com.unciv.logic.map.TileMap import com.unciv.logic.map.TileMap
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
@ -17,8 +18,9 @@ class MapEditorScreen(): CameraStageBaseScreen(){
var tileMap = TileMap() var tileMap = TileMap()
var mapName = "My first map" var mapName = "My first map"
lateinit var mapHolder: TileGroupMap<TileGroup> lateinit var mapHolder: TileGroupMap<TileGroup>
private val tileEditorOptions = TileEditorOptionsTable(this)
private val showHideEditorOptionsButton = TextButton(">",skin) private val showHideEditorOptionsButton = TextButton(">",skin)
val ruleSet = UncivGame.Current.ruleSet
private val tileEditorOptions = TileEditorOptionsTable(this)
constructor(mapNameToLoad:String?):this(){ constructor(mapNameToLoad:String?):this(){
var mapToLoad = mapNameToLoad var mapToLoad = mapNameToLoad
@ -40,7 +42,7 @@ class MapEditorScreen(): CameraStageBaseScreen(){
} }
fun initialize() { fun initialize() {
tileMap.setTransients(game.ruleSet) tileMap.setTransients(ruleSet)
val mapHolder = getMapHolder(tileMap) val mapHolder = getMapHolder(tileMap)
stage.addActor(mapHolder) stage.addActor(mapHolder)

View File

@ -39,7 +39,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
private var currentHex: Actor = Group() private var currentHex: Actor = Group()
val gameBasics = UncivGame.Current.ruleSet val ruleSet = mapEditorScreen.ruleSet
init{ init{
height=mapEditorScreen.stage.height height=mapEditorScreen.stage.height
@ -74,7 +74,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
} }
}).row() }).row()
for(improvement in gameBasics.TileImprovements.values){ for(improvement in ruleSet.TileImprovements.values){
if(improvement.name.startsWith("Remove")) continue if(improvement.name.startsWith("Remove")) continue
val improvementImage = getHex(Color.WHITE,ImageGetter.getImprovementIcon(improvement.name,40f)) val improvementImage = getHex(Color.WHITE,ImageGetter.getImprovementIcon(improvement.name,40f))
improvementImage.onClick { improvementImage.onClick {
@ -88,7 +88,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
editorPickTable.add(ScrollPane(improvementsTable)).height(mapEditorScreen.stage.height*0.7f) editorPickTable.add(ScrollPane(improvementsTable)).height(mapEditorScreen.stage.height*0.7f)
val nationsTable = Table() val nationsTable = Table()
for(nation in gameBasics.Nations.values){ for(nation in ruleSet.Nations.values){
val nationImage = getHex(Color.WHITE,ImageGetter.getNationIndicator(nation,40f)) val nationImage = getHex(Color.WHITE,ImageGetter.getNationIndicator(nation,40f))
nationImage.onClick { nationImage.onClick {
clearSelection() clearSelection()
@ -151,16 +151,16 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
} }
}) })
for (resource in gameBasics.TileResources.values) { for (resource in ruleSet.TileResources.values) {
val resourceHex = getHex(Color.WHITE, ImageGetter.getResourceImage(resource.name, 40f)) val resourceHex = getHex(Color.WHITE, ImageGetter.getResourceImage(resource.name, 40f))
resourceHex.onClick { resourceHex.onClick {
clearSelection() clearSelection()
selectedResource = resource selectedResource = resource
val tileInfo = TileInfo() val tileInfo = TileInfo()
tileInfo.ruleSet = UncivGame.Current.ruleSet tileInfo.ruleSet = mapEditorScreen.ruleSet
val terrain = resource.terrainsCanBeFoundOn.first() val terrain = resource.terrainsCanBeFoundOn.first()
val terrainObject = gameBasics.Terrains[terrain]!! val terrainObject = ruleSet.Terrains[terrain]!!
if (terrainObject.type == TerrainType.TerrainFeature) { if (terrainObject.type == TerrainType.TerrainFeature) {
tileInfo.baseTerrain = when { tileInfo.baseTerrain = when {
terrainObject.occursOn == null -> terrainObject.occursOn!!.first() terrainObject.occursOn == null -> terrainObject.occursOn!!.first()
@ -179,9 +179,9 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
} }
private fun addTerrainOptions(terrainFeaturesTable: Table, baseTerrainTable: Table) { private fun addTerrainOptions(terrainFeaturesTable: Table, baseTerrainTable: Table) {
for (terrain in gameBasics.Terrains.values) { for (terrain in ruleSet.Terrains.values) {
val tileInfo = TileInfo() val tileInfo = TileInfo()
tileInfo.ruleSet = UncivGame.Current.ruleSet tileInfo.ruleSet = mapEditorScreen.ruleSet
if (terrain.type == TerrainType.TerrainFeature) { if (terrain.type == TerrainType.TerrainFeature) {
tileInfo.baseTerrain = when { tileInfo.baseTerrain = when {
terrain.occursOn != null -> terrain.occursOn.first() terrain.occursOn != null -> terrain.occursOn.first()

View File

@ -23,12 +23,13 @@ import kotlin.concurrent.thread
class NewGameScreen: PickerScreen(){ class NewGameScreen: PickerScreen(){
val newGameParameters= UncivGame.Current.gameInfo.gameParameters val newGameParameters= UncivGame.Current.gameInfo.gameParameters
val ruleSet = UncivGame.Current.ruleSet
init { init {
setDefaultCloseAction() setDefaultCloseAction()
val playerPickerTable = PlayerPickerTable(this, newGameParameters) val playerPickerTable = PlayerPickerTable(this, newGameParameters)
topTable.add(NewGameScreenOptionsTable(newGameParameters) { playerPickerTable.update() }) topTable.add(NewGameScreenOptionsTable(newGameParameters,ruleSet) { playerPickerTable.update() })
topTable.add(playerPickerTable).pad(10f) topTable.add(playerPickerTable).pad(10f)
topTable.pack() topTable.pack()
topTable.setFillParent(true) topTable.setFillParent(true)

View File

@ -6,9 +6,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
import com.badlogic.gdx.utils.Array import com.badlogic.gdx.utils.Array
import com.unciv.UncivGame
import com.unciv.logic.MapSaver import com.unciv.logic.MapSaver
import com.unciv.logic.map.MapType import com.unciv.logic.map.MapType
import com.unciv.models.gamebasics.RuleSet
import com.unciv.models.gamebasics.VictoryType import com.unciv.models.gamebasics.VictoryType
import com.unciv.models.gamebasics.tech.TechEra import com.unciv.models.gamebasics.tech.TechEra
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
@ -17,7 +17,7 @@ import com.unciv.models.metadata.GameSpeed
import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.CameraStageBaseScreen
import com.unciv.ui.utils.toLabel import com.unciv.ui.utils.toLabel
class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMultiplayerToggled:()->Unit) class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val ruleSet: RuleSet, val onMultiplayerToggled:()->Unit)
: Table(CameraStageBaseScreen.skin){ : Table(CameraStageBaseScreen.skin){
init{ init{
addMapTypeSizeAndFile() addMapTypeSizeAndFile()
@ -128,7 +128,7 @@ class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMul
val cityStatesSelectBox = SelectBox<Int>(CameraStageBaseScreen.skin) val cityStatesSelectBox = SelectBox<Int>(CameraStageBaseScreen.skin)
val cityStatesArray = Array<Int>() val cityStatesArray = Array<Int>()
(0..UncivGame.Current.ruleSet.Nations.filter { it.value.isCityState() }.size).forEach { cityStatesArray.add(it) } (0..ruleSet.Nations.filter { it.value.isCityState() }.size).forEach { cityStatesArray.add(it) }
cityStatesSelectBox.items = cityStatesArray cityStatesSelectBox.items = cityStatesArray
cityStatesSelectBox.selected = newGameParameters.numberOfCityStates cityStatesSelectBox.selected = newGameParameters.numberOfCityStates
add(cityStatesSelectBox).pad(10f).row() add(cityStatesSelectBox).pad(10f).row()
@ -141,7 +141,7 @@ class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMul
private fun addDifficultySelectBox() { private fun addDifficultySelectBox() {
add("{Difficulty}:".tr()) add("{Difficulty}:".tr())
val difficultySelectBox = TranslatedSelectBox(UncivGame.Current.ruleSet.Difficulties.keys, newGameParameters.difficulty, CameraStageBaseScreen.skin) val difficultySelectBox = TranslatedSelectBox(ruleSet.Difficulties.keys, newGameParameters.difficulty, CameraStageBaseScreen.skin)
difficultySelectBox.addListener(object : ChangeListener() { difficultySelectBox.addListener(object : ChangeListener() {
override fun changed(event: ChangeEvent?, actor: Actor?) { override fun changed(event: ChangeEvent?, actor: Actor?) {
newGameParameters.difficulty = difficultySelectBox.selected.value newGameParameters.difficulty = difficultySelectBox.selected.value

View File

@ -30,7 +30,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
fun update() { fun update() {
playerListTable.clear() playerListTable.clear()
val gameBasics = UncivGame.Current.ruleSet // when we add mods, this will need to change val gameBasics = newGameScreen.ruleSet // when we add mods, this will need to change
for (player in newGameParameters.players) for (player in newGameParameters.players)
playerListTable.add(getPlayerTable(player,gameBasics)).pad(10f).row() playerListTable.add(getPlayerTable(player,gameBasics)).pad(10f).row()
if(newGameParameters.players.count() < gameBasics.Nations.values.count { it.isMajorCiv() }) { if(newGameParameters.players.count() < gameBasics.Nations.values.count { it.isMajorCiv() }) {
@ -44,7 +44,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
playerTable.pad(20f) playerTable.pad(20f)
playerTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.8f)) playerTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.8f))
val nationTable = getNationTable(player,ruleSet) val nationTable = getNationTable(player)
playerTable.add(nationTable) playerTable.add(nationTable)
val playerTypeTextbutton = TextButton(player.playerType.name, CameraStageBaseScreen.skin) val playerTypeTextbutton = TextButton(player.playerType.name, CameraStageBaseScreen.skin)
@ -102,22 +102,22 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
return playerTable return playerTable
} }
private fun getNationTable(player: Player, ruleSet: RuleSet): Table { private fun getNationTable(player: Player): Table {
val nationTable = Table() val nationTable = Table()
val nationImage = if (player.chosenCiv == "Random") "?".toLabel(Color.BLACK,30) val nationImage = if (player.chosenCiv == "Random") "?".toLabel(Color.BLACK,30)
.apply { this.setAlignment(Align.center) } .apply { this.setAlignment(Align.center) }
.surroundWithCircle(50f) .surroundWithCircle(50f)
else ImageGetter.getNationIndicator(ruleSet.Nations[player.chosenCiv]!!, 50f) else ImageGetter.getNationIndicator(newGameScreen.ruleSet.Nations[player.chosenCiv]!!, 50f)
nationTable.add(nationImage) nationTable.add(nationImage)
nationTable.add(player.chosenCiv.toLabel()).pad(20f) nationTable.add(player.chosenCiv.toLabel()).pad(20f)
nationTable.touchable = Touchable.enabled nationTable.touchable = Touchable.enabled
nationTable.onClick { nationTable.onClick {
popupNationPicker(player,ruleSet) popupNationPicker(player)
} }
return nationTable return nationTable
} }
private fun popupNationPicker(player: Player, ruleSet: RuleSet) { private fun popupNationPicker(player: Player) {
val nationsPopup = PopupTable(newGameScreen) val nationsPopup = PopupTable(newGameScreen)
val nationListTable = Table() val nationListTable = Table()
@ -137,11 +137,11 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
nationListTable.add(randomPlayerTable).pad(10f).width(halfWidth).row() nationListTable.add(randomPlayerTable).pad(10f).width(halfWidth).row()
for (nation in ruleSet.Nations.values.filter { !it.isCityState() && it.name != "Barbarians" }) { for (nation in newGameScreen.ruleSet.Nations.values.filter { !it.isCityState() && it.name != "Barbarians" }) {
if (player.chosenCiv != nation.name && newGameParameters.players.any { it.chosenCiv == nation.name }) if (player.chosenCiv != nation.name && newGameParameters.players.any { it.chosenCiv == nation.name })
continue continue
nationListTable.add(NationTable(nation, halfWidth,ruleSet).onClick { nationListTable.add(NationTable(nation, halfWidth,newGameScreen.ruleSet).onClick {
player.chosenCiv = nation.name player.chosenCiv = nation.name
nationsPopup.close() nationsPopup.close()
update() update()

View File

@ -2,6 +2,7 @@ package com.unciv.ui.pickerscreens
import com.badlogic.gdx.scenes.scene2d.ui.Button import com.badlogic.gdx.scenes.scene2d.ui.Button
import com.unciv.UncivGame import com.unciv.UncivGame
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.GreatPersonManager import com.unciv.logic.civilization.GreatPersonManager
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
import com.unciv.models.gamebasics.unit.BaseUnit import com.unciv.models.gamebasics.unit.BaseUnit
@ -9,13 +10,13 @@ import com.unciv.ui.utils.ImageGetter
import com.unciv.ui.utils.onClick import com.unciv.ui.utils.onClick
import com.unciv.ui.utils.toLabel import com.unciv.ui.utils.toLabel
class GreatPersonPickerScreen : PickerScreen() { class GreatPersonPickerScreen(val civInfo:CivilizationInfo) : PickerScreen() {
private var theChosenOne: BaseUnit? = null private var theChosenOne: BaseUnit? = null
init { init {
closeButton.isVisible=false closeButton.isVisible=false
rightSideButton.setText("Choose a free great person".tr()) rightSideButton.setText("Choose a free great person".tr())
for (unit in game.ruleSet.Units.values for (unit in civInfo.gameInfo.ruleSet.Units.values
.filter { it.name in GreatPersonManager().statToGreatPersonMapping.values || it.name == "Great General"}) .filter { it.name in GreatPersonManager().statToGreatPersonMapping.values || it.name == "Great General"})
{ {
val button = Button(skin) val button = Button(skin)
@ -34,9 +35,8 @@ class GreatPersonPickerScreen : PickerScreen() {
} }
rightSideButton.onClick("choir") { rightSideButton.onClick("choir") {
val currentPlayerCiv = UncivGame.Current.gameInfo.getCurrentPlayerCivilization() civInfo.placeUnitNearTile(civInfo.cities[0].location, theChosenOne!!.name)
currentPlayerCiv.placeUnitNearTile(currentPlayerCiv.cities[0].location, theChosenOne!!.name) civInfo.greatPeople.freeGreatPeople--
currentPlayerCiv.greatPeople.freeGreatPeople--
UncivGame.Current.setWorldScreen() UncivGame.Current.setWorldScreen()
} }

View File

@ -38,7 +38,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
val regularImprovements = VerticalGroup() val regularImprovements = VerticalGroup()
regularImprovements.space(10f) regularImprovements.space(10f)
for (improvement in game.ruleSet.TileImprovements.values) { for (improvement in tileInfo.tileMap.gameInfo.ruleSet.TileImprovements.values) {
if (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue if (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue
if(improvement.name == tileInfo.improvement) continue if(improvement.name == tileInfo.improvement) continue
if(improvement.name==tileInfo.improvementInProgress) continue if(improvement.name==tileInfo.improvementInProgress) continue
@ -62,7 +62,8 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
group.onClick { group.onClick {
selectedImprovement = improvement selectedImprovement = improvement
pick(improvement.name.tr()) pick(improvement.name.tr())
descriptionLabel.setText(improvement.getDescription(game.ruleSet)) val ruleSet = tileInfo.tileMap.gameInfo.ruleSet
descriptionLabel.setText(improvement.getDescription(ruleSet))
} }
val pickNow = "Pick now!".toLabel() val pickNow = "Pick now!".toLabel()

View File

@ -33,7 +33,7 @@ object ImageGetter {
setTextureRegionDrawables() setTextureRegionDrawables()
} }
fun getGameBasics() = UncivGame.Current.ruleSet fun getRuleSet() = UncivGame.Current.ruleSet
fun setTextureRegionDrawables(){ fun setTextureRegionDrawables(){
textureRegionDrawables.clear() textureRegionDrawables.clear()
@ -112,13 +112,13 @@ object ImageGetter {
return getImage("OtherIcons/Stop") return getImage("OtherIcons/Stop")
if(improvementName.startsWith("StartingLocation ")){ if(improvementName.startsWith("StartingLocation ")){
val nationName = improvementName.removePrefix("StartingLocation ") val nationName = improvementName.removePrefix("StartingLocation ")
val nation = getGameBasics().Nations[nationName]!! val nation = getRuleSet().Nations[nationName]!!
return getNationIndicator(nation,size) return getNationIndicator(nation,size)
} }
val iconGroup = getImage("ImprovementIcons/$improvementName").surroundWithCircle(size) val iconGroup = getImage("ImprovementIcons/$improvementName").surroundWithCircle(size)
val improvement = getGameBasics().TileImprovements[improvementName]!! val improvement = getRuleSet().TileImprovements[improvementName]!!
when { when {
improvement.food>0 -> iconGroup.circle.color= foodCircleColor improvement.food>0 -> iconGroup.circle.color= foodCircleColor
improvement.production>0 -> iconGroup.circle.color= productionCircleColor improvement.production>0 -> iconGroup.circle.color= productionCircleColor
@ -131,8 +131,8 @@ object ImageGetter {
} }
fun getConstructionImage(construction: String): Image { fun getConstructionImage(construction: String): Image {
if(getGameBasics().Buildings.containsKey(construction)) return getImage("BuildingIcons/$construction") if(getRuleSet().Buildings.containsKey(construction)) return getImage("BuildingIcons/$construction")
if(getGameBasics().Units.containsKey(construction)) return getUnitIcon(construction) if(getRuleSet().Units.containsKey(construction)) return getUnitIcon(construction)
if(construction=="Nothing") return getImage("OtherIcons/Stop") if(construction=="Nothing") return getImage("OtherIcons/Stop")
return getStatIcon(construction) return getStatIcon(construction)
} }
@ -180,7 +180,7 @@ object ImageGetter {
fun getResourceImage(resourceName: String, size:Float): Actor { fun getResourceImage(resourceName: String, size:Float): Actor {
val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size) val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size)
val resource = getGameBasics().TileResources[resourceName]!! val resource = getRuleSet().TileResources[resourceName]!!
when { when {
resource.food>0 -> iconGroup.circle.color= foodCircleColor resource.food>0 -> iconGroup.circle.color= foodCircleColor
resource.production>0 -> iconGroup.circle.color= productionCircleColor resource.production>0 -> iconGroup.circle.color= productionCircleColor
@ -204,7 +204,7 @@ object ImageGetter {
fun getTechIconGroup(techName: String, circleSize: Float): Group { fun getTechIconGroup(techName: String, circleSize: Float): Group {
var techIconColor = Color.WHITE var techIconColor = Color.WHITE
when (getGameBasics().Technologies[techName]!!.era().name) { when (getRuleSet().Technologies[techName]!!.era().name) {
"Ancient" -> techIconColor = colorFromRGB(255, 87, 35) "Ancient" -> techIconColor = colorFromRGB(255, 87, 35)
"Classical" -> techIconColor = colorFromRGB(233, 31, 99) "Classical" -> techIconColor = colorFromRGB(233, 31, 99)
"Medieval" -> techIconColor = colorFromRGB(157, 39, 176) "Medieval" -> techIconColor = colorFromRGB(157, 39, 176)

View File

@ -188,7 +188,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
when { when {
!gameInfo.oneMoreTurnMode && gameInfo.civilizations.any { it.victoryManager.hasWon() } -> game.setScreen(VictoryScreen()) !gameInfo.oneMoreTurnMode && gameInfo.civilizations.any { it.victoryManager.hasWon() } -> game.setScreen(VictoryScreen())
viewingCiv.policies.freePolicies > 0 && viewingCiv.policies.canAdoptPolicy() -> game.setScreen(PolicyPickerScreen(this)) viewingCiv.policies.freePolicies > 0 && viewingCiv.policies.canAdoptPolicy() -> game.setScreen(PolicyPickerScreen(this))
viewingCiv.greatPeople.freeGreatPeople > 0 -> game.setScreen(GreatPersonPickerScreen()) viewingCiv.greatPeople.freeGreatPeople > 0 -> game.setScreen(GreatPersonPickerScreen(viewingCiv))
viewingCiv.popupAlerts.any() -> AlertPopup(this, viewingCiv.popupAlerts.first()) viewingCiv.popupAlerts.any() -> AlertPopup(this, viewingCiv.popupAlerts.first())
viewingCiv.tradeRequests.isNotEmpty() -> TradePopup(this) viewingCiv.tradeRequests.isNotEmpty() -> TradePopup(this)
} }

View File

@ -40,7 +40,7 @@ class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScree
addSeparator() addSeparator()
addSquareButton("Civilopedia".tr()){ addSquareButton("Civilopedia".tr()){
UncivGame.Current.setScreen(CivilopediaScreen()) UncivGame.Current.setScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet))
remove() remove()
}.size(width,height) }.size(width,height)
addSeparator() addSeparator()

View File

@ -16,9 +16,9 @@ import kotlin.concurrent.thread
class Language(val language:String, ruleSet: RuleSet){ class Language(val language:String, ruleSet: RuleSet){
val percentComplete:Int val percentComplete:Int
init{ init{
val availableTranslations = UncivGame.Current.ruleSet.Translations.count { it.value.containsKey(language) } val availableTranslations = ruleSet.Translations.count { it.value.containsKey(language) }
if(language=="English") percentComplete = 100 if(language=="English") percentComplete = 100
else percentComplete = (availableTranslations*100 / UncivGame.Current.ruleSet.Translations.size) else percentComplete = (availableTranslations*100 / ruleSet.Translations.size)
} }
override fun toString(): String { override fun toString(): String {
val spaceSplitLang = language.replace("_"," ") val spaceSplitLang = language.replace("_"," ")
@ -288,7 +288,7 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
val missingTextSelectBox = SelectBox<String>(skin) val missingTextSelectBox = SelectBox<String>(skin)
val missingTextArray = Array<String>() val missingTextArray = Array<String>()
val currentLanguage = UncivGame.Current.settings.language val currentLanguage = UncivGame.Current.settings.language
UncivGame.Current.ruleSet.Translations.filter { !it.value.containsKey(currentLanguage) } ruleSet.Translations.filter { !it.value.containsKey(currentLanguage) }
.forEach { missingTextArray.add(it.key) } .forEach { missingTextArray.add(it.key) }
missingTextSelectBox.items = missingTextArray missingTextSelectBox.items = missingTextArray
missingTextSelectBox.selected = "Untranslated texts" missingTextSelectBox.selected = "Untranslated texts"