Skip to content

Commit

Permalink
Added new patches
Browse files Browse the repository at this point in the history
Adds a Quick Restart and Quick exit to Select Song patch
as well as a patch to load saves offline.

and of course, credit to Lukino for that offline saving patch.
  • Loading branch information
cainan-c authored Apr 14, 2022
1 parent e34d5e1 commit 33306c9
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
17 changes: 17 additions & 0 deletions OfflineSaveLoad.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using HarmonyLib;

namespace TaikoModStuff
{
[HarmonyPatch]
public class OfflineSaveLoad
{
[HarmonyPatch(typeof(GameTitleManager), "Start")]
[HarmonyPostfix]
private static void BootManager_Postfix(GameTitleManager __instance)
{
TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData.LoadData("x_game_save_default_container", "save_data_blob");
TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MyDataManager.PlayData.LoadData("x_game_save_default_container", "system_data_blob");
TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MySceneManager.ChangeScene("SongSelect", false);
}
}
}
34 changes: 31 additions & 3 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ public class Plugin : BasePlugin
public static ConfigEntry<int> configCustomFramerate;
public static ConfigEntry<bool> configToggleVSync;

public static ConfigEntry<bool> configEnableRecording;
public static ConfigEntry<bool> configEnableRecording;

public static ConfigEntry<bool> configOfflineSaveLoad;
public static ConfigEntry<bool> configQuickRestart;
public static ConfigEntry<bool> configQuickQuitSong;

public override void Load()
{
Expand Down Expand Up @@ -51,12 +55,36 @@ public override void Load()
true,
"Enables Game Recording from the Xbox Game Bar where it was previously disabled.");

configOfflineSaveLoad = Config.Bind("General.Toggles",
"OfflineSaveLoad",
false,
"Loads local save files even when offline. Bypasses the log-in checks. Requires the FreeLocalSaves Plugin.\nEnabling this without FreeLocalSaves can and will wipe your save file.");

configQuickRestart = Config.Bind("General.Toggles",
"QuickRestart",
false,
"Hit \"Backspace\" on your keyboard to quickly restart a song.");

configQuickQuitSong = Config.Bind("General.Toggles",
"QuickQuitSong",
false,
"Hit \"Escape\" on your keyboard to quickly quit a song and return to Song Select.");


var instance = new Harmony(PluginInfo.PLUGIN_NAME);
instance.PatchAll(typeof(FontChanger));
instance.PatchAll(typeof(CustomResolution));
instance.PatchAll(typeof(ForceFramerate));
instance.PatchAll(typeof(RecordingEnable));
instance.PatchAll(typeof(ForceFramerate));
instance.PatchAll(typeof(RecordingEnable));

if (Plugin.configOfflineSaveLoad.Value)
instance.PatchAll(typeof(OfflineSaveLoad));

if (Plugin.configQuickRestart.Value)
instance.PatchAll(typeof(QuickRestart));

if (Plugin.configQuickQuitSong.Value)
instance.PatchAll(typeof(QuickQuitSong));

// Plugin startup logic
Log.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
Expand Down
22 changes: 22 additions & 0 deletions QuickQuitSong.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using BepInEx;
using HarmonyLib;

namespace TaikoModStuff
{
[HarmonyPatch]
public class QuickQuitSong
{
[HarmonyPatch(typeof(EnsoGameManager), "ProcExecPause")]
[HarmonyPrefix]
static void customProcExecPause()
{
bool keyDown = Input.GetKeyDown(KeyCode.Escape);
if (keyDown)
{
TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MySceneManager.ChangeRelayScene("SongSelect", true);
}
}
}
}
23 changes: 23 additions & 0 deletions QuickRestart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using BepInEx;
using HarmonyLib;

namespace TaikoModStuff
{
[HarmonyPatch]
public class QuickRestart
{
[HarmonyPatch(typeof(EnsoGameManager), "ProcExecPause")]
[HarmonyPrefix]
static void customProcExecPause()
{
bool keyDown = Input.GetKeyDown(KeyCode.Backspace);
if (keyDown)
{
//TaikoSingletonMonoBehaviour<EnsoGameManager>.Instance.Invoke("RestartPlay", 1);
TaikoSingletonMonoBehaviour<CommonObjects>.Instance.MySceneManager.ChangeRelayScene("Enso", true);
}
}
}
}

0 comments on commit 33306c9

Please sign in to comment.