SNES Game Genie dialog - Always on Top, Floating Window, refactor
This commit is contained in:
parent
239ce987da
commit
791a4d655b
|
@ -467,10 +467,8 @@ namespace BizHawk.Client.Common
|
|||
public bool NESGGAutoload = false;
|
||||
|
||||
// SNES Game Genie Encoder/Decoder
|
||||
public ToolDialogSettings SnesGGSettings = new ToolDialogSettings();
|
||||
public bool SNESGGAutoload = false;
|
||||
public bool SNESGGSaveWindowPosition = true;
|
||||
public int SNESGGWndx = -1;
|
||||
public int SNESGGWndy = -1;
|
||||
|
||||
// GB/GG Game Genie Encoder/Decoder
|
||||
public ToolDialogSettings GbGGSettings = new ToolDialogSettings();
|
||||
|
|
|
@ -57,13 +57,15 @@
|
|||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.ClearButton = new System.Windows.Forms.Button();
|
||||
this.menuStrip1 = new MenuStripEx();
|
||||
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AutoloadMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.cheatname = new System.Windows.Forms.TextBox();
|
||||
this.CheatNameBox = new System.Windows.Forms.TextBox();
|
||||
this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.GameGenieCodeBox.SuspendLayout();
|
||||
this.ButtonPanel.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
|
@ -92,7 +94,6 @@
|
|||
this.GGCodeMaskBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.GGCodeMaskBox.TextMaskFormat = System.Windows.Forms.MaskFormat.ExcludePromptAndLiterals;
|
||||
this.GGCodeMaskBox.TextChanged += new System.EventHandler(this.GGCodeMaskBox_TextChanged);
|
||||
this.GGCodeMaskBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.GGCodeMaskBox_KeyPress);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
|
@ -384,55 +385,57 @@
|
|||
//
|
||||
this.menuStrip1.ClickThrough = true;
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.optionsToolStripMenuItem});
|
||||
this.OptionsSubMenu});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(302, 24);
|
||||
this.menuStrip1.Size = new System.Drawing.Size(292, 24);
|
||||
this.menuStrip1.TabIndex = 8;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// optionsToolStripMenuItem
|
||||
// OptionsSubMenu
|
||||
//
|
||||
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.autoloadToolStripMenuItem,
|
||||
this.saveWindowPositionToolStripMenuItem,
|
||||
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.AutoloadMenuItem,
|
||||
this.SaveWindowPositionMenuItem,
|
||||
this.AlwaysOnTopMenuItem,
|
||||
this.FloatingWindowMenuItem,
|
||||
this.toolStripSeparator1,
|
||||
this.exitToolStripMenuItem});
|
||||
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
||||
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
|
||||
this.optionsToolStripMenuItem.Text = "&Options";
|
||||
this.optionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.optionsToolStripMenuItem_DropDownOpened);
|
||||
this.ExitMenuItem});
|
||||
this.OptionsSubMenu.Name = "OptionsSubMenu";
|
||||
this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20);
|
||||
this.OptionsSubMenu.Text = "&Options";
|
||||
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
|
||||
//
|
||||
// autoloadToolStripMenuItem
|
||||
// AutoloadMenuItem
|
||||
//
|
||||
this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem";
|
||||
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.autoloadToolStripMenuItem.Text = "Auto-load";
|
||||
this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click);
|
||||
this.AutoloadMenuItem.Name = "AutoloadMenuItem";
|
||||
this.AutoloadMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.AutoloadMenuItem.Text = "Autoload";
|
||||
this.AutoloadMenuItem.Click += new System.EventHandler(this.AutoloadMenuItem_Click);
|
||||
//
|
||||
// saveWindowPositionToolStripMenuItem
|
||||
// SaveWindowPositionMenuItem
|
||||
//
|
||||
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
|
||||
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position";
|
||||
this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click);
|
||||
this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem";
|
||||
this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.SaveWindowPositionMenuItem.Text = "Save Window Position";
|
||||
this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(188, 6);
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
// ExitMenuItem
|
||||
//
|
||||
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(191, 22);
|
||||
this.exitToolStripMenuItem.Text = "E&xit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
this.ExitMenuItem.Name = "ExitMenuItem";
|
||||
this.ExitMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4)));
|
||||
this.ExitMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.ExitMenuItem.Text = "E&xit";
|
||||
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.cheatname);
|
||||
this.groupBox2.Controls.Add(this.CheatNameBox);
|
||||
this.groupBox2.Location = new System.Drawing.Point(31, 197);
|
||||
this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
|
@ -444,17 +447,31 @@
|
|||
//
|
||||
// cheatname
|
||||
//
|
||||
this.cheatname.Location = new System.Drawing.Point(18, 23);
|
||||
this.cheatname.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cheatname.Name = "cheatname";
|
||||
this.cheatname.Size = new System.Drawing.Size(227, 20);
|
||||
this.cheatname.TabIndex = 0;
|
||||
this.CheatNameBox.Location = new System.Drawing.Point(18, 23);
|
||||
this.CheatNameBox.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.CheatNameBox.Name = "CheatNameBox";
|
||||
this.CheatNameBox.Size = new System.Drawing.Size(227, 20);
|
||||
this.CheatNameBox.TabIndex = 0;
|
||||
//
|
||||
// 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);
|
||||
//
|
||||
// FloatingWindowMenuItem
|
||||
//
|
||||
this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem";
|
||||
this.FloatingWindowMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.FloatingWindowMenuItem.Text = "Floating Window";
|
||||
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
|
||||
//
|
||||
// SNESGameGenie
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(302, 262);
|
||||
this.ClientSize = new System.Drawing.Size(292, 252);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.ClearButton);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
|
@ -471,6 +488,7 @@
|
|||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "SNES Game Genie Encoder / Decoder";
|
||||
this.Load += new System.EventHandler(this.SNESGameGenie_Load);
|
||||
this.GameGenieCodeBox.ResumeLayout(false);
|
||||
this.GameGenieCodeBox.PerformLayout();
|
||||
this.ButtonPanel.ResumeLayout(false);
|
||||
|
@ -515,13 +533,15 @@
|
|||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Button ClearButton;
|
||||
private MenuStripEx menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem OptionsSubMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem AutoloadMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
|
||||
private System.Windows.Forms.MaskedTextBox GGCodeMaskBox;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.TextBox cheatname;
|
||||
private System.Windows.Forms.TextBox CheatNameBox;
|
||||
private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES;
|
||||
|
@ -12,8 +11,53 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class SNESGameGenie : Form, IToolForm
|
||||
{
|
||||
private readonly Dictionary<char, int> GameGenieTable = new Dictionary<char, int>();
|
||||
private bool Processing = false;
|
||||
// including transposition
|
||||
// Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E
|
||||
// Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
private readonly Dictionary<char, int> _gameGenieTable = new Dictionary<char, int>
|
||||
{
|
||||
{ 'D', 0 }, // 0000
|
||||
{ 'F', 1 }, // 0001
|
||||
{ '4', 2 }, // 0010
|
||||
{ '7', 3 }, // 0011
|
||||
{ '0', 4 }, // 0100
|
||||
{ '9', 5 }, // 0101
|
||||
{ '1', 6 }, // 0110
|
||||
{ '5', 7 }, // 0111
|
||||
{ '6', 8 }, // 1000
|
||||
{ 'B', 9 }, // 1001
|
||||
{ 'C', 10 }, // 1010
|
||||
{ '8', 11 }, // 1011
|
||||
{ 'A', 12 }, // 1100
|
||||
{ '2', 13 }, // 1101
|
||||
{ '3', 14 }, // 1110
|
||||
{ 'E', 15 } // 1111
|
||||
};
|
||||
|
||||
private bool _processing;
|
||||
|
||||
public SNESGameGenie()
|
||||
{
|
||||
InitializeComponent();
|
||||
TopMost = Global.Config.SnesGGSettings.TopMost;
|
||||
Closing += (o, e) =>
|
||||
{
|
||||
Global.Config.SnesGGSettings.Wndx = Location.X;
|
||||
Global.Config.SnesGGSettings.Wndy = Location.Y;
|
||||
};
|
||||
}
|
||||
|
||||
private void SNESGameGenie_Load(object sender, EventArgs e)
|
||||
{
|
||||
addcheatbt.Enabled = false;
|
||||
|
||||
if (Global.Config.SnesGGSettings.UseWindowPosition)
|
||||
{
|
||||
Location = Global.Config.SnesGGSettings.WindowPosition;
|
||||
}
|
||||
}
|
||||
|
||||
#region Public API
|
||||
|
||||
public bool AskSave() { return true; }
|
||||
public bool UpdateBefore { get { return false; } }
|
||||
|
@ -24,6 +68,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateValues()
|
||||
{
|
||||
if (!(Global.Emulator is LibsnesCore))
|
||||
|
@ -32,35 +77,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public SNESGameGenie()
|
||||
#endregion
|
||||
|
||||
private void SnesGGDecode(string code, ref int val, ref int add)
|
||||
{
|
||||
InitializeComponent();
|
||||
Closing += (o, e) => SaveConfigSettings();
|
||||
//including transposition
|
||||
//Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E
|
||||
//Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
|
||||
GameGenieTable.Add('D', 0); //0000
|
||||
GameGenieTable.Add('F', 1); //0001
|
||||
GameGenieTable.Add('4', 2); //0010
|
||||
GameGenieTable.Add('7', 3); //0011
|
||||
GameGenieTable.Add('0', 4); //0100
|
||||
GameGenieTable.Add('9', 5); //0101
|
||||
GameGenieTable.Add('1', 6); //0110
|
||||
GameGenieTable.Add('5', 7); //0111
|
||||
GameGenieTable.Add('6', 8); //1000
|
||||
GameGenieTable.Add('B', 9); //1001
|
||||
GameGenieTable.Add('C', 10); //1010
|
||||
GameGenieTable.Add('8', 11); //1011
|
||||
GameGenieTable.Add('A', 12); //1100
|
||||
GameGenieTable.Add('2', 13); //1101
|
||||
GameGenieTable.Add('3', 14); //1110
|
||||
GameGenieTable.Add('E', 15); //1111
|
||||
}
|
||||
|
||||
public void SNESGGDecode(string code, ref int val, ref int add)
|
||||
{
|
||||
|
||||
// Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E
|
||||
// Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
// XXYY-YYYY, where XX is the value, and YY-YYYY is the address.
|
||||
|
@ -68,65 +88,64 @@ namespace BizHawk.Client.EmuHawk
|
|||
// Bit # |3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|
|
||||
// maps to| Value |i|j|k|l|q|r|s|t|o|p|a|b|c|d|u|v|w|x|e|f|g|h|m|n|
|
||||
// order | Value |a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|
|
||||
|
||||
int x;
|
||||
|
||||
// Getting Value
|
||||
if (code.Length > 0)
|
||||
{
|
||||
GameGenieTable.TryGetValue(code[0], out x);
|
||||
_gameGenieTable.TryGetValue(code[0], out x);
|
||||
val = x << 4;
|
||||
}
|
||||
|
||||
if (code.Length > 1)
|
||||
{
|
||||
GameGenieTable.TryGetValue(code[1], out x);
|
||||
_gameGenieTable.TryGetValue(code[1], out x);
|
||||
val |= x;
|
||||
}
|
||||
|
||||
// Address
|
||||
if (code.Length > 2)
|
||||
{
|
||||
GameGenieTable.TryGetValue(code[2], out x);
|
||||
add = (x << 12);
|
||||
_gameGenieTable.TryGetValue(code[2], out x);
|
||||
add = x << 12;
|
||||
}
|
||||
|
||||
if (code.Length > 3)
|
||||
{
|
||||
GameGenieTable.TryGetValue(code[3], out x);
|
||||
add |= (x << 4);
|
||||
_gameGenieTable.TryGetValue(code[3], out x);
|
||||
add |= x << 4;
|
||||
}
|
||||
|
||||
if (code.Length > 4)
|
||||
{
|
||||
GameGenieTable.TryGetValue(code[4], out x);
|
||||
add |= ((x & 0xC) << 6);
|
||||
add |= ((x & 0x3) << 22);
|
||||
_gameGenieTable.TryGetValue(code[4], out x);
|
||||
add |= (x & 0xC) << 6;
|
||||
add |= (x & 0x3) << 22;
|
||||
}
|
||||
|
||||
if (code.Length > 5)
|
||||
{
|
||||
GameGenieTable.TryGetValue(code[5], out x);
|
||||
add |= ((x & 0xC) << 18);
|
||||
add |= ((x & 0x3) << 2);
|
||||
_gameGenieTable.TryGetValue(code[5], out x);
|
||||
add |= (x & 0xC) << 18;
|
||||
add |= (x & 0x3) << 2;
|
||||
}
|
||||
|
||||
if (code.Length > 6)
|
||||
{
|
||||
GameGenieTable.TryGetValue(code[6], out x);
|
||||
add |= ((x & 0xC) >> 2);
|
||||
add |= ((x & 0x3) << 18);
|
||||
_gameGenieTable.TryGetValue(code[6], out x);
|
||||
add |= (x & 0xC) >> 2;
|
||||
add |= (x & 0x3) << 18;
|
||||
}
|
||||
|
||||
if (code.Length > 7)
|
||||
{
|
||||
GameGenieTable.TryGetValue(code[7], out x);
|
||||
add |= ((x & 0xC) << 14);
|
||||
add |= ((x & 0x3) << 10);
|
||||
_gameGenieTable.TryGetValue(code[7], out x);
|
||||
add |= (x & 0xC) << 14;
|
||||
add |= (x & 0x3) << 10;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private string SNESGGEncode(int val, int add)
|
||||
private static string SnesGGEncode(int val, int add)
|
||||
{
|
||||
// Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E
|
||||
// Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
|
@ -135,7 +154,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
// maps to| Value |i|j|k|l|q|r|s|t|o|p|a|b|c|d|u|v|w|x|e|f|g|h|m|n|
|
||||
// order | Value |a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|
|
||||
char[] letters = { 'D', 'F', '4', '7', '0', '9', '1', '5', '6', 'B', 'C', '8', 'A', '2', '3', 'E' };
|
||||
string code = "";
|
||||
var code = string.Empty;
|
||||
int[] num = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
num[0] = (val & 0xF0) >> 4;
|
||||
num[1] = val & 0x0F;
|
||||
|
@ -145,60 +164,229 @@ namespace BizHawk.Client.EmuHawk
|
|||
num[4] = ((add & 0x000300) >> 6) | ((add & 0xC00000) >> 22); // opab
|
||||
num[5] = ((add & 0x300000) >> 18) | ((add & 0x00000C) >> 2); // cduv
|
||||
num[6] = ((add & 0x000003) << 2) | ((add & 0x0C0000) >> 18); // wxef
|
||||
num[7] = ((add & 0x030000) >> 14) | ((add & 0x000C00) >> 10);//ghmn*/
|
||||
for (int x = 0; x < 8; x++)
|
||||
code += letters[num[x]];
|
||||
num[7] = ((add & 0x030000) >> 14) | ((add & 0x000C00) >> 10); // ghmn
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
code += letters[num[i]];
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
private void SNESGameGenie_Load(object sender, EventArgs e)
|
||||
|
||||
private void RefreshFloatingWindowControl()
|
||||
{
|
||||
Owner = Global.Config.SnesGGSettings.FloatingWindow ? null : GlobalWin.MainForm;
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
#region Menu
|
||||
|
||||
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
AutoloadMenuItem.Checked = Global.Config.SNESGGAutoload;
|
||||
SaveWindowPositionMenuItem.Checked = Global.Config.SnesGGSettings.SaveWindowPosition;
|
||||
AlwaysOnTopMenuItem.Checked = Global.Config.SnesGGSettings.TopMost;
|
||||
FloatingWindowMenuItem.Checked = Global.Config.SnesGGSettings.FloatingWindow;
|
||||
}
|
||||
|
||||
private void AutoloadMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.SNESGGAutoload ^= true;
|
||||
}
|
||||
|
||||
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.SnesGGSettings.SaveWindowPosition ^= true;
|
||||
}
|
||||
|
||||
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.SnesGGSettings.TopMost ^= true;
|
||||
TopMost = Global.Config.SnesGGSettings.TopMost;
|
||||
}
|
||||
|
||||
private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.SnesGGSettings.FloatingWindow ^= true;
|
||||
RefreshFloatingWindowControl();
|
||||
}
|
||||
|
||||
private void ExitMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dialog and Controls
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
RefreshFloatingWindowControl();
|
||||
base.OnShown(e);
|
||||
}
|
||||
|
||||
private void ClearButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddressBox.Text = string.Empty;
|
||||
ValueBox.Text = string.Empty;
|
||||
GGCodeMaskBox.Text = string.Empty;
|
||||
addcheatbt.Enabled = false;
|
||||
|
||||
if (Global.Config.SNESGGSaveWindowPosition && Global.Config.SNESGGWndx >= 0 && Global.Config.SNESGGWndy >= 0)
|
||||
Location = new Point(Global.Config.SNESGGWndx, Global.Config.SNESGGWndy);
|
||||
}
|
||||
|
||||
private void SaveConfigSettings()
|
||||
private void AddCheat_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.SNESGGWndx = Location.X;
|
||||
Global.Config.SNESGGWndy = Location.Y;
|
||||
if (Global.Emulator is LibsnesCore)
|
||||
{
|
||||
string name;
|
||||
var address = 0;
|
||||
var value = 0;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(CheatNameBox.Text))
|
||||
{
|
||||
name = CheatNameBox.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
_processing = true;
|
||||
GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals;
|
||||
name = GGCodeMaskBox.Text;
|
||||
GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
|
||||
_processing = false;
|
||||
}
|
||||
|
||||
private void GGCodeMaskBox_KeyPress(object sender, KeyPressEventArgs e)
|
||||
if (!string.IsNullOrWhiteSpace(AddressBox.Text))
|
||||
{
|
||||
// Find a better way to remove all NON HEX char, while still allowing copy/paste
|
||||
//Right now its all done through removing em GGCodeMaskBox_TextChanged
|
||||
address = int.Parse(AddressBox.Text, NumberStyles.HexNumber)
|
||||
+ 0x8000;
|
||||
}
|
||||
|
||||
private void GGCodeMaskBox_TextChanged(object sender, EventArgs e)
|
||||
if (!string.IsNullOrWhiteSpace(ValueBox.Text))
|
||||
{
|
||||
|
||||
if (Processing == false)
|
||||
{
|
||||
Processing = true;
|
||||
//insert REGEX Remove non HEXA char
|
||||
if (Regex.IsMatch(GGCodeMaskBox.Text, @"[^a-fA-F0-9]"))
|
||||
{
|
||||
string temp = Regex.Replace(GGCodeMaskBox.Text, @"[^a-fA-F0-9]", string.Empty);
|
||||
GGCodeMaskBox.Text = temp;
|
||||
value = byte.Parse(ValueBox.Text, NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
if (GGCodeMaskBox.Text.Length > 0)
|
||||
var watch = Watch.GenerateWatch(
|
||||
Global.Emulator.MemoryDomains["BUS"],
|
||||
address,
|
||||
Watch.WatchSize.Byte,
|
||||
Watch.DisplayType.Hex,
|
||||
name,
|
||||
bigEndian: false
|
||||
);
|
||||
|
||||
Global.CheatList.Add(new Cheat(
|
||||
watch,
|
||||
value
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private void AddressBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
int val = 0;
|
||||
int add = 0;
|
||||
SNESGGDecode(GGCodeMaskBox.Text, ref val, ref add);
|
||||
AddressBox.Text = String.Format("{0:X6}", add);
|
||||
ValueBox.Text = String.Format("{0:X2}", val);
|
||||
// Remove invalid character when pasted
|
||||
if (_processing == false)
|
||||
{
|
||||
_processing = true;
|
||||
if (Regex.IsMatch(AddressBox.Text, @"[^a-fA-F0-9]"))
|
||||
{
|
||||
AddressBox.Text = Regex.Replace(AddressBox.Text, @"[^a-fA-F0-9]", string.Empty);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(AddressBox.Text) || !string.IsNullOrEmpty(ValueBox.Text))
|
||||
{
|
||||
int val = 0, add = 0;
|
||||
if (!string.IsNullOrEmpty(AddressBox.Text))
|
||||
{
|
||||
add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(ValueBox.Text))
|
||||
{
|
||||
val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
GGCodeMaskBox.Text = SnesGGEncode(val, add);
|
||||
addcheatbt.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddressBox.Text = "";
|
||||
ValueBox.Text = "";
|
||||
GGCodeMaskBox.Text = string.Empty;
|
||||
addcheatbt.Enabled = false;
|
||||
}
|
||||
Processing = false;
|
||||
|
||||
_processing = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ValueBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_processing == false)
|
||||
{
|
||||
_processing = true;
|
||||
|
||||
// remove invalid character when pasted
|
||||
if (Regex.IsMatch(ValueBox.Text, @"[^a-fA-F0-9]"))
|
||||
{
|
||||
ValueBox.Text = Regex.Replace(ValueBox.Text, @"[^a-fA-F0-9]", string.Empty);
|
||||
}
|
||||
|
||||
if ((AddressBox.Text.Length > 0) || (ValueBox.Text.Length > 0))
|
||||
{
|
||||
int val = 0, add = 0;
|
||||
if (ValueBox.Text.Length > 0)
|
||||
{
|
||||
val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
if (AddressBox.Text.Length > 0)
|
||||
{
|
||||
add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
GGCodeMaskBox.Text = SnesGGEncode(val, add);
|
||||
addcheatbt.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GGCodeMaskBox.Text = string.Empty;
|
||||
addcheatbt.Enabled = false;
|
||||
}
|
||||
|
||||
_processing = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void GGCodeMaskBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_processing == false)
|
||||
{
|
||||
_processing = true;
|
||||
|
||||
// insert REGEX Remove non HEXA char
|
||||
if (Regex.IsMatch(GGCodeMaskBox.Text, @"[^a-fA-F0-9]"))
|
||||
{
|
||||
GGCodeMaskBox.Text = Regex.Replace(GGCodeMaskBox.Text, @"[^a-fA-F0-9]", string.Empty);
|
||||
}
|
||||
|
||||
if (GGCodeMaskBox.Text.Length > 0)
|
||||
{
|
||||
int val = 0, add = 0;
|
||||
SnesGGDecode(GGCodeMaskBox.Text, ref val, ref add);
|
||||
AddressBox.Text = string.Format("{0:X6}", add);
|
||||
ValueBox.Text = string.Format("{0:X2}", val);
|
||||
addcheatbt.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddressBox.Text = string.Empty;
|
||||
ValueBox.Text = string.Empty;
|
||||
addcheatbt.Enabled = false;
|
||||
}
|
||||
|
||||
_processing = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +394,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (GGCodeMaskBox.Text.Length < 8)
|
||||
{
|
||||
string code = "";
|
||||
var code = string.Empty;
|
||||
if (sender == B0) code = "0";
|
||||
if (sender == B1) code = "1";
|
||||
if (sender == B2) code = "2";
|
||||
|
@ -225,173 +413,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (sender == BF) code = "F";
|
||||
|
||||
GGCodeMaskBox.Text += code;
|
||||
//int x = GGCodeMaskBox.SelectionStart;
|
||||
//GGCodeMaskBox.Text = GGCodeMaskBox.Text.Insert(x, code);
|
||||
//GGCodeMaskBox.SelectionStart = x + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddressBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
//remove invalid character when pasted
|
||||
if (Processing == false)
|
||||
{
|
||||
Processing = true;
|
||||
if (Regex.IsMatch(AddressBox.Text, @"[^a-fA-F0-9]"))
|
||||
{
|
||||
string temp = Regex.Replace(AddressBox.Text, @"[^a-fA-F0-9]", string.Empty);
|
||||
AddressBox.Text = temp;
|
||||
}
|
||||
if ((AddressBox.Text.Length > 0) || (ValueBox.Text.Length > 0))
|
||||
{
|
||||
int val = 0;
|
||||
int add = 0;
|
||||
if (ValueBox.Text.Length > 0)
|
||||
val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
|
||||
if (AddressBox.Text.Length > 0)
|
||||
add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
|
||||
GGCodeMaskBox.Text = SNESGGEncode(val, add);
|
||||
addcheatbt.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GGCodeMaskBox.Text = "";
|
||||
addcheatbt.Enabled = false;
|
||||
}
|
||||
Processing = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ValueBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Processing == false)
|
||||
{
|
||||
Processing = true;
|
||||
//remove invalid character when pasted
|
||||
if (Regex.IsMatch(ValueBox.Text, @"[^a-fA-F0-9]"))
|
||||
{
|
||||
string temp = Regex.Replace(ValueBox.Text, @"[^a-fA-F0-9]", string.Empty);
|
||||
ValueBox.Text = temp;
|
||||
}
|
||||
if ((AddressBox.Text.Length > 0) || (ValueBox.Text.Length > 0))
|
||||
{
|
||||
int val = 0;
|
||||
int add = 0;
|
||||
if (ValueBox.Text.Length > 0)
|
||||
val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
|
||||
if (AddressBox.Text.Length > 0)
|
||||
add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
|
||||
GGCodeMaskBox.Text = SNESGGEncode(val, add);
|
||||
addcheatbt.Enabled = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
GGCodeMaskBox.Text = "";
|
||||
addcheatbt.Enabled = false;
|
||||
}
|
||||
Processing = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void ClearButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddressBox.Text = "";
|
||||
ValueBox.Text = "";
|
||||
GGCodeMaskBox.Text = "";
|
||||
addcheatbt.Enabled = false;
|
||||
}
|
||||
|
||||
private void AddCheat_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Global.Emulator is LibsnesCore)
|
||||
{
|
||||
string NAME;
|
||||
int ADDRESS = 0;
|
||||
int VALUE = 0;
|
||||
int sysBusIndex = 0;
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(cheatname.Text))
|
||||
{
|
||||
NAME = cheatname.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
Processing = true;
|
||||
GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals;
|
||||
NAME = GGCodeMaskBox.Text;
|
||||
GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
|
||||
Processing = false;
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(AddressBox.Text))
|
||||
{
|
||||
ADDRESS = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
|
||||
ADDRESS += 0x8000;
|
||||
}
|
||||
if (!String.IsNullOrWhiteSpace(ValueBox.Text))
|
||||
{
|
||||
VALUE = (byte)(int.Parse(ValueBox.Text, NumberStyles.HexNumber));
|
||||
}
|
||||
|
||||
for (int i = 0; i < Global.Emulator.MemoryDomains.Count; i++)
|
||||
{
|
||||
if (Global.Emulator.MemoryDomains[i].ToString() == "BUS")
|
||||
{
|
||||
sysBusIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Watch watch = Watch.GenerateWatch(
|
||||
Global.Emulator.MemoryDomains[sysBusIndex],
|
||||
ADDRESS,
|
||||
Watch.WatchSize.Byte,
|
||||
Watch.DisplayType.Hex,
|
||||
NAME,
|
||||
bigEndian: false
|
||||
);
|
||||
|
||||
Global.CheatList.Add(new Cheat(
|
||||
watch,
|
||||
VALUE,
|
||||
compare: null,
|
||||
enabled: true
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.SNESGGSaveWindowPosition ^= true;
|
||||
}
|
||||
|
||||
private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.SNESGGAutoload ^= true;
|
||||
}
|
||||
|
||||
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
autoloadToolStripMenuItem.Checked = Global.Config.SNESGGAutoload;
|
||||
saveWindowPositionToolStripMenuItem.Checked = Global.Config.SNESGGSaveWindowPosition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue