2022-01-27 23:21:14 +01:00
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace TaikoModStuff
|
|
|
|
|
{
|
|
|
|
|
internal class ForceFramerate
|
|
|
|
|
{
|
2022-01-28 00:39:40 +01:00
|
|
|
|
private static readonly int VSyncFrames = Plugin.configToggleVSync.Value ? 1 : 0;
|
|
|
|
|
|
2022-01-27 23:21:14 +01:00
|
|
|
|
// Skip the original method, we're doing magic here
|
|
|
|
|
[HarmonyPatch(typeof(ForceRenderRate), "Start")]
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
static bool PrefixFocus()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Skip the original method, we're doing magic here
|
|
|
|
|
[HarmonyPatch(typeof(ForceRenderRate), "Update")]
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
static bool PrefixScreenType()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch(typeof(ForceRenderRate), "Start")]
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
static void customStart()
|
|
|
|
|
{
|
|
|
|
|
// Force vsync at all times
|
2022-01-28 00:39:40 +01:00
|
|
|
|
QualitySettings.vSyncCount = VSyncFrames;
|
2022-01-27 23:21:14 +01:00
|
|
|
|
Application.targetFrameRate = Plugin.configCustomFramerate.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch(typeof(ForceRenderRate), "Update")]
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
static void customUpdate()
|
|
|
|
|
{
|
|
|
|
|
// Force vsync at all times
|
2022-01-28 00:39:40 +01:00
|
|
|
|
QualitySettings.vSyncCount = VSyncFrames;
|
2022-01-27 23:21:14 +01:00
|
|
|
|
Application.targetFrameRate = Plugin.configCustomFramerate.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|