-
Notifications
You must be signed in to change notification settings - Fork 3
/
KeyBindings.cs
73 lines (66 loc) · 4.07 KB
/
KeyBindings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using BepInEx.Configuration;
using System.Collections.Generic;
using Timberborn.SingletonSystem;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
namespace ToolShortcuts
{
public class KeyBindings : ILoadableSingleton
{
public Dictionary<ToolGroupName, KeyControl> GroupTools;
public List<KeyControl> Tools;
public KeyBindings()
{
Plugin.KeyBindings = this;
}
public void Load()
{
GroupTools = new Dictionary<ToolGroupName, KeyControl> {
{ ToolGroupName.TreeCutting, ConfigEntryToKeyControl(KeyBindingsConfig.treeCuttingGroupTool) },
{ ToolGroupName.FieldsPlanting, ConfigEntryToKeyControl(KeyBindingsConfig.fieldsPlantingGroupTool) },
{ ToolGroupName.ForestryPlanting, ConfigEntryToKeyControl(KeyBindingsConfig.forestryPlantingGroupTool) },
{ ToolGroupName.Demolishing, ConfigEntryToKeyControl(KeyBindingsConfig.demolishingGroupTool) },
{ ToolGroupName.Priority, ConfigEntryToKeyControl(KeyBindingsConfig.priorityGroupTool) },
{ ToolGroupName.Paths, ConfigEntryToKeyControl(KeyBindingsConfig.pathsGroupTool) },
{ ToolGroupName.Landscaping, ConfigEntryToKeyControl(KeyBindingsConfig.landscapingGroupTool) },
{ ToolGroupName.Storage, ConfigEntryToKeyControl(KeyBindingsConfig.storageGroupTool) },
{ ToolGroupName.Labor, ConfigEntryToKeyControl(KeyBindingsConfig.laborGroupTool) },
{ ToolGroupName.Housing, ConfigEntryToKeyControl(KeyBindingsConfig.housingGroupTool) },
{ ToolGroupName.Water, ConfigEntryToKeyControl(KeyBindingsConfig.waterGroupTool) },
{ ToolGroupName.Food, ConfigEntryToKeyControl(KeyBindingsConfig.foodGroupTool) },
{ ToolGroupName.Wood, ConfigEntryToKeyControl(KeyBindingsConfig.woodGroupTool) },
{ ToolGroupName.Metal, ConfigEntryToKeyControl(KeyBindingsConfig.metalGroupTool) },
{ ToolGroupName.Power, ConfigEntryToKeyControl(KeyBindingsConfig.powerGroupTool) },
{ ToolGroupName.Science, ConfigEntryToKeyControl(KeyBindingsConfig.scienceGroupTool) },
{ ToolGroupName.Leisure, ConfigEntryToKeyControl(KeyBindingsConfig.leisureGroupTool) },
{ ToolGroupName.Decoration, ConfigEntryToKeyControl(KeyBindingsConfig.decorationGroupTool) },
{ ToolGroupName.Monuments, ConfigEntryToKeyControl(KeyBindingsConfig.monumentsGroupTool) },
{ ToolGroupName.MapEditor, ConfigEntryToKeyControl(KeyBindingsConfig.mapEditorGroupTool) },
{ ToolGroupName.Ruins, ConfigEntryToKeyControl(KeyBindingsConfig.ruinsGroupTool) },
};
Tools = new List<KeyControl> {
ConfigEntryToKeyControl(KeyBindingsConfig.tool1),
ConfigEntryToKeyControl(KeyBindingsConfig.tool2),
ConfigEntryToKeyControl(KeyBindingsConfig.tool3),
ConfigEntryToKeyControl(KeyBindingsConfig.tool4),
ConfigEntryToKeyControl(KeyBindingsConfig.tool5),
ConfigEntryToKeyControl(KeyBindingsConfig.tool6),
ConfigEntryToKeyControl(KeyBindingsConfig.tool7),
ConfigEntryToKeyControl(KeyBindingsConfig.tool8),
ConfigEntryToKeyControl(KeyBindingsConfig.tool9),
ConfigEntryToKeyControl(KeyBindingsConfig.tool10),
ConfigEntryToKeyControl(KeyBindingsConfig.tool11),
ConfigEntryToKeyControl(KeyBindingsConfig.tool12),
ConfigEntryToKeyControl(KeyBindingsConfig.tool13),
ConfigEntryToKeyControl(KeyBindingsConfig.tool14),
ConfigEntryToKeyControl(KeyBindingsConfig.tool15),
ConfigEntryToKeyControl(KeyBindingsConfig.tool16),
};
}
private static KeyControl ConfigEntryToKeyControl(ConfigEntry<string> configEntry)
{
string value = configEntry.Value.ToLower();
return value != "" ? (KeyControl)Keyboard.current[value] : null;
}
}
}