diff --git a/BizHawk.Client.ApiHawk/Attributes/BizHawkExternalToolUsageAttribute.cs b/BizHawk.Client.ApiHawk/Attributes/BizHawkExternalToolUsageAttribute.cs
new file mode 100644
index 0000000000..5526e4878e
--- /dev/null
+++ b/BizHawk.Client.ApiHawk/Attributes/BizHawkExternalToolUsageAttribute.cs
@@ -0,0 +1,72 @@
+using System;
+
+namespace BizHawk.Client.ApiHawk
+{
+ ///
+ /// This class hold logic interraction for the BizHawkExternalToolUsageAttribute
+ /// This attribute helps ApiHawk to know how a tool can be enabled or not
+ ///
+ [AttributeUsage(AttributeTargets.Assembly)]
+ public sealed class BizHawkExternalToolUsageAttribute : Attribute
+ {
+ #region Fields
+
+ private BizHawkExternalToolUsage _ToolUsage;
+ private string _Parameter;
+
+ #endregion
+
+ #region cTor(s)
+
+ ///
+ /// Initialize a new instance of
+ ///
+ /// i.e. what your external tool is for
+ /// The parameter; either emulator type or game hash depending of what you want to do
+ public BizHawkExternalToolUsageAttribute(BizHawkExternalToolUsage usage, string parameter)
+ {
+ _ToolUsage = usage;
+ if(usage != BizHawkExternalToolUsage.Global && parameter.Trim() == string.Empty)
+ {
+ throw new InvalidOperationException("You must specify the parameter. Either emulator type or game hash depending of what you want to do");
+ }
+ _Parameter = parameter;
+ }
+
+ ///
+ /// Initialize a new instance of
+ ///
+ public BizHawkExternalToolUsageAttribute()
+ :this(BizHawkExternalToolUsage.Global, string.Empty)
+ { }
+
+
+ #endregion
+
+ #region Properties
+
+ ///
+ /// Gets the tool usage
+ ///
+ public BizHawkExternalToolUsage ToolUsage
+ {
+ get
+ {
+ return _ToolUsage;
+ }
+ }
+
+ ///
+ /// Gets the parameter (Emulator or Game hash)
+ ///
+ public string Parameter
+ {
+ get
+ {
+ return _Parameter;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj
index 1e0d0a9d16..e3cef06e45 100644
--- a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj
+++ b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj
@@ -96,7 +96,10 @@
+
+
+
diff --git a/BizHawk.Client.ApiHawk/Classes/BizHawkExternalToolUsage.cs b/BizHawk.Client.ApiHawk/Classes/BizHawkExternalToolUsage.cs
new file mode 100644
index 0000000000..5ba308b4c2
--- /dev/null
+++ b/BizHawk.Client.ApiHawk/Classes/BizHawkExternalToolUsage.cs
@@ -0,0 +1,21 @@
+namespace BizHawk.Client.ApiHawk
+{
+ ///
+ /// This enum describe how an external tool is handled
+ ///
+ public enum BizHawkExternalToolUsage : short
+ {
+ ///
+ /// General usage, works even with null emulator
+ ///
+ Global = 0,
+ ///
+ /// Specific to an emulator (NES,SNES,etc...)
+ ///
+ EmulatorSpecific = 1,
+ ///
+ /// Specific to a Game
+ ///
+ GameSpecific = 2
+ }
+}
diff --git a/BizHawk.Client.ApiHawk/Classes/ClientApi.cs b/BizHawk.Client.ApiHawk/Classes/ClientApi.cs
new file mode 100644
index 0000000000..f8bb767db1
--- /dev/null
+++ b/BizHawk.Client.ApiHawk/Classes/ClientApi.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Reflection;
+
+namespace BizHawk.Client.ApiHawk
+{
+ ///
+ /// This class contains some methods that
+ /// interract with BizHawk client
+ ///
+ public static class ClientApi
+ {
+ #region Fields
+
+ private static readonly Assembly clientAssembly;
+
+ public static event EventHandler RomLoaded;
+
+ #endregion
+
+ #region cTor(s)
+
+ static ClientApi()
+ {
+ clientAssembly = Assembly.GetEntryAssembly();
+ }
+
+ #endregion
+
+ #region Methods
+
+ ///
+ /// Raise when a rom is successfully Loaded
+ ///
+ public static void OnRomLoaded()
+ {
+ if(RomLoaded != null)
+ {
+ RomLoaded(null, EventArgs.Empty);
+ }
+ }
+
+ ///
+ /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements
+ ///
+ /// Left padding
+ /// Top padding
+ /// Right padding
+ /// Bottom padding
+ public static void SetExtraPadding(int left, int top, int right, int bottom)
+ {
+ Type emuLuaLib = clientAssembly.GetType("BizHawk.Client.EmuHawk.EmuHawkLuaLibrary");
+ MethodInfo paddingMethod = emuLuaLib.GetMethod("SetClientExtraPadding");
+ paddingMethod.Invoke(paddingMethod, new object[] { left, top, right, bottom });
+ }
+
+ ///
+ /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements
+ ///
+ /// Left padding
+ public static void SetExtraPadding(int left)
+ {
+ SetExtraPadding(left, 0, 0, 0);
+ }
+
+ ///
+ /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements
+ ///
+ /// Left padding
+ /// Top padding
+ public static void SetExtraPadding(int left, int top)
+ {
+ SetExtraPadding(left, top, 0, 0);
+ }
+
+ ///
+ /// Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements
+ ///
+ /// Left padding
+ /// Top padding
+ /// Right padding
+ public static void SetExtraPadding(int left, int top, int right)
+ {
+ SetExtraPadding(left, top, right, 0);
+ }
+
+ #endregion
+ }
+}
diff --git a/BizHawk.Client.ApiHawk/Classes/ExternalToolManager.cs b/BizHawk.Client.ApiHawk/Classes/ExternalToolManager.cs
index 631d789319..169fa47a6a 100644
--- a/BizHawk.Client.ApiHawk/Classes/ExternalToolManager.cs
+++ b/BizHawk.Client.ApiHawk/Classes/ExternalToolManager.cs
@@ -8,7 +8,6 @@ using System.Reflection;
using System.Windows.Forms;
using BizHawk.Client.Common;
-using BizHawk.Client.EmuHawk;
namespace BizHawk.Client.ApiHawk
{
@@ -42,6 +41,8 @@ namespace BizHawk.Client.ApiHawk
directoryMonitor.Created += new FileSystemEventHandler(DirectoryMonitor_Created);
directoryMonitor.EnableRaisingEvents = true;
+ ClientApi.RomLoaded += delegate { BuildToolStrip(); };
+
BuildToolStrip();
}
@@ -105,6 +106,27 @@ namespace BizHawk.Client.ApiHawk
item.Enabled = false;
}
item.Tag = fileName;
+
+ attributes = externalToolFile.GetCustomAttributes(typeof(BizHawkExternalToolUsageAttribute), false);
+ if (attributes != null && attributes.Count() == 1)
+ {
+ BizHawkExternalToolUsageAttribute attribute2 = (BizHawkExternalToolUsageAttribute)attributes[0];
+ if(Global.Emulator.SystemId == "NULL" && attribute2.ToolUsage != BizHawkExternalToolUsage.Global)
+ {
+ item.ToolTipText = "This tool doesn't work if nothing is loaded";
+ item.Enabled = false;
+ }
+ else if(attribute2.ToolUsage == BizHawkExternalToolUsage.EmulatorSpecific && Global.Emulator.SystemId != attribute2.Parameter)
+ {
+ item.ToolTipText = "This tool doesn't work for current system";
+ item.Enabled = false;
+ }
+ else if (attribute2.ToolUsage == BizHawkExternalToolUsage.GameSpecific && Global.Game.Hash != attribute2.Parameter)
+ {
+ item.ToolTipText = "This tool doesn't work for current game";
+ item.Enabled = false;
+ }
+ }
}
else
{
diff --git a/BizHawk.Client.ApiHawk/Interfaces/IExternalToolForm.cs b/BizHawk.Client.ApiHawk/Interfaces/IExternalToolForm.cs
index f8116f705c..2d920e52fc 100644
--- a/BizHawk.Client.ApiHawk/Interfaces/IExternalToolForm.cs
+++ b/BizHawk.Client.ApiHawk/Interfaces/IExternalToolForm.cs
@@ -1,16 +1,10 @@
-using System;
-using System.Windows.Forms;
-
-namespace BizHawk.Client.EmuHawk
+namespace BizHawk.Client.EmuHawk
{
///
/// Interface to implements in order to make a custom tool
///
public interface IExternalToolForm : IToolForm
{
- ///
- ///
- ///
- event FormClosedEventHandler FormClosed;
+
}
}
diff --git a/BizHawk.Client.ApiHawk/Properties/AssemblyInfo.cs b/BizHawk.Client.ApiHawk/Properties/AssemblyInfo.cs
index 66ceacbb35..53f24b5e3c 100644
--- a/BizHawk.Client.ApiHawk/Properties/AssemblyInfo.cs
+++ b/BizHawk.Client.ApiHawk/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]
diff --git a/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd b/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd
index 669f44d4a3..636d153226 100644
--- a/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd
+++ b/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd
@@ -50,10 +50,24 @@
Attributes\ExternalToolAttribute.cs
+
+
+
+ AAEAAAAAAAAAAAAAAAAAQAIAAAAAACAAAAAAAAAAAAA=
+ Classes\ClientApi.cs
+
+
+
+
+
+ AIAAAAAAEAAAAAAAAAAAAAAAAAAQAACAAAAAAAAAAAA=
+ Attributes\BizHawkExternalToolUsageAttribute.cs
+
+
- gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
Interfaces\IExternalToolForm.cs
@@ -77,5 +91,12 @@
+
+
+
+ AAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAgAAAABAAA=
+ Classes\BizHawkExternalToolUsage.cs
+
+
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs
index d9c1f2b482..e4a81cec06 100644
--- a/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.cs
@@ -3492,6 +3492,7 @@ namespace BizHawk.Client.EmuHawk
Console.WriteLine(" {0} : {1}", f.FirmwareId, f.Hash);
}
}
+ ApiHawk.ClientApi.OnRomLoaded();
return true;
}
else
@@ -3502,6 +3503,7 @@ namespace BizHawk.Client.EmuHawk
//The ROM has been loaded by a recursive invocation of the LoadROM method.
if (!(Global.Emulator is NullEmulator))
{
+ ApiHawk.ClientApi.OnRomLoaded();
return true;
}