fixs spaces into tabs in a bunch of files because I'm tired of fixing it gradually

This commit is contained in:
andres.delikat 2011-06-19 23:39:25 +00:00
parent 38422fda10
commit 5bda595ee7
19 changed files with 2926 additions and 2914 deletions

View File

@ -28,88 +28,89 @@
/// </summary>
private void InitializeComponent()
{
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.lvMembers = new System.Windows.Forms.ListView();
this.colSize = new System.Windows.Forms.ColumnHeader();
this.colName = new System.Windows.Forms.ColumnHeader();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.Controls.Add(this.btnCancel);
this.flowLayoutPanel1.Controls.Add(this.btnOK);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 276);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(528, 29);
this.flowLayoutPanel1.TabIndex = 0;
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(450, 3);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(369, 3);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 0;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// lvMembers
//
this.lvMembers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.lvMembers = new System.Windows.Forms.ListView();
this.colSize = new System.Windows.Forms.ColumnHeader();
this.colName = new System.Windows.Forms.ColumnHeader();
this.flowLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.Controls.Add(this.btnCancel);
this.flowLayoutPanel1.Controls.Add(this.btnOK);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 276);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(528, 29);
this.flowLayoutPanel1.TabIndex = 0;
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(450, 3);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(369, 3);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 0;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// lvMembers
//
this.lvMembers.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colSize,
this.colName});
this.lvMembers.Dock = System.Windows.Forms.DockStyle.Fill;
this.lvMembers.FullRowSelect = true;
this.lvMembers.GridLines = true;
this.lvMembers.Location = new System.Drawing.Point(0, 0);
this.lvMembers.Name = "lvMembers";
this.lvMembers.Size = new System.Drawing.Size(528, 276);
this.lvMembers.TabIndex = 0;
this.lvMembers.UseCompatibleStateImageBehavior = false;
this.lvMembers.View = System.Windows.Forms.View.Details;
this.lvMembers.ItemActivate += new System.EventHandler(this.lvMembers_ItemActivate);
//
// colSize
//
this.colSize.Text = "Size";
//
// colName
//
this.colName.Text = "Name";
this.colName.Width = 409;
//
// ArchiveChooser
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(528, 305);
this.Controls.Add(this.lvMembers);
this.Controls.Add(this.flowLayoutPanel1);
this.Name = "ArchiveChooser";
this.ShowIcon = false;
this.Text = "Choose File From Archive";
this.flowLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
this.lvMembers.Dock = System.Windows.Forms.DockStyle.Fill;
this.lvMembers.FullRowSelect = true;
this.lvMembers.GridLines = true;
this.lvMembers.Location = new System.Drawing.Point(0, 0);
this.lvMembers.Name = "lvMembers";
this.lvMembers.Size = new System.Drawing.Size(528, 276);
this.lvMembers.TabIndex = 0;
this.lvMembers.UseCompatibleStateImageBehavior = false;
this.lvMembers.View = System.Windows.Forms.View.Details;
this.lvMembers.ItemActivate += new System.EventHandler(this.lvMembers_ItemActivate);
//
// colSize
//
this.colSize.Text = "Size";
//
// colName
//
this.colName.Text = "Name";
this.colName.Width = 409;
//
// ArchiveChooser
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(528, 305);
this.Controls.Add(this.lvMembers);
this.Controls.Add(this.flowLayoutPanel1);
this.Name = "ArchiveChooser";
this.ShowIcon = false;
this.Text = "Choose File From Archive";
this.Load += new System.EventHandler(this.ArchiveChooser_Load);
this.flowLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}

View File

@ -51,5 +51,10 @@ namespace BizHawk.MultiClient
DialogResult = DialogResult.OK;
Close();
}
private void ArchiveChooser_Load(object sender, EventArgs e)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -3,37 +3,37 @@ using Newtonsoft.Json;
namespace BizHawk.MultiClient
{
public static class ConfigService
{
public static T Load<T>(string filepath) where T : new()
{
T config = new T();
public static class ConfigService
{
public static T Load<T>(string filepath) where T : new()
{
T config = new T();
try
{
var file = new FileInfo(filepath);
if(file.Exists)
try
{
var file = new FileInfo(filepath);
if (file.Exists)
using (var reader = file.OpenText())
{
var s = new JsonSerializer();
var r = new JsonReader(reader);
config = (T) s.Deserialize(r, typeof (T));
config = (T)s.Deserialize(r, typeof(T));
}
}
catch { }
}
catch { }
if (config == null) return new T();
else return config;
}
else return config;
}
public static void Save(string filepath, object config)
{
var file = new FileInfo(filepath);
using (var writer = file.CreateText())
{
var s = new JsonSerializer();
var w = new JsonWriter(writer) { Formatting = Formatting.Indented };
s.Serialize(w, config);
}
}
}
public static void Save(string filepath, object config)
{
var file = new FileInfo(filepath);
using (var writer = file.CreateText())
{
var s = new JsonSerializer();
var w = new JsonWriter(writer) { Formatting = Formatting.Indented };
s.Serialize(w, config);
}
}
}
}

View File

@ -3,24 +3,24 @@ using SlimDX.DirectSound;
namespace BizHawk.MultiClient
{
public static class Global
{
public static MainForm MainForm;
public static DirectSound DSound;
public static Direct3D Direct3D;
public static Sound Sound;
public static IRenderer RenderPanel;
public static Config Config;
public static IEmulator Emulator;
public static class Global
{
public static MainForm MainForm;
public static DirectSound DSound;
public static Direct3D Direct3D;
public static Sound Sound;
public static IRenderer RenderPanel;
public static Config Config;
public static IEmulator Emulator;
public static CoreInputComm CoreInputComm;
public static RomGame Game;
public static Controller ClientControls;
public static Controller SMSControls;
public static Controller PCEControls;
public static Controller GenControls;
public static RomGame Game;
public static Controller ClientControls;
public static Controller SMSControls;
public static Controller PCEControls;
public static Controller GenControls;
public static Controller TI83Controls;
public static Controller NESControls;
public static Controller ActiveController;
public static Controller NullControls;
}
public static Controller ActiveController;
public static Controller NullControls;
}
}

View File

@ -9,8 +9,8 @@ namespace BizHawk.MultiClient
//split into "bind" and "open (the bound thing)"
//scan archive to flatten interior directories down to a path (maintain our own archive item list)
public class HawkFile : IDisposable
{
public class HawkFile : IDisposable
{
public static bool ExistsAt(string path)
{
using (var file = new HawkFile(path))
@ -62,7 +62,7 @@ namespace BizHawk.MultiClient
/// <summary>
/// returns the complete canonical full path ("c:\path\to\archive|member") of the bound file
/// </summary>
public string CanonicalFullPath { get { return MakeCanonicalName(rootPath,memberPath); } }
public string CanonicalFullPath { get { return MakeCanonicalName(rootPath, memberPath); } }
/// <summary>
/// returns the complete canonical name ("archive|member") of the bound file
@ -72,7 +72,7 @@ namespace BizHawk.MultiClient
/// <summary>
/// returns the virtual name of the bound file (disregarding the archive)
/// </summary>
public string Name { get { return GetBoundNameFromCanonical(MakeCanonicalName(rootPath,memberPath)); } }
public string Name { get { return GetBoundNameFromCanonical(MakeCanonicalName(rootPath, memberPath)); } }
/// <summary>
/// returns the extension of Name
@ -111,7 +111,7 @@ namespace BizHawk.MultiClient
List<ArchiveItem> archiveItems;
public HawkFile(string path)
{
{
string autobind = null;
bool isArchivePath = IsCanonicalArchivePath(path);
if (isArchivePath)
@ -121,11 +121,11 @@ namespace BizHawk.MultiClient
autobind = parts[1];
}
var fi = new FileInfo(path);
var fi = new FileInfo(path);
rootExists = fi.Exists;
if (fi.Exists == false)
return;
return;
rootPath = path;
exists = true;
@ -158,7 +158,7 @@ namespace BizHawk.MultiClient
exists = false;
}
}
}
/// <summary>
/// is the supplied path a canonical name including an archive?
@ -204,7 +204,7 @@ namespace BizHawk.MultiClient
boundStream.Position = 0;
memberPath = FixArchiveFilename(extractor.ArchiveFileNames[archiveIndex]); //TODO - maybe go through our own list of names? maybe not, its indexes dont match..
Console.WriteLine("bound " + CanonicalFullPath);
return this;
}
@ -244,7 +244,7 @@ namespace BizHawk.MultiClient
return BindByExtensionCore(false, extensions);
}
/// <summary>
/// <summary>
/// Binds the first item in the archive (or the file itself) if the extension matches one of the supplied templates.
/// You probably should not use this. use BindSoleItemOf or the archive chooser instead
/// </summary>
@ -308,7 +308,7 @@ namespace BizHawk.MultiClient
}
private void AnalyzeArchive(string path)
{
{
SevenZip.FileChecker.ThrowExceptions = false;
int offset;
bool isExecutable;
@ -326,17 +326,17 @@ namespace BizHawk.MultiClient
archiveItems = null;
}
}
}
}
public void Dispose()
{
public void Dispose()
{
Unbind();
if (extractor != null) extractor.Dispose();
if (rootStream != null) rootStream.Dispose();
extractor = null;
rootStream = null;
}
}
}
}

View File

