mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Options table was getting too long - now scrolls nicely
This commit is contained in:
parent
c3efc10ea8
commit
e1dda58f58
@ -63,15 +63,15 @@ open class CameraStageBaseScreen : Screen {
|
||||
}
|
||||
|
||||
fun resetFonts(){
|
||||
skin.get<TextButton.TextButtonStyle>(TextButton.TextButtonStyle::class.java).font = Fonts().getFont(20)
|
||||
skin.get<Label.LabelStyle>(Label.LabelStyle::class.java).apply {
|
||||
skin.get(TextButton.TextButtonStyle::class.java).font = Fonts().getFont(20)
|
||||
skin.get(Label.LabelStyle::class.java).apply {
|
||||
font = Fonts().getFont(18)
|
||||
fontColor= Color.WHITE
|
||||
}
|
||||
skin.get<TextField.TextFieldStyle>(TextField.TextFieldStyle::class.java).font = Fonts().getFont(18)
|
||||
skin.get<SelectBox.SelectBoxStyle>(SelectBox.SelectBoxStyle::class.java).font = Fonts().getFont(20)
|
||||
skin.get<SelectBox.SelectBoxStyle>(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts().getFont(20)
|
||||
skin.get<CheckBox.CheckBoxStyle>(CheckBox.CheckBoxStyle::class.java).fontColor= Color.WHITE
|
||||
skin.get(TextField.TextFieldStyle::class.java).font = Fonts().getFont(18)
|
||||
skin.get(SelectBox.SelectBoxStyle::class.java).font = Fonts().getFont(20)
|
||||
skin.get(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts().getFont(20)
|
||||
skin.get(CheckBox.CheckBoxStyle::class.java).fontColor= Color.WHITE
|
||||
}
|
||||
internal var batch: Batch = SpriteBatch()
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ 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.ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||
@ -41,61 +42,69 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
||||
settings.save()
|
||||
clear()
|
||||
|
||||
add("Worked tiles".toLabel())
|
||||
if (settings.showWorkedTiles) addButton("Hide") { settings.showWorkedTiles = false; update() }
|
||||
else addButton("Show") { settings.showWorkedTiles = true; update() }
|
||||
val innerTable = PopupTable(screen) // cheating, to get the old code to fit inside a Scroll =)
|
||||
innerTable.background=null
|
||||
innerTable.add("Worked tiles".toLabel())
|
||||
if (settings.showWorkedTiles) innerTable.addButton("Hide") { settings.showWorkedTiles = false; update() }
|
||||
else innerTable.addButton("Show") { settings.showWorkedTiles = true; update() }
|
||||
|
||||
add("Resources and improvements".toLabel())
|
||||
innerTable.add("Resources and improvements".toLabel())
|
||||
if (settings.showResourcesAndImprovements)
|
||||
addButton("Hide") { settings.showResourcesAndImprovements = false; update() }
|
||||
else addButton("Show") { settings.showResourcesAndImprovements = true; update() }
|
||||
innerTable.addButton("Hide") { settings.showResourcesAndImprovements = false; update() }
|
||||
else innerTable.addButton("Show") { settings.showResourcesAndImprovements = true; update() }
|
||||
|
||||
add("Check for idle units".toLabel())
|
||||
addButton(if(settings.checkForDueUnits) "Yes".tr() else "No".tr()) {
|
||||
innerTable.add("Check for idle units".toLabel())
|
||||
innerTable.addButton(if(settings.checkForDueUnits) "Yes".tr() else "No".tr()) {
|
||||
settings.checkForDueUnits = !settings.checkForDueUnits
|
||||
update()
|
||||
}
|
||||
|
||||
add("Move units with a single tap".toLabel())
|
||||
addButton(if(settings.singleTapMove) "Yes".tr() else "No".tr()) {
|
||||
innerTable.add("Move units with a single tap".toLabel())
|
||||
innerTable.addButton(if(settings.singleTapMove) "Yes".tr() else "No".tr()) {
|
||||
settings.singleTapMove = !settings.singleTapMove
|
||||
update()
|
||||
}
|
||||
|
||||
add("Show tutorials".toLabel())
|
||||
addButton(if(settings.showTutorials) "Yes".tr() else "No".tr()) {
|
||||
innerTable.add("Show tutorials".toLabel())
|
||||
innerTable.addButton(if(settings.showTutorials) "Yes".tr() else "No".tr()) {
|
||||
settings.showTutorials= !settings.showTutorials
|
||||
update()
|
||||
}
|
||||
|
||||
add("Auto-assign city production".toLabel())
|
||||
addButton(if(settings.autoAssignCityProduction) "Yes".tr() else "No".tr()) {
|
||||
innerTable.add("Auto-assign city production".toLabel())
|
||||
innerTable.addButton(if(settings.autoAssignCityProduction) "Yes".tr() else "No".tr()) {
|
||||
settings.autoAssignCityProduction= !settings.autoAssignCityProduction
|
||||
update()
|
||||
}
|
||||
|
||||
addLanguageSelectBox()
|
||||
addLanguageSelectBox(innerTable)
|
||||
|
||||
addResolutionSelectBox()
|
||||
addResolutionSelectBox(innerTable)
|
||||
|
||||
addAutosaveTurnsSelectBox()
|
||||
addAutosaveTurnsSelectBox(innerTable)
|
||||
|
||||
addTileSetSelectBox()
|
||||
addTileSetSelectBox(innerTable)
|
||||
|
||||
addSoundEffectsVolumeSlider()
|
||||
addSoundEffectsVolumeSlider(innerTable)
|
||||
|
||||
add("Version".toLabel())
|
||||
add(UnCivGame.Current.version.toLabel()).row()
|
||||
innerTable.add("Version".toLabel())
|
||||
innerTable.add(UnCivGame.Current.version.toLabel()).row()
|
||||
|
||||
addButton("Close"){ remove() }.colspan(2)
|
||||
val scrollPane = ScrollPane(innerTable,skin)
|
||||
scrollPane.setOverscroll(false,false)
|
||||
scrollPane.fadeScrollBars=false
|
||||
scrollPane.setScrollingDisabled(true,false)
|
||||
add(scrollPane).maxHeight(screen.stage.height*0.6f).row()
|
||||
|
||||
addButton("Close"){ remove() }
|
||||
|
||||
pack() // Needed to show the background.
|
||||
center(UnCivGame.Current.worldScreen.stage)
|
||||
UnCivGame.Current.worldScreen.shouldUpdate=true
|
||||
}
|
||||
|
||||
private fun addSoundEffectsVolumeSlider() {
|
||||
add("Sound effects volume".tr())
|
||||
private fun addSoundEffectsVolumeSlider(innerTable: PopupTable) {
|
||||
innerTable.add("Sound effects volume".tr())
|
||||
|
||||
val soundEffectsVolumeSlider = Slider(0f, 1.0f, 0.1f, false, skin)
|
||||
soundEffectsVolumeSlider.value = UnCivGame.Current.settings.soundEffectsVolume
|
||||
@ -106,18 +115,18 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
||||
Sounds.play("click")
|
||||
}
|
||||
})
|
||||
add(soundEffectsVolumeSlider).row()
|
||||
innerTable.add(soundEffectsVolumeSlider).row()
|
||||
}
|
||||
|
||||
private fun addResolutionSelectBox() {
|
||||
add("Resolution".toLabel())
|
||||
private fun addResolutionSelectBox(innerTable: PopupTable) {
|
||||
innerTable.add("Resolution".toLabel())
|
||||
|
||||
val resolutionSelectBox = SelectBox<String>(skin)
|
||||
val resolutionArray = Array<String>()
|
||||
resolutionArray.addAll("900x600", "1050x700", "1200x800", "1500x1000")
|
||||
resolutionSelectBox.items = resolutionArray
|
||||
resolutionSelectBox.selected = UnCivGame.Current.settings.resolution
|
||||
add(resolutionSelectBox).pad(10f).row()
|
||||
innerTable.add(resolutionSelectBox).pad(10f).row()
|
||||
|
||||
resolutionSelectBox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
@ -130,8 +139,8 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
||||
})
|
||||
}
|
||||
|
||||
private fun addTileSetSelectBox() {
|
||||
add("Tileset".toLabel())
|
||||
private fun addTileSetSelectBox(innerTable: PopupTable) {
|
||||
innerTable.add("Tileset".toLabel())
|
||||
|
||||
val tileSetSelectBox = SelectBox<String>(skin)
|
||||
val tileSetArray = Array<String>()
|
||||
@ -140,7 +149,7 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
||||
for(tileset in tileSets) tileSetArray.add(tileset)
|
||||
tileSetSelectBox.items = tileSetArray
|
||||
tileSetSelectBox.selected = UnCivGame.Current.settings.tileSet
|
||||
add(tileSetSelectBox).pad(10f).row()
|
||||
innerTable.add(tileSetSelectBox).pad(10f).row()
|
||||
|
||||
tileSetSelectBox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
@ -153,8 +162,8 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
||||
})
|
||||
}
|
||||
|
||||
private fun addAutosaveTurnsSelectBox() {
|
||||
add("Turns between autosaves".toLabel())
|
||||
private fun addAutosaveTurnsSelectBox(innerTable: PopupTable) {
|
||||
innerTable.add("Turns between autosaves".toLabel())
|
||||
|
||||
val autosaveTurnsSelectBox = SelectBox<Int>(skin)
|
||||
val autosaveTurnsArray = Array<Int>()
|
||||
@ -162,7 +171,7 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
||||
autosaveTurnsSelectBox.items = autosaveTurnsArray
|
||||
autosaveTurnsSelectBox.selected = UnCivGame.Current.settings.turnsBetweenAutosaves
|
||||
|
||||
add(autosaveTurnsSelectBox).pad(10f).row()
|
||||
innerTable.add(autosaveTurnsSelectBox).pad(10f).row()
|
||||
|
||||
autosaveTurnsSelectBox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
@ -173,15 +182,15 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
||||
})
|
||||
}
|
||||
|
||||
private fun addLanguageSelectBox() {
|
||||
add("Language".toLabel())
|
||||
private fun addLanguageSelectBox(innerTable: PopupTable) {
|
||||
innerTable.add("Language".toLabel())
|
||||
val languageSelectBox = SelectBox<Language>(skin)
|
||||
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()
|
||||
innerTable.add(languageSelectBox).pad(10f).row()
|
||||
|
||||
languageSelectBox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
@ -211,14 +220,14 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
||||
})
|
||||
|
||||
if (languageSelectBox.selected.percentComplete != 100) {
|
||||
add("Missing translations:".toLabel()).pad(5f).colspan(2).row()
|
||||
innerTable.add("Missing translations:".toLabel()).pad(5f).colspan(2).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).colspan(2).row()
|
||||
innerTable.add(missingTextSelectBox).pad(10f).width(UnCivGame.Current.worldScreen.stage.width / 2).colspan(2).row()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user