fix: don't make the judgements crazy strict

This commit is contained in:
beerpsi 2024-07-09 01:56:35 +07:00
parent 26c90f5343
commit 6fc5af8050
4 changed files with 33 additions and 20 deletions

View File

@ -13,17 +13,23 @@ namespace UnlockFrameRate;
[BepInProcess("Sinmai.exe")]
public class FrameRatePlugin : BaseUnityPlugin
{
public static int TargetFrameRate { get; private set; } = 60;
public new static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("FrameRate");
public static FrameRatePlugin Instance { get; private set; }
public int TargetFrameRate => _configFrameRate.Value;
public bool PatchJudgementTiming => _configChangeJudgementTiming.Value;
private ConfigEntry<int> _configFrameRate;
private ConfigEntry<int> _configVSyncCount;
private ConfigEntry<bool> _configDisplayFps;
private ConfigEntry<bool> _configChangeJudgementTiming;
private Harmony _harmony;
private void Awake()
{
Instance = this;
_configFrameRate = Config.Bind(
"Config",
"FrameRate",
@ -39,10 +45,14 @@ public class FrameRatePlugin : BaseUnityPlugin
"DisplayFPS",
false,
"Show an FPS counter");
_configChangeJudgementTiming = Config.Bind(
"Config",
"ChangeJudgementTiming",
true,
"Adjusts JUDGEMENT TIMING options to match the new frame rate.\nIf this is enabled, 0.1 in-game offset is equivalent to 10000 / FrameRate.");
if (_configVSyncCount.Value is > 0 and <= 4)
{
TargetFrameRate = Screen.currentResolution.refreshRate / _configVSyncCount.Value;
QualitySettings.vSyncCount = _configVSyncCount.Value;
Logger.LogInfo(
@ -52,7 +62,6 @@ public class FrameRatePlugin : BaseUnityPlugin
}
else
{
TargetFrameRate = _configFrameRate.Value;
Application.targetFrameRate = TargetFrameRate;
QualitySettings.vSyncCount = 0;

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BepInEx.Logging;
using BepInEx.Logging;
namespace UnlockFrameRate;

View File

@ -1,13 +1,13 @@
// ReSharper disable InconsistentNaming
using HarmonyLib;
using Manager;
using Manager.UserDatas;
using Monitor;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using Manager;
using Manager.UserDatas;
namespace UnlockFrameRate;
@ -20,16 +20,25 @@ internal class PatchFrameTime
private static IEnumerable<MethodBase> TargetMethods()
{
var noteJudge = AccessTools.TypeByName("NoteJudge");
var juggeTiming = AccessTools.Inner(noteJudge, "JuggeTiming"); // lol
// This shouldn't be patched, because they make the judgements
// harder or easier depending on your frame rate.
// var noteJudge = AccessTools.TypeByName("NoteJudge");
// var juggeTiming = AccessTools.Inner(noteJudge, "JuggeTiming"); // lol
// yield return AccessTools.Constructor(juggeTiming);
// This changes the effect of judgement timing based on the set FPS,
// so +2.0 at 120Hz will only add 17ms instead of 33ms.
if (FrameRatePlugin.Instance.PatchJudgementTiming)
{
yield return AccessTools.Method(typeof(NoteJudge), nameof(NoteJudge.GetJudgeTiming));
yield return AccessTools.Method(typeof(NoteJudge), nameof(NoteJudge.GetSlideJudgeTiming));
yield return AccessTools.Method(typeof(UserOption), nameof(UserOption.GetAdjustMSec));
}
yield return AccessTools.Constructor(juggeTiming);
yield return AccessTools.Method(typeof(UserOption), nameof(UserOption.GetAdjustMSec));
yield return AccessTools.Method(typeof(NoteBase), "IsNoteCheckTimeStart");
yield return AccessTools.Method(typeof(TouchNoteB), "GetNoteYPosition");
yield return AccessTools.Method(typeof(SlideRoot), "IsNoteCheckTimeStart");
yield return AccessTools.Method(typeof(NoteJudge), nameof(NoteJudge.GetJudgeTiming));
yield return AccessTools.Method(typeof(NoteJudge), nameof(NoteJudge.GetSlideJudgeTiming));
yield return AccessTools.Method(typeof(SlideJudge), nameof(SlideJudge.Initialize));
yield return AccessTools.Method(typeof(JudgeGrade), nameof(JudgeGrade.Initialize));
yield return AccessTools.Method(typeof(NotesManager), nameof(NotesManager.getPlayFirstMsec));
@ -45,8 +54,8 @@ internal class PatchFrameTime
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase __originalMethod)
{
var targetFrameTime = 1000f / FrameRatePlugin.TargetFrameRate;
var targetFramePerMs = (float)FrameRatePlugin.TargetFrameRate / 1000;
var targetFrameTime = 1000f / FrameRatePlugin.Instance.TargetFrameRate;
var targetFramePerMs = (float)FrameRatePlugin.Instance.TargetFrameRate / 1000;
var i = 0;
foreach (var instruction in instructions)

View File

@ -27,7 +27,7 @@ internal class PatchGetMaiBugAdjustMSec
if (Math.Abs(operand - OriginalFrameRate) < float.Epsilon)
{
instruction.operand = (float)FrameRatePlugin.TargetFrameRate;
instruction.operand = (float)FrameRatePlugin.Instance.TargetFrameRate;
FrameRatePlugin.Logger.LogDebug(
"Overrode constant at opcode index {0} in {1}: {2} => {3}",
i,