mirror of
https://gitea.tendokyu.moe/beerpsi/sinmai-mods.git
synced 2025-02-21 12:51:24 +01:00
fix: don't make the judgements crazy strict
This commit is contained in:
parent
26c90f5343
commit
6fc5af8050
@ -13,17 +13,23 @@ namespace UnlockFrameRate;
|
|||||||
[BepInProcess("Sinmai.exe")]
|
[BepInProcess("Sinmai.exe")]
|
||||||
public class FrameRatePlugin : BaseUnityPlugin
|
public class FrameRatePlugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
public static int TargetFrameRate { get; private set; } = 60;
|
|
||||||
public new static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("FrameRate");
|
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> _configFrameRate;
|
||||||
private ConfigEntry<int> _configVSyncCount;
|
private ConfigEntry<int> _configVSyncCount;
|
||||||
private ConfigEntry<bool> _configDisplayFps;
|
private ConfigEntry<bool> _configDisplayFps;
|
||||||
|
private ConfigEntry<bool> _configChangeJudgementTiming;
|
||||||
|
|
||||||
private Harmony _harmony;
|
private Harmony _harmony;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
Instance = this;
|
||||||
|
|
||||||
_configFrameRate = Config.Bind(
|
_configFrameRate = Config.Bind(
|
||||||
"Config",
|
"Config",
|
||||||
"FrameRate",
|
"FrameRate",
|
||||||
@ -39,10 +45,14 @@ public class FrameRatePlugin : BaseUnityPlugin
|
|||||||
"DisplayFPS",
|
"DisplayFPS",
|
||||||
false,
|
false,
|
||||||
"Show an FPS counter");
|
"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)
|
if (_configVSyncCount.Value is > 0 and <= 4)
|
||||||
{
|
{
|
||||||
TargetFrameRate = Screen.currentResolution.refreshRate / _configVSyncCount.Value;
|
|
||||||
QualitySettings.vSyncCount = _configVSyncCount.Value;
|
QualitySettings.vSyncCount = _configVSyncCount.Value;
|
||||||
|
|
||||||
Logger.LogInfo(
|
Logger.LogInfo(
|
||||||
@ -52,7 +62,6 @@ public class FrameRatePlugin : BaseUnityPlugin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TargetFrameRate = _configFrameRate.Value;
|
|
||||||
Application.targetFrameRate = TargetFrameRate;
|
Application.targetFrameRate = TargetFrameRate;
|
||||||
QualitySettings.vSyncCount = 0;
|
QualitySettings.vSyncCount = 0;
|
||||||
|
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using System;
|
using BepInEx.Logging;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using BepInEx.Logging;
|
|
||||||
|
|
||||||
namespace UnlockFrameRate;
|
namespace UnlockFrameRate;
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using Manager;
|
||||||
|
using Manager.UserDatas;
|
||||||
using Monitor;
|
using Monitor;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
using Manager;
|
|
||||||
using Manager.UserDatas;
|
|
||||||
|
|
||||||
namespace UnlockFrameRate;
|
namespace UnlockFrameRate;
|
||||||
|
|
||||||
@ -20,16 +20,25 @@ internal class PatchFrameTime
|
|||||||
|
|
||||||
private static IEnumerable<MethodBase> TargetMethods()
|
private static IEnumerable<MethodBase> TargetMethods()
|
||||||
{
|
{
|
||||||
var noteJudge = AccessTools.TypeByName("NoteJudge");
|
// This shouldn't be patched, because they make the judgements
|
||||||
var juggeTiming = AccessTools.Inner(noteJudge, "JuggeTiming"); // lol
|
// 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);
|
// 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.Method(typeof(UserOption), nameof(UserOption.GetAdjustMSec));
|
||||||
|
}
|
||||||
|
|
||||||
yield return AccessTools.Method(typeof(NoteBase), "IsNoteCheckTimeStart");
|
yield return AccessTools.Method(typeof(NoteBase), "IsNoteCheckTimeStart");
|
||||||
yield return AccessTools.Method(typeof(TouchNoteB), "GetNoteYPosition");
|
yield return AccessTools.Method(typeof(TouchNoteB), "GetNoteYPosition");
|
||||||
yield return AccessTools.Method(typeof(SlideRoot), "IsNoteCheckTimeStart");
|
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(SlideJudge), nameof(SlideJudge.Initialize));
|
||||||
yield return AccessTools.Method(typeof(JudgeGrade), nameof(JudgeGrade.Initialize));
|
yield return AccessTools.Method(typeof(JudgeGrade), nameof(JudgeGrade.Initialize));
|
||||||
yield return AccessTools.Method(typeof(NotesManager), nameof(NotesManager.getPlayFirstMsec));
|
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)
|
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase __originalMethod)
|
||||||
{
|
{
|
||||||
var targetFrameTime = 1000f / FrameRatePlugin.TargetFrameRate;
|
var targetFrameTime = 1000f / FrameRatePlugin.Instance.TargetFrameRate;
|
||||||
var targetFramePerMs = (float)FrameRatePlugin.TargetFrameRate / 1000;
|
var targetFramePerMs = (float)FrameRatePlugin.Instance.TargetFrameRate / 1000;
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
foreach (var instruction in instructions)
|
foreach (var instruction in instructions)
|
||||||
|
@ -27,7 +27,7 @@ internal class PatchGetMaiBugAdjustMSec
|
|||||||
|
|
||||||
if (Math.Abs(operand - OriginalFrameRate) < float.Epsilon)
|
if (Math.Abs(operand - OriginalFrameRate) < float.Epsilon)
|
||||||
{
|
{
|
||||||
instruction.operand = (float)FrameRatePlugin.TargetFrameRate;
|
instruction.operand = (float)FrameRatePlugin.Instance.TargetFrameRate;
|
||||||
FrameRatePlugin.Logger.LogDebug(
|
FrameRatePlugin.Logger.LogDebug(
|
||||||
"Overrode constant at opcode index {0} in {1}: {2} => {3}",
|
"Overrode constant at opcode index {0} in {1}: {2} => {3}",
|
||||||
i,
|
i,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user