mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
little refactoring to expose some of the ActionManager to plugins
This commit is contained in:
parent
4cbf7e6f0f
commit
1a4b588f44
11 changed files with 24 additions and 46 deletions
|
@ -32,7 +32,7 @@ using System.Windows.Forms;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Actions
|
||||
{
|
||||
internal class ActionManager
|
||||
public class ActionManager
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -62,8 +62,8 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
|
||||
#region ================== Properties
|
||||
|
||||
public SortedDictionary<string, string> Categories { get { return categories; } }
|
||||
public Action this[string action] { get { if(actions.ContainsKey(action)) return actions[action]; else throw new ArgumentException("There is no such action \"" + action + "\""); } }
|
||||
internal SortedDictionary<string, string> Categories { get { return categories; } }
|
||||
internal Action this[string action] { get { if(actions.ContainsKey(action)) return actions[action]; else throw new ArgumentException("There is no such action \"" + action + "\""); } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
||||
#endregion
|
||||
|
@ -71,7 +71,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public ActionManager()
|
||||
internal ActionManager()
|
||||
{
|
||||
// Initialize
|
||||
General.WriteLogLine("Starting action manager...");
|
||||
|
@ -88,7 +88,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
|
||||
// Disposer
|
||||
public void Dispose()
|
||||
internal void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
|
@ -105,7 +105,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
#region ================== Actions
|
||||
|
||||
// This loads all actions from an assembly
|
||||
public void LoadActions(Assembly asm)
|
||||
internal void LoadActions(Assembly asm)
|
||||
{
|
||||
Stream actionsdata;
|
||||
StreamReader actionsreader;
|
||||
|
@ -392,7 +392,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
|
||||
// This returns a list of all actions
|
||||
public Action[] GetAllActions()
|
||||
internal Action[] GetAllActions()
|
||||
{
|
||||
Action[] list = new Action[actions.Count];
|
||||
actions.Values.CopyTo(list, 0);
|
||||
|
@ -406,7 +406,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
|
||||
// This saves the control settings
|
||||
public void SaveSettings()
|
||||
internal void SaveSettings()
|
||||
{
|
||||
// Go for all actions
|
||||
foreach(KeyValuePair<string, Action> a in actions)
|
||||
|
@ -435,7 +435,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
#region ================== Shortcut Keys
|
||||
|
||||
// This applies default keys if they are not already in use
|
||||
public void ApplyDefaultShortcutKeys()
|
||||
internal void ApplyDefaultShortcutKeys()
|
||||
{
|
||||
// Find actions that have no key set
|
||||
foreach(KeyValuePair<string, Action> a in actions)
|
||||
|
@ -487,7 +487,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
|
||||
// Removes all shortcut keys
|
||||
public void RemoveShortcutKeys()
|
||||
internal void RemoveShortcutKeys()
|
||||
{
|
||||
// Clear all keys
|
||||
foreach(KeyValuePair<string, Action> a in actions)
|
||||
|
@ -495,7 +495,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
|
||||
// This notifies a key has been pressed
|
||||
public void KeyPressed(int key)
|
||||
internal void KeyPressed(int key)
|
||||
{
|
||||
int strippedkey = key & ~((int)Keys.Alt | (int)Keys.Shift | (int)Keys.Control);
|
||||
if((strippedkey == (int)Keys.ShiftKey) || (strippedkey == (int)Keys.ControlKey)) key = strippedkey;
|
||||
|
@ -513,7 +513,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
|
||||
// This notifies a key has been released
|
||||
public void KeyReleased(int key)
|
||||
internal void KeyReleased(int key)
|
||||
{
|
||||
int strippedkey = key & ~((int)Keys.Alt | (int)Keys.Shift | (int)Keys.Control);
|
||||
List<Action> keepactions = new List<Action>();
|
||||
|
@ -526,7 +526,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
|
||||
// This releases all pressed keys
|
||||
public void ReleaseAllKeys()
|
||||
internal void ReleaseAllKeys()
|
||||
{
|
||||
// Clear pressed keys
|
||||
pressedkeys.Clear();
|
||||
|
@ -536,7 +536,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
|
||||
// This updates the modifiers
|
||||
public void UpdateModifiers(int mods)
|
||||
internal void UpdateModifiers(int mods)
|
||||
{
|
||||
// Update modifiers
|
||||
modifiers = mods;
|
||||
|
@ -546,7 +546,7 @@ namespace CodeImp.DoomBuilder.Actions
|
|||
}
|
||||
|
||||
// This will call the associated actions for a keypress
|
||||
private void BeginActionByKey(int key, bool repeated)
|
||||
internal void BeginActionByKey(int key, bool repeated)
|
||||
{
|
||||
// Get all actions for which a begin is bound
|
||||
List<Action> boundactions = new List<Action>(actions.Count);
|
||||
|
|
|
@ -117,9 +117,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(e.Button == MouseButtons.XButton2) k = (int)Keys.XButton2;
|
||||
|
||||
// Double select-click? Make that the same as single edit-click
|
||||
if(General.Interface.GetActionByFullName("builder_classicselect").KeyMatches(k))
|
||||
if(General.Actions.GetActionByName("builder_classicselect").KeyMatches(k))
|
||||
{
|
||||
Action a = General.Interface.GetActionByFullName("builder_classicedit");
|
||||
Action a = General.Actions.GetActionByName("builder_classicedit");
|
||||
if(a != null) a.Invoke();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -408,7 +408,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.OnDragStart(e);
|
||||
|
||||
// Edit button used?
|
||||
if(General.Interface.CheckActionActive(null, "classicedit"))
|
||||
if(General.Actions.CheckActionActive(null, "classicedit"))
|
||||
{
|
||||
// Anything highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
|
|
|
@ -534,7 +534,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.OnDragStart(e);
|
||||
|
||||
// Edit button used?
|
||||
if(General.Interface.CheckActionActive(null, "classicedit"))
|
||||
if(General.Actions.CheckActionActive(null, "classicedit"))
|
||||
{
|
||||
// Anything highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
|
|
|
@ -404,7 +404,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.OnDragStart(e);
|
||||
|
||||
// Edit button used?
|
||||
if(General.Interface.CheckActionActive(null, "classicedit"))
|
||||
if(General.Actions.CheckActionActive(null, "classicedit"))
|
||||
{
|
||||
// Anything highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
|
|
|
@ -349,7 +349,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.OnDragStart(e);
|
||||
|
||||
// Edit button used?
|
||||
if(General.Interface.CheckActionActive(null, "classicedit"))
|
||||
if(General.Actions.CheckActionActive(null, "classicedit"))
|
||||
{
|
||||
// Anything highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
|
|
|
@ -263,7 +263,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
bool front, back;
|
||||
|
||||
// Edit button is used?
|
||||
if(General.Interface.CheckActionActive(null, "classicedit"))
|
||||
if(General.Actions.CheckActionActive(null, "classicedit"))
|
||||
{
|
||||
// Item highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
|
|
|
@ -291,7 +291,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
else
|
||||
{
|
||||
// Select button pressed?
|
||||
if(General.Interface.CheckActionActive(General.ThisAssembly, "visualselect"))
|
||||
if(General.Actions.CheckActionActive(General.ThisAssembly, "visualselect"))
|
||||
{
|
||||
// Check if tolerance is exceeded to start UV dragging
|
||||
float deltaxy = mode.CameraAngleXY - dragstartanglexy;
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace CodeImp.DoomBuilder
|
|||
internal static List<CompilerInfo> Compilers { get { return compilers; } }
|
||||
internal static Dictionary<string, ScriptConfiguration> ScriptConfigs { get { return scriptconfigs; } }
|
||||
public static MapManager Map { get { return map; } }
|
||||
internal static ActionManager Actions { get { return actions; } }
|
||||
public static ActionManager Actions { get { return actions; } }
|
||||
internal static PluginManager Plugins { get { return plugins; } }
|
||||
public static Clock Clock { get { return clock; } }
|
||||
public static bool DebugBuild { get { return debugbuild; } }
|
||||
|
|
|
@ -70,7 +70,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
void StopExclusiveMouseInput();
|
||||
void BreakExclusiveMouseInput();
|
||||
void ResumeExclusiveMouseInput();
|
||||
bool CheckActionActive(Assembly assembly, string actionname);
|
||||
void SetCursor(Cursor cursor);
|
||||
void DisplayWarning(string warning);
|
||||
void HideWarning();
|
||||
|
@ -124,8 +123,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
/// <param name="e">Unused.</param>
|
||||
void InvokeTaggedAction(object sender, EventArgs e);
|
||||
|
||||
Action GetActionByFullName(string fullname);
|
||||
|
||||
void AddButton(ToolStripItem button);
|
||||
void RemoveButton(ToolStripItem button);
|
||||
}
|
||||
|
|
|
@ -280,16 +280,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.Update();
|
||||
}
|
||||
|
||||
// This returns the action for a given name
|
||||
// Returns null when the action does not exists
|
||||
public Action GetActionByFullName(string fullname)
|
||||
{
|
||||
if(General.Actions.Exists(fullname))
|
||||
return General.Actions.GetActionByName(fullname);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Window
|
||||
|
@ -1002,15 +992,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
#endregion
|
||||
|
||||
#region ================== Input
|
||||
|
||||
// This checks if a given action is active
|
||||
public bool CheckActionActive(Assembly assembly, string actionname)
|
||||
{
|
||||
if(assembly == null)
|
||||
return General.Actions.CheckActionActive(General.ThisAssembly, actionname);
|
||||
else
|
||||
return General.Actions.CheckActionActive(assembly, actionname);
|
||||
}
|
||||
|
||||
// This is a tool to lock the mouse in exclusive mode
|
||||
private void StartMouseExclusive()
|
||||
|
|
Loading…
Reference in a new issue