From 3820c5efa432021c151ccb7efcea0acfe4a7fa3f Mon Sep 17 00:00:00 2001 From: Gualdimar Date: Sun, 19 Mar 2023 17:13:24 +0200 Subject: [PATCH] Save settings when closing the options popup (#8961) --- core/src/com/unciv/ui/popups/options/AdvancedTab.kt | 4 ---- core/src/com/unciv/ui/popups/options/DisplayTab.kt | 3 --- core/src/com/unciv/ui/popups/options/GameplayTab.kt | 1 - core/src/com/unciv/ui/popups/options/MultiplayerTab.kt | 2 -- core/src/com/unciv/ui/popups/options/OptionsPopup.kt | 3 +-- core/src/com/unciv/ui/popups/options/SettingsSelect.kt | 1 - core/src/com/unciv/ui/popups/options/SoundTab.kt | 3 --- 7 files changed, 1 insertion(+), 16 deletions(-) diff --git a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt index 57f48bdd3c..276642a2e5 100644 --- a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt +++ b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt @@ -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 diff --git a/core/src/com/unciv/ui/popups/options/DisplayTab.kt b/core/src/com/unciv/ui/popups/options/DisplayTab.kt index 2a02681d86..89773688ba 100644 --- a/core/src/com/unciv/ui/popups/options/DisplayTab.kt +++ b/core/src/com/unciv/ui/popups/options/DisplayTab.kt @@ -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) diff --git a/core/src/com/unciv/ui/popups/options/GameplayTab.kt b/core/src/com/unciv/ui/popups/options/GameplayTab.kt index 92d31875c1..f38665e786 100644 --- a/core/src/com/unciv/ui/popups/options/GameplayTab.kt +++ b/core/src/com/unciv/ui/popups/options/GameplayTab.kt @@ -61,7 +61,6 @@ private fun addNotificationLogMaxTurnsSlider( ) { val turns = it.toInt() settings.notificationsLogMaxTurns = turns - settings.save() } table.add(minimapSlider).minWidth(selectBoxMinWidth).pad(10f).row() } diff --git a/core/src/com/unciv/ui/popups/options/MultiplayerTab.kt b/core/src/com/unciv/ui/popups/options/MultiplayerTab.kt index 8a5742b416..bf6bb6f38f 100644 --- a/core/src/com/unciv/ui/popups/options/MultiplayerTab.kt +++ b/core/src/com/unciv/ui/popups/options/MultiplayerTab.kt @@ -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 { diff --git a/core/src/com/unciv/ui/popups/options/OptionsPopup.kt b/core/src/com/unciv/ui/popups/options/OptionsPopup.kt index a4fe82930b..aac80090aa 100644 --- a/core/src/com/unciv/ui/popups/options/OptionsPopup.kt +++ b/core/src/com/unciv/ui/popups/options/OptionsPopup.kt @@ -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 } diff --git a/core/src/com/unciv/ui/popups/options/SettingsSelect.kt b/core/src/com/unciv/ui/popups/options/SettingsSelect.kt index b178330a27..980b9cded5 100644 --- a/core/src/com/unciv/ui/popups/options/SettingsSelect.kt +++ b/core/src/com/unciv/ui/popups/options/SettingsSelect.kt @@ -61,7 +61,6 @@ open class SettingsSelect( val newValue = selectBox.selected.value settingsProperty.set(newValue) sendChangeEvent(newValue) - settings.save() } return selectBox diff --git a/core/src/com/unciv/ui/popups/options/SoundTab.kt b/core/src/com/unciv/ui/popups/options/SoundTab.kt index a172726ac1..6910dd3350 100644 --- a/core/src/com/unciv/ui/popups/options/SoundTab.kt +++ b/core/src/com/unciv/ui/popups/options/SoundTab.kt @@ -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())