Simplified MapParametersTable sliders
More onChange{ } changes
This commit is contained in:
parent
d64bd088c2
commit
a2a38e48ca
4 changed files with 84 additions and 169 deletions
|
@ -182,10 +182,9 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||||
val terrain = resource.terrainsCanBeFoundOn.first()
|
val terrain = resource.terrainsCanBeFoundOn.first()
|
||||||
val terrainObject = ruleset.terrains[terrain]!!
|
val terrainObject = ruleset.terrains[terrain]!!
|
||||||
if (terrainObject.type == TerrainType.TerrainFeature) {
|
if (terrainObject.type == TerrainType.TerrainFeature) {
|
||||||
tileInfo.baseTerrain = when {
|
tileInfo.baseTerrain =
|
||||||
terrainObject.occursOn == null -> terrainObject.occursOn!!.first()
|
if (terrainObject.occursOn == null) terrainObject.occursOn!!.first()
|
||||||
else -> "Grassland"
|
else "Grassland"
|
||||||
}
|
|
||||||
tileInfo.terrainFeature = terrain
|
tileInfo.terrainFeature = terrain
|
||||||
} else tileInfo.baseTerrain = terrain
|
} else tileInfo.baseTerrain = terrain
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package com.unciv.ui.newgamescreen
|
package com.unciv.ui.newgamescreen
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox
|
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
|
||||||
import com.unciv.logic.map.MapParameters
|
import com.unciv.logic.map.MapParameters
|
||||||
import com.unciv.logic.map.MapShape
|
import com.unciv.logic.map.MapShape
|
||||||
import com.unciv.logic.map.MapSize
|
import com.unciv.logic.map.MapSize
|
||||||
import com.unciv.logic.map.MapType
|
import com.unciv.logic.map.MapType
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
|
import com.unciv.ui.utils.onChange
|
||||||
import com.unciv.ui.utils.onClick
|
import com.unciv.ui.utils.onClick
|
||||||
import com.unciv.ui.utils.toLabel
|
import com.unciv.ui.utils.toLabel
|
||||||
|
|
||||||
|
@ -45,11 +44,9 @@ class MapParametersTable(val mapParameters: MapParameters, val isEmptyMapAllowed
|
||||||
)
|
)
|
||||||
val mapShapeSelectBox =
|
val mapShapeSelectBox =
|
||||||
TranslatedSelectBox(mapShapes, mapParameters.shape, skin)
|
TranslatedSelectBox(mapShapes, mapParameters.shape, skin)
|
||||||
mapShapeSelectBox.addListener(object : ChangeListener() {
|
mapShapeSelectBox.onChange {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.shape = mapShapeSelectBox.selected.value
|
mapParameters.shape = mapShapeSelectBox.selected.value
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
add ("{Map shape}:".toLabel()).left()
|
add ("{Map shape}:".toLabel()).left()
|
||||||
add(mapShapeSelectBox).fillX().row()
|
add(mapShapeSelectBox).fillX().row()
|
||||||
|
@ -68,15 +65,13 @@ class MapParametersTable(val mapParameters: MapParameters, val isEmptyMapAllowed
|
||||||
|
|
||||||
mapTypeSelectBox = TranslatedSelectBox(mapTypes, mapParameters.type, skin)
|
mapTypeSelectBox = TranslatedSelectBox(mapTypes, mapParameters.type, skin)
|
||||||
|
|
||||||
mapTypeSelectBox.addListener(object : ChangeListener() {
|
mapTypeSelectBox.onChange {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.type = mapTypeSelectBox.selected.value
|
mapParameters.type = mapTypeSelectBox.selected.value
|
||||||
|
|
||||||
// If the map won't be generated, these options are irrelevant and are hidden
|
// If the map won't be generated, these options are irrelevant and are hidden
|
||||||
noRuinsCheckbox.isVisible = mapParameters.type != MapType.empty
|
noRuinsCheckbox.isVisible = mapParameters.type != MapType.empty
|
||||||
noNaturalWondersCheckbox.isVisible = mapParameters.type != MapType.empty
|
noNaturalWondersCheckbox.isVisible = mapParameters.type != MapType.empty
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
add("{Map generation type}:".toLabel()).left()
|
add("{Map generation type}:".toLabel()).left()
|
||||||
add(mapTypeSelectBox).fillX().row()
|
add(mapTypeSelectBox).fillX().row()
|
||||||
|
@ -90,11 +85,9 @@ class MapParametersTable(val mapParameters: MapParameters, val isEmptyMapAllowed
|
||||||
skin
|
skin
|
||||||
)
|
)
|
||||||
|
|
||||||
worldSizeSelectBox.addListener(object : ChangeListener() {
|
worldSizeSelectBox.onChange {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.size = MapSize.valueOf(worldSizeSelectBox.selected.value)
|
mapParameters.size = MapSize.valueOf(worldSizeSelectBox.selected.value)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
add("{World size}:".toLabel()).left()
|
add("{World size}:".toLabel()).left()
|
||||||
add(worldSizeSelectBox).fillX().row()
|
add(worldSizeSelectBox).fillX().row()
|
||||||
|
@ -103,28 +96,23 @@ class MapParametersTable(val mapParameters: MapParameters, val isEmptyMapAllowed
|
||||||
private fun addNoRuinsCheckbox() {
|
private fun addNoRuinsCheckbox() {
|
||||||
noRuinsCheckbox = CheckBox("No ancient ruins".tr(), skin)
|
noRuinsCheckbox = CheckBox("No ancient ruins".tr(), skin)
|
||||||
noRuinsCheckbox.isChecked = mapParameters.noRuins
|
noRuinsCheckbox.isChecked = mapParameters.noRuins
|
||||||
noRuinsCheckbox.addListener(object : ChangeListener() {
|
noRuinsCheckbox.onChange { mapParameters.noRuins = noRuinsCheckbox.isChecked }
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.noRuins = noRuinsCheckbox.isChecked
|
|
||||||
}
|
|
||||||
})
|
|
||||||
add(noRuinsCheckbox).colspan(2).row()
|
add(noRuinsCheckbox).colspan(2).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addNoNaturalWondersCheckbox() {
|
private fun addNoNaturalWondersCheckbox() {
|
||||||
noNaturalWondersCheckbox = CheckBox("No Natural Wonders".tr(), skin)
|
noNaturalWondersCheckbox = CheckBox("No Natural Wonders".tr(), skin)
|
||||||
noNaturalWondersCheckbox.isChecked = mapParameters.noNaturalWonders
|
noNaturalWondersCheckbox.isChecked = mapParameters.noNaturalWonders
|
||||||
noNaturalWondersCheckbox.addListener(object : ChangeListener() {
|
noNaturalWondersCheckbox.onChange {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
mapParameters.noNaturalWonders = noNaturalWondersCheckbox.isChecked
|
||||||
mapParameters.noNaturalWonders = noNaturalWondersCheckbox.isChecked
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
add(noNaturalWondersCheckbox).colspan(2).row()
|
add(noNaturalWondersCheckbox).colspan(2).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addAdvancedSettings() {
|
private fun addAdvancedSettings() {
|
||||||
val button = TextButton("Show advanced settings".tr(), skin)
|
val button = TextButton("Show advanced settings".tr(), skin)
|
||||||
val advancedSettingsTable = Table().apply {isVisible = false; defaults().pad(5f)}
|
val advancedSettingsTable = Table()
|
||||||
|
.apply {isVisible = false; defaults().pad(5f)}
|
||||||
|
|
||||||
add(button).colspan(2).row()
|
add(button).colspan(2).row()
|
||||||
val advancedSettingsCell = add(Table()).colspan(2)
|
val advancedSettingsCell = add(Table()).colspan(2)
|
||||||
|
@ -142,111 +130,47 @@ class MapParametersTable(val mapParameters: MapParameters, val isEmptyMapAllowed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val sliders = HashMap<Slider, ()->Float>()
|
||||||
|
|
||||||
val elevationExponentSlider = Slider(0.5f,1f,0.01f, false, skin).apply {
|
fun addSlider(text:String, getValue:()->Float, min:Float, max:Float, onChange: (value:Float)->Unit): Slider {
|
||||||
addListener(object : ChangeListener() {
|
val slider = Slider(min, max, (max-min)/20,false,skin)
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
slider.value = getValue()
|
||||||
mapParameters.elevationExponent = this@apply.value
|
slider.onChange { onChange(slider.value) }
|
||||||
}
|
advancedSettingsTable.add(text.toLabel()).left()
|
||||||
})
|
advancedSettingsTable.add(slider).fillX().row()
|
||||||
|
sliders.put(slider, getValue)
|
||||||
|
return slider
|
||||||
}
|
}
|
||||||
elevationExponentSlider.value = mapParameters.elevationExponent
|
|
||||||
advancedSettingsTable.add("Map Height".toLabel()).left()
|
|
||||||
advancedSettingsTable.add(elevationExponentSlider).fillX().row()
|
|
||||||
|
|
||||||
|
addSlider("Map Height", {mapParameters.elevationExponent}, 0.5f,1f)
|
||||||
|
{mapParameters.elevationExponent=it}
|
||||||
|
|
||||||
val tempExtremeSlider = Slider(0.4f,0.8f,0.01f, false, skin).apply {
|
addSlider("Temperature extremeness", {mapParameters.temperatureExtremeness}, 0.4f,0.8f)
|
||||||
addListener(object : ChangeListener() {
|
{ mapParameters.temperatureExtremeness = it}
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.temperatureExtremeness = this@apply.value
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
tempExtremeSlider.value = mapParameters.temperatureExtremeness
|
|
||||||
advancedSettingsTable.add("Temperature extremeness".toLabel()).left()
|
|
||||||
advancedSettingsTable.add(tempExtremeSlider).fillX().row()
|
|
||||||
|
|
||||||
|
addSlider("Resource richness", {mapParameters.resourceRichness},0f,0.5f)
|
||||||
|
{ mapParameters.resourceRichness=it }
|
||||||
|
|
||||||
val resourceRichnessSlider = Slider(0f,0.5f,0.01f, false, skin).apply {
|
addSlider("Vegetation richness", {mapParameters.vegetationRichness}, 0f, 1f)
|
||||||
addListener(object : ChangeListener() {
|
{ mapParameters.vegetationRichness=it }
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.resourceRichness = this@apply.value
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
resourceRichnessSlider.value = mapParameters.resourceRichness
|
|
||||||
advancedSettingsTable.add("Resource richness".toLabel()).left()
|
|
||||||
advancedSettingsTable.add(resourceRichnessSlider).fillX().row()
|
|
||||||
|
|
||||||
val vegetationRichnessSlider = Slider(0f,1f,0.01f, false, skin).apply {
|
addSlider("Rare features richness", {mapParameters.rareFeaturesRichness}, 0f, 0.5f)
|
||||||
addListener(object : ChangeListener() {
|
{ mapParameters.rareFeaturesRichness = it }
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.vegetationRichness = this@apply.value
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
vegetationRichnessSlider.value = mapParameters.vegetationRichness
|
|
||||||
advancedSettingsTable.add("Vegetation richness".toLabel()).left()
|
|
||||||
advancedSettingsTable.add(vegetationRichnessSlider).fillX().row()
|
|
||||||
|
|
||||||
val rareFeaturesRichnessSlider = Slider(0f,0.5f,0.01f, false, skin).apply {
|
addSlider("Max Coast extension", {mapParameters.maxCoastExtension.toFloat()}, 0f, 5f)
|
||||||
addListener(object : ChangeListener() {
|
{ mapParameters.maxCoastExtension =it.toInt() }.apply { stepSize=1f }
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.rareFeaturesRichness = this@apply.value
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
rareFeaturesRichnessSlider.value = mapParameters.rareFeaturesRichness
|
|
||||||
advancedSettingsTable.add("Rare features richness".toLabel()).left()
|
|
||||||
advancedSettingsTable.add(rareFeaturesRichnessSlider).fillX().row()
|
|
||||||
|
|
||||||
|
addSlider("Biome areas extension", {mapParameters.tilesPerBiomeArea.toFloat()}, 1f, 15f)
|
||||||
|
{ mapParameters.tilesPerBiomeArea = it.toInt() }.apply { stepSize=1f }
|
||||||
|
|
||||||
val maxCoastExtensionSlider = Slider(0f,5f,1f, false, skin).apply {
|
addSlider("Water level", {mapParameters.waterThreshold}, -0.1f, 0.1f)
|
||||||
addListener(object : ChangeListener() {
|
{ mapParameters.waterThreshold = it }
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.maxCoastExtension = this@apply.value.toInt()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
maxCoastExtensionSlider.value = mapParameters.maxCoastExtension.toFloat()
|
|
||||||
advancedSettingsTable.add("Max Coast extension".toLabel()).left()
|
|
||||||
advancedSettingsTable.add(maxCoastExtensionSlider).fillX().row()
|
|
||||||
|
|
||||||
|
|
||||||
val tilesPerBiomeAreaSlider = Slider(1f,15f,1f, false, skin).apply {
|
|
||||||
addListener(object : ChangeListener() {
|
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.tilesPerBiomeArea = this@apply.value.toInt()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
tilesPerBiomeAreaSlider.value = mapParameters.tilesPerBiomeArea.toFloat()
|
|
||||||
advancedSettingsTable.add("Biome areas extension".toLabel()).left()
|
|
||||||
advancedSettingsTable.add(tilesPerBiomeAreaSlider).fillX().row()
|
|
||||||
|
|
||||||
|
|
||||||
val waterThresholdSlider = Slider(-0.1f,0.1f,0.01f, false, skin).apply {
|
|
||||||
addListener(object : ChangeListener() {
|
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
|
||||||
mapParameters.waterThreshold = this@apply.value
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
waterThresholdSlider.value = mapParameters.waterThreshold
|
|
||||||
advancedSettingsTable.add("Water level".toLabel()).left()
|
|
||||||
advancedSettingsTable.add(waterThresholdSlider).fillX().row()
|
|
||||||
|
|
||||||
val resetToDefaultButton = TextButton("Reset to default".tr(), skin)
|
val resetToDefaultButton = TextButton("Reset to default".tr(), skin)
|
||||||
resetToDefaultButton.onClick {
|
resetToDefaultButton.onClick {
|
||||||
mapParameters.resetAdvancedSettings()
|
mapParameters.resetAdvancedSettings()
|
||||||
elevationExponentSlider.value = mapParameters.elevationExponent
|
for(entry in sliders)
|
||||||
tempExtremeSlider.value = mapParameters.temperatureExtremeness
|
entry.key.value = entry.value()
|
||||||
resourceRichnessSlider.value = mapParameters.resourceRichness
|
|
||||||
vegetationRichnessSlider.value = mapParameters.vegetationRichness
|
|
||||||
rareFeaturesRichnessSlider.value = mapParameters.rareFeaturesRichness
|
|
||||||
maxCoastExtensionSlider.value = mapParameters.maxCoastExtension.toFloat()
|
|
||||||
tilesPerBiomeAreaSlider.value = mapParameters.tilesPerBiomeArea.toFloat()
|
|
||||||
waterThresholdSlider.value = mapParameters.waterThreshold
|
|
||||||
}
|
}
|
||||||
advancedSettingsTable.add(resetToDefaultButton).colspan(2).row()
|
advancedSettingsTable.add(resetToDefaultButton).colspan(2).row()
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,12 +143,13 @@ fun Actor.onClick(function: () -> Unit): Actor {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Actor.onChange(function: () -> Unit){
|
fun Actor.onChange(function: () -> Unit): Actor {
|
||||||
this.addListener(object : ChangeListener() {
|
this.addListener(object : ChangeListener() {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
function()
|
function()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Actor.surroundWithCircle(size:Float,resizeActor:Boolean=true): IconCircleGroup {
|
fun Actor.surroundWithCircle(size:Float,resizeActor:Boolean=true): IconCircleGroup {
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Language(val language:String, val percentComplete:Int){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen) {
|
||||||
var selectedLanguage: String = "English"
|
var selectedLanguage: String = "English"
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -41,7 +41,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
||||||
|
|
||||||
innerTable.add("Show worked tiles".toLabel())
|
innerTable.add("Show worked tiles".toLabel())
|
||||||
addButton(innerTable, if (settings.showWorkedTiles) "Yes" else "No") {
|
addButton(innerTable, if (settings.showWorkedTiles) "Yes" else "No") {
|
||||||
settings.showWorkedTiles= !settings.showWorkedTiles
|
settings.showWorkedTiles = !settings.showWorkedTiles
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,16 +187,16 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
||||||
val soundEffectsVolumeSlider = Slider(0f, 1.0f, 0.1f, false, skin)
|
val soundEffectsVolumeSlider = Slider(0f, 1.0f, 0.1f, false, skin)
|
||||||
soundEffectsVolumeSlider.value = UncivGame.Current.settings.soundEffectsVolume
|
soundEffectsVolumeSlider.value = UncivGame.Current.settings.soundEffectsVolume
|
||||||
soundEffectsVolumeSlider.onChange {
|
soundEffectsVolumeSlider.onChange {
|
||||||
UncivGame.Current.settings.soundEffectsVolume = soundEffectsVolumeSlider.value
|
UncivGame.Current.settings.soundEffectsVolume = soundEffectsVolumeSlider.value
|
||||||
UncivGame.Current.settings.save()
|
UncivGame.Current.settings.save()
|
||||||
Sounds.play(UncivSound.Click)
|
Sounds.play(UncivSound.Click)
|
||||||
}
|
}
|
||||||
innerTable.add(soundEffectsVolumeSlider).pad(10f).row()
|
innerTable.add(soundEffectsVolumeSlider).pad(10f).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addMusicVolumeSlider(innerTable: Table) {
|
private fun addMusicVolumeSlider(innerTable: Table) {
|
||||||
val musicLocation =Gdx.files.local(UncivGame.Current.musicLocation)
|
val musicLocation = Gdx.files.local(UncivGame.Current.musicLocation)
|
||||||
if(musicLocation.exists()) {
|
if (musicLocation.exists()) {
|
||||||
innerTable.add("Music volume".tr())
|
innerTable.add("Music volume".tr())
|
||||||
|
|
||||||
val musicVolumeSlider = Slider(0f, 1.0f, 0.1f, false, skin)
|
val musicVolumeSlider = Slider(0f, 1.0f, 0.1f, false, skin)
|
||||||
|
@ -212,16 +212,15 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
||||||
music?.volume = 0.4f * musicVolumeSlider.value
|
music?.volume = 0.4f * musicVolumeSlider.value
|
||||||
}
|
}
|
||||||
innerTable.add(musicVolumeSlider).pad(10f).row()
|
innerTable.add(musicVolumeSlider).pad(10f).row()
|
||||||
}
|
} else {
|
||||||
else{
|
val downloadMusicButton = TextButton("Download music".tr(), CameraStageBaseScreen.skin)
|
||||||
val downloadMusicButton = TextButton("Download music".tr(),CameraStageBaseScreen.skin)
|
|
||||||
innerTable.add(downloadMusicButton).colspan(2).row()
|
innerTable.add(downloadMusicButton).colspan(2).row()
|
||||||
val errorTable = Table()
|
val errorTable = Table()
|
||||||
innerTable.add(errorTable).colspan(2).row()
|
innerTable.add(errorTable).colspan(2).row()
|
||||||
|
|
||||||
downloadMusicButton.onClick {
|
downloadMusicButton.onClick {
|
||||||
// So the whole game doesn't get stuck while downloading the file
|
// So the whole game doesn't get stuck while downloading the file
|
||||||
thread(name="Music") {
|
thread(name = "Music") {
|
||||||
try {
|
try {
|
||||||
downloadMusicButton.disable()
|
downloadMusicButton.disable()
|
||||||
errorTable.clear()
|
errorTable.clear()
|
||||||
|
@ -244,7 +243,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
||||||
|
|
||||||
val resolutionSelectBox = SelectBox<String>(skin)
|
val resolutionSelectBox = SelectBox<String>(skin)
|
||||||
val resolutionArray = Array<String>()
|
val resolutionArray = Array<String>()
|
||||||
resolutionArray.addAll("750x500","900x600", "1050x700", "1200x800", "1500x1000")
|
resolutionArray.addAll("750x500", "900x600", "1050x700", "1200x800", "1500x1000")
|
||||||
resolutionSelectBox.items = resolutionArray
|
resolutionSelectBox.items = resolutionArray
|
||||||
resolutionSelectBox.selected = UncivGame.Current.settings.resolution
|
resolutionSelectBox.selected = UncivGame.Current.settings.resolution
|
||||||
innerTable.add(resolutionSelectBox).minWidth(240f).pad(10f).row()
|
innerTable.add(resolutionSelectBox).minWidth(240f).pad(10f).row()
|
||||||
|
@ -265,20 +264,18 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
||||||
val tileSetArray = Array<String>()
|
val tileSetArray = Array<String>()
|
||||||
val tileSets = ImageGetter.atlas.regions.filter { it.name.startsWith("TileSets") }
|
val tileSets = ImageGetter.atlas.regions.filter { it.name.startsWith("TileSets") }
|
||||||
.map { it.name.split("/")[1] }.distinct()
|
.map { it.name.split("/")[1] }.distinct()
|
||||||
for(tileset in tileSets) tileSetArray.add(tileset)
|
for (tileset in tileSets) tileSetArray.add(tileset)
|
||||||
tileSetSelectBox.items = tileSetArray
|
tileSetSelectBox.items = tileSetArray
|
||||||
tileSetSelectBox.selected = UncivGame.Current.settings.tileSet
|
tileSetSelectBox.selected = UncivGame.Current.settings.tileSet
|
||||||
innerTable.add(tileSetSelectBox).minWidth(240f).pad(10f).row()
|
innerTable.add(tileSetSelectBox).minWidth(240f).pad(10f).row()
|
||||||
|
|
||||||
tileSetSelectBox.addListener(object : ChangeListener() {
|
tileSetSelectBox.onChange {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
UncivGame.Current.settings.tileSet = tileSetSelectBox.selected
|
||||||
UncivGame.Current.settings.tileSet = tileSetSelectBox.selected
|
UncivGame.Current.settings.save()
|
||||||
UncivGame.Current.settings.save()
|
UncivGame.Current.worldScreen = WorldScreen(worldScreen.viewingCiv)
|
||||||
UncivGame.Current.worldScreen = WorldScreen(worldScreen.viewingCiv)
|
UncivGame.Current.setWorldScreen()
|
||||||
UncivGame.Current.setWorldScreen()
|
WorldScreenOptionsPopup(UncivGame.Current.worldScreen).open()
|
||||||
WorldScreenOptionsPopup(UncivGame.Current.worldScreen).open()
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addAutosaveTurnsSelectBox(innerTable: Table) {
|
private fun addAutosaveTurnsSelectBox(innerTable: Table) {
|
||||||
|
@ -286,19 +283,17 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
||||||
|
|
||||||
val autosaveTurnsSelectBox = SelectBox<Int>(skin)
|
val autosaveTurnsSelectBox = SelectBox<Int>(skin)
|
||||||
val autosaveTurnsArray = Array<Int>()
|
val autosaveTurnsArray = Array<Int>()
|
||||||
autosaveTurnsArray.addAll(1,2,5,10)
|
autosaveTurnsArray.addAll(1, 2, 5, 10)
|
||||||
autosaveTurnsSelectBox.items = autosaveTurnsArray
|
autosaveTurnsSelectBox.items = autosaveTurnsArray
|
||||||
autosaveTurnsSelectBox.selected = UncivGame.Current.settings.turnsBetweenAutosaves
|
autosaveTurnsSelectBox.selected = UncivGame.Current.settings.turnsBetweenAutosaves
|
||||||
|
|
||||||
innerTable.add(autosaveTurnsSelectBox).pad(10f).row()
|
innerTable.add(autosaveTurnsSelectBox).pad(10f).row()
|
||||||
|
|
||||||
autosaveTurnsSelectBox.addListener(object : ChangeListener() {
|
autosaveTurnsSelectBox.onChange {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
UncivGame.Current.settings.turnsBetweenAutosaves = autosaveTurnsSelectBox.selected
|
||||||
UncivGame.Current.settings.turnsBetweenAutosaves= autosaveTurnsSelectBox.selected
|
UncivGame.Current.settings.save()
|
||||||
UncivGame.Current.settings.save()
|
update()
|
||||||
update()
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addMultiplayerTurnCheckerDelayBox(innerTable: Table) {
|
private fun addMultiplayerTurnCheckerDelayBox(innerTable: Table) {
|
||||||
|
@ -312,42 +307,38 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
||||||
|
|
||||||
innerTable.add(checkDelaySelectBox).pad(10f).row()
|
innerTable.add(checkDelaySelectBox).pad(10f).row()
|
||||||
|
|
||||||
checkDelaySelectBox.addListener(object : ChangeListener() {
|
checkDelaySelectBox.onChange {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
UncivGame.Current.settings.multiplayerTurnCheckerDelayInMinutes = checkDelaySelectBox.selected
|
||||||
UncivGame.Current.settings.multiplayerTurnCheckerDelayInMinutes = checkDelaySelectBox.selected
|
UncivGame.Current.settings.save()
|
||||||
UncivGame.Current.settings.save()
|
update()
|
||||||
update()
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addLanguageSelectBox(innerTable: Table) {
|
private fun addLanguageSelectBox(innerTable: Table) {
|
||||||
val languageSelectBox = SelectBox<Language>(skin)
|
val languageSelectBox = SelectBox<Language>(skin)
|
||||||
val languageArray = Array<Language>()
|
val languageArray = Array<Language>()
|
||||||
UncivGame.Current.translations.percentCompleteOfLanguages
|
UncivGame.Current.translations.percentCompleteOfLanguages
|
||||||
.map { Language(it.key, if(it.key=="English") 100 else it.value) }
|
.map { Language(it.key, if (it.key == "English") 100 else it.value) }
|
||||||
.sortedByDescending { it.percentComplete }
|
.sortedByDescending { it.percentComplete }
|
||||||
.forEach { languageArray.add(it) }
|
.forEach { languageArray.add(it) }
|
||||||
if(languageArray.size==0) return
|
if (languageArray.size == 0) return
|
||||||
|
|
||||||
innerTable.add("Language".toLabel())
|
innerTable.add("Language".toLabel())
|
||||||
languageSelectBox.items = languageArray
|
languageSelectBox.items = languageArray
|
||||||
val matchingLanguage = languageArray.firstOrNull { it.language == UncivGame.Current.settings.language }
|
val matchingLanguage = languageArray.firstOrNull { it.language == UncivGame.Current.settings.language }
|
||||||
languageSelectBox.selected = if (matchingLanguage != null) matchingLanguage else languageArray.first()
|
languageSelectBox.selected = if (matchingLanguage != null) matchingLanguage else languageArray.first()
|
||||||
innerTable.add(languageSelectBox).minWidth(240f).pad(10f).row()
|
innerTable.add(languageSelectBox).minWidth(240f).pad(10f).row()
|
||||||
|
|
||||||
languageSelectBox.addListener(object : ChangeListener() {
|
languageSelectBox.onChange {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
// Sometimes the "changed" is triggered even when we didn't choose something that isn't the
|
||||||
// Sometimes the "changed" is triggered even when we didn't choose something that isn't the
|
selectedLanguage = languageSelectBox.selected.language
|
||||||
selectedLanguage = languageSelectBox.selected.language
|
|
||||||
|
|
||||||
if(selectedLanguage!=UncivGame.Current.settings.language )
|
|
||||||
selectLanguage()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
if (selectedLanguage != UncivGame.Current.settings.language)
|
||||||
|
selectLanguage()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun selectLanguage(){
|
fun selectLanguage() {
|
||||||
UncivGame.Current.settings.language = selectedLanguage
|
UncivGame.Current.settings.language = selectedLanguage
|
||||||
UncivGame.Current.settings.save()
|
UncivGame.Current.settings.save()
|
||||||
|
|
||||||
|
@ -357,4 +348,4 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
||||||
UncivGame.Current.setWorldScreen()
|
UncivGame.Current.setWorldScreen()
|
||||||
WorldScreenOptionsPopup(UncivGame.Current.worldScreen).open()
|
WorldScreenOptionsPopup(UncivGame.Current.worldScreen).open()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue