Code refactoring of Tools files - no functional changes other than some very tiny speedups and null checks

This commit is contained in:
adelikat 2013-04-14 23:56:45 +00:00
parent cff1ff2940
commit be2937fdec
66 changed files with 2253 additions and 2753 deletions

View File

@ -465,8 +465,6 @@ namespace BizHawk.Emulation.CPUs.M6502
End_SuppressInterrupt,
}
Action[] opcodeHandlers;
void InitOpcodeHandlers()
{
//delegates arent faster than the switch. pretty sure. dont use it.

View File

@ -1,7 +1,6 @@
using BizHawk.Emulation.Computers.Commodore64.Cartridge;
using BizHawk.Emulation.Computers.Commodore64.Disk;
using BizHawk.Emulation.Computers.Commodore64.MOS;
using BizHawk.Emulation.Computers.Commodore64.Tape;
using System.IO;
namespace BizHawk.Emulation.Computers.Commodore64
@ -18,7 +17,6 @@ namespace BizHawk.Emulation.Computers.Commodore64
private Motherboard board;
private VIC1541 disk;
private VIC1530 tape;
// ------------------------------------

View File

@ -32,7 +32,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
private static byte[] portBit = new byte[] { 0x80, 0x40 };
private static byte[] portMask = new byte[] { 0x7F, 0xBF };
private uint acrShiftMode;
private bool caPulse;
private bool cbPulse;
private bool[] enableIrqCA;
@ -52,13 +51,12 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
private bool pbLatchEnable;
private byte paOut;
private byte pbOut;
private bool[] pbPulse;
private uint[] pcrControlA;
private uint[] pcrControlB;
private readonly bool[] pbPulse;
private readonly uint[] pcrControlA;
private readonly uint[] pcrControlB;
private byte sr;
private uint srControl;
private uint srCounter;
private uint[] tControl;
private readonly uint[] tControl;
public Func<bool> ReadCA0;
public Func<bool> ReadCA1;
@ -87,7 +85,6 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public void HardReset()
{
acrShiftMode = 0;
caPulse = false;
cbPulse = false;
enableIrqCA[0] = false;

View File

@ -31,7 +31,9 @@ namespace BizHawk.Emulation.Consoles.Atari
public byte HM;
public bool reflect;
public bool delay;
/*
public byte nusiz;
*/
};
struct ballMissileData
{
@ -39,8 +41,11 @@ namespace BizHawk.Emulation.Consoles.Atari
public byte pos;
public byte HM;
public byte size;
/*
public bool reset;
public bool delay;
*/
};
ballMissileData ball;

View File

@ -73,7 +73,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
};
public PPUPHASE ppuphase;
NES nes;
private readonly NES nes;
public PPU(NES nes)
{
this.nes = nes;
@ -105,8 +105,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public void SyncState(Serializer ser)
{
byte temp8;
ser.Sync("ppudead", ref ppudead);
ser.Sync("idleSynch", ref idleSynch);
ser.Sync("NMI_PendingInstructions", ref NMI_PendingInstructions);
@ -124,7 +122,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
ser.Sync("Reg2002_vblank_active_pending", ref Reg2002_vblank_active_pending);
ser.Sync("Reg2002_vblank_clear_pending", ref Reg2002_vblank_clear_pending);
ppur.SyncState(ser);
temp8 = reg_2000.Value; ser.Sync("reg_2000.Value", ref temp8); reg_2000.Value = temp8;
byte temp8 = reg_2000.Value; ser.Sync("reg_2000.Value", ref temp8); reg_2000.Value = temp8;
temp8 = reg_2001.Value; ser.Sync("reg_2001.Value", ref temp8); reg_2001.Value = temp8;
ser.Sync("reg_2003", ref reg_2003);

View File

@ -3,72 +3,63 @@ using System.Globalization;
namespace BizHawk.Emulation.Consoles.Sega
{
partial class Genesis
{
// State
bool EepromEnabled;
partial class Genesis
{
// State
bool EepromEnabled;
int EepromSize;
int EepromAddrMask;
int SdaInAddr, SdaInBit;
int SdaOutAddr, SdaOutBit;
int SclAddr, SclBit;
int EepromSize;
int EepromAddrMask;
int SdaInAddr, SdaInBit;
int SdaOutAddr, SdaOutBit;
int SclAddr, SclBit;
int SdaInCurrValue, SdaOutCurrValue, SclCurrValue;
int SdaInPrevValue, SdaOutPrevValue, SclPrevValue;
int SdaInCurrValue, SclCurrValue;
// Code
// Code
void InitializeEeprom(GameInfo game)
{
if (game["EEPROM"] == false)
return;
EepromEnabled = true;
EepromAddrMask = game.GetHexValue("EEPROM_ADDR_MASK");
EepromSize = EepromAddrMask + 1;
void InitializeEeprom(GameInfo game)
{
if (game["EEPROM"] == false)
return;
var t = game.OptionValue("SDA_IN").Split(':');
SdaInAddr = int.Parse(t[0], NumberStyles.HexNumber);
SdaInBit = int.Parse(t[1]);
EepromEnabled = true;
EepromAddrMask = game.GetHexValue("EEPROM_ADDR_MASK");
EepromSize = EepromAddrMask + 1;
t = game.OptionValue("SDA_OUT").Split(':');
SdaOutAddr = int.Parse(t[0], NumberStyles.HexNumber);
SdaOutBit = int.Parse(t[1]);
var t = game.OptionValue("SDA_IN").Split(':');
SdaInAddr = int.Parse(t[0], NumberStyles.HexNumber);
SdaInBit = int.Parse(t[1]);
t = game.OptionValue("SCL").Split(':');
SclAddr = int.Parse(t[0], NumberStyles.HexNumber);
SclBit = int.Parse(t[1]);
t = game.OptionValue("SDA_OUT").Split(':');
SdaOutAddr = int.Parse(t[0], NumberStyles.HexNumber);
SdaOutBit = int.Parse(t[1]);
SaveRAM = new byte[EepromSize];
t = game.OptionValue("SCL").Split(':');
SclAddr = int.Parse(t[0], NumberStyles.HexNumber);
SclBit = int.Parse(t[1]);
Console.WriteLine("EEPROM enabled. Size: ${0:X} SDA_IN: ${1:X}:{2} SDA_OUT: ${3:X}:{4}, SCL: ${5:X}:{6}",
EepromSize, SdaInAddr, SdaInBit, SdaOutAddr, SdaOutBit, SclAddr, SclBit);
}
SaveRAM = new byte[EepromSize];
void WriteByteEeprom(int address, byte value)
{
if (address == SdaInAddr)
{
SdaInPrevValue = SdaInCurrValue;
SdaInCurrValue = (value >> SdaInBit) & 1;
Console.WriteLine("SDA_IN: {0}", SdaInCurrValue);
}
if (address == SclAddr)
{
SclPrevValue = SclCurrValue;
SclCurrValue = (value >> SclBit) & 1;
Console.WriteLine("SCL: {0}", SclCurrValue);
}
Console.WriteLine("EEPROM enabled. Size: ${0:X} SDA_IN: ${1:X}:{2} SDA_OUT: ${3:X}:{4}, SCL: ${5:X}:{6}",
EepromSize, SdaInAddr, SdaInBit, SdaOutAddr, SdaOutBit, SclAddr, SclBit);
}
// todo: logic!
void WriteByteEeprom(int address, byte value)
{
if (address == SdaInAddr)
{
SdaInCurrValue = (value >> SdaInBit) & 1;
Console.WriteLine("SDA_IN: {0}", SdaInCurrValue);
}
if (address == SclAddr)
{
SclCurrValue = (value >> SclBit) & 1;
Console.WriteLine("SCL: {0}", SclCurrValue);
}
}
// todo: logic!
byte ReadByteEeeprom()
{
return 0; // meh
}
}
}
}
}

View File

@ -1,10 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Drawing;
using System.Runtime.InteropServices;
using BizHawk;
//some helpful p/invoke from http://www.codeproject.com/KB/audio-video/Motion_Detection.aspx?msg=1142967

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
@ -62,7 +61,7 @@ namespace BizHawk.MultiClient
System.IO.Path.GetDirectoryName(baseName),
System.IO.Path.GetFileNameWithoutExtension(baseName));
this.ext = System.IO.Path.GetExtension(baseName);
ext = System.IO.Path.GetExtension(baseName);
segment = 0;
OpenFileSegment();
@ -285,7 +284,7 @@ namespace BizHawk.MultiClient
public void SetDefaultVideoCodecToken()
{
this.token = FFmpegWriterForm.FormatPreset.GetDefaultPreset();
token = FFmpegWriterForm.FormatPreset.GetDefaultPreset();
}
public string ShortName()

View File

@ -1,21 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Media;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.MultiClient
{
public partial class AboutBox : Form
{
SoundPlayer sfx;
Random r = new Random();
int ctr = 0;
Point loc;
private readonly SoundPlayer sfx;
private readonly Random r = new Random();
private int ctr;
private Point loc;
public AboutBox()
{
@ -122,13 +117,8 @@ namespace BizHawk.MultiClient
pictureBox4.Location = new Point(21 + xbleh, 89);
}
int xbleh = 0;
int bounceCounter = -1;
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
}
private int xbleh;
private int bounceCounter = -1;
public void PaintJunk(Graphics g)
{
@ -137,7 +127,7 @@ namespace BizHawk.MultiClient
using (Font font = new Font("Courier New", 20, FontStyle.Bold))
{
if (bounceCounter == -1) return;
string str = "INTERIM BUILD";
const string str = "INTERIM BUILD";
float x = 0;
int timefactor = bounceCounter;
for (int i = 0; i < str.Length; i++)
@ -158,7 +148,7 @@ namespace BizHawk.MultiClient
}
}
int[] DigitTable ={
private readonly int[] DigitTable ={
0,3,6,9,12,
14,15,15,16,16,16,15,15,14,12,
9,6,3,0,2,4,4,5,5,5,
@ -174,16 +164,14 @@ namespace BizHawk.MultiClient
private void Close_Click(object sender, EventArgs e)
{
this.Close();
Close();
}
private void Close_MouseEnter(object sender, EventArgs e)
{
int width = Width;
int height = Height;
Random r = new Random();
width = r.Next(1, Width - CloseBtn.Width);
height = r.Next(1, Height - CloseBtn.Height);
Random random = new Random();
int width = random.Next(1, Width - CloseBtn.Width);
int height = random.Next(1, Height - CloseBtn.Height);
CloseBtn.Location = new Point(width, height);
CloseBtn.BringToFront();
}
@ -203,7 +191,7 @@ namespace BizHawk.MultiClient
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
AboutBox ab = this.FindForm() as AboutBox;
AboutBox ab = FindForm() as AboutBox;
if (ab != null)
ab.PaintJunk(e.Graphics);
}
@ -212,8 +200,7 @@ namespace BizHawk.MultiClient
{
get
{
CreateParams cp;
cp = base.CreateParams;
CreateParams cp = base.CreateParams;
cp.Style &= ~0x04000000; //WS_CLIPSIBLINGS
cp.Style &= ~0x02000000; //WS_CLIPCHILDREN
return cp;

View File

@ -422,7 +422,6 @@
this.label28.Size = new System.Drawing.Size(104, 13);
this.label28.TabIndex = 25;
this.label28.Text = "author: Mike Murphy";
this.label28.Click += new System.EventHandler(this.label28_Click);
//
// label30
//
@ -432,7 +431,6 @@
this.label30.Size = new System.Drawing.Size(80, 13);
this.label30.TabIndex = 23;
this.label30.Text = "Atari7800Hawk";
this.label30.Click += new System.EventHandler(this.label30_Click);
//
// linkLabel4
//

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.MultiClient
@ -18,13 +12,13 @@ namespace BizHawk.MultiClient
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.linkLabel1.LinkVisited = true;
linkLabel1.LinkVisited = true;
System.Diagnostics.Process.Start("http://code.google.com/p/bizhawk/");
}
private void OK_Click(object sender, EventArgs e)
{
this.Close();
Close();
}
private void BizBox_Load(object sender, EventArgs e)
@ -35,34 +29,19 @@ namespace BizHawk.MultiClient
private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.linkLabel3.LinkVisited = true;
linkLabel3.LinkVisited = true;
System.Diagnostics.Process.Start("http://byuu.org/bsnes/");
}
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.linkLabel2.LinkVisited = true;
linkLabel2.LinkVisited = true;
System.Diagnostics.Process.Start("http://gambatte.sourceforge.net/");
}
private void label30_Click(object sender, EventArgs e)
{
}
private void label28_Click(object sender, EventArgs e)
{
}
private void label29_Click(object sender, EventArgs e)
{
}
private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.linkLabel4.LinkVisited = true;
linkLabel4.LinkVisited = true;
System.Diagnostics.Process.Start("http://emu7800.sourceforge.net/");
}
}

View File

@ -643,9 +643,7 @@ namespace BizHawk.MultiClient
luaNativeSurfacePreOSD = new DisplaySurface(1, 1);
}
volatile bool VsyncToggle = false;
volatile bool VsyncRequested = false;
SwappableDisplaySurfaceSet sourceSurfaceSet = new SwappableDisplaySurfaceSet();
readonly SwappableDisplaySurfaceSet sourceSurfaceSet = new SwappableDisplaySurfaceSet();
DisplaySurface luaEmuSurface = null;

View File

@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
@ -23,10 +19,6 @@ namespace BizHawk.MultiClient.GBtools
/// the most recently loaded or saved palette file
/// </summary>
string currentfile;
/// <summary>
/// whether currentfile has been modified
/// </summary>
bool filemodified;
/// <summary>
/// gambatte's default dmg colors
@ -157,7 +149,6 @@ namespace BizHawk.MultiClient.GBtools
{
colors[i] = dlg.Color;
sender.BackColor = colors[i];
filemodified = true;
label4.Text = "Current palette file (modified):";
}
}
@ -250,7 +241,6 @@ namespace BizHawk.MultiClient.GBtools
dlg.SetAllColors(DefaultDMGColors);
dlg.textBox1.Text = "(none)";
dlg.currentfile = "";
dlg.filemodified = false;
if (!string.IsNullOrEmpty(Global.Config.GB_PaletteFile))
{
@ -287,7 +277,6 @@ namespace BizHawk.MultiClient.GBtools
SetAllColors(newcolors);
textBox1.Text = Path.GetFileName(filename);
currentfile = filename;
filemodified = false;
label4.Text = "Current palette file:";
}
}
@ -310,7 +299,6 @@ namespace BizHawk.MultiClient.GBtools
savecolors[i] = colors[i].ToArgb() & 0xffffff;
SavePalFile(f, savecolors);
currentfile = filename;
filemodified = false;
label4.Text = "Current palette file:";
textBox1.Text = Path.GetFileName(filename);
}
@ -389,7 +377,6 @@ namespace BizHawk.MultiClient.GBtools
{
textBox1.Text = "(none)";
currentfile = "";
filemodified = false;
SetAllColors(DefaultDMGColors);
}
@ -397,7 +384,6 @@ namespace BizHawk.MultiClient.GBtools
{
textBox1.Text = "(none)";
currentfile = "";
filemodified = false;
SetAllColors(DefaultCGBColors);
}
}

View File

