Cheat Window - various things implemented

This commit is contained in:
andres.delikat 2011-03-17 02:21:14 +00:00
parent 2eb6dd3199
commit fc313ea483
3 changed files with 164 additions and 67 deletions

View File

@ -978,7 +978,7 @@ namespace BizHawk.MultiClient
if (!RamWatch1.IsHandleCreated || RamWatch1.IsDisposed)
{
RamWatch1 = new RamWatch();
if (Global.Config.AutoLoadRamWatch)
if (Global.Config.AutoLoadRamWatch && Global.Config.RecentWatches.Length() > 0)
RamWatch1.LoadWatchFromRecent(Global.Config.RecentWatches.GetRecentFileByPosition(0));
RamWatch1.Show();
}
@ -1024,8 +1024,8 @@ namespace BizHawk.MultiClient
if (!Cheats1.IsHandleCreated || Cheats1.IsDisposed)
{
Cheats1 = new Cheats();
if (Global.Config.AutoLoadCheats)
Cheats1.LoadWatchFromRecent(Global.Config.RecentCheats.GetRecentFileByPosition(0));
if (Global.Config.AutoLoadCheats && Global.Config.RecentCheats.Length() > 0)
Cheats1.LoadCheatFromRecent(Global.Config.RecentCheats.GetRecentFileByPosition(0));
Cheats1.Show();
}
else

View File

@ -69,16 +69,20 @@
this.toolStripButtonMoveDown = new System.Windows.Forms.ToolStripButton();
this.MessageLabel = new System.Windows.Forms.Label();
this.AddCheatGroup = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.AddCheatButton = new System.Windows.Forms.Button();
this.ValueBox = new System.Windows.Forms.TextBox();
this.AddressBox = new System.Windows.Forms.TextBox();
this.NameBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
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.noneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.autoLoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CheatsMenu.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.AddCheatGroup.SuspendLayout();
@ -86,16 +90,20 @@
//
// CheatListView
//
this.CheatListView.AllowColumnReorder = true;
this.CheatListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.CheatListView.AutoArrange = false;
this.CheatListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.CheatName,
this.Address,
this.Value,
this.Compare});
this.CheatListView.FullRowSelect = true;
this.CheatListView.GridLines = true;
this.CheatListView.ItemCount = 0;
this.CheatListView.LabelEdit = true;
this.CheatListView.Location = new System.Drawing.Point(12, 72);
this.CheatListView.Name = "CheatListView";
this.CheatListView.selectedItem = -1;
@ -189,9 +197,15 @@
//
// recentToolStripMenuItem
//
this.recentToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.noneToolStripMenuItem,
this.toolStripSeparator4,
this.clearToolStripMenuItem,
this.autoLoadToolStripMenuItem});
this.recentToolStripMenuItem.Name = "recentToolStripMenuItem";
this.recentToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
this.recentToolStripMenuItem.Text = "Recent";
this.recentToolStripMenuItem.DropDownOpened += new System.EventHandler(this.recentToolStripMenuItem_DropDownOpened);
//
// toolStripSeparator1
//
@ -274,12 +288,14 @@
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
this.optionsToolStripMenuItem.Text = "&Options";
this.optionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.optionsToolStripMenuItem_DropDownOpened);
//
// saveWindowPositionToolStripMenuItem
//
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position";
this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click);
//
// findAndLoadCheatFileByGameToolStripMenuItem
//
@ -429,6 +445,59 @@
this.AddCheatGroup.TabStop = false;
this.AddCheatGroup.Text = "Add Cheat";
//
// 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";
//
// 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";
//
// 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);
//
// 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;
//
// 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;
//
// NameBox
//
this.NameBox.Location = new System.Drawing.Point(64, 25);
this.NameBox.Name = "NameBox";
this.NameBox.Size = new System.Drawing.Size(100, 20);
this.NameBox.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
@ -456,59 +525,6 @@
this.label1.TabIndex = 0;
this.label1.Text = "Name";
//
// NameBox
//
this.NameBox.Location = new System.Drawing.Point(64, 25);
this.NameBox.Name = "NameBox";
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;
@ -518,6 +534,29 @@
this.NumCheatsLabel.TabIndex = 5;
this.NumCheatsLabel.Text = "0 Cheats";
//
// noneToolStripMenuItem
//
this.noneToolStripMenuItem.Name = "noneToolStripMenuItem";
this.noneToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.noneToolStripMenuItem.Text = "None";
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(149, 6);
//
// clearToolStripMenuItem
//
this.clearToolStripMenuItem.Name = "clearToolStripMenuItem";
this.clearToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.clearToolStripMenuItem.Text = "Clear";
//
// autoLoadToolStripMenuItem
//
this.autoLoadToolStripMenuItem.Name = "autoLoadToolStripMenuItem";
this.autoLoadToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.autoLoadToolStripMenuItem.Text = "Auto-load";
//
// Cheats
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -596,5 +635,9 @@
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label NumCheatsLabel;
private System.Windows.Forms.ToolStripMenuItem noneToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem autoLoadToolStripMenuItem;
}
}