@ -4,108 +4,108 @@ using System.Text;
namespace BizHawk.MultiClient
{
public class Controller : IController
{
private ControllerDefinition type;
private Dictionary<string,List<string>> bindings = new Dictionary<string, List<string>>();
private Dictionary<string,bool> stickyButtons = new Dictionary<string, bool>();
private List<string> unpressedButtons = new List<string>();
private List<string> forcePressedButtons = new List<string>();
private List<string> removeFromForcePressedButtons = new List<string>();
private List<string> programmaticallyPressedButtons = new List<string>();
public class Controller : IController
{
private ControllerDefinition type;
private Dictionary<string, List<string>> bindings = new Dictionary<string, List<string>>();
private Dictionary<string, bool> stickyButtons = new Dictionary<string, bool>();
private List<string> unpressedButtons = new List<string>();
private List<string> forcePressedButtons = new List<string>();
private List<string> removeFromForcePressedButtons = new List<string>();
private List<string> programmaticallyPressedButtons = new List<string>();
private bool movieMode;
public bool MovieMode
{
get { return movieMode; }
set
{
movieMode = value;
if (value == false)
programmaticallyPressedButtons.Clear();
}
}
private bool movieMode;
public bool MovieMode
{
get { return movieMode; }
set
{
movieMode = value;
if (value == false)
programmaticallyPressedButtons.Clear();
}
}
public Controller(ControllerDefinition definition)
{
type = definition;
public Controller(ControllerDefinition definition)
{
type = definition;
foreach (var b in type.BoolButtons)
{
bindings[b] = new List<string>();
stickyButtons[b] = false;
}
foreach (var b in type.BoolButtons)
{
bindings[b] = new List<string>();
stickyButtons[b] = false;
}
foreach (var f in type.FloatControls)
bindings[f] = new List<string>();
}
public void BindButton(string button, string control)
{
bindings[button].Add(control);
}
foreach (var f in type.FloatControls)
bindings[f] = new List<string>();
}
public void BindMulti(string button, string controlString)
{
if (string.IsNullOrEmpty(controlString))
return;
string[] controlbindings = controlString.Split(',');
foreach (string control in controlbindings)
public void BindButton(string button, string control)
{
bindings[button].Add(control);
}
public void BindMulti(string button, string controlString)
{
if (string.IsNullOrEmpty(controlString))
return;
string[] controlbindings = controlString.Split(',');
foreach (string control in controlbindings)
bindings[button].Add(control.Trim());
}
}
public ControllerDefinition Type
{
get { return type; }
}
public ControllerDefinition Type
{
get { return type; }
}
public bool this[string button]
{
get { return IsPressed(button); }
}
public bool IsPressed(string button)
{
if (MovieMode)
{
return programmaticallyPressedButtons.Contains(button);
}
if (forcePressedButtons.Contains(button))
{
removeFromForcePressedButtons.Add(button);
return true;
}
if (unpressedButtons.Contains(button))
{
if (IsPressedActually(button) == false)
unpressedButtons.Remove(button);
public bool this[string button]
{
get { return IsPressed(button); }
}
return false;
}
public bool IsPressed(string button)
{
if (MovieMode)
{
return programmaticallyPressedButtons.Contains(button);
}
if (forcePressedButtons.Contains(button))
{
removeFromForcePressedButtons.Add(button);
return true;
}
if (unpressedButtons.Contains(button))
{
if (IsPressedActually(button) == false)
unpressedButtons.Remove(button);
if (Global.Config.AllowUD_LR == false)
{
string prefix;
return false;
}
if (button.Contains("Down"))
{
prefix = button.GetPrecedingString("Down");
if (IsPressed(prefix + "Up"))
return false;
}
if (button.Contains("Right"))
{
prefix = button.GetPrecedingString("Right");
if (IsPressed(prefix + "Left"))
return false;
}
}
if (Global.Config.AllowUD_LR == false)
{
string prefix;
return IsPressedActually(button);
}
if (button.Contains("Down"))
{
prefix = button.GetPrecedingString("Down");
if (IsPressed(prefix + "Up"))
return false;
}
if (button.Contains("Right"))
{
prefix = button.GetPrecedingString("Right");
if (IsPressed(prefix + "Left"))
return false;
}
}
public bool IsPressedActually(string button)
{
return IsPressedActually(button);
}
public bool IsPressedActually(string button)
{
bool sticky = stickyButtons[button];
foreach (var control in bindings[button])
@ -113,95 +113,95 @@ namespace BizHawk.MultiClient
return sticky ? false : true;
return sticky ? true : false;
}
}
public float GetFloat(string name)
{
throw new NotImplementedException();
}
public float GetFloat(string name)
{
throw new NotImplementedException();
}
public void UnpressButton(string name)
{
unpressedButtons.Add(name);
}
public void UnpressButton(string name)
{
unpressedButtons.Add(name);
}
private int frameNumber;
private int frameNumber;
public void UpdateControls(int frame)
{
if (frame != frameNumber)
{
// update
unpressedButtons.RemoveAll(button => IsPressedActually(button) == false);
forcePressedButtons.RemoveAll(button => removeFromForcePressedButtons.Contains(button));
removeFromForcePressedButtons.Clear();
}
frameNumber = frame;
}
public void UpdateControls(int frame)
{
if (frame != frameNumber)
{
// update
unpressedButtons.RemoveAll(button => IsPressedActually(button) == false);
forcePressedButtons.RemoveAll(button => removeFromForcePressedButtons.Contains(button));
removeFromForcePressedButtons.Clear();
}
frameNumber = frame;
}
public void SetSticky(string button, bool sticky)
{
stickyButtons[button] = sticky;
}
public void SetSticky(string button, bool sticky)
{
stickyButtons[button] = sticky;
}
public bool IsSticky(string button)
{
return stickyButtons[button];
}
public bool IsSticky(string button)
{
return stickyButtons[button];
}
public void ForceButton(string button)
{
forcePressedButtons.Add(button);
}
public void ForceButton(string button)
{
forcePressedButtons.Add(button);
}
public string GetControllersAsMnemonic()
{
StringBuilder input = new StringBuilder("|");
if (type.Name == "SMS Controller")
{
input.Append(IsPressed("P1 Up") ? "U" : ".");
input.Append(IsPressed("P1 Down") ? "D" : ".");
input.Append(IsPressed("P1 Left") ? "L" : ".");
input.Append(IsPressed("P1 Right") ? "R" : ".");
input.Append(IsPressed("P1 B1") ? "1" : ".");
input.Append(IsPressed("P1 B2") ? "2" : ".");
input.Append("|");
input.Append(IsPressed("P2 Up") ? "U" : ".");
input.Append(IsPressed("P2 Down") ? "D" : ".");
input.Append(IsPressed("P2 Left") ? "L" : ".");
input.Append(IsPressed("P2 Right") ? "R" : ".");
input.Append(IsPressed("P2 B1") ? "1" : ".");
input.Append(IsPressed("P2 B2") ? "2" : ".");
input.Append("|");
input.Append(IsPressed("Pause") ? "P" : ".");
input.Append(IsPressed("Reset") ? "R" : ".");
input.Append("|");
return input.ToString();
}
public string GetControllersAsMnemonic()
{
StringBuilder input = new StringBuilder("|");
if (type.Name == "PC Engine Controller")
{
input.Append("."); //TODO: reset goes here - the turbografx DOES NOT HAVE A RESET BUTTON. but I assume this is for pcejin movie file compatibility, which is a fools errand anyway......... I'll leave it for now, but marked for deletion
input.Append("|");
for (int player = 1; player < 6; player++)
{
input.Append(IsPressed("P" + player.ToString() + " Up") ? "U" : ".");
input.Append(IsPressed("P" + player.ToString() + " Down") ? "D" : ".");
input.Append(IsPressed("P" + player.ToString() + " Left") ? "L" : ".");
input.Append(IsPressed("P" + player.ToString() + " Right") ? "R" : ".");
input.Append(IsPressed("P" + player.ToString() + " B1") ? "1" : ".");
input.Append(IsPressed("P" + player.ToString() + " B2") ? "2" : ".");
input.Append(IsPressed("P" + player.ToString() + " Run") ? "R" : ".");
input.Append(IsPressed("P" + player.ToString() + " Select") ? "S" : ".");
input.Append("|");
}
return input.ToString();
}
if (type.Name == "SMS Controller")
{
input.Append(IsPressed("P1 Up") ? "U" : ".");
input.Append(IsPressed("P1 Down") ? "D" : ".");
input.Append(IsPressed("P1 Left") ? "L" : ".");
input.Append(IsPressed("P1 Right") ? "R" : ".");
input.Append(IsPressed("P1 B1") ? "1" : ".");
input.Append(IsPressed("P1 B2") ? "2" : ".");
input.Append("|");
input.Append(IsPressed("P2 Up") ? "U" : ".");
input.Append(IsPressed("P2 Down") ? "D" : ".");
input.Append(IsPressed("P2 Left") ? "L" : ".");
input.Append(IsPressed("P2 Right") ? "R" : ".");
input.Append(IsPressed("P2 B1") ? "1" : ".");
input.Append(IsPressed("P2 B2") ? "2" : ".");
input.Append("|");
input.Append(IsPressed("Pause") ? "P" : ".");
input.Append(IsPressed("Reset") ? "R" : ".");
input.Append("|");
return input.ToString();
}
if (type.Name == "NES Controls")
{
if (type.Name == "PC Engine Controller")
{
input.Append("."); //TODO: reset goes here - the turbografx DOES NOT HAVE A RESET BUTTON. but I assume this is for pcejin movie file compatibility, which is a fools errand anyway......... I'll leave it for now, but marked for deletion
input.Append("|");
for (int player = 1; player < 6; player++)
{
input.Append(IsPressed("P" + player.ToString() + " Up") ? "U" : ".");
input.Append(IsPressed("P" + player.ToString() + " Down") ? "D" : ".");
input.Append(IsPressed("P" + player.ToString() + " Left") ? "L" : ".");
input.Append(IsPressed("P" + player.ToString() + " Right") ? "R" : ".");
input.Append(IsPressed("P" + player.ToString() + " B1") ? "1" : ".");
input.Append(IsPressed("P" + player.ToString() + " B2") ? "2" : ".");
input.Append(IsPressed("P" + player.ToString() + " Run") ? "R" : ".");
input.Append(IsPressed("P" + player.ToString() + " Select") ? "S" : ".");
input.Append("|");
}
return input.ToString();
}
if (type.Name == "NES Controls")
{
input.Append(IsPressed("Reset") ? "r" : ".");
input.Append("|");
for (int player = 1; player <= 2; player++)
@ -216,154 +216,154 @@ namespace BizHawk.MultiClient
input.Append(IsPressed("P" + player.ToString() + " A") ? "A" : ".");
input.Append("|");
}
return input.ToString();
}
return input.ToString();
}
if (type.Name == "TI83 Controls")
{
input.Append(IsPressed("0") ? "0" : ".");
input.Append(IsPressed("1") ? "1" : ".");
input.Append(IsPressed("2") ? "2" : ".");
input.Append(IsPressed("3") ? "3" : ".");
input.Append(IsPressed("4") ? "4" : ".");
input.Append(IsPressed("5") ? "5" : ".");
input.Append(IsPressed("6") ? "6" : ".");
input.Append(IsPressed("7") ? "7" : ".");
input.Append(IsPressed("8") ? "8" : ".");
input.Append(IsPressed("9") ? "9" : ".");
input.Append(IsPressed("DOT") ? "`" : ".");
input.Append(IsPressed("ON") ? "O" : ".");
input.Append(IsPressed("ENTER") ? "=" : ".");
input.Append(IsPressed("UP") ? "U" : ".");
input.Append(IsPressed("DOWN") ? "D" : ".");
input.Append(IsPressed("LEFT") ? "L" : ".");
input.Append(IsPressed("RIGHT") ? "R": ".");
input.Append(IsPressed("PLUS") ? "+": ".");
input.Append(IsPressed("MINUS") ? "_": ".");
input.Append(IsPressed("MULTIPLY") ? "*": ".");
input.Append(IsPressed("DIVIDE") ? "/": ".");
input.Append(IsPressed("CLEAR") ? "c": ".");
input.Append(IsPressed("EXP") ? "^": ".");
input.Append(IsPressed("DASH") ? "-": ".");
input.Append(IsPressed("PARAOPEN") ? "(" : ".");
input.Append(IsPressed("PARACLOSE") ? ")" : ".");
input.Append(IsPressed("TAN") ? "T" : ".");
input.Append(IsPressed("VARS") ? "V" : ".");
input.Append(IsPressed("COS") ? "C" : ".");
input.Append(IsPressed("PRGM") ? "P" : ".");
input.Append(IsPressed("STAT") ? "s" : ".");
input.Append(IsPressed("MATRIX") ? "m" : ".");
input.Append(IsPressed("X") ? "X" : ".");
input.Append(IsPressed("STO") ? ">" : ".");
input.Append(IsPressed("LN") ? "n" : ".");
input.Append(IsPressed("LOG") ? "L" : ".");
input.Append(IsPressed("SQUARED") ? "2" : ".");
input.Append(IsPressed("NEG1") ? "1" : ".");
input.Append(IsPressed("MATH") ? "H" : ".");
input.Append(IsPressed("ALPHA") ? "A" : ".");
input.Append(IsPressed("GRAPH") ? "G" : ".");
input.Append(IsPressed("TRACE") ? "t" : ".");
input.Append(IsPressed("ZOOM") ? "Z" : ".");
input.Append(IsPressed("WINDOW") ? "W" : ".");
input.Append(IsPressed("Y") ? "Y" : ".");
input.Append(IsPressed("2ND") ? "&" : ".");
input.Append(IsPressed("MODE") ? "O" : ".");
input.Append(IsPressed("DEL") ? "D" : ".");
input.Append(IsPressed("COMMA") ? "," : ".");
input.Append(IsPressed("SIN") ? "S" : ".");
input.Append("|.|"); //TODO: perhaps ON should go here?
return input.ToString();
}
return "?";
}
if (type.Name == "TI83 Controls")
{
input.Append(IsPressed("0") ? "0" : ".");
input.Append(IsPressed("1") ? "1" : ".");
input.Append(IsPressed("2") ? "2" : ".");
input.Append(IsPressed("3") ? "3" : ".");
input.Append(IsPressed("4") ? "4" : ".");
input.Append(IsPressed("5") ? "5" : ".");
input.Append(IsPressed("6") ? "6" : ".");
input.Append(IsPressed("7") ? "7" : ".");
input.Append(IsPressed("8") ? "8" : ".");
input.Append(IsPressed("9") ? "9" : ".");
input.Append(IsPressed("DOT") ? "`" : ".");
input.Append(IsPressed("ON") ? "O" : ".");
input.Append(IsPressed("ENTER") ? "=" : ".");
input.Append(IsPressed("UP") ? "U" : ".");
input.Append(IsPressed("DOWN") ? "D" : ".");
input.Append(IsPressed("LEFT") ? "L" : ".");
input.Append(IsPressed("RIGHT") ? "R" : ".");
input.Append(IsPressed("PLUS") ? "+" : ".");
input.Append(IsPressed("MINUS") ? "_" : ".");
input.Append(IsPressed("MULTIPLY") ? "*" : ".");
input.Append(IsPressed("DIVIDE") ? "/" : ".");
input.Append(IsPressed("CLEAR") ? "c" : ".");
input.Append(IsPressed("EXP") ? "^" : ".");
input.Append(IsPressed("DASH") ? "-" : ".");
input.Append(IsPressed("PARAOPEN") ? "(" : ".");
input.Append(IsPressed("PARACLOSE") ? ")" : ".");
input.Append(IsPressed("TAN") ? "T" : ".");
input.Append(IsPressed("VARS") ? "V" : ".");
input.Append(IsPressed("COS") ? "C" : ".");
input.Append(IsPressed("PRGM") ? "P" : ".");
input.Append(IsPressed("STAT") ? "s" : ".");
input.Append(IsPressed("MATRIX") ? "m" : ".");
input.Append(IsPressed("X") ? "X" : ".");
input.Append(IsPressed("STO") ? ">" : ".");
input.Append(IsPressed("LN") ? "n" : ".");
input.Append(IsPressed("LOG") ? "L" : ".");
input.Append(IsPressed("SQUARED") ? "2" : ".");
input.Append(IsPressed("NEG1") ? "1" : ".");
input.Append(IsPressed("MATH") ? "H" : ".");
input.Append(IsPressed("ALPHA") ? "A" : ".");
input.Append(IsPressed("GRAPH") ? "G" : ".");
input.Append(IsPressed("TRACE") ? "t" : ".");
input.Append(IsPressed("ZOOM") ? "Z" : ".");
input.Append(IsPressed("WINDOW") ? "W" : ".");
input.Append(IsPressed("Y") ? "Y" : ".");
input.Append(IsPressed("2ND") ? "&" : ".");
input.Append(IsPressed("MODE") ? "O" : ".");
input.Append(IsPressed("DEL") ? "D" : ".");
input.Append(IsPressed("COMMA") ? "," : ".");
input.Append(IsPressed("SIN") ? "S" : ".");
input.Append("|.|"); //TODO: perhaps ON should go here?
return input.ToString();
}
return "?";
}
public void SetControllersAsMnemonic(string mnemonic)
{
MovieMode = true;
programmaticallyPressedButtons.Clear();
public void SetControllersAsMnemonic(string mnemonic)
{
MovieMode = true;
programmaticallyPressedButtons.Clear();
if (type.Name == "SMS Controller")
{
if (mnemonic[1] != '.') programmaticallyPressedButtons.Add("P1 Up");
if (mnemonic[2] != '.') programmaticallyPressedButtons.Add("P1 Down");
if (mnemonic[3] != '.') programmaticallyPressedButtons.Add("P1 Left");
if (mnemonic[4] != '.') programmaticallyPressedButtons.Add("P1 Right");
if (mnemonic[5] != '.') programmaticallyPressedButtons.Add("P1 B1");
if (mnemonic[6] != '.') programmaticallyPressedButtons.Add("P1 B2");
if (type.Name == "SMS Controller")
{
if (mnemonic[1] != '.') programmaticallyPressedButtons.Add("P1 Up");
if (mnemonic[2] != '.') programmaticallyPressedButtons.Add("P1 Down");
if (mnemonic[3] != '.') programmaticallyPressedButtons.Add("P1 Left");
if (mnemonic[4] != '.') programmaticallyPressedButtons.Add("P1 Right");
if (mnemonic[5] != '.') programmaticallyPressedButtons.Add("P1 B1");
if (mnemonic[6] != '.') programmaticallyPressedButtons.Add("P1 B2");
if (mnemonic[8] != '.') programmaticallyPressedButtons.Add("P2 Up");
if (mnemonic[9] != '.') programmaticallyPressedButtons.Add("P2 Down");
if (mnemonic[10] != '.') programmaticallyPressedButtons.Add("P2 Left");
if (mnemonic[11] != '.') programmaticallyPressedButtons.Add("P2 Right");
if (mnemonic[12] != '.') programmaticallyPressedButtons.Add("P2 B1");
if (mnemonic[13] != '.') programmaticallyPressedButtons.Add("P2 B2");
if (mnemonic[8] != '.') programmaticallyPressedButtons.Add("P2 Up");
if (mnemonic[9] != '.') programmaticallyPressedButtons.Add("P2 Down");
if (mnemonic[10] != '.') programmaticallyPressedButtons.Add("P2 Left");
if (mnemonic[11] != '.') programmaticallyPressedButtons.Add("P2 Right");
if (mnemonic[12] != '.') programmaticallyPressedButtons.Add("P2 B1");
if (mnemonic[13] != '.') programmaticallyPressedButtons.Add("P2 B2");
if (mnemonic[15] != '.') programmaticallyPressedButtons.Add("Pause");
if (mnemonic[16] != '.') programmaticallyPressedButtons.Add("Reset");
}
if (mnemonic[15] != '.') programmaticallyPressedButtons.Add("Pause");
if (mnemonic[16] != '.') programmaticallyPressedButtons.Add("Reset");
}
if (type.Name == "PC Engine Controller")
{
if (!Global.MainForm.UserMovie.MultiTrack.isActive || (Global.MainForm.UserMovie.GetMovieMode() == MOVIEMODE.PLAY))
{
for (int i = 1; i < 6; i++)
{
if (mnemonic.Length < (1 + i * 9)) return;
if (mnemonic[(i - 1) * 9 + 3] != '.') programmaticallyPressedButtons.Add("P" + i + " Up");
if (mnemonic[(i - 1) * 9 + 4] != '.') programmaticallyPressedButtons.Add("P" + i + " Down");
if (mnemonic[(i - 1) * 9 + 5] != '.') programmaticallyPressedButtons.Add("P" + i + " Left");
if (mnemonic[(i - 1) * 9 + 6] != '.') programmaticallyPressedButtons.Add("P" + i + " Right");
if (mnemonic[(i - 1) * 9 + 7] != '.') programmaticallyPressedButtons.Add("P" + i + " B1");
if (mnemonic[(i - 1) * 9 + 8] != '.') programmaticallyPressedButtons.Add("P" + i + " B2");
if (mnemonic[(i - 1) * 9 + 9] != '.') programmaticallyPressedButtons.Add("P" + i + " Run");
if (mnemonic[(i - 1) * 9 + 10] != '.') programmaticallyPressedButtons.Add("P" + i + " Select");
}
}
else
{
for (int i = 1; i < 6; i++)
{
if ((Global.MainForm.UserMovie.MultiTrack.CurrentPlayer == i) || Global.MainForm.UserMovie.MultiTrack.RecordAll)
{
if (IsPressedActually("P1 Up")) programmaticallyPressedButtons.Add("P" + i + " Up");
if (IsPressedActually("P1 Down")) programmaticallyPressedButtons.Add("P" + i + " Down");
if (IsPressedActually("P1 Left")) programmaticallyPressedButtons.Add("P" + i + " Left");
if (IsPressedActually("P1 Right")) programmaticallyPressedButtons.Add("P" + i + " Right");
if (IsPressedActually("P1 B1")) programmaticallyPressedButtons.Add("P" + i + " B1");
if (IsPressedActually("P1 B2")) programmaticallyPressedButtons.Add("P" + i + " B2");
if (IsPressedActually("P1 Run")) programmaticallyPressedButtons.Add("P" + i + " Run");
if (IsPressedActually("P1 Select")) programmaticallyPressedButtons.Add("P" + i + " Select");
}
else
{
if (mnemonic.Length >= (1 + i * 9))
{
if (mnemonic[(i - 1) * 9 + 3] != '.') programmaticallyPressedButtons.Add("P" + i + " Up");
if (mnemonic[(i - 1) * 9 + 4] != '.') programmaticallyPressedButtons.Add("P" + i + " Down");
if (mnemonic[(i - 1) * 9 + 5] != '.') programmaticallyPressedButtons.Add("P" + i + " Left");
if (mnemonic[(i - 1) * 9 + 6] != '.') programmaticallyPressedButtons.Add("P" + i + " Right");
if (mnemonic[(i - 1) * 9 + 7] != '.') programmaticallyPressedButtons.Add("P" + i + " B1");
if (mnemonic[(i - 1) * 9 + 8] != '.') programmaticallyPressedButtons.Add("P" + i + " B2");
if (mnemonic[(i - 1) * 9 + 9] != '.') programmaticallyPressedButtons.Add("P" + i + " Run");
if (mnemonic[(i - 1) * 9 + 10] != '.') programmaticallyPressedButtons.Add("P" + i + " Select");
}
}
}
}
}
if (type.Name == "PC Engine Controller")
{
if (!Global.MainForm.UserMovie.MultiTrack.isActive || (Global.MainForm.UserMovie.GetMovieMode() == MOVIEMODE.PLAY))
{
for (int i = 1; i < 6; i++)
{
if (mnemonic.Length < (1 + i * 9)) return;
if (mnemonic[(i - 1) * 9 + 3] != '.') programmaticallyPressedButtons.Add("P" + i + " Up");
if (mnemonic[(i - 1) * 9 + 4] != '.') programmaticallyPressedButtons.Add("P" + i + " Down");
if (mnemonic[(i - 1) * 9 + 5] != '.') programmaticallyPressedButtons.Add("P" + i + " Left");
if (mnemonic[(i - 1) * 9 + 6] != '.') programmaticallyPressedButtons.Add("P" + i + " Right");
if (mnemonic[(i - 1) * 9 + 7] != '.') programmaticallyPressedButtons.Add("P" + i + " B1");
if (mnemonic[(i - 1) * 9 + 8] != '.') programmaticallyPressedButtons.Add("P" + i + " B2");
if (mnemonic[(i - 1) * 9 + 9] != '.') programmaticallyPressedButtons.Add("P" + i + " Run");
if (mnemonic[(i - 1) * 9 + 10] != '.') programmaticallyPressedButtons.Add("P" + i + " Select");
}
}
else
{
for (int i = 1; i < 6; i++)
{
if ((Global.MainForm.UserMovie.MultiTrack.CurrentPlayer == i) || Global.MainForm.UserMovie.MultiTrack.RecordAll)
{
if (IsPressedActually("P1 Up")) programmaticallyPressedButtons.Add("P" + i + " Up");
if (IsPressedActually("P1 Down")) programmaticallyPressedButtons.Add("P" + i + " Down");
if (IsPressedActually("P1 Left")) programmaticallyPressedButtons.Add("P" + i + " Left");
if (IsPressedActually("P1 Right")) programmaticallyPressedButtons.Add("P" + i + " Right");
if (IsPressedActually("P1 B1")) programmaticallyPressedButtons.Add("P" + i + " B1");
if (IsPressedActually("P1 B2")) programmaticallyPressedButtons.Add("P" + i + " B2");
if (IsPressedActually("P1 Run")) programmaticallyPressedButtons.Add("P" + i + " Run");
if (IsPressedActually("P1 Select")) programmaticallyPressedButtons.Add("P" + i + " Select");
}
else
{
if (mnemonic.Length >= (1 + i * 9))
{
if (mnemonic[(i - 1) * 9 + 3] != '.') programmaticallyPressedButtons.Add("P" + i + " Up");
if (mnemonic[(i - 1) * 9 + 4] != '.') programmaticallyPressedButtons.Add("P" + i + " Down");
if (mnemonic[(i - 1) * 9 + 5] != '.') programmaticallyPressedButtons.Add("P" + i + " Left");
if (mnemonic[(i - 1) * 9 + 6] != '.') programmaticallyPressedButtons.Add("P" + i + " Right");
if (mnemonic[(i - 1) * 9 + 7] != '.') programmaticallyPressedButtons.Add("P" + i + " B1");
if (mnemonic[(i - 1) * 9 + 8] != '.') programmaticallyPressedButtons.Add("P" + i + " B2");
if (mnemonic[(i - 1) * 9 + 9] != '.') programmaticallyPressedButtons.Add("P" + i + " Run");
if (mnemonic[(i - 1) * 9 + 10] != '.') programmaticallyPressedButtons.Add("P" + i + " Select");
}
}
}
}
}
if (type.Name == "NES Controls")
{
if (mnemonic.Length < 10) return;
//if (mnemonic[1] != '.' && mnemonic[1] != '0') programmaticallyPressedButtons.Add("Reset");
if (mnemonic[3] != '.') programmaticallyPressedButtons.Add("P1 Right");
if (type.Name == "NES Controls")
{
if (mnemonic.Length < 10) return;
//if (mnemonic[1] != '.' && mnemonic[1] != '0') programmaticallyPressedButtons.Add("Reset");
if (mnemonic[3] != '.') programmaticallyPressedButtons.Add("P1 Right");
if (mnemonic[4] != '.') programmaticallyPressedButtons.Add("P1 Left");
if (mnemonic[5] != '.') programmaticallyPressedButtons.Add("P1 Down");
if (mnemonic[6] != '.') programmaticallyPressedButtons.Add("P1 Up");
if (mnemonic[7] != '.') programmaticallyPressedButtons.Add("P1 Start");
if (mnemonic[8] != '.') programmaticallyPressedButtons.Add("P1 Select");
if (mnemonic[9] != '.') programmaticallyPressedButtons.Add("P1 B");
if (mnemonic[10] != '.') programmaticallyPressedButtons.Add("P1 A");
if (mnemonic[10] != '.') programmaticallyPressedButtons.Add("P1 A");
if (mnemonic.Length < 20) return;
if (mnemonic[12] != '.') programmaticallyPressedButtons.Add("P2 Right");
@ -374,113 +374,113 @@ namespace BizHawk.MultiClient
if (mnemonic[17] != '.') programmaticallyPressedButtons.Add("P2 Select");
if (mnemonic[18] != '.') programmaticallyPressedButtons.Add("P2 B");
if (mnemonic[19] != '.') programmaticallyPressedButtons.Add("P2 A");
}
}
if (type.Name == "TI83 Controls")
{
if (mnemonic.Length < 50) return;
if (type.Name == "TI83 Controls")
{
if (mnemonic.Length < 50) return;
if (mnemonic[1] != '.')
programmaticallyPressedButtons.Add("0");
if (mnemonic[2] != '.')
programmaticallyPressedButtons.Add("1");
if (mnemonic[3] != '.')
programmaticallyPressedButtons.Add("2");
if (mnemonic[4] != '.')
programmaticallyPressedButtons.Add("3");
if (mnemonic[5] != '.')
programmaticallyPressedButtons.Add("4");
if (mnemonic[6] != '.')
programmaticallyPressedButtons.Add("5");
if (mnemonic[7] != '.')
programmaticallyPressedButtons.Add("6");
if (mnemonic[8] != '.')
programmaticallyPressedButtons.Add("7");
if (mnemonic[9] != '.')
programmaticallyPressedButtons.Add("8");
if (mnemonic[10] != '.')
programmaticallyPressedButtons.Add("9");
if (mnemonic[11] != '.')
programmaticallyPressedButtons.Add("DOT");
if (mnemonic[12] != '.')
programmaticallyPressedButtons.Add("ON");
if (mnemonic[13] != '.')
programmaticallyPressedButtons.Add("ENTER");
if (mnemonic[14] != '.')
programmaticallyPressedButtons.Add("UP");
if (mnemonic[15] != '.')
programmaticallyPressedButtons.Add("DOWN");
if (mnemonic[16] != '.')
programmaticallyPressedButtons.Add("LEFT");
if (mnemonic[17] != '.')
programmaticallyPressedButtons.Add("RIGHT");
if (mnemonic[18] != '.')
programmaticallyPressedButtons.Add("PLUS");
if (mnemonic[19] != '.')
programmaticallyPressedButtons.Add("MINUS");
if (mnemonic[20] != '.')
programmaticallyPressedButtons.Add("MULTIPLY");
if (mnemonic[21] != '.')
programmaticallyPressedButtons.Add("DIVIDE");
if (mnemonic[22] != '.')
programmaticallyPressedButtons.Add("CLEAR");
if (mnemonic[23] != '.')
programmaticallyPressedButtons.Add("EXP");
if (mnemonic[24] != '.')
programmaticallyPressedButtons.Add("DASH");
if (mnemonic[25] != '.')
programmaticallyPressedButtons.Add("PARAOPEN");
if (mnemonic[26] != '.')
programmaticallyPressedButtons.Add("PARACLOSE");
if (mnemonic[27] != '.')
programmaticallyPressedButtons.Add("TAN");
if (mnemonic[28] != '.')
programmaticallyPressedButtons.Add("VARS");
if (mnemonic[29] != '.')
programmaticallyPressedButtons.Add("COS");
if (mnemonic[30] != '.')
programmaticallyPressedButtons.Add("PGRM");
if (mnemonic[31] != '.')
programmaticallyPressedButtons.Add("STAT");
if (mnemonic[32] != '.')
programmaticallyPressedButtons.Add("MATRIX");
if (mnemonic[33] != '.')
programmaticallyPressedButtons.Add("X");
if (mnemonic[34] != '.')
programmaticallyPressedButtons.Add("STO");
if (mnemonic[35] != '.')
programmaticallyPressedButtons.Add("LN");
if (mnemonic[36] != '.')
programmaticallyPressedButtons.Add("LOG");
if (mnemonic[37] != '.')
programmaticallyPressedButtons.Add("SQUARED");
if (mnemonic[38] != '.')
programmaticallyPressedButtons.Add("NEG");
if (mnemonic[39] != '.')
programmaticallyPressedButtons.Add("MATH");
if (mnemonic[40] != '.')
programmaticallyPressedButtons.Add("ALPHA");
if (mnemonic[41] != '.')
programmaticallyPressedButtons.Add("GRAPH");
if (mnemonic[42] != '.')
programmaticallyPressedButtons.Add("TRACE");
if (mnemonic[43] != '.')
programmaticallyPressedButtons.Add("ZOOM");
if (mnemonic[44] != '.')
programmaticallyPressedButtons.Add("WINDOW");
if (mnemonic[45] != '.')
programmaticallyPressedButtons.Add("Y");
if (mnemonic[46] != '.')
programmaticallyPressedButtons.Add("2ND");
if (mnemonic[47] != '.')
programmaticallyPressedButtons.Add("MODE");
if (mnemonic[48] != '.')
programmaticallyPressedButtons.Add("DEL");
if (mnemonic[49] != '.')
programmaticallyPressedButtons.Add("COMMA");
if (mnemonic[50] != '.')
programmaticallyPressedButtons.Add("SIN");
}
}
}
if (mnemonic[1] != '.')
programmaticallyPressedButtons.Add("0");
if (mnemonic[2] != '.')
programmaticallyPressedButtons.Add("1");
if (mnemonic[3] != '.')
programmaticallyPressedButtons.Add("2");
if (mnemonic[4] != '.')
programmaticallyPressedButtons.Add("3");
if (mnemonic[5] != '.')
programmaticallyPressedButtons.Add("4");
if (mnemonic[6] != '.')
programmaticallyPressedButtons.Add("5");
if (mnemonic[7] != '.')
programmaticallyPressedButtons.Add("6");
if (mnemonic[8] != '.')
programmaticallyPressedButtons.Add("7");
if (mnemonic[9] != '.')
programmaticallyPressedButtons.Add("8");
if (mnemonic[10] != '.')
programmaticallyPressedButtons.Add("9");
if (mnemonic[11] != '.')
programmaticallyPressedButtons.Add("DOT");
if (mnemonic[12] != '.')
programmaticallyPressedButtons.Add("ON");
if (mnemonic[13] != '.')
programmaticallyPressedButtons.Add("ENTER");
if (mnemonic[14] != '.')
programmaticallyPressedButtons.Add("UP");
if (mnemonic[15] != '.')
programmaticallyPressedButtons.Add("DOWN");
if (mnemonic[16] != '.')
programmaticallyPressedButtons.Add("LEFT");
if (mnemonic[17] != '.')
programmaticallyPressedButtons.Add("RIGHT");
if (mnemonic[18] != '.')
programmaticallyPressedButtons.Add("PLUS");
if (mnemonic[19] != '.')
programmaticallyPressedButtons.Add("MINUS");
if (mnemonic[20] != '.')
programmaticallyPressedButtons.Add("MULTIPLY");
if (mnemonic[21] != '.')
programmaticallyPressedButtons.Add("DIVIDE");
if (mnemonic[22] != '.')
programmaticallyPressedButtons.Add("CLEAR");
if (mnemonic[23] != '.')
programmaticallyPressedButtons.Add("EXP");
if (mnemonic[24] != '.')
programmaticallyPressedButtons.Add("DASH");
if (mnemonic[25] != '.')
programmaticallyPressedButtons.Add("PARAOPEN");
if (mnemonic[26] != '.')
programmaticallyPressedButtons.Add("PARACLOSE");
if (mnemonic[27] != '.')
programmaticallyPressedButtons.Add("TAN");
if (mnemonic[28] != '.')
programmaticallyPressedButtons.Add("VARS");
if (mnemonic[29] != '.')
programmaticallyPressedButtons.Add("COS");
if (mnemonic[30] != '.')
programmaticallyPressedButtons.Add("PGRM");
if (mnemonic[31] != '.')
programmaticallyPressedButtons.Add("STAT");
if (mnemonic[32] != '.')
programmaticallyPressedButtons.Add("MATRIX");
if (mnemonic[33] != '.')
programmaticallyPressedButtons.Add("X");
if (mnemonic[34] != '.')
programmaticallyPressedButtons.Add("STO");
if (mnemonic[35] != '.')
programmaticallyPressedButtons.Add("LN");
if (mnemonic[36] != '.')
programmaticallyPressedButtons.Add("LOG");
if (mnemonic[37] != '.')
programmaticallyPressedButtons.Add("SQUARED");
if (mnemonic[38] != '.')
programmaticallyPressedButtons.Add("NEG");
if (mnemonic[39] != '.')
programmaticallyPressedButtons.Add("MATH");
if (mnemonic[40] != '.')
programmaticallyPressedButtons.Add("ALPHA");
if (mnemonic[41] != '.')
programmaticallyPressedButtons.Add("GRAPH");
if (mnemonic[42] != '.')
programmaticallyPressedButtons.Add("TRACE");
if (mnemonic[43] != '.')
programmaticallyPressedButtons.Add("ZOOM");
if (mnemonic[44] != '.')
programmaticallyPressedButtons.Add("WINDOW");
if (mnemonic[45] != '.')
programmaticallyPressedButtons.Add("Y");
if (mnemonic[46] != '.')
programmaticallyPressedButtons.Add("2ND");
if (mnemonic[47] != '.')
programmaticallyPressedButtons.Add("MODE");
if (mnemonic[48] != '.')
programmaticallyPressedButtons.Add("DEL");
if (mnemonic[49] != '.')
programmaticallyPressedButtons.Add("COMMA");
if (mnemonic[50] != '.')
programmaticallyPressedButtons.Add("SIN");
}
}
}
}

View File

@ -5,156 +5,156 @@ using SlimDX.DirectInput;
namespace BizHawk.MultiClient
{
public class GamePad
{
// ********************************** Static interface **********************************
public class GamePad
{
// ********************************** Static interface **********************************
private static DirectInput dinput;
public static List<GamePad> Devices;
private static DirectInput dinput;
public static List<GamePad> Devices;
public static void Initialize()
{
if (dinput == null)
dinput = new DirectInput();
public static void Initialize()
{
if (dinput == null)
dinput = new DirectInput();
Devices = new List<GamePad>();
Devices = new List<GamePad>();
foreach (DeviceInstance device in dinput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly))
{
var joystick = new Joystick(dinput, device.InstanceGuid);
joystick.SetCooperativeLevel(Global.MainForm.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
foreach (DeviceObjectInstance deviceObject in joystick.GetObjects())
{
if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0)
joystick.GetObjectPropertiesById((int)deviceObject.ObjectType).SetRange(-1000, 1000);
}
joystick.Acquire();
foreach (DeviceInstance device in dinput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly))
{
var joystick = new Joystick(dinput, device.InstanceGuid);
joystick.SetCooperativeLevel(Global.MainForm.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
foreach (DeviceObjectInstance deviceObject in joystick.GetObjects())
{
if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0)
joystick.GetObjectPropertiesById((int)deviceObject.ObjectType).SetRange(-1000, 1000);
}
joystick.Acquire();
GamePad p = new GamePad(device.InstanceName, device.InstanceGuid, joystick);
Devices.Add(p);
}
}
GamePad p = new GamePad(device.InstanceName, device.InstanceGuid, joystick);
Devices.Add(p);
}
}
public static void UpdateAll()
{
foreach (var device in Devices)
device.Update();
}
public static void UpdateAll()
{
foreach (var device in Devices)
device.Update();
}
// ********************************** Instance Members **********************************
// ********************************** Instance Members **********************************
private readonly string name;
private readonly Guid guid;
private readonly Joystick joystick;
private JoystickState state = new JoystickState();
private bool[] buttons;
private int[] pov;
private readonly string name;
private readonly Guid guid;
private readonly Joystick joystick;
private JoystickState state = new JoystickState();
private bool[] buttons;
private int[] pov;
private GamePad(string name, Guid guid, Joystick joystick)
{
this.name = name;
this.guid = guid;
this.joystick = joystick;
Update();
}
private GamePad(string name, Guid guid, Joystick joystick)
{
this.name = name;
this.guid = guid;
this.joystick = joystick;
Update();
}
public void Update()
{
if (joystick.Acquire().IsFailure)
return;
if (joystick.Poll().IsFailure)
return;
state = joystick.GetCurrentState();
if (Result.Last.IsFailure)
return;
public void Update()
{
if (joystick.Acquire().IsFailure)
return;
if (joystick.Poll().IsFailure)
return;
buttons = state.GetButtons();
pov = state.GetPointOfViewControllers();
}
state = joystick.GetCurrentState();
if (Result.Last.IsFailure)
return;
public string Name { get { return name; } }
public Guid Guid { get { return guid; } }
buttons = state.GetButtons();
pov = state.GetPointOfViewControllers();
}
public float X { get { return state.X / 1000f; } }
public float Y { get { return state.Y / 1000f; } }
public float Z { get { return state.Z / 1000f; } }
public string Name { get { return name; } }
public Guid Guid { get { return guid; } }
public bool[] Buttons { get { return buttons; } }
public bool Up
{
get
{
if (state.Y < -250 || state.RotationY < -250)
return true;
foreach (int p in pov)
if (p.In(0, 4500, 31500))
return true;
return false;
}
}
public float X { get { return state.X / 1000f; } }
public float Y { get { return state.Y / 1000f; } }
public float Z { get { return state.Z / 1000f; } }
public bool Down
{
get
{
if (state.Y > 250 || state.RotationY > 250)
return true;
foreach (int p in pov)
if (p.In(13500, 18000, 22500))
return true;
return false;
}
}
public bool[] Buttons { get { return buttons; } }
public bool Left
{
get
{
if (state.X < -250 || state.RotationX < -250)
return true;
foreach (int p in pov)
if (p.In(22500, 27000, 31500))
return true;
return false;
}
}
public bool Up
{
get
{
if (state.Y < -250 || state.RotationY < -250)
return true;
foreach (int p in pov)
if (p.In(0, 4500, 31500))
return true;
return false;
}
}
public bool Right
{
get
{
if (state.X > 250 || state.RotationX > 250)
return true;
foreach (int p in pov)
if (p.In(4500, 9000, 13500))
return true;
return false;
}
}
public bool Down
{
get
{
if (state.Y > 250 || state.RotationY > 250)
return true;
foreach (int p in pov)
if (p.In(13500, 18000, 22500))
return true;
return false;
}
}
/// <summary>
/// Note that this does not appear to work at this time. I probably need to have more infos.
/// </summary>
public void SetVibration(int left, int right)
{
int[] temp1, temp2;
// my first clue that it doesnt work is that LEFT and RIGHT _ARENT USED_
// I should just look for C++ examples instead of trying to look for SlimDX examples
public bool Left
{
get
{
if (state.X < -250 || state.RotationX < -250)
return true;
foreach (int p in pov)
if (p.In(22500, 27000, 31500))
return true;
return false;
}
}
var parameters = new EffectParameters();
parameters.Duration = 0x2710;
parameters.Gain = 0x2710;
parameters.SamplePeriod = 0;
parameters.TriggerButton = 0;
parameters.TriggerRepeatInterval = 0x2710;
parameters.Flags = EffectFlags.None;
parameters.GetAxes(out temp1, out temp2);
parameters.SetAxes(temp1, temp2);
var effect = new Effect(joystick, EffectGuid.ConstantForce);
effect.SetParameters(parameters);
effect.Start(1);
}
}
public bool Right
{
get
{
if (state.X > 250 || state.RotationX > 250)
return true;
foreach (int p in pov)
if (p.In(4500, 9000, 13500))
return true;
return false;
}
}
/// <summary>
/// Note that this does not appear to work at this time. I probably need to have more infos.
/// </summary>
public void SetVibration(int left, int right)
{
int[] temp1, temp2;
// my first clue that it doesnt work is that LEFT and RIGHT _ARENT USED_
// I should just look for C++ examples instead of trying to look for SlimDX examples
var parameters = new EffectParameters();
parameters.Duration = 0x2710;
parameters.Gain = 0x2710;
parameters.SamplePeriod = 0;
parameters.TriggerButton = 0;
parameters.TriggerRepeatInterval = 0x2710;
parameters.Flags = EffectFlags.None;
parameters.GetAxes(out temp1, out temp2);
parameters.SetAxes(temp1, temp2);
var effect = new Effect(joystick, EffectGuid.ConstantForce);
effect.SetParameters(parameters);
effect.Start(1);
}
}
}