@ -1,5 +1,4 @@
using BizHawk.MultiClient;
using BizHawk.Emulation.Consoles.Nintendo;
using BizHawk.Emulation.Consoles.Nintendo;
namespace BizHawk.MultiClient
{

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;
using System.Windows.Forms;
@ -17,7 +16,6 @@ namespace BizHawk.MultiClient
public bool LoadCheatFile(string path, bool append)
{
int y;
var file = new FileInfo(path);
if (file.Exists == false) return false;
@ -26,8 +24,7 @@ namespace BizHawk.MultiClient
{
if (!append) currentCheatFile = path;
string s = "";
string temp = "";
string s;
if (append == false)
{
@ -39,10 +36,10 @@ namespace BizHawk.MultiClient
{
if (s.Length < 6) continue;
Cheat c = new Cheat();
temp = s.Substring(0, s.IndexOf('\t')); //Address
string temp = s.Substring(0, s.IndexOf('\t'));
c.address = int.Parse(temp, NumberStyles.HexNumber);
y = s.IndexOf('\t') + 1;
int y = s.IndexOf('\t') + 1;
s = s.Substring(y, s.Length - y); //Value
temp = s.Substring(0, 2);
c.value = byte.Parse(temp, NumberStyles.HexNumber);
@ -106,9 +103,9 @@ namespace BizHawk.MultiClient
if (Global.Config.DisableCheatsOnLoad)
{
for (int x = 0; x < cheatList.Count; x++)
foreach (Cheat t in cheatList)
{
cheatList[x].Disable();
t.Disable();
}
}
@ -134,11 +131,11 @@ namespace BizHawk.MultiClient
private MemoryDomain SetDomain(string name)
{
//Attempts to find the memory domain by name, if it fails, it defaults to index 0
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
foreach (MemoryDomain t in Global.Emulator.MemoryDomains)
{
if (Global.Emulator.MemoryDomains[x].Name == name)
if (t.Name == name)
{
return Global.Emulator.MemoryDomains[x];
return t;
}
}
return Global.Emulator.MemoryDomains[0];
@ -146,19 +143,12 @@ namespace BizHawk.MultiClient
public bool IsActiveCheat(MemoryDomain d, int address)
{
for (int x = 0; x < cheatList.Count; x++)
{
if (cheatList[x].address == address && cheatList[x].domain.Name == d.Name)
{
return true;
}
}
return false;
return cheatList.Any(t => t.address == address && t.domain.Name == d.Name);
}
public Cheat GetCheat(MemoryDomain d, int address)
{
return cheatList.Where(x => x.address == address && x.domain.Name == d.Name).FirstOrDefault();
return cheatList.FirstOrDefault(x => x.address == address && x.domain.Name == d.Name);
}
public void RemoveCheat(MemoryDomain d, int address)
@ -211,8 +201,11 @@ namespace BizHawk.MultiClient
break;
}
var f = new FileInfo(path);
if (f.Directory.Exists == false)
if (f.Directory != null && f.Directory.Exists == false)
{
f.Directory.Create();
}
return path;
}
}
@ -220,7 +213,7 @@ namespace BizHawk.MultiClient
public bool SaveCheatFile(string path)
{
FileInfo file = new FileInfo(path);
if (!file.Directory.Exists)
if (file.Directory != null && !file.Directory.Exists)
{
file.Directory.Create();
}
@ -229,23 +222,23 @@ namespace BizHawk.MultiClient
{
string str = "";
for (int x = 0; x < cheatList.Count; x++)
foreach (Cheat t in cheatList)
{
str += FormatAddress(cheatList[x].address) + "\t";
str += String.Format("{0:X2}", cheatList[x].value) + "\t";
str += FormatAddress(t.address) + "\t";
str += String.Format("{0:X2}", t.value) + "\t";
if (cheatList[x].compare == null)
if (t.compare == null)
{
str += "N\t";
}
else
{
str += String.Format("{0:X2}", cheatList[x].compare) + "\t";
str += String.Format("{0:X2}", t.compare) + "\t";
}
str += cheatList[x].domain.Name + "\t";
str += t.domain.Name + "\t";
if (cheatList[x].IsEnabled())
if (t.IsEnabled())
{
str += "1\t";
}
@ -254,7 +247,7 @@ namespace BizHawk.MultiClient
str += "0\t";
}
str += cheatList[x].name + "\n";
str += t.name + "\n";
}
sw.WriteLine(str);
@ -373,17 +366,7 @@ namespace BizHawk.MultiClient
public bool HasActiveCheats
{
get
{
for (int x = 0; x < cheatList.Count; x++)
{
if (cheatList[x].IsEnabled())
{
return true;
}
}
return false;
}
get { return cheatList.Any(t => t.IsEnabled()); }
}
}
}

View File

@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Globalization;
@ -15,16 +13,14 @@ namespace BizHawk.MultiClient
{
public partial class Cheats : Form
{
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight;
int defaultNameWidth;
int defaultAddressWidth;
int defaultValueWidth;
int defaultCompareWidth;
int defaultDomainWidth;
int defaultOnWidth;
private int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
private int defaultHeight;
private int defaultNameWidth;
private int defaultAddressWidth;
private int defaultValueWidth;
private int defaultCompareWidth;
private int defaultDomainWidth;
private int defaultOnWidth;
private void ClearFields()
{
@ -39,14 +35,14 @@ namespace BizHawk.MultiClient
public void Restart()
{
NewCheatList(); //Should be run even if dialog isn't open so cheats system can work
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
ClearFields();
ToggleGameGenieButtons();
}
public void UpdateValues()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
CheatListView.ItemCount = Global.CheatList.Count;
DisplayCheatsList();
CheatListView.Refresh();
@ -56,8 +52,8 @@ namespace BizHawk.MultiClient
{
InitializeComponent();
Closing += (o, e) => SaveConfigSettings();
CheatListView.QueryItemText += new QueryItemTextHandler(CheatListView_QueryItemText);
CheatListView.QueryItemBkColor += new QueryItemBkColorHandler(CheatListView_QueryItemBkColor);
CheatListView.QueryItemText += CheatListView_QueryItemText;
CheatListView.QueryItemBkColor += CheatListView_QueryItemBkColor;
CheatListView.VirtualMode = true;
}
@ -85,7 +81,7 @@ namespace BizHawk.MultiClient
}
else
{
color = this.BackColor;
color = BackColor;
}
}
}
@ -179,8 +175,6 @@ namespace BizHawk.MultiClient
//Hacky Disabling if not a supported core
switch (Global.Emulator.SystemId)
{
default:
break;
case "UglyBrokenCore":
AddCheatGroup.Enabled = false;
CheatListView.Enabled = false;
@ -194,9 +188,9 @@ namespace BizHawk.MultiClient
DomainComboBox.Items.Clear();
if (Global.Emulator.MemoryDomains.Count > 0)
{
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
foreach (MemoryDomain t in Global.Emulator.MemoryDomains)
{
string str = Global.Emulator.MemoryDomains[x].ToString();
string str = t.ToString();
DomainComboBox.Items.Add(str);
}
DomainComboBox.SelectedIndex = 0;
@ -212,7 +206,7 @@ namespace BizHawk.MultiClient
Changes();
Global.CheatList.Add(c);
Global.OSD.AddMessage("Cheat added.");
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
DisplayCheatsList();
CheatListView.Refresh();
@ -228,7 +222,7 @@ namespace BizHawk.MultiClient
Global.CheatList.RemoveCheat(c.domain, c.address);
Global.OSD.AddMessage("Cheat removed.");
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
DisplayCheatsList();
CheatListView.Refresh();
Global.MainForm.RamWatch1.UpdateValues();
@ -264,9 +258,7 @@ namespace BizHawk.MultiClient
if (Global.Config.RecentCheats.IsEmpty)
{
var none = new ToolStripMenuItem();
none.Enabled = false;
none.Text = "None";
var none = new ToolStripMenuItem {Enabled = false, Text = "None"};
recentToolStripMenuItem.DropDownItems.Add(none);
}
else
@ -274,8 +266,7 @@ namespace BizHawk.MultiClient
for (int x = 0; x < Global.Config.RecentCheats.Count; x++)
{
string path = Global.Config.RecentCheats.GetRecentFileByPosition(x);
var item = new ToolStripMenuItem();
item.Text = path;
var item = new ToolStripMenuItem {Text = path};
item.Click += (o, ev) => LoadCheatFromRecent(path);
recentToolStripMenuItem.DropDownItems.Add(item);
}
@ -283,8 +274,7 @@ namespace BizHawk.MultiClient
recentToolStripMenuItem.DropDownItems.Add("-");
var clearitem = new ToolStripMenuItem();
clearitem.Text = "&Clear";
var clearitem = new ToolStripMenuItem {Text = "&Clear"};
clearitem.Click += (o, ev) => Global.Config.RecentCheats.Clear();
recentToolStripMenuItem.DropDownItems.Add(clearitem);
}
@ -309,7 +299,7 @@ namespace BizHawk.MultiClient
if (Global.Config.CheatsWidth >= 0 && Global.Config.CheatsHeight >= 0)
{
Size = new System.Drawing.Size(Global.Config.CheatsWidth, Global.Config.CheatsHeight);
Size = new Size(Global.Config.CheatsWidth, Global.Config.CheatsHeight);
}
if (Global.Config.CheatsNameWidth > 0)
@ -341,10 +331,10 @@ namespace BizHawk.MultiClient
public void SaveConfigSettings()
{
ColumnPositionSet();
Global.Config.CheatsWndx = this.Location.X;
Global.Config.CheatsWndy = this.Location.Y;
Global.Config.CheatsWidth = this.Right - this.Left;
Global.Config.CheatsHeight = this.Bottom - this.Top;
Global.Config.CheatsWndx = Location.X;
Global.Config.CheatsWndy = Location.Y;
Global.Config.CheatsWidth = Right - Left;
Global.Config.CheatsHeight = Bottom - Top;
Global.Config.CheatsNameWidth = CheatListView.Columns[Global.Config.CheatsNameIndex].Width;
Global.Config.CheatsAddressWidth = CheatListView.Columns[Global.Config.CheatsAddressIndex].Width;
@ -365,11 +355,10 @@ namespace BizHawk.MultiClient
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
if (indexes[0] == 0)
return;
Cheat temp = new Cheat();
if (indexes.Count == 0) return;
foreach (int index in indexes)
{
temp = Global.CheatList.Cheat(index);
Cheat temp = Global.CheatList.Cheat(index);
Global.CheatList.Remove(Global.CheatList.Cheat(index));
Global.CheatList.Insert(index - 1, temp);
@ -384,9 +373,9 @@ namespace BizHawk.MultiClient
}
CheatListView.SelectedIndices.Clear();
for (int z = 0; z < i.Count; z++)
foreach (int t in i)
{
CheatListView.SelectItem(i[z], true);
CheatListView.SelectItem(t, true);
}
DisplayCheatsList();
@ -395,11 +384,10 @@ namespace BizHawk.MultiClient
private void MoveDown()
{
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
Cheat temp = new Cheat();
if (indexes.Count == 0) return;
foreach (int index in indexes)
{
temp = Global.CheatList.Cheat(index);
Cheat temp = Global.CheatList.Cheat(index);
if (index < Global.CheatList.Count - 1)
{
@ -499,7 +487,7 @@ namespace BizHawk.MultiClient
if (result == DialogResult.Yes)
{
//TOOD: Do quicksave if filename, else save as
if (string.Compare(Global.CheatList.currentCheatFile, "") == 0)
if (String.CompareOrdinal(Global.CheatList.currentCheatFile, "") == 0)
{
SaveAs();
}
@ -520,7 +508,7 @@ namespace BizHawk.MultiClient
bool result = true;
if (Global.CheatList.Changes) result = AskSave();
if (result == true)
if (result)
{
Global.CheatList.Clear();
DisplayCheatsList();
@ -625,19 +613,20 @@ namespace BizHawk.MultiClient
private void InsertSeparator()
{
Changes();
Cheat c = new Cheat();
c.address = -1;
Cheat c = new Cheat {address = -1};
ListView.SelectedIndexCollection indexes = CheatListView.SelectedIndices;
int x;
if (indexes.Count > 0)
{
x = indexes[0];
if (indexes[0] > 0)
{
Global.CheatList.Insert(indexes[0], c);
}
}
else
{
Global.CheatList.Add(c);
}
DisplayCheatsList();
CheatListView.Refresh();
}
@ -659,8 +648,7 @@ namespace BizHawk.MultiClient
return null;
}
Cheat c = new Cheat();
c.name = NameBox.Text;
Cheat c = new Cheat {name = NameBox.Text};
try
{
@ -956,13 +944,12 @@ namespace BizHawk.MultiClient
}
string Str = e.Label;
int index = e.Item;
Global.CheatList.cheatList[e.Item].name = Str;
}
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
Size = new Size(defaultWidth, defaultHeight);
Global.Config.CheatsNameIndex = 0;
Global.Config.CheatsAddressIndex = 1;
Global.Config.CheatsValueIndex = 2;
@ -983,7 +970,7 @@ namespace BizHawk.MultiClient
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
Close();
}
private void appendFileToolStripMenuItem_Click(object sender, EventArgs e)
@ -1021,9 +1008,9 @@ namespace BizHawk.MultiClient
Global.OSD.AddMessage("All cheats disabled.");
}
for (int x = 0; x < Global.CheatList.cheatList.Count; x++)
foreach (Cheat t in Global.CheatList.cheatList)
{
Global.CheatList.cheatList[x].Disable();
t.Disable();
}
MemoryPulse.Clear();
@ -1035,7 +1022,7 @@ namespace BizHawk.MultiClient
{
Global.CheatList.Clear();
MemoryPulse.Clear();
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
CheatListView.Refresh();
UpdateNumberOfCheats();
Global.OSD.AddMessage("All cheats removed");
@ -1080,9 +1067,9 @@ namespace BizHawk.MultiClient
{
ColumnHeader header = e.Header;
int lowIndex = 0;
int highIndex = 0;
int changeIndex = 0;
int lowIndex;
int highIndex;
int changeIndex;
if (e.NewDisplayIndex > e.OldDisplayIndex)
{
changeIndex = -1;
@ -1163,23 +1150,25 @@ namespace BizHawk.MultiClient
CheatListView.Columns.Clear();
List<KeyValuePair<int, string>> columnSettings = new List<KeyValuePair<int, string>>();
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Name"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Address"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Value"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Compare"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Domain"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "On"));
List<KeyValuePair<int, string>> columnSettings = new List<KeyValuePair<int, string>>
{
new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Name"),
new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Address"),
new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Value"),
new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Compare"),
new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Domain"),
new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "On")
};
columnSettings = columnSettings.OrderBy(s => s.Key).ToList();
for (int i = 0; i < columnSettings.Count; i++)
foreach (KeyValuePair<int, string> t in columnSettings)
{
for (int j = 0; j < columnHeaders.Count; j++)
foreach (ColumnHeader t1 in columnHeaders)
{
if (columnSettings[i].Value == columnHeaders[j].Text)
if (t.Value == t1.Text)
{
CheatListView.Columns.Add(columnHeaders[j]);
CheatListView.Columns.Add(t1);
}
}
}
@ -1187,7 +1176,7 @@ namespace BizHawk.MultiClient
private void Cheats_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
}
private void Cheats_DragDrop(object sender, DragEventArgs e)

View File

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.MultiClient
@ -28,61 +22,61 @@ namespace BizHawk.MultiClient
private void HexBackgrnd_Click(Object sender, MouseEventArgs e)
{
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
Global.Config.HexBackgrndColor = colorDialog1.Color;
Global.MainForm.HexEditor1.Header.BackColor = colorDialog1.Color;
Global.MainForm.HexEditor1.MemoryViewerBox.BackColor = Global.Config.HexBackgrndColor;
this.HexBackgrnd.BackColor = colorDialog1.Color;
HexBackgrnd.BackColor = colorDialog1.Color;
}
}
private void HexForegrnd_Click(Object sender, MouseEventArgs e)
{
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
Global.Config.HexForegrndColor = colorDialog1.Color;
Global.MainForm.HexEditor1.Header.ForeColor = colorDialog1.Color;
Global.MainForm.HexEditor1.MemoryViewerBox.ForeColor = Global.Config.HexForegrndColor;
this.HexForegrnd.BackColor = colorDialog1.Color;
HexForegrnd.BackColor = colorDialog1.Color;
}
}
private void HexMenubar_Click(Object sender, MouseEventArgs e)
{
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
Global.Config.HexMenubarColor = colorDialog1.Color;
Global.MainForm.HexEditor1.menuStrip1.BackColor = Global.Config.HexMenubarColor;
this.HexMenubar.BackColor = colorDialog1.Color;
HexMenubar.BackColor = colorDialog1.Color;
}
}
private void HexHighlight_Click(Object sender, MouseEventArgs e)
{
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
Global.Config.HexHighlightColor = colorDialog1.Color;
this.HexHighlight.BackColor = colorDialog1.Color;
HexHighlight.BackColor = colorDialog1.Color;
}
}
private void HexFreeze_Click(Object sender, MouseEventArgs e)
{
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
Global.Config.HexFreezeColor = colorDialog1.Color;
this.HexFreeze.BackColor = colorDialog1.Color;
HexFreeze.BackColor = colorDialog1.Color;
}
}
private void HexFreezeHL_Click(Object sender, MouseEventArgs e)
{
if (colorDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
Global.Config.HexHighlightFreezeColor = colorDialog1.Color;
this.HexFreezeHL.BackColor = colorDialog1.Color;
HexFreezeHL.BackColor = colorDialog1.Color;
}
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
@ -17,46 +16,39 @@ namespace BizHawk.MultiClient
//Increment/Decrement wrapping logic for 4 byte values is messed up
//2 & 4 byte text area clicking is off
int defaultWidth;
int defaultHeight;
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
int RowsVisible = 0;
int NumDigits = 4;
string NumDigitsStr = "{0:X4}";
string DigitFormatString = "{0:X2}";
char[] nibbles = { 'G', 'G', 'G', 'G' , 'G', 'G', 'G', 'G'}; //G = off 0-9 & A-F are acceptable values
int addressHighlighted = -1;
List<int> SecondaryHighlightedAddresses = new List<int>();
int addressOver = -1;
int maxRow = 0;
MemoryDomain Domain = new MemoryDomain("NULL", 1024, Endian.Little, addr => { return 0; }, (a, v) => { v = 0; });
string info = "";
int row = 0;
int addr = 0;
private int Pointedx = 0;
private int Pointedy = 0;
const int rowX = 1;
const int rowY = 4;
const int rowYoffset = 20;
const int fontHeight = 14;
const int fontWidth = 7; //Width of 1 digits
string FindStr = "";
bool loaded = false;
bool MouseIsDown = false;
byte[] ROM;
MemoryDomain ROMDomain;
private int defaultWidth;
private int defaultHeight;
private readonly List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
private int RowsVisible = 0;
private int NumDigits = 4;
private string NumDigitsStr = "{0:X4}";
private string DigitFormatString = "{0:X2}";
private readonly char[] nibbles = { 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G' }; //G = off 0-9 & A-F are acceptable values
private int addressHighlighted = -1;
private readonly List<int> SecondaryHighlightedAddresses = new List<int>();
private int addressOver = -1;
private int maxRow = 0;
private MemoryDomain Domain = new MemoryDomain("NULL", 1024, Endian.Little, addr => 0, (a, v) => { v = 0; });
private string info = "";
private int row;
private int addr;
private const int fontHeight = 14;
private const int fontWidth = 7; //Width of 1 digits
private string FindStr = "";
private bool loaded;
private bool MouseIsDown;
private byte[] ROM;
private MemoryDomain ROMDomain;
// Configurations
bool AutoLoad;
bool SaveWindowPosition;
int Wndx = -1;
int Wndy = -1;
int Width_ = -1;
int Height_ = -1;
bool BigEndian;
int DataSize;
private bool AutoLoad;
private bool SaveWindowPosition;
private int Wndx = -1;
private int Wndy = -1;
private int Width_ = -1;
private int Height_ = -1;
private bool BigEndian;
private int DataSize;
HexFind HexFind1 = new HexFind();
@ -102,10 +94,10 @@ namespace BizHawk.MultiClient
Global.Config.HexEditorSaveWindowPosition = SaveWindowPosition;
if (SaveWindowPosition)
{
Global.Config.HexEditorWndx = loaded ? this.Location.X : Wndx;
Global.Config.HexEditorWndy = loaded ? this.Location.Y : Wndy;
Global.Config.HexEditorWidth = loaded ? this.Right - this.Left : Width_;
Global.Config.HexEditorHeight = loaded ? this.Bottom - this.Top : Height_;
Global.Config.HexEditorWndx = loaded ? Location.X : Wndx;
Global.Config.HexEditorWndy = loaded ? Location.Y : Wndy;
Global.Config.HexEditorWidth = loaded ? Right - Left : Width_;
Global.Config.HexEditorHeight = loaded ? Bottom - Top : Height_;
}
Global.Config.HexEditorBigEndian = BigEndian;
Global.Config.HexEditorDataSize = DataSize;
@ -113,15 +105,19 @@ namespace BizHawk.MultiClient
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;
defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
defaultHeight = Size.Height;
if (SaveWindowPosition)
{
if (Wndx >= 0 && Wndy >= 0)
this.Location = new Point(Wndx, Wndy);
{
Location = new Point(Wndx, Wndy);
}
if (Width_ >= 0 && Height_ >= 0)
this.Size = new System.Drawing.Size(Width_, Height_);
{
Size = new Size(Width_, Height_);
}
}
SetMemoryDomainMenu();
SetDataSize(DataSize);
@ -131,12 +127,12 @@ namespace BizHawk.MultiClient
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
Close();
}
public void UpdateValues()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
AddressesLabel.Text = GenerateMemoryViewString();
AddressLabel.Text = GenerateAddressString();
@ -214,46 +210,46 @@ namespace BizHawk.MultiClient
else return (char)val;
}
private int MakeValue(int addr)
private int MakeValue(int address)
{
switch (DataSize)
{
default:
case 1:
return Domain.PeekByte(addr);
return Domain.PeekByte(address);
case 2:
if (BigEndian)
{
int value = 0;
value |= Domain.PeekByte(addr) << 8;
value |= Domain.PeekByte(addr + 1);
value |= Domain.PeekByte(address) << 8;
value |= Domain.PeekByte(address + 1);
return value;
}
else
{
int value = 0;
value |= Domain.PeekByte(addr);
value |= Domain.PeekByte(addr + 1) << 8;
value |= Domain.PeekByte(address);
value |= Domain.PeekByte(address + 1) << 8;
return value;
}
case 4:
if (BigEndian)
{
int value = 0;
value |= Domain.PeekByte(addr) << 24;
value |= Domain.PeekByte(addr + 1) << 16;
value |= Domain.PeekByte(addr + 2) << 8;
value |= Domain.PeekByte(addr + 3) << 0;
value |= Domain.PeekByte(address) << 24;
value |= Domain.PeekByte(address + 1) << 16;
value |= Domain.PeekByte(address + 2) << 8;
value |= Domain.PeekByte(address + 3) << 0;
return value;
}
else
{
int value = 0;
value |= Domain.PeekByte(addr) << 0;
value |= Domain.PeekByte(addr + 1) << 8;
value |= Domain.PeekByte(addr + 2) << 16;
value |= Domain.PeekByte(addr + 3) << 24;
value |= Domain.PeekByte(address) << 0;
value |= Domain.PeekByte(address + 1) << 8;
value |= Domain.PeekByte(address + 2) << 16;
value |= Domain.PeekByte(address + 3) << 24;
return value;
}
}
@ -282,9 +278,9 @@ namespace BizHawk.MultiClient
public void Restart()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
int? theDomain = null;
int? theDomain;
if (Domain.Name.ToLower() == "rom file")
{
theDomain = 999;
@ -300,7 +296,7 @@ namespace BizHawk.MultiClient
if (theDomain != null)
{
SetMemoryDomain(theDomain ?? 0);
SetMemoryDomain((int) theDomain);
}
SetHeader();
@ -314,7 +310,7 @@ namespace BizHawk.MultiClient
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
Size = new Size(defaultWidth, defaultHeight);
SetUpScrollBar();
}
@ -348,12 +344,12 @@ namespace BizHawk.MultiClient
if (IsFrozen(GetHighlightedAddress()))
{
freezeAddressToolStripMenuItem.Image = MultiClient.Properties.Resources.Unfreeze;
freezeAddressToolStripMenuItem.Image = Properties.Resources.Unfreeze;
freezeAddressToolStripMenuItem.Text = "Un&freeze Address";
}
else
{
freezeAddressToolStripMenuItem.Image = MultiClient.Properties.Resources.Freeze;
freezeAddressToolStripMenuItem.Image = Properties.Resources.Freeze;
freezeAddressToolStripMenuItem.Text = "&Freeze Address";
}
@ -447,15 +443,11 @@ namespace BizHawk.MultiClient
{
if (pos == 999)
{
ROM = GetRomBytes();
if (ROM == null)
{
ROM = new byte[1] { 0xFF };
}
ROM = GetRomBytes() ?? new byte[] { 0xFF };
ROMDomain = new MemoryDomain("ROM File", ROM.Length, Endian.Little,
addr => ROM[addr],
(addr, value) => ROM[addr] = value);
i => ROM[i],
(i, value) => ROM[i] = value);
Domain = ROMDomain;
}
@ -491,8 +483,7 @@ namespace BizHawk.MultiClient
if (Global.Emulator.MemoryDomains[i].Size > 0)
{
string str = Global.Emulator.MemoryDomains[i].ToString();
var item = new ToolStripMenuItem();
item.Text = str;
var item = new ToolStripMenuItem {Text = str};
{
int z = i;
item.Click += (o, ev) => SetMemoryDomain(z);
@ -507,8 +498,7 @@ namespace BizHawk.MultiClient
}
//Add ROM File memory domain
var rom_item = new ToolStripMenuItem();
rom_item.Text = "ROM File";
var rom_item = new ToolStripMenuItem {Text = "ROM File"};
rom_item.Click += (o, ev) => SetMemoryDomain(999); //999 will denote ROM file
memoryDomainsToolStripMenuItem.DropDownItems.Add(rom_item);
domainMenuItems.Add(rom_item);
@ -530,8 +520,7 @@ namespace BizHawk.MultiClient
public void GoToSpecifiedAddress()
{
InputPrompt i = new InputPrompt();
i.Text = "Go to Address";
InputPrompt i = new InputPrompt {Text = "Go to Address"};
i.SetMessage("Enter a hexadecimal value");
Global.Sound.StopSound();
i.ShowDialog();
@ -550,16 +539,22 @@ namespace BizHawk.MultiClient
private void ClearNibbles()
{
for (int x = 0; x < 8; x++)
{
nibbles[x] = 'G';
}
}
public void GoToAddress(int address)
{
if (address < 0)
{
address = 0;
}
if (address >= Domain.Size)
{
address = Domain.Size - 1;
}
SetHighlighted(address);
ClearNibbles();
@ -568,22 +563,29 @@ namespace BizHawk.MultiClient
AddressLabel.Text = GenerateAddressString();
}
public void SetHighlighted(int addr)
public void SetHighlighted(int address)
{
if (addr < 0)
addr = 0;
if (addr >= Domain.Size)
addr = Domain.Size - 1;
if (!IsVisible(addr))
if (address < 0)
{
int v = (addr / 16) - RowsVisible + 1;
address = 0;
}
if (address >= Domain.Size)
{
address = Domain.Size - 1;
}
if (!IsVisible(address))
{
int v = (address / 16) - RowsVisible + 1;
if (v < 0)
{
v = 0;
}
vScrollBar1.Value = v;
}
addressHighlighted = addr;
addressOver = addr;
addressHighlighted = address;
addressOver = address;
ClearNibbles();
info = String.Format(NumDigitsStr, addressOver);
UpdateFormText();
@ -597,14 +599,10 @@ namespace BizHawk.MultiClient
Text = "Hex Editor";
}
public bool IsVisible(int addr)
public bool IsVisible(int address)
{
int row = addr >> 4;
if (row >= vScrollBar1.Value && row < (RowsVisible + vScrollBar1.Value))
return true;
else
return false;
int i = address >> 4;
return i >= vScrollBar1.Value && i < (RowsVisible + vScrollBar1.Value);
}
private void HexEditor_Resize(object sender, EventArgs e)
@ -664,11 +662,7 @@ namespace BizHawk.MultiClient
private Watch MakeWatch(int address)
{
Watch w = new Watch();
w.Address = address;
w.BigEndian = BigEndian;
w.Signed = Watch.DISPTYPE.HEX;
w.Domain = Domain;
Watch w = new Watch {Address = address, BigEndian = BigEndian, Signed = Watch.DISPTYPE.HEX, Domain = Domain};
switch (DataSize)
{
default:
@ -699,56 +693,46 @@ namespace BizHawk.MultiClient
{
Global.MainForm.RamWatch1.AddWatch(MakeWatch(address));
}
foreach (int addr in SecondaryHighlightedAddresses)
foreach (int i in SecondaryHighlightedAddresses)
{
Global.MainForm.RamWatch1.AddWatch(MakeWatch(addr));
Global.MainForm.RamWatch1.AddWatch(MakeWatch(i));
}
}
private void MemoryViewer_MouseDoubleClick(object sender, MouseEventArgs e)
{
AddToRamWatch();
}
private void pokeToolStripMenuItem_Click(object sender, EventArgs e)
{
PokeAddress();
}
private void PokeAddress()
{
int p = GetHighlightedAddress();
if (p >= 0)
{
Watch w = new Watch();
w.Address = p;
w.Value = MakeValue(p);
w.BigEndian = BigEndian;
w.Signed = Watch.DISPTYPE.HEX;
w.Domain = Domain;
switch (DataSize)
if (p < 0) return;
Watch w = new Watch
{
default:
case 1:
w.Type = Watch.TYPE.BYTE;
break;
case 2:
w.Type = Watch.TYPE.WORD;
break;
case 4:
w.Type = Watch.TYPE.DWORD;
break;
}
RamPoke poke = new RamPoke();
poke.SetWatchObject(w);
poke.location = GetAddressCoordinates(p);
Global.Sound.StopSound();
poke.ShowDialog();
Global.Sound.StartSound();
UpdateValues();
Address = p,
Value = MakeValue(p),
BigEndian = BigEndian,
Signed = Watch.DISPTYPE.HEX,
Domain = Domain
};
switch (DataSize)
{
default:
case 1:
w.Type = Watch.TYPE.BYTE;
break;
case 2:
w.Type = Watch.TYPE.WORD;
break;
case 4:
w.Type = Watch.TYPE.DWORD;
break;
}
RamPoke poke = new RamPoke();
poke.SetWatchObject(w);
poke.NewLocation = GetAddressCoordinates(p);
Global.Sound.StopSound();
poke.ShowDialog();
Global.Sound.StartSound();
UpdateValues();
}
public int GetPointedAddress()
@ -837,15 +821,15 @@ namespace BizHawk.MultiClient
{
FreezeAddress(GetHighlightedAddress());
}
foreach (int addr in SecondaryHighlightedAddresses)
foreach (int i in SecondaryHighlightedAddresses)
{
if (IsFrozen(addr))
if (IsFrozen(i))
{
UnFreezeAddress(addr);
UnFreezeAddress(i);
}
else
{
FreezeAddress(addr);
FreezeAddress(i);
}
}
@ -858,10 +842,7 @@ namespace BizHawk.MultiClient
{
if (address >= 0)
{
Cheat c = new Cheat();
c.address = address;
c.value = Domain.PeekByte(address);
c.domain = Domain;
Cheat c = new Cheat {address = address, value = Domain.PeekByte(address), domain = Domain};
Global.MainForm.Cheats1.RemoveCheat(c);
switch (DataSize)
@ -870,30 +851,18 @@ namespace BizHawk.MultiClient
case 1:
break;
case 2:
Cheat c2 = new Cheat();
c2.address = address + 1;
c2.domain = Domain;
c2.value = Domain.PeekByte(address + 1);
Cheat c2 = new Cheat {address = address + 1, domain = Domain, value = Domain.PeekByte(address + 1)};
c2.Enable();
Global.MainForm.Cheats1.RemoveCheat(c2);
break;
case 4:
Cheat c42 = new Cheat();
c42.address = address + 1;
c42.domain = Domain;
c42.value = Domain.PeekByte(address + 1);
Cheat c42 = new Cheat {address = address + 1, domain = Domain, value = Domain.PeekByte(address + 1)};
c42.Enable();
Global.MainForm.Cheats1.RemoveCheat(c42);
Cheat c43 = new Cheat();
c43.address = address + 2;
c43.domain = Domain;
c43.value = Domain.PeekByte(address + 2);
Cheat c43 = new Cheat {address = address + 2, domain = Domain, value = Domain.PeekByte(address + 2)};
c43.Enable();
Global.MainForm.Cheats1.RemoveCheat(c43);
Cheat c44 = new Cheat();
c44.address = address + 3;
c44.domain = Domain;
c44.value = Domain.PeekByte(address + 3);
Cheat c44 = new Cheat {address = address + 3, domain = Domain, value = Domain.PeekByte(address + 3)};
c44.Enable();
Global.MainForm.Cheats1.RemoveCheat(c44);
break;
@ -906,10 +875,7 @@ namespace BizHawk.MultiClient
{
if (address >= 0)
{
Cheat c = new Cheat();
c.address = address;
c.value = Domain.PeekByte(address);
c.domain = Domain;
Cheat c = new Cheat {address = address, value = Domain.PeekByte(address), domain = Domain};
c.Enable();
Global.MainForm.Cheats1.AddCheat(c);
@ -919,30 +885,18 @@ namespace BizHawk.MultiClient
case 1:
break;
case 2:
Cheat c2 = new Cheat();
c2.address = address + 1;
c2.domain = Domain;
c2.value = Domain.PeekByte(address + 1);
Cheat c2 = new Cheat {address = address + 1, domain = Domain, value = Domain.PeekByte(address + 1)};
c2.Enable();
Global.MainForm.Cheats1.AddCheat(c2);
break;
case 4:
Cheat c42 = new Cheat();
c42.address = address + 1;
c42.domain = Domain;
c42.value = Domain.PeekByte(address + 1);
Cheat c42 = new Cheat {address = address + 1, domain = Domain, value = Domain.PeekByte(address + 1)};
c42.Enable();
Global.MainForm.Cheats1.AddCheat(c42);
Cheat c43 = new Cheat();
c43.address = address + 2;
c43.domain = Domain;
c43.value = Domain.PeekByte(address + 2);
Cheat c43 = new Cheat {address = address + 2, domain = Domain, value = Domain.PeekByte(address + 2)};
c43.Enable();
Global.MainForm.Cheats1.AddCheat(c43);
Cheat c44 = new Cheat();
c44.address = address + 3;
c44.domain = Domain;
c44.value = Domain.PeekByte(address + 3);
Cheat c44 = new Cheat {address = address + 3, domain = Domain, value = Domain.PeekByte(address + 3)};
c44.Enable();
Global.MainForm.Cheats1.AddCheat(c44);
break;
@ -958,15 +912,15 @@ namespace BizHawk.MultiClient
private void CheckDomainMenuItems()
{
for (int x = 0; x < domainMenuItems.Count; x++)
foreach (ToolStripMenuItem t in domainMenuItems)
{
if (Domain.Name == domainMenuItems[x].Text)
if (Domain.Name == t.Text)
{
domainMenuItems[x].Checked = true;
t.Checked = true;
}
else
{
domainMenuItems[x].Checked = false;
t.Checked = false;
}
}
}
@ -1015,8 +969,6 @@ namespace BizHawk.MultiClient
{
using (BinaryWriter binWriter = new BinaryWriter(File.Open(file.FullName, FileMode.Create)))
{
byte[] dump = new byte[Domain.Size];
for (int x = 0; x < Domain.Size; x++)
{
binWriter.Write(Domain.PeekByte(x));
@ -1107,12 +1059,12 @@ namespace BizHawk.MultiClient
private int GetPointedAddress(int x, int y)
{
int address = -1;
int address;
//Scroll value determines the first row
int row = vScrollBar1.Value;
int i = vScrollBar1.Value;
int rowoffset = y / fontHeight;
row += rowoffset;
int colWidth = 0;
i += rowoffset;
int colWidth;
switch (DataSize)
{
default:
@ -1134,9 +1086,9 @@ namespace BizHawk.MultiClient
column = (x - start) / (fontWidth / DataSize);
}
if (row >= 0 && row <= maxRow && column >= 0 && column < (16 / DataSize))
if (i >= 0 && i <= maxRow && column >= 0 && column < (16 / DataSize))
{
address = row * 16 + (column * DataSize);
address = i * 16 + (column * DataSize);
info = String.Format(NumDigitsStr, addressOver);
}
else
@ -1155,8 +1107,6 @@ namespace BizHawk.MultiClient
private void AddressesLabel_MouseMove(object sender, MouseEventArgs e)
{
addressOver = GetPointedAddress(e.X, e.Y);
Pointedx = e.X;
Pointedy = e.Y;
if (MouseIsDown)
{
@ -1215,7 +1165,7 @@ namespace BizHawk.MultiClient
private int GetTextOffset()
{
int start = 0;
int start;
switch (DataSize)
{
default:
@ -1329,8 +1279,6 @@ namespace BizHawk.MultiClient
private void AddressesLabel_MouseLeave(object sender, EventArgs e)
{
Pointedx = 0;
Pointedy = 0;
addressOver = -1;
MemoryViewerBox.Refresh();
}
@ -1672,17 +1620,17 @@ namespace BizHawk.MultiClient
MemoryViewerBox.Refresh();
}
private void PokeWord(int addr, byte _1, byte _2)
private void PokeWord(int address, byte _1, byte _2)
{
if (BigEndian)
{
Domain.PokeByte(addr, _2);
Domain.PokeByte(addr + 1, _1);
Domain.PokeByte(address, _2);
Domain.PokeByte(address + 1, _1);
}
else
{
Domain.PokeByte(addr, _1);
Domain.PokeByte(addr + 1, _2);
Domain.PokeByte(address, _1);
Domain.PokeByte(address + 1, _2);
}
}
@ -1727,9 +1675,9 @@ namespace BizHawk.MultiClient
private void IncrementAddress()
{
int address = GetHighlightedAddress();
byte value;
if (address >= 0)
{
byte value;
switch (DataSize)
{
default:
@ -1799,16 +1747,16 @@ namespace BizHawk.MultiClient
}
else
{
Domain.PokeByte(address, (byte)value);
Domain.PokeByte(address, value);
}
}
private void DecrementAddress()
{
int address = GetHighlightedAddress();
byte value;
if (address >= 0)
{
byte value;
switch (DataSize)
{
default:
@ -1898,7 +1846,7 @@ namespace BizHawk.MultiClient
private void ViewerContextMenuStrip_Opening(object sender, CancelEventArgs e)
{
if (addressHighlighted > 0 || SecondaryHighlightedAddresses.Count() > 0)
if (addressHighlighted > 0 || SecondaryHighlightedAddresses.Any())
{
copyToolStripMenuItem1.Visible = true;
}
@ -1909,7 +1857,7 @@ namespace BizHawk.MultiClient
IDataObject iData = Clipboard.GetDataObject();
if (iData.GetDataPresent(DataFormats.Text))
if (iData != null && iData.GetDataPresent(DataFormats.Text))
{
pasteToolStripMenuItem1.Visible = true;
}
@ -1921,12 +1869,12 @@ namespace BizHawk.MultiClient
if (IsFrozen(GetHighlightedAddress()))
{
freezeToolStripMenuItem.Text = "Un&freeze";
freezeToolStripMenuItem.Image = MultiClient.Properties.Resources.Unfreeze;
freezeToolStripMenuItem.Image = Properties.Resources.Unfreeze;
}
else
{
freezeToolStripMenuItem.Text = "&Freeze";
freezeToolStripMenuItem.Image = MultiClient.Properties.Resources.Freeze;
freezeToolStripMenuItem.Image = Properties.Resources.Freeze;
}
}
@ -1939,7 +1887,7 @@ namespace BizHawk.MultiClient
{
if (address != -1)
{
return String.Format(DigitFormatString, (int)MakeValue(address)).Trim();
return String.Format(DigitFormatString, MakeValue(address)).Trim();
}
else
{
@ -1968,16 +1916,15 @@ namespace BizHawk.MultiClient
private string GetFindValues()
{
string values = "";
if (addressHighlighted > 0)
{
values += ValueString(GetHighlightedAddress());
foreach (int x in SecondaryHighlightedAddresses)
{
values += ValueString(x);
}
string values = ValueString(GetHighlightedAddress());
return SecondaryHighlightedAddresses.Aggregate(values, (current, x) => current + ValueString(x));
}
else
{
return "";
}
return values;
}
public void FindNext(string value, Boolean wrap)
@ -1990,7 +1937,7 @@ namespace BizHawk.MultiClient
int numByte = search.Length / 2;
int startByte = 0;
int startByte;
if (addressHighlighted == -1)
{
startByte = 0;
@ -2042,7 +1989,7 @@ namespace BizHawk.MultiClient
int numByte = search.Length / 2;
int startByte = 0;
int startByte;
if (addressHighlighted == -1)
{
startByte = Domain.Size - DataSize;
@ -2099,82 +2046,10 @@ namespace BizHawk.MultiClient
}
private void Find()
{
InputPrompt prompt = new InputPrompt();
prompt.SetMessage("Enter a set of hex values to search for");
prompt.SetCasing(CharacterCasing.Upper);
prompt.TextInputType = InputPrompt.InputType.HEX;
if (addressHighlighted > 0)
{
string values = ValueString(GetHighlightedAddress());
foreach (int x in SecondaryHighlightedAddresses)
{
values += ValueString(x);
}
prompt.SetInitialValue(values);
}
prompt.ShowDialog();
if (prompt.UserOK)
{
int found = 0;
string search = prompt.UserText.Replace(" ", "").ToUpper();
if (search.Length == 0)
return;
int numByte = search.Length / 2;
int startByte = 0;
if (addressHighlighted == -1)
{
startByte = 0;
}
else if (addressHighlighted >= (Domain.Size - 1 - numByte))
{
startByte = 0;
}
else
{
startByte = addressHighlighted + DataSize;
}
for (int i = startByte; i < (Domain.Size - numByte); i++)
{
StringBuilder ramblock = new StringBuilder();
for (int j = 0; j < numByte; j++)
{
ramblock.Append(String.Format("{0:X2}", (int)Domain.PeekByte(i + j)));
}
string block = ramblock.ToString().ToUpper();
if (search == block)
{
found = i;
break;
}
}
if (found > 0)
{
GoToAddress(found);
}
else
{
MessageBox.Show("Could not find the values: " + search);
}
}
}
private void Copy()
{
string value = ValueString(GetHighlightedAddress());
foreach (int x in SecondaryHighlightedAddresses)
{
value += ValueString(x);
}
value = SecondaryHighlightedAddresses.Aggregate(value, (current, x) => current + ValueString(x));
if (!String.IsNullOrWhiteSpace(value))
{
Clipboard.SetDataObject(value);
@ -2190,7 +2065,7 @@ namespace BizHawk.MultiClient
{
IDataObject iData = Clipboard.GetDataObject();
if (iData.GetDataPresent(DataFormats.Text))
if (iData != null && iData.GetDataPresent(DataFormats.Text))
{
string clipboardRaw = (String)iData.GetData(DataFormats.Text);
string hex = InputValidate.DoHexString(clipboardRaw);
@ -2243,11 +2118,11 @@ namespace BizHawk.MultiClient
private void resetToDefaultToolStripMenuItem1_Click(object sender, EventArgs e)
{
this.MemoryViewerBox.BackColor = Color.FromName("Control");
this.MemoryViewerBox.ForeColor = Color.FromName("ControlText");
this.menuStrip1.BackColor = Color.FromName("Control");
this.Header.BackColor = Color.FromName("Control");
this.Header.ForeColor = Color.FromName("ControlText");
MemoryViewerBox.BackColor = Color.FromName("Control");
MemoryViewerBox.ForeColor = Color.FromName("ControlText");
menuStrip1.BackColor = Color.FromName("Control");
Header.BackColor = Color.FromName("Control");
Header.ForeColor = Color.FromName("ControlText");
Global.Config.HexMenubarColor = Color.FromName("Control");
Global.Config.HexForegrndColor = Color.FromName("ControlText");
Global.Config.HexBackgrndColor = Color.FromName("Control");
@ -2343,25 +2218,25 @@ namespace BizHawk.MultiClient
{
if (e.Button == MouseButtons.Left)
{
int addressOver = GetPointedAddress(e.X, e.Y);
if (addressOver >= 0)
int pointed_address = GetPointedAddress(e.X, e.Y);
if (pointed_address >= 0)
{
if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
if ((ModifierKeys & Keys.Control) == Keys.Control)
{
if (addressOver == addressHighlighted)
if (pointed_address == addressHighlighted)
{
ClearHighlighted();
}
else if (SecondaryHighlightedAddresses.Contains(addressOver))
else if (SecondaryHighlightedAddresses.Contains(pointed_address))
{
SecondaryHighlightedAddresses.Remove(addressOver);
SecondaryHighlightedAddresses.Remove(pointed_address);
}
else
{
SecondaryHighlightedAddresses.Add(addressOver);
SecondaryHighlightedAddresses.Add(pointed_address);
}
}
else if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
else if ((ModifierKeys & Keys.Shift) == Keys.Shift)
{
DoShiftClick();
}
@ -2371,7 +2246,7 @@ namespace BizHawk.MultiClient
//}
else
{
SetHighlighted(addressOver);
SetHighlighted(pointed_address);
SecondaryHighlightedAddresses.Clear();
FindStr = "";
}

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
@ -32,7 +30,7 @@ namespace BizHawk.MultiClient
{
if (location.X > 0 && location.Y > 0)
{
this.Location = location;
Location = location;
}
}
@ -48,11 +46,7 @@ namespace BizHawk.MultiClient
}
else
{
List<byte> bytes = new List<byte>();
foreach (char c in FindBox.Text)
{
bytes.Add(Convert.ToByte(c));
}
List<byte> bytes = FindBox.Text.Select(c => Convert.ToByte(c)).ToList();
StringBuilder bytestring = new StringBuilder();
foreach (byte b in bytes)

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BizHawk.MultiClient
namespace BizHawk.MultiClient
{
public interface IVirtualPad
{

View File

@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.MultiClient
@ -55,7 +50,7 @@ namespace BizHawk.MultiClient
{
if (_Location.X > 0 && _Location.Y > 0)
{
this.Location = _Location;
Location = _Location;
}
}
@ -63,13 +58,13 @@ namespace BizHawk.MultiClient
{
UserOK = true;
UserText = PromptBox.Text;
this.Close();
Close();
}
private void Cancel_Click(object sender, EventArgs e)
{
UserOK = false;
this.Close();
Close();
}
private void PromptBox_KeyPress(object sender, KeyPressEventArgs e)

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.MultiClient.tools
@ -10,8 +7,8 @@ namespace BizHawk.MultiClient.tools
{
private void DoLuaClick(object sender, EventArgs e)
{
LuaWinform parent = this.Parent as LuaWinform;
parent.DoLuaEvent(this.Handle);
LuaWinform parent = Parent as LuaWinform;
if (parent != null) parent.DoLuaEvent(Handle);
}
protected override void OnClick(EventArgs e)

View File

@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using LuaInterface;
namespace BizHawk.MultiClient
{
@ -21,7 +18,7 @@ namespace BizHawk.MultiClient
string currentSessionFile = "";
List<LuaFile> luaList = new List<LuaFile>();
public LuaImplementation LuaImp;
string lastLuaFile = "";
string lastLuaFile = ""; //TODO: this isn't getting used!
bool changes = false;
private List<LuaFile> GetLuaFileList()
@ -48,8 +45,8 @@ namespace BizHawk.MultiClient
InitializeComponent();
LuaImp = new LuaImplementation(this);
Closing += (o, e) => SaveConfigSettings();
LuaListView.QueryItemText += new QueryItemTextHandler(LuaListView_QueryItemText);
LuaListView.QueryItemBkColor += new QueryItemBkColorHandler(LuaListView_QueryItemBkColor);
LuaListView.QueryItemText += LuaListView_QueryItemText;
LuaListView.QueryItemBkColor += LuaListView_QueryItemBkColor;
LuaListView.VirtualMode = true;
}
@ -72,11 +69,17 @@ namespace BizHawk.MultiClient
if (column == 0)
{
if (luaList[index].IsSeparator)
color = this.BackColor;
{
color = BackColor;
}
else if (luaList[index].Enabled && !luaList[index].Paused)
{
color = Color.LightCyan;
}
else if (luaList[index].Enabled && luaList[index].Paused)
{
color = Color.IndianRed;
}
}
UpdateNumberOfScripts();
@ -117,8 +120,10 @@ namespace BizHawk.MultiClient
private void StopAllScripts()
{
for (int x = 0; x < luaList.Count; x++)
luaList[x].Enabled = false;
foreach (LuaFile t in luaList)
{
t.Enabled = false;
}
Changes(true);
}
@ -130,10 +135,10 @@ namespace BizHawk.MultiClient
private void SaveConfigSettings()
{
LuaImp.Close();
Global.Config.LuaConsoleWndx = this.Location.X;
Global.Config.LuaConsoleWndy = this.Location.Y;
Global.Config.LuaConsoleWidth = this.Right - this.Left;
Global.Config.LuaConsoleHeight = this.Bottom - this.Top;
Global.Config.LuaConsoleWndx = Location.X;
Global.Config.LuaConsoleWndy = Location.Y;
Global.Config.LuaConsoleWidth = Right - Left;
Global.Config.LuaConsoleHeight = Bottom - Top;
}
private void LoadConfigSettings()
@ -146,18 +151,18 @@ namespace BizHawk.MultiClient
if (Global.Config.LuaConsoleWidth >= 0 && Global.Config.LuaConsoleHeight >= 0)
{
Size = new System.Drawing.Size(Global.Config.LuaConsoleWidth, Global.Config.LuaConsoleHeight);
Size = new Size(Global.Config.LuaConsoleWidth, Global.Config.LuaConsoleHeight);
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
Close();
}
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
Size = new Size(defaultWidth, defaultHeight);
}
private FileInfo GetFileFromUser(string filter)
@ -215,11 +220,11 @@ namespace BizHawk.MultiClient
}
else
{
for (int i = 0; i < luaList.Count; i++)
foreach (LuaFile t in luaList)
{
if (path == luaList[i].Path && luaList[i].Enabled == false && !Global.Config.DisableLuaScriptsOnLoad)
if (path == t.Path && t.Enabled == false && !Global.Config.DisableLuaScriptsOnLoad)
{
luaList[i].Toggle();
t.Toggle();
RunLuaScripts();
LuaListView.Refresh();
Changes(true);
@ -244,11 +249,6 @@ namespace BizHawk.MultiClient
LuaListView.ItemCount = luaList.Count;
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenLuaFile();
}
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
saveWindowPositionToolStripMenuItem.Checked = Global.Config.LuaConsoleSaveWindowPosition;
@ -327,14 +327,14 @@ namespace BizHawk.MultiClient
{
string message = "";
int active = 0, paused = 0, separators = 0;
for (int x = 0; x < luaList.Count; x++)
foreach (LuaFile t in luaList)
{
if (!luaList[x].IsSeparator)
if (!t.IsSeparator)
{
if (luaList[x].Enabled)
if (t.Enabled)
{
active++;
if (luaList[x].Paused)
if (t.Paused)
paused++;
}
}
@ -355,16 +355,6 @@ namespace BizHawk.MultiClient
NumberOfScripts.Text = message;
}
private void moveUpToolStripMenuItem_Click(object sender, EventArgs e)
{
MoveUp();
}
private void moveDownToolStripMenuItem_Click(object sender, EventArgs e)
{
MoveDown();
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
if (changes)
@ -392,7 +382,7 @@ namespace BizHawk.MultiClient
bool result = true;
if (changes) result = AskSave();
if (result == true || suppressAsk)
if (result || suppressAsk)
{
ClearOutput();
StopAllScripts();
@ -418,11 +408,6 @@ namespace BizHawk.MultiClient
Global.Config.AutoLoadLuaConsole ^= true;
}
private void removeToolStripMenuItem_Click(object sender, EventArgs e)
{
RemoveScript();
}
private void RemoveScript()
{
if (luaList.Count == 0) return;
@ -452,19 +437,20 @@ namespace BizHawk.MultiClient
private void InsertSeparator()
{
LuaFile f = new LuaFile(true);
f.IsSeparator = true;
LuaFile f = new LuaFile(true) {IsSeparator = true};
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
int x;
if (indexes.Count > 0)
{
x = indexes[0];
if (indexes[0] > 0)
{
luaList.Insert(indexes[0], f);
}
}
else
{
luaList.Add(f);
}
DisplayLuaList();
LuaListView.Refresh();
Changes(true);
@ -481,11 +467,10 @@ namespace BizHawk.MultiClient
if (indexes[0] == 0)
return;
LuaFile temp = new LuaFile(false);
if (indexes.Count == 0) return;
foreach (int index in indexes)
{
temp = luaList[index];
LuaFile temp = luaList[index];
luaList.Remove(luaList[index]);
luaList.Insert(index - 1, temp);
@ -498,8 +483,10 @@ namespace BizHawk.MultiClient
i.Add(indexes[z] - 1);
LuaListView.SelectedIndices.Clear();
for (int z = 0; z < i.Count; z++)
LuaListView.SelectItem(i[z], true);
foreach (int t in i)
{
LuaListView.SelectItem(t, true);
}
DisplayLuaList();
}
@ -507,11 +494,10 @@ namespace BizHawk.MultiClient
private void MoveDown()
{
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
LuaFile temp = new LuaFile(false);
if (indexes.Count == 0) return;
foreach (int index in indexes)
{
temp = luaList[index];
LuaFile temp = luaList[index];
if (index < luaList.Count - 1)
{
@ -531,8 +517,10 @@ namespace BizHawk.MultiClient
i.Add(indexes[z] + 1);
LuaListView.SelectedIndices.Clear();
for (int z = 0; z < i.Count; z++)
LuaListView.SelectItem(i[z], true);
foreach (int t in i)
{
LuaListView.SelectItem(t, true);
}
DisplayLuaList();
}
@ -550,9 +538,7 @@ namespace BizHawk.MultiClient
if (Global.Config.RecentLua.IsEmpty)
{
var none = new ToolStripMenuItem();
none.Enabled = false;
none.Text = "None";
var none = new ToolStripMenuItem {Enabled = false, Text = "None"};
recentToolStripMenuItem.DropDownItems.Add(none);
}
else
@ -560,8 +546,7 @@ namespace BizHawk.MultiClient
for (int x = 0; x < Global.Config.RecentLua.Count; x++)
{
string path = Global.Config.RecentLua.GetRecentFileByPosition(x);
var item = new ToolStripMenuItem();
item.Text = path;
var item = new ToolStripMenuItem {Text = path};
item.Click += (o, ev) => LoadLuaFromRecent(path);
recentToolStripMenuItem.DropDownItems.Add(item);
}
@ -569,8 +554,7 @@ namespace BizHawk.MultiClient
recentToolStripMenuItem.DropDownItems.Add("-");
var clearitem = new ToolStripMenuItem();
clearitem.Text = "&Clear";
var clearitem = new ToolStripMenuItem {Text = "&Clear"};
clearitem.Click += (o, ev) => Global.Config.RecentLua.Clear();
recentToolStripMenuItem.DropDownItems.Add(clearitem);
}
@ -582,16 +566,7 @@ namespace BizHawk.MultiClient
private bool LuaAlreadyInSession(string path)
{
bool Validated = false;
for (int i = 0; i < luaList.Count; i++)
{
if (path == luaList[i].Path)
{
Validated = true;
break;
}
}
return Validated;
return luaList.Any(t => path == t.Path);
}
private void LuaConsole_DragDrop(object sender, DragEventArgs e)
@ -626,7 +601,7 @@ namespace BizHawk.MultiClient
private void LuaConsole_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
}
private void LuaListView_KeyDown(object sender, KeyEventArgs e)
@ -770,30 +745,32 @@ namespace BizHawk.MultiClient
using (StreamReader sr = file.OpenText())
{
bool enabled = false;
string s = "";
string temp = "";
LuaFile l;
string s;
while ((s = sr.ReadLine()) != null)
{
//.luases
if (s.Length < 3) continue;
LuaFile l;
if (s.Substring(0, 3) == "---")
{
l = new LuaFile(true);
l.IsSeparator = true;
l = new LuaFile(true) {IsSeparator = true};
}
else
{
temp = s.Substring(0, 1); //Get enabled flag
string temp = s.Substring(0, 1);
bool enabled;
try
{
if (int.Parse(temp) == 0)
{
enabled = false;
}
else
{
enabled = true;
}
}
catch
{
@ -846,10 +823,8 @@ namespace BizHawk.MultiClient
{
LuaImp.gui_drawNewEmu();
}
for (int i = 0; i < luaList.Count; i++)
foreach (var lf in luaList)
{
var lf = luaList[i];
//save old current directory before this lua thread clobbers it for the .net thread
string oldcd = Environment.CurrentDirectory;
@ -858,11 +833,7 @@ namespace BizHawk.MultiClient
//LuaImp.gui_clearGraphics();
if (lf.Enabled && lf.Thread != null && !(lf.Paused))
{
bool prohibit = false;
if (lf.FrameWaiting && !includeFrameWaiters)
{
prohibit = true;
}
bool prohibit = lf.FrameWaiting && !includeFrameWaiters;
if (!prohibit)
{
//restore this lua thread's preferred current directory
@ -892,8 +863,7 @@ namespace BizHawk.MultiClient
//restore the current directory
Environment.CurrentDirectory = oldcd;
} //loop across luaList
}
}
//LuaImp.gui_drawFinishEmu();
}
@ -922,10 +892,12 @@ namespace BizHawk.MultiClient
public bool WaitOne(int timeout)
{
if (!this.IsHandleCreated || this.IsDisposed)
if (!IsHandleCreated || IsDisposed)
{
return true;
}
return this.LuaImp.LuaWait.WaitOne(timeout);
return LuaImp.LuaWait.WaitOne(timeout);
}
private void openToolStripButton_Click(object sender, EventArgs e)
@ -991,23 +963,25 @@ namespace BizHawk.MultiClient
}
}
private bool SaveSession(string path)
private void SaveSession(string path)
{
var file = new FileInfo(path);
using (StreamWriter sw = new StreamWriter(path))
{
string str = "";
for (int i = 0; i < luaList.Count; i++)
foreach (LuaFile t in luaList)
{
if (!luaList[i].IsSeparator)
if (!t.IsSeparator)
{
if (luaList[i].Enabled)
if (t.Enabled)
{
str += "1 ";
}
else
{
str += "0 ";
}
str += luaList[i].Path + "\n";
str += t.Path + "\n";
}
else
{
@ -1018,7 +992,6 @@ namespace BizHawk.MultiClient
}
Changes(false);
return true;
}
private void fileToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
@ -1041,9 +1014,7 @@ namespace BizHawk.MultiClient
if (Global.Config.RecentLuaSession.IsEmpty)
{
var none = new ToolStripMenuItem();
none.Enabled = false;
none.Text = "None";
var none = new ToolStripMenuItem {Enabled = false, Text = "None"};
recentSessionsToolStripMenuItem.DropDownItems.Add(none);
}
else
@ -1051,8 +1022,7 @@ namespace BizHawk.MultiClient
for (int x = 0; x < Global.Config.RecentLuaSession.Count; x++)
{
string path = Global.Config.RecentLuaSession.GetRecentFileByPosition(x);
var item = new ToolStripMenuItem();
item.Text = path;
var item = new ToolStripMenuItem {Text = path};
item.Click += (o, ev) => LoadSessionFromRecent(path);
recentSessionsToolStripMenuItem.DropDownItems.Add(item);
}
@ -1060,8 +1030,7 @@ namespace BizHawk.MultiClient
recentSessionsToolStripMenuItem.DropDownItems.Add("-");
var clearitem = new ToolStripMenuItem();
clearitem.Text = "&Clear";
var clearitem = new ToolStripMenuItem {Text = "&Clear"};
clearitem.Click += (o, ev) => Global.Config.RecentLuaSession.Clear();
recentSessionsToolStripMenuItem.DropDownItems.Add(clearitem);
}
@ -1132,10 +1101,12 @@ namespace BizHawk.MultiClient
private void scriptToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
bool luaRunning = false;
for (int i = 0; i < luaList.Count; i++)
foreach (LuaFile t in luaList)
{
if (luaList[i].Enabled)
if (t.Enabled)
{
luaRunning = true;
}
}
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
@ -1184,9 +1155,9 @@ namespace BizHawk.MultiClient
{
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
bool luaRunning = false;
for (int i = 0; i < luaList.Count; i++)
foreach (LuaFile t in luaList)
{
if (luaList[i].Enabled)
if (t.Enabled)
luaRunning = true;
}
@ -1238,11 +1209,6 @@ namespace BizHawk.MultiClient
Global.Config.AutoLoadLuaSession ^= true;
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
TogglePause();
}
private void TogglePause()
{
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
@ -1307,8 +1273,7 @@ namespace BizHawk.MultiClient
private void OpenLuaWriter(string path)
{
LuaWriter writer = new LuaWriter();
writer.CurrentFile = path;
LuaWriter writer = new LuaWriter {CurrentFile = path};
writer.Show();
}

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -39,16 +38,7 @@ namespace BizHawk.MultiClient.tools
public List<string> GetFunctionsByLibrary(string library)
{
List<string> functions = new List<string>();
for (int i = 0; i < FunctionList.Count; i++)
{
if (FunctionList[i].library == library)
{
functions.Add(FunctionList[i].name);
}
}
return functions;
return (from t in FunctionList where t.library == library select t.name).ToList();
}
public class LibraryFunction
@ -94,9 +84,7 @@ namespace BizHawk.MultiClient.tools
{
get
{
string r = "";
r = return_type.Replace("System.", "").Replace("LuaInterface.", "").ToLower().Trim();
return r;
return return_type.Replace("System.", "").Replace("LuaInterface.", "").ToLower().Trim();
}
}
}

View File

@ -1,8 +1,4 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace BizHawk.MultiClient
{
@ -39,7 +35,8 @@ namespace BizHawk.MultiClient
IsSeparator = false;
//the current directory for the lua task will start off wherever the lua file is located
CurrentDirectory = new FileInfo(path).Directory.FullName;
var directory_info = new FileInfo(path).Directory;
if (directory_info != null) CurrentDirectory = directory_info.FullName;
}
public LuaFile(bool isSeparator)

View File

@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.MultiClient.tools;
@ -12,7 +7,8 @@ namespace BizHawk.MultiClient
{
public partial class LuaFunctionList : Form
{
Sorting ColumnSort = new Sorting();
private readonly Sorting ColumnSort = new Sorting();
public LuaFunctionList()
{
InitializeComponent();
@ -28,8 +24,7 @@ namespace BizHawk.MultiClient
FunctionView.Items.Clear();
foreach (LuaDocumentation.LibraryFunction l in Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList)
{
ListViewItem item = new ListViewItem();
item.Text = l.ReturnType;
ListViewItem item = new ListViewItem {Text = l.ReturnType};
item.SubItems.Add(l.library + ".");
item.SubItems.Add(l.name);
item.SubItems.Add(l.ParameterList);
@ -81,7 +76,7 @@ namespace BizHawk.MultiClient
private void OK_Click(object sender, EventArgs e)
{
this.Close();
Close();
}
private void FunctionView_ColumnClick(object sender, ColumnClickEventArgs e)
@ -91,7 +86,7 @@ namespace BizHawk.MultiClient
public class Sorting
{
private bool desc = false;
private bool desc;
private int column = 1;
public int Column

View File

@ -1,32 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using Font = SlimDX.Direct3D9.Font;
using System.Drawing;
using SlimDX;
using SlimDX.Direct3D9;
namespace BizHawk.MultiClient.tools
{
class LuaText
{
public int x;
public int y;
// public Font font;
public Color color;
public Color outline;
public String message;
//private Device device;
public int X;
public int Y;
public Color Color;
public Color Outline;
public String Message;
public LuaText()
{
x = 0;
y = 0;
// font = new Font(device, 16, 0, FontWeight.Bold, 1, false, CharacterSet.Default, Precision.Default, FontQuality.Default, PitchAndFamily.Default | PitchAndFamily.DontCare, "Arial");
color = Color.White;
outline = Color.Black;
message = "";
X = 0;
Y = 0;
Color = Color.White;
Outline = Color.Black;
Message = "";
}
}
}

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms;
namespace BizHawk.MultiClient.tools
{

View File

@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LuaInterface;

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
@ -31,21 +29,20 @@ namespace BizHawk.MultiClient
//listview object with lua functions, double click inserts them into the script
public string CurrentFile = "";
bool changes = false;
bool redo = false;
bool hasChanged = false;
bool ProcessingText;
public Regex keyWords = new Regex("and|break|do|else|if|end|false|for|function|in|local|nil|not|or|repeat|return|then|true|until|while|elseif");
char[] Symbols = { '+', '-', '*', '/', '%', '^', '#', '=', '<', '>', '(', ')', '{', '}', '[', ']', ';', ':', ',', '.' };
public Regex libraryWords;
List<int[]> pos = new List<int[]>();
private bool changes;
private bool redo;
private bool hasChanged;
private bool ProcessingText;
private readonly char[] Symbols = { '+', '-', '*', '/', '%', '^', '#', '=', '<', '>', '(', ')', '{', '}', '[', ']', ';', ':', ',', '.' };
private List<int[]> pos = new List<int[]>();
public LuaWriter()
{
InitializeComponent();
LuaText.MouseWheel += new MouseEventHandler(LuaText_MouseWheel);
LuaText.MouseWheel += LuaText_MouseWheel;
}
void LuaText_MouseWheel(object sender, MouseEventArgs e)
@ -54,9 +51,13 @@ namespace BizHawk.MultiClient
{
Double Zoom;
if ((LuaText.ZoomFactor == 0.1F && e.Delta < 0) || (LuaText.ZoomFactor == 5.0F && e.Delta > 0))
Zoom = (LuaText.ZoomFactor * 100);
{
Zoom = (LuaText.ZoomFactor*100);
}
else
Zoom = (LuaText.ZoomFactor * 100) + e.Delta / 12;
{
Zoom = (LuaText.ZoomFactor*100) + e.Delta/12;
}
ZoomLabel.Text = string.Format("Zoom: {0:0}%", Zoom);
}
@ -127,15 +128,15 @@ namespace BizHawk.MultiClient
private void AddCommentsAndStrings()
{
string temp = LuaText.Text;
int comment, longcomment, quote, apos, longstring, position = 0;
int position = 0;
while (position <= temp.Length)
{
comment = temp.IndexOf("--", position);
longcomment = temp.IndexOf("--[[", position);
quote = temp.IndexOf('"', position);
apos = temp.IndexOf('\'', position);
longstring = temp.IndexOf("[", position);
int comment = temp.IndexOf("--", position, StringComparison.Ordinal);
int longcomment = temp.IndexOf("--[[", position);
int quote = temp.IndexOf('"', position);
int apos = temp.IndexOf('\'', position);
int longstring = temp.IndexOf("[", position);
int secondBracket = temp.IndexOf('[', longstring + 1);
if (secondBracket >= 0)
@ -199,41 +200,29 @@ namespace BizHawk.MultiClient
private string GetLongStringClosingBracket(string openingBracket)
{
string closingBrackets = "]";
int level = 0;
foreach (char c in openingBracket)
if (c == '=')
level++;
int level = openingBracket.Count(c => c == '=');
for (int x = 0; x < level; x++)
{
closingBrackets += '=';
}
return closingBrackets + ']';
}
private bool IsLongString(string longstring)
private static bool IsLongString(string longstring)
{
bool Validated = true;
foreach (char c in longstring)
if (c != '[' && c != '=')
{
Validated = false;
break;
}
return Validated;
return longstring.All(c => c == '[' || c == '=');
}
private void AddSymbols()
{
string temp = LuaText.Text;
int selection;
foreach (char mark in Symbols)
{
int currPos = 0;
selection = temp.IndexOf(mark, currPos);
int selection = temp.IndexOf(mark, currPos);
while (selection >= 0)
{
@ -251,14 +240,18 @@ namespace BizHawk.MultiClient
private int AddString(int startPos, char mark)
{
int ending, endLine;
int endLine;
if (LuaText.GetLineFromCharIndex(startPos) + 1 == LuaText.Lines.Count())
{
endLine = LuaText.Text.Length - 1;
}
else
{
endLine = LuaText.GetFirstCharIndexFromLine(LuaText.GetLineFromCharIndex(startPos) + 1) - 1;
}
ending = 0;
int ending;
if (startPos != LuaText.Text.Length - 1)
{
@ -300,12 +293,16 @@ namespace BizHawk.MultiClient
for (int x = wholestring.Length - 2; x > -1; x--)
{
if (wholestring[x] == '\\')
{
ammount++;
}
else
{
break;
}
}
return !(ammount % 2 == 0);
return ammount % 2 != 0;
}
private int AddComment(int startPos)
@ -324,13 +321,17 @@ namespace BizHawk.MultiClient
private int AddMultiLineComment(int startPos)
{
int selection, endComment;
int endComment;
selection = LuaText.Text.IndexOf("]]");
int selection = LuaText.Text.IndexOf("]]", StringComparison.Ordinal);
if (selection > 0)
{
endComment = selection - startPos + 2;
}
else
{
endComment = LuaText.Text.Length;
}
AddPosition(startPos, endComment, Global.Config.LuaCommentColor, Global.Config.LuaCommentBold, 1);
@ -363,19 +364,7 @@ namespace BizHawk.MultiClient
private bool IsThisPartOfStringOrComment(int startPos)
{
bool Validated = false;
foreach (int[] position in pos)
{
if (position[4] == 1)
if (position[0] <= startPos && position[0] + position[1] > startPos)
{
Validated = true;
break;
}
}
return Validated;
return pos.Where(position => position[4] == 1).Any(position => position[0] <= startPos && position[0] + position[1] > startPos);
}
private void AddPosition(int start, int lenght, int color, bool bold, int iscommentorstring)
@ -395,7 +384,7 @@ namespace BizHawk.MultiClient
IndexToAdd = x + 1;
}
pos.Insert(IndexToAdd, new int[] { start, lenght, color, IsBold, iscommentorstring });
pos.Insert(IndexToAdd, new[] { start, lenght, color, IsBold, iscommentorstring });
}
private void ColorText()
@ -467,7 +456,7 @@ namespace BizHawk.MultiClient
{
//LuaTextFont;
ProcessingText = true;
LuaText.SelectionTabs = new int[] { 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 480, 500, 520, 540, 560, 580, 600 }; //adelikat: What a goofy way to have to do this
LuaText.SelectionTabs = new[] { 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 480, 500, 520, 540, 560, 580, 600 }; //adelikat: What a goofy way to have to do this
LoadFont();
LuaText.BackColor = Color.FromArgb(Global.Config.LuaWriterBackColor);
LuaText.ZoomFactor = Global.Config.LuaWriterZoom;
@ -513,7 +502,7 @@ namespace BizHawk.MultiClient
private void LuaWriter_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
}
private void LuaWriter_DragDrop(object sender, DragEventArgs e)
@ -767,7 +756,7 @@ namespace BizHawk.MultiClient
int lastSpace = LuaText.Text.Substring(0, last).LastIndexOf(' ');
int lastTab = LuaText.Text.Substring(0, last).LastIndexOf('\t');
int lastLine = LuaText.Text.Substring(0, last).LastIndexOf('\n');
int start = 0;
int start;
if (lastSpace > lastLine || lastTab > lastLine)
{
if (lastSpace > lastTab)
@ -839,7 +828,7 @@ namespace BizHawk.MultiClient
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
//TODO: check for changes and ask save
this.Close();
Close();
}
private void LuaWriter_FormClosing(object sender, FormClosingEventArgs e)

View File

@ -1,15 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Forms;
using System.Drawing;
namespace BizHawk.MultiClient
@ -24,11 +13,6 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground(pevent);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
@ -36,15 +20,15 @@ namespace BizHawk.MultiClient
#region win32interop
protected override void WndProc(ref System.Windows.Forms.Message m)
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == 0x000F && !InhibitPaint) //WM_PAINT
{
// raise the paint event
using (Graphics graphic = base.CreateGraphics())
using (Graphics graphic = CreateGraphics())
OnPaint(new PaintEventArgs(graphic,
base.ClientRectangle));
ClientRectangle));
}
}

View File

@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.MultiClient.tools
@ -136,8 +131,8 @@ namespace BizHawk.MultiClient.tools
private void OK_Click(object sender, EventArgs e)
{
SaveData(); //Save the chosen settings
this.DialogResult = DialogResult.OK;
this.Close();
DialogResult = DialogResult.OK;
Close();
}
private void SaveData()

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace BizHawk.MultiClient
{
@ -13,7 +12,7 @@ namespace BizHawk.MultiClient
public MemoryDomain domain;
}
private static List<MemoryPulseEntry> entries = new List<MemoryPulseEntry>();
private static readonly List<MemoryPulseEntry> entries = new List<MemoryPulseEntry>();
public static void Pulse()
{

View File

@ -1,8 +1,6 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
@ -18,50 +16,47 @@ namespace BizHawk.MultiClient
//different back color for frozen addresses
public VScrollBar vScrollBar1;
//public Label info;
string info = "";
MemoryDomain Domain = new MemoryDomain("NULL", 1024, Endian.Little, addr => { return 0; }, (a, v) => { v = 0; });
Font font = new Font("Courier New", 8);
public Brush highlightBrush = Brushes.LightBlue;
int RowsVisible = 0;
int DataSize = 1;
public bool BigEndian = false;
string Header = "";
int NumDigits = 4;
char[] nibbles = { 'G', 'G', 'G', 'G' }; //G = off 0-9 & A-F are acceptable values
int addressHighlighted = -1;
int addressOver = -1;
int addrOffset = 0; //If addresses are > 4 digits, this offset is how much the columns are moved to the right
int maxRow = 0;
const int rowX = 1;
const int rowY = 4;
const int rowYoffset = 20;
public bool BlazingFast = false;
private string info = "";
private MemoryDomain Domain = new MemoryDomain("NULL", 1024, Endian.Little, addr => 0, (a, v) => { v = 0; });
private readonly Font font = new Font("Courier New", 8);
private int _rows_visible;
private int _data_size = 1;
private string _header = "";
private int _num_digits = 4;
private readonly char[] nibbles = { 'G', 'G', 'G', 'G' }; //G = off 0-9 & A-F are acceptable values
private int addressHighlighted = -1;
private int addressOver = -1;
private int addrOffset; //If addresses are > 4 digits, this offset is how much the columns are moved to the right
private int maxRow;
private const int ROWX = 1;
private const int ROWY = 4;
public MemoryViewer()
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MemoryViewer_MouseMove);
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.MemoryViewer_MouseClick);
this.vScrollBar1 = new VScrollBar();
Point n = new Point(this.Size);
this.vScrollBar1.Location = new System.Drawing.Point(n.X - 16, n.Y - this.Height + 7);
this.vScrollBar1.Height = this.Height - 8;
this.vScrollBar1.Width = 16;
this.vScrollBar1.Visible = true;
this.vScrollBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.vScrollBar1.LargeChange = 16;
this.vScrollBar1.Name = "vScrollBar1";
this.vScrollBar1.TabIndex = 0;
this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScrollBar1_Scroll);
this.Controls.Add(this.vScrollBar1);
BorderStyle = BorderStyle.Fixed3D;
MouseMove += MemoryViewer_MouseMove;
MouseClick += MemoryViewer_MouseClick;
vScrollBar1 = new VScrollBar();
Point n = new Point(Size);
vScrollBar1.Location = new Point(n.X - 16, n.Y - Height + 7);
vScrollBar1.Height = Height - 8;
vScrollBar1.Width = 16;
vScrollBar1.Visible = true;
vScrollBar1.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom)
| AnchorStyles.Right;
vScrollBar1.LargeChange = 16;
vScrollBar1.Name = "vScrollBar1";
vScrollBar1.TabIndex = 0;
vScrollBar1.Scroll += vScrollBar1_Scroll;
Controls.Add(vScrollBar1);
SetHeader();
}
@ -91,17 +86,17 @@ namespace BizHawk.MultiClient
else if (keyData == Keys.Tab)
{
addressHighlighted += 8;
this.Refresh();
Refresh();
}
else if (keyData == Keys.PageDown)
{
GoToAddress(addressHighlighted + (RowsVisible * 16));
GoToAddress(addressHighlighted + (_rows_visible * 16));
}
else if (keyData == Keys.PageUp)
{
GoToAddress(addressHighlighted - (RowsVisible * 16));
GoToAddress(addressHighlighted - (_rows_visible * 16));
}
else if (keyData == Keys.Home)
@ -146,34 +141,34 @@ namespace BizHawk.MultiClient
Domain.PokeByte(addressHighlighted, (byte)x);
ClearNibbles();
SetHighlighted(addressHighlighted + 1);
this.Refresh();
Refresh();
}
base.OnKeyUp(e);
}
public void SetHighlighted(int addr)
public void SetHighlighted(int address)
{
if (addr < 0)
addr = 0;
if (addr >= Domain.Size)
addr = Domain.Size - 1;
if (address < 0)
address = 0;
if (address >= Domain.Size)
address = Domain.Size - 1;
if (!IsVisible(addr))
if (!IsVisible(address))
{
int v = (addr / 16) - RowsVisible + 1;
int v = (address / 16) - _rows_visible + 1;
if (v < 0)
v = 0;
vScrollBar1.Value = v;
}
addressHighlighted = addr;
addressOver = addr;
addressHighlighted = address;
addressOver = address;
info = String.Format("{0:X4}", addressOver);
Refresh();
}
int row = 0;
int addr = 0;
int row;
int addr;
protected override void OnPaint(PaintEventArgs e)
{
@ -183,7 +178,7 @@ namespace BizHawk.MultiClient
addr = 0;
StringBuilder rowStr = new StringBuilder("");
addrOffset = (NumDigits % 4) * 9;
addrOffset = (_num_digits % 4) * 9;
if (addressHighlighted >= 0 && IsVisible(addressHighlighted))
{
@ -195,15 +190,15 @@ namespace BizHawk.MultiClient
}
rowStr.Append(Domain.Name + " " + info + '\n');
rowStr.Append(Header + '\n');
rowStr.Append(_header + '\n');
for (int i = 0; i < RowsVisible; i++)
for (int i = 0; i < _rows_visible; i++)
{
row = i + vScrollBar1.Value;
if (row * 16 >= Domain.Size)
break;
rowStr.AppendFormat("{0:X" + NumDigits + "} ", row * 16);
switch (DataSize)
rowStr.AppendFormat("{0:X" + _num_digits + "} ", row * 16);
switch (_data_size)
{
default:
case 1:
@ -225,7 +220,7 @@ namespace BizHawk.MultiClient
for (int j = 0; j < 16; j += 2)
{
if (addr + j < Domain.Size)
rowStr.AppendFormat("{0:X4} ", MakeValue(addr + j, DataSize, BigEndian));
rowStr.AppendFormat("{0:X4} ", MakeValue(addr + j, _data_size, BigEndian));
}
rowStr.AppendLine();
rowStr.Append(" | ");
@ -239,7 +234,7 @@ namespace BizHawk.MultiClient
for (int j = 0; j < 16; j += 4)
{
if (addr < Domain.Size)
rowStr.AppendFormat("{0:X8} ", MakeValue(addr + j, DataSize, BigEndian));
rowStr.AppendFormat("{0:X8} ", MakeValue(addr + j, _data_size, BigEndian));
}
rowStr.AppendLine();
rowStr.Append(" | ");
@ -252,7 +247,7 @@ namespace BizHawk.MultiClient
}
}
e.Graphics.DrawString(rowStr.ToString(), font, Brushes.Black, new Point(rowX, rowY));
e.Graphics.DrawString(rowStr.ToString(), font, Brushes.Black, new Point(ROWX, ROWY));
}
}
@ -266,7 +261,7 @@ namespace BizHawk.MultiClient
}
}
private int MakeValue(int addr, int size, bool Bigendian)
private int MakeValue(int address, int size, bool Bigendian)
{
unchecked
{
@ -276,14 +271,14 @@ namespace BizHawk.MultiClient
switch (size)
{
case 1:
x = Domain.PeekByte(addr);
x = Domain.PeekByte(address);
break;
case 2:
x = MakeWord(addr, Bigendian);
x = MakeWord(address, Bigendian);
break;
case 4:
x = (MakeWord(addr, Bigendian) * 65536) +
MakeWord(addr + 2, Bigendian);
x = (MakeWord(address, Bigendian) * 65536) +
MakeWord(address + 2, Bigendian);
break;
}
return x;
@ -293,14 +288,18 @@ namespace BizHawk.MultiClient
}
}
private int MakeWord(int addr, bool endian)
private int MakeWord(int address, bool endian)
{
unchecked
{
if (endian)
return Domain.PeekByte(addr) + (Domain.PeekByte(addr + 1) * 255);
{
return Domain.PeekByte(address) + (Domain.PeekByte(address + 1)*255);
}
else
return (Domain.PeekByte(addr) * 255) + Domain.PeekByte(addr + 1);
{
return (Domain.PeekByte(address)*255) + Domain.PeekByte(address + 1);
}
}
}
@ -313,9 +312,9 @@ namespace BizHawk.MultiClient
public void SetUpScrollBar()
{
RowsVisible = ((this.Height - 8) / 13) - 1;
_rows_visible = ((Height - 8) / 13) - 1;
int totalRows = Domain.Size / 16;
int MaxRows = (totalRows - RowsVisible) + 16;
int MaxRows = (totalRows - _rows_visible) + 16;
if (MaxRows > 0)
{
@ -345,38 +344,38 @@ namespace BizHawk.MultiClient
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
this.SetUpScrollBar();
this.Refresh();
SetUpScrollBar();
Refresh();
}
public void SetDataSize(int size)
{
if (size == 1 || size == 2 || size == 4)
DataSize = size;
_data_size = size;
SetHeader();
}
private void SetHeader()
{
switch (DataSize)
switch (_data_size)
{
case 1:
Header = " 0 1 2 3 4 5 6 7 8 9 A B C D E F";
_header = " 0 1 2 3 4 5 6 7 8 9 A B C D E F";
break;
case 2:
Header = " 0 2 4 6 8 A C E";
_header = " 0 2 4 6 8 A C E";
break;
case 4:
Header = " 0 4 8 C";
_header = " 0 4 8 C";
break;
}
NumDigits = GetNumDigits(Domain.Size);
_num_digits = GetNumDigits(Domain.Size);
}
public int GetDataSize()
{
return DataSize;
return _data_size;
}
private int GetNumDigits(Int32 i)
@ -392,15 +391,15 @@ namespace BizHawk.MultiClient
private void SetAddressOver(int x, int y)
{
//Scroll value determines the first row
int row = vScrollBar1.Value;
row += (y - 36) / (font.Height - 1);
int i = vScrollBar1.Value;
i += (y - 36) / (font.Height - 1);
int column = (x - (49 + addrOffset)) / 20;
//TODO: 2 & 4 byte views
if (row >= 0 && row <= maxRow && column >= 0 && column < 16)
if (i >= 0 && i <= maxRow && column >= 0 && column < 16)
{
addressOver = row * 16 + column;
addressOver = i * 16 + column;
info = String.Format("{0:X4}", addressOver);
}
else
@ -424,8 +423,8 @@ namespace BizHawk.MultiClient
else
addressHighlighted = -1;
ClearNibbles();
this.Focus();
this.Refresh();
Focus();
Refresh();
}
private void MemoryViewer_MouseClick(object sender, MouseEventArgs e)
@ -434,10 +433,12 @@ namespace BizHawk.MultiClient
if (addressOver == addressHighlighted && addressOver >= 0)
{
addressHighlighted = -1;
this.Refresh();
Refresh();
}
else
{
HighlightPointed();
}
}
public int GetPointedAddress()
@ -451,21 +452,29 @@ namespace BizHawk.MultiClient
public int GetHighlightedAddress()
{
if (addressHighlighted >= 0)
{
return addressHighlighted;
}
else
{
return -1; //Negative = no address highlighted
}
}
public bool IsVisible(int addr)
public bool IsVisible(int address)
{
unchecked
{
int row = addr >> 4;
int i = address >> 4;
if (row >= vScrollBar1.Value && row < (RowsVisible + vScrollBar1.Value))
if (i >= vScrollBar1.Value && i < (_rows_visible + vScrollBar1.Value))
{
return true;
}
else
{
return false;
}
}
}
@ -506,8 +515,7 @@ namespace BizHawk.MultiClient
public void GoToSpecifiedAddress()
{
InputPrompt i = new InputPrompt();
i.Text = "Go to Address";
InputPrompt i = new InputPrompt {Text = "Go to Address"};
i.SetMessage("Enter a hexadecimal value");
Global.Sound.StopSound();
i.ShowDialog();
@ -522,13 +530,13 @@ namespace BizHawk.MultiClient
}
}
protected override void WndProc(ref System.Windows.Forms.Message m)
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x0201: //WM_LBUTTONDOWN
{
this.Focus();
Focus();
return;
}
//case 0x0202://WM_LBUTTONUP

View File

@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
@ -12,9 +7,9 @@ namespace BizHawk.MultiClient
{
public partial class RamPoke : Form
{
public Watch watch = new Watch();
public MemoryDomain domain = Global.Emulator.MainMemory;
public Point location = new Point();
public Watch Watch = new Watch();
public MemoryDomain Domain = Global.Emulator.MainMemory;
public Point NewLocation = new Point();
public RamPoke()
{
@ -24,17 +19,17 @@ namespace BizHawk.MultiClient
public void SetWatchObject(Watch w)
{
PopulateMemoryDomainComboBox();
watch = new Watch(w);
domain = w.Domain;
Watch = new Watch(w);
Domain = w.Domain;
}
private void RamPoke_Load(object sender, EventArgs e)
{
if (watch.Address == 0)
if (Watch.Address == 0)
PopulateMemoryDomainComboBox();
SetTypeRadio(watch.Type);
SetSignedRadio(watch.Signed);
if (watch.Signed == Watch.DISPTYPE.HEX)
SetTypeRadio(Watch.Type);
SetSignedRadio(Watch.Signed);
if (Watch.Signed == Watch.DISPTYPE.HEX)
{
ValueHexLabel.Text = "0x";
}
@ -43,7 +38,7 @@ namespace BizHawk.MultiClient
ValueHexLabel.Text = "";
}
if (watch.BigEndian == true)
if (Watch.BigEndian)
{
BigEndianRadio.Checked = true;
}
@ -55,11 +50,13 @@ namespace BizHawk.MultiClient
SetValueBox();
SetAddressBox();
AddressBox.MaxLength = GetNumDigits(domain.Size);
AddressBox.MaxLength = GetNumDigits(Domain.Size);
ValueBox.MaxLength = GetValueNumDigits();
if (location.X > 0 && location.Y > 0)
this.Location = location;
if (NewLocation.X > 0 && NewLocation.Y > 0)
{
Location = NewLocation;
}
UpdateTitleText();
SetDomainSelection();
@ -69,7 +66,7 @@ namespace BizHawk.MultiClient
private void SetValueBoxProperties()
{
switch (watch.Signed)
switch (Watch.Signed)
{
case Watch.DISPTYPE.SIGNED:
SignedRadio.Checked = true;
@ -93,7 +90,7 @@ namespace BizHawk.MultiClient
{
ValueHexLabel.Text = "0x";
ValueBox.MaxLength = GetValueNumDigits();
watch.Signed = Watch.DISPTYPE.HEX;
Watch.Signed = Watch.DISPTYPE.HEX;
FormatValue();
}
@ -101,7 +98,7 @@ namespace BizHawk.MultiClient
{
ValueHexLabel.Text = "";
ValueBox.MaxLength = GetValueNumDigits();
watch.Signed = Watch.DISPTYPE.UNSIGNED;
Watch.Signed = Watch.DISPTYPE.UNSIGNED;
FormatValue();
}
@ -109,7 +106,7 @@ namespace BizHawk.MultiClient
{
ValueHexLabel.Text = "";
ValueBox.MaxLength = GetValueNumDigits();
watch.Signed = Watch.DISPTYPE.SIGNED;
Watch.Signed = Watch.DISPTYPE.SIGNED;
FormatValue();
}
@ -117,20 +114,20 @@ namespace BizHawk.MultiClient
{
if (HexRadio.Checked)
ValueBox.Text = String.Format("{0:X" +
GetValueNumDigits() + "}", watch.Value);
GetValueNumDigits() + "}", Watch.Value);
else
ValueBox.Text = watch.Value.ToString();
ValueBox.Text = Watch.Value.ToString();
}
private void SetAddressBox()
{
AddressBox.Text = String.Format("{0:X" +
GetNumDigits(watch.Address) + "}", watch.Address);
GetNumDigits(Watch.Address) + "}", Watch.Address);
}
private void UpdateTitleText()
{
Text = "Ram Poke - " + domain.ToString();
Text = "Ram Poke - " + Domain;
}
private void SetTypeRadio(Watch.TYPE a)
@ -146,8 +143,6 @@ namespace BizHawk.MultiClient
case Watch.TYPE.DWORD:
Byte4Radio.Checked = true;
break;
default:
break;
}
}
@ -164,14 +159,12 @@ namespace BizHawk.MultiClient
case Watch.DISPTYPE.HEX:
HexRadio.Checked = true;
break;
default:
break;
}
}
private void Cancel_Click(object sender, EventArgs e)
{
this.Close();
Close();
}
private void OK_Click(object sender, EventArgs e)
@ -179,7 +172,7 @@ namespace BizHawk.MultiClient
//Put user settings in the watch file
if (InputValidate.IsValidHexNumber(AddressBox.Text))
watch.Address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
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);
@ -190,37 +183,37 @@ namespace BizHawk.MultiClient
if (SignedRadio.Checked)
{
watch.Signed = Watch.DISPTYPE.SIGNED;
Watch.Signed = Watch.DISPTYPE.SIGNED;
}
else if (UnsignedRadio.Checked)
{
watch.Signed = Watch.DISPTYPE.UNSIGNED;
Watch.Signed = Watch.DISPTYPE.UNSIGNED;
}
else if (HexRadio.Checked)
{
watch.Signed = Watch.DISPTYPE.HEX;
Watch.Signed = Watch.DISPTYPE.HEX;
}
if (Byte1Radio.Checked)
{
watch.Type = Watch.TYPE.BYTE;
Watch.Type = Watch.TYPE.BYTE;
}
else if (Byte2Radio.Checked)
{
watch.Type = Watch.TYPE.WORD;
Watch.Type = Watch.TYPE.WORD;
}
else if (Byte4Radio.Checked)
{
watch.Type = Watch.TYPE.DWORD;
Watch.Type = Watch.TYPE.DWORD;
}
if (BigEndianRadio.Checked)
{
watch.BigEndian = true;
Watch.BigEndian = true;
}
else if (LittleEndianRadio.Checked)
{
watch.BigEndian = false;
Watch.BigEndian = false;
}
int? x = GetSpecificValue();
@ -233,18 +226,18 @@ namespace BizHawk.MultiClient
}
else
{
watch.TrySetValue(ValueBox.Text);
Watch.TrySetValue(ValueBox.Text);
}
watch.Domain = domain;
watch.PokeAddress();
Watch.Domain = Domain;
Watch.PokeAddress();
string value;
if (HexRadio.Checked)
value = "0x" + String.Format("{0:X" + GetValueNumDigits() + "}", watch.Value);
value = "0x" + String.Format("{0:X" + GetValueNumDigits() + "}", Watch.Value);
else
value = watch.Value.ToString();
string address = String.Format("{0:X" + GetNumDigits(domain.Size).ToString()
+ "}", watch.Address);
value = Watch.Value.ToString();
string address = String.Format("{0:X" + GetNumDigits(Domain.Size).ToString()
+ "}", Watch.Address);
OutputLabel.Text = value + " written to " + address;
@ -266,7 +259,7 @@ namespace BizHawk.MultiClient
{
ValueBox.Text = ValueBox.Text.Replace(" ", "");
switch (watch.Signed)
switch (Watch.Signed)
{
case Watch.DISPTYPE.UNSIGNED:
if (!InputValidate.IsValidUnsignedNumber(ValueBox.Text))
@ -369,7 +362,7 @@ namespace BizHawk.MultiClient
private int? GetSpecificValue()
{
if (ValueBox.Text == "" || ValueBox.Text == "-") return 0;
bool i = false;
bool i;
switch (GetDataType())
{
case Watch.DISPTYPE.UNSIGNED:
@ -440,10 +433,9 @@ namespace BizHawk.MultiClient
DomainComboBox.Items.Clear();
if (Global.Emulator.MemoryDomains.Count > 0)
{
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
foreach (MemoryDomain t in Global.Emulator.MemoryDomains)
{
string str = Global.Emulator.MemoryDomains[x].ToString();
DomainComboBox.Items.Add(str);
DomainComboBox.Items.Add(t.ToString());
}
}
SetDomainSelection();
@ -451,14 +443,14 @@ namespace BizHawk.MultiClient
private void DomainComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
domain = Global.Emulator.MemoryDomains[DomainComboBox.SelectedIndex];
Domain = Global.Emulator.MemoryDomains[DomainComboBox.SelectedIndex];
UpdateTitleText();
int x = GetNumDigits(domain.Size);
watch.Address = 0;
watch.Value = 0;
GetNumDigits(Domain.Size);
Watch.Address = 0;
Watch.Value = 0;
SetAddressBox();
SetValueBox();
AddressBox.MaxLength = GetNumDigits(domain.Size);
AddressBox.MaxLength = GetNumDigits(Domain.Size);
}
private void SetDomainSelection()
@ -472,16 +464,16 @@ namespace BizHawk.MultiClient
for (int x = 0; x < max; x++)
{
if (domain.ToString() == DomainComboBox.Items[x].ToString())
if (Domain.ToString() == DomainComboBox.Items[x].ToString())
DomainComboBox.SelectedIndex = x;
}
}
private void FormatValue()
{
watch.Signed = GetDataType();
watch.TrySetValue(ValueBox.Text);
ValueBox.Text = watch.ValueString;
Watch.Signed = GetDataType();
Watch.TrySetValue(ValueBox.Text);
ValueBox.Text = Watch.ValueString;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
@ -22,30 +21,23 @@ namespace BizHawk.MultiClient
//A GUI interface for setting the x,y coordinates of the ram watch display
//Allow each watch to be on or off screen, and on its own x,y
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight;
int defaultAddressWidth;
int defaultValueWidth;
int defaultPrevWidth;
int defaultChangeWidth;
int defaultDiffWidth;
int defaultDomainWidth;
int NotesWidth;
private int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
private int defaultHeight;
string systemID = "NULL";
MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
List<Watch> Watches = new List<Watch>();
string currentFile = "";
bool changes = false;
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
string addressFormatStr = "{0:X4} ";
private string systemID = "NULL";
private MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
private readonly List<Watch> Watches = new List<Watch>();
private string currentFile = "";
private bool changes = false;
private readonly List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
private string addressFormatStr = "{0:X4} ";
string sortedCol;
bool sortReverse;
public void Restart()
{
if ((!this.IsHandleCreated || this.IsDisposed) && !Global.Config.DisplayRamWatch)
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch)
{
return;
}
@ -62,12 +54,7 @@ namespace BizHawk.MultiClient
public List<Watch> GetRamWatchList()
{
List<Watch> w = new List<Watch>();
for (int x = 0; x < Watches.Count; x++)
{
w.Add(new Watch(Watches[x]));
}
return w;
return Watches.Select(t => new Watch(t)).ToList();
}
public void DisplayWatchList()
@ -77,14 +64,14 @@ namespace BizHawk.MultiClient
public void UpdateValues()
{
if ((!this.IsHandleCreated || this.IsDisposed) && !Global.Config.DisplayRamWatch)
if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch)
{
return;
}
for (int x = 0; x < Watches.Count; x++)
foreach (Watch t in Watches)
{
Watches[x].PeekAddress();
t.PeekAddress();
}
if (Global.Config.DisplayRamWatch)
@ -97,7 +84,7 @@ namespace BizHawk.MultiClient
}
}
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
WatchListView.BlazingFast = true;
WatchListView.Refresh();
@ -118,13 +105,6 @@ namespace BizHawk.MultiClient
defaultWidth = Size.Width; //Save these first so that the user can restore to its original size
defaultHeight = Size.Height;
defaultAddressWidth = WatchListView.Columns[Global.Config.RamWatchAddressIndex].Width;
defaultValueWidth = WatchListView.Columns[Global.Config.RamWatchValueIndex].Width;
defaultPrevWidth = WatchListView.Columns[Global.Config.RamWatchPrevIndex].Width;
defaultChangeWidth = WatchListView.Columns[Global.Config.RamWatchChangeIndex].Width;
defaultDiffWidth = WatchListView.Columns[Global.Config.RamWatchDiffIndex].Width;
defaultDomainWidth = WatchListView.Columns[Global.Config.RamWatchDomainIndex].Width;
NotesWidth = WatchListView.Columns[Global.Config.RamWatchNotesIndex].Width;
if (Global.Config.RamWatchSaveWindowPosition && Global.Config.RamWatchWndx >= 0 && Global.Config.RamWatchWndy >= 0)
@ -134,7 +114,7 @@ namespace BizHawk.MultiClient
if (Global.Config.RamWatchWidth >= 0 && Global.Config.RamWatchHeight >= 0)
{
Size = new System.Drawing.Size(Global.Config.RamWatchWidth, Global.Config.RamWatchHeight);
Size = new Size(Global.Config.RamWatchWidth, Global.Config.RamWatchHeight);
}
SetPrevColumn(Global.Config.RamWatchShowPrevColumn);
SetChangesColumn(Global.Config.RamWatchShowChangeColumn);
@ -182,17 +162,17 @@ namespace BizHawk.MultiClient
Global.Config.RamWatchDomainWidth = WatchListView.Columns[Global.Config.RamWatchDomainIndex].Width;
Global.Config.RamWatchNotesWidth = WatchListView.Columns[Global.Config.RamWatchNotesIndex].Width;
Global.Config.RamWatchWndx = this.Location.X;
Global.Config.RamWatchWndy = this.Location.Y;
Global.Config.RamWatchWidth = this.Right - this.Left;
Global.Config.RamWatchHeight = this.Bottom - this.Top;
Global.Config.RamWatchWndx = Location.X;
Global.Config.RamWatchWndy = Location.Y;
Global.Config.RamWatchWidth = Right - Left;
Global.Config.RamWatchHeight = Bottom - Top;
}
public RamWatch()
{
InitializeComponent();
WatchListView.QueryItemText += new QueryItemTextHandler(WatchListView_QueryItemText);
WatchListView.QueryItemBkColor += new QueryItemBkColorHandler(WatchListView_QueryItemBkColor);
WatchListView.QueryItemText += WatchListView_QueryItemText;
WatchListView.QueryItemBkColor += WatchListView_QueryItemBkColor;
WatchListView.VirtualMode = true;
Closing += (o, e) => SaveConfigSettings();
sortReverse = false;
@ -217,7 +197,7 @@ namespace BizHawk.MultiClient
{
if (Watches[index].Type == Watch.TYPE.SEPARATOR)
{
color = this.BackColor;
color = BackColor;
}
if (Global.CheatList.IsActiveCheat(Domain, Watches[index].Address))
{
@ -291,12 +271,15 @@ namespace BizHawk.MultiClient
Global.Sound.StartSound();
if (result == DialogResult.Yes)
{
if (string.Compare(currentFile, "") == 0)
if (String.CompareOrdinal(currentFile, "") == 0)
{
SaveAs();
}
else
{
SaveWatchFile(currentFile);
}
return true;
}
else if (result == DialogResult.No)
@ -331,7 +314,7 @@ namespace BizHawk.MultiClient
bool result = true;
if (changes) result = AskSave();
if (result == true || suppressAsk)
if (result || suppressAsk)
{
Watches.Clear();
DisplayWatchList();
@ -344,28 +327,21 @@ namespace BizHawk.MultiClient
}
}
private bool SaveWatchFile(string path)
private void SaveWatchFile(string path)
{
return WatchCommon.SaveWchFile(path, Domain.Name, Watches);
WatchCommon.SaveWchFile(path, Domain.Name, Watches);
}
private void UpdateWatchCount()
{
int count = 0;
foreach (Watch w in Watches)
{
if (!(w.Type == Watch.TYPE.SEPARATOR))
{
count++;
}
}
int count = Watches.Count(w => w.Type != Watch.TYPE.SEPARATOR);
WatchCountLabel.Text = count.ToString() + (count == 1 ? " watch" : " watches");
}
public bool LoadWatchFile(string path, bool append)
{
string domain = "";
string domain;
bool result = WatchCommon.LoadWatchFile(path, append, Watches, out domain);
if (result)
@ -393,24 +369,18 @@ namespace BizHawk.MultiClient
private Point GetPromptPoint()
{
Point p = new Point(WatchListView.Location.X, WatchListView.Location.Y);
Point q = new Point();
q = PointToScreen(p);
return q;
return PointToScreen(p);
}
private void AddNewWatch()
{
RamWatchNewWatch r = new RamWatchNewWatch();
r.location = GetPromptPoint();
Watch w = new Watch();
w.Domain = Domain;
RamWatchNewWatch r = new RamWatchNewWatch {location = GetPromptPoint()};
Watch w = new Watch {Domain = Domain};
r.SetWatch(w);
Global.Sound.StopSound();
r.ShowDialog();
Global.Sound.StartSound();
if (r.SelectionWasMade == true)
if (r.SelectionWasMade)
{
InitializeAddress(r.Watch);
Watches.Add(r.Watch);
@ -438,14 +408,13 @@ namespace BizHawk.MultiClient
void EditWatchObject(int pos)
{
RamWatchNewWatch r = new RamWatchNewWatch();
r.location = GetPromptPoint();
RamWatchNewWatch r = new RamWatchNewWatch {location = GetPromptPoint()};
r.SetWatch(Watches[pos], "Edit Watch");
Global.Sound.StopSound();
r.ShowDialog();
Global.Sound.StartSound();
if (r.SelectionWasMade == true)
if (r.SelectionWasMade)
{
Changes();
Watches[pos] = r.Watch;
@ -487,15 +456,14 @@ namespace BizHawk.MultiClient
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
if (indexes.Count > 0)
{
RamWatchNewWatch r = new RamWatchNewWatch();
r.location = GetPromptPoint();
RamWatchNewWatch r = new RamWatchNewWatch {location = GetPromptPoint()};
r.SetWatch(Watches[indexes[0]], "Duplicate Watch");
Global.Sound.StopSound();
r.ShowDialog();
Global.Sound.StartSound();
if (r.SelectionWasMade == true)
if (r.SelectionWasMade)
{
InitializeAddress(r.Watch);
Changes();
@ -514,11 +482,10 @@ namespace BizHawk.MultiClient
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
if (indexes[0] == 0)
return;
Watch temp = new Watch();
if (indexes.Count == 0) return;
foreach (int index in indexes)
{
temp = Watches[index];
Watch temp = Watches[index];
Watches.Remove(Watches[index]);
Watches.Insert(index - 1, temp);
@ -533,9 +500,9 @@ namespace BizHawk.MultiClient
}
WatchListView.SelectedIndices.Clear();
for (int z = 0; z < i.Count; z++)
foreach (int t in i)
{
WatchListView.SelectItem(i[z], true);
WatchListView.SelectItem(t, true);
}
DisplayWatchList();
@ -544,11 +511,10 @@ namespace BizHawk.MultiClient
void MoveDown()
{
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
Watch temp = new Watch();
if (indexes.Count == 0) return;
foreach (int index in indexes)
{
temp = Watches[index];
Watch temp = Watches[index];
if (index < Watches.Count - 1)
{
@ -565,11 +531,15 @@ namespace BizHawk.MultiClient
List<int> i = new List<int>();
for (int z = 0; z < indexes.Count; z++)
{
i.Add(indexes[z] + 1);
}
WatchListView.SelectedIndices.Clear();
for (int z = 0; z < i.Count; z++)
WatchListView.SelectItem(i[z], true);
foreach (int t in i)
{
WatchListView.SelectItem(t, true);
}
DisplayWatchList();
}
@ -579,7 +549,7 @@ namespace BizHawk.MultiClient
if (!AskSave())
return;
this.Close();
Close();
}
private void newListToolStripMenuItem_Click(object sender, EventArgs e)
@ -627,7 +597,7 @@ namespace BizHawk.MultiClient
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
if (string.Compare(currentFile, "") == 0)
if (String.CompareOrdinal(currentFile, "") == 0)
{
SaveAs();
}
@ -664,11 +634,6 @@ namespace BizHawk.MultiClient
Changes();
}
private void autoLoadToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateAutoLoadRamWatch();
}
private void newWatchToolStripMenuItem_Click(object sender, EventArgs e)
{
AddNewWatch();
@ -707,10 +672,14 @@ namespace BizHawk.MultiClient
private void filesToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
if (Global.Config.AutoLoadRamWatch == true)
if (Global.Config.AutoLoadRamWatch)
{
autoLoadToolStripMenuItem.Checked = true;
}
else
{
autoLoadToolStripMenuItem.Checked = false;
}
if (!changes)
{
@ -734,9 +703,7 @@ namespace BizHawk.MultiClient
if (Global.Config.RecentWatches.IsEmpty)
{
var none = new ToolStripMenuItem();
none.Enabled = false;
none.Text = "None";
var none = new ToolStripMenuItem {Enabled = false, Text = "None"};
recentToolStripMenuItem.DropDownItems.Add(none);
}
else
@ -744,8 +711,7 @@ namespace BizHawk.MultiClient
for (int x = 0; x < Global.Config.RecentWatches.Count; x++)
{
string path = Global.Config.RecentWatches.GetRecentFileByPosition(x);
var item = new ToolStripMenuItem();
item.Text = path;
var item = new ToolStripMenuItem {Text = path};
item.Click += (o, ev) => LoadWatchFromRecent(path);
recentToolStripMenuItem.DropDownItems.Add(item);
}
@ -753,18 +719,21 @@ namespace BizHawk.MultiClient
recentToolStripMenuItem.DropDownItems.Add("-");
var clearitem = new ToolStripMenuItem();
clearitem.Text = "&Clear";
var clearitem = new ToolStripMenuItem {Text = "&Clear"};
clearitem.Click += (o, ev) => Global.Config.RecentWatches.Clear();
recentToolStripMenuItem.DropDownItems.Add(clearitem);
var auto = new ToolStripMenuItem();
auto.Text = "&Auto-Load";
var auto = new ToolStripMenuItem {Text = "&Auto-Load"};
auto.Click += (o, ev) => UpdateAutoLoadRamWatch();
if (Global.Config.AutoLoadRamWatch == true)
if (Global.Config.AutoLoadRamWatch)
{
auto.Checked = true;
}
else
{
auto.Checked = false;
}
recentToolStripMenuItem.DropDownItems.Add(auto);
}
@ -789,7 +758,7 @@ namespace BizHawk.MultiClient
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
Size = new Size(defaultWidth, defaultHeight);
Global.Config.RamWatchAddressIndex = 0;
Global.Config.RamWatchValueIndex = 1;
@ -841,16 +810,15 @@ namespace BizHawk.MultiClient
private void InsertSeparator()
{
Changes();
Watch w = new Watch();
w.Type = Watch.TYPE.SEPARATOR;
Watch w = new Watch {Type = Watch.TYPE.SEPARATOR};
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
int x;
if (indexes.Count > 0)
{
x = indexes[0];
if (indexes[0] > 0)
{
Watches.Insert(indexes[0], w);
}
}
else
{
@ -914,7 +882,7 @@ namespace BizHawk.MultiClient
{
p.SetWatchObject(Watches[indexes[0]]);
}
p.location = GetPromptPoint();
p.NewLocation = GetPromptPoint();
p.ShowDialog();
UpdateValues();
@ -1015,14 +983,12 @@ namespace BizHawk.MultiClient
if (Global.CheatList.IsActiveCheat(Domain, Watches[indexes[0]].Address))
{
freezeToolStripMenuItem.Text = "&Unfreeze address";
freezeToolStripMenuItem.Image =
BizHawk.MultiClient.Properties.Resources.Unfreeze;
freezeToolStripMenuItem.Image = Properties.Resources.Unfreeze;
}
else
{
freezeToolStripMenuItem.Text = "&Freeze address";
freezeToolStripMenuItem.Image =
BizHawk.MultiClient.Properties.Resources.Freeze;
freezeToolStripMenuItem.Image = Properties.Resources.Freeze;
}
}
else
@ -1039,14 +1005,12 @@ namespace BizHawk.MultiClient
if (allCheats)
{
freezeToolStripMenuItem.Text = "&Unfreeze address";
freezeToolStripMenuItem.Image =
BizHawk.MultiClient.Properties.Resources.Unfreeze;
freezeToolStripMenuItem.Image = Properties.Resources.Unfreeze;
}
else
{
freezeToolStripMenuItem.Text = "&Freeze address";
freezeToolStripMenuItem.Image =
BizHawk.MultiClient.Properties.Resources.Freeze;
freezeToolStripMenuItem.Image = Properties.Resources.Freeze;
}
}
}
@ -1119,13 +1083,16 @@ namespace BizHawk.MultiClient
private void RamWatch_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
}
private void ClearChangeCounts()
{
for (int x = 0; x < Watches.Count; x++)
Watches[x].Changecount = 0;
foreach (Watch t in Watches)
{
t.Changecount = 0;
}
DisplayWatchList();
MessageLabel.Text = "Change counts cleared";
}
@ -1243,16 +1210,6 @@ namespace BizHawk.MultiClient
}
}
private int WORDGetLowerByte(int value)
{
return value / 256;
}
private int WORDGetUpperByte(int value)
{
return value >> 2;
}
private void FreezeAddress()
{
ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices;
@ -1399,8 +1356,7 @@ namespace BizHawk.MultiClient
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
{
string str = Global.Emulator.MemoryDomains[x].ToString();
var item = new ToolStripMenuItem();
item.Text = str;
var item = new ToolStripMenuItem {Text = str};
{
int z = x;
item.Click += (o, ev) => SetMemoryDomain(z);
@ -1414,17 +1370,23 @@ namespace BizHawk.MultiClient
}
}
else
{
memoryDomainsToolStripMenuItem.Enabled = false;
}
}
private void CheckDomainMenuItems()
{
for (int x = 0; x < domainMenuItems.Count; x++)
foreach (ToolStripMenuItem t in domainMenuItems)
{
if (Domain.Name == domainMenuItems[x].Text)
domainMenuItems[x].Checked = true;
if (Domain.Name == t.Text)
{
t.Checked = true;
}
else
domainMenuItems[x].Checked = false;
{
t.Checked = false;
}
}
}
@ -1437,9 +1399,9 @@ namespace BizHawk.MultiClient
{
ColumnHeader header = e.Header;
int lowIndex = 0;
int highIndex = 0;
int changeIndex = 0;
int lowIndex;
int highIndex;
int changeIndex;
if (e.NewDisplayIndex > e.OldDisplayIndex)
{
changeIndex = -1;
@ -1522,25 +1484,27 @@ namespace BizHawk.MultiClient
WatchListView.Columns.Clear();
List<KeyValuePair<int, string>> columnSettings = new List<KeyValuePair<int, string>>();
columnSettings.Add(new KeyValuePair<int,string>(Global.Config.RamWatchAddressIndex, "Address"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchValueIndex, "Value"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchPrevIndex, "Prev"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchChangeIndex, "Changes"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchDiffIndex, "Diff"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchDomainIndex, "Domain"));
columnSettings.Add(new KeyValuePair<int, string>(Global.Config.RamWatchNotesIndex, "Notes"));
List<KeyValuePair<int, string>> columnSettings = new List<KeyValuePair<int, string>>
{
new KeyValuePair<int, string>(Global.Config.RamWatchAddressIndex, "Address"),
new KeyValuePair<int, string>(Global.Config.RamWatchValueIndex, "Value"),
new KeyValuePair<int, string>(Global.Config.RamWatchPrevIndex, "Prev"),
new KeyValuePair<int, string>(Global.Config.RamWatchChangeIndex, "Changes"),
new KeyValuePair<int, string>(Global.Config.RamWatchDiffIndex, "Diff"),
new KeyValuePair<int, string>(Global.Config.RamWatchDomainIndex, "Domain"),
new KeyValuePair<int, string>(Global.Config.RamWatchNotesIndex, "Notes")
};
columnSettings = columnSettings.OrderBy(s => s.Key).ToList();
for (int i = 0; i < columnSettings.Count; i++)
foreach (KeyValuePair<int, string> t in columnSettings)
{
for (int j = 0; j < columnHeaders.Count; j++)
foreach (ColumnHeader t1 in columnHeaders)
{
if (columnSettings[i].Value == columnHeaders[j].Text)
if (t.Value == t1.Text)
{
WatchListView.Columns.Add(columnHeaders[j]);
WatchListView.Columns.Add(t1);
}
}
}
@ -1549,7 +1513,7 @@ namespace BizHawk.MultiClient
private void OrderColumn(int columnToOrder)
{
string columnName = WatchListView.Columns[columnToOrder].Text;
if (sortedCol.CompareTo(columnName) != 0)
if (String.Compare(sortedCol, columnName, StringComparison.Ordinal) != 0)
{
sortReverse = false;
}

View File

@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
@ -16,7 +11,7 @@ namespace BizHawk.MultiClient
public bool SelectionWasMade = false;
public Point location = new Point();
private bool DoNotResetAddress = false;
private bool DoNotResetAddress;
public RamWatchNewWatch()
{
@ -27,7 +22,7 @@ namespace BizHawk.MultiClient
{
DoNotResetAddress = true; //Hack for the drop down event changing when initializing the drop down
Watch = new Watch(watch);
this.Text = message;
Text = message;
NotesBox.Text = watch.Notes;
setTypeRadio();
@ -43,7 +38,7 @@ namespace BizHawk.MultiClient
{
if (location.X > 0 && location.Y > 0)
{
this.Location = location;
Location = location;
}
populateMemoryDomainComboBox();
@ -53,7 +48,7 @@ namespace BizHawk.MultiClient
private void Cancel_Click(object sender, EventArgs e)
{
SelectionWasMade = false;
this.Close();
Close();
}
private void OK_Click(object sender, EventArgs e)
@ -111,7 +106,7 @@ namespace BizHawk.MultiClient
Watch.Domain = Global.Emulator.MemoryDomains[DomainComboBox.SelectedIndex];
Watch.Notes = NotesBox.Text;
this.Close();
Close();
}
private void AddressBox_Leave(object sender, EventArgs e)
@ -143,7 +138,6 @@ namespace BizHawk.MultiClient
if (!DoNotResetAddress)
{
Watch.Domain = Global.Emulator.MemoryDomains[DomainComboBox.SelectedIndex];
int x = getNumDigits(Watch.Domain.Size);
Watch.Address = 0;
Watch.Value = 0;
setAddressBox();
@ -212,10 +206,9 @@ namespace BizHawk.MultiClient
DomainComboBox.Items.Clear();
if (Global.Emulator.MemoryDomains.Count > 0)
{
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
foreach (MemoryDomain t in Global.Emulator.MemoryDomains)
{
string str = Global.Emulator.MemoryDomains[x].ToString();
DomainComboBox.Items.Add(str);
DomainComboBox.Items.Add(t.ToString());
}
}
setDomainSelection();
@ -239,8 +232,6 @@ namespace BizHawk.MultiClient
case Watch.DISPTYPE.HEX:
HexRadio.Checked = true;
break;
default:
break;
}
}

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace BizHawk.MultiClient
@ -12,8 +10,7 @@ namespace BizHawk.MultiClient
{
TimeLine movietimeline = new TimeLine(Global.MovieSession.Movie.LogDump);
Timelines = new List<TimeLine>();
Timelines.Add(movietimeline);
Timelines = new List<TimeLine> {movietimeline};
//Load all 10 saveslots and process
for (int i = 0; i < 10; i++)

View File

@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.MultiClient
@ -29,9 +26,9 @@ namespace BizHawk.MultiClient
//Allow hotkeys when TAStudio has focus
//Reduce the memory footprint with compression and or dropping frames and rerunning them when requested.
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight;
int stopOnFrame = 0;
private int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
private int defaultHeight;
private int stopOnFrame;
public bool Engaged; //When engaged the Client will listen to TAStudio for input
@ -44,8 +41,8 @@ namespace BizHawk.MultiClient
{
InitializeComponent();
Closing += (o, e) => SaveConfigSettings();
TASView.QueryItemText += new QueryItemTextHandler(TASView_QueryItemText);
TASView.QueryItemBkColor += new QueryItemBkColorHandler(TASView_QueryItemBkColor);
TASView.QueryItemText += TASView_QueryItemText;
TASView.QueryItemBkColor += TASView_QueryItemBkColor;
TASView.VirtualMode = true;
}
@ -53,15 +50,15 @@ namespace BizHawk.MultiClient
//TODO: move me
public class ClipboardEntry
{
public int frame;
public string inputstr;
public int Frame;
public string Inputstr;
}
public List<ClipboardEntry> Clipboard = new List<ClipboardEntry>();
public void UpdateValues()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
TASView.BlazingFast = true;
if (Global.MovieSession.Movie.IsActive)
{
@ -77,7 +74,7 @@ namespace BizHawk.MultiClient
TASView.BlazingFast = false;
}
if (Global.Emulator.Frame < this.stopOnFrame)
if (Global.Emulator.Frame < stopOnFrame)
{
Global.MainForm.PressFrameAdvance = true;
}
@ -157,7 +154,7 @@ namespace BizHawk.MultiClient
public void Restart()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
TASView.Items.Clear();
LoadTAStudio();
}
@ -205,12 +202,12 @@ namespace BizHawk.MultiClient
if (Global.Config.TAStudioSaveWindowPosition && Global.Config.TASWndx >= 0 && Global.Config.TASWndy >= 0)
{
this.Location = new Point(Global.Config.TASWndx, Global.Config.TASWndy);
Location = new Point(Global.Config.TASWndx, Global.Config.TASWndy);
}
if (Global.Config.TASWidth >= 0 && Global.Config.TASHeight >= 0)
{
this.Size = new System.Drawing.Size(Global.Config.TASWidth, Global.Config.TASHeight);
Size = new Size(Global.Config.TASWidth, Global.Config.TASHeight);
}
}
@ -218,15 +215,15 @@ namespace BizHawk.MultiClient
private void SaveConfigSettings()
{
Engaged = false;
Global.Config.TASWndx = this.Location.X;
Global.Config.TASWndy = this.Location.Y;
Global.Config.TASWidth = this.Right - this.Left;
Global.Config.TASHeight = this.Bottom - this.Top;
Global.Config.TASWndx = Location.X;
Global.Config.TASWndy = Location.Y;
Global.Config.TASWidth = Right - Left;
Global.Config.TASHeight = Bottom - Top;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
Close();
}
private void settingsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
@ -243,7 +240,7 @@ namespace BizHawk.MultiClient
private void restoreWindowToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
Size = new Size(defaultWidth, defaultHeight);
}
private void StopButton_Click(object sender, EventArgs e)
@ -259,7 +256,7 @@ namespace BizHawk.MultiClient
private void RewindButton_Click(object sender, EventArgs e)
{
this.stopOnFrame = 0;
stopOnFrame = 0;
if (Global.MovieSession.Movie.IsFinished || !Global.MovieSession.Movie.IsActive)
{
Global.MainForm.Rewind(1);
@ -290,12 +287,12 @@ namespace BizHawk.MultiClient
if (ReadOnlyCheckBox.Checked)
{
Global.MainForm.SetReadOnly(true);
ReadOnlyCheckBox.BackColor = System.Drawing.SystemColors.Control;
ReadOnlyCheckBox.BackColor = SystemColors.Control;
if (Global.MovieSession.Movie.IsActive)
{
Global.MovieSession.Movie.SwitchToPlay();
toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Currently Read-Only Mode");
toolTip1.SetToolTip(ReadOnlyCheckBox, "Currently Read-Only Mode");
}
}
else
@ -305,7 +302,7 @@ namespace BizHawk.MultiClient
if (Global.MovieSession.Movie.IsActive)
{
Global.MovieSession.Movie.SwitchToRecord();
toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Currently Read+Write Mode");
toolTip1.SetToolTip(ReadOnlyCheckBox, "Currently Read+Write Mode");
}
}
}
@ -320,12 +317,12 @@ namespace BizHawk.MultiClient
{
//TODO: adelikat: I removed the stop on frame feature, so this will keep playing into movie finished mode, need to rebuild that functionality
this.FastFowardToEnd.Checked ^= true;
Global.MainForm.FastForward = this.FastFowardToEnd.Checked;
if (true == this.FastFowardToEnd.Checked)
FastFowardToEnd.Checked ^= true;
Global.MainForm.FastForward = FastFowardToEnd.Checked;
if (FastFowardToEnd.Checked)
{
this.FastForward.Checked = false;
this.TurboFastForward.Checked = false;
FastForward.Checked = false;
TurboFastForward.Checked = false;
}
}
@ -398,23 +395,23 @@ namespace BizHawk.MultiClient
private void FastForward_Click(object sender, EventArgs e)
{
this.FastForward.Checked ^= true;
Global.MainForm.FastForward = this.FastForward.Checked;
if (true == this.FastForward.Checked)
FastForward.Checked ^= true;
Global.MainForm.FastForward = FastForward.Checked;
if (FastForward.Checked)
{
this.TurboFastForward.Checked = false;
this.FastFowardToEnd.Checked = false;
TurboFastForward.Checked = false;
FastFowardToEnd.Checked = false;
}
}
private void TurboFastForward_Click(object sender, EventArgs e)
{
Global.MainForm.TurboFastForward ^= true;
this.TurboFastForward.Checked ^= true;
if (true == this.TurboFastForward.Checked)
TurboFastForward.Checked ^= true;
if (TurboFastForward.Checked)
{
this.FastForward.Checked = false;
this.FastFowardToEnd.Checked = false;
FastForward.Checked = false;
FastFowardToEnd.Checked = false;
}
}
@ -427,13 +424,13 @@ namespace BizHawk.MultiClient
{
if (TASView.selectedItem <= Global.MovieSession.Movie.StateLastIndex)
{
this.stopOnFrame = 0;
stopOnFrame = 0;
Global.MovieSession.Movie.RewindToFrame(TASView.selectedItem);
}
else
{
Global.MovieSession.Movie.RewindToFrame(Global.MovieSession.Movie.StateLastIndex);
this.stopOnFrame = TASView.selectedItem;
stopOnFrame = TASView.selectedItem;
Global.MainForm.PressFrameAdvance = true;
}
@ -452,10 +449,12 @@ namespace BizHawk.MultiClient
private static string SaveRecordingAs()
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath);
sfd.DefaultExt = "." + Global.Config.MovieExtension;
sfd.FileName = Global.MovieSession.Movie.Filename;
SaveFileDialog sfd = new SaveFileDialog
{
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath),
DefaultExt = "." + Global.Config.MovieExtension,
FileName = Global.MovieSession.Movie.Filename
};
string filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*";
sfd.Filter = filter;
@ -473,9 +472,9 @@ namespace BizHawk.MultiClient
{
//if ((Control.MouseButtons & MouseButtons.Middle) > 0) //adelikat: TODO: right-click + mouse wheel won't work because in this dialog, right-click freezes emulation in the main window. Why? Hex Editor doesn't do this for instance
if ((Control.ModifierKeys & Keys.Control) > 0)
if ((ModifierKeys & Keys.Control) > 0)
{
this.stopOnFrame = 0;
stopOnFrame = 0;
if (e.Delta > 0) //Scroll up
{
@ -545,7 +544,7 @@ namespace BizHawk.MultiClient
private void DeleteFrames()
{
ListView.SelectedIndexCollection list = TASView.SelectedIndices;
for (int index = 0; index < list.Count; index++)
foreach (object t in list)
{
Global.MovieSession.Movie.DeleteFrame(list[0]); //TODO: this doesn't allow of non-continuous deletion, instead it should iterate from last to first and remove the iterated value
}
@ -580,8 +579,7 @@ namespace BizHawk.MultiClient
ListView.SelectedIndexCollection list = TASView.SelectedIndices;
if (list.Count > 0)
{
InputPrompt prompt = new InputPrompt();
prompt.TextInputType = InputPrompt.InputType.UNSIGNED;
InputPrompt prompt = new InputPrompt {TextInputType = InputPrompt.InputType.UNSIGNED};
prompt.SetMessage("How many frames?");
prompt.SetInitialValue("1");
prompt.SetTitle("Insert new frames");
@ -657,9 +655,7 @@ namespace BizHawk.MultiClient
ListView.SelectedIndexCollection list = TASView.SelectedIndices;
for (int i = 0; i < list.Count; i++)
{
ClipboardEntry entry = new ClipboardEntry();
entry.frame = list[i];
entry.inputstr = Global.MovieSession.Movie.GetInput(list[i]);
ClipboardEntry entry = new ClipboardEntry {Frame = list[i], Inputstr = Global.MovieSession.Movie.GetInput(list[i])};
Clipboard.Add(entry);
}
UpdateSlicerDisplay();
@ -704,7 +700,7 @@ namespace BizHawk.MultiClient
{
for (int i = 0; i < Clipboard.Count; i++)
{
Global.MovieSession.Movie.ModifyFrame(Clipboard[i].inputstr, list[0] + i);
Global.MovieSession.Movie.ModifyFrame(Clipboard[i].Inputstr, list[0] + i);
}
}
UpdateValues();
@ -717,7 +713,7 @@ namespace BizHawk.MultiClient
{
for (int i = 0; i < Clipboard.Count; i++)
{
Global.MovieSession.Movie.InsertFrame(Clipboard[i].inputstr, list[0] + i);
Global.MovieSession.Movie.InsertFrame(Clipboard[i].Inputstr, list[0] + i);
}
}
UpdateValues();
@ -741,9 +737,7 @@ namespace BizHawk.MultiClient
Clipboard.Clear();
for (int i = 0; i < list.Count; i++)
{
ClipboardEntry entry = new ClipboardEntry();
entry.frame = list[i];
entry.inputstr = Global.MovieSession.Movie.GetInput(list[i]);
ClipboardEntry entry = new ClipboardEntry {Frame = list[i], Inputstr = Global.MovieSession.Movie.GetInput(list[i])};
Clipboard.Add(entry);
Global.MovieSession.Movie.DeleteFrame(list[0]);
}
@ -786,32 +780,22 @@ namespace BizHawk.MultiClient
private void button1_Click(object sender, EventArgs e)
{
//Do visualization
DoVisualizerScan = true;
VisualizerBox.Refresh();
DoVisualizerScan = false;
}
private void VisualizerBox_Paint(object sender, PaintEventArgs e)
{
if (DoVisualizerScan)
{
StateVisualizer vizualizer = new StateVisualizer();
//if (DoVisualizerScan)
//{
//StateVisualizer vizualizer = new StateVisualizer();
for (int i = 0; i < vizualizer.TimeLineCount; i++)
{
//for (int i = 0; i < vizualizer.TimeLineCount; i++)
//{
}
int x = 0;
x++;
int y = x;
y++;
}
//}
//}
}
private bool DoVisualizerScan = false;
private void VisualizerBox_Enter(object sender, EventArgs e)
{

View File

@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Emulation.Consoles.Nintendo;
using BizHawk.Emulation.Consoles.Calculator;
@ -67,7 +62,7 @@ namespace BizHawk.MultiClient
SNESGraphicsDebuggerButton.Visible = false;
}
Size = new Size(this.Size.Width, toolStrip1.Size.Height + 50);
Size = new Size(Size.Width, toolStrip1.Size.Height + 50);
}
private void toolStripButton1_Click(object sender, EventArgs e)

View File

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
@ -16,15 +13,15 @@ namespace BizHawk.MultiClient
//Make faster, such as not saving to disk until the logging is stopped, dont' add to Instructions list every frame, etc
//Remember window size
List<string> Instructions = new List<string>();
FileInfo LogFile;
private readonly List<string> Instructions = new List<string>();
private FileInfo LogFile;
public TraceLogger()
{
InitializeComponent();
TraceView.QueryItemText += new QueryItemTextHandler(TraceView_QueryItemText);
TraceView.QueryItemBkColor += new QueryItemBkColorHandler(TraceView_QueryItemBkColor);
TraceView.QueryItemText += TraceView_QueryItemText;
TraceView.QueryItemBkColor += TraceView_QueryItemBkColor;
TraceView.VirtualMode = true;
Closing += (o, e) => SaveConfigSettings();
@ -33,8 +30,8 @@ namespace BizHawk.MultiClient
public void SaveConfigSettings()
{
Global.CoreComm.Tracer.Enabled = false;
Global.Config.TraceLoggerWndx = this.Location.X;
Global.Config.TraceLoggerWndy = this.Location.Y;
Global.Config.TraceLoggerWndx = Location.X;
Global.Config.TraceLoggerWndy = Location.Y;
}
private void TraceView_QueryItemBkColor(int index, int column, ref Color color)
@ -58,7 +55,7 @@ namespace BizHawk.MultiClient
{
if (Global.Config.TraceLoggerSaveWindowPosition && Global.Config.TraceLoggerWndx >= 0 && Global.Config.TraceLoggerWndy >= 0)
{
this.Location = new Point(Global.Config.TraceLoggerWndx, Global.Config.TraceLoggerWndy);
Location = new Point(Global.Config.TraceLoggerWndx, Global.Config.TraceLoggerWndy);
}
ClearList();
@ -75,7 +72,7 @@ namespace BizHawk.MultiClient
public void Restart()
{
if (!this.IsHandleCreated || this.IsDisposed)
if (!IsHandleCreated || IsDisposed)
{
return;
}
@ -88,7 +85,7 @@ namespace BizHawk.MultiClient
}
else
{
this.Close();
Close();
}
}
}
@ -169,11 +166,6 @@ namespace BizHawk.MultiClient
saveWindowPositionToolStripMenuItem.Checked = Global.Config.TraceLoggerSaveWindowPosition;
}
private void CloseButton_Click(object sender, EventArgs e)
{
Close();
}
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.TraceLoggerSaveWindowPosition ^= true;
@ -182,9 +174,7 @@ namespace BizHawk.MultiClient
private Point GetPromptPoint()
{
Point p = new Point(TraceView.Location.X + 30, TraceView.Location.Y + 30);
Point q = new Point();
q = PointToScreen(p);
return q;
return PointToScreen(p);
}
private void setMaxWindowLinesToolStripMenuItem_Click(object sender, EventArgs e)
@ -194,7 +184,7 @@ namespace BizHawk.MultiClient
p.SetInitialValue(Global.Config.TraceLoggerMaxLines.ToString());
p.TextInputType = InputPrompt.InputType.UNSIGNED;
p._Location = GetPromptPoint();
DialogResult result = p.ShowDialog();
p.ShowDialog();
if (p.UserOK)
{
int x = int.Parse(p.UserText);
@ -244,7 +234,7 @@ namespace BizHawk.MultiClient
string name = PathManager.FilesystemSafeName(Global.Game);
string filename = Path.Combine(PathManager.MakeAbsolutePath(Global.Config.LogPath), name) + ".txt";
LogFile = new FileInfo(filename);
if (!LogFile.Directory.Exists)
if (LogFile.Directory != null && !LogFile.Directory.Exists)
{
LogFile.Directory.Create();
}

View File

@ -1,10 +1,5 @@
using System;
using System.Drawing;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
@ -33,8 +28,8 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Size = new Size(174, 74);
BorderStyle = BorderStyle.Fixed3D;
Size = new Size(174, 74);
Controller = "P1";
}

View File

@ -1,10 +1,8 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
class VirtualPadA26 : VirtualPad
@ -20,68 +18,77 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Size = new Size(174, 74);
Point n = new Point(this.Size);
BorderStyle = BorderStyle.Fixed3D;
Size = new Size(174, 74);
this.PU = new CheckBox();
this.PU.Appearance = System.Windows.Forms.Appearance.Button;
this.PU.AutoSize = true;
this.PU.Image = global::BizHawk.MultiClient.Properties.Resources.BlueUp;
this.PU.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PU.Location = ButtonPoints[0];
this.PU.TabIndex = 1;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PU = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueUp,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[0],
TabIndex = 1,
UseVisualStyleBackColor = true
};
PU.CheckedChanged += this.Buttons_CheckedChanged;
this.PD = new CheckBox();
this.PD.Appearance = System.Windows.Forms.Appearance.Button;
this.PD.AutoSize = true;
this.PD.Image = global::BizHawk.MultiClient.Properties.Resources.BlueDown;
this.PD.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PD.Location = ButtonPoints[1];
this.PD.TabIndex = 4;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PD = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueDown,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[1],
TabIndex = 4,
UseVisualStyleBackColor = true
};
PD.CheckedChanged += Buttons_CheckedChanged;
this.PR = new CheckBox();
this.PR.Appearance = System.Windows.Forms.Appearance.Button;
this.PR.AutoSize = true;
this.PR.Image = global::BizHawk.MultiClient.Properties.Resources.Forward;
this.PR.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PR.Location = ButtonPoints[3];
this.PR.TabIndex = 3;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PR = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Forward,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[3],
TabIndex = 3,
UseVisualStyleBackColor = true
};
PR.CheckedChanged += Buttons_CheckedChanged;
this.PL = new CheckBox();
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
this.PL.AutoSize = true;
this.PL.Image = global::BizHawk.MultiClient.Properties.Resources.Back;
this.PL.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PL.Location = ButtonPoints[2];
this.PL.TabIndex = 2;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PL = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Back,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[2],
TabIndex = 2,
UseVisualStyleBackColor = true
};
PL.CheckedChanged += Buttons_CheckedChanged;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[4];
this.B1.TabIndex = 5;
this.B1.Text = "B";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[4],
TabIndex = 5,
Text = "B",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
this.Controls.Add(this.PU);
this.Controls.Add(this.PD);
this.Controls.Add(this.PL);
this.Controls.Add(this.PR);
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
this.Controls.Add(this.B3);
this.Controls.Add(this.B4);
Controls.Add(PU);
Controls.Add(PD);
Controls.Add(PL);
Controls.Add(PR);
Controls.Add(B1);
Controls.Add(B2);
Controls.Add(B3);
Controls.Add(B4);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -89,24 +96,25 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}

View File

@ -1,10 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
@ -18,36 +15,38 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(108, 34);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(108, 34);
Point n = new Point(this.Size);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[0],
TabIndex = 5,
Text = "Reset",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
B1.ForeColor = Color.Red;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[0];
this.B1.TabIndex = 5;
this.B1.Text = "Reset";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B1.ForeColor = Color.Red;
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[1],
TabIndex = 6,
Text = "Select",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
B2.ForeColor = Color.Red;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[1];
this.B2.TabIndex = 6;
this.B2.Text = "Select";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B2.ForeColor = Color.Red;
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
Controls.Add(B1);
Controls.Add(B2);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -55,23 +54,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}
@ -103,18 +102,26 @@ namespace BizHawk.MultiClient
else if (sender == B1)
{
Global.StickyXORAdapter.SetSticky("Reset", B1.Checked);
if (B1.Checked == true)
if (B1.Checked)
{
B1.BackColor = Color.Pink;
}
else
{
B1.BackColor = SystemColors.Control;
}
}
else if (sender == B2)
{
Global.StickyXORAdapter.SetSticky("Select", B2.Checked);
if (B2.Checked == true)
if (B2.Checked)
{
B2.BackColor = Color.Pink;
}
else
{
B2.BackColor = SystemColors.Control;
}
}
}

View File

@ -120,7 +120,6 @@
this.Controls.Add(this.PU);
this.Name = "VirtualPadA78";
this.Size = new System.Drawing.Size(128, 89);
this.Load += new System.EventHandler(this.VirtualPadA78_Load);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
@ -18,8 +13,7 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
BorderStyle = BorderStyle.Fixed3D;
InitializeComponent();
}
@ -28,38 +22,27 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}
private void VirtualPad_Paint(object sender, PaintEventArgs e)
{
}
private void VirtualPadA78_Load(object sender, EventArgs e)
{
}
public string GetMnemonic()
{
StringBuilder input = new StringBuilder("");

View File

@ -92,7 +92,6 @@
this.Controls.Add(this.B1);
this.Name = "VirtualPadA78Control";
this.Size = new System.Drawing.Size(217, 34);
this.Load += new System.EventHandler(this.VirtualPadA78Control_Load);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
@ -16,39 +11,35 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
InitializeComponent();
}
private void VirtualPadA78Control_Load(object sender, EventArgs e)
{
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}

View File

@ -1091,7 +1091,6 @@
this.Controls.Add(this.KLeftArrow);
this.Name = "VirtualPadC64Keyboard";
this.Size = new System.Drawing.Size(454, 134);
this.Load += new System.EventHandler(this.VirtualPadC64Keyboard_Load);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
@ -16,11 +11,6 @@ namespace BizHawk.MultiClient
InitializeComponent();
}
private void VirtualPadC64Keyboard_Load(object sender, EventArgs e)
{
}
private void Buttons_CheckedChanged(object sender, EventArgs e)
{
if (Global.Emulator.SystemId != "C64")

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
@ -17,8 +12,8 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
InitializeComponent();
}
@ -32,23 +27,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}

View File

@ -1,21 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.MultiClient
{
public partial class VirtualPadForm : Form
{
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight;
List<IVirtualPad> Pads = new List<IVirtualPad>();
private int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
private int defaultHeight;
private readonly List<IVirtualPad> Pads = new List<IVirtualPad>();
public VirtualPadForm()
{
@ -38,22 +32,22 @@ namespace BizHawk.MultiClient
if (Global.Config.VirtualPadSaveWindowPosition && Global.Config.VPadWndx >= 0 && Global.Config.VPadWndy >= 0)
{
this.Location = new Point(Global.Config.VPadWndx, Global.Config.VPadWndy);
Location = new Point(Global.Config.VPadWndx, Global.Config.VPadWndy);
}
if (Global.Config.VirtualPadSaveWindowPosition && Global.Config.VPadWidth >= 0 && Global.Config.VPadHeight >= 0)
{
Size = new System.Drawing.Size(Global.Config.VPadWidth, Global.Config.VPadHeight);
Size = new Size(Global.Config.VPadWidth, Global.Config.VPadHeight);
}
}
private void SaveConfigSettings()
{
Global.Config.VPadWndx = this.Location.X;
Global.Config.VPadWndy = this.Location.Y;
Global.Config.VPadWndx = Location.X;
Global.Config.VPadWndy = Location.Y;
Global.Config.VPadWidth = this.Right - this.Left;
Global.Config.VPadHeight = this.Bottom - this.Top;
Global.Config.VPadWidth = Right - Left;
Global.Config.VPadHeight = Bottom - Top;
Pads.Clear();
}
@ -62,90 +56,59 @@ namespace BizHawk.MultiClient
{
switch (Global.Emulator.SystemId)
{
case "NULL":
default:
break;
case "A26":
VirtualPadA26 ataripad1 = new VirtualPadA26();
ataripad1.Location = new Point(8, 19);
ataripad1.Controller = "P1";
VirtualPadA26 ataripad2 = new VirtualPadA26();
ataripad2.Location = new Point(188, 19);
ataripad2.Controller = "P2";
VirtualPadA26 ataripad1 = new VirtualPadA26 {Location = new Point(8, 19), Controller = "P1"};
VirtualPadA26 ataripad2 = new VirtualPadA26 {Location = new Point(188, 19), Controller = "P2"};
Pads.Add(ataripad1);
Pads.Add(ataripad2);
ControllerBox.Controls.Add(ataripad1);
ControllerBox.Controls.Add(ataripad2);
VirtualPadA26Control ataricontrols = new VirtualPadA26Control();
ataricontrols.Location = new Point(8, 109);
VirtualPadA26Control ataricontrols = new VirtualPadA26Control {Location = new Point(8, 109)};
Pads.Add(ataricontrols);
ControllerBox.Controls.Add(Pads[2] as Control);
break;
case "A78":
VirtualPadA78 atari78pad1 = new VirtualPadA78();
atari78pad1.Location = new Point(8, 19);
atari78pad1.Controller = "P1";
VirtualPadA78 atari78pad2 = new VirtualPadA78();
atari78pad2.Location = new Point(150, 19);
atari78pad2.Controller = "P2";
VirtualPadA78 atari78pad1 = new VirtualPadA78 {Location = new Point(8, 19), Controller = "P1"};
VirtualPadA78 atari78pad2 = new VirtualPadA78 {Location = new Point(150, 19), Controller = "P2"};
Pads.Add(atari78pad1);
Pads.Add(atari78pad2);
ControllerBox.Controls.Add(atari78pad1);
ControllerBox.Controls.Add(atari78pad2);
VirtualPadA78Control atari78controls = new VirtualPadA78Control();
atari78controls.Location = new Point(8, 125);
VirtualPadA78Control atari78controls = new VirtualPadA78Control {Location = new Point(8, 125)};
Pads.Add(atari78controls);
ControllerBox.Controls.Add(Pads[2] as Control);
break;
case "NES":
VirtualPadNES nespad1 = new VirtualPadNES();
nespad1.Location = new Point(8, 19);
nespad1.Controller = "P1";
VirtualPadNES nespad2 = new VirtualPadNES();
nespad2.Location = new Point(188, 19);
nespad2.Controller = "P2";
VirtualPadNES nespad1 = new VirtualPadNES {Location = new Point(8, 19), Controller = "P1"};
VirtualPadNES nespad2 = new VirtualPadNES {Location = new Point(188, 19), Controller = "P2"};
Pads.Add(nespad1);
Pads.Add(nespad2);
ControllerBox.Controls.Add(nespad1);
ControllerBox.Controls.Add(nespad2);
VirtualPadNESControl controlpad1 = new VirtualPadNESControl();
controlpad1.Location = new Point(8, 109);
VirtualPadNESControl controlpad1 = new VirtualPadNESControl {Location = new Point(8, 109)};
Pads.Add(controlpad1);
ControllerBox.Controls.Add(controlpad1);
break;
case "SMS":
case "SG":
case "GG":
VirtualPadSMS smspad1 = new VirtualPadSMS();
smspad1.Location = new Point(8, 19);
smspad1.Controller = "P1";
VirtualPadSMS smspad2 = new VirtualPadSMS();
smspad2.Location = new Point(188, 19);
smspad2.Controller = "P2";
VirtualPadSMS smspad1 = new VirtualPadSMS {Location = new Point(8, 19), Controller = "P1"};
VirtualPadSMS smspad2 = new VirtualPadSMS {Location = new Point(188, 19), Controller = "P2"};
Pads.Add(smspad1);
Pads.Add(smspad2);
ControllerBox.Controls.Add(smspad1);
ControllerBox.Controls.Add(smspad2);
VirtualPadSMSControl controlpad2 = new VirtualPadSMSControl();
controlpad2.Location = new Point(8, 109);
VirtualPadSMSControl controlpad2 = new VirtualPadSMSControl {Location = new Point(8, 109)};
Pads.Add(controlpad2);
ControllerBox.Controls.Add(Pads[2] as Control);
break;
case "PCE":
case "PCECD":
case "SGX":
VirtualPadPCE pcepad1 = new VirtualPadPCE();
pcepad1.Location = new Point(8, 19);
pcepad1.Controller = "P1";
VirtualPadPCE pcepad2 = new VirtualPadPCE();
pcepad2.Location = new Point(188, 19);
pcepad2.Controller = "P2";
VirtualPadPCE pcepad3 = new VirtualPadPCE();
pcepad3.Location = new Point(8, 109);
pcepad3.Controller = "P3";
VirtualPadPCE pcepad4 = new VirtualPadPCE();
pcepad4.Location = new Point(188, 109);
pcepad4.Controller = "P4";
VirtualPadPCE pcepad1 = new VirtualPadPCE {Location = new Point(8, 19), Controller = "P1"};
VirtualPadPCE pcepad2 = new VirtualPadPCE {Location = new Point(188, 19), Controller = "P2"};
VirtualPadPCE pcepad3 = new VirtualPadPCE {Location = new Point(8, 109), Controller = "P3"};
VirtualPadPCE pcepad4 = new VirtualPadPCE {Location = new Point(188, 109), Controller = "P4"};
Pads.Add(pcepad1);
Pads.Add(pcepad2);
Pads.Add(pcepad3);
@ -156,20 +119,11 @@ namespace BizHawk.MultiClient
ControllerBox.Controls.Add(pcepad4);
break;
case "SNES":
VirtualPadSNES snespad1 = new VirtualPadSNES();
snespad1.Location = new Point(8, 19);
snespad1.Controller = "P1";
VirtualPadSNES snespad2 = new VirtualPadSNES();
snespad2.Location = new Point(188, 19);
snespad2.Controller = "P2";
VirtualPadSNES snespad3 = new VirtualPadSNES();
snespad3.Location = new Point(8, 95);
snespad3.Controller = "P3";
VirtualPadSNES snespad4 = new VirtualPadSNES();
snespad4.Location = new Point(188, 95);
snespad4.Controller = "P4";
VirtualPadSNESControl snescontrolpad = new VirtualPadSNESControl();
snescontrolpad.Location = new Point(8, 170);
VirtualPadSNES snespad1 = new VirtualPadSNES {Location = new Point(8, 19), Controller = "P1"};
VirtualPadSNES snespad2 = new VirtualPadSNES {Location = new Point(188, 19), Controller = "P2"};
VirtualPadSNES snespad3 = new VirtualPadSNES {Location = new Point(8, 95), Controller = "P3"};
VirtualPadSNES snespad4 = new VirtualPadSNES {Location = new Point(188, 95), Controller = "P4"};
VirtualPadSNESControl snescontrolpad = new VirtualPadSNESControl {Location = new Point(8, 170)};
Pads.Add(snespad1);
Pads.Add(snespad2);
Pads.Add(snespad3);
@ -183,54 +137,37 @@ namespace BizHawk.MultiClient
break;
case "GB":
case "GBC":
VirtualPadGB gbpad1 = new VirtualPadGB();
gbpad1.Location = new Point(8, 19);
gbpad1.Controller = "";
VirtualPadGB gbpad1 = new VirtualPadGB {Location = new Point(8, 19), Controller = ""};
Pads.Add(gbpad1);
ControllerBox.Controls.Add(gbpad1);
VirtualPadGBControl gbcontrolpad = new VirtualPadGBControl();
gbcontrolpad.Location = new Point(8, 109);
VirtualPadGBControl gbcontrolpad = new VirtualPadGBControl {Location = new Point(8, 109)};
Pads.Add(gbcontrolpad);
ControllerBox.Controls.Add(gbcontrolpad);
break;
case "GBA":
VirtualPadGBA gbapad1 = new VirtualPadGBA();
gbapad1.Location = new Point(8, 19);
gbapad1.Controller = "";
VirtualPadGBA gbapad1 = new VirtualPadGBA {Location = new Point(8, 19), Controller = ""};
Pads.Add(gbapad1);
ControllerBox.Controls.Add(gbapad1);
break;
case "GEN":
VirtualPadGen3Button genpad1 = new VirtualPadGen3Button();
genpad1.Location = new Point(8, 19);
genpad1.Controller = "P1";
VirtualPadGen3Button genpad1 = new VirtualPadGen3Button {Location = new Point(8, 19), Controller = "P1"};
Pads.Add(genpad1);
ControllerBox.Controls.Add(genpad1);
break;
case "Coleco":
VirtualPadColeco coleco1 = new VirtualPadColeco();
coleco1.Location = new Point(8, 19);
coleco1.Controller = "P1";
VirtualPadColeco coleco2 = new VirtualPadColeco();
coleco2.Location = new Point(130, 19);
coleco2.Controller = "P2";
VirtualPadColeco coleco1 = new VirtualPadColeco {Location = new Point(8, 19), Controller = "P1"};
VirtualPadColeco coleco2 = new VirtualPadColeco {Location = new Point(130, 19), Controller = "P2"};
Pads.Add(coleco1);
Pads.Add(coleco2);
ControllerBox.Controls.Add(coleco1);
ControllerBox.Controls.Add(coleco2);
break;
case "C64":
VirtualPadC64Keyboard c64k = new VirtualPadC64Keyboard();
c64k.Location = new Point(8, 19);
VirtualPadC64Keyboard c64k = new VirtualPadC64Keyboard {Location = new Point(8, 19)};
Pads.Add(c64k);
ControllerBox.Controls.Add(c64k);
VirtualPadA26 _ataripad1 = new VirtualPadA26();
_ataripad1.Location = new Point(8, 159);
_ataripad1.Controller = "P1";
VirtualPadA26 _ataripad2 = new VirtualPadA26();
_ataripad2.Location = new Point(218, 159);
_ataripad2.Controller = "P2";
VirtualPadA26 _ataripad1 = new VirtualPadA26 {Location = new Point(8, 159), Controller = "P1"};
VirtualPadA26 _ataripad2 = new VirtualPadA26 {Location = new Point(218, 159), Controller = "P2"};
Pads.Add(_ataripad1);
Pads.Add(_ataripad2);
ControllerBox.Controls.Add(_ataripad1);
@ -241,31 +178,34 @@ namespace BizHawk.MultiClient
//Hack for now
if (Global.Emulator.SystemId == "C64")
{
if (this.Width < 505)
if (Width < 505)
{
this.Width = 505;
ControllerBox.Width = this.Width - 37;
Width = 505;
ControllerBox.Width = Width - 37;
}
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
Close();
}
public void ClearVirtualPadHolds()
{
foreach (var controller in ControllerBox.Controls)
{
if (controller is IVirtualPad)
((IVirtualPad)controller).Clear();
var pad = controller as IVirtualPad;
if (pad != null)
{
pad.Clear();
}
}
}
public void Restart()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
ControllerBox.Controls.Clear();
Pads.Clear();
LoadPads();
@ -273,12 +213,12 @@ namespace BizHawk.MultiClient
public void UpdateValues()
{
if (!this.IsHandleCreated || this.IsDisposed) return;
if (!IsHandleCreated || IsDisposed) return;
if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished)
{
string str = Global.MovieSession.Movie.GetInput(Global.Emulator.Frame);
if (Global.Config.TASUpdatePads == true && str != "")
if (Global.Config.TASUpdatePads && str != "")
{
switch (Global.Emulator.SystemId)
{
@ -328,8 +268,6 @@ namespace BizHawk.MultiClient
break;
case "C64":
break;
default:
break;
}
}
}
@ -378,7 +316,7 @@ namespace BizHawk.MultiClient
private void RestoreDefaultSettings()
{
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
Size = new Size(defaultWidth, defaultHeight);
Global.Config.VirtualPadSaveWindowPosition = true;
Global.Config.VPadHeight = -1;

View File

@ -1,10 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
@ -25,100 +22,114 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(174, 74);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(174, 74);
Point n = new Point(this.Size);
PU = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueUp,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[0],
TabIndex = 1,
UseVisualStyleBackColor = true
};
PU.CheckedChanged += Buttons_CheckedChanged;
this.PU = new CheckBox();
this.PU.Appearance = System.Windows.Forms.Appearance.Button;
this.PU.AutoSize = true;
this.PU.Image = global::BizHawk.MultiClient.Properties.Resources.BlueUp;
this.PU.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PU.Location = ButtonPoints[0];
this.PU.TabIndex = 1;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PD = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueDown,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[1],
TabIndex = 4,
UseVisualStyleBackColor = true
};
PD.CheckedChanged += Buttons_CheckedChanged;
this.PD = new CheckBox();
this.PD.Appearance = System.Windows.Forms.Appearance.Button;
this.PD.AutoSize = true;
this.PD.Image = global::BizHawk.MultiClient.Properties.Resources.BlueDown;
this.PD.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PD.Location = ButtonPoints[1];
this.PD.TabIndex = 4;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PR = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Forward,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[3],
TabIndex = 3,
UseVisualStyleBackColor = true
};
PR.CheckedChanged += Buttons_CheckedChanged;
this.PR = new CheckBox();
this.PR.Appearance = System.Windows.Forms.Appearance.Button;
this.PR.AutoSize = true;
this.PR.Image = global::BizHawk.MultiClient.Properties.Resources.Forward;
this.PR.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PR.Location = ButtonPoints[3];
this.PR.TabIndex = 3;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PL = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Back,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[2],
TabIndex = 2,
UseVisualStyleBackColor = true
};
PL.CheckedChanged += Buttons_CheckedChanged;
this.PL = new CheckBox();
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
this.PL.AutoSize = true;
this.PL.Image = global::BizHawk.MultiClient.Properties.Resources.Back;
this.PL.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PL.Location = ButtonPoints[2];
this.PL.TabIndex = 2;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[4],
TabIndex = 5,
Text = "s",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[4];
this.B1.TabIndex = 5;
this.B1.Text = "s";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[5],
TabIndex = 6,
Text = "S",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[5];
this.B2.TabIndex = 6;
this.B2.Text = "S";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B3 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[6],
TabIndex = 7,
Text = "B",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B3.CheckedChanged += Buttons_CheckedChanged;
this.B3 = new CheckBox();
this.B3.Appearance = System.Windows.Forms.Appearance.Button;
this.B3.AutoSize = true;
this.B3.Location = ButtonPoints[6];
this.B3.TabIndex = 7;
this.B3.Text = "B";
this.B3.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B3.UseVisualStyleBackColor = true;
this.B3.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B4 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[7],
TabIndex = 8,
Text = "A",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B4.CheckedChanged += Buttons_CheckedChanged;
this.B4 = new CheckBox();
this.B4.Appearance = System.Windows.Forms.Appearance.Button;
this.B4.AutoSize = true;
this.B4.Location = ButtonPoints[7];
this.B4.TabIndex = 8;
this.B4.Text = "A";
this.B4.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B4.UseVisualStyleBackColor = true;
this.B4.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.Controls.Add(this.PU);
this.Controls.Add(this.PD);
this.Controls.Add(this.PL);
this.Controls.Add(this.PR);
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
this.Controls.Add(this.B3);
this.Controls.Add(this.B4);
Controls.Add(PU);
Controls.Add(PD);
Controls.Add(PL);
Controls.Add(PR);
Controls.Add(B1);
Controls.Add(B2);
Controls.Add(B3);
Controls.Add(B4);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -126,23 +137,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}

View File

@ -1,10 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
@ -26,122 +23,140 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(194, 74);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(194, 74);
Point n = new Point(this.Size);
PU = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueUp,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[0],
TabIndex = 1,
UseVisualStyleBackColor = true
};
PU.CheckedChanged += Buttons_CheckedChanged;
this.PU = new CheckBox();
this.PU.Appearance = System.Windows.Forms.Appearance.Button;
this.PU.AutoSize = true;
this.PU.Image = global::BizHawk.MultiClient.Properties.Resources.BlueUp;
this.PU.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PU.Location = ButtonPoints[0];
this.PU.TabIndex = 1;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PD = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueDown,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[1],
TabIndex = 4,
UseVisualStyleBackColor = true
};
PD.CheckedChanged += Buttons_CheckedChanged;
this.PD = new CheckBox();
this.PD.Appearance = System.Windows.Forms.Appearance.Button;
this.PD.AutoSize = true;
this.PD.Image = global::BizHawk.MultiClient.Properties.Resources.BlueDown;
this.PD.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PD.Location = ButtonPoints[1];
this.PD.TabIndex = 4;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PR = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Forward,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[3],
TabIndex = 3,
UseVisualStyleBackColor = true
};
PR.CheckedChanged += Buttons_CheckedChanged;
this.PR = new CheckBox();
this.PR.Appearance = System.Windows.Forms.Appearance.Button;
this.PR.AutoSize = true;
this.PR.Image = global::BizHawk.MultiClient.Properties.Resources.Forward;
this.PR.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PR.Location = ButtonPoints[3];
this.PR.TabIndex = 3;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PL = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Back,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[2],
TabIndex = 2,
UseVisualStyleBackColor = true
};
PL.CheckedChanged += Buttons_CheckedChanged;
this.PL = new CheckBox();
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
this.PL.AutoSize = true;
this.PL.Image = global::BizHawk.MultiClient.Properties.Resources.Back;
this.PL.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PL.Location = ButtonPoints[2];
this.PL.TabIndex = 2;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[4],
TabIndex = 5,
Text = "s",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[4];
this.B1.TabIndex = 5;
this.B1.Text = "s";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[5],
TabIndex = 6,
Text = "S",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[5];
this.B2.TabIndex = 6;
this.B2.Text = "S";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B3 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[6],
TabIndex = 7,
Text = "B",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B3.CheckedChanged += Buttons_CheckedChanged;
this.B3 = new CheckBox();
this.B3.Appearance = System.Windows.Forms.Appearance.Button;
this.B3.AutoSize = true;
this.B3.Location = ButtonPoints[6];
this.B3.TabIndex = 7;
this.B3.Text = "B";
this.B3.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B3.UseVisualStyleBackColor = true;
this.B3.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B4 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[7],
TabIndex = 8,
Text = "A",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B4.CheckedChanged += Buttons_CheckedChanged;
this.B4 = new CheckBox();
this.B4.Appearance = System.Windows.Forms.Appearance.Button;
this.B4.AutoSize = true;
this.B4.Location = ButtonPoints[7];
this.B4.TabIndex = 8;
this.B4.Text = "A";
this.B4.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B4.UseVisualStyleBackColor = true;
this.B4.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B5 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[8],
TabIndex = 8,
Text = "L",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B5.CheckedChanged += Buttons_CheckedChanged;
this.B5 = new CheckBox();
this.B5.Appearance = System.Windows.Forms.Appearance.Button;
this.B5.AutoSize = true;
this.B5.Location = ButtonPoints[8];
this.B5.TabIndex = 8;
this.B5.Text = "L";
this.B5.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B5.UseVisualStyleBackColor = true;
this.B5.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B6 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[9],
TabIndex = 8,
Text = "R",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B6.CheckedChanged += Buttons_CheckedChanged;
this.B6 = new CheckBox();
this.B6.Appearance = System.Windows.Forms.Appearance.Button;
this.B6.AutoSize = true;
this.B6.Location = ButtonPoints[9];
this.B6.TabIndex = 8;
this.B6.Text = "R";
this.B6.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B6.UseVisualStyleBackColor = true;
this.B6.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.Controls.Add(this.PU);
this.Controls.Add(this.PD);
this.Controls.Add(this.PL);
this.Controls.Add(this.PR);
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
this.Controls.Add(this.B3);
this.Controls.Add(this.B4);
this.Controls.Add(this.B5);
this.Controls.Add(this.B6);
Controls.Add(PU);
Controls.Add(PD);
Controls.Add(PL);
Controls.Add(PR);
Controls.Add(B1);
Controls.Add(B2);
Controls.Add(B3);
Controls.Add(B4);
Controls.Add(B5);
Controls.Add(B6);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -149,23 +164,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}

View File

@ -1,16 +1,12 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
public class VirtualPadGBControl : VirtualPad
{
public VirtualPadGBControl()
{
ButtonPoints[0] = new Point(2, 2);
@ -18,47 +14,47 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(108, 34);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(108, 34);
Point n = new Point(this.Size);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[0],
TabIndex = 5,
Text = "Power",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
B1.ForeColor = Color.Red;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[0];
this.B1.TabIndex = 5;
this.B1.Text = "Power";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B1.ForeColor = Color.Red;
this.Controls.Add(this.B1);
Controls.Add(B1);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Up)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}
@ -98,7 +94,7 @@ namespace BizHawk.MultiClient
else if (sender == B1)
{
Global.StickyXORAdapter.SetSticky("Power", B1.Checked);
if (B1.Checked == true)
if (B1.Checked)
{
B1.BackColor = Color.Pink;
}

View File

@ -1,10 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
@ -24,124 +21,135 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(174, 74);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(174, 74);
Point n = new Point(this.Size);
PU = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueUp,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[0],
TabIndex = 1,
UseVisualStyleBackColor = true
};
PU.CheckedChanged += Buttons_CheckedChanged;
this.PU = new CheckBox();
this.PU.Appearance = System.Windows.Forms.Appearance.Button;
this.PU.AutoSize = true;
this.PU.Image = global::BizHawk.MultiClient.Properties.Resources.BlueUp;
this.PU.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PU.Location = ButtonPoints[0];
this.PU.TabIndex = 1;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PD = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueDown,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[1],
TabIndex = 4,
UseVisualStyleBackColor = true
};
PD.CheckedChanged += Buttons_CheckedChanged;
this.PD = new CheckBox();
this.PD.Appearance = System.Windows.Forms.Appearance.Button;
this.PD.AutoSize = true;
this.PD.Image = global::BizHawk.MultiClient.Properties.Resources.BlueDown;
this.PD.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PD.Location = ButtonPoints[1];
this.PD.TabIndex = 4;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PR = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Forward,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[3],
TabIndex = 3,
UseVisualStyleBackColor = true
};
PR.CheckedChanged += Buttons_CheckedChanged;
this.PR = new CheckBox();
this.PR.Appearance = System.Windows.Forms.Appearance.Button;
this.PR.AutoSize = true;
this.PR.Image = global::BizHawk.MultiClient.Properties.Resources.Forward;
this.PR.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PR.Location = ButtonPoints[3];
this.PR.TabIndex = 3;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PL = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Back,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[2],
TabIndex = 2,
UseVisualStyleBackColor = true
};
PL.CheckedChanged += Buttons_CheckedChanged;
this.PL = new CheckBox();
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
this.PL.AutoSize = true;
this.PL.Image = global::BizHawk.MultiClient.Properties.Resources.Back;
this.PL.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PL.Location = ButtonPoints[2];
this.PL.TabIndex = 2;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[4],
TabIndex = 5,
Text = "C",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[4];
this.B1.TabIndex = 5;
this.B1.Text = "C";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[5],
TabIndex = 6,
Text = "S",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[5];
this.B2.TabIndex = 6;
this.B2.Text = "S";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B3 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[6],
TabIndex = 7,
Text = "B",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B3.CheckedChanged += Buttons_CheckedChanged;
this.B3 = new CheckBox();
this.B3.Appearance = System.Windows.Forms.Appearance.Button;
this.B3.AutoSize = true;
this.B3.Location = ButtonPoints[6];
this.B3.TabIndex = 7;
this.B3.Text = "B";
this.B3.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B3.UseVisualStyleBackColor = true;
this.B3.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B4 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[7],
TabIndex = 8,
Text = "A",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B4.CheckedChanged += Buttons_CheckedChanged;
this.B4 = new CheckBox();
this.B4.Appearance = System.Windows.Forms.Appearance.Button;
this.B4.AutoSize = true;
this.B4.Location = ButtonPoints[7];
this.B4.TabIndex = 8;
this.B4.Text = "A";
this.B4.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B4.UseVisualStyleBackColor = true;
this.B4.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.Controls.Add(this.PU);
this.Controls.Add(this.PD);
this.Controls.Add(this.PL);
this.Controls.Add(this.PR);
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
this.Controls.Add(this.B3);
this.Controls.Add(this.B4);
Controls.Add(PU);
Controls.Add(PD);
Controls.Add(PL);
Controls.Add(PR);
Controls.Add(B1);
Controls.Add(B2);
Controls.Add(B3);
Controls.Add(B4);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Up)
switch (keyData)
{
//TODO: move to next logical key
this.Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
case Keys.Up:
Refresh();
break;
case Keys.Down:
Refresh();
break;
case Keys.Left:
Refresh();
break;
case Keys.Right:
Refresh();
break;
case Keys.Tab:
Refresh();
break;
}
return true;
}

View File

@ -1,16 +1,12 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
public class VirtualPadNES : VirtualPad
{
public VirtualPadNES()
{
ButtonPoints[0] = new Point(14, 2);
@ -25,100 +21,114 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(174, 74);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(174, 74);
Point n = new Point(this.Size);
PU = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueUp,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[0],
TabIndex = 1,
UseVisualStyleBackColor = true
};
PU.CheckedChanged += Buttons_CheckedChanged;
this.PU = new CheckBox();
this.PU.Appearance = System.Windows.Forms.Appearance.Button;
this.PU.AutoSize = true;
this.PU.Image = global::BizHawk.MultiClient.Properties.Resources.BlueUp;
this.PU.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PU.Location = ButtonPoints[0];
this.PU.TabIndex = 1;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PD = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueDown,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[1],
TabIndex = 4,
UseVisualStyleBackColor = true
};
PD.CheckedChanged += Buttons_CheckedChanged;
this.PD = new CheckBox();
this.PD.Appearance = System.Windows.Forms.Appearance.Button;
this.PD.AutoSize = true;
this.PD.Image = global::BizHawk.MultiClient.Properties.Resources.BlueDown;
this.PD.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PD.Location = ButtonPoints[1];
this.PD.TabIndex = 4;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PR = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Forward,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[3],
TabIndex = 3,
UseVisualStyleBackColor = true
};
PR.CheckedChanged += Buttons_CheckedChanged;
this.PR = new CheckBox();
this.PR.Appearance = System.Windows.Forms.Appearance.Button;
this.PR.AutoSize = true;
this.PR.Image = global::BizHawk.MultiClient.Properties.Resources.Forward;
this.PR.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PR.Location = ButtonPoints[3];
this.PR.TabIndex = 3;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PL = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Back,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[2],
TabIndex = 2,
UseVisualStyleBackColor = true
};
PL.CheckedChanged += Buttons_CheckedChanged;
this.PL = new CheckBox();
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
this.PL.AutoSize = true;
this.PL.Image = global::BizHawk.MultiClient.Properties.Resources.Back;
this.PL.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PL.Location = ButtonPoints[2];
this.PL.TabIndex = 2;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[4],
TabIndex = 5,
Text = "s",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[4];
this.B1.TabIndex = 5;
this.B1.Text = "s";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[5],
TabIndex = 6,
Text = "S",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[5];
this.B2.TabIndex = 6;
this.B2.Text = "S";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B3 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[6],
TabIndex = 7,
Text = "B",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B3.CheckedChanged += Buttons_CheckedChanged;
this.B3 = new CheckBox();
this.B3.Appearance = System.Windows.Forms.Appearance.Button;
this.B3.AutoSize = true;
this.B3.Location = ButtonPoints[6];
this.B3.TabIndex = 7;
this.B3.Text = "B";
this.B3.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B3.UseVisualStyleBackColor = true;
this.B3.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B4 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[7],
TabIndex = 8,
Text = "A",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B4.CheckedChanged += Buttons_CheckedChanged;
this.B4 = new CheckBox();
this.B4.Appearance = System.Windows.Forms.Appearance.Button;
this.B4.AutoSize = true;
this.B4.Location = ButtonPoints[7];
this.B4.TabIndex = 8;
this.B4.Text = "A";
this.B4.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B4.UseVisualStyleBackColor = true;
this.B4.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.Controls.Add(this.PU);
this.Controls.Add(this.PD);
this.Controls.Add(this.PL);
this.Controls.Add(this.PR);
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
this.Controls.Add(this.B3);
this.Controls.Add(this.B4);
Controls.Add(PU);
Controls.Add(PD);
Controls.Add(PL);
Controls.Add(PR);
Controls.Add(B1);
Controls.Add(B2);
Controls.Add(B3);
Controls.Add(B4);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -126,23 +136,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}

View File

@ -1,56 +1,52 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
public class VirtualPadNESControl : VirtualPad
{
public VirtualPadNESControl()
{
ButtonPoints[0] = new Point(2, 2);
ButtonPoints[1] = new Point(56, 2);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(108, 34);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(108, 34);
Point n = new Point(this.Size);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[0],
TabIndex = 5,
Text = "Power",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
B1.ForeColor = Color.Red;
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[1],
TabIndex = 6,
Text = "Reset",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
B2.ForeColor = Color.Red;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[0];
this.B1.TabIndex = 5;
this.B1.Text = "Power";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B1.ForeColor = Color.Red;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[1];
this.B2.TabIndex = 6;
this.B2.Text = "Reset";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B2.ForeColor = Color.Red;
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
Controls.Add(B1);
Controls.Add(B2);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -58,23 +54,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}
@ -121,7 +117,7 @@ namespace BizHawk.MultiClient
else if (sender == B1)
{
Global.StickyXORAdapter.SetSticky("Power", B1.Checked);
if (B1.Checked == true)
if (B1.Checked)
B1.BackColor = Color.Pink;
else
B1.BackColor = SystemColors.Control;
@ -129,7 +125,7 @@ namespace BizHawk.MultiClient
else if (sender == B2)
{
Global.StickyXORAdapter.SetSticky("Reset", B2.Checked);
if (B2.Checked == true)
if (B2.Checked)
B2.BackColor = Color.Pink;
else
B2.BackColor = SystemColors.Control;

View File

@ -1,16 +1,12 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
public class VirtualPadPCE : VirtualPad
{
public VirtualPadPCE()
{
ButtonPoints[0] = new Point(14, 2);
@ -25,100 +21,114 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(174, 74);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(174, 74);
Point n = new Point(this.Size);
PU = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueUp,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[0],
TabIndex = 1,
UseVisualStyleBackColor = true
};
PU.CheckedChanged += Buttons_CheckedChanged;
this.PU = new CheckBox();
this.PU.Appearance = System.Windows.Forms.Appearance.Button;
this.PU.AutoSize = true;
this.PU.Image = global::BizHawk.MultiClient.Properties.Resources.BlueUp;
this.PU.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PU.Location = ButtonPoints[0];
this.PU.TabIndex = 1;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PD = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueDown,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[1],
TabIndex = 4,
UseVisualStyleBackColor = true
};
PD.CheckedChanged += Buttons_CheckedChanged;
this.PD = new CheckBox();
this.PD.Appearance = System.Windows.Forms.Appearance.Button;
this.PD.AutoSize = true;
this.PD.Image = global::BizHawk.MultiClient.Properties.Resources.BlueDown;
this.PD.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PD.Location = ButtonPoints[1];
this.PD.TabIndex = 4;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PR = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Forward,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[3],
TabIndex = 3,
UseVisualStyleBackColor = true
};
PR.CheckedChanged += Buttons_CheckedChanged;
this.PR = new CheckBox();
this.PR.Appearance = System.Windows.Forms.Appearance.Button;
this.PR.AutoSize = true;
this.PR.Image = global::BizHawk.MultiClient.Properties.Resources.Forward;
this.PR.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PR.Location = ButtonPoints[3];
this.PR.TabIndex = 3;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PL = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Back,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[2],
TabIndex = 2,
UseVisualStyleBackColor = true
};
PL.CheckedChanged += Buttons_CheckedChanged;
this.PL = new CheckBox();
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
this.PL.AutoSize = true;
this.PL.Image = global::BizHawk.MultiClient.Properties.Resources.Back;
this.PL.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PL.Location = ButtonPoints[2];
this.PL.TabIndex = 2;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[4],
TabIndex = 5,
Text = "s",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[4];
this.B1.TabIndex = 5;
this.B1.Text = "s";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[5],
TabIndex = 6,
Text = "R",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[5];
this.B2.TabIndex = 6;
this.B2.Text = "R";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B3 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[6],
TabIndex = 7,
Text = "II",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B3.CheckedChanged += Buttons_CheckedChanged;
this.B3 = new CheckBox();
this.B3.Appearance = System.Windows.Forms.Appearance.Button;
this.B3.AutoSize = true;
this.B3.Location = ButtonPoints[6];
this.B3.TabIndex = 7;
this.B3.Text = "II";
this.B3.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B3.UseVisualStyleBackColor = true;
this.B3.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B4 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[7],
TabIndex = 8,
Text = "I",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B4.CheckedChanged += Buttons_CheckedChanged;
this.B4 = new CheckBox();
this.B4.Appearance = System.Windows.Forms.Appearance.Button;
this.B4.AutoSize = true;
this.B4.Location = ButtonPoints[7];
this.B4.TabIndex = 8;
this.B4.Text = "I";
this.B4.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B4.UseVisualStyleBackColor = true;
this.B4.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.Controls.Add(this.PU);
this.Controls.Add(this.PD);
this.Controls.Add(this.PL);
this.Controls.Add(this.PR);
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
this.Controls.Add(this.B3);
this.Controls.Add(this.B4);
Controls.Add(PU);
Controls.Add(PD);
Controls.Add(PL);
Controls.Add(PR);
Controls.Add(B1);
Controls.Add(B2);
Controls.Add(B3);
Controls.Add(B4);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -126,23 +136,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}

View File

@ -1,16 +1,12 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
public class VirtualPadSMS : VirtualPad
{
public VirtualPadSMS()
{
ButtonPoints[0] = new Point(14, 2);
@ -23,80 +19,90 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(174, 74);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(174, 74);
Point n = new Point(this.Size);
PU = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueUp,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[0],
TabIndex = 1,
UseVisualStyleBackColor = true
};
PU.CheckedChanged += Buttons_CheckedChanged;
this.PU = new CheckBox();
this.PU.Appearance = System.Windows.Forms.Appearance.Button;
this.PU.AutoSize = true;
this.PU.Image = global::BizHawk.MultiClient.Properties.Resources.BlueUp;
this.PU.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PU.Location = ButtonPoints[0];
this.PU.TabIndex = 1;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PD = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueDown,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[1],
TabIndex = 4,
UseVisualStyleBackColor = true
};
PD.CheckedChanged += Buttons_CheckedChanged;
this.PD = new CheckBox();
this.PD.Appearance = System.Windows.Forms.Appearance.Button;
this.PD.AutoSize = true;
this.PD.Image = global::BizHawk.MultiClient.Properties.Resources.BlueDown;
this.PD.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PD.Location = ButtonPoints[1];
this.PD.TabIndex = 4;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PR = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Forward,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[3],
TabIndex = 3,
UseVisualStyleBackColor = true
};
PR.CheckedChanged += Buttons_CheckedChanged;
this.PR = new CheckBox();
this.PR.Appearance = System.Windows.Forms.Appearance.Button;
this.PR.AutoSize = true;
this.PR.Image = global::BizHawk.MultiClient.Properties.Resources.Forward;
this.PR.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PR.Location = ButtonPoints[3];
this.PR.TabIndex = 3;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PL = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Back,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[2],
TabIndex = 2,
UseVisualStyleBackColor = true
};
PL.CheckedChanged += Buttons_CheckedChanged;
this.PL = new CheckBox();
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
this.PL.AutoSize = true;
this.PL.Image = global::BizHawk.MultiClient.Properties.Resources.Back;
this.PL.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PL.Location = ButtonPoints[2];
this.PL.TabIndex = 2;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[4],
TabIndex = 5,
Text = "1",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[4];
this.B1.TabIndex = 5;
this.B1.Text = "1";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[5],
TabIndex = 6,
Text = "2",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[5];
this.B2.TabIndex = 6;
this.B2.Text = "2";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.Controls.Add(this.PU);
this.Controls.Add(this.PD);
this.Controls.Add(this.PL);
this.Controls.Add(this.PR);
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
this.Controls.Add(this.B3);
this.Controls.Add(this.B4);
Controls.Add(PU);
Controls.Add(PD);
Controls.Add(PL);
Controls.Add(PR);
Controls.Add(B1);
Controls.Add(B2);
Controls.Add(B3);
Controls.Add(B4);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -104,23 +110,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}

View File

@ -1,16 +1,12 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
public class VirtualPadSMSControl : VirtualPad
{
public VirtualPadSMSControl()
{
ButtonPoints[0] = new Point(2, 2);
@ -19,36 +15,38 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(108, 34);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(108, 34);
Point n = new Point(this.Size);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[0],
TabIndex = 5,
Text = "Pause",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
B1.ForeColor = Color.Red;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[0];
this.B1.TabIndex = 5;
this.B1.Text = "Pause";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B1.ForeColor = Color.Red;
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[1],
TabIndex = 6,
Text = "Reset",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
B2.ForeColor = Color.Red;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[1];
this.B2.TabIndex = 6;
this.B2.Text = "Reset";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B2.ForeColor = Color.Red;
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
Controls.Add(B1);
Controls.Add(B2);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -56,23 +54,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}
@ -105,7 +103,7 @@ namespace BizHawk.MultiClient
else if (sender == B1)
{
Global.StickyXORAdapter.SetSticky("Pause", B1.Checked);
if (B1.Checked == true)
if (B1.Checked)
B1.BackColor = Color.Pink;
else
B1.BackColor = SystemColors.Control;
@ -113,7 +111,7 @@ namespace BizHawk.MultiClient
else if (sender == B2)
{
Global.StickyXORAdapter.SetSticky("Reset", B2.Checked);
if (B2.Checked == true)
if (B2.Checked)
B2.BackColor = Color.Pink;
else
B2.BackColor = SystemColors.Control;

View File

@ -1,16 +1,12 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
public class VirtualPadSNES : VirtualPad
{
public VirtualPadSNES()
{
ButtonPoints[0] = new Point(14, 2);
@ -19,159 +15,177 @@ namespace BizHawk.MultiClient
ButtonPoints[3] = new Point(24, 24);
ButtonPoints[4] = new Point(56, 42);
ButtonPoints[5] = new Point(78, 42);
ButtonPoints[6] = new Point(122, 12); //X
ButtonPoints[7] = new Point(146, 22); //A
ButtonPoints[8] = new Point(110, 34); //Y
ButtonPoints[9] = new Point(134, 48); //B
ButtonPoints[10] = new Point(42, 0); //L
ButtonPoints[11] = new Point(94, 0); //R
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(174, 74);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(174, 74);
Point n = new Point(this.Size);
PU = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueUp,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[0],
TabIndex = 1,
UseVisualStyleBackColor = true
};
PU.CheckedChanged += Buttons_CheckedChanged;
this.PU = new CheckBox();
this.PU.Appearance = System.Windows.Forms.Appearance.Button;
this.PU.AutoSize = true;
this.PU.Image = global::BizHawk.MultiClient.Properties.Resources.BlueUp;
this.PU.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PU.Location = ButtonPoints[0];
this.PU.TabIndex = 1;
this.PU.UseVisualStyleBackColor = true;
this.PU.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PD = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.BlueDown,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[1],
TabIndex = 4,
UseVisualStyleBackColor = true
};
PD.CheckedChanged += Buttons_CheckedChanged;
this.PD = new CheckBox();
this.PD.Appearance = System.Windows.Forms.Appearance.Button;
this.PD.AutoSize = true;
this.PD.Image = global::BizHawk.MultiClient.Properties.Resources.BlueDown;
this.PD.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PD.Location = ButtonPoints[1];
this.PD.TabIndex = 4;
this.PD.UseVisualStyleBackColor = true;
this.PD.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PR = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Forward,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[3],
TabIndex = 3,
UseVisualStyleBackColor = true
};
PR.CheckedChanged += Buttons_CheckedChanged;
this.PR = new CheckBox();
this.PR.Appearance = System.Windows.Forms.Appearance.Button;
this.PR.AutoSize = true;
this.PR.Image = global::BizHawk.MultiClient.Properties.Resources.Forward;
this.PR.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PR.Location = ButtonPoints[3];
this.PR.TabIndex = 3;
this.PR.UseVisualStyleBackColor = true;
this.PR.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
PL = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Image = Properties.Resources.Back,
ImageAlign = ContentAlignment.BottomRight,
Location = ButtonPoints[2],
TabIndex = 2,
UseVisualStyleBackColor = true
};
PL.CheckedChanged += Buttons_CheckedChanged;
this.PL = new CheckBox();
this.PL.Appearance = System.Windows.Forms.Appearance.Button;
this.PL.AutoSize = true;
this.PL.Image = global::BizHawk.MultiClient.Properties.Resources.Back;
this.PL.ImageAlign = System.Drawing.ContentAlignment.BottomRight;
this.PL.Location = ButtonPoints[2];
this.PL.TabIndex = 2;
this.PL.UseVisualStyleBackColor = true;
this.PL.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[4],
TabIndex = 5,
Text = "s",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[4];
this.B1.TabIndex = 5;
this.B1.Text = "s";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[5],
TabIndex = 6,
Text = "S",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[5];
this.B2.TabIndex = 6;
this.B2.Text = "S";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B3 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[9],
TabIndex = 7,
Text = "B",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B3.CheckedChanged += Buttons_CheckedChanged;
this.B3 = new CheckBox();
this.B3.Appearance = System.Windows.Forms.Appearance.Button;
this.B3.AutoSize = true;
this.B3.Location = ButtonPoints[9];
this.B3.TabIndex = 7;
this.B3.Text = "B";
this.B3.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B3.UseVisualStyleBackColor = true;
this.B3.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B4 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[7],
TabIndex = 8,
Text = "A",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B4.CheckedChanged += Buttons_CheckedChanged;
this.B4 = new CheckBox();
this.B4.Appearance = System.Windows.Forms.Appearance.Button;
this.B4.AutoSize = true;
this.B4.Location = ButtonPoints[7];
this.B4.TabIndex = 8;
this.B4.Text = "A";
this.B4.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B4.UseVisualStyleBackColor = true;
this.B4.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B5 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[6],
TabIndex = 8,
Text = "X",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B5.CheckedChanged += Buttons_CheckedChanged;
this.B5 = new CheckBox();
this.B5.Appearance = System.Windows.Forms.Appearance.Button;
this.B5.AutoSize = true;
this.B5.Location = ButtonPoints[6];
this.B5.TabIndex = 8;
this.B5.Text = "X";
this.B5.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B5.UseVisualStyleBackColor = true;
this.B5.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B6 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[8],
TabIndex = 8,
Text = "Y",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B6.CheckedChanged += Buttons_CheckedChanged;
this.B6 = new CheckBox();
this.B6.Appearance = System.Windows.Forms.Appearance.Button;
this.B6.AutoSize = true;
this.B6.Location = ButtonPoints[8];
this.B6.TabIndex = 8;
this.B6.Text = "Y";
this.B6.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B6.UseVisualStyleBackColor = true;
this.B6.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B7 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[10],
TabIndex = 8,
Text = "L",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B7.CheckedChanged += Buttons_CheckedChanged;
this.B7 = new CheckBox();
this.B7.Appearance = System.Windows.Forms.Appearance.Button;
this.B7.AutoSize = true;
this.B7.Location = ButtonPoints[10];
this.B7.TabIndex = 8;
this.B7.Text = "L";
this.B7.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B7.UseVisualStyleBackColor = true;
this.B7.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B8 = new CheckBox();
this.B8.Appearance = System.Windows.Forms.Appearance.Button;
this.B8.AutoSize = true;
this.B8.Location = ButtonPoints[11];
this.B8.TabIndex = 8;
this.B8.Text = "R";
this.B8.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B8.UseVisualStyleBackColor = true;
this.B8.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
B8 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[11],
TabIndex = 8,
Text = "R",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B8.CheckedChanged += Buttons_CheckedChanged;
this.Controls.Add(this.PU);
this.Controls.Add(this.PD);
this.Controls.Add(this.PL);
this.Controls.Add(this.PR);
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
this.Controls.Add(this.B3);
this.Controls.Add(this.B4);
this.Controls.Add(this.B5);
this.Controls.Add(this.B6);
this.Controls.Add(this.B7);
this.Controls.Add(this.B8);
Controls.Add(PU);
Controls.Add(PD);
Controls.Add(PL);
Controls.Add(PR);
Controls.Add(B1);
Controls.Add(B2);
Controls.Add(B3);
Controls.Add(B4);
Controls.Add(B5);
Controls.Add(B6);
Controls.Add(B7);
Controls.Add(B8);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -179,23 +193,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}

View File

@ -1,10 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
@ -20,37 +17,38 @@ namespace BizHawk.MultiClient
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.Fixed3D;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.VirtualPad_Paint);
this.Size = new Size(108, 34);
BorderStyle = BorderStyle.Fixed3D;
Paint += VirtualPad_Paint;
Size = new Size(108, 34);
Point n = new Point(this.Size);
B1 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[0],
TabIndex = 5,
Text = "Power",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B1.CheckedChanged += Buttons_CheckedChanged;
B1.ForeColor = Color.Red;
B2 = new CheckBox
{
Appearance = Appearance.Button,
AutoSize = true,
Location = ButtonPoints[1],
TabIndex = 6,
Text = "Reset",
TextAlign = ContentAlignment.BottomCenter,
UseVisualStyleBackColor = true
};
B2.CheckedChanged += Buttons_CheckedChanged;
B2.ForeColor = Color.Red;
this.B1 = new CheckBox();
this.B1.Appearance = System.Windows.Forms.Appearance.Button;
this.B1.AutoSize = true;
this.B1.Location = ButtonPoints[0];
this.B1.TabIndex = 5;
this.B1.Text = "Power";
this.B1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B1.UseVisualStyleBackColor = true;
this.B1.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B1.ForeColor = Color.Red;
this.B2 = new CheckBox();
this.B2.Appearance = System.Windows.Forms.Appearance.Button;
this.B2.AutoSize = true;
this.B2.Location = ButtonPoints[1];
this.B2.TabIndex = 6;
this.B2.Text = "Reset";
this.B2.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.B2.UseVisualStyleBackColor = true;
this.B2.CheckedChanged += new System.EventHandler(this.Buttons_CheckedChanged);
this.B2.ForeColor = Color.Red;
this.Controls.Add(this.B1);
this.Controls.Add(this.B2);
Controls.Add(B1);
Controls.Add(B2);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
@ -58,23 +56,23 @@ namespace BizHawk.MultiClient
if (keyData == Keys.Up)
{
//TODO: move to next logical key
this.Refresh();
Refresh();
}
else if (keyData == Keys.Down)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Left)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Right)
{
this.Refresh();
Refresh();
}
else if (keyData == Keys.Tab)
{
this.Refresh();
Refresh();
}
return true;
}
@ -129,7 +127,7 @@ namespace BizHawk.MultiClient
else if (sender == B1)
{
Global.StickyXORAdapter.SetSticky("Power", B1.Checked);
if (B1.Checked == true)
if (B1.Checked)
{
B1.BackColor = Color.Pink;
}
@ -141,7 +139,7 @@ namespace BizHawk.MultiClient
else if (sender == B2)
{
Global.StickyXORAdapter.SetSticky("Reset", B2.Checked);
if (B2.Checked == true)
if (B2.Checked)
{
B2.BackColor = Color.Pink;
}

View File

@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
namespace BizHawk.MultiClient
{
/// <summary>
/// An object that represent a ram address and related properties
/// </summary>
@ -195,12 +192,12 @@ namespace BizHawk.MultiClient
public string DiffPrevString
{
get { return DiffToString(this.DiffPrev); }
get { return DiffToString(DiffPrev); }
}
public string DiffLastChangeString
{
get { return DiffToString(this.DiffLastChange); }
get { return DiffToString(DiffLastChange); }
}
#endregion
@ -325,9 +322,9 @@ namespace BizHawk.MultiClient
switch (Type)
{
case TYPE.BYTE:
return (uint)(byte)val;
return (byte)val;
case TYPE.WORD:
return (uint)(ushort)val;
return (ushort)val;
}
return (uint)val;
}
@ -337,9 +334,9 @@ namespace BizHawk.MultiClient
switch (Type)
{
case TYPE.BYTE:
return (int)(sbyte)val;
return (sbyte)val;
case TYPE.WORD:
return (int)(short)val;
return (short)val;
}
return val;
}
@ -504,9 +501,9 @@ namespace BizHawk.MultiClient
private int CompareAddress(Watch Other)
{
if (this.Address < Other.Address)
if (Address < Other.Address)
return -1;
else if (this.Address > Other.Address)
else if (Address > Other.Address)
return 1;
else
return 0;
@ -516,16 +513,16 @@ namespace BizHawk.MultiClient
{
if (Signed == DISPTYPE.SIGNED)
{
if (SignedVal(this.Value) < SignedVal(Other.Value))
if (SignedVal(Value) < SignedVal(Other.Value))
return -1;
else if (SignedVal(this.Value) > SignedVal(Other.Value))
else if (SignedVal(Value) > SignedVal(Other.Value))
return 1;
else
return 0;
}
if (UnsignedVal(this.Value) < UnsignedVal(Other.Value))
if (UnsignedVal(Value) < UnsignedVal(Other.Value))
return -1;
else if (UnsignedVal(this.Value) > UnsignedVal(Other.Value))
else if (UnsignedVal(Value) > UnsignedVal(Other.Value))
return 1;
else
return 0;
@ -535,16 +532,16 @@ namespace BizHawk.MultiClient
{
if (Signed == DISPTYPE.SIGNED)
{
if (SignedVal(this.Prev) < SignedVal(Other.Prev))
if (SignedVal(Prev) < SignedVal(Other.Prev))
return -1;
else if (SignedVal(this.Prev) > SignedVal(Other.Prev))
else if (SignedVal(Prev) > SignedVal(Other.Prev))
return 1;
else
return 0;
}
if (UnsignedVal(this.Prev) < UnsignedVal(Other.Prev))
if (UnsignedVal(Prev) < UnsignedVal(Other.Prev))
return -1;
else if (UnsignedVal(this.Prev) > UnsignedVal(Other.Prev))
else if (UnsignedVal(Prev) > UnsignedVal(Other.Prev))
return 1;
else
return 0;
@ -554,16 +551,16 @@ namespace BizHawk.MultiClient
{
if (Signed == DISPTYPE.SIGNED)
{
if (SignedVal(this.Original) < SignedVal(Other.Original))
if (SignedVal(Original) < SignedVal(Other.Original))
return -1;
else if (SignedVal(this.Original) > SignedVal(Other.Original))
else if (SignedVal(Original) > SignedVal(Other.Original))
return 1;
else
return 0;
}
if (UnsignedVal(this.Original) < UnsignedVal(Other.Original))
if (UnsignedVal(Original) < UnsignedVal(Other.Original))
return -1;
else if (UnsignedVal(this.Original) > UnsignedVal(Other.Original))
else if (UnsignedVal(Original) > UnsignedVal(Other.Original))
return 1;
else
return 0;
@ -573,16 +570,16 @@ namespace BizHawk.MultiClient
{
if (Signed == DISPTYPE.SIGNED)
{
if (SignedVal(this.LastChange) < SignedVal(Other.LastChange))
if (SignedVal(LastChange) < SignedVal(Other.LastChange))
return -1;
else if (SignedVal(this.LastChange) > SignedVal(Other.LastChange))
else if (SignedVal(LastChange) > SignedVal(Other.LastChange))
return 1;
else
return 0;
}
if (UnsignedVal(this.LastChange) < UnsignedVal(Other.LastChange))
if (UnsignedVal(LastChange) < UnsignedVal(Other.LastChange))
return -1;
else if (UnsignedVal(this.LastChange) > UnsignedVal(Other.LastChange))
else if (UnsignedVal(LastChange) > UnsignedVal(Other.LastChange))
return 1;
else
return 0;
@ -592,16 +589,16 @@ namespace BizHawk.MultiClient
{
if (Signed == DISPTYPE.SIGNED)
{
if (SignedVal(this.LastSearch) < SignedVal(Other.LastSearch))
if (SignedVal(LastSearch) < SignedVal(Other.LastSearch))
return -1;
else if (SignedVal(this.LastSearch) > SignedVal(Other.LastSearch))
else if (SignedVal(LastSearch) > SignedVal(Other.LastSearch))
return 1;
else
return 0;
}
if (UnsignedVal(this.LastSearch) < UnsignedVal(Other.LastSearch))
if (UnsignedVal(LastSearch) < UnsignedVal(Other.LastSearch))
return -1;
else if (UnsignedVal(this.LastSearch) > UnsignedVal(Other.LastSearch))
else if (UnsignedVal(LastSearch) > UnsignedVal(Other.LastSearch))
return 1;
else
return 0;
@ -609,9 +606,9 @@ namespace BizHawk.MultiClient
private int CompareDiffPrev(Watch Other)
{
if (this.DiffPrev < Other.DiffPrev)
if (DiffPrev < Other.DiffPrev)
return -1;
else if (this.DiffPrev > Other.DiffPrev)
else if (DiffPrev > Other.DiffPrev)
return 1;
else
return 0;
@ -619,9 +616,9 @@ namespace BizHawk.MultiClient
private int CompareDiffOriginal(Watch Other)
{
if (this.DiffOriginal < Other.DiffOriginal)
if (DiffOriginal < Other.DiffOriginal)
return -1;
else if (this.DiffOriginal > Other.DiffOriginal)
else if (DiffOriginal > Other.DiffOriginal)
return 1;
else
return 0;
@ -629,9 +626,9 @@ namespace BizHawk.MultiClient
private int CompareDiffLastChange(Watch Other)
{
if (this.DiffLastChange < Other.DiffLastChange)
if (DiffLastChange < Other.DiffLastChange)
return -1;
else if (this.DiffLastChange > Other.DiffLastChange)
else if (DiffLastChange > Other.DiffLastChange)
return 1;
else
return 0;
@ -639,9 +636,9 @@ namespace BizHawk.MultiClient
private int CompareDiffLastSearch(Watch Other)
{
if (this.DiffLastSearch < Other.DiffLastSearch)
if (DiffLastSearch < Other.DiffLastSearch)
return -1;
else if (this.DiffLastSearch > Other.DiffLastSearch)
else if (DiffLastSearch > Other.DiffLastSearch)
return 1;
else
return 0;
@ -649,9 +646,9 @@ namespace BizHawk.MultiClient
private int CompareChanges(Watch Other)
{
if (this.Changecount < Other.Changecount)
if (Changecount < Other.Changecount)
return -1;
else if (this.Changecount > Other.Changecount)
else if (Changecount > Other.Changecount)
return 1;
else
return 0;
@ -659,23 +656,23 @@ namespace BizHawk.MultiClient
private int CompareNotes(Watch Other)
{
if (this.Notes == null & Other.Notes == null)
if (Notes == null & Other.Notes == null)
return 0;
else if (this.Notes == null)
else if (Notes == null)
return -1;
else if (Other.Notes == null)
return 1;
else
return this.Notes.CompareTo(Other.Notes);
return Notes.CompareTo(Other.Notes);
}
private int CompareDomain(Watch Other)
{
if (this.Domain == null & Other.Domain == null)
if (Domain == null & Other.Domain == null)
{
return 0;
}
else if (this.Domain == null)
else if (Domain == null)
{
return -1;
}
@ -685,7 +682,7 @@ namespace BizHawk.MultiClient
}
else
{
return this.Domain.Name.CompareTo(Other.Domain.Name);
return Domain.Name.CompareTo(Other.Domain.Name);
}
}

View File

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
@ -15,8 +11,6 @@ namespace BizHawk.MultiClient
{
public static bool SaveWchFile(string path, string domain_name, List<Watch> watchList)
{
var file = new FileInfo(path);
using (StreamWriter sw = new StreamWriter(path))
{
StringBuilder str = new StringBuilder();
@ -27,16 +21,16 @@ namespace BizHawk.MultiClient
str.Append(Global.Emulator.SystemId);
str.Append('\n');
for (int x = 0; x < watchList.Count; x++)
foreach (Watch t in watchList)
{
str.Append(string.Format("{0:X4}", watchList[x].Address));
str.Append(string.Format("{0:X4}", t.Address));
str.Append('\t');
str.Append(watchList[x].TypeChar);
str.Append(t.TypeChar);
str.Append('\t');
str.Append(watchList[x].SignedChar);
str.Append(t.SignedChar);
str.Append('\t');
if (watchList[x].BigEndian == true)
if (t.BigEndian)
{
str.Append("1\t");
}
@ -44,9 +38,9 @@ namespace BizHawk.MultiClient
{
str.Append("0\t");
}
str.Append(watchList[x].Domain.Name);
str.Append(t.Domain.Name);
str.Append('\t');
str.Append(watchList[x].Notes);
str.Append(t.Notes);
str.Append('\n');
}
@ -58,16 +52,13 @@ namespace BizHawk.MultiClient
public static bool LoadWatchFile(string path, bool append, List<Watch> watchList, out string domain)
{
domain = "";
int y, z;
var file = new FileInfo(path);
if (file.Exists == false) return false;
bool isBizHawkWatch = true; //Hack to support .wch files from other emulators
bool isOldBizHawkWatch = false;
using (StreamReader sr = file.OpenText())
{
int count = 0;
string s = "";
string temp = "";
string s;
if (append == false)
{
@ -93,7 +84,8 @@ namespace BizHawk.MultiClient
if (s.Length >= 8 && s.Substring(0, 8) == "SystemID")
continue;
z = StringHelpers.HowMany(s, '\t');
int z = StringHelpers.HowMany(s, '\t');
int y;
if (z == 5)
{
//If 5, then this is a post 1.0.5 .wch file
@ -115,10 +107,9 @@ namespace BizHawk.MultiClient
{
continue; //If not 4, something is wrong with this line, ignore it
}
count++;
Watch w = new Watch();
temp = s.Substring(0, s.IndexOf('\t'));
string temp = s.Substring(0, s.IndexOf('\t'));
try
{
w.Address = int.Parse(temp, NumberStyles.HexNumber);