diff --git a/Source/Actions/Action.cs b/Source/Actions/Action.cs index 8455896e..65a376a9 100644 --- a/Source/Actions/Action.cs +++ b/Source/Actions/Action.cs @@ -28,7 +28,7 @@ using CodeImp.DoomBuilder.IO; namespace CodeImp.DoomBuilder.Actions { - internal class Action + public class Action { #region ================== Variables @@ -80,7 +80,7 @@ namespace CodeImp.DoomBuilder.Actions #region ================== Constructor / Disposer // Constructor - public Action(Configuration cfg, string name, string shortname, int key) + internal Action(Configuration cfg, string name, string shortname, int key) { // Initialize this.name = name; @@ -198,39 +198,46 @@ namespace CodeImp.DoomBuilder.Actions #region ================== Methods + // This invokes the action + public void Invoke() + { + this.Begin(); + this.End(); + } + // This sets a new key for the action - public void SetShortcutKey(int key) + internal void SetShortcutKey(int key) { // Make it so. this.key = key & keymask; } // This binds a delegate to this action - public void BindBegin(ActionDelegate method) + internal void BindBegin(ActionDelegate method) { begindelegates.Add(method); } // This removes a delegate from this action - public void UnbindBegin(ActionDelegate method) + internal void UnbindBegin(ActionDelegate method) { begindelegates.Remove(method); } // This binds a delegate to this action - public void BindEnd(ActionDelegate method) + internal void BindEnd(ActionDelegate method) { enddelegates.Add(method); } // This removes a delegate from this action - public void UnbindEnd(ActionDelegate method) + internal void UnbindEnd(ActionDelegate method) { enddelegates.Remove(method); } // This raises events for this action - public void Begin() + internal void Begin() { List delegateslist; @@ -246,7 +253,7 @@ namespace CodeImp.DoomBuilder.Actions } // This raises events for this action - public void End() + internal void End() { List delegateslist; diff --git a/Source/Actions/ActionManager.cs b/Source/Actions/ActionManager.cs index fcf729f8..0c040336 100644 --- a/Source/Actions/ActionManager.cs +++ b/Source/Actions/ActionManager.cs @@ -398,6 +398,12 @@ namespace CodeImp.DoomBuilder.Actions actions.Values.CopyTo(list, 0); return list; } + + // This returns the specified action + public Action GetActionByName(string fullname) + { + return actions[fullname]; + } // This saves the control settings public void SaveSettings() @@ -415,9 +421,7 @@ namespace CodeImp.DoomBuilder.Actions { if(Exists(actionname)) { - Action a = actions[actionname]; - a.Begin(); - a.End(); + actions[actionname].Invoke(); return true; } else diff --git a/Source/BuilderModes/ClassicModes/BaseClassicMode.cs b/Source/BuilderModes/ClassicModes/BaseClassicMode.cs index 9d73aeab..574227ee 100644 --- a/Source/BuilderModes/ClassicModes/BaseClassicMode.cs +++ b/Source/BuilderModes/ClassicModes/BaseClassicMode.cs @@ -104,6 +104,26 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Editing.ChangeMode(editmode); } + // Double-clicking + public override void OnMouseDoubleClick(MouseEventArgs e) + { + base.OnMouseDoubleClick(e); + + int k = 0; + if(e.Button == MouseButtons.Left) k = (int)Keys.LButton; + if(e.Button == MouseButtons.Middle) k = (int)Keys.MButton; + if(e.Button == MouseButtons.Right) k = (int)Keys.RButton; + if(e.Button == MouseButtons.XButton1) k = (int)Keys.XButton1; + 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)) + { + Action a = General.Interface.GetActionByFullName("builder_classicedit"); + if(a != null) a.Invoke(); + } + } + #endregion #region ================== Actions diff --git a/Source/Windows/IMainForm.cs b/Source/Windows/IMainForm.cs index e6b83abc..a26956e8 100644 --- a/Source/Windows/IMainForm.cs +++ b/Source/Windows/IMainForm.cs @@ -26,6 +26,7 @@ using System.IO; using System.Reflection; using System.Drawing; using System.ComponentModel; +using CodeImp.DoomBuilder.Actions; using CodeImp.DoomBuilder.Map; using SlimDX.Direct3D9; using SlimDX; @@ -123,6 +124,8 @@ namespace CodeImp.DoomBuilder.Windows /// Unused. void InvokeTaggedAction(object sender, EventArgs e); + Action GetActionByFullName(string fullname); + void AddButton(ToolStripItem button); void RemoveButton(ToolStripItem button); } diff --git a/Source/Windows/MainForm.cs b/Source/Windows/MainForm.cs index 4d5b2d97..c19e0c1b 100644 --- a/Source/Windows/MainForm.cs +++ b/Source/Windows/MainForm.cs @@ -280,6 +280,16 @@ 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