give user the option to (attempt) keep or discard states when changing state history settings

This commit is contained in:
SuuperW 2020-08-24 18:31:22 -05:00
parent 4b6ff639ac
commit 6b63db80e2
4 changed files with 18 additions and 10 deletions

View File

@ -1,6 +1,6 @@
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
partial class DefaultGreenzoneSettings partial class GreenzoneSettings
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@ -5,24 +5,31 @@ using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class DefaultGreenzoneSettings : Form public partial class GreenzoneSettings : Form
{ {
private readonly Action<ZwinderStateManagerSettings> _saveSettings; private readonly Action<ZwinderStateManagerSettings, bool> _saveSettings;
private ZwinderStateManagerSettings _settings; private ZwinderStateManagerSettings _settings;
private readonly bool _isDefault;
public DefaultGreenzoneSettings(ZwinderStateManagerSettings settings, Action<ZwinderStateManagerSettings> saveSettings) public GreenzoneSettings(ZwinderStateManagerSettings settings, Action<ZwinderStateManagerSettings, bool> saveSettings, bool isDefault)
{ {
InitializeComponent(); InitializeComponent();
Icon = Properties.Resources.TAStudioIcon; Icon = Properties.Resources.TAStudioIcon;
_saveSettings = saveSettings; _saveSettings = saveSettings;
_settings = settings; _settings = settings;
_isDefault = isDefault;
if (!isDefault)
Text = "Savestate History Settings";
SettingsPropertyGrid.SelectedObject = _settings; SettingsPropertyGrid.SelectedObject = _settings;
} }
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
_saveSettings(_settings); bool keep = false;
if (!_isDefault)
keep = (MessageBox.Show("Attempt to keep old states?", "Keep old states?", MessageBoxButtons.YesNo) == DialogResult.Yes);
_saveSettings(_settings, keep);
Close(); Close();
} }

View File

@ -998,12 +998,12 @@ namespace BizHawk.Client.EmuHawk
private void StateHistorySettingsMenuItem_Click(object sender, EventArgs e) private void StateHistorySettingsMenuItem_Click(object sender, EventArgs e)
{ {
new DefaultGreenzoneSettings( new GreenzoneSettings(
new ZwinderStateManagerSettings(CurrentTasMovie.TasStateManager.Settings), new ZwinderStateManagerSettings(CurrentTasMovie.TasStateManager.Settings),
s => { CurrentTasMovie.TasStateManager.UpdateSettings(s, true); }) (s, k) => { CurrentTasMovie.TasStateManager.UpdateSettings(s, k); },
false)
{ {
Location = this.ChildPointToScreen(TasView), Location = this.ChildPointToScreen(TasView),
Text = "Savestate History Settings",
Owner = Owner Owner = Owner
}.ShowDialog(); }.ShowDialog();
} }
@ -1022,9 +1022,10 @@ namespace BizHawk.Client.EmuHawk
private void DefaultStateSettingsMenuItem_Click(object sender, EventArgs e) private void DefaultStateSettingsMenuItem_Click(object sender, EventArgs e)
{ {
new DefaultGreenzoneSettings( new GreenzoneSettings(
new ZwinderStateManagerSettings(Config.Movies.DefaultTasStateManagerSettings), new ZwinderStateManagerSettings(Config.Movies.DefaultTasStateManagerSettings),
s => { Config.Movies.DefaultTasStateManagerSettings = s; }) (s, k) => { Config.Movies.DefaultTasStateManagerSettings = s; },
true)
{ {
Location = this.ChildPointToScreen(TasView), Location = this.ChildPointToScreen(TasView),
Owner = Owner Owner = Owner