More code refactoring
This commit is contained in:
parent
345b628dad
commit
720cf763cd
|
@ -85,14 +85,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public void UpdateDialog()
|
public void UpdateDialog()
|
||||||
{
|
{
|
||||||
CheatListView.ItemCount = Global.CheatList.Count;
|
CheatListView.ItemCount = Global.CheatList.Count;
|
||||||
TotalLabel.Text = Global.CheatList.CheatCount.ToString()
|
TotalLabel.Text = Global.CheatList.CheatCount
|
||||||
+ (Global.CheatList.CheatCount == 1 ? " cheat " : " cheats ")
|
+ (Global.CheatList.CheatCount == 1 ? " cheat " : " cheats ")
|
||||||
+ Global.CheatList.ActiveCount.ToString() + " active";
|
+ Global.CheatList.ActiveCount + " active";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFileFromRecent(string path)
|
public void LoadFileFromRecent(string path)
|
||||||
{
|
{
|
||||||
bool ask_result = true;
|
var ask_result = true;
|
||||||
if (Global.CheatList.Changes)
|
if (Global.CheatList.Changes)
|
||||||
{
|
{
|
||||||
ask_result = AskSave();
|
ask_result = AskSave();
|
||||||
|
@ -100,7 +100,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
if (ask_result)
|
if (ask_result)
|
||||||
{
|
{
|
||||||
bool load_result = Global.CheatList.Load(path, append: false);
|
var load_result = Global.CheatList.Load(path, append: false);
|
||||||
if (!load_result)
|
if (!load_result)
|
||||||
{
|
{
|
||||||
ToolHelpers.HandleLoadError(Global.Config.RecentWatches, path);
|
ToolHelpers.HandleLoadError(Global.Config.RecentWatches, path);
|
||||||
|
@ -140,7 +140,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (Global.CheatList.Changes)
|
if (Global.CheatList.Changes)
|
||||||
{
|
{
|
||||||
GlobalWin.Sound.StopSound();
|
GlobalWin.Sound.StopSound();
|
||||||
DialogResult result = MessageBox.Show("Save Changes?", "Cheats", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
var result = MessageBox.Show("Save Changes?", "Cheats", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||||||
GlobalWin.Sound.StartSound();
|
GlobalWin.Sound.StartSound();
|
||||||
if (result == DialogResult.Yes)
|
if (result == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
|
@ -160,11 +160,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadFile(FileInfo file, bool append)
|
private void LoadFile(FileSystemInfo file, bool append)
|
||||||
{
|
{
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
bool result = true;
|
var result = true;
|
||||||
if (Global.CheatList.Changes)
|
if (Global.CheatList.Changes)
|
||||||
{
|
{
|
||||||
result = AskSave();
|
result = AskSave();
|
||||||
|
@ -180,17 +180,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SaveAs()
|
private static bool SaveAs()
|
||||||
{
|
{
|
||||||
var file = ToolHelpers.GetCheatSaveFileFromUser(Global.CheatList.CurrentFileName);
|
var file = ToolHelpers.GetCheatSaveFileFromUser(Global.CheatList.CurrentFileName);
|
||||||
if (file != null)
|
return file != null && Global.CheatList.SaveFile(file.FullName);
|
||||||
{
|
|
||||||
return Global.CheatList.SaveFile(file.FullName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NewCheatForm_Load(object sender, EventArgs e)
|
private void NewCheatForm_Load(object sender, EventArgs e)
|
||||||
|
@ -281,7 +274,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string columnName = CheatListView.Columns[column].Name;
|
var columnName = CheatListView.Columns[column].Name;
|
||||||
|
|
||||||
switch (columnName)
|
switch (columnName)
|
||||||
{
|
{
|
||||||
|
@ -332,7 +325,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private IEnumerable<int> SelectedIndices
|
private IEnumerable<int> SelectedIndices
|
||||||
{
|
{
|
||||||
get { return CheatListView.SelectedIndices.Cast<int>().ToList(); }
|
get { return CheatListView.SelectedIndices.Cast<int>(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Cheat> SelectedItems
|
private IEnumerable<Cheat> SelectedItems
|
||||||
|
@ -342,7 +335,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private IEnumerable<Cheat> SelectedCheats
|
private IEnumerable<Cheat> SelectedCheats
|
||||||
{
|
{
|
||||||
get { return SelectedItems.Where(x => !x.IsSeparator).ToList(); }
|
get { return SelectedItems.Where(x => !x.IsSeparator); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveUp()
|
private void MoveUp()
|
||||||
|
@ -363,13 +356,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
UpdateMessageLabel();
|
UpdateMessageLabel();
|
||||||
|
|
||||||
var newindices = new List<int>();
|
var newindices = new List<int>();
|
||||||
for (int i = 0; i < indices.Count; i++)
|
for (var i = 0; i < indices.Count; i++)
|
||||||
{
|
{
|
||||||
newindices.Add(indices[i] - 1);
|
newindices.Add(indices[i] - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheatListView.SelectedIndices.Clear();
|
CheatListView.SelectedIndices.Clear();
|
||||||
foreach (int newi in newindices)
|
foreach (var newi in newindices)
|
||||||
{
|
{
|
||||||
CheatListView.SelectItem(newi, true);
|
CheatListView.SelectItem(newi, true);
|
||||||
}
|
}
|
||||||
|
@ -399,13 +392,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
UpdateMessageLabel();
|
UpdateMessageLabel();
|
||||||
|
|
||||||
var newindices = new List<int>();
|
var newindices = new List<int>();
|
||||||
for (int i = 0; i < indices.Count; i++)
|
for (var i = 0; i < indices.Count; i++)
|
||||||
{
|
{
|
||||||
newindices.Add(indices[i] + 1);
|
newindices.Add(indices[i] + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheatListView.SelectedIndices.Clear();
|
CheatListView.SelectedIndices.Clear();
|
||||||
foreach (int newi in newindices)
|
foreach (var newi in newindices)
|
||||||
{
|
{
|
||||||
CheatListView.SelectItem(newi, true);
|
CheatListView.SelectItem(newi, true);
|
||||||
}
|
}
|
||||||
|
@ -521,7 +514,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void NewList()
|
private void NewList()
|
||||||
{
|
{
|
||||||
bool result = true;
|
var result = true;
|
||||||
if (Global.CheatList.Changes)
|
if (Global.CheatList.Changes)
|
||||||
{
|
{
|
||||||
result = AskSave();
|
result = AskSave();
|
||||||
|
@ -535,9 +528,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public string GenerateDefaultCheatFilename()
|
public string GenerateDefaultCheatFilename()
|
||||||
{
|
{
|
||||||
PathEntry pathEntry = Global.Config.PathEntries[Global.Emulator.SystemId, "Cheats"] ??
|
var pathEntry = Global.Config.PathEntries[Global.Emulator.SystemId, "Cheats"] ??
|
||||||
Global.Config.PathEntries[Global.Emulator.SystemId, "Base"];
|
Global.Config.PathEntries[Global.Emulator.SystemId, "Base"];
|
||||||
string path = PathManager.MakeAbsolutePath(pathEntry.Path, Global.Emulator.SystemId);
|
var path = PathManager.MakeAbsolutePath(pathEntry.Path, Global.Emulator.SystemId);
|
||||||
|
|
||||||
var f = new FileInfo(path);
|
var f = new FileInfo(path);
|
||||||
if (f.Directory != null && f.Directory.Exists == false)
|
if (f.Directory != null && f.Directory.Exists == false)
|
||||||
|
@ -572,7 +565,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void OpenMenuItem_Click(object sender, EventArgs e)
|
private void OpenMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
bool append = sender == AppendMenuItem;
|
var append = sender == AppendMenuItem;
|
||||||
LoadFile(ToolHelpers.GetCheatFileFromUser(Global.CheatList.CurrentFileName), append);
|
LoadFile(ToolHelpers.GetCheatFileFromUser(Global.CheatList.CurrentFileName), append);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,7 +667,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void SelectAllMenuItem_Click(object sender, EventArgs e)
|
private void SelectAllMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Global.CheatList.Count; i++)
|
for (var i = 0; i < Global.CheatList.Count; i++)
|
||||||
{
|
{
|
||||||
CheatListView.SelectItem(i, true);
|
CheatListView.SelectItem(i, true);
|
||||||
}
|
}
|
||||||
|
@ -913,7 +906,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void NewCheatForm_DragDrop(object sender, DragEventArgs e)
|
private void NewCheatForm_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||||
if (Path.GetExtension(filePaths[0]) == (".cht"))
|
if (Path.GetExtension(filePaths[0]) == (".cht"))
|
||||||
{
|
{
|
||||||
LoadFile(new FileInfo(filePaths[0]), append: false);
|
LoadFile(new FileInfo(filePaths[0]), append: false);
|
||||||
|
|
|
@ -115,9 +115,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void StopAllScripts()
|
private void StopAllScripts()
|
||||||
{
|
{
|
||||||
foreach (LuaFile t in _luaList)
|
foreach (var file in _luaList)
|
||||||
{
|
{
|
||||||
t.Enabled = false;
|
file.Enabled = false;
|
||||||
}
|
}
|
||||||
Changes(true);
|
Changes(true);
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (LuaAlreadyInSession(path) == false)
|
if (LuaAlreadyInSession(path) == false)
|
||||||
{
|
{
|
||||||
LuaFile luaFile = new LuaFile(String.Empty, path);
|
var luaFile = new LuaFile(String.Empty, path);
|
||||||
_luaList.Add(luaFile);
|
_luaList.Add(luaFile);
|
||||||
LuaListView.ItemCount = _luaList.Count;
|
LuaListView.ItemCount = _luaList.Count;
|
||||||
LuaListView.Refresh();
|
LuaListView.Refresh();
|
||||||
|
@ -205,11 +205,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (LuaFile t in _luaList)
|
foreach (var file in _luaList)
|
||||||
{
|
{
|
||||||
if (path == t.Path && t.Enabled == false && !Global.Config.DisableLuaScriptsOnLoad)
|
if (path == file.Path && file.Enabled == false && !Global.Config.DisableLuaScriptsOnLoad)
|
||||||
{
|
{
|
||||||
t.Toggle();
|
file.Toggle();
|
||||||
RunLuaScripts();
|
RunLuaScripts();
|
||||||
LuaListView.Refresh();
|
LuaListView.Refresh();
|
||||||
Changes(true);
|
Changes(true);
|
||||||
|
@ -226,19 +226,19 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public void RunLuaScripts()
|
public void RunLuaScripts()
|
||||||
{
|
{
|
||||||
for (int x = 0; x < _luaList.Count; x++)
|
for (var i = 0; i < _luaList.Count; i++)
|
||||||
{
|
{
|
||||||
if (_luaList[x].Enabled && _luaList[x].Thread == null)
|
if (_luaList[i].Enabled && _luaList[i].Thread == null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_luaList[x].Thread = LuaImp.SpawnCoroutine(_luaList[x].Path);
|
_luaList[i].Thread = LuaImp.SpawnCoroutine(_luaList[i].Path);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (e.ToString().Substring(0, 32) == "LuaInterface.LuaScriptException:")
|
if (e.ToString().Substring(0, 32) == "LuaInterface.LuaScriptException:")
|
||||||
{
|
{
|
||||||
_luaList[x].Enabled = false;
|
_luaList[i].Enabled = false;
|
||||||
AddText(e.Message);
|
AddText(e.Message);
|
||||||
}
|
}
|
||||||
else MessageBox.Show(e.ToString());
|
else MessageBox.Show(e.ToString());
|
||||||
|
@ -246,24 +246,26 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StopScript(x);
|
StopScript(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateNumberOfScripts()
|
private void UpdateNumberOfScripts()
|
||||||
{
|
{
|
||||||
string message = "";
|
var message = String.Empty;
|
||||||
int active = 0, paused = 0, separators = 0;
|
int active = 0, paused = 0, separators = 0;
|
||||||
foreach (LuaFile t in _luaList)
|
foreach (var file in _luaList)
|
||||||
{
|
{
|
||||||
if (!t.IsSeparator)
|
if (!file.IsSeparator)
|
||||||
{
|
{
|
||||||
if (t.Enabled)
|
if (file.Enabled)
|
||||||
{
|
{
|
||||||
active++;
|
active++;
|
||||||
if (t.Paused)
|
if (file.Paused)
|
||||||
|
{
|
||||||
paused++;
|
paused++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -272,19 +274,19 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int L = _luaList.Count - separators;
|
var L = _luaList.Count - separators;
|
||||||
|
|
||||||
if (L == 1)
|
if (L == 1)
|
||||||
{
|
{
|
||||||
message += L.ToString() + " script (" + active.ToString() + " active, " + paused.ToString() + " paused)";
|
message += L + " script (" + active + " active, " + paused + " paused)";
|
||||||
}
|
}
|
||||||
else if (L == 0)
|
else if (L == 0)
|
||||||
{
|
{
|
||||||
message += L.ToString() + " script";
|
message += L + " script";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message += L.ToString() + " scripts (" + active.ToString() + " active, " + paused.ToString() + " paused)";
|
message += L + " scripts (" + active + " active, " + paused + " paused)";
|
||||||
}
|
}
|
||||||
|
|
||||||
NumberOfScripts.Text = message;
|
NumberOfScripts.Text = message;
|
||||||
|
@ -334,7 +336,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
StopAllScripts();
|
StopAllScripts();
|
||||||
_luaList = new List<LuaFile>();
|
_luaList = new List<LuaFile>();
|
||||||
|
|
||||||
using (StreamReader sr = file.OpenText())
|
using (var sr = file.OpenText())
|
||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
|
|
||||||
|
@ -349,19 +351,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string temp = s.Substring(0, 1);
|
var temp = s.Substring(0, 1);
|
||||||
|
|
||||||
bool enabled;
|
bool enabled;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (int.Parse(temp) == 0)
|
enabled = int.Parse(temp) != 0;
|
||||||
{
|
|
||||||
enabled = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
enabled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -370,12 +365,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
s = s.Substring(2, s.Length - 2); //Get path
|
s = s.Substring(2, s.Length - 2); //Get path
|
||||||
|
|
||||||
l = new LuaFile(s);
|
l = new LuaFile(s) {Enabled = !Global.Config.DisableLuaScriptsOnLoad && enabled};
|
||||||
|
|
||||||
if (!Global.Config.DisableLuaScriptsOnLoad)
|
|
||||||
l.Enabled = enabled;
|
|
||||||
else
|
|
||||||
l.Enabled = false;
|
|
||||||
}
|
}
|
||||||
_luaList.Add(l);
|
_luaList.Add(l);
|
||||||
}
|
}
|
||||||
|
@ -401,14 +391,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
foreach (var lf in _luaList)
|
foreach (var lf in _luaList)
|
||||||
{
|
{
|
||||||
//save old current directory before this lua thread clobbers it for the .net thread
|
//save old current directory before this lua thread clobbers it for the .net thread
|
||||||
string oldcd = Environment.CurrentDirectory;
|
var oldcd = Environment.CurrentDirectory;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//LuaImp.gui_clearGraphics();
|
//LuaImp.gui_clearGraphics();
|
||||||
if (lf.Enabled && lf.Thread != null && !(lf.Paused))
|
if (lf.Enabled && lf.Thread != null && !(lf.Paused))
|
||||||
{
|
{
|
||||||
bool prohibit = lf.FrameWaiting && !includeFrameWaiters;
|
var prohibit = lf.FrameWaiting && !includeFrameWaiters;
|
||||||
if (!prohibit)
|
if (!prohibit)
|
||||||
{
|
{
|
||||||
//restore this lua thread's preferred current directory
|
//restore this lua thread's preferred current directory
|
||||||
|
@ -521,10 +511,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void SaveSession(string path)
|
private void SaveSession(string path)
|
||||||
{
|
{
|
||||||
using (StreamWriter sw = new StreamWriter(path))
|
using (var sw = new StreamWriter(path))
|
||||||
{
|
{
|
||||||
string str = "";
|
var str = String.Empty;
|
||||||
foreach (LuaFile t in _luaList)
|
foreach (var t in _luaList)
|
||||||
{
|
{
|
||||||
if (!t.IsSeparator)
|
if (!t.IsSeparator)
|
||||||
{
|
{
|
||||||
|
@ -552,7 +542,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public void LoadSessionFromRecent(string path)
|
public void LoadSessionFromRecent(string path)
|
||||||
{
|
{
|
||||||
bool doload = true;
|
var doload = true;
|
||||||
if (_changes) doload = AskSave();
|
if (_changes) doload = AskSave();
|
||||||
|
|
||||||
if (doload)
|
if (doload)
|
||||||
|
@ -582,7 +572,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (_changes)
|
if (_changes)
|
||||||
{
|
{
|
||||||
GlobalWin.Sound.StopSound();
|
GlobalWin.Sound.StopSound();
|
||||||
DialogResult result = MessageBox.Show("Save changes to session?", "Lua Console", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
var result = MessageBox.Show("Save changes to session?", "Lua Console", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||||||
GlobalWin.Sound.StartSound();
|
GlobalWin.Sound.StartSound();
|
||||||
if (result == DialogResult.Yes)
|
if (result == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
|
@ -609,32 +599,17 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoLuaWriter()
|
private static void OpenLuaWriter(string path)
|
||||||
{
|
{
|
||||||
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
|
var writer = new LuaWriter {CurrentFile = path};
|
||||||
if (indexes.Count == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (indexes.Count > 0)
|
|
||||||
{
|
|
||||||
var item = _luaList[indexes[0]];
|
|
||||||
if (!item.IsSeparator)
|
|
||||||
{
|
|
||||||
OpenLuaWriter(_luaList[indexes[0]].Path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OpenLuaWriter(string path)
|
|
||||||
{
|
|
||||||
LuaWriter writer = new LuaWriter {CurrentFile = path};
|
|
||||||
writer.Show();
|
writer.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point GetPromptPoint()
|
private Point GetPromptPoint()
|
||||||
{
|
{
|
||||||
Point p = new Point(LuaListView.Location.X + 30, LuaListView.Location.Y + 30);
|
return PointToScreen(
|
||||||
return PointToScreen(p);
|
new Point(LuaListView.Location.X + 30, LuaListView.Location.Y + 30)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<int> SelectedIndices
|
private IEnumerable<int> SelectedIndices
|
||||||
|
@ -679,7 +654,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void NewSessionMenuItem_Click(object sender, EventArgs e)
|
private void NewSessionMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
bool result = !_changes || AskSave();
|
var result = !_changes || AskSave();
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
@ -771,7 +746,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void ToggleScriptMenuItem_Click(object sender, EventArgs e)
|
private void ToggleScriptMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
foreach(int index in SelectedIndices)
|
foreach(var index in SelectedIndices)
|
||||||
{
|
{
|
||||||
var item = _luaList[index];
|
var item = _luaList[index];
|
||||||
if (!item.IsSeparator)
|
if (!item.IsSeparator)
|
||||||
|
@ -859,7 +834,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int index in indices)
|
foreach (var index in indices)
|
||||||
{
|
{
|
||||||
var file = _luaList[index];
|
var file = _luaList[index];
|
||||||
_luaList.Remove(file);
|
_luaList.Remove(file);
|
||||||
|
@ -870,7 +845,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var newindices = indices.Select(t => t - 1).ToList();
|
var newindices = indices.Select(t => t - 1).ToList();
|
||||||
|
|
||||||
LuaListView.SelectedIndices.Clear();
|
LuaListView.SelectedIndices.Clear();
|
||||||
foreach (int newi in newindices)
|
foreach (var newi in newindices)
|
||||||
{
|
{
|
||||||
LuaListView.SelectItem(newi, true);
|
LuaListView.SelectItem(newi, true);
|
||||||
}
|
}
|
||||||
|
@ -886,7 +861,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int index in indices)
|
foreach (var index in indices)
|
||||||
{
|
{
|
||||||
var file = _luaList[index];
|
var file = _luaList[index];
|
||||||
_luaList.Remove(file);
|
_luaList.Remove(file);
|
||||||
|
@ -896,7 +871,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var newindices = indices.Select(t => t + 1).ToList();
|
var newindices = indices.Select(t => t + 1).ToList();
|
||||||
|
|
||||||
LuaListView.SelectedIndices.Clear();
|
LuaListView.SelectedIndices.Clear();
|
||||||
foreach (int newi in newindices)
|
foreach (var newi in newindices)
|
||||||
{
|
{
|
||||||
LuaListView.SelectItem(newi, true);
|
LuaListView.SelectItem(newi, true);
|
||||||
}
|
}
|
||||||
|
@ -906,9 +881,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void SelectAllMenuItem_Click(object sender, EventArgs e)
|
private void SelectAllMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < _luaList.Count; x++)
|
for (var i = 0; i < _luaList.Count; i++)
|
||||||
{
|
{
|
||||||
LuaListView.SelectItem(x, true);
|
LuaListView.SelectItem(i, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -921,7 +896,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (LuaImp.RegisteredFunctions.Any())
|
if (LuaImp.RegisteredFunctions.Any())
|
||||||
{
|
{
|
||||||
bool alreadyOpen = false;
|
var alreadyOpen = false;
|
||||||
foreach (Form form in Application.OpenForms)
|
foreach (Form form in Application.OpenForms)
|
||||||
{
|
{
|
||||||
if (form is LuaRegisteredFunctionsList)
|
if (form is LuaRegisteredFunctionsList)
|
||||||
|
@ -1000,7 +975,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (VersionInfo.INTERIM)
|
if (VersionInfo.INTERIM)
|
||||||
{
|
{
|
||||||
DoLuaWriter();
|
SelectedFiles.ToList().ForEach(x => OpenLuaWriter(x.Path));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1036,10 +1011,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void LuaConsole_DragDrop(object sender, DragEventArgs e)
|
private void LuaConsole_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (string path in filePaths)
|
foreach (var path in filePaths)
|
||||||
{
|
{
|
||||||
if (Path.GetExtension(path) == (".lua") || Path.GetExtension(path) == (".txt"))
|
if (Path.GetExtension(path) == (".lua") || Path.GetExtension(path) == (".txt"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -125,9 +125,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (string filename in recent)
|
foreach (var filename in recent)
|
||||||
{
|
{
|
||||||
string temp = filename;
|
var temp = filename;
|
||||||
var item = new ToolStripMenuItem { Text = temp };
|
var item = new ToolStripMenuItem { Text = temp };
|
||||||
item.Click += (o, ev) => loadFileCallback(temp);
|
item.Click += (o, ev) => loadFileCallback(temp);
|
||||||
items.Add(item);
|
items.Add(item);
|
||||||
|
@ -146,7 +146,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public static void HandleLoadError(RecentFiles recent, string path)
|
public static void HandleLoadError(RecentFiles recent, string path)
|
||||||
{
|
{
|
||||||
GlobalWin.Sound.StopSound();
|
GlobalWin.Sound.StopSound();
|
||||||
DialogResult result = MessageBox.Show("Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
|
var result = MessageBox.Show("Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
|
||||||
if (result == DialogResult.Yes)
|
if (result == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
recent.Remove(path);
|
recent.Remove(path);
|
||||||
|
@ -161,8 +161,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
foreach (var domain in Global.Emulator.MemoryDomains)
|
foreach (var domain in Global.Emulator.MemoryDomains)
|
||||||
{
|
{
|
||||||
string name = domain.Name;
|
var name = domain.Name;
|
||||||
|
|
||||||
var item = new ToolStripMenuItem { Text = name };
|
var item = new ToolStripMenuItem { Text = name };
|
||||||
item.Click += (o, ev) => setCallback(name);
|
item.Click += (o, ev) => setCallback(name);
|
||||||
item.Checked = name == selectedDomain;
|
item.Checked = name == selectedDomain;
|
||||||
|
@ -203,27 +202,21 @@ namespace BizHawk.Client.EmuHawk
|
||||||
GlobalWin.MainForm.UpdateCheatStatus();
|
GlobalWin.MainForm.UpdateCheatStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FreezeAddress(List<Watch> watches)
|
public static void FreezeAddress(IEnumerable<Watch> watches)
|
||||||
{
|
{
|
||||||
foreach(var watch in watches)
|
foreach (var watch in watches.Where(watch => !watch.IsSeparator))
|
||||||
{
|
{
|
||||||
if (!watch.IsSeparator)
|
Global.CheatList.Add(
|
||||||
{
|
new Cheat(watch, watch.Value ?? 0)
|
||||||
Global.CheatList.Add(
|
|
||||||
new Cheat(watch, watch.Value ?? 0)
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UnfreezeAddress(List<Watch> watches)
|
public static void UnfreezeAddress(IEnumerable<Watch> watches)
|
||||||
{
|
{
|
||||||
foreach (var watch in watches)
|
foreach (var watch in watches.Where(watch => !watch.IsSeparator))
|
||||||
{
|
{
|
||||||
if (!watch.IsSeparator)
|
Global.CheatList.Remove(watch);
|
||||||
{
|
|
||||||
Global.CheatList.Remove(watch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +233,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (listView.Columns[columnName] == null)
|
if (listView.Columns[columnName] == null)
|
||||||
{
|
{
|
||||||
ColumnHeader column = new ColumnHeader
|
var column = new ColumnHeader
|
||||||
{
|
{
|
||||||
Name = columnName,
|
Name = columnName,
|
||||||
Text = columnName.Replace("Column", ""),
|
Text = columnName.Replace("Column", ""),
|
||||||
|
|
|
@ -21,9 +21,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetWatch(List<Watch> watches)
|
public void SetWatch(IEnumerable<Watch> watches)
|
||||||
{
|
{
|
||||||
_watchList = watches;
|
_watchList = watches.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnSupportedConfiguration()
|
private void UnSupportedConfiguration()
|
||||||
|
@ -49,9 +49,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
if (_watchList.Count > 1)
|
if (_watchList.Count > 1)
|
||||||
{
|
{
|
||||||
bool hasMixedSizes = _watchList.Select(x => x.Size).Distinct().Count() > 1;
|
var hasMixedSizes = _watchList.Select(x => x.Size).Distinct().Count() > 1;
|
||||||
bool hasMixedTypes = _watchList.Select(x => x.Type).Distinct().Count() > 1;
|
var hasMixedTypes = _watchList.Select(x => x.Type).Distinct().Count() > 1;
|
||||||
bool hasMixedEndian = _watchList.Select(x => x.BigEndian).Distinct().Count() > 1;
|
var hasMixedEndian = _watchList.Select(x => x.BigEndian).Distinct().Count() > 1;
|
||||||
|
|
||||||
if (hasMixedSizes || hasMixedTypes || hasMixedEndian)
|
if (hasMixedSizes || hasMixedTypes || hasMixedEndian)
|
||||||
{
|
{
|
||||||
|
@ -85,23 +85,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void OK_Click(object sender, EventArgs e)
|
private void OK_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
bool success = true;
|
var success = true;
|
||||||
foreach (var watch in _watchList)
|
foreach (var watch in _watchList.Where(watch => !watch.Poke(ValueBox.Text)))
|
||||||
{
|
{
|
||||||
if (!watch.Poke(ValueBox.Text))
|
success = false;
|
||||||
{
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success)
|
OutputLabel.Text = success ? "Value successfully written."
|
||||||
{
|
: "An error occured when writing Value.";
|
||||||
OutputLabel.Text = "Value successfully written.";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OutputLabel.Text = "An error occured when writing Value.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,14 +29,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private string _sortedColumn = String.Empty;
|
private string _sortedColumn = String.Empty;
|
||||||
private bool _sortReverse;
|
private bool _sortReverse;
|
||||||
|
|
||||||
private readonly WatchList Watches = new WatchList(Global.Emulator.MemoryDomains.MainMemory);
|
private readonly WatchList _watches = new WatchList(Global.Emulator.MemoryDomains.MainMemory);
|
||||||
|
|
||||||
#region API
|
#region API
|
||||||
|
|
||||||
public void AddWatch(Watch watch)
|
public void AddWatch(Watch watch)
|
||||||
{
|
{
|
||||||
Watches.Add(watch);
|
_watches.Add(watch);
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
UpdateValues();
|
UpdateValues();
|
||||||
UpdateWatchCount();
|
UpdateWatchCount();
|
||||||
Changes();
|
Changes();
|
||||||
|
@ -49,18 +49,18 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Watches.Changes)
|
if (_watches.Changes)
|
||||||
{
|
{
|
||||||
GlobalWin.Sound.StopSound();
|
GlobalWin.Sound.StopSound();
|
||||||
DialogResult result = MessageBox.Show("Save Changes?", "Ram Watch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
var result = MessageBox.Show("Save Changes?", "Ram Watch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||||||
GlobalWin.Sound.StartSound();
|
GlobalWin.Sound.StartSound();
|
||||||
if (result == DialogResult.Yes)
|
if (result == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
Watches.Save();
|
_watches.Save();
|
||||||
}
|
}
|
||||||
else if (result == DialogResult.No)
|
else if (result == DialogResult.No)
|
||||||
{
|
{
|
||||||
Watches.Changes = false;
|
_watches.Changes = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (result == DialogResult.Cancel)
|
else if (result == DialogResult.Cancel)
|
||||||
|
@ -76,21 +76,21 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Watches.Where(x => !x.IsSeparator).Select(x => x.Address ?? 0).ToList();
|
return _watches.Where(x => !x.IsSeparator).Select(x => x.Address ?? 0).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFileFromRecent(string path)
|
public void LoadFileFromRecent(string path)
|
||||||
{
|
{
|
||||||
bool ask_result = true;
|
var ask_result = true;
|
||||||
if (Watches.Changes)
|
if (_watches.Changes)
|
||||||
{
|
{
|
||||||
ask_result = AskSave();
|
ask_result = AskSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ask_result)
|
if (ask_result)
|
||||||
{
|
{
|
||||||
bool load_result = Watches.Load(path, append: false);
|
var load_result = _watches.Load(path, append: false);
|
||||||
if (!load_result)
|
if (!load_result)
|
||||||
{
|
{
|
||||||
ToolHelpers.HandleLoadError(Global.Config.RecentWatches, path);
|
ToolHelpers.HandleLoadError(Global.Config.RecentWatches, path);
|
||||||
|
@ -98,10 +98,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Global.Config.RecentWatches.Add(path);
|
Global.Config.RecentWatches.Add(path);
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
UpdateWatchCount();
|
UpdateWatchCount();
|
||||||
UpdateMessageLabel();
|
UpdateMessageLabel();
|
||||||
Watches.Changes = false;
|
_watches.Changes = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,20 +110,20 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
bool result = true;
|
var result = true;
|
||||||
if (Watches.Changes)
|
if (_watches.Changes)
|
||||||
{
|
{
|
||||||
result = AskSave();
|
result = AskSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
Watches.Load(file.FullName, append);
|
_watches.Load(file.FullName, append);
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
UpdateMessageLabel();
|
UpdateMessageLabel();
|
||||||
UpdateWatchCount();
|
UpdateWatchCount();
|
||||||
Global.Config.RecentWatches.Add(Watches.CurrentFileName);
|
Global.Config.RecentWatches.Add(_watches.CurrentFileName);
|
||||||
SetMemoryDomain(Watches.Domain.ToString());
|
SetMemoryDomain(_watches.Domain.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,9 +158,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrWhiteSpace(Watches.CurrentFileName))
|
if (!String.IsNullOrWhiteSpace(_watches.CurrentFileName))
|
||||||
{
|
{
|
||||||
Watches.Reload();
|
_watches.Reload();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -177,17 +177,17 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Watches.Any())
|
if (_watches.Any())
|
||||||
{
|
{
|
||||||
Watches.UpdateValues();
|
_watches.UpdateValues();
|
||||||
|
|
||||||
if (Global.Config.DisplayRamWatch)
|
if (Global.Config.DisplayRamWatch)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < Watches.Count; x++)
|
for (var x = 0; x < _watches.Count; x++)
|
||||||
{
|
{
|
||||||
bool alert = !Watches[x].IsSeparator && Global.CheatList.IsActive(Watches[x].Domain, (Watches[x].Address ?? 0));
|
var alert = !_watches[x].IsSeparator && Global.CheatList.IsActive(_watches[x].Domain, (_watches[x].Address ?? 0));
|
||||||
GlobalWin.OSD.AddGUIText(
|
GlobalWin.OSD.AddGUIText(
|
||||||
Watches[x].ToString(),
|
_watches[x].ToString(),
|
||||||
Global.Config.DispRamWatchx,
|
Global.Config.DispRamWatchx,
|
||||||
(Global.Config.DispRamWatchy + (x * 14)),
|
(Global.Config.DispRamWatchy + (x * 14)),
|
||||||
alert,
|
alert,
|
||||||
|
@ -213,39 +213,38 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void AddNewWatch()
|
private void AddNewWatch()
|
||||||
{
|
{
|
||||||
WatchEditor we = new WatchEditor
|
var we = new WatchEditor
|
||||||
{
|
{
|
||||||
InitialLocation = GetPromptPoint()
|
InitialLocation = GetPromptPoint()
|
||||||
};
|
};
|
||||||
we.SetWatch(Watches.Domain);
|
we.SetWatch(_watches.Domain);
|
||||||
GlobalWin.Sound.StopSound();
|
GlobalWin.Sound.StopSound();
|
||||||
we.ShowDialog();
|
we.ShowDialog();
|
||||||
GlobalWin.Sound.StartSound();
|
GlobalWin.Sound.StartSound();
|
||||||
|
|
||||||
if (we.DialogResult == DialogResult.OK)
|
if (we.DialogResult == DialogResult.OK)
|
||||||
{
|
{
|
||||||
Watches.Add(we.Watches[0]);
|
_watches.Add(we.Watches[0]);
|
||||||
Changes();
|
Changes();
|
||||||
UpdateWatchCount();
|
UpdateWatchCount();
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
UpdateValues();
|
UpdateValues();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Changes()
|
private void Changes()
|
||||||
{
|
{
|
||||||
Watches.Changes = true;
|
_watches.Changes = true;
|
||||||
UpdateMessageLabel();
|
UpdateMessageLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ColumnPositions()
|
private void ColumnPositions()
|
||||||
{
|
{
|
||||||
List<KeyValuePair<string, int>> Columns =
|
var Columns = Global.Config.RamWatchColumnIndexes
|
||||||
Global.Config.RamWatchColumnIndexes
|
|
||||||
.Where(x => WatchListView.Columns.ContainsKey(x.Key))
|
.Where(x => WatchListView.Columns.ContainsKey(x.Key))
|
||||||
.OrderBy(x => x.Value).ToList();
|
.OrderBy(x => x.Value).ToList();
|
||||||
|
|
||||||
for (int i = 0; i < Columns.Count; i++)
|
for (var i = 0; i < Columns.Count; i++)
|
||||||
{
|
{
|
||||||
if (WatchListView.Columns.ContainsKey(Columns[i].Key))
|
if (WatchListView.Columns.ContainsKey(Columns[i].Key))
|
||||||
{
|
{
|
||||||
|
@ -256,12 +255,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void CopyWatchesToClipBoard()
|
private void CopyWatchesToClipBoard()
|
||||||
{
|
{
|
||||||
var indexes = WatchListView.SelectedIndices;
|
var indexes = SelectedIndices.ToList();
|
||||||
|
|
||||||
if (indexes.Count > 0)
|
if (indexes.Any())
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
foreach (int index in indexes)
|
foreach (var index in indexes)
|
||||||
{
|
{
|
||||||
foreach (ColumnHeader column in WatchListView.Columns)
|
foreach (ColumnHeader column in WatchListView.Columns)
|
||||||
{
|
{
|
||||||
|
@ -280,21 +279,19 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void EditWatch(bool duplicate = false)
|
private void EditWatch(bool duplicate = false)
|
||||||
{
|
{
|
||||||
var indexes = WatchListView.SelectedIndices;
|
var indexes = SelectedIndices.ToList();
|
||||||
|
|
||||||
if (indexes.Count > 0)
|
if (SelectedWatches.Any())
|
||||||
{
|
{
|
||||||
WatchEditor we = new WatchEditor
|
var we = new WatchEditor
|
||||||
{
|
{
|
||||||
InitialLocation = GetPromptPoint(),
|
InitialLocation = GetPromptPoint(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!SelectedWatches.Any())
|
we.SetWatch(_watches.Domain,
|
||||||
{
|
SelectedWatches, duplicate ? WatchEditor.Mode.Duplicate : WatchEditor.Mode.Edit
|
||||||
return;
|
);
|
||||||
}
|
|
||||||
|
|
||||||
we.SetWatch(Watches.Domain, SelectedWatches, duplicate ? WatchEditor.Mode.Duplicate : WatchEditor.Mode.Edit);
|
|
||||||
GlobalWin.Sound.StopSound();
|
GlobalWin.Sound.StopSound();
|
||||||
var result = we.ShowDialog();
|
var result = we.ShowDialog();
|
||||||
if (result == DialogResult.OK)
|
if (result == DialogResult.OK)
|
||||||
|
@ -302,14 +299,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Changes();
|
Changes();
|
||||||
if (duplicate)
|
if (duplicate)
|
||||||
{
|
{
|
||||||
Watches.AddRange(we.Watches);
|
_watches.AddRange(we.Watches);
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < we.Watches.Count; i++)
|
for (var i = 0; i < we.Watches.Count; i++)
|
||||||
{
|
{
|
||||||
Watches[indexes[i]] = we.Watches[i];
|
_watches[indexes[i]] = we.Watches[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,19 +323,19 @@ namespace BizHawk.Client.EmuHawk
|
||||||
default:
|
default:
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
case WatchList.ADDRESS:
|
case WatchList.ADDRESS:
|
||||||
return Watches[index].AddressString;
|
return _watches[index].AddressString;
|
||||||
case WatchList.VALUE:
|
case WatchList.VALUE:
|
||||||
return Watches[index].ValueString;
|
return _watches[index].ValueString;
|
||||||
case WatchList.PREV:
|
case WatchList.PREV:
|
||||||
return Watches[index].PreviousStr;
|
return _watches[index].PreviousStr;
|
||||||
case WatchList.CHANGES:
|
case WatchList.CHANGES:
|
||||||
return Watches[index].ChangeCount.ToString();
|
return _watches[index].ChangeCount.ToString();
|
||||||
case WatchList.DIFF:
|
case WatchList.DIFF:
|
||||||
return Watches[index].Diff;
|
return _watches[index].Diff;
|
||||||
case WatchList.DOMAIN:
|
case WatchList.DOMAIN:
|
||||||
return Watches[index].Domain.Name;
|
return _watches[index].Domain.Name;
|
||||||
case WatchList.NOTES:
|
case WatchList.NOTES:
|
||||||
return Watches[index].Notes;
|
return _watches[index].Notes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,16 +357,16 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void InsertSeparator()
|
private void InsertSeparator()
|
||||||
{
|
{
|
||||||
var indexes = WatchListView.SelectedIndices;
|
var indexes = SelectedIndices.ToList();
|
||||||
if (indexes.Count > 0)
|
if (indexes.Any())
|
||||||
{
|
{
|
||||||
Watches.Insert(indexes[0], SeparatorWatch.Instance);
|
_watches.Insert(indexes[0], SeparatorWatch.Instance);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Watches.Add(SeparatorWatch.Instance);
|
_watches.Add(SeparatorWatch.Instance);
|
||||||
}
|
}
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
Changes();
|
Changes();
|
||||||
UpdateWatchCount();
|
UpdateWatchCount();
|
||||||
}
|
}
|
||||||
|
@ -409,88 +406,76 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void MoveDown()
|
private void MoveDown()
|
||||||
{
|
{
|
||||||
var indexes = WatchListView.SelectedIndices;
|
var indexes = SelectedIndices.ToList();
|
||||||
if (indexes.Count == 0)
|
if (!indexes.Any())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int index in indexes)
|
foreach (var index in indexes)
|
||||||
{
|
{
|
||||||
var watch = Watches[index];
|
var watch = _watches[index];
|
||||||
|
|
||||||
if (index < Watches.Count - 1)
|
if (index < _watches.Count - 1)
|
||||||
{
|
{
|
||||||
Watches.Remove(Watches[index]);
|
_watches.Remove(_watches[index]);
|
||||||
Watches.Insert(index + 1, watch);
|
_watches.Insert(index + 1, watch);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Note: here it will get flagged many times redundantly potentially,
|
|
||||||
//but this avoids it being flagged falsely when the user did not select an index
|
|
||||||
Changes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var indices = new List<int>();
|
Changes();
|
||||||
for (int i = 0; i < indexes.Count; i++)
|
|
||||||
{
|
var indices = indexes.Select(t => t + 1).ToList();
|
||||||
indices.Add(indexes[i] + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
WatchListView.SelectedIndices.Clear();
|
WatchListView.SelectedIndices.Clear();
|
||||||
foreach (int t in indices)
|
foreach (var t in indices)
|
||||||
{
|
{
|
||||||
WatchListView.SelectItem(t, true);
|
WatchListView.SelectItem(t, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveUp()
|
private void MoveUp()
|
||||||
{
|
{
|
||||||
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
|
var indexes = SelectedIndices.ToList();
|
||||||
if (indexes.Count == 0 || indexes[0] == 0)
|
if (!indexes.Any() || indexes[0] == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int index in indexes)
|
foreach (var index in indexes)
|
||||||
{
|
{
|
||||||
var watch = Watches[index];
|
var watch = _watches[index];
|
||||||
Watches.Remove(Watches[index]);
|
_watches.Remove(_watches[index]);
|
||||||
Watches.Insert(index - 1, watch);
|
_watches.Insert(index - 1, watch);
|
||||||
|
|
||||||
//Note: here it will get flagged many times redundantly potentially,
|
|
||||||
//but this avoids it being flagged falsely when the user did not select an index
|
|
||||||
Changes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var indices = new List<int>();
|
Changes();
|
||||||
for (int i = 0; i < indexes.Count; i++)
|
|
||||||
{
|
var indices = indexes.Select(t => t - 1).ToList();
|
||||||
indices.Add(indexes[i] - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
WatchListView.SelectedIndices.Clear();
|
WatchListView.SelectedIndices.Clear();
|
||||||
foreach (int t in indices)
|
foreach (var t in indices)
|
||||||
{
|
{
|
||||||
WatchListView.SelectItem(t, true);
|
WatchListView.SelectItem(t, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NewWatchList(bool suppressAsk)
|
private void NewWatchList(bool suppressAsk)
|
||||||
{
|
{
|
||||||
bool result = true;
|
var result = true;
|
||||||
if (Watches.Changes)
|
if (_watches.Changes)
|
||||||
{
|
{
|
||||||
result = AskSave();
|
result = AskSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result || suppressAsk)
|
if (result || suppressAsk)
|
||||||
{
|
{
|
||||||
Watches.Clear();
|
_watches.Clear();
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
UpdateWatchCount();
|
UpdateWatchCount();
|
||||||
UpdateMessageLabel();
|
UpdateMessageLabel();
|
||||||
_sortReverse = false;
|
_sortReverse = false;
|
||||||
|
@ -506,7 +491,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_sortReverse = false;
|
_sortReverse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Watches.OrderWatches(column.Name, _sortReverse);
|
_watches.OrderWatches(column.Name, _sortReverse);
|
||||||
|
|
||||||
_sortedColumn = column.Name;
|
_sortedColumn = column.Name;
|
||||||
_sortReverse ^= true;
|
_sortReverse ^= true;
|
||||||
|
@ -517,7 +502,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
if (SelectedWatches.Any())
|
if (SelectedWatches.Any())
|
||||||
{
|
{
|
||||||
RamPoke poke = new RamPoke
|
var poke = new RamPoke
|
||||||
{
|
{
|
||||||
InitialLocation = GetPromptPoint()
|
InitialLocation = GetPromptPoint()
|
||||||
};
|
};
|
||||||
|
@ -539,27 +524,26 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void RemoveWatch()
|
private void RemoveWatch()
|
||||||
{
|
{
|
||||||
var indexes = WatchListView.SelectedIndices;
|
if (SelectedItems.Any())
|
||||||
if (indexes.Count > 0)
|
|
||||||
{
|
{
|
||||||
foreach (int index in indexes)
|
foreach (var item in SelectedItems)
|
||||||
{
|
{
|
||||||
Watches.Remove(Watches[indexes[0]]); //index[0] used since each iteration will make this the correct list index
|
_watches.Remove(item);
|
||||||
}
|
}
|
||||||
indexes.Clear();
|
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
|
UpdateValues();
|
||||||
|
UpdateWatchCount();
|
||||||
}
|
}
|
||||||
UpdateValues();
|
|
||||||
UpdateWatchCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveAs()
|
private void SaveAs()
|
||||||
{
|
{
|
||||||
bool result = Watches.SaveAs(ToolHelpers.GetWatchSaveFileFromUser(Watches.CurrentFileName));
|
var result = _watches.SaveAs(ToolHelpers.GetWatchSaveFileFromUser(_watches.CurrentFileName));
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
UpdateMessageLabel(saved: true);
|
UpdateMessageLabel(saved: true);
|
||||||
Global.Config.RecentWatches.Add(Watches.CurrentFileName);
|
Global.Config.RecentWatches.Add(_watches.CurrentFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,50 +603,51 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void SelectAll()
|
private void SelectAll()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Watches.Count; i++)
|
for (var i = 0; i < _watches.Count; i++)
|
||||||
{
|
{
|
||||||
WatchListView.SelectItem(i, true);
|
WatchListView.SelectItem(i, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Watch> SelectedWatches
|
private IEnumerable<int> SelectedIndices
|
||||||
{
|
{
|
||||||
get
|
get { return WatchListView.SelectedIndices.Cast<int>(); }
|
||||||
{
|
}
|
||||||
var selected = new List<Watch>();
|
|
||||||
ListView.SelectedIndexCollection indices = WatchListView.SelectedIndices;
|
private IEnumerable<Watch> SelectedItems
|
||||||
if (indices.Count > 0)
|
{
|
||||||
{
|
get { return SelectedIndices.Select(index => _watches[index]); }
|
||||||
selected.AddRange(from int index in indices where !Watches[index].IsSeparator select Watches[index]);
|
}
|
||||||
}
|
|
||||||
return selected;
|
private IEnumerable<Watch> SelectedWatches
|
||||||
}
|
{
|
||||||
|
get { return SelectedItems.Where(x => !x.IsSeparator); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetMemoryDomain(string name)
|
private void SetMemoryDomain(string name)
|
||||||
{
|
{
|
||||||
Watches.Domain = Global.Emulator.MemoryDomains[name];
|
_watches.Domain = Global.Emulator.MemoryDomains[name];
|
||||||
SetPlatformAndMemoryDomainLabel();
|
SetPlatformAndMemoryDomainLabel();
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetPlatformAndMemoryDomainLabel()
|
private void SetPlatformAndMemoryDomainLabel()
|
||||||
{
|
{
|
||||||
MemDomainLabel.Text = Global.Emulator.SystemId + " " + Watches.Domain.Name;
|
MemDomainLabel.Text = Global.Emulator.SystemId + " " + _watches.Domain.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateMessageLabel(bool saved = false)
|
private void UpdateMessageLabel(bool saved = false)
|
||||||
{
|
{
|
||||||
string message = String.Empty;
|
var message = String.Empty;
|
||||||
if (!String.IsNullOrWhiteSpace(Watches.CurrentFileName))
|
if (!String.IsNullOrWhiteSpace(_watches.CurrentFileName))
|
||||||
{
|
{
|
||||||
if (saved)
|
if (saved)
|
||||||
{
|
{
|
||||||
message = Path.GetFileName(Watches.CurrentFileName) + " saved.";
|
message = Path.GetFileName(_watches.CurrentFileName) + " saved.";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message = Path.GetFileName(Watches.CurrentFileName) + (Watches.Changes ? " *" : String.Empty);
|
message = Path.GetFileName(_watches.CurrentFileName) + (_watches.Changes ? " *" : String.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,23 +656,23 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void UpdateWatchCount()
|
private void UpdateWatchCount()
|
||||||
{
|
{
|
||||||
WatchCountLabel.Text = Watches.WatchCount.ToString() + (Watches.WatchCount == 1 ? " watch" : " watches");
|
WatchCountLabel.Text = _watches.WatchCount + (_watches.WatchCount == 1 ? " watch" : " watches");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WatchListView_QueryItemBkColor(int index, int column, ref Color color)
|
private void WatchListView_QueryItemBkColor(int index, int column, ref Color color)
|
||||||
{
|
{
|
||||||
if (index >= Watches.ItemCount)
|
if (index >= _watches.ItemCount)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column == 0)
|
if (column == 0)
|
||||||
{
|
{
|
||||||
if (Watches[index].IsSeparator)
|
if (_watches[index].IsSeparator)
|
||||||
{
|
{
|
||||||
color = BackColor;
|
color = BackColor;
|
||||||
}
|
}
|
||||||
else if (Global.CheatList.IsActive(Watches.Domain, Watches[index].Address ?? 0))
|
else if (Global.CheatList.IsActive(_watches.Domain, _watches[index].Address ?? 0))
|
||||||
{
|
{
|
||||||
color = Color.LightCyan;
|
color = Color.LightCyan;
|
||||||
}
|
}
|
||||||
|
@ -696,39 +681,39 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void WatchListView_QueryItemText(int index, int column, out string text)
|
private void WatchListView_QueryItemText(int index, int column, out string text)
|
||||||
{
|
{
|
||||||
text = "";
|
text = String.Empty;
|
||||||
|
|
||||||
if (index >= Watches.ItemCount || Watches[index].IsSeparator)
|
if (index >= _watches.ItemCount || _watches[index].IsSeparator)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string columnName = WatchListView.Columns[column].Name;
|
var columnName = WatchListView.Columns[column].Name;
|
||||||
|
|
||||||
switch (columnName)
|
switch (columnName)
|
||||||
{
|
{
|
||||||
case WatchList.ADDRESS:
|
case WatchList.ADDRESS:
|
||||||
text = Watches[index].AddressString;
|
text = _watches[index].AddressString;
|
||||||
break;
|
break;
|
||||||
case WatchList.VALUE:
|
case WatchList.VALUE:
|
||||||
text = Watches[index].ValueString;
|
text = _watches[index].ValueString;
|
||||||
break;
|
break;
|
||||||
case WatchList.PREV:
|
case WatchList.PREV:
|
||||||
text = Watches[index].PreviousStr;
|
text = _watches[index].PreviousStr;
|
||||||
break;
|
break;
|
||||||
case WatchList.CHANGES:
|
case WatchList.CHANGES:
|
||||||
if (!Watches[index].IsSeparator)
|
if (!_watches[index].IsSeparator)
|
||||||
{
|
{
|
||||||
text = Watches[index].ChangeCount.ToString();
|
text = _watches[index].ChangeCount.ToString();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WatchList.DIFF:
|
case WatchList.DIFF:
|
||||||
text = Watches[index].Diff;
|
text = _watches[index].Diff;
|
||||||
break;
|
break;
|
||||||
case WatchList.DOMAIN:
|
case WatchList.DOMAIN:
|
||||||
text = Watches[index].Domain.Name;
|
text = _watches[index].Domain.Name;
|
||||||
break;
|
break;
|
||||||
case WatchList.NOTES:
|
case WatchList.NOTES:
|
||||||
text = Watches[index].Notes;
|
text = _watches[index].Notes;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -754,11 +739,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void NewRamWatch_DragDrop(object sender, DragEventArgs e)
|
private void NewRamWatch_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||||
if (Path.GetExtension(filePaths[0]) == (".wch"))
|
if (Path.GetExtension(filePaths[0]) == (".wch"))
|
||||||
{
|
{
|
||||||
Watches.Load(filePaths[0], append:false);
|
_watches.Load(filePaths[0], append:false);
|
||||||
WatchListView.ItemCount = Watches.ItemCount;
|
WatchListView.ItemCount = _watches.ItemCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,7 +755,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
/*************File***********************/
|
/*************File***********************/
|
||||||
private void filesToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
private void filesToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
saveToolStripMenuItem.Enabled = Watches.Changes;
|
saveToolStripMenuItem.Enabled = _watches.Changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newListToolStripMenuItem_Click(object sender, EventArgs e)
|
private void newListToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -780,15 +765,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
bool append = sender == appendFileToolStripMenuItem;
|
var append = sender == appendFileToolStripMenuItem;
|
||||||
LoadWatchFile(ToolHelpers.GetWatchFileFromUser(Watches.CurrentFileName), append);
|
LoadWatchFile(ToolHelpers.GetWatchFileFromUser(_watches.CurrentFileName), append);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrWhiteSpace(Watches.CurrentFileName))
|
if (!String.IsNullOrWhiteSpace(_watches.CurrentFileName))
|
||||||
{
|
{
|
||||||
if (Watches.Save())
|
if (_watches.Save())
|
||||||
{
|
{
|
||||||
UpdateMessageLabel(saved: true);
|
UpdateMessageLabel(saved: true);
|
||||||
}
|
}
|
||||||
|
@ -830,33 +815,20 @@ namespace BizHawk.Client.EmuHawk
|
||||||
/*************Watches***********************/
|
/*************Watches***********************/
|
||||||
private void watchesToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
private void watchesToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
|
editWatchToolStripMenuItem.Enabled =
|
||||||
if (indexes.Count > 0)
|
duplicateWatchToolStripMenuItem.Enabled =
|
||||||
{
|
removeWatchToolStripMenuItem.Enabled =
|
||||||
editWatchToolStripMenuItem.Enabled = true;
|
moveUpToolStripMenuItem.Enabled =
|
||||||
duplicateWatchToolStripMenuItem.Enabled = true;
|
moveDownToolStripMenuItem.Enabled =
|
||||||
removeWatchToolStripMenuItem.Enabled = true;
|
pokeAddressToolStripMenuItem.Enabled =
|
||||||
moveUpToolStripMenuItem.Enabled = true;
|
freezeAddressToolStripMenuItem.Enabled =
|
||||||
moveDownToolStripMenuItem.Enabled = true;
|
SelectedIndices.Any();
|
||||||
pokeAddressToolStripMenuItem.Enabled = true;
|
|
||||||
freezeAddressToolStripMenuItem.Enabled = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
editWatchToolStripMenuItem.Enabled = false;
|
|
||||||
duplicateWatchToolStripMenuItem.Enabled = false;
|
|
||||||
removeWatchToolStripMenuItem.Enabled = false;
|
|
||||||
moveUpToolStripMenuItem.Enabled = false;
|
|
||||||
moveDownToolStripMenuItem.Enabled = false;
|
|
||||||
pokeAddressToolStripMenuItem.Enabled = false;
|
|
||||||
freezeAddressToolStripMenuItem.Enabled = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
memoryDomainsToolStripMenuItem.DropDownItems.Clear();
|
memoryDomainsToolStripMenuItem.DropDownItems.Clear();
|
||||||
memoryDomainsToolStripMenuItem.DropDownItems.AddRange(ToolHelpers.GenerateMemoryDomainMenuItems(SetMemoryDomain, Watches.Domain.Name).ToArray());
|
memoryDomainsToolStripMenuItem.DropDownItems.AddRange(ToolHelpers.GenerateMemoryDomainMenuItems(SetMemoryDomain, _watches.Domain.Name).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newWatchToolStripMenuItem_Click(object sender, EventArgs e)
|
private void newWatchToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -886,18 +858,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void freezeAddressToolStripMenuItem_Click(object sender, EventArgs e)
|
private void freezeAddressToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
bool allCheats = true;
|
var allCheats = SelectedWatches.All(watch => !Global.CheatList.IsActive(watch.Domain, watch.Address ?? 0));
|
||||||
foreach (var watch in SelectedWatches)
|
|
||||||
{
|
|
||||||
if (!watch.IsSeparator)
|
|
||||||
{
|
|
||||||
if (!Global.CheatList.IsActive(watch.Domain, watch.Address ?? 0))
|
|
||||||
{
|
|
||||||
allCheats = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allCheats)
|
if (allCheats)
|
||||||
{
|
{
|
||||||
ToolHelpers.UnfreezeAddress(SelectedWatches);
|
ToolHelpers.UnfreezeAddress(SelectedWatches);
|
||||||
|
@ -915,7 +876,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void clearChangeCountsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void clearChangeCountsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Watches.ClearChangeCounts();
|
_watches.ClearChangeCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveUpToolStripMenuItem_Click(object sender, EventArgs e)
|
private void moveUpToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -1082,7 +1043,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
/*************Context Menu***********************/
|
/*************Context Menu***********************/
|
||||||
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
|
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
|
||||||
{
|
{
|
||||||
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
|
var indexes = WatchListView.SelectedIndices;
|
||||||
|
|
||||||
EditContextMenuItem.Visible =
|
EditContextMenuItem.Visible =
|
||||||
RemoveContextMenuItem.Visible =
|
RemoveContextMenuItem.Visible =
|
||||||
DuplicateContextMenuItem.Visible =
|
DuplicateContextMenuItem.Visible =
|
||||||
|
@ -1097,17 +1059,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
indexes.Count > 0;
|
indexes.Count > 0;
|
||||||
|
|
||||||
|
|
||||||
bool allCheats = true;
|
var allCheats = _watches.All(x => Global.CheatList.IsActive(x.Domain, x.Address ?? 0));
|
||||||
foreach (int i in indexes)
|
|
||||||
{
|
|
||||||
if (!Watches[i].IsSeparator)
|
|
||||||
{
|
|
||||||
if (!Global.CheatList.IsActive(Watches[i].Domain, Watches[i].Address ?? 0))
|
|
||||||
{
|
|
||||||
allCheats = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allCheats)
|
if (allCheats)
|
||||||
{
|
{
|
||||||
|
@ -1127,7 +1079,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
UnfreezeAllContextMenuItem.Visible = Global.CheatList.ActiveCount > 0;
|
UnfreezeAllContextMenuItem.Visible = Global.CheatList.ActiveCount > 0;
|
||||||
|
|
||||||
ViewInHexEditorContextMenuItem.Visible = SelectedWatches.Count == 1;
|
ViewInHexEditorContextMenuItem.Visible = SelectedWatches.Count() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnfreezeAllContextMenuItem_Click(object sender, EventArgs e)
|
private void UnfreezeAllContextMenuItem_Click(object sender, EventArgs e)
|
||||||
|
@ -1137,7 +1089,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void ViewInHexEditorContextMenuItem_Click(object sender, EventArgs e)
|
private void ViewInHexEditorContextMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var selected = SelectedWatches;
|
var selected = SelectedWatches.ToList();
|
||||||
if (selected.Any())
|
if (selected.Any())
|
||||||
{
|
{
|
||||||
GlobalWin.Tools.Load<HexEditor>();
|
GlobalWin.Tools.Load<HexEditor>();
|
||||||
|
@ -1163,7 +1115,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else if (e.KeyCode == Keys.A && e.Control && !e.Alt && !e.Shift) //Select All
|
else if (e.KeyCode == Keys.A && e.Control && !e.Alt && !e.Shift) //Select All
|
||||||
{
|
{
|
||||||
for (int x = 0; x < Watches.Count; x++)
|
for (var x = 0; x < _watches.Count; x++)
|
||||||
{
|
{
|
||||||
WatchListView.SelectItem(x, true);
|
WatchListView.SelectItem(x, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetWatch(MemoryDomain domain, List<Watch> watches = null, Mode mode = Mode.New)
|
public void SetWatch(MemoryDomain domain, IEnumerable<Watch> watches = null, Mode mode = Mode.New)
|
||||||
{
|
{
|
||||||
if (watches != null)
|
if (watches != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue