2007-06-26 06:01:52 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Text;
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2008-05-29 11:34:01 +00:00
|
|
|
namespace CodeImp.DoomBuilder.Actions
|
2007-06-26 06:01:52 +00:00
|
|
|
{
|
2008-01-05 18:11:29 +00:00
|
|
|
/// <summary>
|
|
|
|
/// This binds a method to an action.
|
|
|
|
/// </summary>
|
2008-04-27 12:07:26 +00:00
|
|
|
[AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
|
2007-10-24 17:25:03 +00:00
|
|
|
public class ActionAttribute : Attribute
|
2007-06-26 06:01:52 +00:00
|
|
|
{
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// The action to bind to
|
2008-04-27 12:07:26 +00:00
|
|
|
protected string action;
|
|
|
|
protected bool baseaction;
|
|
|
|
|
2007-06-26 06:01:52 +00:00
|
|
|
#endregion
|
|
|
|
|
2008-01-02 21:49:43 +00:00
|
|
|
#region ================== Properties
|
|
|
|
|
2008-01-05 18:11:29 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Set to true to indicate this is a core Doom Builder action when used within a plugin.
|
|
|
|
/// </summary>
|
2008-01-02 21:49:43 +00:00
|
|
|
public bool BaseAction { get { return baseaction; } set { baseaction = value; } }
|
2008-04-27 12:07:26 +00:00
|
|
|
internal string ActionName { get { return action; } }
|
2008-01-02 21:49:43 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2007-06-26 06:01:52 +00:00
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
2008-01-05 18:11:29 +00:00
|
|
|
/// <summary>
|
|
|
|
/// This binds a method to an action.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="action">The action name as defined in Actions.cfg resource.</param>
|
2007-06-26 06:01:52 +00:00
|
|
|
public ActionAttribute(string action)
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
this.action = action;
|
2008-01-02 21:49:43 +00:00
|
|
|
this.baseaction = false;
|
2007-06-26 06:01:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2008-01-02 21:49:43 +00:00
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// This makes the proper name
|
|
|
|
public string GetFullActionName(Assembly asm)
|
|
|
|
{
|
|
|
|
string asmname;
|
2008-04-27 12:07:26 +00:00
|
|
|
|
2008-01-02 21:49:43 +00:00
|
|
|
if(baseaction)
|
|
|
|
asmname = General.ThisAssembly.GetName().Name.ToLowerInvariant();
|
|
|
|
else
|
|
|
|
asmname = asm.GetName().Name.ToLowerInvariant();
|
2008-04-27 12:07:26 +00:00
|
|
|
|
2008-01-02 21:49:43 +00:00
|
|
|
return asmname + "_" + action;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This makes the proper name
|
|
|
|
public string GetFullActionName(Assembly asm, bool baseaction, string actionname)
|
|
|
|
{
|
|
|
|
string asmname;
|
|
|
|
|
|
|
|
if(baseaction)
|
|
|
|
asmname = General.ThisAssembly.GetName().Name.ToLowerInvariant();
|
|
|
|
else
|
|
|
|
asmname = asm.GetName().Name.ToLowerInvariant();
|
|
|
|
|
|
|
|
return asmname + "_" + actionname;
|
|
|
|
}
|
|
|
|
|
2007-06-26 06:01:52 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|