mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -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(){
|
fun resetFonts(){
|
||||||
skin.get<TextButton.TextButtonStyle>(TextButton.TextButtonStyle::class.java).font = Fonts().getFont(20)
|
skin.get(TextButton.TextButtonStyle::class.java).font = Fonts().getFont(20)
|
||||||
skin.get<Label.LabelStyle>(Label.LabelStyle::class.java).apply {
|
skin.get(Label.LabelStyle::class.java).apply {
|
||||||
font = Fonts().getFont(18)
|
font = Fonts().getFont(18)
|
||||||
fontColor= Color.WHITE
|
fontColor= Color.WHITE
|
||||||
}
|
}
|
||||||
skin.get<TextField.TextFieldStyle>(TextField.TextFieldStyle::class.java).font = Fonts().getFont(18)
|
skin.get(TextField.TextFieldStyle::class.java).font = Fonts().getFont(18)
|
||||||
skin.get<SelectBox.SelectBoxStyle>(SelectBox.SelectBoxStyle::class.java).font = Fonts().getFont(20)
|
skin.get(SelectBox.SelectBoxStyle::class.java).font = Fonts().getFont(20)
|
||||||
skin.get<SelectBox.SelectBoxStyle>(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts().getFont(20)
|
skin.get(SelectBox.SelectBoxStyle::class.java).listStyle.font = Fonts().getFont(20)
|
||||||
skin.get<CheckBox.CheckBoxStyle>(CheckBox.CheckBoxStyle::class.java).fontColor= Color.WHITE
|
skin.get(CheckBox.CheckBoxStyle::class.java).fontColor= Color.WHITE
|
||||||
}
|
}
|
||||||
internal var batch: Batch = SpriteBatch()
|
internal var batch: Batch = SpriteBatch()
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.ui.worldscreen.optionstable
|
|||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
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.SelectBox
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||||
@ -41,61 +42,69 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
settings.save()
|
settings.save()
|
||||||
clear()
|
clear()
|
||||||
|
|
||||||
add("Worked tiles".toLabel())
|
val innerTable = PopupTable(screen) // cheating, to get the old code to fit inside a Scroll =)
|
||||||
if (settings.showWorkedTiles) addButton("Hide") { settings.showWorkedTiles = false; update() }
|
innerTable.background=null
|
||||||
else addButton("Show") { settings.showWorkedTiles = true; update() }
|
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)
|
if (settings.showResourcesAndImprovements)
|
||||||
addButton("Hide") { settings.showResourcesAndImprovements = false; update() }
|
innerTable.addButton("Hide") { settings.showResourcesAndImprovements = false; update() }
|
||||||
else addButton("Show") { settings.showResourcesAndImprovements = true; update() }
|
else innerTable.addButton("Show") { settings.showResourcesAndImprovements = true; update() }
|
||||||
|
|
||||||
add("Check for idle units".toLabel())
|
innerTable.add("Check for idle units".toLabel())
|
||||||
addButton(if(settings.checkForDueUnits) "Yes".tr() else "No".tr()) {
|
innerTable.addButton(if(settings.checkForDueUnits) "Yes".tr() else "No".tr()) {
|
||||||
settings.checkForDueUnits = !settings.checkForDueUnits
|
settings.checkForDueUnits = !settings.checkForDueUnits
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
add("Move units with a single tap".toLabel())
|
innerTable.add("Move units with a single tap".toLabel())
|
||||||
addButton(if(settings.singleTapMove) "Yes".tr() else "No".tr()) {
|
innerTable.addButton(if(settings.singleTapMove) "Yes".tr() else "No".tr()) {
|
||||||
settings.singleTapMove = !settings.singleTapMove
|
settings.singleTapMove = !settings.singleTapMove
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
add("Show tutorials".toLabel())
|
innerTable.add("Show tutorials".toLabel())
|
||||||
addButton(if(settings.showTutorials) "Yes".tr() else "No".tr()) {
|
innerTable.addButton(if(settings.showTutorials) "Yes".tr() else "No".tr()) {
|
||||||
settings.showTutorials= !settings.showTutorials
|
settings.showTutorials= !settings.showTutorials
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
add("Auto-assign city production".toLabel())
|
innerTable.add("Auto-assign city production".toLabel())
|
||||||
addButton(if(settings.autoAssignCityProduction) "Yes".tr() else "No".tr()) {
|
innerTable.addButton(if(settings.autoAssignCityProduction) "Yes".tr() else "No".tr()) {
|
||||||
settings.autoAssignCityProduction= !settings.autoAssignCityProduction
|
settings.autoAssignCityProduction= !settings.autoAssignCityProduction
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
addLanguageSelectBox()
|
addLanguageSelectBox(innerTable)
|
||||||
|
|
||||||
addResolutionSelectBox()
|
addResolutionSelectBox(innerTable)
|
||||||
|
|
||||||
addAutosaveTurnsSelectBox()
|
addAutosaveTurnsSelectBox(innerTable)
|
||||||
|
|
||||||
addTileSetSelectBox()
|
addTileSetSelectBox(innerTable)
|
||||||
|
|
||||||
addSoundEffectsVolumeSlider()
|
addSoundEffectsVolumeSlider(innerTable)
|
||||||
|
|
||||||
add("Version".toLabel())
|
innerTable.add("Version".toLabel())
|
||||||
add(UnCivGame.Current.version.toLabel()).row()
|
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.
|
pack() // Needed to show the background.
|
||||||
center(UnCivGame.Current.worldScreen.stage)
|
center(UnCivGame.Current.worldScreen.stage)
|
||||||
UnCivGame.Current.worldScreen.shouldUpdate=true
|
UnCivGame.Current.worldScreen.shouldUpdate=true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addSoundEffectsVolumeSlider() {
|
private fun addSoundEffectsVolumeSlider(innerTable: PopupTable) {
|
||||||
add("Sound effects volume".tr())
|
innerTable.add("Sound effects volume".tr())
|
||||||
|
|
||||||
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
|
||||||
@ -106,18 +115,18 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
Sounds.play("click")
|
Sounds.play("click")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
add(soundEffectsVolumeSlider).row()
|
innerTable.add(soundEffectsVolumeSlider).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addResolutionSelectBox() {
|
private fun addResolutionSelectBox(innerTable: PopupTable) {
|
||||||
add("Resolution".toLabel())
|
innerTable.add("Resolution".toLabel())
|
||||||
|
|
||||||
val resolutionSelectBox = SelectBox<String>(skin)
|
val resolutionSelectBox = SelectBox<String>(skin)
|
||||||
val resolutionArray = Array<String>()
|
val resolutionArray = Array<String>()
|
||||||
resolutionArray.addAll("900x600", "1050x700", "1200x800", "1500x1000")
|
resolutionArray.addAll("900x600", "1050x700", "1200x800", "1500x1000")
|
||||||
resolutionSelectBox.items = resolutionArray
|
resolutionSelectBox.items = resolutionArray
|
||||||
resolutionSelectBox.selected = UnCivGame.Current.settings.resolution
|
resolutionSelectBox.selected = UnCivGame.Current.settings.resolution
|
||||||
add(resolutionSelectBox).pad(10f).row()
|
innerTable.add(resolutionSelectBox).pad(10f).row()
|
||||||
|
|
||||||
resolutionSelectBox.addListener(object : ChangeListener() {
|
resolutionSelectBox.addListener(object : ChangeListener() {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
@ -130,8 +139,8 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addTileSetSelectBox() {
|
private fun addTileSetSelectBox(innerTable: PopupTable) {
|
||||||
add("Tileset".toLabel())
|
innerTable.add("Tileset".toLabel())
|
||||||
|
|
||||||
val tileSetSelectBox = SelectBox<String>(skin)
|
val tileSetSelectBox = SelectBox<String>(skin)
|
||||||
val tileSetArray = Array<String>()
|
val tileSetArray = Array<String>()
|
||||||
@ -140,7 +149,7 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
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
|
||||||
add(tileSetSelectBox).pad(10f).row()
|
innerTable.add(tileSetSelectBox).pad(10f).row()
|
||||||
|
|
||||||
tileSetSelectBox.addListener(object : ChangeListener() {
|
tileSetSelectBox.addListener(object : ChangeListener() {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
@ -153,8 +162,8 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addAutosaveTurnsSelectBox() {
|
private fun addAutosaveTurnsSelectBox(innerTable: PopupTable) {
|
||||||
add("Turns between autosaves".toLabel())
|
innerTable.add("Turns between autosaves".toLabel())
|
||||||
|
|
||||||
val autosaveTurnsSelectBox = SelectBox<Int>(skin)
|
val autosaveTurnsSelectBox = SelectBox<Int>(skin)
|
||||||
val autosaveTurnsArray = Array<Int>()
|
val autosaveTurnsArray = Array<Int>()
|
||||||
@ -162,7 +171,7 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
autosaveTurnsSelectBox.items = autosaveTurnsArray
|
autosaveTurnsSelectBox.items = autosaveTurnsArray
|
||||||
autosaveTurnsSelectBox.selected = UnCivGame.Current.settings.turnsBetweenAutosaves
|
autosaveTurnsSelectBox.selected = UnCivGame.Current.settings.turnsBetweenAutosaves
|
||||||
|
|
||||||
add(autosaveTurnsSelectBox).pad(10f).row()
|
innerTable.add(autosaveTurnsSelectBox).pad(10f).row()
|
||||||
|
|
||||||
autosaveTurnsSelectBox.addListener(object : ChangeListener() {
|
autosaveTurnsSelectBox.addListener(object : ChangeListener() {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
@ -173,15 +182,15 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addLanguageSelectBox() {
|
private fun addLanguageSelectBox(innerTable: PopupTable) {
|
||||||
add("Language".toLabel())
|
innerTable.add("Language".toLabel())
|
||||||
val languageSelectBox = SelectBox<Language>(skin)
|
val languageSelectBox = SelectBox<Language>(skin)
|
||||||
val languageArray = Array<Language>()
|
val languageArray = Array<Language>()
|
||||||
GameBasics.Translations.getLanguages().map { Language(it) }.sortedByDescending { it.percentComplete }
|
GameBasics.Translations.getLanguages().map { Language(it) }.sortedByDescending { it.percentComplete }
|
||||||
.forEach { languageArray.add(it) }
|
.forEach { languageArray.add(it) }
|
||||||
languageSelectBox.items = languageArray
|
languageSelectBox.items = languageArray
|
||||||
languageSelectBox.selected = languageArray.first { it.language == UnCivGame.Current.settings.language }
|
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() {
|
languageSelectBox.addListener(object : ChangeListener() {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
@ -211,14 +220,14 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (languageSelectBox.selected.percentComplete != 100) {
|
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 missingTextSelectBox = SelectBox<String>(skin)
|
||||||
val missingTextArray = Array<String>()
|
val missingTextArray = Array<String>()
|
||||||
val currentLanguage = UnCivGame.Current.settings.language
|
val currentLanguage = UnCivGame.Current.settings.language
|
||||||
GameBasics.Translations.filter { !it.value.containsKey(currentLanguage) }.forEach { missingTextArray.add(it.key) }
|
GameBasics.Translations.filter { !it.value.containsKey(currentLanguage) }.forEach { missingTextArray.add(it.key) }
|
||||||
missingTextSelectBox.items = missingTextArray
|
missingTextSelectBox.items = missingTextArray
|
||||||
missingTextSelectBox.selected = "Untranslated texts"
|
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