mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 02:09:21 +07:00
Save settings when closing the options popup (#8961)
This commit is contained in:
@ -116,7 +116,6 @@ private fun addAutosaveTurnsSelectBox(table: Table, settings: GameSettings) {
|
|||||||
|
|
||||||
autosaveTurnsSelectBox.onChange {
|
autosaveTurnsSelectBox.onChange {
|
||||||
settings.turnsBetweenAutosaves = autosaveTurnsSelectBox.selected
|
settings.turnsBetweenAutosaves = autosaveTurnsSelectBox.selected
|
||||||
settings.save()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +206,6 @@ private fun addFontSizeMultiplier(
|
|||||||
initial = settings.fontSizeMultiplier
|
initial = settings.fontSizeMultiplier
|
||||||
) {
|
) {
|
||||||
settings.fontSizeMultiplier = it
|
settings.fontSizeMultiplier = it
|
||||||
settings.save()
|
|
||||||
}
|
}
|
||||||
fontSizeSlider.onChange {
|
fontSizeSlider.onChange {
|
||||||
if (!fontSizeSlider.isDragging)
|
if (!fontSizeSlider.isDragging)
|
||||||
@ -223,7 +221,6 @@ private fun addMaxZoomSlider(table: Table, settings: GameSettings) {
|
|||||||
initial = settings.maxWorldZoomOut
|
initial = settings.maxWorldZoomOut
|
||||||
) {
|
) {
|
||||||
settings.maxWorldZoomOut = it
|
settings.maxWorldZoomOut = it
|
||||||
settings.save()
|
|
||||||
if (GUI.isWorldLoaded())
|
if (GUI.isWorldLoaded())
|
||||||
GUI.getMap().reloadMaxZoom()
|
GUI.getMap().reloadMaxZoom()
|
||||||
}
|
}
|
||||||
@ -333,7 +330,6 @@ private fun addSetUserId(table: Table, settings: GameSettings) {
|
|||||||
"Take user ID from clipboard"
|
"Take user ID from clipboard"
|
||||||
) {
|
) {
|
||||||
settings.multiplayer.userId = clipboardContents
|
settings.multiplayer.userId = clipboardContents
|
||||||
settings.save()
|
|
||||||
idSetLabel.setFontColor(Color.WHITE).setText("ID successfully set!".tr())
|
idSetLabel.setFontColor(Color.WHITE).setText("ID successfully set!".tr())
|
||||||
}.open(true)
|
}.open(true)
|
||||||
idSetLabel.isVisible = true
|
idSetLabel.isVisible = true
|
||||||
|
@ -114,7 +114,6 @@ private fun addMinimapSizeSlider(table: Table, settings: GameSettings, selectBox
|
|||||||
settings.showMinimap = true
|
settings.showMinimap = true
|
||||||
settings.minimapSize = size
|
settings.minimapSize = size
|
||||||
}
|
}
|
||||||
settings.save()
|
|
||||||
val worldScreen = GUI.getWorldScreenIfActive()
|
val worldScreen = GUI.getWorldScreenIfActive()
|
||||||
if (worldScreen != null)
|
if (worldScreen != null)
|
||||||
GUI.setUpdateWorldOnNextRender()
|
GUI.setUpdateWorldOnNextRender()
|
||||||
@ -131,7 +130,6 @@ private fun addUnitIconAlphaSlider(table: Table, settings: GameSettings, selectB
|
|||||||
0f, 1f, 0.1f, initial = settings.unitIconOpacity, getTipText = getTipText
|
0f, 1f, 0.1f, initial = settings.unitIconOpacity, getTipText = getTipText
|
||||||
) {
|
) {
|
||||||
settings.unitIconOpacity = it
|
settings.unitIconOpacity = it
|
||||||
settings.save()
|
|
||||||
|
|
||||||
val worldScreen = UncivGame.Current.getWorldScreenIfActive()
|
val worldScreen = UncivGame.Current.getWorldScreenIfActive()
|
||||||
if (worldScreen != null)
|
if (worldScreen != null)
|
||||||
@ -246,7 +244,6 @@ private fun addResetTutorials(table: Table, settings: GameSettings) {
|
|||||||
) {
|
) {
|
||||||
settings.tutorialsShown.clear()
|
settings.tutorialsShown.clear()
|
||||||
settings.tutorialTasksCompleted.clear()
|
settings.tutorialTasksCompleted.clear()
|
||||||
settings.save()
|
|
||||||
resetTutorialsButton.setText("Done!".tr())
|
resetTutorialsButton.setText("Done!".tr())
|
||||||
resetTutorialsButton.clearListeners()
|
resetTutorialsButton.clearListeners()
|
||||||
}.open(true)
|
}.open(true)
|
||||||
|
@ -61,7 +61,6 @@ private fun addNotificationLogMaxTurnsSlider(
|
|||||||
) {
|
) {
|
||||||
val turns = it.toInt()
|
val turns = it.toInt()
|
||||||
settings.notificationsLogMaxTurns = turns
|
settings.notificationsLogMaxTurns = turns
|
||||||
settings.save()
|
|
||||||
}
|
}
|
||||||
table.add(minimapSlider).minWidth(selectBoxMinWidth).pad(10f).row()
|
table.add(minimapSlider).minWidth(selectBoxMinWidth).pad(10f).row()
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,6 @@ private fun addMultiplayerServerOptions(
|
|||||||
} else {
|
} else {
|
||||||
settings.multiplayer.server = multiplayerServerTextField.text
|
settings.multiplayer.server = multiplayerServerTextField.text
|
||||||
}
|
}
|
||||||
settings.save()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
serverIpTable.add(multiplayerServerTextField)
|
serverIpTable.add(multiplayerServerTextField)
|
||||||
@ -174,7 +173,6 @@ private fun addMultiplayerServerOptions(
|
|||||||
serverIpTable.add("Reset to Dropbox".toTextButton().onClick {
|
serverIpTable.add("Reset to Dropbox".toTextButton().onClick {
|
||||||
multiplayerServerTextField.text = Constants.dropboxMultiplayerServer
|
multiplayerServerTextField.text = Constants.dropboxMultiplayerServer
|
||||||
for (refreshSelect in toUpdate) refreshSelect.update(false)
|
for (refreshSelect in toUpdate) refreshSelect.update(false)
|
||||||
settings.save()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
serverIpTable.add(connectionToServerButton.onClick {
|
serverIpTable.add(connectionToServerButton.onClick {
|
||||||
|
@ -118,6 +118,7 @@ class OptionsPopup(
|
|||||||
screen.game.musicController.onChange(null)
|
screen.game.musicController.onChange(null)
|
||||||
center(screen.stage)
|
center(screen.stage)
|
||||||
keyBindingsTab?.save()
|
keyBindingsTab?.save()
|
||||||
|
settings.save()
|
||||||
onClose()
|
onClose()
|
||||||
}.padBottom(10f)
|
}.padBottom(10f)
|
||||||
|
|
||||||
@ -139,7 +140,6 @@ class OptionsPopup(
|
|||||||
/** Reload this Popup after major changes (resolution, tileset, language, font) */
|
/** Reload this Popup after major changes (resolution, tileset, language, font) */
|
||||||
private fun reloadWorldAndOptions() {
|
private fun reloadWorldAndOptions() {
|
||||||
Concurrency.run("Reload from options") {
|
Concurrency.run("Reload from options") {
|
||||||
settings.save()
|
|
||||||
withGLContext {
|
withGLContext {
|
||||||
// We have to run setSkin before the screen is rebuild else changing skins
|
// We have to run setSkin before the screen is rebuild else changing skins
|
||||||
// would only load the new SkinConfig after the next rebuild
|
// 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)) {
|
fun addCheckbox(table: Table, text: String, initialState: Boolean, updateWorld: Boolean = false, newRow: Boolean = true, action: ((Boolean) -> Unit)) {
|
||||||
val checkbox = text.toCheckBox(initialState) {
|
val checkbox = text.toCheckBox(initialState) {
|
||||||
action(it)
|
action(it)
|
||||||
settings.save()
|
|
||||||
val worldScreen = GUI.getWorldScreenIfActive()
|
val worldScreen = GUI.getWorldScreenIfActive()
|
||||||
if (updateWorld && worldScreen != null) worldScreen.shouldUpdate = true
|
if (updateWorld && worldScreen != null) worldScreen.shouldUpdate = true
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,6 @@ open class SettingsSelect<T : Any>(
|
|||||||
val newValue = selectBox.selected.value
|
val newValue = selectBox.selected.value
|
||||||
settingsProperty.set(newValue)
|
settingsProperty.set(newValue)
|
||||||
sendChangeEvent(newValue)
|
sendChangeEvent(newValue)
|
||||||
settings.save()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectBox
|
return selectBox
|
||||||
|
@ -90,7 +90,6 @@ private fun addSoundEffectsVolumeSlider(table: Table, settings: GameSettings) {
|
|||||||
getTipText = UncivSlider::formatPercent
|
getTipText = UncivSlider::formatPercent
|
||||||
) {
|
) {
|
||||||
settings.soundEffectsVolume = it
|
settings.soundEffectsVolume = it
|
||||||
settings.save()
|
|
||||||
}
|
}
|
||||||
table.add(soundEffectsVolumeSlider).pad(5f).row()
|
table.add(soundEffectsVolumeSlider).pad(5f).row()
|
||||||
}
|
}
|
||||||
@ -104,7 +103,6 @@ private fun addCitySoundsVolumeSlider(table: Table, settings: GameSettings) {
|
|||||||
getTipText = UncivSlider::formatPercent
|
getTipText = UncivSlider::formatPercent
|
||||||
) {
|
) {
|
||||||
settings.citySoundsVolume = it
|
settings.citySoundsVolume = it
|
||||||
settings.save()
|
|
||||||
}
|
}
|
||||||
table.add(citySoundVolumeSlider).pad(5f).row()
|
table.add(citySoundVolumeSlider).pad(5f).row()
|
||||||
}
|
}
|
||||||
@ -119,7 +117,6 @@ fun addMusicVolumeSlider(table: Table, settings: GameSettings, music: MusicContr
|
|||||||
getTipText = UncivSlider::formatPercent
|
getTipText = UncivSlider::formatPercent
|
||||||
) {
|
) {
|
||||||
settings.musicVolume = it
|
settings.musicVolume = it
|
||||||
settings.save()
|
|
||||||
|
|
||||||
music.setVolume(it)
|
music.setVolume(it)
|
||||||
if (!music.isPlaying())
|
if (!music.isPlaying())
|
||||||
|
Reference in New Issue
Block a user