View File

@ -42,15 +42,15 @@ namespace BizHawk.MultiClient
{
InitializeComponent();
Closing += (o, e) => SaveConfigSettings();
CheatListView.QueryItemText += new QueryItemTextHandler(CheatListView_QueryItemText);
CheatListView.QueryItemBkColor += new QueryItemBkColorHandler(CheatListView_QueryItemBkColor);
CheatListView.VirtualMode = true;
}
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);
}
@ -105,9 +105,10 @@ namespace BizHawk.MultiClient
cheatList.Add(c);
UpdateNumberOfCheats();
DisplayCheatsList();
CheatListView.Refresh();
}
public void LoadWatchFromRecent(string file)
public void LoadCheatFromRecent(string file)
{
bool z = true;
@ -127,6 +128,50 @@ namespace BizHawk.MultiClient
}
}
private void UpdateAutoLoadCheats()
{
autoLoadToolStripMenuItem.Checked = Global.Config.AutoLoadCheats ^= true;
}
private void recentToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
//Clear out recent Roms list
//repopulate it with an up to date list
recentToolStripMenuItem.DropDownItems.Clear();
if (Global.Config.RecentCheats.IsEmpty())
{
recentToolStripMenuItem.DropDownItems.Add("None");
}
else
{
for (int x = 0; x < Global.Config.RecentCheats.Length(); x++)
{
string path = Global.Config.RecentCheats.GetRecentFileByPosition(x);
var item = new ToolStripMenuItem();
item.Text = path;
item.Click += (o, ev) => LoadCheatFromRecent(path);
recentToolStripMenuItem.DropDownItems.Add(item);
}
}
recentToolStripMenuItem.DropDownItems.Add("-");
var clearitem = new ToolStripMenuItem();
clearitem.Text = "&Clear";
clearitem.Click += (o, ev) => Global.Config.RecentCheats.Clear();
recentToolStripMenuItem.DropDownItems.Add(clearitem);
var auto = new ToolStripMenuItem();
auto.Text = "&Auto-Load";
auto.Click += (o, ev) => UpdateAutoLoadCheats();
if (Global.Config.AutoLoadCheats == true)
auto.Checked = true;
else
auto.Checked = false;
recentToolStripMenuItem.DropDownItems.Add(auto);
}
private void LoadConfigSettings()
{
defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
@ -152,7 +197,6 @@ namespace BizHawk.MultiClient
private void DisplayCheatsList()
{
CheatListView.ItemCount = cheatList.Count;
//CheatListView.Refresh();
}
private void MoveUp()
@ -508,5 +552,15 @@ namespace BizHawk.MultiClient
else
NumCheatsLabel.Text = z.ToString() + " cheats";
}
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.CheatsSaveWindowPosition ^= true;
}
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
saveWindowPositionToolStripMenuItem.Checked = Global.Config.CheatsSaveWindowPosition;
}
}
}