Revert "Cleanup GameShark.Designer.cs"

This reverts commit 9864d8190c, reversing
changes made to 0630be922b.
This commit is contained in:
zeromus 2015-11-14 15:11:13 -06:00
parent 9864d8190c
commit fae4d27bed
7 changed files with 66 additions and 19 deletions

View File

@ -3979,6 +3979,8 @@ namespace BizHawk.Client.EmuHawk
private void gameSharkConverterToolStripMenuItem_Click(object sender, EventArgs e)
{
//TODO:
//Wire up the Connection to the Object
GlobalWin.Tools.Load<GameShark>();
}

View File

@ -1,16 +1,19 @@
using System;
using System.Drawing;
using System.Collections.Generic;
namespace BizHawk.Client.EmuHawk
{
[AttributeUsage(AttributeTargets.Class)]
public class ToolAttributes : Attribute
{
public ToolAttributes(bool released)
public ToolAttributes(bool released, string[] supportedSystems)
{
Released = released;
SupportedSystems = supportedSystems;
}
public bool Released { get; private set; }
public IEnumerable<string> SupportedSystems { get; private set; }
}
}

View File

@ -11,7 +11,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
[ToolAttributes(released: false)]
[ToolAttributes(released: false, supportedSystems: null)]
public partial class AutoHawk : Form, IToolFormAutoConfig
{
public AutoHawk()

View File

@ -13,7 +13,6 @@ using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
[ToolAttributes(released: true)]
public partial class GenericDebugger : Form, IToolFormAutoConfig, IControlMainform
{
public GenericDebugger()

View File

@ -50,7 +50,7 @@
this.btnClear.Location = new System.Drawing.Point(141, 132);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(75, 23);
this.btnClear.TabIndex = 4;
this.btnClear.TabIndex = 16;
this.btnClear.Text = "Clear";
this.btnClear.UseVisualStyleBackColor = true;
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
@ -69,14 +69,14 @@
this.txtCheat.Location = new System.Drawing.Point(128, 106);
this.txtCheat.Name = "txtCheat";
this.txtCheat.Size = new System.Drawing.Size(100, 20);
this.txtCheat.TabIndex = 2;
this.txtCheat.TabIndex = 10;
//
// btnGo
//
this.btnGo.Location = new System.Drawing.Point(35, 131);
this.btnGo.Name = "btnGo";
this.btnGo.Size = new System.Drawing.Size(75, 23);
this.btnGo.TabIndex = 3;
this.btnGo.TabIndex = 9;
this.btnGo.Text = "Convert";
this.btnGo.UseVisualStyleBackColor = true;
this.btnGo.Click += new System.EventHandler(this.btnGo_Click);
@ -95,7 +95,7 @@
this.txtDescription.Location = new System.Drawing.Point(22, 106);
this.txtDescription.Name = "txtDescription";
this.txtDescription.Size = new System.Drawing.Size(100, 20);
this.txtDescription.TabIndex = 1;
this.txtDescription.TabIndex = 18;
//
// GameShark
//

View File

@ -1,17 +1,20 @@
using System;
using System.Windows.Forms;
using BizHawk.Emulation.Common;
//Using the GameBoy Core Directly, is an issue with the limitations for what this tool does.
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Client.Common;
using System.Globalization;
namespace BizHawk.Client.EmuHawk
{
[ToolAttributes(released: true, supportedSystems: new[] { "GB" })]
public partial class GameShark : Form, IToolForm, IToolFormAutoConfig
{
[ToolAttributes(released: true, supportedSystems: new[] { "GB" })]
//We are using Memory Domains, so we NEED this.
[RequiredService]
private IMemoryDomains MemoryDomains { get; set; }
public GameShark()
{
InitializeComponent();
@ -32,7 +35,7 @@ namespace BizHawk.Client.EmuHawk
public void FastUpdate()
{
throw new NotImplementedException();
}
public void Restart()
@ -71,8 +74,8 @@ namespace BizHawk.Client.EmuHawk
RAMAddress = RAMAddress + parseString.Remove(2, 2);
//We now have our values.
//This part, is annoying...
try
{
//try
//{
//A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works.
//System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description. Not Big Endian.
var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Byte, Watch.DisplayType.Hex, txtDescription.Text, false);
@ -81,11 +84,11 @@ namespace BizHawk.Client.EmuHawk
//Clear old Inputs
txtCheat.Clear();
txtDescription.Clear();
}
catch (Exception ex)
/*}
catch
{
MessageBox.Show("An Error occured:" + ex.GetType().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
MessageBox.Show("An Error occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} */
}
private void btnClear_Click(object sender, EventArgs e)
@ -94,5 +97,10 @@ namespace BizHawk.Client.EmuHawk
txtCheat.Clear();
txtDescription.Clear();
}
private void GameShark_Load(object sender, EventArgs e)
{
}
}
}

View File

@ -43,10 +43,14 @@ namespace BizHawk.Client.EmuHawk
public IToolForm Load(Type toolType, bool focus = true)
{
if (!typeof(IToolForm).IsAssignableFrom(toolType))
throw new ArgumentException(String.Format("Type {0} does not implement IToolForm.", toolType.Name));
{
throw new ArgumentException(string.Format("Type {0} does not implement IToolForm.", toolType.Name));
}
if (!ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, toolType))
if (!IsAvailable(toolType))
{
return null;
}
var existingTool = _tools.FirstOrDefault(x => toolType.IsAssignableFrom(x.GetType()));
@ -63,6 +67,7 @@ namespace BizHawk.Client.EmuHawk
existingTool.Show();
existingTool.Focus();
}
return existingTool;
}
}
@ -580,7 +585,37 @@ namespace BizHawk.Client.EmuHawk
public bool IsAvailable(Type t)
{
return ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, t);
if (!ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, t))
{
return false;
}
var tool = Assembly
.GetAssembly(typeof(IToolForm))
.GetTypes()
.FirstOrDefault(type => type == t);
if (tool == null) // This isn't a tool, must not be available
{
return false;
}
var attr = tool.GetCustomAttributes(false)
.OfType<ToolAttributes>()
.FirstOrDefault();
if (attr == null) // If no attributes there is no supported systems documented so assume all
{
return true;
}
// If no supported systems mentioned assume all
if (attr.SupportedSystems != null && attr.SupportedSystems.Any())
{
return attr.SupportedSystems.Contains(Global.Emulator.SystemId);
}
return true;
}
// Eventually we want a single game genie tool, then this mess goes away