View File

@ -3,40 +3,40 @@ using SlimDX.DirectInput;
namespace BizHawk.MultiClient
{
public static class Input
{
public static void Initialize()
{
KeyInput.Initialize();
GamePad.Initialize();
}
public static class Input
{
public static void Initialize()
{
KeyInput.Initialize();
GamePad.Initialize();
}
public static void Update()
{
KeyInput.Update();
GamePad.UpdateAll();
}
public static void Update()
{
KeyInput.Update();
GamePad.UpdateAll();
}
public static bool IsPressed(string control)
{
string[] controls = control.Split('+');
for (int i=0; i<controls.Length; i++)
{
if (IsPressedSingle(controls[i]) == false)
return false;
}
return true;
}
public static bool IsPressed(string control)
{
string[] controls = control.Split('+');
for (int i = 0; i < controls.Length; i++)
{
if (IsPressedSingle(controls[i]) == false)
return false;
}
return true;
}
private static bool IsPressedSingle(string control)
{
if (string.IsNullOrEmpty(control))
return false;
private static bool IsPressedSingle(string control)
{
if (string.IsNullOrEmpty(control))
return false;
if (control.StartsWith("J1 ")) return GetGamePad(0, control.Substring(3));
if (control.StartsWith("J2 ")) return GetGamePad(1, control.Substring(3));
if (control.StartsWith("J3 ")) return GetGamePad(2, control.Substring(3));
if (control.StartsWith("J4 ")) return GetGamePad(3, control.Substring(3));
if (control.StartsWith("J1 ")) return GetGamePad(0, control.Substring(3));
if (control.StartsWith("J2 ")) return GetGamePad(1, control.Substring(3));
if (control.StartsWith("J3 ")) return GetGamePad(2, control.Substring(3));
if (control.StartsWith("J4 ")) return GetGamePad(3, control.Substring(3));
//Key z = Key.n
Key z = Key.NumberPad4;
Key y = Key.LeftArrow;
@ -45,35 +45,35 @@ namespace BizHawk.MultiClient
int x = 0;
x++;
}
Key k = (Key) Enum.Parse(typeof(Key), control, true);
return KeyInput.IsPressed(k);
}
Key k = (Key)Enum.Parse(typeof(Key), control, true);
return KeyInput.IsPressed(k);
}
private static bool GetGamePad(int index, string control)
{
if (index >= GamePad.Devices.Count)
return false;
private static bool GetGamePad(int index, string control)
{
if (index >= GamePad.Devices.Count)
return false;
if (control == "Up") return GamePad.Devices[index].Up;
if (control == "Down") return GamePad.Devices[index].Down;
if (control == "Left") return GamePad.Devices[index].Left;
if (control == "Right") return GamePad.Devices[index].Right;
if (control == "Up") return GamePad.Devices[index].Up;
if (control == "Down") return GamePad.Devices[index].Down;
if (control == "Left") return GamePad.Devices[index].Left;
if (control == "Right") return GamePad.Devices[index].Right;
if (control.StartsWith("B"))
{
int buttonIndex = int.Parse(control.Substring(1)) - 1;
if (buttonIndex >= GamePad.Devices[index].Buttons.Length)
return false;
return GamePad.Devices[index].Buttons[buttonIndex];
}
if (control.StartsWith("B"))
{
int buttonIndex = int.Parse(control.Substring(1)) - 1;
if (buttonIndex >= GamePad.Devices[index].Buttons.Length)
return false;
return GamePad.Devices[index].Buttons[buttonIndex];
}
return false;
}
return false;
}
public static string GetPressedKey()
{
//for (int j = 0; j < GamePad.Devices.Count; j++)
return null;
}
}
public static string GetPressedKey()
{
//for (int j = 0; j < GamePad.Devices.Count; j++)
return null;
}
}
}

View File

@ -1,53 +1,53 @@
namespace BizHawk.MultiClient
{
public class MruStack<T>
{
private T[] store;
private int count;
private int head;
public class MruStack<T>
{
private T[] store;
private int count;
private int head;
public int Count { get { return count; } }
public int Count { get { return count; } }
public MruStack(int capacity)
{
store = new T[capacity];
Clear();
}
public MruStack(int capacity)
{
store = new T[capacity];
Clear();
}
public void Clear()
{
head = 0;
count = 0;
for (int i = 0; i < store.Length; i++)
store[i] = default(T);
}
public void Clear()
{
head = 0;
count = 0;
for (int i = 0; i < store.Length; i++)
store[i] = default(T);
}
public void Push(T value)
{
store[head] = value;
head = (head + 1) % store.Length;
public void Push(T value)
{
store[head] = value;
head = (head + 1) % store.Length;
if (count < store.Length)
count++;
}
if (count < store.Length)
count++;
}
public T Pop()
{
if (count == 0)
return default(T);
public T Pop()
{
if (count == 0)
return default(T);
head--;
if (head < 0)
head = store.Length - 1;
count--;
T value = store[head];
store[head] = default(T);
return value;
}
head--;
if (head < 0)
head = store.Length - 1;
count--;
T value = store[head];
store[head] = default(T);
return value;
}
public bool HasElements()
{
return count > 0;
}
}
public bool HasElements()
{
return count > 0;
}
}
}

View File

@ -6,21 +6,22 @@ using Microsoft.VisualBasic.ApplicationServices;
namespace BizHawk.MultiClient
{
static class Program
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
static class Program
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Global.Config = ConfigService.Load<Config>(PathManager.DefaultIniPath);
try { Global.DSound = new DirectSound(); }
catch {
MessageBox.Show("Couldn't initialize DirectSound!");
return;
}
try { Global.DSound = new DirectSound(); }
catch
{
MessageBox.Show("Couldn't initialize DirectSound!");
return;
}
try { Global.Direct3D = new Direct3D(); }
catch
@ -29,55 +30,60 @@ namespace BizHawk.MultiClient
Global.Config.ForceGDI = true;
}
try {
if (Global.Config.SingleInstanceMode)
{
SingleInstanceController controller = new SingleInstanceController(args);
controller.Run(args);
}
else
{
var mf = new MainForm(args);
mf.Show();
mf.ProgramRunLoop();
}
} catch (Exception e) {
try
{
if (Global.Config.SingleInstanceMode)
{
SingleInstanceController controller = new SingleInstanceController(args);
controller.Run(args);
}
else
{
var mf = new MainForm(args);
mf.Show();
mf.ProgramRunLoop();
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Oh, no, a terrible thing happened!\n\n" + e.ToString());
} finally {
if (Global.DSound != null && Global.DSound.Disposed == false)
Global.DSound.Dispose();
if (Global.Direct3D != null && Global.Direct3D.Disposed == false)
Global.Direct3D.Dispose();
}
}
}
finally
{
if (Global.DSound != null && Global.DSound.Disposed == false)
Global.DSound.Dispose();
if (Global.Direct3D != null && Global.Direct3D.Disposed == false)
Global.Direct3D.Dispose();
}
public class SingleInstanceController : WindowsFormsApplicationBase
{
MainForm mf;
string[] cmdArgs;
public SingleInstanceController(string[] args)
{
cmdArgs = args;
IsSingleInstance = true;
StartupNextInstance += this_StartupNextInstance;
}
}
void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
{
mf.LoadRom(e.CommandLine[0]);
}
public class SingleInstanceController : WindowsFormsApplicationBase
{
MainForm mf;
string[] cmdArgs;
public SingleInstanceController(string[] args)
{
cmdArgs = args;
IsSingleInstance = true;
StartupNextInstance += this_StartupNextInstance;
protected override void OnCreateMainForm()
{
MainForm = new RamWatch();
}
mf = new MainForm(cmdArgs);
MainForm = mf;
mf.Show();
mf.ProgramRunLoop();
}
}
}
void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
{
mf.LoadRom(e.CommandLine[0]);
}
protected override void OnCreateMainForm()
{
MainForm = new RamWatch();
mf = new MainForm(cmdArgs);
MainForm = mf;
mf.Show();
mf.ProgramRunLoop();
}
}
}
}

