mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 12:50:52 +00:00
added actions and shortcut keys
This commit is contained in:
parent
b9a6bfb3ea
commit
0ddda9fe00
10 changed files with 418 additions and 5 deletions
|
@ -2,9 +2,9 @@
|
||||||
mainwindow
|
mainwindow
|
||||||
{
|
{
|
||||||
positionx = 124;
|
positionx = 124;
|
||||||
|
sizewidth = 739;
|
||||||
|
sizeheight = 572;
|
||||||
windowstate = 2;
|
windowstate = 2;
|
||||||
sizeheight = 388;
|
|
||||||
sizewidth = 530;
|
|
||||||
positiony = 35;
|
positiony = 35;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
@ -47,8 +47,12 @@
|
||||||
<Compile Include="Editing\EditMode.cs" />
|
<Compile Include="Editing\EditMode.cs" />
|
||||||
<Compile Include="Editing\FrozenOverviewMode.cs" />
|
<Compile Include="Editing\FrozenOverviewMode.cs" />
|
||||||
<Compile Include="Editing\ViewClassicMode.cs" />
|
<Compile Include="Editing\ViewClassicMode.cs" />
|
||||||
|
<Compile Include="Controls\ActionDelegate.cs" />
|
||||||
|
<Compile Include="Controls\Actions.cs" />
|
||||||
|
<Compile Include="Controls\ActionManager.cs" />
|
||||||
<Compile Include="General\ConfigurationInfo.cs" />
|
<Compile Include="General\ConfigurationInfo.cs" />
|
||||||
<Compile Include="General\MapManager.cs" />
|
<Compile Include="General\MapManager.cs" />
|
||||||
|
<Compile Include="Controls\SpecialKeys.cs" />
|
||||||
<Compile Include="Geometry\Angle2D.cs" />
|
<Compile Include="Geometry\Angle2D.cs" />
|
||||||
<Compile Include="Geometry\Line2D.cs" />
|
<Compile Include="Geometry\Line2D.cs" />
|
||||||
<Compile Include="Geometry\Vector2D.cs" />
|
<Compile Include="Geometry\Vector2D.cs" />
|
||||||
|
@ -149,6 +153,7 @@
|
||||||
<None Include="Resources\Splash2small.png" />
|
<None Include="Resources\Splash2small.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Resources\Actions.cfg" />
|
||||||
<None Include="Resources\Splash2.png" />
|
<None Include="Resources\Splash2.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
30
Source/Controls/ActionDelegate.cs
Normal file
30
Source/Controls/ActionDelegate.cs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder.Controls
|
||||||
|
{
|
||||||
|
internal delegate void ActionDelegate();
|
||||||
|
}
|
156
Source/Controls/ActionManager.cs
Normal file
156
Source/Controls/ActionManager.cs
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
|
||||||
|
#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 CodeImp.DoomBuilder.Properties;
|
||||||
|
using System.IO;
|
||||||
|
using CodeImp.DoomBuilder.IO;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder.Controls
|
||||||
|
{
|
||||||
|
internal class ActionManager : IDisposable
|
||||||
|
{
|
||||||
|
#region ================== Constants
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Variables
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
private Dictionary<string, Action> actions;
|
||||||
|
|
||||||
|
// Disposing
|
||||||
|
private bool isdisposed = false;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Properties
|
||||||
|
|
||||||
|
public Action this[string action] { get { return actions[action]; } }
|
||||||
|
public bool IsDisposed { get { return isdisposed; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public ActionManager()
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
actions = new Dictionary<string, Action>();
|
||||||
|
|
||||||
|
// Load all actions
|
||||||
|
LoadActions();
|
||||||
|
|
||||||
|
// We have no destructor
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Diposer
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
// Not already disposed?
|
||||||
|
if(!isdisposed)
|
||||||
|
{
|
||||||
|
// Clean up
|
||||||
|
|
||||||
|
// Done
|
||||||
|
isdisposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Actions
|
||||||
|
|
||||||
|
// This loads all actions
|
||||||
|
private void LoadActions()
|
||||||
|
{
|
||||||
|
Stream actionsdata;
|
||||||
|
StreamReader actionsreader;
|
||||||
|
Configuration cfg;
|
||||||
|
string name, title, desc;
|
||||||
|
|
||||||
|
// Get a stream from the resource
|
||||||
|
actionsdata = General.ThisAssembly.GetManifestResourceStream("CodeImp.DoomBuilder.Resources.Actions.cfg");
|
||||||
|
actionsreader = new StreamReader(actionsdata, Encoding.ASCII);
|
||||||
|
|
||||||
|
// Load configuration from stream
|
||||||
|
cfg = new Configuration();
|
||||||
|
cfg.InputConfiguration(actionsreader.ReadToEnd());
|
||||||
|
|
||||||
|
// Done with the resource
|
||||||
|
actionsreader.Dispose();
|
||||||
|
actionsdata.Dispose();
|
||||||
|
|
||||||
|
// Go for all objects in the configuration
|
||||||
|
foreach(DictionaryEntry a in cfg.Root)
|
||||||
|
{
|
||||||
|
// Get action properties
|
||||||
|
name = a.Key.ToString();
|
||||||
|
title = cfg.ReadSetting(name + ".title", "[" + name + "]");
|
||||||
|
desc = cfg.ReadSetting(name + ".description", "");
|
||||||
|
|
||||||
|
// Create an action
|
||||||
|
actions.Add(name, new Action(title, desc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This checks if a given action exists
|
||||||
|
public bool Exists(string action)
|
||||||
|
{
|
||||||
|
return actions.ContainsKey(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Shortcut Keys
|
||||||
|
|
||||||
|
// Removes all shortcut keys
|
||||||
|
public void RemoveShortcutKeys()
|
||||||
|
{
|
||||||
|
// Clear all keys
|
||||||
|
foreach(KeyValuePair<string, Action> a in actions)
|
||||||
|
a.Value.SetShortcutKey(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This will call the associated action for a keypress
|
||||||
|
public void InvokeByKey(int key)
|
||||||
|
{
|
||||||
|
// Go for all actions
|
||||||
|
foreach(KeyValuePair<string, Action> a in actions)
|
||||||
|
{
|
||||||
|
// This action is associated with this key?
|
||||||
|
if(a.Value.ShortcutKey == key)
|
||||||
|
{
|
||||||
|
// Invoke action
|
||||||
|
a.Value.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
112
Source/Controls/Actions.cs
Normal file
112
Source/Controls/Actions.cs
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder.Controls
|
||||||
|
{
|
||||||
|
internal class Action
|
||||||
|
{
|
||||||
|
#region ================== Constants
|
||||||
|
|
||||||
|
public const string NEWMAP = "newmap";
|
||||||
|
public const string OPENMAP = "openmap";
|
||||||
|
public const string SAVEMAP = "savemap";
|
||||||
|
public const string SAVEMAPAS = "savemapas";
|
||||||
|
public const string SHOWOVERVIEW = "showoverview";
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Variables
|
||||||
|
|
||||||
|
// Description
|
||||||
|
private string title;
|
||||||
|
private string description;
|
||||||
|
|
||||||
|
// Shortcut key
|
||||||
|
private int key;
|
||||||
|
|
||||||
|
// Delegate
|
||||||
|
private List<ActionDelegate> delegates;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Properties
|
||||||
|
|
||||||
|
public string Title { get { return title; } }
|
||||||
|
public string Description { get { return description; } }
|
||||||
|
public int ShortcutKey { get { return key; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public Action(string title, string description)
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
this.title = title;
|
||||||
|
this.description = description;
|
||||||
|
this.delegates = new List<ActionDelegate>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Action()
|
||||||
|
{
|
||||||
|
// Moo.
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Methods
|
||||||
|
|
||||||
|
// This sets a new key for the action
|
||||||
|
public void SetShortcutKey(int key)
|
||||||
|
{
|
||||||
|
// Make it so.
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This binds a delegate to this action
|
||||||
|
public void Bind(ActionDelegate method)
|
||||||
|
{
|
||||||
|
delegates.Add(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This removes a delegate from this action
|
||||||
|
public void Unbind(ActionDelegate method)
|
||||||
|
{
|
||||||
|
delegates.Remove(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This raises events for this action
|
||||||
|
public void Invoke()
|
||||||
|
{
|
||||||
|
// Check if this action exists
|
||||||
|
foreach(ActionDelegate ad in delegates) ad.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
34
Source/Controls/SpecialKeys.cs
Normal file
34
Source/Controls/SpecialKeys.cs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder.Controls
|
||||||
|
{
|
||||||
|
public enum SpecialKeys : int
|
||||||
|
{
|
||||||
|
MScrollUp = 65530,
|
||||||
|
MScrollDown = 65531,
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ using CodeImp.DoomBuilder.IO;
|
||||||
using CodeImp.DoomBuilder.Map;
|
using CodeImp.DoomBuilder.Map;
|
||||||
using CodeImp.DoomBuilder.Geometry;
|
using CodeImp.DoomBuilder.Geometry;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using CodeImp.DoomBuilder.Controls;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ namespace CodeImp.DoomBuilder
|
||||||
private static MainForm mainwindow;
|
private static MainForm mainwindow;
|
||||||
private static Configuration settings;
|
private static Configuration settings;
|
||||||
private static MapManager map;
|
private static MapManager map;
|
||||||
|
private static ActionManager actions;
|
||||||
|
|
||||||
// Configurations
|
// Configurations
|
||||||
private static List<ConfigurationInfo> configs;
|
private static List<ConfigurationInfo> configs;
|
||||||
|
@ -79,6 +81,7 @@ namespace CodeImp.DoomBuilder
|
||||||
public static Configuration Settings { get { return settings; } }
|
public static Configuration Settings { get { return settings; } }
|
||||||
public static List<ConfigurationInfo> Configs { get { return configs; } }
|
public static List<ConfigurationInfo> Configs { get { return configs; } }
|
||||||
public static MapManager Map { get { return map; } }
|
public static MapManager Map { get { return map; } }
|
||||||
|
public static ActionManager Actions { get { return actions; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -192,6 +195,9 @@ namespace CodeImp.DoomBuilder
|
||||||
if(!File.Exists(Path.Combine(apppath, SETTINGS_CONFIG_FILE))) throw (new FileNotFoundException("Unable to find the program configuration \"" + SETTINGS_CONFIG_FILE + "\"."));
|
if(!File.Exists(Path.Combine(apppath, SETTINGS_CONFIG_FILE))) throw (new FileNotFoundException("Unable to find the program configuration \"" + SETTINGS_CONFIG_FILE + "\"."));
|
||||||
settings = new Configuration(Path.Combine(apppath, SETTINGS_CONFIG_FILE), false);
|
settings = new Configuration(Path.Combine(apppath, SETTINGS_CONFIG_FILE), false);
|
||||||
|
|
||||||
|
// Create action manager
|
||||||
|
actions = new ActionManager();
|
||||||
|
|
||||||
// Create main window
|
// Create main window
|
||||||
mainwindow = new MainForm();
|
mainwindow = new MainForm();
|
||||||
mainwindow.UpdateMenus();
|
mainwindow.UpdateMenus();
|
||||||
|
@ -217,6 +223,7 @@ namespace CodeImp.DoomBuilder
|
||||||
{
|
{
|
||||||
// Clean up
|
// Clean up
|
||||||
mainwindow.Dispose();
|
mainwindow.Dispose();
|
||||||
|
actions.Dispose();
|
||||||
|
|
||||||
// Save settings configuration
|
// Save settings configuration
|
||||||
settings.SaveConfiguration(Path.Combine(apppath, SETTINGS_CONFIG_FILE));
|
settings.SaveConfiguration(Path.Combine(apppath, SETTINGS_CONFIG_FILE));
|
||||||
|
|
3
Source/Interface/MainForm.Designer.cs
generated
3
Source/Interface/MainForm.Designer.cs
generated
|
@ -83,7 +83,9 @@ namespace CodeImp.DoomBuilder.Interface
|
||||||
// itemnewmap
|
// itemnewmap
|
||||||
//
|
//
|
||||||
this.itemnewmap.Name = "itemnewmap";
|
this.itemnewmap.Name = "itemnewmap";
|
||||||
|
this.itemnewmap.ShortcutKeyDisplayString = "";
|
||||||
this.itemnewmap.Size = new System.Drawing.Size(167, 22);
|
this.itemnewmap.Size = new System.Drawing.Size(167, 22);
|
||||||
|
this.itemnewmap.Tag = "newmap";
|
||||||
this.itemnewmap.Text = "New Map";
|
this.itemnewmap.Text = "New Map";
|
||||||
this.itemnewmap.Click += new System.EventHandler(this.itemnewmap_Click);
|
this.itemnewmap.Click += new System.EventHandler(this.itemnewmap_Click);
|
||||||
//
|
//
|
||||||
|
@ -91,6 +93,7 @@ namespace CodeImp.DoomBuilder.Interface
|
||||||
//
|
//
|
||||||
this.itemopenmap.Name = "itemopenmap";
|
this.itemopenmap.Name = "itemopenmap";
|
||||||
this.itemopenmap.Size = new System.Drawing.Size(167, 22);
|
this.itemopenmap.Size = new System.Drawing.Size(167, 22);
|
||||||
|
this.itemopenmap.Tag = "openmap";
|
||||||
this.itemopenmap.Text = "Open Map...";
|
this.itemopenmap.Text = "Open Map...";
|
||||||
this.itemopenmap.Click += new System.EventHandler(this.itemopenmap_Click);
|
this.itemopenmap.Click += new System.EventHandler(this.itemopenmap_Click);
|
||||||
//
|
//
|
||||||
|
|
|
@ -22,6 +22,7 @@ using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using CodeImp.DoomBuilder.Controls;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -61,7 +62,10 @@ namespace CodeImp.DoomBuilder.Interface
|
||||||
{
|
{
|
||||||
// Setup controls
|
// Setup controls
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
// Apply shortcut keys
|
||||||
|
ApplyShortcutKeys();
|
||||||
|
|
||||||
// Keep last position and size
|
// Keep last position and size
|
||||||
lastposition = this.Location;
|
lastposition = this.Location;
|
||||||
lastsize = this.Size;
|
lastsize = this.Size;
|
||||||
|
@ -274,6 +278,49 @@ namespace CodeImp.DoomBuilder.Interface
|
||||||
|
|
||||||
#region ================== Menus
|
#region ================== Menus
|
||||||
|
|
||||||
|
// Public method to apply shortcut keys
|
||||||
|
public void ApplyShortcutKeys()
|
||||||
|
{
|
||||||
|
// Apply shortcut keys to menus
|
||||||
|
ApplyShortcutKeys(menumain.Items);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This sets the shortcut keys on menu items
|
||||||
|
private void ApplyShortcutKeys(ToolStripItemCollection items)
|
||||||
|
{
|
||||||
|
ToolStripMenuItem menuitem;
|
||||||
|
string actionname;
|
||||||
|
|
||||||
|
// Go for all controls to find menu items
|
||||||
|
foreach(ToolStripItem item in items)
|
||||||
|
{
|
||||||
|
// This is a menu item?
|
||||||
|
if(item is ToolStripMenuItem)
|
||||||
|
{
|
||||||
|
// Get the item in proper type
|
||||||
|
menuitem = (item as ToolStripMenuItem);
|
||||||
|
|
||||||
|
// Tag set for this item?
|
||||||
|
if(menuitem.Tag != null)
|
||||||
|
{
|
||||||
|
// Get the action name
|
||||||
|
actionname = menuitem.Tag.ToString();
|
||||||
|
|
||||||
|
// Action with this name available?
|
||||||
|
if(General.Actions.Exists(actionname))
|
||||||
|
{
|
||||||
|
// Put the action shortcut key on the menu item
|
||||||
|
// TODO: Use a friendly shortcut key description
|
||||||
|
menuitem.ShortcutKeyDisplayString = General.Actions[actionname].ShortcutKey.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recursively apply shortcut keys to child menu items as well
|
||||||
|
ApplyShortcutKeys(menuitem.DropDownItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This updates all menus for the current status
|
// This updates all menus for the current status
|
||||||
public void UpdateMenus()
|
public void UpdateMenus()
|
||||||
{
|
{
|
||||||
|
|
19
Source/Resources/Actions.cfg
Normal file
19
Source/Resources/Actions.cfg
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
/******************************************\
|
||||||
|
Doom Builder Actions Configuration
|
||||||
|
\******************************************/
|
||||||
|
|
||||||
|
// This just defines which actions there are and what description they have
|
||||||
|
// The source code will bind to these actions with delegates (function pointers)
|
||||||
|
|
||||||
|
newmap
|
||||||
|
{
|
||||||
|
title = "File: New Map";
|
||||||
|
description = "Starts with a new, empty workspace to begin drawing a map from scratch.";
|
||||||
|
}
|
||||||
|
|
||||||
|
openmap
|
||||||
|
{
|
||||||
|
title = "File: Open Map";
|
||||||
|
description = "Opens an existing map from WAD file for viewing or modifying.";
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue