[+] Support official quick retry (3456) in UX/QuickSkip

Merge pull request #60

* Official quick retry
pull/58/head^2
Menci 2024-10-13 21:45:14 +08:00 committed by GitHub
parent 81e0232712
commit cdfb86e021
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 233 additions and 202 deletions

View File

@ -26,6 +26,7 @@ LoadAssetsPng=true
# Use together with `LoadJacketPng`
LoadLocalBga=true
# Press key "7" for 1 second to skip to next step or restart current song
# Hold the bottom four buttons (3456) for official quick retry (non-utage only)
QuickSkip=true
# Add ".ab" image resources without the need of rebuilding a manifest
LoadAssetBundleWithoutManifest=true

View File

@ -33,6 +33,7 @@ LoadLocalBga=true
# - 在选歌界面直接结束游戏
# 在游玩界面,按一下 “7” 或者 Service 键重开当前的歌,按 1P 的“选择”键立即结束当前乐曲
# 打完最后一个音符之后也可以
# 按住下方四个按钮3456使用官方快速重开仅对非宴谱有效
QuickSkip=true
# 优化图片资源的加载,就算没有 AssetBundleImages.manifest 也可以正常加载 ab 格式的图片资源
# 导入了删除曲包之类的话,应该需要开启这个

View File

@ -6,6 +6,7 @@ using MAI2.Util;
using Main;
using Manager;
using MelonLoader;
using Monitor;
using Process;
using UnityEngine;
@ -84,5 +85,33 @@ namespace AquaMai.UX
Singleton<GamePlayManager>.Instance.SetQuickRetryFrag(flag: true);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(QuickRetry), "IsQuickRetryEnable")]
public static bool OnQuickRetryIsQuickRetryEnable(ref bool __result)
{
var isUtageProperty = Traverse.Create(typeof(GameManager)).Property("IsUtage");
__result = !isUtageProperty.PropertyExists() || !isUtageProperty.GetValue<bool>();
return false;
}
// Fix for the game not resetting Fast and Late counts when quick retrying
// For game version < 1.35.0
[HarmonyPostfix]
[HarmonyPatch(typeof(GamePlayManager), "SetQuickRetryFrag")]
public static void PostGamePlayManagerSetQuickRetryFrag(GamePlayManager __instance, bool flag)
{
// Since 1.35.0, `GameScoreList.Initialize()` resets the Fast and Late counts
if (flag && !Traverse.Create(typeof(GameScoreList)).Methods().Contains("Initialize"))
{
for (int i = 0; i < 4; i++)
{
var gameScoreList = __instance.GetGameScore(i);
var traverse = Traverse.Create(gameScoreList);
traverse.Property("Fast").SetValue((uint)0);
traverse.Property("Late").SetValue((uint)0);
}
}
}
}
}