Save settings when closing the options popup (#8961)

This commit is contained in:
Gualdimar
2023-03-19 17:13:24 +02:00
committed by GitHub
parent 88d329a51d
commit 3820c5efa4
7 changed files with 1 additions and 16 deletions

View File

@ -116,7 +116,6 @@ private fun addAutosaveTurnsSelectBox(table: Table, settings: GameSettings) {
autosaveTurnsSelectBox.onChange {
settings.turnsBetweenAutosaves = autosaveTurnsSelectBox.selected
settings.save()
}
}
@ -207,7 +206,6 @@ private fun addFontSizeMultiplier(
initial = settings.fontSizeMultiplier
) {
settings.fontSizeMultiplier = it
settings.save()
}
fontSizeSlider.onChange {
if (!fontSizeSlider.isDragging)
@ -223,7 +221,6 @@ private fun addMaxZoomSlider(table: Table, settings: GameSettings) {
initial = settings.maxWorldZoomOut
) {
settings.maxWorldZoomOut = it
settings.save()
if (GUI.isWorldLoaded())
GUI.getMap().reloadMaxZoom()
}
@ -333,7 +330,6 @@ private fun addSetUserId(table: Table, settings: GameSettings) {
"Take user ID from clipboard"
) {
settings.multiplayer.userId = clipboardContents
settings.save()
idSetLabel.setFontColor(Color.WHITE).setText("ID successfully set!".tr())
}.open(true)
idSetLabel.isVisible = true

View File

@ -114,7 +114,6 @@ private fun addMinimapSizeSlider(table: Table, settings: GameSettings, selectBox
settings.showMinimap = true
settings.minimapSize = size
}
settings.save()
val worldScreen = GUI.getWorldScreenIfActive()
if (worldScreen != null)
GUI.setUpdateWorldOnNextRender()
@ -131,7 +130,6 @@ private fun addUnitIconAlphaSlider(table: Table, settings: GameSettings, selectB
0f, 1f, 0.1f, initial = settings.unitIconOpacity, getTipText = getTipText
) {
settings.unitIconOpacity = it
settings.save()
val worldScreen = UncivGame.Current.getWorldScreenIfActive()
if (worldScreen != null)
@ -246,7 +244,6 @@ private fun addResetTutorials(table: Table, settings: GameSettings) {
) {
settings.tutorialsShown.clear()
settings.tutorialTasksCompleted.clear()
settings.save()
resetTutorialsButton.setText("Done!".tr())
resetTutorialsButton.clearListeners()
}.open(true)

View File

@ -61,7 +61,6 @@ private fun addNotificationLogMaxTurnsSlider(
) {
val turns = it.toInt()
settings.notificationsLogMaxTurns = turns
settings.save()
}
table.add(minimapSlider).minWidth(selectBoxMinWidth).pad(10f).row()
}

View File

@ -164,7 +164,6 @@ private fun addMultiplayerServerOptions(
} else {
settings.multiplayer.server = multiplayerServerTextField.text
}
settings.save()
}
serverIpTable.add(multiplayerServerTextField)
@ -174,7 +173,6 @@ private fun addMultiplayerServerOptions(
serverIpTable.add("Reset to Dropbox".toTextButton().onClick {
multiplayerServerTextField.text = Constants.dropboxMultiplayerServer
for (refreshSelect in toUpdate) refreshSelect.update(false)
settings.save()
})
serverIpTable.add(connectionToServerButton.onClick {

View File

@ -118,6 +118,7 @@ class OptionsPopup(
screen.game.musicController.onChange(null)
center(screen.stage)
keyBindingsTab?.save()
settings.save()
onClose()
}.padBottom(10f)
@ -139,7 +140,6 @@ class OptionsPopup(
/** Reload this Popup after major changes (resolution, tileset, language, font) */
private fun reloadWorldAndOptions() {
Concurrency.run("Reload from options") {
settings.save()
withGLContext {
// We have to run setSkin before the screen is rebuild else changing skins
// would only load the new SkinConfig after the next rebuild
@ -162,7 +162,6 @@ class OptionsPopup(
fun addCheckbox(table: Table, text: String, initialState: Boolean, updateWorld: Boolean = false, newRow: Boolean = true, action: ((Boolean) -> Unit)) {
val checkbox = text.toCheckBox(initialState) {
action(it)
settings.save()
val worldScreen = GUI.getWorldScreenIfActive()
if (updateWorld && worldScreen != null) worldScreen.shouldUpdate = true
}

View File

@ -61,7 +61,6 @@ open class SettingsSelect<T : Any>(
val newValue = selectBox.selected.value
settingsProperty.set(newValue)
sendChangeEvent(newValue)
settings.save()
}
return selectBox

View File

@ -90,7 +90,6 @@ private fun addSoundEffectsVolumeSlider(table: Table, settings: GameSettings) {
getTipText = UncivSlider::formatPercent
) {
settings.soundEffectsVolume = it
settings.save()
}
table.add(soundEffectsVolumeSlider).pad(5f).row()
}
@ -104,7 +103,6 @@ private fun addCitySoundsVolumeSlider(table: Table, settings: GameSettings) {
getTipText = UncivSlider::formatPercent
) {
settings.citySoundsVolume = it
settings.save()
}
table.add(citySoundVolumeSlider).pad(5f).row()
}
@ -119,7 +117,6 @@ fun addMusicVolumeSlider(table: Table, settings: GameSettings, music: MusicContr
getTipText = UncivSlider::formatPercent
) {
settings.musicVolume = it
settings.save()
music.setVolume(it)
if (!music.isPlaying())