Fix a bunch of crash issues with Ram Watch & Cheats related to having no list item selected. Implement Drag & drop for .cht & .wch files on Main form

This commit is contained in:
andres.delikat 2011-05-22 20:19:28 +00:00
parent 16d282a15d
commit 36a0580dca
6 changed files with 59 additions and 11 deletions

View File

@ -541,6 +541,18 @@ namespace BizHawk.MultiClient
} }
else if (Path.GetExtension(filePaths[0]).ToUpper() == ".STATE") else if (Path.GetExtension(filePaths[0]).ToUpper() == ".STATE")
LoadStateFile(filePaths[0], Path.GetFileName(filePaths[0])); LoadStateFile(filePaths[0], Path.GetFileName(filePaths[0]));
else if (Path.GetExtension(filePaths[0]).ToUpper() == ".CHT")
{
LoadCheatsWindow();
Cheats1.LoadCheatFile(filePaths[0], false);
Cheats1.DisplayCheatsList();
}
else if (Path.GetExtension(filePaths[0]).ToUpper() == ".WCH")
{
LoadRamWatch();
RamWatch1.LoadWatchFile(filePaths[0], false);
RamWatch1.DisplayWatchList();
}
else else
LoadRom(filePaths[0]); LoadRom(filePaths[0]);
} }

View File

@ -227,6 +227,7 @@
this.cheatsToolStripMenuItem.Name = "cheatsToolStripMenuItem"; this.cheatsToolStripMenuItem.Name = "cheatsToolStripMenuItem";
this.cheatsToolStripMenuItem.Size = new System.Drawing.Size(53, 20); this.cheatsToolStripMenuItem.Size = new System.Drawing.Size(53, 20);
this.cheatsToolStripMenuItem.Text = "&Cheats"; this.cheatsToolStripMenuItem.Text = "&Cheats";
this.cheatsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.cheatsToolStripMenuItem_DropDownOpened);
// //
// addCheatToolStripMenuItem // addCheatToolStripMenuItem
// //

View File

@ -282,7 +282,7 @@ namespace BizHawk.MultiClient
} }
} }
private void DisplayCheatsList() public void DisplayCheatsList()
{ {
UpdateNumberOfCheats(); UpdateNumberOfCheats();
CheatListView.ItemCount = cheatList.Count; CheatListView.ItemCount = cheatList.Count;
@ -292,7 +292,7 @@ namespace BizHawk.MultiClient
{ {
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices; ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
Cheat temp = new Cheat(); Cheat temp = new Cheat();
if (indexes[0] == 0) return; if (indexes.Count == 0) return;
foreach (int index in indexes) foreach (int index in indexes)
{ {
temp = cheatList[index]; temp = cheatList[index];
@ -319,7 +319,7 @@ namespace BizHawk.MultiClient
{ {
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices; ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
Cheat temp = new Cheat(); Cheat temp = new Cheat();
if (indexes.Count == 0) return;
foreach (int index in indexes) foreach (int index in indexes)
{ {
temp = cheatList[index]; temp = cheatList[index];
@ -576,7 +576,7 @@ namespace BizHawk.MultiClient
return Global.Emulator.MemoryDomains[0]; return Global.Emulator.MemoryDomains[0];
} }
bool LoadCheatFile(string path, bool append) public bool LoadCheatFile(string path, bool append)
{ {
int y; int y;
var file = new FileInfo(path); var file = new FileInfo(path);
@ -715,6 +715,7 @@ namespace BizHawk.MultiClient
private void RemoveCheat() private void RemoveCheat()
{ {
if (cheatList.Count == 0) return;
Changes(); Changes();
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices; ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
if (indexes.Count > 0) if (indexes.Count > 0)
@ -1102,5 +1103,25 @@ namespace BizHawk.MultiClient
DisplayCheatsList(); DisplayCheatsList();
} }
} }
private void cheatsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
if (indexes.Count > 0)
{
moveDownToolStripMenuItem.Enabled = false;
moveUpToolStripMenuItem.Enabled = false;
removeCheatToolStripMenuItem.Enabled = false;
duplicateToolStripMenuItem.Enabled = false;
}
else
{
moveDownToolStripMenuItem.Enabled = true;
moveUpToolStripMenuItem.Enabled = true;
removeCheatToolStripMenuItem.Enabled = true;
duplicateToolStripMenuItem.Enabled = true;
}
}
} }
} }

View File

@ -246,25 +246,27 @@
// removeToolStripMenuItem // removeToolStripMenuItem
// //
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
this.removeToolStripMenuItem.Size = new System.Drawing.Size(141, 22); this.removeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.removeToolStripMenuItem.Text = "Remove"; this.removeToolStripMenuItem.Text = "Remove";
// //
// toolStripSeparator2 // toolStripSeparator2
// //
this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(138, 6); this.toolStripSeparator2.Size = new System.Drawing.Size(149, 6);
// //
// moveUpToolStripMenuItem // moveUpToolStripMenuItem
// //
this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem"; this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem";
this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(141, 22); this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.moveUpToolStripMenuItem.Text = "Move Up"; this.moveUpToolStripMenuItem.Text = "Move Up";
this.moveUpToolStripMenuItem.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click);
// //
// moveDownToolStripMenuItem // moveDownToolStripMenuItem
// //
this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem"; this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem";
this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(141, 22); this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.moveDownToolStripMenuItem.Text = "Move Down"; this.moveDownToolStripMenuItem.Text = "Move Down";
this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click);
// //
// optionsToolStripMenuItem // optionsToolStripMenuItem
// //

View File

@ -217,5 +217,15 @@ namespace BizHawk.MultiClient
{ {
} }
private void moveUpToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void moveDownToolStripMenuItem_Click(object sender, EventArgs e)
{
}
} }
} }

View File

@ -354,7 +354,7 @@ namespace BizHawk.MultiClient
return 0; return 0;
} }
bool LoadWatchFile(string path, bool append) public bool LoadWatchFile(string path, bool append)
{ {
int y, z; int y, z;
var file = new FileInfo(path); var file = new FileInfo(path);
@ -516,9 +516,11 @@ namespace BizHawk.MultiClient
void MoveUp() void MoveUp()
{ {
if (WatchListView.SelectedIndices.Count == 0)
return;
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices; ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
Watch temp = new Watch(); Watch temp = new Watch();
if (indexes[0] == 0) return; if (indexes.Count == 0) return;
foreach (int index in indexes) foreach (int index in indexes)
{ {
temp = watchList[index]; temp = watchList[index];
@ -545,7 +547,7 @@ namespace BizHawk.MultiClient
{ {
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices; ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
Watch temp = new Watch(); Watch temp = new Watch();
if (indexes.Count == 0) return;
foreach (int index in indexes) foreach (int index in indexes)
{ {
temp = watchList[index]; temp = watchList[index];