More Cheats Dialog progress

This commit is contained in:
andres.delikat 2011-03-16 15:48:47 +00:00
parent ff5623cd46
commit f43767897a
4 changed files with 357 additions and 58 deletions

View File

@ -5,7 +5,7 @@ using System.Text;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
class Cheat public class Cheat
{ {
public string name { get; set; } public string name { get; set; }
public int address { get; set; } public int address { get; set; }

View File

@ -29,7 +29,7 @@
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Cheats)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Cheats));
this.CheatListView = new System.Windows.Forms.ListView(); this.CheatListView = new BizHawk.VirtualListView();
this.CheatName = new System.Windows.Forms.ColumnHeader(); this.CheatName = new System.Windows.Forms.ColumnHeader();
this.Address = new System.Windows.Forms.ColumnHeader(); this.Address = new System.Windows.Forms.ColumnHeader();
this.Value = new System.Windows.Forms.ColumnHeader(); this.Value = new System.Windows.Forms.ColumnHeader();
@ -41,6 +41,7 @@
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.appendFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.appendFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.recentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cheatsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.cheatsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -51,6 +52,10 @@
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.findAndLoadCheatFileByGameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.autoTurnOnCheatsOnLoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.newToolStripButton = new System.Windows.Forms.ToolStripButton(); this.newToolStripButton = new System.Windows.Forms.ToolStripButton();
this.openToolStripButton = new System.Windows.Forms.ToolStripButton(); this.openToolStripButton = new System.Windows.Forms.ToolStripButton();
@ -63,13 +68,20 @@
this.toolStripButtonMoveUp = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonMoveUp = new System.Windows.Forms.ToolStripButton();
this.toolStripButtonMoveDown = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonMoveDown = new System.Windows.Forms.ToolStripButton();
this.MessageLabel = new System.Windows.Forms.Label(); this.MessageLabel = new System.Windows.Forms.Label();
this.recentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AddCheatGroup = new System.Windows.Forms.GroupBox();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.label3 = new System.Windows.Forms.Label();
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.label2 = new System.Windows.Forms.Label();
this.findAndLoadCheatFileByGameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.label1 = new System.Windows.Forms.Label();
this.autoTurnOnCheatsOnLoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.NameBox = new System.Windows.Forms.TextBox();
this.AddressBox = new System.Windows.Forms.TextBox();
this.ValueBox = new System.Windows.Forms.TextBox();
this.AddCheatButton = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.NumCheatsLabel = new System.Windows.Forms.Label();
this.CheatsMenu.SuspendLayout(); this.CheatsMenu.SuspendLayout();
this.toolStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout();
this.AddCheatGroup.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// CheatListView // CheatListView
@ -83,9 +95,11 @@
this.Value, this.Value,
this.Compare}); this.Compare});
this.CheatListView.GridLines = true; this.CheatListView.GridLines = true;
this.CheatListView.Location = new System.Drawing.Point(12, 56); this.CheatListView.ItemCount = 0;
this.CheatListView.Location = new System.Drawing.Point(12, 72);
this.CheatListView.Name = "CheatListView"; this.CheatListView.Name = "CheatListView";
this.CheatListView.Size = new System.Drawing.Size(294, 293); this.CheatListView.selectedItem = -1;
this.CheatListView.Size = new System.Drawing.Size(294, 277);
this.CheatListView.TabIndex = 0; this.CheatListView.TabIndex = 0;
this.CheatListView.UseCompatibleStateImageBehavior = false; this.CheatListView.UseCompatibleStateImageBehavior = false;
this.CheatListView.View = System.Windows.Forms.View.Details; this.CheatListView.View = System.Windows.Forms.View.Details;
@ -173,6 +187,12 @@
this.appendFileToolStripMenuItem.Size = new System.Drawing.Size(204, 22); this.appendFileToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
this.appendFileToolStripMenuItem.Text = "Append File"; this.appendFileToolStripMenuItem.Text = "Append File";
// //
// recentToolStripMenuItem
//
this.recentToolStripMenuItem.Name = "recentToolStripMenuItem";
this.recentToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
this.recentToolStripMenuItem.Text = "Recent";
//
// toolStripSeparator1 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
@ -204,12 +224,14 @@
this.addCheatToolStripMenuItem.Name = "addCheatToolStripMenuItem"; this.addCheatToolStripMenuItem.Name = "addCheatToolStripMenuItem";
this.addCheatToolStripMenuItem.Size = new System.Drawing.Size(165, 22); this.addCheatToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
this.addCheatToolStripMenuItem.Text = "&Add Cheat"; this.addCheatToolStripMenuItem.Text = "&Add Cheat";
this.addCheatToolStripMenuItem.Click += new System.EventHandler(this.addCheatToolStripMenuItem_Click);
// //
// removeCheatToolStripMenuItem // removeCheatToolStripMenuItem
// //
this.removeCheatToolStripMenuItem.Name = "removeCheatToolStripMenuItem"; this.removeCheatToolStripMenuItem.Name = "removeCheatToolStripMenuItem";
this.removeCheatToolStripMenuItem.Size = new System.Drawing.Size(165, 22); this.removeCheatToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
this.removeCheatToolStripMenuItem.Text = "&Remove Cheat"; this.removeCheatToolStripMenuItem.Text = "&Remove Cheat";
this.removeCheatToolStripMenuItem.Click += new System.EventHandler(this.removeCheatToolStripMenuItem_Click);
// //
// duplicateToolStripMenuItem // duplicateToolStripMenuItem
// //
@ -222,6 +244,7 @@
this.insertSeparatorToolStripMenuItem.Name = "insertSeparatorToolStripMenuItem"; this.insertSeparatorToolStripMenuItem.Name = "insertSeparatorToolStripMenuItem";
this.insertSeparatorToolStripMenuItem.Size = new System.Drawing.Size(165, 22); this.insertSeparatorToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
this.insertSeparatorToolStripMenuItem.Text = "Insert Separator"; this.insertSeparatorToolStripMenuItem.Text = "Insert Separator";
this.insertSeparatorToolStripMenuItem.Click += new System.EventHandler(this.insertSeparatorToolStripMenuItem_Click);
// //
// toolStripSeparator3 // toolStripSeparator3
// //
@ -242,6 +265,34 @@
this.moveDownToolStripMenuItem.Text = "Move &Down"; this.moveDownToolStripMenuItem.Text = "Move &Down";
this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click); this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click);
// //
// optionsToolStripMenuItem
//
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.saveWindowPositionToolStripMenuItem,
this.findAndLoadCheatFileByGameToolStripMenuItem,
this.autoTurnOnCheatsOnLoadToolStripMenuItem});
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
this.optionsToolStripMenuItem.Text = "&Options";
//
// saveWindowPositionToolStripMenuItem
//
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position";
//
// findAndLoadCheatFileByGameToolStripMenuItem
//
this.findAndLoadCheatFileByGameToolStripMenuItem.Name = "findAndLoadCheatFileByGameToolStripMenuItem";
this.findAndLoadCheatFileByGameToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
this.findAndLoadCheatFileByGameToolStripMenuItem.Text = "Find and Load Cheat File by Game";
//
// autoTurnOnCheatsOnLoadToolStripMenuItem
//
this.autoTurnOnCheatsOnLoadToolStripMenuItem.Name = "autoTurnOnCheatsOnLoadToolStripMenuItem";
this.autoTurnOnCheatsOnLoadToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
this.autoTurnOnCheatsOnLoadToolStripMenuItem.Text = "Auto Turn on Cheats on Load";
//
// toolStrip1 // toolStrip1
// //
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -299,11 +350,12 @@
// cutToolStripButton // cutToolStripButton
// //
this.cutToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.cutToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.cutToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("cutToolStripButton.Image"))); this.cutToolStripButton.Image = global::BizHawk.MultiClient.Properties.Resources.BuilderDialog_delete;
this.cutToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.cutToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.cutToolStripButton.Name = "cutToolStripButton"; this.cutToolStripButton.Name = "cutToolStripButton";
this.cutToolStripButton.Size = new System.Drawing.Size(23, 22); this.cutToolStripButton.Size = new System.Drawing.Size(23, 22);
this.cutToolStripButton.Text = "&Remove"; this.cutToolStripButton.Text = "&Remove";
this.cutToolStripButton.Click += new System.EventHandler(this.cutToolStripButton_Click);
// //
// copyToolStripButton // copyToolStripButton
// //
@ -322,6 +374,7 @@
this.toolStripButtonSeparator.Name = "toolStripButtonSeparator"; this.toolStripButtonSeparator.Name = "toolStripButtonSeparator";
this.toolStripButtonSeparator.Size = new System.Drawing.Size(23, 22); this.toolStripButtonSeparator.Size = new System.Drawing.Size(23, 22);
this.toolStripButtonSeparator.Text = "Insert Separator"; this.toolStripButtonSeparator.Text = "Insert Separator";
this.toolStripButtonSeparator.Click += new System.EventHandler(this.toolStripButtonSeparator_Click);
// //
// toolStripSeparator2 // toolStripSeparator2
// //
@ -354,49 +407,124 @@
this.MessageLabel.AutoSize = true; this.MessageLabel.AutoSize = true;
this.MessageLabel.Location = new System.Drawing.Point(13, 356); this.MessageLabel.Location = new System.Drawing.Point(13, 356);
this.MessageLabel.Name = "MessageLabel"; this.MessageLabel.Name = "MessageLabel";
this.MessageLabel.Size = new System.Drawing.Size(35, 13); this.MessageLabel.Size = new System.Drawing.Size(0, 13);
this.MessageLabel.TabIndex = 3; this.MessageLabel.TabIndex = 3;
this.MessageLabel.Text = "label1";
// //
// recentToolStripMenuItem // AddCheatGroup
// //
this.recentToolStripMenuItem.Name = "recentToolStripMenuItem"; this.AddCheatGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.recentToolStripMenuItem.Size = new System.Drawing.Size(204, 22); this.AddCheatGroup.Controls.Add(this.label5);
this.recentToolStripMenuItem.Text = "Recent"; this.AddCheatGroup.Controls.Add(this.label4);
this.AddCheatGroup.Controls.Add(this.AddCheatButton);
this.AddCheatGroup.Controls.Add(this.ValueBox);
this.AddCheatGroup.Controls.Add(this.AddressBox);
this.AddCheatGroup.Controls.Add(this.NameBox);
this.AddCheatGroup.Controls.Add(this.label3);
this.AddCheatGroup.Controls.Add(this.label2);
this.AddCheatGroup.Controls.Add(this.label1);
this.AddCheatGroup.Location = new System.Drawing.Point(327, 72);
this.AddCheatGroup.Name = "AddCheatGroup";
this.AddCheatGroup.Size = new System.Drawing.Size(170, 150);
this.AddCheatGroup.TabIndex = 4;
this.AddCheatGroup.TabStop = false;
this.AddCheatGroup.Text = "Add Cheat";
// //
// optionsToolStripMenuItem // label3
// //
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.label3.AutoSize = true;
this.saveWindowPositionToolStripMenuItem, this.label3.Location = new System.Drawing.Point(7, 82);
this.findAndLoadCheatFileByGameToolStripMenuItem, this.label3.Name = "label3";
this.autoTurnOnCheatsOnLoadToolStripMenuItem}); this.label3.Size = new System.Drawing.Size(34, 13);
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; this.label3.TabIndex = 2;
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(56, 20); this.label3.Text = "Value";
this.optionsToolStripMenuItem.Text = "&Options";
// //
// saveWindowPositionToolStripMenuItem // label2
// //
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem"; this.label2.AutoSize = true;
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(248, 22); this.label2.Location = new System.Drawing.Point(6, 54);
this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(45, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Address";
// //
// findAndLoadCheatFileByGameToolStripMenuItem // label1
// //
this.findAndLoadCheatFileByGameToolStripMenuItem.Name = "findAndLoadCheatFileByGameToolStripMenuItem"; this.label1.AutoSize = true;
this.findAndLoadCheatFileByGameToolStripMenuItem.Size = new System.Drawing.Size(248, 22); this.label1.Location = new System.Drawing.Point(6, 28);
this.findAndLoadCheatFileByGameToolStripMenuItem.Text = "Find and Load Cheat File by Game"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Name";
// //
// autoTurnOnCheatsOnLoadToolStripMenuItem // NameBox
// //
this.autoTurnOnCheatsOnLoadToolStripMenuItem.Name = "autoTurnOnCheatsOnLoadToolStripMenuItem"; this.NameBox.Location = new System.Drawing.Point(64, 25);
this.autoTurnOnCheatsOnLoadToolStripMenuItem.Size = new System.Drawing.Size(248, 22); this.NameBox.Name = "NameBox";
this.autoTurnOnCheatsOnLoadToolStripMenuItem.Text = "Auto Turn on Cheats on Load"; this.NameBox.Size = new System.Drawing.Size(100, 20);
this.NameBox.TabIndex = 3;
//
// AddressBox
//
this.AddressBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.AddressBox.Location = new System.Drawing.Point(99, 51);
this.AddressBox.MaxLength = 8;
this.AddressBox.Name = "AddressBox";
this.AddressBox.Size = new System.Drawing.Size(65, 20);
this.AddressBox.TabIndex = 4;
//
// ValueBox
//
this.ValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.ValueBox.Location = new System.Drawing.Point(99, 79);
this.ValueBox.MaxLength = 2;
this.ValueBox.Name = "ValueBox";
this.ValueBox.Size = new System.Drawing.Size(65, 20);
this.ValueBox.TabIndex = 5;
//
// AddCheatButton
//
this.AddCheatButton.Location = new System.Drawing.Point(99, 115);
this.AddCheatButton.Name = "AddCheatButton";
this.AddCheatButton.Size = new System.Drawing.Size(65, 23);
this.AddCheatButton.TabIndex = 6;
this.AddCheatButton.Text = "&Add";
this.AddCheatButton.UseVisualStyleBackColor = true;
this.AddCheatButton.Click += new System.EventHandler(this.AddCheatButton_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(80, 56);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(18, 13);
this.label4.TabIndex = 7;
this.label4.Text = "0x";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(80, 85);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(18, 13);
this.label5.TabIndex = 8;
this.label5.Text = "0x";
//
// NumCheatsLabel
//
this.NumCheatsLabel.AutoSize = true;
this.NumCheatsLabel.Location = new System.Drawing.Point(9, 52);
this.NumCheatsLabel.Name = "NumCheatsLabel";
this.NumCheatsLabel.Size = new System.Drawing.Size(49, 13);
this.NumCheatsLabel.TabIndex = 5;
this.NumCheatsLabel.Text = "0 Cheats";
// //
// Cheats // Cheats
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(509, 379); this.ClientSize = new System.Drawing.Size(509, 379);
this.Controls.Add(this.NumCheatsLabel);
this.Controls.Add(this.AddCheatGroup);
this.Controls.Add(this.MessageLabel); this.Controls.Add(this.MessageLabel);
this.Controls.Add(this.toolStrip1); this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.CheatListView); this.Controls.Add(this.CheatListView);
@ -409,6 +537,8 @@
this.CheatsMenu.PerformLayout(); this.CheatsMenu.PerformLayout();
this.toolStrip1.ResumeLayout(false); this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout(); this.toolStrip1.PerformLayout();
this.AddCheatGroup.ResumeLayout(false);
this.AddCheatGroup.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -416,7 +546,7 @@
#endregion #endregion
private System.Windows.Forms.ListView CheatListView; private VirtualListView CheatListView;
private System.Windows.Forms.MenuStrip CheatsMenu; private System.Windows.Forms.MenuStrip CheatsMenu;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
@ -455,5 +585,16 @@
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem findAndLoadCheatFileByGameToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem findAndLoadCheatFileByGameToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem autoTurnOnCheatsOnLoadToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem autoTurnOnCheatsOnLoadToolStripMenuItem;
private System.Windows.Forms.GroupBox AddCheatGroup;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox AddressBox;
private System.Windows.Forms.TextBox NameBox;
private System.Windows.Forms.TextBox ValueBox;
private System.Windows.Forms.Button AddCheatButton;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label NumCheatsLabel;
} }
} }

