Skip to content

Commit b2f0967

Browse files
committed
Add keybind disabling and keycode changing
1 parent ecf377a commit b2f0967

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
using SpaceWarp.API.UI.Appbar;
77
using MicroEngineer.UI;
88
using KSP.Game;
9+
using BepInEx.Configuration;
910

1011
namespace MicroMod
1112
{
12-
[BepInPlugin("com.micrologist.microengineer", "MicroEngineer", "1.4.0")]
13+
[BepInPlugin("com.micrologist.microengineer", "MicroEngineer", "1.5.0")]
1314
[BepInDependency(SpaceWarpPlugin.ModGuid, SpaceWarpPlugin.ModVer)]
1415
public class MicroEngineerMod : BaseSpaceWarpPlugin
1516
{
1617
public static MicroEngineerMod Instance { get; set; }
1718
public string GUID;
19+
20+
private ConfigEntry<bool> _enableKeybinding;
21+
private ConfigEntry<KeyCode> _keybind1;
22+
private ConfigEntry<KeyCode> _keybind2;
1823

1924
public override void OnInitialized()
2025
{
@@ -52,14 +57,20 @@ public override void OnInitialized()
5257
OABSceneController.Instance.ShowGui = isOpen;
5358
Utility.SaveLayout();
5459
});
60+
61+
_enableKeybinding = Config.Bind("Micro Engineer", "Enable keybinding", true, "Enables or disables keyboard shortcuts to show or hide windows in Flight and OAB scenes.");
62+
_keybind1 = Config.Bind("Micro Engineer", "Keycode 1", KeyCode.LeftControl, "First keycode.");
63+
_keybind2 = Config.Bind("Micro Engineer", "Keycode 2", KeyCode.E, "Second keycode.");
5564
}
5665

5766
public void Update()
5867
{
5968
Manager.Instance.Update();
6069

61-
// Keyboard shortcut for opening UI
62-
if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.E))
70+
// Keyboard shortcut for opening the UI
71+
if (_enableKeybinding.Value &&
72+
(_keybind1.Value != KeyCode.None ? Input.GetKey(_keybind1.Value) : true) &&
73+
(_keybind2.Value != KeyCode.None ? Input.GetKeyDown(_keybind2.Value) : true))
6374
{
6475
if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView)
6576
{

0 commit comments

Comments
 (0)