From 42cf65bdb7271d5b8582dd6d02f3cfd0d913807f Mon Sep 17 00:00:00 2001 From: akanyan Date: Thu, 4 Jul 2024 21:43:10 +0900 Subject: [PATCH] feat: add 4 things * DisableEncryption * LoadBoost * UnlockFrameRate * UnlockMasterDifficulty WIP, not fully reviewed/tested yet. --- DisableEncryption/DisableEncryption.csproj | 7 ++ DisableEncryption/MU3/patch_NetConfig.cs | 28 ++++++++ LoadBoost/LoadBoost.csproj | 7 ++ LoadBoost/MU3.Data/patch_DataManager.cs | 70 +++++++++++++++++++ LoadBoost/MU3.Data/patch_DataStudioManager.cs | 60 ++++++++++++++++ LoadBoost/MU3.Sequence/patch_Initialize.cs | 16 +++++ .../MU3.Notes/patch_NotesManager.cs | 11 +++ UnlockFrameRate/MU3.Sys/patch_Config.cs | 19 +++++ UnlockFrameRate/MU3.Sys/patch_Time.cs | 20 ++++++ UnlockFrameRate/UnlockFrameRate.csproj | 7 ++ .../MU3.ViewData/patch_MusicViewData.cs | 13 ++++ .../UnlockMasterDifficulty.csproj | 8 +++ 12 files changed, 266 insertions(+) create mode 100644 DisableEncryption/DisableEncryption.csproj create mode 100644 DisableEncryption/MU3/patch_NetConfig.cs create mode 100644 LoadBoost/LoadBoost.csproj create mode 100644 LoadBoost/MU3.Data/patch_DataManager.cs create mode 100644 LoadBoost/MU3.Data/patch_DataStudioManager.cs create mode 100644 LoadBoost/MU3.Sequence/patch_Initialize.cs create mode 100644 UnlockFrameRate/MU3.Notes/patch_NotesManager.cs create mode 100644 UnlockFrameRate/MU3.Sys/patch_Config.cs create mode 100644 UnlockFrameRate/MU3.Sys/patch_Time.cs create mode 100644 UnlockFrameRate/UnlockFrameRate.csproj create mode 100644 UnlockMasterDifficulty/MU3.ViewData/patch_MusicViewData.cs create mode 100644 UnlockMasterDifficulty/UnlockMasterDifficulty.csproj diff --git a/DisableEncryption/DisableEncryption.csproj b/DisableEncryption/DisableEncryption.csproj new file mode 100644 index 0000000..2dc87c7 --- /dev/null +++ b/DisableEncryption/DisableEncryption.csproj @@ -0,0 +1,7 @@ + + + Assembly-CSharp.DisableEncryption.mm + Disable encryption + + + \ No newline at end of file diff --git a/DisableEncryption/MU3/patch_NetConfig.cs b/DisableEncryption/MU3/patch_NetConfig.cs new file mode 100644 index 0000000..1717938 --- /dev/null +++ b/DisableEncryption/MU3/patch_NetConfig.cs @@ -0,0 +1,28 @@ +using MonoMod; + +namespace MU3; + +[MonoModPatch("global::MU3.NetConfig")] +public static class patch_NetConfig { + private static int encryptVersion_; + + private static bool useTLS_; + + public static int EncryptVersion { + get { + return 0; + } + set { + encryptVersion_ = 0; + } + } + + public static bool UseTLS { + get { + return false; + } + set { + useTLS_ = false; + } + } +} diff --git a/LoadBoost/LoadBoost.csproj b/LoadBoost/LoadBoost.csproj new file mode 100644 index 0000000..44300da --- /dev/null +++ b/LoadBoost/LoadBoost.csproj @@ -0,0 +1,7 @@ + + + Assembly-CSharp.LoadBoost.mm + Speed up startup + + + \ No newline at end of file diff --git a/LoadBoost/MU3.Data/patch_DataManager.cs b/LoadBoost/MU3.Data/patch_DataManager.cs new file mode 100644 index 0000000..5064ca4 --- /dev/null +++ b/LoadBoost/MU3.Data/patch_DataManager.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace MU3.Data; + +public class patch_DataManager: DataManager { + private Dictionary _fumenAnalysisData; + + private void InitCache() { + if(File.Exists("data_fumen_analysis_cache.bin")) { + System.Console.WriteLine("Loading FumenAnalysisData cache..."); + _fumenAnalysisData = new Dictionary(); + using(FileStream input = File.OpenRead("data_fumen_analysis_cache.bin")) { + using BinaryReader binaryReader = new BinaryReader(input); + while(binaryReader.BaseStream.Position < binaryReader.BaseStream.Length) { + int key = binaryReader.ReadInt32(); + bool isExist = binaryReader.ReadBoolean(); + int bpm = binaryReader.ReadInt32(); + int platinumScoreMax = binaryReader.ReadInt32(); + string notesDesignerName = binaryReader.ReadString(); + _fumenAnalysisData.Add(key, new FumenAnalysisData { + isExist = isExist, + bpm = bpm, + platinumScoreMax = platinumScoreMax, + notesDesignerName = notesDesignerName + }); + } + } + System.Console.WriteLine("Success"); + } else { + _fumenAnalysisData = new Dictionary(); + } + } + + private void SaveCache() { + System.Console.WriteLine($"Saving FumenAnalysisData cache...{Enumerable.First>((IEnumerable>)_fumenAnalysisData).Key},{Enumerable.First>((IEnumerable>)_fumenAnalysisData).Value.notesDesignerName}"); + if(File.Exists("data_fumen_analysis_cache.bin")) { + File.Delete("data_fumen_analysis_cache.bin"); + } + using(FileStream fileStream = File.OpenWrite("data_fumen_analysis_cache.bin")) { + using BinaryWriter binaryWriter = new BinaryWriter(fileStream); + foreach(KeyValuePair fumenAnalysisDatum in _fumenAnalysisData) { + binaryWriter.Write(fumenAnalysisDatum.Key); + binaryWriter.Write(fumenAnalysisDatum.Value.isExist); + binaryWriter.Write(fumenAnalysisDatum.Value.bpm); + binaryWriter.Write(fumenAnalysisDatum.Value.platinumScoreMax); + binaryWriter.Write(fumenAnalysisDatum.Value.notesDesignerName); + } + fileStream.Flush(); + } + System.Console.WriteLine("Success"); + } + + private extern void orig_makeFumenAnalysisDataList(); + + private void makeFumenAnalysisDataList() { + try { + if(DataStudioManager.needSave || !File.Exists("data_fumen_analysis_cache.bin")) { + orig_makeFumenAnalysisDataList(); + SaveCache(); + } else { + InitCache(); + } + } catch(Exception value) { + System.Console.WriteLine(value); + } + } +} diff --git a/LoadBoost/MU3.Data/patch_DataStudioManager.cs b/LoadBoost/MU3.Data/patch_DataStudioManager.cs new file mode 100644 index 0000000..e0f670d --- /dev/null +++ b/LoadBoost/MU3.Data/patch_DataStudioManager.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; +using System.IO; +using System.Runtime.Serialization.Formatters.Binary; + +namespace MU3.Data; + +public class DataStudioManager { + public static bool needSave; + + private static Dictionary _dataCache; + + private static extern bool orig_Deserialize(string filePath, out T dsr) where T : new(); + + private static void InitCache() { + if(File.Exists("data_cache.bin")) { + System.Console.WriteLine("Loading cache..."); + using FileStream serializationStream = File.OpenRead("data_cache.bin"); + _dataCache = (Dictionary)new BinaryFormatter().Deserialize(serializationStream); + return; + } + _dataCache = new Dictionary(); + } + + private static void SaveCache() { + if(File.Exists("data_cache.bin")) { + File.Delete("data_cache.bin"); + } + using FileStream serializationStream = File.OpenWrite("data_cache.bin"); + new BinaryFormatter().Serialize(serializationStream, _dataCache); + } + + private static bool Deserialize(string filePath, out T dsr) where T : new() { + if(_dataCache == null) { + InitCache(); + } + if(_dataCache.ContainsKey(filePath)) { + dsr = (T)_dataCache[filePath]; + return true; + } + if(orig_Deserialize(filePath, out dsr)) { + needSave = true; + _dataCache.Add(filePath, dsr); + return true; + } + return false; + } + + public extern bool orig_IsLoaded(); + + public bool IsLoaded() { + if(orig_IsLoaded()) { + if(needSave) { + System.Console.WriteLine("Saving cache..."); + SaveCache(); + } + return true; + } + return false; + } +} diff --git a/LoadBoost/MU3.Sequence/patch_Initialize.cs b/LoadBoost/MU3.Sequence/patch_Initialize.cs new file mode 100644 index 0000000..a1154e6 --- /dev/null +++ b/LoadBoost/MU3.Sequence/patch_Initialize.cs @@ -0,0 +1,16 @@ +using MU3.SceneObject; + +namespace MU3.Sequence; + +public class patch_Initialize: Initialize { + private Scene_12_Initialize _initializeObject; + + private void Execute_InitQRReader() { + _initializeObject.setQRCodeReaderStatus("SKIP"); + setNextState(EState.CheckDelivery); + } + + private void Enter_Warning() { + setNextState(EState.StateEnd); + } +} diff --git a/UnlockFrameRate/MU3.Notes/patch_NotesManager.cs b/UnlockFrameRate/MU3.Notes/patch_NotesManager.cs new file mode 100644 index 0000000..f35a789 --- /dev/null +++ b/UnlockFrameRate/MU3.Notes/patch_NotesManager.cs @@ -0,0 +1,11 @@ +namespace MU3.Notes; + +class patch_NotesManager: NotesManager { + private float _frame; + + private float _frameReal; + + private void progressFrameAndFrameReal() { + _frame = _frameReal; + } +} diff --git a/UnlockFrameRate/MU3.Sys/patch_Config.cs b/UnlockFrameRate/MU3.Sys/patch_Config.cs new file mode 100644 index 0000000..953b26c --- /dev/null +++ b/UnlockFrameRate/MU3.Sys/patch_Config.cs @@ -0,0 +1,19 @@ +using UnityEngine; + +namespace MU3.Sys; + +class patch_Config: Config { + public extern void orig_initialize(); + + public new void initialize() { + orig_initialize(); + + using IniFile iniFile = new("mu3.ini"); + + if(iniFile.getIntValue("Video", "VSync", 0) != 0) { + QualitySettings.vSyncCount = 1; + } else { + Application.targetFrameRate = iniFile.getIntValue("Video", "Framerate", 60); + } + } +} diff --git a/UnlockFrameRate/MU3.Sys/patch_Time.cs b/UnlockFrameRate/MU3.Sys/patch_Time.cs new file mode 100644 index 0000000..a00b13e --- /dev/null +++ b/UnlockFrameRate/MU3.Sys/patch_Time.cs @@ -0,0 +1,20 @@ +namespace MU3.Sys; + +class patch_Time: Time { + private static bool _init; + + private static float _deltaTime; + + private static float _adjustAccumlation; + + private static float _realtimeSinceStartup; + + public static new void update() { + if(!_init) { + _adjustAccumlation = 0f; + _init = true; + } + _deltaTime = UnityEngine.Time.deltaTime; + _realtimeSinceStartup = UnityEngine.Time.realtimeSinceStartup; + } +} diff --git a/UnlockFrameRate/UnlockFrameRate.csproj b/UnlockFrameRate/UnlockFrameRate.csproj new file mode 100644 index 0000000..614816c --- /dev/null +++ b/UnlockFrameRate/UnlockFrameRate.csproj @@ -0,0 +1,7 @@ + + + Assembly-CSharp.UnlockFramerate.mm + Unlock framerate + + + \ No newline at end of file diff --git a/UnlockMasterDifficulty/MU3.ViewData/patch_MusicViewData.cs b/UnlockMasterDifficulty/MU3.ViewData/patch_MusicViewData.cs new file mode 100644 index 0000000..b05c744 --- /dev/null +++ b/UnlockMasterDifficulty/MU3.ViewData/patch_MusicViewData.cs @@ -0,0 +1,13 @@ +using MonoMod; + +namespace MU3.ViewData; + +[MonoModPatch("global::MU3.ViewData.MusicViewData")] +public class patch_MusicViewData { + public bool isMasterLock { + get { + return false; + } + set { /* nop */ } + } +} diff --git a/UnlockMasterDifficulty/UnlockMasterDifficulty.csproj b/UnlockMasterDifficulty/UnlockMasterDifficulty.csproj new file mode 100644 index 0000000..b0187fb --- /dev/null +++ b/UnlockMasterDifficulty/UnlockMasterDifficulty.csproj @@ -0,0 +1,8 @@ + + + Assembly-CSharp.UnlockMasterDifficulty.mm + Unlock master difficulty + {965FCDBC-12EA-4F31-AAF6-9C4C3B9F7022} + + + \ No newline at end of file