Commented out snow - we don't want it appearing in patches until we have better map generation

This commit is contained in:
Yair Morgenstern 2019-03-08 10:15:10 +02:00
parent 7b6d37053b
commit adea36fb81
6 changed files with 212 additions and 210 deletions

View file

@ -67,6 +67,7 @@
impassable:true,
RGB: [89, 45, 0]
},
/*
{
name:"Snow",
type:"Land",
@ -74,6 +75,7 @@
defenceBonus: -0.1,
RGB: [153, 255, 255]
},
*/
// Terrain features
{

View file

@ -17,7 +17,7 @@ import kotlin.math.min
class CityInfo {
@Transient lateinit var civInfo: CivilizationInfo
@Transient var isConnectedToCapital = false
@Transient lateinit var ccenterTile:TileInfo // 'cached' for better performance
@Transient lateinit var ccenterTile:TileInfo // cached for better performance
@Transient val range = 2
var location: Vector2 = Vector2.Zero
@ -48,8 +48,8 @@ class CityInfo {
val cityNameRounds = civInfo.citiesCreated / nationCities.size
val cityNamePrefix = if(cityNameRounds==0) ""
else if(cityNameRounds==2) "New "
else "Newer "
else if(cityNameRounds==1) "New "
else "Neo "
name = cityNamePrefix + cityName

View file

@ -15,7 +15,7 @@ import com.unciv.models.gamebasics.tr
import com.unciv.models.stats.Stats
import com.unciv.ui.EmpireOverviewScreen
import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.optionstable.WorldScreenOptionsTable
import com.unciv.ui.worldscreen.optionstable.WorldScreenMenuTable
import kotlin.math.abs
import kotlin.math.ceil
@ -95,8 +95,8 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
.apply { setSize(50f, 50f) }
menuButton.color = Color.WHITE
menuButton.onClick {
if(screen.stage.actors.none { it is WorldScreenOptionsTable })
WorldScreenOptionsTable(screen)
if(screen.stage.actors.none { it is WorldScreenMenuTable })
WorldScreenMenuTable(screen)
}
menuButton.centerY(this)
menuButton.x = menuButton.y

View file

@ -1,156 +0,0 @@
package com.unciv.ui.worldscreen.optionstable
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
import com.badlogic.gdx.scenes.scene2d.ui.Slider
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
import com.badlogic.gdx.utils.Array
import com.unciv.UnCivGame
import com.unciv.models.gamebasics.GameBasics
import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.WorldScreen
import kotlin.concurrent.thread
class Language(val language:String){
val percentComplete:Int
init{
val availableTranslations = GameBasics.Translations.filter { it.value.containsKey(language) }
if(language=="English") percentComplete = 100
else percentComplete = (availableTranslations.size*100 / GameBasics.Translations.size)
}
override fun toString(): String {
val spaceSplitLang = language.replace("_"," ")
return "$spaceSplitLang- $percentComplete%"
}
}
class WorldScreenDisplayOptionsTable(screen:WorldScreen) : PopupTable(screen){
val languageSelectBox = SelectBox<Language>(skin)
init {
update()
open()
}
fun update() {
val settings = UnCivGame.Current.settings
settings.save()
clear()
if (settings.showWorkedTiles) addButton("{Hide} {worked tiles}") { settings.showWorkedTiles = false; update() }
else addButton("{Show} {worked tiles}") { settings.showWorkedTiles = true; update() }
if (settings.showResourcesAndImprovements)
addButton("{Hide} {resources and improvements}") { settings.showResourcesAndImprovements = false; update() }
else addButton("{Show} {resources and improvements}") { settings.showResourcesAndImprovements = true; update() }
addLanguageSelectBox()
val resolutionSelectBox= SelectBox<String>(skin)
val resolutionArray = com.badlogic.gdx.utils.Array<String>()
resolutionArray.addAll("900x600","1050x700","1200x800","1500x1000")
resolutionSelectBox.items = resolutionArray
resolutionSelectBox.selected = UnCivGame.Current.settings.resolution
add(resolutionSelectBox).pad(10f).row()
resolutionSelectBox.addListener(object : ChangeListener() {
override fun changed(event: ChangeEvent?, actor: Actor?) {
UnCivGame.Current.settings.resolution = resolutionSelectBox.selected
UnCivGame.Current.settings.save()
UnCivGame.Current.worldScreen = WorldScreen()
UnCivGame.Current.setWorldScreen()
WorldScreenDisplayOptionsTable(UnCivGame.Current.worldScreen)
}
})
val soundEffectsVolumeSlider = Slider(0f,1.0f,0.1f,false,skin)
soundEffectsVolumeSlider.value = UnCivGame.Current.settings.soundEffectsVolume
soundEffectsVolumeSlider.addListener(object: ChangeListener(){
override fun changed(event: ChangeEvent?, actor: Actor?) {
UnCivGame.Current.settings.soundEffectsVolume= soundEffectsVolumeSlider.value
UnCivGame.Current.settings.save()
Sounds.play("click")
}
})
add("Sound effects volume").row()
add(soundEffectsVolumeSlider).row()
addButton("Close"){ remove() }
pack() // Needed to show the background.
center(UnCivGame.Current.worldScreen.stage)
UnCivGame.Current.worldScreen.shouldUpdate=true
}
private fun addLanguageSelectBox() {
val languageArray = Array<Language>()
GameBasics.Translations.getLanguages().map { Language(it) }.sortedByDescending { it.percentComplete }
.forEach { languageArray.add(it) }
languageSelectBox.items = languageArray
languageSelectBox.selected = languageArray.first { it.language == UnCivGame.Current.settings.language }
add(languageSelectBox).pad(10f).row()
languageSelectBox.addListener(object : ChangeListener() {
override fun changed(event: ChangeEvent?, actor: Actor?) {
val selectedLanguage = languageSelectBox.selected.language
if (Fonts().containsFont(Fonts().getFontForLanguage(selectedLanguage)))
selectLanguage()
else {
val spaceSplitLang = selectedLanguage.replace("_", " ")
YesNoPopupTable("This language requires you to download fonts.\n" +
"Do you want to download fonts for $spaceSplitLang?",
{
val downloading = PopupTable(screen)
downloading.add("Downloading...".toLabel())
downloading.open()
Gdx.input.inputProcessor = null // no interaction until download is over
thread {
Fonts().downloadFontForLanguage(selectedLanguage)
// The language selection must be done on the render thread, because it requires a GL context.
// This means that we have to tell the table to create it on render.
shouldSelectLanguage = true
}
})
}
}
})
if (languageSelectBox.selected.percentComplete != 100) {
add("Missing translations:".toLabel()).pad(5f).row()
val missingTextSelectBox = SelectBox<String>(skin)
val missingTextArray = Array<String>()
val currentLanguage = UnCivGame.Current.settings.language
GameBasics.Translations.filter { !it.value.containsKey(currentLanguage) }.forEach { missingTextArray.add(it.key) }
missingTextSelectBox.items = missingTextArray
missingTextSelectBox.selected = "Untranslated texts"
add(missingTextSelectBox).pad(10f).width(UnCivGame.Current.worldScreen.stage.width / 2).row()
}
}
fun selectLanguage(){
UnCivGame.Current.settings.language = languageSelectBox.selected.language
UnCivGame.Current.settings.save()
CameraStageBaseScreen.resetFonts()
UnCivGame.Current.worldScreen = WorldScreen()
UnCivGame.Current.setWorldScreen()
WorldScreenDisplayOptionsTable(UnCivGame.Current.worldScreen)
}
var shouldSelectLanguage = false
override fun draw(batch: Batch?, parentAlpha: Float) {
if(shouldSelectLanguage){
shouldSelectLanguage=false
selectLanguage()
}
super.draw(batch, parentAlpha)
}
}

View file

@ -0,0 +1,56 @@
package com.unciv.ui.worldscreen.optionstable
import com.unciv.UnCivGame
import com.unciv.models.gamebasics.tr
import com.unciv.ui.CivilopediaScreen
import com.unciv.ui.NewGameScreen
import com.unciv.ui.VictoryScreen
import com.unciv.ui.mapeditor.MapEditorScreen
import com.unciv.ui.pickerscreens.PolicyPickerScreen
import com.unciv.ui.saves.LoadScreen
import com.unciv.ui.saves.SaveScreen
import com.unciv.ui.worldscreen.WorldScreen
class WorldScreenMenuTable(val worldScreen: WorldScreen) : PopupTable(worldScreen) {
init {
addButton("Map editor".tr()){
UnCivGame.Current.screen = MapEditorScreen(null)
remove()
}
addButton("Civilopedia".tr()){
UnCivGame.Current.screen = CivilopediaScreen()
remove()
}
addButton("Load game".tr()){
UnCivGame.Current.screen = LoadScreen()
remove()
}
addButton("Save game".tr()) {
UnCivGame.Current.screen = SaveScreen()
remove()
}
addButton("Start new game".tr()){ UnCivGame.Current.screen = NewGameScreen() }
addButton("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() }
addButton("Social policies".tr()){
UnCivGame.Current.screen = PolicyPickerScreen(UnCivGame.Current.gameInfo.getCurrentPlayerCivilization())
}
addButton("Options".tr()){
UnCivGame.Current.worldScreen.stage.addActor(WorldScreenOptionsTable(worldScreen))
remove()
}
addButton("Close".tr()){ remove() }
open()
}
}

View file

@ -1,56 +1,156 @@
package com.unciv.ui.worldscreen.optionstable
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
import com.badlogic.gdx.scenes.scene2d.ui.Slider
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
import com.badlogic.gdx.utils.Array
import com.unciv.UnCivGame
import com.unciv.models.gamebasics.tr
import com.unciv.ui.CivilopediaScreen
import com.unciv.ui.NewGameScreen
import com.unciv.ui.VictoryScreen
import com.unciv.ui.mapeditor.MapEditorScreen
import com.unciv.ui.pickerscreens.PolicyPickerScreen
import com.unciv.ui.saves.LoadScreen
import com.unciv.ui.saves.SaveScreen
import com.unciv.models.gamebasics.GameBasics
import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.WorldScreen
import kotlin.concurrent.thread
class WorldScreenOptionsTable(val worldScreen: WorldScreen) : PopupTable(worldScreen) {
init {
addButton("Map editor".tr()){
UnCivGame.Current.screen = MapEditorScreen(null)
remove()
}
addButton("Civilopedia".tr()){
UnCivGame.Current.screen = CivilopediaScreen()
remove()
}
addButton("Load game".tr()){
UnCivGame.Current.screen = LoadScreen()
remove()
}
addButton("Save game".tr()) {
UnCivGame.Current.screen = SaveScreen()
remove()
}
addButton("Start new game".tr()){ UnCivGame.Current.screen = NewGameScreen() }
addButton("Victory status".tr()) { UnCivGame.Current.screen = VictoryScreen() }
addButton("Social policies".tr()){
UnCivGame.Current.screen = PolicyPickerScreen(UnCivGame.Current.gameInfo.getCurrentPlayerCivilization())
}
addButton("Display options".tr()){
UnCivGame.Current.worldScreen.stage.addActor(WorldScreenDisplayOptionsTable(worldScreen))
remove()
}
addButton("Close".tr()){ remove() }
open()
class Language(val language:String){
val percentComplete:Int
init{
val availableTranslations = GameBasics.Translations.filter { it.value.containsKey(language) }
if(language=="English") percentComplete = 100
else percentComplete = (availableTranslations.size*100 / GameBasics.Translations.size)
}
override fun toString(): String {
val spaceSplitLang = language.replace("_"," ")
return "$spaceSplitLang- $percentComplete%"
}
}
class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
val languageSelectBox = SelectBox<Language>(skin)
init {
update()
open()
}
fun update() {
val settings = UnCivGame.Current.settings
settings.save()
clear()
if (settings.showWorkedTiles) addButton("{Hide} {worked tiles}") { settings.showWorkedTiles = false; update() }
else addButton("{Show} {worked tiles}") { settings.showWorkedTiles = true; update() }
if (settings.showResourcesAndImprovements)
addButton("{Hide} {resources and improvements}") { settings.showResourcesAndImprovements = false; update() }
else addButton("{Show} {resources and improvements}") { settings.showResourcesAndImprovements = true; update() }
addLanguageSelectBox()
val resolutionSelectBox= SelectBox<String>(skin)
val resolutionArray = com.badlogic.gdx.utils.Array<String>()
resolutionArray.addAll("900x600","1050x700","1200x800","1500x1000")
resolutionSelectBox.items = resolutionArray
resolutionSelectBox.selected = UnCivGame.Current.settings.resolution
add(resolutionSelectBox).pad(10f).row()
resolutionSelectBox.addListener(object : ChangeListener() {
override fun changed(event: ChangeEvent?, actor: Actor?) {
UnCivGame.Current.settings.resolution = resolutionSelectBox.selected
UnCivGame.Current.settings.save()
UnCivGame.Current.worldScreen = WorldScreen()
UnCivGame.Current.setWorldScreen()
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
}
})
val soundEffectsVolumeSlider = Slider(0f,1.0f,0.1f,false,skin)
soundEffectsVolumeSlider.value = UnCivGame.Current.settings.soundEffectsVolume
soundEffectsVolumeSlider.addListener(object: ChangeListener(){
override fun changed(event: ChangeEvent?, actor: Actor?) {
UnCivGame.Current.settings.soundEffectsVolume= soundEffectsVolumeSlider.value
UnCivGame.Current.settings.save()
Sounds.play("click")
}
})
add("Sound effects volume").row()
add(soundEffectsVolumeSlider).row()
addButton("Close"){ remove() }
pack() // Needed to show the background.
center(UnCivGame.Current.worldScreen.stage)
UnCivGame.Current.worldScreen.shouldUpdate=true
}
private fun addLanguageSelectBox() {
val languageArray = Array<Language>()
GameBasics.Translations.getLanguages().map { Language(it) }.sortedByDescending { it.percentComplete }
.forEach { languageArray.add(it) }
languageSelectBox.items = languageArray
languageSelectBox.selected = languageArray.first { it.language == UnCivGame.Current.settings.language }
add(languageSelectBox).pad(10f).row()
languageSelectBox.addListener(object : ChangeListener() {
override fun changed(event: ChangeEvent?, actor: Actor?) {
val selectedLanguage = languageSelectBox.selected.language
if (Fonts().containsFont(Fonts().getFontForLanguage(selectedLanguage)))
selectLanguage()
else {
val spaceSplitLang = selectedLanguage.replace("_", " ")
YesNoPopupTable("This language requires you to download fonts.\n" +
"Do you want to download fonts for $spaceSplitLang?",
{
val downloading = PopupTable(screen)
downloading.add("Downloading...".toLabel())
downloading.open()
Gdx.input.inputProcessor = null // no interaction until download is over
thread {
Fonts().downloadFontForLanguage(selectedLanguage)
// The language selection must be done on the render thread, because it requires a GL context.
// This means that we have to tell the table to create it on render.
shouldSelectLanguage = true
}
})
}
}
})
if (languageSelectBox.selected.percentComplete != 100) {
add("Missing translations:".toLabel()).pad(5f).row()
val missingTextSelectBox = SelectBox<String>(skin)
val missingTextArray = Array<String>()
val currentLanguage = UnCivGame.Current.settings.language
GameBasics.Translations.filter { !it.value.containsKey(currentLanguage) }.forEach { missingTextArray.add(it.key) }
missingTextSelectBox.items = missingTextArray
missingTextSelectBox.selected = "Untranslated texts"
add(missingTextSelectBox).pad(10f).width(UnCivGame.Current.worldScreen.stage.width / 2).row()
}
}
fun selectLanguage(){
UnCivGame.Current.settings.language = languageSelectBox.selected.language
UnCivGame.Current.settings.save()
CameraStageBaseScreen.resetFonts()
UnCivGame.Current.worldScreen = WorldScreen()
UnCivGame.Current.setWorldScreen()
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
}
var shouldSelectLanguage = false
override fun draw(batch: Batch?, parentAlpha: Float) {
if(shouldSelectLanguage){
shouldSelectLanguage=false
selectLanguage()
}
super.draw(batch, parentAlpha)
}
}