1
0
mirror of synced 2024-11-12 01:00:48 +01:00

feat: Allow toggling VSync

This commit is contained in:
Repflez 2022-01-27 16:39:40 -07:00
parent a569ca3dee
commit be7049a6d9
3 changed files with 13 additions and 3 deletions

View File

@ -5,6 +5,8 @@ namespace TaikoModStuff
{
internal class ForceFramerate
{
private static readonly int VSyncFrames = Plugin.configToggleVSync.Value ? 1 : 0;
// Skip the original method, we're doing magic here
[HarmonyPatch(typeof(ForceRenderRate), "Start")]
[HarmonyPrefix]
@ -26,7 +28,7 @@ namespace TaikoModStuff
static void customStart()
{
// Force vsync at all times
QualitySettings.vSyncCount = 1;
QualitySettings.vSyncCount = VSyncFrames;
Application.targetFrameRate = Plugin.configCustomFramerate.Value;
}
@ -35,7 +37,7 @@ namespace TaikoModStuff
static void customUpdate()
{
// Force vsync at all times
QualitySettings.vSyncCount = 1;
QualitySettings.vSyncCount = VSyncFrames;
Application.targetFrameRate = Plugin.configCustomFramerate.Value;
}
}

View File

@ -13,6 +13,7 @@ namespace TaikoModStuff
public static ConfigEntry<int> configCustomWindowedHeight;
public static ConfigEntry<int> configCustomFramerate;
public static ConfigEntry<bool> configToggleVSync;
private void Awake()
{
@ -37,6 +38,13 @@ namespace TaikoModStuff
60,
"Custom framerate. Use with caution");
configToggleVSync = Config.Bind("General.Graphics",
"EnableVSync",
true,
"Enable VSync.");
var instance = new Harmony(PluginInfo.PLUGIN_NAME);
instance.PatchAll(typeof(FontChanger));
instance.PatchAll(typeof(CustomResolution));

View File

@ -4,7 +4,7 @@
<TargetFramework>net46</TargetFramework>
<AssemblyName>TaikoModStuff</AssemblyName>
<Description>My first plugin</Description>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>