From b80928bd959a2225ef420a5d836c6ef52d6819da Mon Sep 17 00:00:00 2001 From: Ivaylo Draganov Date: Fri, 24 Jan 2020 23:04:09 +0200 Subject: [PATCH] Display a confirmation prompt on settings panel reset --- .../Widgets/Logic/SettingsLogic.cs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 8bde502437..19b927058a 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -65,6 +65,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic panelContainer = widget.Get("SETTINGS_PANEL"); tabContainer = widget.Get("TAB_CONTAINER"); + var panelNames = new Dictionary() + { + { PanelType.Display, "Display" }, + { PanelType.Audio, "Audio" }, + { PanelType.Input, "Input" }, + { PanelType.Hotkeys, "Hotkeys" }, + { PanelType.Advanced, "Advanced" }, + }; + RegisterSettingsPanel(PanelType.Display, InitDisplayPanel, ResetDisplayPanel, "DISPLAY_PANEL", "DISPLAY_TAB"); RegisterSettingsPanel(PanelType.Audio, InitAudioPanel, ResetAudioPanel, "AUDIO_PANEL", "AUDIO_TAB"); RegisterSettingsPanel(PanelType.Input, InitInputPanel, ResetInputPanel, "INPUT_PANEL", "INPUT_TAB"); @@ -104,8 +113,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic panelContainer.Get("RESET_BUTTON").OnClick = () => { - resetPanelActions[settingsPanel](); - Game.Settings.Save(); + Action reset = () => + { + resetPanelActions[settingsPanel](); + Game.Settings.Save(); + }; + + ConfirmationDialogs.ButtonPrompt( + title: "Reset \"{0}\"".F(panelNames[settingsPanel]), + text: "Are you sure you want to reset\nall settings in this panel?", + onConfirm: reset, + onCancel: () => { }, + confirmText: "Reset", + cancelText: "Cancel"); }; }