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")
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
LoadRom(filePaths[0]);
}

View File

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

View File

@ -282,7 +282,7 @@ namespace BizHawk.MultiClient
}
}
private void DisplayCheatsList()
public void DisplayCheatsList()
{
UpdateNumberOfCheats();
CheatListView.ItemCount = cheatList.Count;
@ -292,7 +292,7 @@ namespace BizHawk.MultiClient
{
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
Cheat temp = new Cheat();
if (indexes[0] == 0) return;
if (indexes.Count == 0) return;
foreach (int index in indexes)
{
temp = cheatList[index];
@ -319,7 +319,7 @@ namespace BizHawk.MultiClient
{
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
Cheat temp = new Cheat();
if (indexes.Count == 0) return;
foreach (int index in indexes)
{
temp = cheatList[index];
@ -576,7 +576,7 @@ namespace BizHawk.MultiClient
return Global.Emulator.MemoryDomains[0];
}
bool LoadCheatFile(string path, bool append)
public bool LoadCheatFile(string path, bool append)
{
int y;
var file = new FileInfo(path);
@ -715,6 +715,7 @@ namespace BizHawk.MultiClient
private void RemoveCheat()
{
if (cheatList.Count == 0) return;
Changes();
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
if (indexes.Count > 0)
@ -1102,5 +1103,25 @@ namespace BizHawk.MultiClient
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
//
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";
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(138, 6);
this.toolStripSeparator2.Size = new System.Drawing.Size(149, 6);
//
// 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.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click);
//
// 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.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click);
//
// 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;
}
bool LoadWatchFile(string path, bool append)
public bool LoadWatchFile(string path, bool append)
{
int y, z;
var file = new FileInfo(path);
@ -516,9 +516,11 @@ namespace BizHawk.MultiClient
void MoveUp()
{
if (WatchListView.SelectedIndices.Count == 0)
return;
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
Watch temp = new Watch();
if (indexes[0] == 0) return;
if (indexes.Count == 0) return;
foreach (int index in indexes)
{
temp = watchList[index];
@ -545,7 +547,7 @@ namespace BizHawk.MultiClient
{
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
Watch temp = new Watch();
if (indexes.Count == 0) return;
foreach (int index in indexes)
{
temp = watchList[index];