Fixes to ram watch and cheats closing events and restarting and asking to save changes, some of these are regressions from refactoring, some from the rewrite of these tools, and some have been this way since day 1

This commit is contained in:
adelikat 2013-11-05 16:37:05 +00:00
parent 2da8696b8d
commit 0a0487850d
3 changed files with 64 additions and 40 deletions

View File

@ -100,11 +100,18 @@ namespace BizHawk.Client.EmuHawk
Closing += (o, e) =>
{
Global.CheatList.SaveOnClose();
CloseGame();
Global.MovieSession.Movie.Stop();
GlobalWin.Tools.Close();
SaveConfig();
if (GlobalWin.Tools.AskSave())
{
Global.CheatList.SaveOnClose();
CloseGame();
Global.MovieSession.Movie.Stop();
GlobalWin.Tools.Close();
SaveConfig();
}
else
{
e.Cancel = true;
}
};
ResizeBegin += (o, e) =>
@ -3726,21 +3733,24 @@ namespace BizHawk.Client.EmuHawk
public void CloseROM(bool clearSRAM = false)
{
CloseGame(clearSRAM);
Global.CoreComm = new CoreComm();
CoreFileProvider.SyncCoreCommInputSignals();
Global.Emulator = new NullEmulator(Global.CoreComm);
Global.Game = GameInfo.GetNullGame();
if (GlobalWin.Tools.AskSave())
{
CloseGame(clearSRAM);
Global.CoreComm = new CoreComm();
CoreFileProvider.SyncCoreCommInputSignals();
Global.Emulator = new NullEmulator(Global.CoreComm);
Global.Game = GameInfo.GetNullGame();
GlobalWin.Tools.Restart();
GlobalWin.Tools.Restart();
RewireSound();
ResetRewindBuffer();
Cheats_Restart();
Text = "BizHawk" + (INTERIM ? " (interim) " : "");
HandlePlatformMenus();
StateSlots.Clear();
UpdateDumpIcon();
RewireSound();
ResetRewindBuffer();
Cheats_Restart();
Text = "BizHawk" + (INTERIM ? " (interim) " : "");
HandlePlatformMenus();
StateSlots.Clear();
UpdateDumpIcon();
}
}
private void SwapBackupSavestate(string path) //Move inside Saveslot Manager

View File

@ -51,7 +51,18 @@ namespace BizHawk.Client.EmuHawk
public Cheats()
{
InitializeComponent();
Closing += (o, e) => SaveConfigSettings();
Closing += (o, e) =>
{
if (AskSave())
{
SaveConfigSettings();
}
else
{
e.Cancel = true;
}
};
CheatListView.QueryItemText += CheatListView_QueryItemText;
CheatListView.QueryItemBkColor += CheatListView_QueryItemBkColor;
CheatListView.VirtualMode = true;
@ -75,15 +86,7 @@ namespace BizHawk.Client.EmuHawk
public void Restart()
{
if (!IsHandleCreated || IsDisposed)
{
return;
}
else
{
NewList();
ToggleGameGenieButton();
}
StartNewList();
}
private void UpdateListView()
@ -152,6 +155,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (result == DialogResult.No)
{
Global.CheatList.Changes = false;
return true;
}
else if (result == DialogResult.Cancel)
@ -545,6 +549,14 @@ namespace BizHawk.Client.EmuHawk
}
}
private void StartNewList()
{
Global.CheatList.NewList(GlobalWin.MainForm.GenerateDefaultCheatFilename());
UpdateListView();
UpdateMessageLabel();
ToggleGameGenieButton();
}
private void NewList()
{
bool result = true;
@ -555,9 +567,7 @@ namespace BizHawk.Client.EmuHawk
if (result)
{
Global.CheatList.NewList(GlobalWin.MainForm.GenerateDefaultCheatFilename());
UpdateListView();
UpdateMessageLabel();
StartNewList();
}
}

View File

@ -38,8 +38,18 @@ namespace BizHawk.Client.EmuHawk
WatchListView.QueryItemText += WatchListView_QueryItemText;
WatchListView.QueryItemBkColor += WatchListView_QueryItemBkColor;
WatchListView.VirtualMode = true;
Closing += (o, e) => SaveConfigSettings();
_sortedColumn = "";
Closing += (o, e) =>
{
if (AskSave())
{
SaveConfigSettings();
}
else
{
e.Cancel = true;
}
};
_sortedColumn = String.Empty;
_sortReverse = false;
TopMost = Global.Config.RamWatchAlwaysOnTop;
@ -169,6 +179,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (result == DialogResult.No)
{
Watches.Changes = false;
return true;
}
else if (result == DialogResult.Cancel)
@ -234,13 +245,6 @@ namespace BizHawk.Client.EmuHawk
}
}
protected override void OnClosing(CancelEventArgs e)
{
if (!AskSave())
e.Cancel = true;
base.OnClosing(e);
}
private int GetColumnWidth(string columnName)
{
var width = Global.Config.RamWatchColumnWidths[columnName];