NES Game Genie dialog - implement Always on Top and Floating Window + refactor

This commit is contained in:
adelikat 2014-01-31 20:49:38 +00:00
parent 8654303b59
commit 4aab2ea31d
3 changed files with 555 additions and 512 deletions

View File

@ -469,10 +469,8 @@ namespace BizHawk.Client.Common
public bool VirtualPadSticky = true;
// NES Game Genie Encoder/Decoder
public ToolDialogSettings NesGGSettings = new ToolDialogSettings();
public bool NESGGAutoload = false;
public bool NESGGSaveWindowPosition = true;
public int NESGGWndx = -1;
public int NESGGWndy = -1;
// SNES Game Genie Encoder/Decoder
public bool SNESGGAutoload = false;

View File

@ -64,6 +64,8 @@
this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AutoloadMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.GameGenieCodeBox.SuspendLayout();
@ -433,7 +435,7 @@
this.OptionsSubMenu});
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
this.MenuStrip.Name = "MenuStrip";
this.MenuStrip.Size = new System.Drawing.Size(302, 24);
this.MenuStrip.Size = new System.Drawing.Size(292, 24);
this.MenuStrip.TabIndex = 8;
this.MenuStrip.Text = "menuStrip1";
//
@ -442,6 +444,8 @@
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.AutoloadMenuItem,
this.SaveWindowPositionMenuItem,
this.AlwaysOnTopMenuItem,
this.FloatingWindowMenuItem,
this.toolStripSeparator1,
this.ExitMenuItem});
this.OptionsSubMenu.Name = "OptionsSubMenu";
@ -463,6 +467,20 @@
this.SaveWindowPositionMenuItem.Text = "Save Window Position";
this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
//
// AlwaysOnTopMenuItem
//
this.AlwaysOnTopMenuItem.Name = "AlwaysOnTopMenuItem";
this.AlwaysOnTopMenuItem.Size = new System.Drawing.Size(191, 22);
this.AlwaysOnTopMenuItem.Text = "Always On Top";
this.AlwaysOnTopMenuItem.Click += new System.EventHandler(this.AlwaysOnTopMenuItem_Click);
//
// floatingWindowToolStripMenuItem
//
this.FloatingWindowMenuItem.Name = "floatingWindowToolStripMenuItem";
this.FloatingWindowMenuItem.Size = new System.Drawing.Size(191, 22);
this.FloatingWindowMenuItem.Text = "Floating Window";
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
@ -480,7 +498,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(302, 263);
this.ClientSize = new System.Drawing.Size(292, 260);
this.Controls.Add(this.ClearButton);
this.Controls.Add(this.Encoding);
this.Controls.Add(this.groupBox1);
@ -550,5 +568,7 @@
private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem;
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
}
}

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
@ -61,9 +60,10 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent();
Closing += (o, e) =>
{
Global.Config.NESGGWndx = Location.X;
Global.Config.NESGGWndy = Location.Y;
Global.Config.NesGGSettings.Wndx = Location.X;
Global.Config.NesGGSettings.Wndy = Location.Y;
};
TopMost = Global.Config.NesGGSettings.TopMost;
AddressBox.SetHexProperties(0x10000);
ValueBox.SetHexProperties(0x100);
CompareBox.SetHexProperties(0x100);
@ -73,9 +73,9 @@ namespace BizHawk.Client.EmuHawk
{
AddCheat.Enabled = false;
if (Global.Config.NESGGSaveWindowPosition && Global.Config.NESGGWndx >= 0 && Global.Config.NESGGWndy >= 0)
if (Global.Config.NesGGSettings.UseWindowPosition)
{
Location = new Point(Global.Config.NESGGWndx, Global.Config.NESGGWndy);
Location = Global.Config.NesGGSettings.WindowPosition;
}
}
@ -125,16 +125,16 @@ namespace BizHawk.Client.EmuHawk
AddressBox.Text =
CompareBox.Text =
ValueBox.Text =
String.Empty;
string.Empty;
AddCheat.Enabled = false;
}
private void TryEnableAddCheat()
{
AddCheat.Enabled = !String.IsNullOrWhiteSpace(AddressBox.Text)
&& !String.IsNullOrWhiteSpace(ValueBox.Text)
&& !String.IsNullOrWhiteSpace(GameGenieCode.Text);
AddCheat.Enabled = !string.IsNullOrWhiteSpace(AddressBox.Text)
&& !string.IsNullOrWhiteSpace(ValueBox.Text)
&& !string.IsNullOrWhiteSpace(GameGenieCode.Text);
}
private void EncodeGameGenie()
@ -147,7 +147,7 @@ namespace BizHawk.Client.EmuHawk
private void AddCheatClick()
{
if (!String.IsNullOrWhiteSpace(AddressBox.Text) && !String.IsNullOrWhiteSpace(ValueBox.Text))
if (!string.IsNullOrWhiteSpace(AddressBox.Text) && !string.IsNullOrWhiteSpace(ValueBox.Text))
{
var watch = Watch.GenerateWatch(
Global.Emulator.MemoryDomains["System Bus"],
@ -165,6 +165,11 @@ namespace BizHawk.Client.EmuHawk
}
}
private void RefreshFloatingWindowControl()
{
Owner = Global.Config.NesGGSettings.FloatingWindow ? null : GlobalWin.MainForm;
}
#region Events
#region File Menu
@ -172,7 +177,9 @@ namespace BizHawk.Client.EmuHawk
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{
AutoloadMenuItem.Checked = Global.Config.NESGGAutoload;
SaveWindowPositionMenuItem.Checked = Global.Config.NESGGSaveWindowPosition;
SaveWindowPositionMenuItem.Checked = Global.Config.NesGGSettings.SaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Global.Config.NesGGSettings.TopMost;
FloatingWindowMenuItem.Checked = Global.Config.NesGGSettings.FloatingWindow;
}
private void AutoloadMenuItem_Click(object sender, EventArgs e)
@ -182,7 +189,7 @@ namespace BizHawk.Client.EmuHawk
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{
Global.Config.NESGGSaveWindowPosition ^= true;
Global.Config.NesGGSettings.SaveWindowPosition ^= true;
}
private void ExitMenuItem_Click(object sender, EventArgs e)
@ -190,6 +197,18 @@ namespace BizHawk.Client.EmuHawk
Close();
}
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
{
Global.Config.NesGGSettings.TopMost ^= true;
TopMost = Global.Config.NesGGSettings.TopMost;
}
private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
{
Global.Config.NesGGSettings.FloatingWindow ^= true;
RefreshFloatingWindowControl();
}
#endregion
#region Control Events
@ -212,7 +231,7 @@ namespace BizHawk.Client.EmuHawk
private void ClearButton_Click(object sender, EventArgs e)
{
ClearProperties();
GameGenieCode.Text = String.Empty;
GameGenieCode.Text = string.Empty;
Encoding.Checked = false;
}
@ -234,12 +253,12 @@ namespace BizHawk.Client.EmuHawk
private void ValueBox_TextChanged(object sender, EventArgs e)
{
if (Encoding.Checked && !String.IsNullOrWhiteSpace(ValueBox.Text))
if (Encoding.Checked && !string.IsNullOrWhiteSpace(ValueBox.Text))
{
int val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
var val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
if (val > 0 && val < 0x100)
{
if (!String.IsNullOrWhiteSpace(AddressBox.Text))
if (!string.IsNullOrWhiteSpace(AddressBox.Text))
{
_value = val;
EncodeGameGenie();
@ -254,7 +273,7 @@ namespace BizHawk.Client.EmuHawk
{
if (GameGenieCode.Text.Length < 8)
{
var code = String.Empty;
var code = string.Empty;
if (sender == A) code = "A";
if (sender == P) code += "P";
if (sender == Z) code += "Z";
@ -283,7 +302,7 @@ namespace BizHawk.Client.EmuHawk
{
if (Encoding.Checked && AddressBox.Text.Length > 0)
{
if (!String.IsNullOrEmpty(ValueBox.Text))
if (!string.IsNullOrEmpty(ValueBox.Text))
{
EncodeGameGenie();
}
@ -298,7 +317,7 @@ namespace BizHawk.Client.EmuHawk
{
if (CompareBox.Text.Length > 0)
{
int c = int.Parse(CompareBox.Text, NumberStyles.HexNumber);
var c = int.Parse(CompareBox.Text, NumberStyles.HexNumber);
if (c > 0 && c < 0x100)
{
if (ValueBox.Text.Length > 0 && AddressBox.Text.Length > 0)
@ -335,6 +354,12 @@ namespace BizHawk.Client.EmuHawk
TryEnableAddCheat();
}
protected override void OnShown(EventArgs e)
{
RefreshFloatingWindowControl();
base.OnShown(e);
}
#endregion
#endregion