From 6900a4cfa7ab1c74b62303216d55c1fcdff75303 Mon Sep 17 00:00:00 2001 From: codeimp Date: Mon, 25 Jun 2007 19:28:03 +0000 Subject: [PATCH] more --- Source/Controls/Action.cs | 14 +++++++++++++- Source/Controls/ActionManager.cs | 6 +++++- Source/Interface/MainForm.Designer.cs | 1 + Source/Interface/MainForm.cs | 11 +++++++++++ Source/Interface/MainForm.resx | 6 +++--- Source/Resources/Actions.cfg | 9 +++++++++ 6 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Source/Controls/Action.cs b/Source/Controls/Action.cs index 2e937fda..ac00420a 100644 --- a/Source/Controls/Action.cs +++ b/Source/Controls/Action.cs @@ -49,6 +49,11 @@ namespace CodeImp.DoomBuilder.Controls // Shortcut key private int key; + // Shortcut options + private bool allowkeys; + private bool allowmouse; + private bool allowscroll; + // Delegate private List delegates; @@ -59,18 +64,25 @@ namespace CodeImp.DoomBuilder.Controls public string Title { get { return title; } } public string Description { get { return description; } } public int ShortcutKey { get { return key; } } + public bool AllowKeys { get { return allowkeys; } } + public bool AllowMouse { get { return allowmouse; } } + public bool AllowScroll { get { return allowscroll; } } #endregion #region ================== Constructor / Disposer // Constructor - public Action(string title, string description, int key) + public Action(string title, string description, int key, + bool allowkeys, bool allowmouse, bool allowscroll) { // Initialize this.title = title; this.description = description; this.delegates = new List(); + this.allowkeys = allowkeys; + this.allowmouse = allowmouse; + this.allowscroll = allowscroll; this.key = key; } diff --git a/Source/Controls/ActionManager.cs b/Source/Controls/ActionManager.cs index a8c7bae7..78f1fd28 100644 --- a/Source/Controls/ActionManager.cs +++ b/Source/Controls/ActionManager.cs @@ -92,6 +92,7 @@ namespace CodeImp.DoomBuilder.Controls StreamReader actionsreader; Configuration cfg; string name, title, desc; + bool amouse, akeys, ascroll; int key; // Get a stream from the resource @@ -114,9 +115,12 @@ namespace CodeImp.DoomBuilder.Controls title = cfg.ReadSetting(name + ".title", "[" + name + "]"); desc = cfg.ReadSetting(name + ".description", ""); key = General.Settings.ReadSetting("shortcuts." + name, 0); + akeys = cfg.ReadSetting(name + ".allowkeys", false); + amouse = cfg.ReadSetting(name + ".allowmouse", false); + ascroll = cfg.ReadSetting(name + ".allowscroll", false); // Create an action - actions.Add(name, new Action(title, desc, key)); + actions.Add(name, new Action(title, desc, key, akeys, amouse, ascroll)); } } diff --git a/Source/Interface/MainForm.Designer.cs b/Source/Interface/MainForm.Designer.cs index e34b316e..c8707d94 100644 --- a/Source/Interface/MainForm.Designer.cs +++ b/Source/Interface/MainForm.Designer.cs @@ -236,6 +236,7 @@ namespace CodeImp.DoomBuilder.Interface this.Resize += new System.EventHandler(this.MainForm_Resize); this.Move += new System.EventHandler(this.MainForm_Move); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MainForm_KeyDown); this.ResizeEnd += new System.EventHandler(this.MainForm_ResizeEnd); this.Load += new System.EventHandler(this.MainForm_Load); this.menumain.ResumeLayout(false); diff --git a/Source/Interface/MainForm.cs b/Source/Interface/MainForm.cs index 5bd098ca..667ad138 100644 --- a/Source/Interface/MainForm.cs +++ b/Source/Interface/MainForm.cs @@ -276,6 +276,17 @@ namespace CodeImp.DoomBuilder.Interface #endregion + #region ================== Input + + // When a key is pressed + private void MainForm_KeyDown(object sender, KeyEventArgs e) + { + // Invoke any actions associated with this key + General.Actions.InvokeByKey((int)e.KeyData); + } + + #endregion + #region ================== Menus // Public method to apply shortcut keys diff --git a/Source/Interface/MainForm.resx b/Source/Interface/MainForm.resx index 5b98b04e..9598dc33 100644 --- a/Source/Interface/MainForm.resx +++ b/Source/Interface/MainForm.resx @@ -123,12 +123,12 @@ 17, 17 - - True - 121, 17 + + True + True diff --git a/Source/Resources/Actions.cfg b/Source/Resources/Actions.cfg index ca661140..e06c8cc7 100644 --- a/Source/Resources/Actions.cfg +++ b/Source/Resources/Actions.cfg @@ -9,16 +9,25 @@ newmap { title = "File: New Map"; description = "Starts with a new, empty workspace to begin drawing a map from scratch."; + allowkeys = true; + allowmouse = false; + allowscroll = false; } openmap { title = "File: Open Map"; description = "Opens an existing map from WAD file for viewing or modifying."; + allowkeys = true; + allowmouse = false; + allowscroll = false; } closemap { title = "File: Close Map"; description = "Closes the current map and the WAD file in which it exits."; + allowkeys = true; + allowmouse = false; + allowscroll = false; }