上传文件至 Common
This commit is contained in:
58
Common/ChangeFadeStyle.cs
Normal file
58
Common/ChangeFadeStyle.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using Process;
|
||||
|
||||
namespace SinmaiAssist.Common;
|
||||
|
||||
public class ChangeFadeStyle
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(FadeProcess), "OnStart")]
|
||||
public static IEnumerable<CodeInstruction> TranspilerFade(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
var codes = new List<CodeInstruction>(instructions);
|
||||
bool isFound = false;
|
||||
|
||||
for (int i = 0; i < codes.Count - 1; i++)
|
||||
{
|
||||
if (codes[i].opcode == OpCodes.Ldstr && codes[i].operand.ToString().StartsWith("Process/ChangeScreen/Prefabs/ChangeScreen_"))
|
||||
{
|
||||
var typeString = "02";
|
||||
if (codes[i].operand.ToString().EndsWith("02")) typeString = "01";
|
||||
codes[i].operand = $"Process/ChangeScreen/Prefabs/ChangeScreen_{typeString}";
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isFound)
|
||||
MelonLogger.Warning("Failed to patch ChangeFadeStyle, Method Not Found!");
|
||||
|
||||
return codes;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(NextTrackProcess), "OnStart")]
|
||||
public static IEnumerable<CodeInstruction> TranspilerNextTrack(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
var codes = new List<CodeInstruction>(instructions);
|
||||
bool isFound = false;
|
||||
|
||||
for (int i = 0; i < codes.Count - 1; i++)
|
||||
{
|
||||
if (codes[i].opcode == OpCodes.Ldstr && codes[i].operand.ToString().StartsWith("Process/ChangeScreen/Prefabs/ChangeScreen_"))
|
||||
{
|
||||
var typeString = "02";
|
||||
if (codes[i].operand.ToString().EndsWith("02")) typeString = "01";
|
||||
codes[i].operand = $"Process/ChangeScreen/Prefabs/ChangeScreen_{typeString}";
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isFound)
|
||||
MelonLogger.Warning("Failed to patch ChangeFadeStyle, Method Not Found!");
|
||||
|
||||
return codes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user