Skip to content

Commit

Permalink
EEX has its own fix (sorta), so remove harmony patching
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed Jun 24, 2023
1 parent afcd8a8 commit 340901b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 88 deletions.
37 changes: 0 additions & 37 deletions Source/Harmony/EditorExtensionsRedux.cs

This file was deleted.

52 changes: 2 additions & 50 deletions Source/Harmony/GameSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ internal class PatchGameSettings
internal static bool DVSet = false;
internal static bool DELTAV_APP_ENABLED = true;
internal static bool DELTAV_CALCULATIONS_ENABLED = true;

public static void FixDV()
{
if (DVSet)
Expand All @@ -24,36 +25,10 @@ public static void FixDV()
GameSettings.DELTAV_CALCULATIONS_ENABLED = false;
}

internal static System.Type EEXType = AccessTools.TypeByName("EditorExtensionsRedux.EditorExtensions");
internal static PropertyInfo EEXInstance = EEXType?.GetProperty("Instance", AccessTools.all);
internal static FieldInfo HotkeyEditor_toggleSymModePrimary = EEXType?.GetField("HotkeyEditor_toggleSymModePrimary", AccessTools.all);
internal static FieldInfo HotkeyEditor_toggleSymModeSecondary = EEXType?.GetField("HotkeyEditor_toggleSymModeSecondary", AccessTools.all);
internal static FieldInfo HotkeyEditor_toggleAngleSnapPrimary = EEXType?.GetField("HotkeyEditor_toggleAngleSnapPrimary", AccessTools.all);
internal static FieldInfo HotkeyEditor_toggleAngleSnapSecondary = EEXType?.GetField("HotkeyEditor_toggleAngleSnapSecondary", AccessTools.all);


[HarmonyPrefix]
[HarmonyPatch("WriteCfg")]
internal static void Prefix_WriteCfg()
{
if (EEXType != null)
{
Debug.Log("Temporarily changing GameSettings editor keybindings to work around an Editor Extensions Redux issue.");
object eex = EEXInstance.GetValue(null);
if (eex != null)
{
PatchEditorExtensionsRedux_Start.toggleSym.primary = HotkeyEditor_toggleSymModePrimary.GetValue(eex) as KeyCodeExtended;
PatchEditorExtensionsRedux_Start.toggleSym.secondary = HotkeyEditor_toggleSymModeSecondary.GetValue(eex) as KeyCodeExtended;
PatchEditorExtensionsRedux_Start.toggleSnap.primary = HotkeyEditor_toggleAngleSnapPrimary.GetValue(eex) as KeyCodeExtended;
PatchEditorExtensionsRedux_Start.toggleSnap.secondary = HotkeyEditor_toggleAngleSnapSecondary.GetValue(eex) as KeyCodeExtended;
}

GameSettings.Editor_toggleSymMode.primary = PatchEditorExtensionsRedux_Start.toggleSym.primary;
GameSettings.Editor_toggleSymMode.secondary = PatchEditorExtensionsRedux_Start.toggleSym.secondary;
GameSettings.Editor_toggleAngleSnap.primary = PatchEditorExtensionsRedux_Start.toggleSnap.primary;
GameSettings.Editor_toggleAngleSnap.secondary = PatchEditorExtensionsRedux_Start.toggleSnap.secondary;
}

{
FixDV();

GameSettings.DELTAV_APP_ENABLED = DELTAV_APP_ENABLED;
Expand All @@ -64,15 +39,6 @@ internal static void Prefix_WriteCfg()
[HarmonyPatch("WriteCfg")]
internal static void Postfix_WriteCfg()
{
if (EEXType != null)
{
Debug.Log("Settings returned.");
GameSettings.Editor_toggleSymMode.primary = new KeyCodeExtended(KeyCode.None);
GameSettings.Editor_toggleSymMode.secondary = new KeyCodeExtended(KeyCode.None);
GameSettings.Editor_toggleAngleSnap.primary = new KeyCodeExtended(KeyCode.None);
GameSettings.Editor_toggleAngleSnap.secondary = new KeyCodeExtended(KeyCode.None);
}

GameSettings.DELTAV_APP_ENABLED = false;
GameSettings.DELTAV_CALCULATIONS_ENABLED = false;
}
Expand All @@ -89,20 +55,6 @@ internal static void Postfix_ParseCfg()
internal static void Postfix_SetDefaultValues()
{
FixDV();

if (EEXType != null)
{
PatchEditorExtensionsRedux_Start.toggleSym.primary = GameSettings.Editor_toggleSymMode.primary;
PatchEditorExtensionsRedux_Start.toggleSym.secondary = GameSettings.Editor_toggleSymMode.secondary;

PatchEditorExtensionsRedux_Start.toggleSnap.primary = GameSettings.Editor_toggleAngleSnap.primary;
PatchEditorExtensionsRedux_Start.toggleSnap.secondary = GameSettings.Editor_toggleAngleSnap.secondary;

GameSettings.Editor_toggleSymMode.primary = new KeyCodeExtended(KeyCode.None);
GameSettings.Editor_toggleSymMode.secondary = new KeyCodeExtended(KeyCode.None);
GameSettings.Editor_toggleAngleSnap.primary = new KeyCodeExtended(KeyCode.None);
GameSettings.Editor_toggleAngleSnap.secondary = new KeyCodeExtended(KeyCode.None);
}
}
}
}
1 change: 0 additions & 1 deletion Source/RP0.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
<Compile Include="Harmony\EditorPartIcon.cs" />
<Compile Include="Harmony\KerbalRoster.cs" />
<Compile Include="Harmony\KSCSwitcher.cs" />
<Compile Include="Harmony\EditorExtensionsRedux.cs" />
<Compile Include="Harmony\EngineersReport.cs" />
<Compile Include="Harmony\CostWidget.cs" />
<Compile Include="Harmony\AstronautComplex.cs" />
Expand Down

0 comments on commit 340901b

Please sign in to comment.