Skip to content

Commit

Permalink
options fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
repkins committed Dec 27, 2022
1 parent 5f7f7f6 commit 2916a35
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions TerraformingShared/Configuration/uGuiOptionsPanelPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,44 +94,24 @@ public static void AddTerraformingSection(uGUI_OptionsPanel __instance)
}
}

[HarmonyPatch(typeof(uGUI_TabbedControlsPanel))]
[HarmonyPatch(nameof(uGUI_TabbedControlsPanel.SetVisibleTab))]
public static class SetVisibleTabPatch
{
[HarmonyPrefix]
public static void OnSwitchingFromModsTab_SaveTerraformingConfig(uGUI_TabbedControlsPanel __instance, int tabIndex)
{
if (nullableModsTabIndex.HasValue)
{
var modsTabIndex = nullableModsTabIndex.Value;

// If navigating from Mods tab...
if (__instance.currentTab == modsTabIndex && tabIndex != modsTabIndex)
{
Config.Save();
}
}
}
}

[HarmonyPatch(typeof(uGUI_OptionsPanel))]
[HarmonyPatch(nameof(uGUI_OptionsPanel.OnDisable))]
public static class OnDisablePatch
{
[HarmonyPostfix]
public static void OnClosingOptionsPanelAtModsTab_SaveTerraformingConfig(uGUI_OptionsPanel __instance)
public static void SaveTerraformingConfig(uGUI_OptionsPanel __instance)
{
if (nullableModsTabIndex.HasValue)
{
var modsTabIndex = nullableModsTabIndex.Value;

// If at Mods tab...
if (__instance.currentTab == modsTabIndex)
{
Config.Save();
}
Config.Save();
}
}

[HarmonyPostfix]
public static void DeassignModsTabIndex()
{
nullableModsTabIndex = null;
}
}
}
}

0 comments on commit 2916a35

Please sign in to comment.