View File

@ -3,84 +3,84 @@ using System.Text;
namespace BizHawk.MultiClient
{
public class RecentFiles
{
private int MAX_RECENT_FILES; //Maximum number of files
private List<string> recentlist; //List of recent files
public class RecentFiles
{
private int MAX_RECENT_FILES; //Maximum number of files
private List<string> recentlist; //List of recent files
public RecentFiles() : this(8) {}
public RecentFiles(int max)
{
recentlist = new List<string>();
MAX_RECENT_FILES = max;
}
public void Clear()
{
recentlist.Clear();
}
public RecentFiles() : this(8) { }
public RecentFiles(int max)
{
recentlist = new List<string>();
MAX_RECENT_FILES = max;
}
public bool IsEmpty()
{
if (recentlist.Count == 0)
return true;
else
return false;
}
public void Clear()
{
recentlist.Clear();
}
public int Length()
{
return recentlist.Count;
}
public bool IsEmpty()
{
if (recentlist.Count == 0)
return true;
else
return false;
}
public void Add(string newFile)
{
for (int x = 0; x < recentlist.Count; x++)
{
if (string.Compare(newFile, recentlist[x]) == 0)
{
recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
}
}
recentlist.Insert(0, newFile);
if (recentlist.Count > MAX_RECENT_FILES)
recentlist.Remove(recentlist[recentlist.Count-1]);
}
public int Length()
{
return recentlist.Count;
}
public bool Remove(string newFile)
{
bool removed = false;
for (int x = 0; x < recentlist.Count; x++)
{
if (string.Compare(newFile, recentlist[x]) == 0)
{
recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
removed = true;
}
public void Add(string newFile)
{
for (int x = 0; x < recentlist.Count; x++)
{
if (string.Compare(newFile, recentlist[x]) == 0)
{
recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
}
}
recentlist.Insert(0, newFile);
if (recentlist.Count > MAX_RECENT_FILES)
recentlist.Remove(recentlist[recentlist.Count - 1]);
}
}
return removed;
}
public bool Remove(string newFile)
{
bool removed = false;
for (int x = 0; x < recentlist.Count; x++)
{
if (string.Compare(newFile, recentlist[x]) == 0)
{
recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
removed = true;
}
public List<string> GetRecentList()
{
return recentlist;
}
}
return removed;
}
public List<string> GetRecentListTruncated(int length)
{
//iterate through list, truncating each item to length, and return the result in a List<string>
List<string> temp = new List<string>();
for (int x = 0; x < recentlist.Count; x++)
{
temp.Add(recentlist[x].Substring(0, length));
}
return temp;
}
public List<string> GetRecentList()
{
return recentlist;
}
public string GetRecentFileByPosition(int position)
{
return recentlist[position];
}
}
public List<string> GetRecentListTruncated(int length)
{
//iterate through list, truncating each item to length, and return the result in a List<string>
List<string> temp = new List<string>();
for (int x = 0; x < recentlist.Count; x++)
{
temp.Add(recentlist[x].Substring(0, length));
}
return temp;
}
public string GetRecentFileByPosition(int position)
{
return recentlist[position];
}
}
}

View File

@ -3,45 +3,45 @@ using System.Runtime.InteropServices;
namespace BizHawk.MultiClient
{
// Derived from http://www.codeproject.com/KB/cs/ScreenSaverControl.aspx
public static class ScreenSaver
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern bool SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int flags);
// Derived from http://www.codeproject.com/KB/cs/ScreenSaverControl.aspx
public static class ScreenSaver
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern bool SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int flags);
private const int SPI_GETSCREENSAVERTIMEOUT = 14;
private const int SPI_SETSCREENSAVERTIMEOUT = 15;
private const int SPIF_SENDWININICHANGE = 2;
private const int SPI_GETSCREENSAVERTIMEOUT = 14;
private const int SPI_SETSCREENSAVERTIMEOUT = 15;
private const int SPIF_SENDWININICHANGE = 2;
public static void ResetTimerImmediate()
{
SetScreenSaverTimeout(GetScreenSaverTimeout());
}
public static void ResetTimerImmediate()
{
SetScreenSaverTimeout(GetScreenSaverTimeout());
}
private static int ctr;
public static void ResetTimerPeriodically()
{
ctr++;
if (ctr == 120)
{
SetScreenSaverTimeout(GetScreenSaverTimeout());
ctr = 0;
}
}
private static int ctr;
public static void ResetTimerPeriodically()
{
ctr++;
if (ctr == 120)
{
SetScreenSaverTimeout(GetScreenSaverTimeout());
ctr = 0;
}
}
// Returns the screen saver timeout setting, in seconds
private static Int32 GetScreenSaverTimeout()
{
Int32 value = 0;
SystemParametersInfo(SPI_GETSCREENSAVERTIMEOUT, 0, ref value, 0);
return value;
}
// Returns the screen saver timeout setting, in seconds
private static Int32 GetScreenSaverTimeout()
{
Int32 value = 0;
SystemParametersInfo(SPI_GETSCREENSAVERTIMEOUT, 0, ref value, 0);
return value;
}
// Pass in the number of seconds to set the screen saver timeout value.
private static void SetScreenSaverTimeout(Int32 Value)
{
int nullVar = 0;
SystemParametersInfo(SPI_SETSCREENSAVERTIMEOUT, Value, ref nullVar, SPIF_SENDWININICHANGE);
}
}
// Pass in the number of seconds to set the screen saver timeout value.
private static void SetScreenSaverTimeout(Int32 Value)
{
int nullVar = 0;
SystemParametersInfo(SPI_SETSCREENSAVERTIMEOUT, Value, ref nullVar, SPIF_SENDWININICHANGE);
}
}
}

View File

