Skip to content

Commit e3660a7

Browse files
committed
Defined various shortcut keys on the node type menu items. Changed toolbar button to toolbar menu item so it can have a shortcut too.
1 parent 05c13a1 commit e3660a7

File tree

3 files changed

+47
-8
lines changed

3 files changed

+47
-8
lines changed

ReClass.NET/Forms/MainForm.Designer.cs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ReClass.NET/Settings.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
1-
using System.Drawing;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Drawing;
24
using System.Text;
5+
using System.Windows.Forms;
6+
using ReClassNET.Nodes;
37
using ReClassNET.Util;
48

59
namespace ReClassNET
610
{
711
public class Settings
812
{
13+
private readonly Dictionary<Type, Keys> _shortcutKeyPerNode;
14+
15+
public Settings()
16+
{
17+
_shortcutKeyPerNode = new Dictionary<Type, Keys>
18+
{
19+
{ typeof(Hex64Node), Keys.Control | Keys.Shift | Keys.D6 },
20+
{ typeof(ClassInstanceNode), Keys.Control | Keys.Shift | Keys.I },
21+
{ typeof(FloatNode), Keys.Control | Keys.Shift | Keys.F },
22+
{ typeof(Hex8Node), Keys.Control | Keys.Shift | Keys.B },
23+
{ typeof(PointerNode), Keys.Control | Keys.Shift | Keys.P },
24+
{ typeof(Vector2Node), Keys.Control | Keys.Shift | Keys.D2 },
25+
{ typeof(Vector3Node), Keys.Control | Keys.Shift | Keys.D3 },
26+
{ typeof(Vector4Node), Keys.Control | Keys.Shift | Keys.D4 },
27+
{ typeof(VirtualMethodTableNode), Keys.Control | Keys.Shift | Keys.T },
28+
{ typeof(BoolNode), Keys.Control | Keys.Shift | Keys.O },
29+
{ typeof(EnumNode), Keys.Control | Keys.Shift | Keys.E },
30+
{ typeof(Int32Node), Keys.Control | Keys.Shift | Keys.N }
31+
};
32+
33+
// Define more here.
34+
}
35+
36+
937
// Application Settings
1038

1139
public string LastProcess { get; set; } = string.Empty;
@@ -76,6 +104,12 @@ public class Settings
76104

77105
public CustomDataMap CustomData { get; } = new CustomDataMap();
78106

107+
108+
public Keys GetShortcutKeyForNodeType(Type nodeType)
109+
{
110+
return !_shortcutKeyPerNode.TryGetValue(nodeType, out var shortcutKeys) ? Keys.None : shortcutKeys;
111+
}
112+
79113
public Settings Clone() => MemberwiseClone() as Settings;
80114
}
81115
}

ReClass.NET/UI/NodeTypesBuilder.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ public static IEnumerable<ToolStripItem> CreateToolStripButtons(Action<Type> han
5757

5858
return CreateToolStripItems(t =>
5959
{
60-
GetNodeInfoFromType(t, out var label, out var icon);
60+
GetNodeInfoFromType(t, out var label, out var icon, out var shortcutKeys);
6161

62-
var item = new TypeToolStripButton
62+
var item = new TypeToolStripMenuItem
6363
{
6464
Value = t,
6565
ToolTipText = label,
6666
DisplayStyle = ToolStripItemDisplayStyle.Image,
67-
Image = icon
67+
Image = icon,
68+
ShortcutKeys = shortcutKeys,
6869
};
6970
item.Click += clickHandler;
7071
return item;
@@ -74,7 +75,7 @@ public static IEnumerable<ToolStripItem> CreateToolStripButtons(Action<Type> han
7475
Image = p.Icon
7576
}, t =>
7677
{
77-
GetNodeInfoFromType(t, out var label, out var icon);
78+
GetNodeInfoFromType(t, out var label, out var icon, out var shortcutKeys);
7879

7980
var item = new TypeToolStripMenuItem
8081
{
@@ -95,13 +96,14 @@ public static IEnumerable<ToolStripItem> CreateToolStripMenuItems(Action<Type> h
9596

9697
var items = CreateToolStripItems(t =>
9798
{
98-
GetNodeInfoFromType(t, out var label, out var icon);
99+
GetNodeInfoFromType(t, out var label, out var icon, out var shortcutKeys);
99100

100101
var item = new TypeToolStripMenuItem
101102
{
102103
Value = t,
103104
Text = label,
104-
Image = icon
105+
Image = icon,
106+
ShortcutKeys = shortcutKeys,
105107
};
106108
item.Click += clickHandler;
107109
return item;
@@ -166,10 +168,12 @@ private static IEnumerable<ToolStripItem> CreateToolStripItems(Func<Type, ToolSt
166168
return items;
167169
}
168170

169-
private static void GetNodeInfoFromType(Type nodeType, out string label, out Image icon)
171+
private static void GetNodeInfoFromType(Type nodeType, out string label, out Image icon, out Keys shortcutKeys)
170172
{
171173
Contract.Requires(nodeType != null);
172174

175+
shortcutKeys = Program.Settings.GetShortcutKeyForNodeType(nodeType);
176+
173177
var node = BaseNode.CreateInstanceFromType(nodeType, false);
174178
if (node == null)
175179
{

0 commit comments

Comments
 (0)