Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display a confirmation prompt on settings panel reset #17617

Merged
merged 1 commit into from Jan 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 22 additions & 2 deletions OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs
Expand Up @@ -69,6 +69,15 @@ public SettingsLogic(Widget widget, Action onExit, ModData modData, WorldRendere
panelContainer = widget.Get("SETTINGS_PANEL");
tabContainer = widget.Get("TAB_CONTAINER");

var panelNames = new Dictionary<PanelType, string>()
{
{ 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");
Expand Down Expand Up @@ -110,8 +119,19 @@ public SettingsLogic(Widget widget, Action onExit, ModData modData, WorldRendere

panelContainer.Get<ButtonWidget>("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");
};
}

Expand Down