@ -9,180 +9,180 @@ using System.Windows.Forms;
namespace BizHawk.MultiClient.tools
{
public partial class HotkeyWindow : Form
{
public HotkeyWindow()
{
InitializeComponent();
IDW_FRAMEADVANCE.Text = Global.Config.FrameAdvanceBinding;
IDW_PAUSE.Text = Global.Config.EmulatorPauseBinding;
IDW_HARDRESET.Text = Global.Config.HardResetBinding;
IDW_REWIND.Text = Global.Config.RewindBinding;
IDW_UNTHROTTLE.Text = Global.Config.UnthrottleBinding;
IDW_FASTFORWARD.Text = Global.Config.FastForwardBinding;
IDW_SCREENSHOT.Text = Global.Config.ScreenshotBinding;
IDW_FULLSCREEN.Text = Global.Config.ToggleFullscreenBinding;
public partial class HotkeyWindow : Form
{
public HotkeyWindow()
{
InitializeComponent();
IDW_FRAMEADVANCE.Text = Global.Config.FrameAdvanceBinding;
IDW_PAUSE.Text = Global.Config.EmulatorPauseBinding;
IDW_HARDRESET.Text = Global.Config.HardResetBinding;
IDW_REWIND.Text = Global.Config.RewindBinding;
IDW_UNTHROTTLE.Text = Global.Config.UnthrottleBinding;
IDW_FASTFORWARD.Text = Global.Config.FastForwardBinding;
IDW_SCREENSHOT.Text = Global.Config.ScreenshotBinding;
IDW_FULLSCREEN.Text = Global.Config.ToggleFullscreenBinding;
IDW_QuickSave.Text = Global.Config.QuickSave;
IDW_QuickLoad.Text = Global.Config.QuickLoad;
//Save States
IDW_SS0.Text = Global.Config.SaveSlot0;
IDW_SS1.Text = Global.Config.SaveSlot1;
IDW_SS2.Text = Global.Config.SaveSlot2;
IDW_SS3.Text = Global.Config.SaveSlot3;
IDW_SS4.Text = Global.Config.SaveSlot4;
IDW_SS5.Text = Global.Config.SaveSlot5;
IDW_SS6.Text = Global.Config.SaveSlot6;
IDW_SS7.Text = Global.Config.SaveSlot7;
IDW_SS8.Text = Global.Config.SaveSlot8;
IDW_SS9.Text = Global.Config.SaveSlot9;
//Load States
IDW_LS0.Text = Global.Config.LoadSlot0;
IDW_LS1.Text = Global.Config.LoadSlot1;
IDW_LS2.Text = Global.Config.LoadSlot2;
IDW_LS3.Text = Global.Config.LoadSlot3;
IDW_LS4.Text = Global.Config.LoadSlot4;
IDW_LS5.Text = Global.Config.LoadSlot5;
IDW_LS6.Text = Global.Config.LoadSlot6;
IDW_LS7.Text = Global.Config.LoadSlot7;
IDW_LS8.Text = Global.Config.LoadSlot8;
IDW_LS9.Text = Global.Config.LoadSlot9;
//Select States
IDW_ST0.Text = Global.Config.SelectSlot0;
IDW_ST1.Text = Global.Config.SelectSlot1;
IDW_ST2.Text = Global.Config.SelectSlot2;
IDW_ST3.Text = Global.Config.SelectSlot3;
IDW_ST4.Text = Global.Config.SelectSlot4;
IDW_ST5.Text = Global.Config.SelectSlot5;
IDW_ST6.Text = Global.Config.SelectSlot6;
IDW_ST7.Text = Global.Config.SelectSlot7;
IDW_ST8.Text = Global.Config.SelectSlot8;
IDW_ST9.Text = Global.Config.SelectSlot9;
IDW_TOOLBOX.Text = Global.Config.ToolBox;
IDW_SAVENAMEDSTATE.Text = Global.Config.SaveNamedState;
IDW_LOADNAMEDSTATE.Text = Global.Config.LoadNamedState;
IDW_NEXTSLOT.Text = Global.Config.NextSlot;
IDW_PREVIOUSSLOT.Text = Global.Config.PreviousSlot;
IDW_RamWatch.Text = Global.Config.RamWatch;
IDW_RamSearch.Text = Global.Config.RamSearch;
IDW_RamPoke.Text = Global.Config.RamPoke;
IDW_HexEditor.Text = Global.Config.HexEditor;
IDW_LuaConsole.Text = Global.Config.LuaConsole;
IDW_Cheats.Text = Global.Config.Cheats;
IDW_OpenROM.Text = Global.Config.OpenROM;
IDW_CloseROM.Text = Global.Config.CloseROM;
IDW_DisplayFPS.Text = Global.Config.FPSBinding;
IDW_FrameCounter.Text = Global.Config.FrameCounterBinding;
IDW_LagCounter.Text = Global.Config.LagCounterBinding;
IDW_InputDisplay.Text = Global.Config.InputDisplayBinding;
IDW_TOGGLEREADONLY.Text = Global.Config.ReadOnlyToggleBinding;
IDW_PLAYMOVIE.Text = Global.Config.PlayMovieBinding;
IDW_RECORDMOVIE.Text = Global.Config.RecordMovieBinding;
IDW_STOPMOVIE.Text = Global.Config.StopMovieBinding;
IDW_PLAYBEGINNING.Text = Global.Config.PlayBeginningBinding;
IDW_VOLUP.Text = Global.Config.VolUpBinding;
IDW_VOLDOWN.Text = Global.Config.VolDownBinding;
IDW_TOGGLEMTRACK.Text = Global.Config.ToggleMultiTrack;
IDW_SELECTNONE.Text = Global.Config.MTRecordNone;
IDW_MTSELECTALL.Text = Global.Config.MTRecordAll;
IDW_MTINCPLAYER.Text = Global.Config.MTIncrementPlayer;
IDW_MTDECPLAYER.Text = Global.Config.MTDecrementPlayer;
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
IDW_QuickSave.Text = Global.Config.QuickSave;
IDW_QuickLoad.Text = Global.Config.QuickLoad;
//Save States
IDW_SS0.Text = Global.Config.SaveSlot0;
IDW_SS1.Text = Global.Config.SaveSlot1;
IDW_SS2.Text = Global.Config.SaveSlot2;
IDW_SS3.Text = Global.Config.SaveSlot3;
IDW_SS4.Text = Global.Config.SaveSlot4;
IDW_SS5.Text = Global.Config.SaveSlot5;
IDW_SS6.Text = Global.Config.SaveSlot6;
IDW_SS7.Text = Global.Config.SaveSlot7;
IDW_SS8.Text = Global.Config.SaveSlot8;
IDW_SS9.Text = Global.Config.SaveSlot9;
//Load States
IDW_LS0.Text = Global.Config.LoadSlot0;
IDW_LS1.Text = Global.Config.LoadSlot1;
IDW_LS2.Text = Global.Config.LoadSlot2;
IDW_LS3.Text = Global.Config.LoadSlot3;
IDW_LS4.Text = Global.Config.LoadSlot4;
IDW_LS5.Text = Global.Config.LoadSlot5;
IDW_LS6.Text = Global.Config.LoadSlot6;
IDW_LS7.Text = Global.Config.LoadSlot7;
IDW_LS8.Text = Global.Config.LoadSlot8;
IDW_LS9.Text = Global.Config.LoadSlot9;
//Select States
IDW_ST0.Text = Global.Config.SelectSlot0;
IDW_ST1.Text = Global.Config.SelectSlot1;
IDW_ST2.Text = Global.Config.SelectSlot2;
IDW_ST3.Text = Global.Config.SelectSlot3;
IDW_ST4.Text = Global.Config.SelectSlot4;
IDW_ST5.Text = Global.Config.SelectSlot5;
IDW_ST6.Text = Global.Config.SelectSlot6;
IDW_ST7.Text = Global.Config.SelectSlot7;
IDW_ST8.Text = Global.Config.SelectSlot8;
IDW_ST9.Text = Global.Config.SelectSlot9;
IDW_TOOLBOX.Text = Global.Config.ToolBox;
IDW_SAVENAMEDSTATE.Text = Global.Config.SaveNamedState;
IDW_LOADNAMEDSTATE.Text = Global.Config.LoadNamedState;
IDW_NEXTSLOT.Text = Global.Config.NextSlot;
IDW_PREVIOUSSLOT.Text = Global.Config.PreviousSlot;
IDW_RamWatch.Text = Global.Config.RamWatch;
IDW_RamSearch.Text = Global.Config.RamSearch;
IDW_RamPoke.Text = Global.Config.RamPoke;
IDW_HexEditor.Text = Global.Config.HexEditor;
IDW_LuaConsole.Text = Global.Config.LuaConsole;
IDW_Cheats.Text = Global.Config.Cheats;
IDW_OpenROM.Text = Global.Config.OpenROM;
IDW_CloseROM.Text = Global.Config.CloseROM;
IDW_DisplayFPS.Text = Global.Config.FPSBinding;
IDW_FrameCounter.Text = Global.Config.FrameCounterBinding;
IDW_LagCounter.Text = Global.Config.LagCounterBinding;
IDW_InputDisplay.Text = Global.Config.InputDisplayBinding;
IDW_TOGGLEREADONLY.Text = Global.Config.ReadOnlyToggleBinding;
IDW_PLAYMOVIE.Text = Global.Config.PlayMovieBinding;
IDW_RECORDMOVIE.Text = Global.Config.RecordMovieBinding;
IDW_STOPMOVIE.Text = Global.Config.StopMovieBinding;
IDW_PLAYBEGINNING.Text = Global.Config.PlayBeginningBinding;
IDW_VOLUP.Text = Global.Config.VolUpBinding;
IDW_VOLDOWN.Text = Global.Config.VolDownBinding;
IDW_TOGGLEMTRACK.Text = Global.Config.ToggleMultiTrack;
IDW_SELECTNONE.Text = Global.Config.MTRecordNone;
IDW_MTSELECTALL.Text = Global.Config.MTRecordAll;
IDW_MTINCPLAYER.Text = Global.Config.MTIncrementPlayer;
IDW_MTDECPLAYER.Text = Global.Config.MTDecrementPlayer;
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void IDB_SAVE_Click(object sender, EventArgs e)
{
private void IDB_SAVE_Click(object sender, EventArgs e)
{
Global.Config.FastForwardBinding = IDW_FASTFORWARD.Text;
Global.Config.FrameAdvanceBinding = IDW_FRAMEADVANCE.Text;
Global.Config.HardResetBinding = IDW_HARDRESET.Text;
Global.Config.RewindBinding = IDW_REWIND.Text;
Global.Config.UnthrottleBinding = IDW_UNTHROTTLE.Text;
Global.Config.EmulatorPauseBinding = IDW_PAUSE.Text;
Global.Config.ToggleFullscreenBinding = IDW_FULLSCREEN.Text;
Global.Config.ScreenshotBinding = IDW_SCREENSHOT.Text;
Global.Config.FastForwardBinding = IDW_FASTFORWARD.Text;
Global.Config.FrameAdvanceBinding = IDW_FRAMEADVANCE.Text;
Global.Config.HardResetBinding = IDW_HARDRESET.Text;
Global.Config.RewindBinding = IDW_REWIND.Text;
Global.Config.UnthrottleBinding = IDW_UNTHROTTLE.Text;
Global.Config.EmulatorPauseBinding = IDW_PAUSE.Text;
Global.Config.ToggleFullscreenBinding = IDW_FULLSCREEN.Text;
Global.Config.ScreenshotBinding = IDW_SCREENSHOT.Text;
Global.Config.QuickLoad = IDW_QuickLoad.Text;
Global.Config.QuickSave = IDW_QuickSave.Text;
Global.Config.QuickLoad = IDW_QuickLoad.Text;
Global.Config.QuickSave = IDW_QuickSave.Text;
Global.Config.SaveSlot0 = IDW_SS0.Text;
Global.Config.SaveSlot1 = IDW_SS1.Text;
Global.Config.SaveSlot2 = IDW_SS2.Text;
Global.Config.SaveSlot3 = IDW_SS3.Text;
Global.Config.SaveSlot4 = IDW_SS4.Text;
Global.Config.SaveSlot5 = IDW_SS5.Text;
Global.Config.SaveSlot6 = IDW_SS6.Text;
Global.Config.SaveSlot7 = IDW_SS7.Text;
Global.Config.SaveSlot8 = IDW_SS8.Text;
Global.Config.SaveSlot9 = IDW_SS9.Text;
Global.Config.SaveSlot0 = IDW_SS0.Text;
Global.Config.SaveSlot1 = IDW_SS1.Text;
Global.Config.SaveSlot2 = IDW_SS2.Text;
Global.Config.SaveSlot3 = IDW_SS3.Text;
Global.Config.SaveSlot4 = IDW_SS4.Text;
Global.Config.SaveSlot5 = IDW_SS5.Text;
Global.Config.SaveSlot6 = IDW_SS6.Text;
Global.Config.SaveSlot7 = IDW_SS7.Text;
Global.Config.SaveSlot8 = IDW_SS8.Text;
Global.Config.SaveSlot9 = IDW_SS9.Text;
Global.Config.LoadSlot0 = IDW_LS0.Text;
Global.Config.LoadSlot1 = IDW_LS1.Text;
Global.Config.LoadSlot2 = IDW_LS2.Text;
Global.Config.LoadSlot3 = IDW_LS3.Text;
Global.Config.LoadSlot4 = IDW_LS4.Text;
Global.Config.LoadSlot5 = IDW_LS5.Text;
Global.Config.LoadSlot6 = IDW_LS6.Text;
Global.Config.LoadSlot7 = IDW_LS7.Text;
Global.Config.LoadSlot8 = IDW_LS8.Text;
Global.Config.LoadSlot9 = IDW_LS9.Text;
Global.Config.LoadSlot0 = IDW_LS0.Text;
Global.Config.LoadSlot1 = IDW_LS1.Text;
Global.Config.LoadSlot2 = IDW_LS2.Text;
Global.Config.LoadSlot3 = IDW_LS3.Text;
Global.Config.LoadSlot4 = IDW_LS4.Text;
Global.Config.LoadSlot5 = IDW_LS5.Text;
Global.Config.LoadSlot6 = IDW_LS6.Text;
Global.Config.LoadSlot7 = IDW_LS7.Text;
Global.Config.LoadSlot8 = IDW_LS8.Text;
Global.Config.LoadSlot9 = IDW_LS9.Text;
Global.Config.SelectSlot0 = IDW_ST0.Text;
Global.Config.SelectSlot1 = IDW_ST1.Text;
Global.Config.SelectSlot2 = IDW_ST2.Text;
Global.Config.SelectSlot3 = IDW_ST3.Text;
Global.Config.SelectSlot4 = IDW_ST4.Text;
Global.Config.SelectSlot5 = IDW_ST5.Text;
Global.Config.SelectSlot6 = IDW_ST6.Text;
Global.Config.SelectSlot7 = IDW_ST7.Text;
Global.Config.SelectSlot8 = IDW_ST8.Text;
Global.Config.SelectSlot9 = IDW_ST9.Text;
Global.Config.ToolBox = IDW_TOOLBOX.Text;
Global.Config.SaveNamedState = IDW_SAVENAMEDSTATE.Text;
Global.Config.LoadNamedState = IDW_LOADNAMEDSTATE.Text;
Global.Config.PreviousSlot = IDW_PREVIOUSSLOT.Text;
Global.Config.NextSlot = IDW_NEXTSLOT.Text;
Global.Config.RamWatch = IDW_RamWatch.Text;
Global.Config.RamSearch = IDW_RamSearch.Text;
Global.Config.RamPoke = IDW_RamPoke.Text;
Global.Config.HexEditor = IDW_HexEditor.Text;
Global.Config.LuaConsole = IDW_LuaConsole.Text;
Global.Config.Cheats = IDW_Cheats.Text;
Global.Config.OpenROM = IDW_OpenROM.Text;
Global.Config.CloseROM = IDW_CloseROM.Text;
Global.Config.FPSBinding = IDW_DisplayFPS.Text;
Global.Config.FrameCounterBinding = IDW_FrameCounter.Text;
Global.Config.LagCounterBinding = IDW_LagCounter.Text;
Global.Config.InputDisplayBinding = IDW_InputDisplay.Text;
Global.Config.ReadOnlyToggleBinding = IDW_TOGGLEREADONLY.Text;
Global.Config.PlayMovieBinding = IDW_PLAYMOVIE.Text;
Global.Config.RecordMovieBinding = IDW_RECORDMOVIE.Text;
Global.Config.StopMovieBinding = IDW_STOPMOVIE.Text;
Global.Config.PlayBeginningBinding = IDW_PLAYBEGINNING.Text;
Global.Config.VolUpBinding = IDW_VOLUP.Text;
Global.Config.VolDownBinding = IDW_VOLDOWN.Text;
Global.Config.SelectSlot0 = IDW_ST0.Text;
Global.Config.SelectSlot1 = IDW_ST1.Text;
Global.Config.SelectSlot2 = IDW_ST2.Text;
Global.Config.SelectSlot3 = IDW_ST3.Text;
Global.Config.SelectSlot4 = IDW_ST4.Text;
Global.Config.SelectSlot5 = IDW_ST5.Text;
Global.Config.SelectSlot6 = IDW_ST6.Text;
Global.Config.SelectSlot7 = IDW_ST7.Text;
Global.Config.SelectSlot8 = IDW_ST8.Text;
Global.Config.SelectSlot9 = IDW_ST9.Text;
Global.Config.ToolBox = IDW_TOOLBOX.Text;
Global.Config.SaveNamedState = IDW_SAVENAMEDSTATE.Text;
Global.Config.LoadNamedState = IDW_LOADNAMEDSTATE.Text;
Global.Config.PreviousSlot = IDW_PREVIOUSSLOT.Text;
Global.Config.NextSlot = IDW_NEXTSLOT.Text;
Global.Config.RamWatch = IDW_RamWatch.Text;
Global.Config.RamSearch = IDW_RamSearch.Text;
Global.Config.RamPoke = IDW_RamPoke.Text;
Global.Config.HexEditor = IDW_HexEditor.Text;
Global.Config.LuaConsole = IDW_LuaConsole.Text;
Global.Config.Cheats = IDW_Cheats.Text;
Global.Config.OpenROM = IDW_OpenROM.Text;
Global.Config.CloseROM = IDW_CloseROM.Text;
Global.Config.FPSBinding = IDW_DisplayFPS.Text;
Global.Config.FrameCounterBinding = IDW_FrameCounter.Text;
Global.Config.LagCounterBinding = IDW_LagCounter.Text;
Global.Config.InputDisplayBinding = IDW_InputDisplay.Text;
Global.Config.ReadOnlyToggleBinding = IDW_TOGGLEREADONLY.Text;
Global.Config.PlayMovieBinding = IDW_PLAYMOVIE.Text;
Global.Config.RecordMovieBinding = IDW_RECORDMOVIE.Text;
Global.Config.StopMovieBinding = IDW_STOPMOVIE.Text;
Global.Config.PlayBeginningBinding = IDW_PLAYBEGINNING.Text;
Global.Config.VolUpBinding = IDW_VOLUP.Text;
Global.Config.VolDownBinding = IDW_VOLDOWN.Text;
Global.Config.ToggleMultiTrack = IDW_TOGGLEMTRACK.Text;
Global.Config.MTRecordAll = IDW_MTSELECTALL.Text;
Global.Config.MTRecordNone = IDW_SELECTNONE.Text;
Global.Config.MTIncrementPlayer = IDW_MTINCPLAYER.Text;
Global.Config.MTDecrementPlayer = IDW_MTDECPLAYER.Text;
Global.Config.ToggleMultiTrack = IDW_TOGGLEMTRACK.Text;
Global.Config.MTRecordAll = IDW_MTSELECTALL.Text;
Global.Config.MTRecordNone = IDW_SELECTNONE.Text;
Global.Config.MTIncrementPlayer = IDW_MTINCPLAYER.Text;
Global.Config.MTDecrementPlayer = IDW_MTDECPLAYER.Text;
this.DialogResult = DialogResult.OK;
this.Close();
}
this.DialogResult = DialogResult.OK;
this.Close();
}
private void hotkeyTabs_SelectedIndexChanged(object sender, EventArgs e)
{
hotkeyTabs.TabPages[hotkeyTabs.SelectedIndex].Controls[0].Focus();
}
private void hotkeyTabs_SelectedIndexChanged(object sender, EventArgs e)
{
hotkeyTabs.TabPages[hotkeyTabs.SelectedIndex].Controls[0].Focus();
}
private void HotkeyWindow_Load(object sender, EventArgs e)
{
private void HotkeyWindow_Load(object sender, EventArgs e)
{
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -5,58 +5,58 @@ using System.Text;
namespace BizHawk.MultiClient
{
public class Cheat
{
//TODO: compare value (for NES)
public string name { get; set; }
public int address { get; set; }
public byte value { get; set; }
public MemoryDomain domain { get; set; }
private bool enabled;
public class Cheat
{
//TODO: compare value (for NES)
public string name { get; set; }
public int address { get; set; }
public byte value { get; set; }
public MemoryDomain domain { get; set; }
private bool enabled;
public Cheat()
{
name = "";
address = 0;
value = 0;
enabled = false;
domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
}
public Cheat()
{
name = "";
address = 0;
value = 0;
enabled = false;
domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
}
public Cheat(Cheat c)
{
name = c.name;
address = c.address;
value = c.value;
enabled = c.enabled;
domain = c.domain;
}
public Cheat(Cheat c)
{
name = c.name;
address = c.address;
value = c.value;
enabled = c.enabled;
domain = c.domain;
}
public Cheat(string cname, int addr, byte val, bool e, MemoryDomain d)
{
name = cname;
address = addr;
value = val;
enabled = e;
domain = d;
}
public Cheat(string cname, int addr, byte val, bool e, MemoryDomain d)
{
name = cname;
address = addr;
value = val;
enabled = e;
domain = d;
}
public void Enable()
{
enabled = true;
domain.SetFreeze(address, new MemoryDomain.FreezeData(MemoryDomain.FreezeData.Flag.Frozen, value));
}
public void Enable()
{
enabled = true;
domain.SetFreeze(address, new MemoryDomain.FreezeData(MemoryDomain.FreezeData.Flag.Frozen, value));
}
public void Disable()
{
enabled = false;
domain.SetFreeze(address, MemoryDomain.FreezeData.Empty);
}
public void Disable()
{
enabled = false;
domain.SetFreeze(address, MemoryDomain.FreezeData.Empty);
}
public bool IsEnabled()
{
return enabled;
}
public bool IsEnabled()
{
return enabled;
}
}
}
}

View File

@ -10,353 +10,353 @@ using System.Globalization;
namespace BizHawk.MultiClient
{
public partial class HexEditor : Form
{
//TODO:
//different back color for frozen addresses
//Find text box - autohighlights matches, and shows total matches
//Users can customize background, & text colors
//Tool strip
//Text box showing currently highlighted address(es) & total
//Show num addresses in group box title (show "address" if 1 address)
//big font for currently mouse over'ed value?
//Unfreeze All items - this one is tricky though, the dialog should keep track of
// which addresses were frozen using this dialog (its own cheatList), and only
// remove those from the Cheats window cheat list
public partial class HexEditor : Form
{
//TODO:
//different back color for frozen addresses
//Find text box - autohighlights matches, and shows total matches
//Users can customize background, & text colors
//Tool strip
//Text box showing currently highlighted address(es) & total
//Show num addresses in group box title (show "address" if 1 address)
//big font for currently mouse over'ed value?
//Unfreeze All items - this one is tricky though, the dialog should keep track of
// which addresses were frozen using this dialog (its own cheatList), and only
// remove those from the Cheats window cheat list
int defaultWidth;
int defaultHeight;
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
int defaultWidth;
int defaultHeight;
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
public HexEditor()
{
InitializeComponent();
Closing += (o, e) => SaveConfigSettings();
}
public HexEditor()
{
InitializeComponent();
Closing += (o, e) => SaveConfigSettings();
}
public void SaveConfigSettings()
{
if (Global.Config.HexEditorSaveWindowPosition)
{
Global.Config.HexEditorWndx = this.Location.X;
Global.Config.HexEditorWndy = this.Location.Y;
Global.Config.HexEditorWidth = this.Right - this.Left;
Global.Config.HexEditorHeight = this.Bottom - this.Top;
}
}
public void SaveConfigSettings()
{
if (Global.Config.HexEditorSaveWindowPosition)
{
Global.Config.HexEditorWndx = this.Location.X;
Global.Config.HexEditorWndy = this.Location.Y;
Global.Config.HexEditorWidth = this.Right - this.Left;
Global.Config.HexEditorHeight = this.Bottom - this.Top;
}
}
private void HexEditor_Load(object sender, EventArgs e)
{
defaultWidth = this.Size.Width; //Save these first so that the user can restore to its original size
defaultHeight = this.Size.Height;
if (Global.Config.HexEditorSaveWindowPosition)
{
if (Global.Config.HexEditorSaveWindowPosition && Global.Config.HexEditorWndx >= 0 && Global.Config.HexEditorWndy >= 0)
this.Location = new Point(Global.Config.HexEditorWndx, Global.Config.HexEditorWndy);
private void HexEditor_Load(object sender, EventArgs e)
{
defaultWidth = this.Size.Width; //Save these first so that the user can restore to its original size
defaultHeight = this.Size.Height;
if (Global.Config.HexEditorSaveWindowPosition)
{
if (Global.Config.HexEditorSaveWindowPosition && Global.Config.HexEditorWndx >= 0 && Global.Config.HexEditorWndy >= 0)
this.Location = new Point(Global.Config.HexEditorWndx, Global.Config.HexEditorWndy);
if (Global.Config.HexEditorWidth >= 0 && Global.Config.HexEditorHeight >= 0)
{
this.Size = new System.Drawing.Size(Global.Config.HexEditorWidth, Global.Config.HexEditorHeight);
}
}
SetMemoryDomainMenu();
}
if (Global.Config.HexEditorWidth >= 0 && Global.Config.HexEditorHeight >= 0)
{
this.Size = new System.Drawing.Size(Global.Config.HexEditorWidth, Global.Config.HexEditorHeight);
}
}
SetMemoryDomainMenu();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
public void UpdateValues()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
MemoryViewer.Refresh();
}
public void UpdateValues()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
MemoryViewer.Refresh();
}
public void Restart()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
SetMemoryDomainMenu(); //Calls update routines
MemoryViewer.ResetScrollBar();
}
public void Restart()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
SetMemoryDomainMenu(); //Calls update routines
MemoryViewer.ResetScrollBar();
}
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
}
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
}
private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.AutoLoadHexEditor ^= true;
}
private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.AutoLoadHexEditor ^= true;
}
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
enToolStripMenuItem.Checked = MemoryViewer.BigEndian;
switch (MemoryViewer.GetDataSize())
{
default:
case 1:
byteToolStripMenuItem.Checked = true;
byteToolStripMenuItem1.Checked = false;
byteToolStripMenuItem2.Checked = false;
break;
case 2:
byteToolStripMenuItem.Checked = false;
byteToolStripMenuItem1.Checked = true;
byteToolStripMenuItem2.Checked = false;
break;
case 4:
byteToolStripMenuItem.Checked = false;
byteToolStripMenuItem1.Checked = false;
byteToolStripMenuItem2.Checked = true;
break;
}
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
enToolStripMenuItem.Checked = MemoryViewer.BigEndian;
switch (MemoryViewer.GetDataSize())
{
default:
case 1:
byteToolStripMenuItem.Checked = true;
byteToolStripMenuItem1.Checked = false;
byteToolStripMenuItem2.Checked = false;
break;
case 2:
byteToolStripMenuItem.Checked = false;
byteToolStripMenuItem1.Checked = true;
byteToolStripMenuItem2.Checked = false;
break;
case 4:
byteToolStripMenuItem.Checked = false;
byteToolStripMenuItem1.Checked = false;
byteToolStripMenuItem2.Checked = true;
break;
}
if (MemoryViewer.GetHighlightedAddress() >= 0)
{
addToRamWatchToolStripMenuItem1.Enabled = true;
freezeAddressToolStripMenuItem.Enabled = true;
}
else
{
addToRamWatchToolStripMenuItem1.Enabled = false;
freezeAddressToolStripMenuItem.Enabled = false;
}
}
if (MemoryViewer.GetHighlightedAddress() >= 0)
{
addToRamWatchToolStripMenuItem1.Enabled = true;
freezeAddressToolStripMenuItem.Enabled = true;
}
else
{
addToRamWatchToolStripMenuItem1.Enabled = false;
freezeAddressToolStripMenuItem.Enabled = false;
}
}
private void SetMemoryDomain(int pos)
{
if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check
{
MemoryViewer.SetMemoryDomain(Global.Emulator.MemoryDomains[pos]);
}
UpdateDomainString();
MemoryViewer.ResetScrollBar();
}
private void SetMemoryDomain(int pos)
{
if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check
{
MemoryViewer.SetMemoryDomain(Global.Emulator.MemoryDomains[pos]);
}
UpdateDomainString();
MemoryViewer.ResetScrollBar();
}
private void UpdateDomainString()
{
string memoryDomain = MemoryViewer.GetMemoryDomainStr();
string systemID = Global.Emulator.SystemId;
MemoryViewer.Text = systemID + " " + memoryDomain;
}
private void UpdateDomainString()
{
string memoryDomain = MemoryViewer.GetMemoryDomainStr();
string systemID = Global.Emulator.SystemId;
MemoryViewer.Text = systemID + " " + memoryDomain;
}
private void SetMemoryDomainMenu()
{
memoryDomainsToolStripMenuItem.DropDownItems.Clear();
if (Global.Emulator.MemoryDomains.Count > 0)
{
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
{
string str = Global.Emulator.MemoryDomains[x].ToString();
var item = new ToolStripMenuItem();
item.Text = str;
{
int z = x;
item.Click += (o, ev) => SetMemoryDomain(z);
}
if (x == 0)
{
SetMemoryDomain(x);
}
memoryDomainsToolStripMenuItem.DropDownItems.Add(item);
domainMenuItems.Add(item);
}
}
else
memoryDomainsToolStripMenuItem.Enabled = false;
}
private void SetMemoryDomainMenu()
{
memoryDomainsToolStripMenuItem.DropDownItems.Clear();
if (Global.Emulator.MemoryDomains.Count > 0)
{
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
{
string str = Global.Emulator.MemoryDomains[x].ToString();
var item = new ToolStripMenuItem();
item.Text = str;
{
int z = x;
item.Click += (o, ev) => SetMemoryDomain(z);
}
if (x == 0)
{
SetMemoryDomain(x);
}
memoryDomainsToolStripMenuItem.DropDownItems.Add(item);
domainMenuItems.Add(item);
}
}
else
memoryDomainsToolStripMenuItem.Enabled = false;
}
public void GoToAddress(int address)
{
if (address < MemoryViewer.GetSize())
{
MemoryViewer.SetHighlighted(address);
MemoryViewer.Refresh();
}
}
public void GoToAddress(int address)
{
if (address < MemoryViewer.GetSize())
{
MemoryViewer.SetHighlighted(address);
MemoryViewer.Refresh();
}
}
private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e)
{
InputPrompt i = new InputPrompt();
i.Text = "Go to Address";
i.SetMessage("Enter a hexadecimal value");
i.ShowDialog();
private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e)
{
InputPrompt i = new InputPrompt();
i.Text = "Go to Address";
i.SetMessage("Enter a hexadecimal value");
i.ShowDialog();
if (i.UserOK)
{
if (InputValidate.IsValidHexNumber(i.UserText))
{
GoToAddress(int.Parse(i.UserText, NumberStyles.HexNumber));
}
}
}
if (i.UserOK)
{
if (InputValidate.IsValidHexNumber(i.UserText))
{
GoToAddress(int.Parse(i.UserText, NumberStyles.HexNumber));
}
}
}
private void HexEditor_Resize(object sender, EventArgs e)
{
MemoryViewer.SetUpScrollBar();
MemoryViewer.Refresh();
}
private void byteToolStripMenuItem_Click(object sender, EventArgs e)
{
MemoryViewer.SetDataSize(1);
}
private void HexEditor_Resize(object sender, EventArgs e)
{
MemoryViewer.SetUpScrollBar();
MemoryViewer.Refresh();
}
private void byteToolStripMenuItem1_Click(object sender, EventArgs e)
{
MemoryViewer.SetDataSize(2);
}
private void byteToolStripMenuItem_Click(object sender, EventArgs e)
{
MemoryViewer.SetDataSize(1);
}
private void byteToolStripMenuItem2_Click(object sender, EventArgs e)
{
MemoryViewer.SetDataSize(4);
}
private void byteToolStripMenuItem1_Click(object sender, EventArgs e)
{
MemoryViewer.SetDataSize(2);
}
private void enToolStripMenuItem_Click(object sender, EventArgs e)
{
MemoryViewer.BigEndian ^= true;
}
private void byteToolStripMenuItem2_Click(object sender, EventArgs e)
{
MemoryViewer.SetDataSize(4);
}
private void MemoryViewer_Paint(object sender, PaintEventArgs e)
{
private void enToolStripMenuItem_Click(object sender, EventArgs e)
{
MemoryViewer.BigEndian ^= true;
}
}
private void MemoryViewer_Paint(object sender, PaintEventArgs e)
{
private void AddToRamWatch()
{
//Add to RAM Watch
int address = MemoryViewer.GetPointedAddress();
if (address >= 0)
{
Watch w = new Watch();
w.address = address;
}
switch (MemoryViewer.GetDataSize())
{
default:
case 1:
w.type = atype.BYTE;
break;
case 2:
w.type = atype.WORD;
break;
case 4:
w.type = atype.DWORD;
break;
}
private void AddToRamWatch()
{
//Add to RAM Watch
int address = MemoryViewer.GetPointedAddress();
if (address >= 0)
{
Watch w = new Watch();
w.address = address;
w.bigendian = MemoryViewer.BigEndian;
w.signed = asigned.HEX;
switch (MemoryViewer.GetDataSize())
{
default:
case 1:
w.type = atype.BYTE;
break;
case 2:
w.type = atype.WORD;
break;
case 4:
w.type = atype.DWORD;
break;
}
Global.MainForm.LoadRamWatch();
Global.MainForm.RamWatch1.AddWatch(w);
}
}
w.bigendian = MemoryViewer.BigEndian;
w.signed = asigned.HEX;
private void MemoryViewer_MouseDoubleClick(object sender, MouseEventArgs e)
{
AddToRamWatch();
}
Global.MainForm.LoadRamWatch();
Global.MainForm.RamWatch1.AddWatch(w);
}
}
private void pokeToolStripMenuItem_Click(object sender, EventArgs e)
{
int p = MemoryViewer.GetPointedAddress();
if (p >= 0)
{
InputPrompt i = new InputPrompt();
i.Text = "Poke " + String.Format("{0:X}", p);
i.SetMessage("Enter a hexadecimal value");
i.ShowDialog();
private void MemoryViewer_MouseDoubleClick(object sender, MouseEventArgs e)
{
AddToRamWatch();
}
if (i.UserOK)
{
if (InputValidate.IsValidHexNumber(i.UserText))
{
int value = int.Parse(i.UserText, NumberStyles.HexNumber);
MemoryViewer.HighlightPointed();
MemoryViewer.PokeHighlighted(value);
}
}
}
}
private void pokeToolStripMenuItem_Click(object sender, EventArgs e)
{
int p = MemoryViewer.GetPointedAddress();
if (p >= 0)
{
InputPrompt i = new InputPrompt();
i.Text = "Poke " + String.Format("{0:X}", p);
i.SetMessage("Enter a hexadecimal value");
i.ShowDialog();
private void addToRamWatchToolStripMenuItem_Click(object sender, EventArgs e)
{
AddToRamWatch();
}
if (i.UserOK)
{
if (InputValidate.IsValidHexNumber(i.UserText))
{
int value = int.Parse(i.UserText, NumberStyles.HexNumber);
MemoryViewer.HighlightPointed();
MemoryViewer.PokeHighlighted(value);
}
}
}
}
private void addToRamWatchToolStripMenuItem1_Click(object sender, EventArgs e)
{
AddToRamWatch();
}
private void addToRamWatchToolStripMenuItem_Click(object sender, EventArgs e)
{
AddToRamWatch();
}
private void saveWindowsSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.HexEditorSaveWindowPosition ^= true;
}
private void addToRamWatchToolStripMenuItem1_Click(object sender, EventArgs e)
{
AddToRamWatch();
}
private void settingsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
autoloadToolStripMenuItem.Checked = Global.Config.AutoLoadHexEditor;
saveWindowsSettingsToolStripMenuItem.Checked = Global.Config.HexEditorSaveWindowPosition;
}
private void saveWindowsSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.HexEditorSaveWindowPosition ^= true;
}
private void freezeToolStripMenuItem_Click(object sender, EventArgs e)
{
FreezeAddress();
}
private void settingsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
autoloadToolStripMenuItem.Checked = Global.Config.AutoLoadHexEditor;
saveWindowsSettingsToolStripMenuItem.Checked = Global.Config.HexEditorSaveWindowPosition;
}
private void FreezeAddress()
{
int address = MemoryViewer.GetPointedAddress();
if (address >= 0)
{
Cheat c = new Cheat();
c.address = address;
c.value = MemoryViewer.GetPointedValue();
c.domain = MemoryViewer.GetDomain();
//TODO: multibyte
switch (MemoryViewer.GetDataSize())
{
default:
case 1:
break;
case 2:
break;
case 4:
break;
}
private void freezeToolStripMenuItem_Click(object sender, EventArgs e)
{
FreezeAddress();
}
//w.bigendian = MemoryViewer.BigEndian;
private void FreezeAddress()
{
int address = MemoryViewer.GetPointedAddress();
if (address >= 0)
{
Cheat c = new Cheat();
c.address = address;
c.value = MemoryViewer.GetPointedValue();
c.domain = MemoryViewer.GetDomain();
//TODO: multibyte
switch (MemoryViewer.GetDataSize())
{
default:
case 1:
break;
case 2:
break;
case 4:
break;
}
Global.MainForm.Cheats1.AddCheat(c);
}
}
//w.bigendian = MemoryViewer.BigEndian;
private void freezeAddressToolStripMenuItem_Click(object sender, EventArgs e)
{
FreezeAddress();
}
Global.MainForm.Cheats1.AddCheat(c);
}
}
private void CheckDomainMenuItems()
{
for (int x = 0; x < domainMenuItems.Count; x++)
{
if (MemoryViewer.GetDomain().Name == domainMenuItems[x].Text)
domainMenuItems[x].Checked = true;
else
domainMenuItems[x].Checked = false;
}
}
private void freezeAddressToolStripMenuItem_Click(object sender, EventArgs e)
{
FreezeAddress();
}
private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
CheckDomainMenuItems();
}
}
private void CheckDomainMenuItems()
{
for (int x = 0; x < domainMenuItems.Count; x++)
{
if (MemoryViewer.GetDomain().Name == domainMenuItems[x].Text)
domainMenuItems[x].Checked = true;
else
domainMenuItems[x].Checked = false;
}
}
private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
CheckDomainMenuItems();
}
}
}

View File

@ -10,233 +10,233 @@ using System.Globalization;
namespace BizHawk.MultiClient
{
public partial class RamPoke : Form
{
//TODO:
//If signed/unsigned/hex radios selected, auto-change the value box, and auto limit box length
//Checked signed/u/h value on RamPoke_Load and set value appopriately
//Memory domain selection
//Output message, format number of digits appropriately
public Watch watch = new Watch();
public Point location = new Point();
public partial class RamPoke : Form
{
//TODO:
//If signed/unsigned/hex radios selected, auto-change the value box, and auto limit box length
//Checked signed/u/h value on RamPoke_Load and set value appopriately
//Memory domain selection
//Output message, format number of digits appropriately
public Watch watch = new Watch();
public Point location = new Point();
public RamPoke()
{
InitializeComponent();
}
public RamPoke()
{
InitializeComponent();
}
public void SetWatchObject(Watch w)
{
watch = w;
}
public void SetWatchObject(Watch w)
{
watch = w;
}
private void RamPoke_Load(object sender, EventArgs e)
{
SetTypeRadio(watch.type);
SetSignedRadio(watch.signed);
if (watch.bigendian == true)
BigEndianRadio.Checked = true;
else
LittleEndianRadio.Checked = true;
AddressBox.Text = String.Format("{0:X}", watch.address);
private void RamPoke_Load(object sender, EventArgs e)
{
SetTypeRadio(watch.type);
SetSignedRadio(watch.signed);
if (watch.bigendian == true)
BigEndianRadio.Checked = true;
else
LittleEndianRadio.Checked = true;
AddressBox.Text = String.Format("{0:X}", watch.address);
ValueBox.Text = watch.value.ToString();
if (location.X > 0 && location.Y > 0)
this.Location = location;
}
private void SetTypeRadio(atype a)
{
switch (a)
{
case atype.BYTE:
Byte1Radio.Checked = true;
break;
case atype.WORD:
Byte2Radio.Checked = true;
break;
case atype.DWORD:
Byte4Radio.Checked = true;
break;
default:
break;
}
}
ValueBox.Text = watch.value.ToString();
private void SetSignedRadio(asigned a)
{
switch (a)
{
case asigned.SIGNED:
SignedRadio.Checked = true;
break;
case asigned.UNSIGNED:
UnsignedRadio.Checked = true;
break;
case asigned.HEX:
HexRadio.Checked = true;
break;
default:
break;
}
}
private void Cancel_Click(object sender, EventArgs e)
{
this.Close();
}
if (location.X > 0 && location.Y > 0)
this.Location = location;
private void OK_Click(object sender, EventArgs e)
{
//Put user settings in the watch file
}
if (InputValidate.IsValidHexNumber(AddressBox.Text))
watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
else
{
MessageBox.Show("Invalid Address, must be a valid hex number", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
AddressBox.Focus();
AddressBox.SelectAll();
return;
}
if (SignedRadio.Checked)
watch.signed = asigned.SIGNED;
else if (UnsignedRadio.Checked)
watch.signed = asigned.UNSIGNED;
else if (HexRadio.Checked)
watch.signed = asigned.HEX;
private void SetTypeRadio(atype a)
{
switch (a)
{
case atype.BYTE:
Byte1Radio.Checked = true;
break;
case atype.WORD:
Byte2Radio.Checked = true;
break;
case atype.DWORD:
Byte4Radio.Checked = true;
break;
default:
break;
}
}
if (Byte1Radio.Checked)
watch.type = atype.BYTE;
else if (Byte2Radio.Checked)
watch.type = atype.WORD;
else if (Byte4Radio.Checked)
watch.type = atype.DWORD;
private void SetSignedRadio(asigned a)
{
switch (a)
{
case asigned.SIGNED:
SignedRadio.Checked = true;
break;
case asigned.UNSIGNED:
UnsignedRadio.Checked = true;
break;
case asigned.HEX:
HexRadio.Checked = true;
break;
default:
break;
}
}
if (BigEndianRadio.Checked)
watch.bigendian = true;
else if (LittleEndianRadio.Checked)
watch.bigendian = false;
private void Cancel_Click(object sender, EventArgs e)
{
this.Close();
}
int x = GetSpecificValue();
if (x == -99999999)
{
MessageBox.Show("Missing or invalid value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
ValueBox.Focus();
ValueBox.SelectAll();
return;
}
else
watch.value = int.Parse(ValueBox.Text);
private void OK_Click(object sender, EventArgs e)
{
//Put user settings in the watch file
watch.PokeAddress(Global.Emulator.MainMemory);
//TODO: format value based on watch.type
OutputLabel.Text = watch.value.ToString() + " written to " + String.Format("{0:X}", watch.address);
}
if (InputValidate.IsValidHexNumber(AddressBox.Text))
watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
else
{
MessageBox.Show("Invalid Address, must be a valid hex number", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
AddressBox.Focus();
AddressBox.SelectAll();
return;
}
private void AddressBox_Leave(object sender, EventArgs e)
{
AddressBox.Text = AddressBox.Text.Replace(" ", "");
if (!InputValidate.IsValidHexNumber(AddressBox.Text))
{
AddressBox.Focus();
AddressBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("Must be a valid hexadecimal value", AddressBox, 5000);
}
}
if (SignedRadio.Checked)
watch.signed = asigned.SIGNED;
else if (UnsignedRadio.Checked)
watch.signed = asigned.UNSIGNED;
else if (HexRadio.Checked)
watch.signed = asigned.HEX;
private void ValueBox_Leave(object sender, EventArgs e)
{
ValueBox.Text = ValueBox.Text.Replace(" ", "");
if (!InputValidate.IsValidUnsignedNumber(ValueBox.Text))
{
ValueBox.Focus();
ValueBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("Must be a valid unsigned decimal value", ValueBox, 5000);
}
}
if (Byte1Radio.Checked)
watch.type = atype.BYTE;
else if (Byte2Radio.Checked)
watch.type = atype.WORD;
else if (Byte4Radio.Checked)
watch.type = atype.DWORD;
private asigned GetDataType()
{
if (SignedRadio.Checked)
return asigned.UNSIGNED;
if (UnsignedRadio.Checked)
return asigned.SIGNED;
if (HexRadio.Checked)
return asigned.HEX;
if (BigEndianRadio.Checked)
watch.bigendian = true;
else if (LittleEndianRadio.Checked)
watch.bigendian = false;
return asigned.UNSIGNED; //Just in case
}
int x = GetSpecificValue();
if (x == -99999999)
{
MessageBox.Show("Missing or invalid value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
ValueBox.Focus();
ValueBox.SelectAll();
return;
}
else
watch.value = int.Parse(ValueBox.Text);
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\b') return;
watch.PokeAddress(Global.Emulator.MainMemory);
if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true;
}
//TODO: format value based on watch.type
OutputLabel.Text = watch.value.ToString() + " written to " + String.Format("{0:X}", watch.address);
}
private void ValueBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\b') return;
private void AddressBox_Leave(object sender, EventArgs e)
{
AddressBox.Text = AddressBox.Text.Replace(" ", "");
if (!InputValidate.IsValidHexNumber(AddressBox.Text))
{
AddressBox.Focus();
AddressBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("Must be a valid hexadecimal value", AddressBox, 5000);
}
}
switch (GetDataType())
{
case asigned.UNSIGNED:
if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
e.Handled = true;
break;
case asigned.SIGNED:
if (!InputValidate.IsValidSignedNumber(e.KeyChar))
e.Handled = true;
break;
case asigned.HEX:
if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true;
break;
}
}
private void ValueBox_Leave(object sender, EventArgs e)
{
ValueBox.Text = ValueBox.Text.Replace(" ", "");
if (!InputValidate.IsValidUnsignedNumber(ValueBox.Text))
{
ValueBox.Focus();
ValueBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("Must be a valid unsigned decimal value", ValueBox, 5000);
}
}
private atype GetDataSize()
{
if (Byte1Radio.Checked)
return atype.BYTE;
if (Byte2Radio.Checked)
return atype.WORD;
if (Byte4Radio.Checked)
return atype.DWORD;
private asigned GetDataType()
{
if (SignedRadio.Checked)
return asigned.UNSIGNED;
if (UnsignedRadio.Checked)
return asigned.SIGNED;
if (HexRadio.Checked)
return asigned.HEX;
return atype.BYTE;
}
return asigned.UNSIGNED; //Just in case
}
private int GetSpecificValue()
{
if (ValueBox.Text == "" || ValueBox.Text == "-") return 0;
bool i = false;
switch (GetDataType())
{
case asigned.UNSIGNED:
i = InputValidate.IsValidUnsignedNumber(ValueBox.Text);
if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text); //Note: 64 to be safe since 4 byte values can be entered
case asigned.SIGNED:
i = InputValidate.IsValidSignedNumber(ValueBox.Text);
if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text);
case asigned.HEX:
i = InputValidate.IsValidHexNumber(ValueBox.Text);
if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text, NumberStyles.HexNumber);
}
return -99999999; //What are the odds someone wants to search for this value?
}
}
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\b') return;
if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true;
}
private void ValueBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\b') return;
switch (GetDataType())
{
case asigned.UNSIGNED:
if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
e.Handled = true;
break;
case asigned.SIGNED:
if (!InputValidate.IsValidSignedNumber(e.KeyChar))
e.Handled = true;
break;
case asigned.HEX:
if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true;
break;
}
}
private atype GetDataSize()
{
if (Byte1Radio.Checked)
return atype.BYTE;
if (Byte2Radio.Checked)
return atype.WORD;
if (Byte4Radio.Checked)
return atype.DWORD;
return atype.BYTE;
}
private int GetSpecificValue()
{
if (ValueBox.Text == "" || ValueBox.Text == "-") return 0;
bool i = false;
switch (GetDataType())
{
case asigned.UNSIGNED:
i = InputValidate.IsValidUnsignedNumber(ValueBox.Text);
if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text); //Note: 64 to be safe since 4 byte values can be entered
case asigned.SIGNED:
i = InputValidate.IsValidSignedNumber(ValueBox.Text);
if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text);
case asigned.HEX:
i = InputValidate.IsValidHexNumber(ValueBox.Text);
if (!i) return -99999999;
return (int)Int64.Parse(ValueBox.Text, NumberStyles.HexNumber);
}
return -99999999; //What are the odds someone wants to search for this value?
}
}
}

