forked from Biotronic/TweakScale
-
Notifications
You must be signed in to change notification settings - Fork 23
/
HotkeyManager.cs
48 lines (41 loc) · 1.32 KB
/
HotkeyManager.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
using System.Collections.Generic;
using KSP.IO;
using TweakScale.Annotations;
using UnityEngine;
namespace TweakScale
{
[KSPAddon(KSPAddon.Startup.EditorAny, false)]
internal class HotkeyManager : SingletonBehavior<HotkeyManager>
{
private readonly OSD _osd = new OSD();
private readonly Dictionary<string, Hotkeyable> _hotkeys = new Dictionary<string, Hotkeyable>();
private /*readonly*/ PluginConfiguration _config;
private void Awake()
{
base.Awake();
_config = PluginConfiguration.CreateForType<TweakScale>();
}
public PluginConfiguration Config {
get { return _config; }
}
[UsedImplicitly]
private void OnGUI()
{
_osd.Update();
}
[UsedImplicitly]
private void Update()
{
foreach (var key in _hotkeys.Values)
{
key.Update();
}
}
public Hotkeyable AddHotkey(string hotkeyName, ICollection<KeyCode> tempDisableDefault, ICollection<KeyCode> toggleDefault, bool state)
{
if (_hotkeys.ContainsKey(hotkeyName))
return _hotkeys[hotkeyName];
return _hotkeys[hotkeyName] = new Hotkeyable(_osd, hotkeyName, tempDisableDefault, toggleDefault, state);
}
}
}