View File

@ -13,13 +13,22 @@ namespace BizHawk.MultiClient
{ {
public partial class Cheats : Form public partial class Cheats : Form
{ {
//TODO: Get vlist display working
//Input validation on address & value boxes
//Remove compare column? make it conditional? Think about this
//Set address box text load based on memory domain size
//Recent files
//Memory domains
//File format - saving & loading
//Shortcuts for Cheat menu items
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight; int defaultHeight;
List<Cheat> cheatList = new List<Cheat>(); List<Cheat> cheatList = new List<Cheat>();
string currentCheatFile = ""; string currentCheatFile = "";
bool changes = false; bool changes = false;
/*
public List<Cheat> GetCheatList() public List<Cheat> GetCheatList()
{ {
List<Cheat> c = new List<Cheat>(); List<Cheat> c = new List<Cheat>();
@ -28,37 +37,94 @@ namespace BizHawk.MultiClient
return c; return c;
} }
*/
public Cheats() public Cheats()
{ {
InitializeComponent(); InitializeComponent();
Closing += (o, e) => SaveConfigSettings(); Closing += (o, e) => SaveConfigSettings();
} }
protected override void OnClosing(CancelEventArgs e)
{
if (!AskSave())
e.Cancel = true;
CheatListView.QueryItemText += new QueryItemTextHandler(CheatListView_QueryItemText);
CheatListView.QueryItemBkColor += new QueryItemBkColorHandler(CheatListView_QueryItemBkColor);
CheatListView.VirtualMode = true;
base.OnClosing(e);
}
private void CheatListView_QueryItemBkColor(int index, int column, ref Color color)
{
if (cheatList[index].address < 0)
color = this.BackColor;
}
private void CheatListView_QueryItemText(int index, int column, out string text)
{
text = "";
if (column == 0) //Name
{
text = cheatList[index].name;
}
if (column == 1) //Address
{
text = String.Format("{0:X" + GetNumDigits((Global.Emulator.MainMemory.Size - 1)).ToString() + "}", cheatList[index].address);
}
if (column == 2) //Value
{
text = String.Format("{0:2X", cheatList[index].value);
}
if (column == 3) //Compare
{
text = String.Format("{0:2X", cheatList[index].compare);
}
}
private int GetNumDigits(Int32 i)
{
//if (i == 0) return 0;
//if (i < 0x10) return 1;
//if (i < 0x100) return 2;
//if (i < 0x1000) return 3; //adelikat: commenting these out because I decided that regardless of domain, 4 digits should be the minimum
if (i < 0x10000) return 4;
//if (i < 0x100000) return 5;
if (i < 0x1000000) return 6;
//if (i < 0x10000000) return 7;
else return 8;
}
private void Cheats_Load(object sender, EventArgs e) private void Cheats_Load(object sender, EventArgs e)
{ {
LoadConfigSettings(); LoadConfigSettings();
} }
public void AddCheat(Cheat c)
{
cheatList.Add(c);
UpdateNumberOfCheats();
DisplayCheatsList();
}
public void LoadWatchFromRecent(string file) public void LoadWatchFromRecent(string file)
{ {
bool z = true; bool z = true;
/*
if (changes) z = AskSave(); if (changes) z = AskSave();
if (z) if (z)
{ {
bool r = LoadWatchFile(file, false); bool r = LoadCheatFile(file, false);
if (!r) if (!r)
{ {
DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (result == DialogResult.Yes) if (result == DialogResult.Yes)
Global.Config.RecentWatches.Remove(file); Global.Config.RecentCheats.Remove(file);
} }
DisplayWatchList(); DisplayCheatsList();
changes = false; changes = false;
} }
*/
} }
private void LoadConfigSettings() private void LoadConfigSettings()
@ -85,12 +151,35 @@ namespace BizHawk.MultiClient
private void DisplayCheatsList() private void DisplayCheatsList()
{ {
CheatListView.ItemCount = cheatList.Count;
//CheatListView.Refresh();
} }
private void MoveUp() private void MoveUp()
{ {
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
Cheat temp = new Cheat();
if (indexes[0] == 0) return;
foreach (int index in indexes)
{
temp = cheatList[index];
cheatList.Remove(cheatList[index]);
cheatList.Insert(index - 1, temp);
//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();
}
List<int> i = new List<int>();
for (int z = 0; z < indexes.Count; z++)
i.Add(indexes[z] - 1);
CheatListView.SelectedIndices.Clear();
for (int z = 0; z < i.Count; z++)
CheatListView.SelectItem(i[z], true);
DisplayCheatsList();
} }
private void MoveDown() private void MoveDown()
@ -337,5 +426,87 @@ namespace BizHawk.MultiClient
{ {
OpenCheatFile(); OpenCheatFile();
} }
private void InsertSeparator()
{
Cheat c = new Cheat();
c.address = -1;
c.name = "Separator"; //TODO: remove me
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
int x;
if (indexes.Count > 0)
{
x = indexes[0];
if (indexes[0] > 0)
cheatList.Insert(indexes[0], c);
}
else
cheatList.Add(c);
DisplayCheatsList();
CheatListView.Refresh();
}
private void toolStripButtonSeparator_Click(object sender, EventArgs e)
{
InsertSeparator();
}
private void insertSeparatorToolStripMenuItem_Click(object sender, EventArgs e)
{
InsertSeparator();
}
private Cheat MakeCheat()
{
Cheat c = new Cheat();
c.name = NameBox.Text;
c.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber); //TODO: validation
c.value = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
return c;
}
private void AddCheatButton_Click(object sender, EventArgs e)
{
AddCheat(MakeCheat());
}
private void addCheatToolStripMenuItem_Click(object sender, EventArgs e)
{
AddCheat(MakeCheat());
}
private void RemoveCheat()
{
Changes();
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
if (indexes.Count > 0)
{
foreach (int index in indexes)
{
cheatList.Remove(cheatList[indexes[0]]); //index[0] used since each iteration will make this the correct list index
}
DisplayCheatsList();
}
}
private void cutToolStripButton_Click(object sender, EventArgs e)
{
RemoveCheat();
}
private void removeCheatToolStripMenuItem_Click(object sender, EventArgs e)
{
RemoveCheat();
}
private void UpdateNumberOfCheats()
{
int z = cheatList.Count;
if (z == 1)
NumCheatsLabel.Text = z.ToString() + " cheat";
else
NumCheatsLabel.Text = z.ToString() + " cheats";
}
} }
} }

View File

@ -166,19 +166,6 @@
e41tHNbucUGnKxICiqXjHpTPJgHBZ/Nv4U1oHqGZJVwstiNe72JwI+J3PYA2MV8IMjOG2dzLfOatBg+2 e41tHNbucUGnKxICiqXjHpTPJgHBZ/Nv4U1oHqGZJVwstiNe72JwI+J3PYA2MV8IMjOG2dzLfOatBg+2
7JDQ0tEPX9cguvv8GHg5hH0mC9S6eiQweLumDhqNVQgo06dP9fN4UsIoJHRnOhVtmxZGM1NXKoJ3JmTH 7JDQ0tEPX9cguvv8GHg5hH0mC9S6eiQweLumDhqNVQgo06dP9fN4UsIoJHRnOhVtmxZGM1NXKoJ3JmTH
Cv71r/4OTrQ4xWMwWlcAAAAASUVORK5CYII= Cv71r/4OTrQ4xWMwWlcAAAAASUVORK5CYII=
</value>
</data>
<data name="cutToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAYdJREFUOE+t001L
QlEQBuB+TdCmRVEJRRIWtRAUlKsQhFmkpZQtIiWyAlMwP5KkXS0shLqGFkgoFqWQmaRR2qIvU7FMwWhd
8JZXkFx0uVGzOcNh5jkDw6mr+++4SN7B6fbju/uQecYm6a25+/Hdl2IJptWNmmJyL4DwWZwZUJbtayT8
RxGqIV8oQaaaRfrxkTmw4z2G+WuKbC6PYDgOkUSJp6ccc+AgdI4luwPbHh/UCxb0S0aZN5fHTmefMTVv
wfDEHIiBMegMpt8BZUShNoGQTIKQGxA8TTIHMoUPGF1vEOvTWHTcgqeJQahNwLqVQiRRpIdS+XcM2l4h
1t2DI3WAP7oGoSYE3kwSPQofljcqm/kxjK4SCH0OXSMetItsUC26wZuOVptYhI0eEOuz1YI2gZnKBdpr
6iR9V2jkKOkBQpeiCryhFFr4eioft16iU7qNho4h1Dc00QOqlRuwpSSa+UawuZXdByIZsPoUaOmWwrUf
owcOozlwZeto7ZXDuXvCfHV/+dGfqqrf44qgu28AAAAASUVORK5CYII=
</value> </value>
</data> </data>
<data name="copyToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="copyToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">