Skip to content

Commit

Permalink
feat: Allow toggling VSync
Browse files Browse the repository at this point in the history
  • Loading branch information
Repflez committed Jan 27, 2022
1 parent a569ca3 commit be7049a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions ForceFramerate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -26,7 +28,7 @@ static bool PrefixScreenType()
static void customStart()
{
// Force vsync at all times
QualitySettings.vSyncCount = 1;
QualitySettings.vSyncCount = VSyncFrames;
Application.targetFrameRate = Plugin.configCustomFramerate.Value;
}

Expand All @@ -35,7 +37,7 @@ static void customStart()
static void customUpdate()
{
// Force vsync at all times
QualitySettings.vSyncCount = 1;
QualitySettings.vSyncCount = VSyncFrames;
Application.targetFrameRate = Plugin.configCustomFramerate.Value;
}
}
Expand Down
8 changes: 8 additions & 0 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Plugin : BaseUnityPlugin
public static ConfigEntry<int> configCustomWindowedHeight;

public static ConfigEntry<int> configCustomFramerate;
public static ConfigEntry<bool> configToggleVSync;

private void Awake()
{
Expand All @@ -37,6 +38,13 @@ private void Awake()
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));
Expand Down
2 changes: 1 addition & 1 deletion TaikoModStuff.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit be7049a

Please sign in to comment.