View File

@ -10,154 +10,154 @@ using System.Globalization;
namespace BizHawk.MultiClient
{
public partial class RamWatchNewWatch : Form
{
public Watch watch = new Watch();
public bool userSelected = false;
public bool customSetup = false;
public Point location = new Point();
public partial class RamWatchNewWatch : Form
{
public Watch watch = new Watch();
public bool userSelected = false;
public bool customSetup = false;
public Point location = new Point();
public RamWatchNewWatch()
{
InitializeComponent();
}
public RamWatchNewWatch()
{
InitializeComponent();
}
private void SetTypeRadio(atype a)
{
switch (a)
{
case atype.BYTE:
Byte1Radio.Checked = true;
break;
case atype.WORD:
Byte2Radio.Checked = true;
break;
case atype.DWORD:
Byte4Radio.Checked = true;
break;
default:
break;
}
}
private void SetTypeRadio(atype a)
{
switch (a)
{
case atype.BYTE:
Byte1Radio.Checked = true;
break;
case atype.WORD:
Byte2Radio.Checked = true;
break;
case atype.DWORD:
Byte4Radio.Checked = true;
break;
default:
break;
}
}
private void SetSignedRadio(asigned a)
{
switch (a)
{
case asigned.SIGNED:
SignedRadio.Checked = true;
break;
case asigned.UNSIGNED:
UnsignedRadio.Checked = true;
break;
case asigned.HEX:
HexRadio.Checked = true;
break;
default:
break;
}
}
private void SetSignedRadio(asigned a)
{
switch (a)
{
case asigned.SIGNED:
SignedRadio.Checked = true;
break;
case asigned.UNSIGNED:
UnsignedRadio.Checked = true;
break;
case asigned.HEX:
HexRadio.Checked = true;
break;
default:
break;
}
}
public void SetToEditWatch(Watch w, string message)
{
//Sets this dialog to Edit Watch and receives default values
this.Text = message;
customSetup = true;
public void SetToEditWatch(Watch w, string message)
{
//Sets this dialog to Edit Watch and receives default values
this.Text = message;
customSetup = true;
AddressBox.Text = string.Format("{0:X4}", w.address);
NotesBox.Text = w.notes;
AddressBox.Text = string.Format("{0:X4}", w.address);
NotesBox.Text = w.notes;
SetTypeRadio(w.type);
SetSignedRadio(w.signed);
if (w.bigendian == true)
BigEndianRadio.Checked = true;
else
LittleEndianRadio.Checked = true;
}
SetTypeRadio(w.type);
SetSignedRadio(w.signed);
private void RamWatchNewWatch_Load(object sender, EventArgs e)
{
if (!customSetup)
{
Watch w = new Watch();
SetTypeRadio(w.type);
SetSignedRadio(w.signed);
if (w.bigendian == true)
BigEndianRadio.Checked = true;
else
LittleEndianRadio.Checked = true;
}
AddressBox.Text = "0000";
private void RamWatchNewWatch_Load(object sender, EventArgs e)
{
if (!customSetup)
{
Watch w = new Watch();
SetTypeRadio(w.type);
SetSignedRadio(w.signed);
if (w.bigendian == true)
BigEndianRadio.Checked = true;
else
LittleEndianRadio.Checked = true;
}
if (location.X > 0 && location.Y > 0)
this.Location = location;
}
AddressBox.Text = "0000";
private void Cancel_Click(object sender, EventArgs e)
{
userSelected = false;
this.Close();
}
if (w.bigendian == true)
BigEndianRadio.Checked = true;
else
LittleEndianRadio.Checked = true;
}
if (location.X > 0 && location.Y > 0)
this.Location = location;
}
private void OK_Click(object sender, EventArgs e)
{
//Put user settings in the watch file
userSelected = true;
if (InputValidate.IsValidHexNumber(AddressBox.Text))
watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
else
{
MessageBox.Show("Not a valid address (enter a valid Hex number)", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
AddressBox.Focus();
AddressBox.SelectAll();
return;
}
private void Cancel_Click(object sender, EventArgs e)
{
userSelected = false;
this.Close();
}
if (SignedRadio.Checked)
watch.signed = asigned.SIGNED;
else if (UnsignedRadio.Checked)
watch.signed = asigned.UNSIGNED;
else if (HexRadio.Checked)
watch.signed = asigned.HEX;
private void OK_Click(object sender, EventArgs e)
{
//Put user settings in the watch file
userSelected = true;
if (InputValidate.IsValidHexNumber(AddressBox.Text))
watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
else
{
MessageBox.Show("Not a valid address (enter a valid Hex number)", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
AddressBox.Focus();
AddressBox.SelectAll();
if (Byte1Radio.Checked)
watch.type = atype.BYTE;
else if (Byte2Radio.Checked)
watch.type = atype.WORD;
else if (Byte4Radio.Checked)
watch.type = atype.DWORD;
return;
}
if (BigEndianRadio.Checked)
watch.bigendian = true;
else if (LittleEndianRadio.Checked)
watch.bigendian = false;
if (SignedRadio.Checked)
watch.signed = asigned.SIGNED;
else if (UnsignedRadio.Checked)
watch.signed = asigned.UNSIGNED;
else if (HexRadio.Checked)
watch.signed = asigned.HEX;
watch.notes = NotesBox.Text;
if (Byte1Radio.Checked)
watch.type = atype.BYTE;
else if (Byte2Radio.Checked)
watch.type = atype.WORD;
else if (Byte4Radio.Checked)
watch.type = atype.DWORD;
this.Close();
}
if (BigEndianRadio.Checked)
watch.bigendian = true;
else if (LittleEndianRadio.Checked)
watch.bigendian = false;
private void AddressBox_Leave(object sender, EventArgs e)
{
AddressBox.Text = AddressBox.Text.Replace(" ", "");
if (!InputValidate.IsValidHexNumber(AddressBox.Text))
{
AddressBox.Focus();
AddressBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("MUst be a valid hexadecimal vaue", AddressBox, 5000);
}
}
watch.notes = NotesBox.Text;
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\b') return;
this.Close();
}
if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true;
}
}
private void AddressBox_Leave(object sender, EventArgs e)
{
AddressBox.Text = AddressBox.Text.Replace(" ", "");
if (!InputValidate.IsValidHexNumber(AddressBox.Text))
{
AddressBox.Focus();
AddressBox.SelectAll();
ToolTip t = new ToolTip();
t.Show("MUst be a valid hexadecimal vaue", AddressBox, 5000);
}
}
private void AddressBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\b') return;
if (!InputValidate.IsValidHexNumber(e.KeyChar))
e.Handled = true;
}
}
}