From f821ff8f50c5ac6df34bc696736203782b152f69 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 19 Mar 2011 01:10:03 +0000 Subject: [PATCH] NES - Game Genie Encoder/Decoder - implement auto-load & window position saving --- BizHawk.MultiClient/Config.cs | 6 ++ BizHawk.MultiClient/MainForm.cs | 11 ++- .../NEStools/NESGameGenie.Designer.cs | 78 +++++++++++++++++-- BizHawk.MultiClient/NEStools/NESGameGenie.cs | 34 +++++++- .../NEStools/NESGameGenie.resx | 3 + 5 files changed, 121 insertions(+), 11 deletions(-) diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs index 816c5cff1a..6e700b4048 100644 --- a/BizHawk.MultiClient/Config.cs +++ b/BizHawk.MultiClient/Config.cs @@ -104,6 +104,12 @@ public int CheatsDomainWidth = -1; public int CheatsOnWidth = -1; + // NES Game Genie Encoder/Decoder + public bool NESGGAutoload = false; + public bool NESGGSaveWindowPosition = true; + public int NESGGWndx = -1; + public int NESGGWndy = -1; + //Movie Settings public RecentFiles RecentMovies = new RecentFiles(8); diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 58b34fd89a..0c6f1c434f 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -143,6 +143,8 @@ namespace BizHawk.MultiClient LoadCheatsWindow(); if (Global.Config.AutoLoadNESPPU && Global.Emulator is NES) LoadNESPPU(); + if (Global.Config.NESGGAutoload && Global.Emulator is NES) + LoadGameGenieEC(); if (Global.Config.MainWndx >= 0 && Global.Config.MainWndy >= 0 && Global.Config.SaveWindowPosition) this.Location = new Point(Global.Config.MainWndx, Global.Config.MainWndy); @@ -997,6 +999,12 @@ namespace BizHawk.MultiClient RamSearch1.Focus(); } + public void LoadGameGenieEC() + { + NESGameGenie gg = new NESGameGenie(); + gg.Show(); + } + public void LoadHexEditor() { if (!HexEditor1.IsHandleCreated || HexEditor1.IsDisposed) @@ -1254,8 +1262,7 @@ namespace BizHawk.MultiClient private void gameGenieCodesToolStripMenuItem_Click(object sender, EventArgs e) { - NESGameGenie g = new NESGameGenie(); - g.Show(); + LoadGameGenieEC(); } private void cheatsToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/NEStools/NESGameGenie.Designer.cs b/BizHawk.MultiClient/NEStools/NESGameGenie.Designer.cs index 00c2d142a7..a297b38a28 100644 --- a/BizHawk.MultiClient/NEStools/NESGameGenie.Designer.cs +++ b/BizHawk.MultiClient/NEStools/NESGameGenie.Designer.cs @@ -60,9 +60,16 @@ this.label4 = new System.Windows.Forms.Label(); this.Encoding = new System.Windows.Forms.CheckBox(); this.ClearButton = new System.Windows.Forms.Button(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.GameGenieCodeBox.SuspendLayout(); this.ButtonPanel.SuspendLayout(); this.groupBox1.SuspendLayout(); + this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // // GameGenieCode @@ -79,7 +86,7 @@ // GameGenieCodeBox // this.GameGenieCodeBox.Controls.Add(this.GameGenieCode); - this.GameGenieCodeBox.Location = new System.Drawing.Point(31, 85); + this.GameGenieCodeBox.Location = new System.Drawing.Point(31, 103); this.GameGenieCodeBox.Name = "GameGenieCodeBox"; this.GameGenieCodeBox.Size = new System.Drawing.Size(115, 54); this.GameGenieCodeBox.TabIndex = 1; @@ -151,7 +158,7 @@ // // AddCheat // - this.AddCheat.Location = new System.Drawing.Point(202, 217); + this.AddCheat.Location = new System.Drawing.Point(202, 235); this.AddCheat.Name = "AddCheat"; this.AddCheat.Size = new System.Drawing.Size(69, 21); this.AddCheat.TabIndex = 3; @@ -178,7 +185,7 @@ this.ButtonPanel.Controls.Add(this.Z); this.ButtonPanel.Controls.Add(this.P); this.ButtonPanel.Controls.Add(this.A); - this.ButtonPanel.Location = new System.Drawing.Point(31, 12); + this.ButtonPanel.Location = new System.Drawing.Point(31, 30); this.ButtonPanel.Name = "ButtonPanel"; this.ButtonPanel.Size = new System.Drawing.Size(240, 67); this.ButtonPanel.TabIndex = 4; @@ -354,7 +361,7 @@ this.groupBox1.Controls.Add(this.AddressBox); this.groupBox1.Controls.Add(this.ValueBox); this.groupBox1.Controls.Add(this.CompareBox); - this.groupBox1.Location = new System.Drawing.Point(31, 145); + this.groupBox1.Location = new System.Drawing.Point(31, 163); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(126, 93); this.groupBox1.TabIndex = 5; @@ -391,7 +398,7 @@ // this.Encoding.Appearance = System.Windows.Forms.Appearance.Button; this.Encoding.AutoSize = true; - this.Encoding.Location = new System.Drawing.Point(217, 101); + this.Encoding.Location = new System.Drawing.Point(217, 119); this.Encoding.Name = "Encoding"; this.Encoding.Size = new System.Drawing.Size(54, 23); this.Encoding.TabIndex = 6; @@ -400,7 +407,7 @@ // // ClearButton // - this.ClearButton.Location = new System.Drawing.Point(217, 130); + this.ClearButton.Location = new System.Drawing.Point(217, 148); this.ClearButton.Name = "ClearButton"; this.ClearButton.Size = new System.Drawing.Size(54, 23); this.ClearButton.TabIndex = 7; @@ -408,6 +415,55 @@ this.ClearButton.UseVisualStyleBackColor = true; this.ClearButton.Click += new System.EventHandler(this.ClearButton_Click); // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.optionsToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(302, 24); + this.menuStrip1.TabIndex = 8; + this.menuStrip1.Text = "menuStrip1"; + // + // optionsToolStripMenuItem + // + this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.autoloadToolStripMenuItem, + this.saveWindowPositionToolStripMenuItem, + this.toolStripSeparator1, + this.exitToolStripMenuItem}); + 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); + // + // autoloadToolStripMenuItem + // + this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem"; + this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(190, 22); + this.autoloadToolStripMenuItem.Text = "Auto-load"; + this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click); + // + // saveWindowPositionToolStripMenuItem + // + this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem"; + this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(190, 22); + this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position"; + this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(187, 6); + // + // exitToolStripMenuItem + // + this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; + this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4))); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(190, 22); + this.exitToolStripMenuItem.Text = "E&xit"; + this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); + // // NESGameGenie // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -419,7 +475,9 @@ this.Controls.Add(this.ButtonPanel); this.Controls.Add(this.AddCheat); this.Controls.Add(this.GameGenieCodeBox); + this.Controls.Add(this.menuStrip1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.MainMenuStrip = this.menuStrip1; this.MaximizeBox = false; this.Name = "NESGameGenie"; this.ShowIcon = false; @@ -430,6 +488,8 @@ this.ButtonPanel.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -469,5 +529,11 @@ private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label4; private System.Windows.Forms.Button ClearButton; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/NEStools/NESGameGenie.cs b/BizHawk.MultiClient/NEStools/NESGameGenie.cs index b06c48969f..46f45ee976 100644 --- a/BizHawk.MultiClient/NEStools/NESGameGenie.cs +++ b/BizHawk.MultiClient/NEStools/NESGameGenie.cs @@ -13,9 +13,6 @@ namespace BizHawk.MultiClient { public partial class NESGameGenie : Form { - //TODO - //Autoload - //Save Window Position int address = -1; int value = -1; int compare = -1; @@ -24,6 +21,7 @@ namespace BizHawk.MultiClient public NESGameGenie() { InitializeComponent(); + Closing += (o, e) => SaveConfigSettings(); } private void NESGameGenie_Load(object sender, EventArgs e) @@ -46,6 +44,15 @@ namespace BizHawk.MultiClient GameGenieTable.Add('N', 15); //1111 AddCheat.Enabled = false; + + if (Global.Config.NESGGWndx >= 0 && Global.Config.NESGGWndy >= 0) + Location = new Point(Global.Config.NESGGWndx, Global.Config.NESGGWndy); + } + + private void SaveConfigSettings() + { + Global.Config.NESGGWndx = this.Location.X; + Global.Config.NESGGWndy = this.Location.Y; } private void GameGenieCode_KeyPress(object sender, KeyPressEventArgs e) @@ -376,5 +383,26 @@ namespace BizHawk.MultiClient c.Enable(); Global.MainForm.Cheats1.AddCheat(c); } + + private void exitToolStripMenuItem_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e) + { + Global.Config.NESGGSaveWindowPosition ^= true; + } + + private void autoloadToolStripMenuItem_Click(object sender, EventArgs e) + { + Global.Config.NESGGAutoload ^= true; + } + + private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e) + { + autoloadToolStripMenuItem.Checked = Global.Config.NESGGAutoload; + saveWindowPositionToolStripMenuItem.Checked = Global.Config.NESGGSaveWindowPosition; + } } } diff --git a/BizHawk.MultiClient/NEStools/NESGameGenie.resx b/BizHawk.MultiClient/NEStools/NESGameGenie.resx index ff31a6db56..69c56499b0 100644 --- a/BizHawk.MultiClient/NEStools/NESGameGenie.resx +++ b/BizHawk.MultiClient/NEStools/NESGameGenie.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file