feat: add 4 things

* DisableEncryption
* LoadBoost
* UnlockFrameRate
* UnlockMasterDifficulty

WIP, not fully reviewed/tested yet.
This commit is contained in:
あかニャン 2024-07-04 21:43:10 +09:00
parent b54b8676c1
commit 42cf65bdb7
12 changed files with 266 additions and 0 deletions

View File

@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<AssemblyName>Assembly-CSharp.DisableEncryption.mm</AssemblyName>
<Description>Disable encryption</Description>
</PropertyGroup>
<Import Project="..\Mu3Mods.csproj" />
</Project>

View File

@ -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;
}
}
}

View File

@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<AssemblyName>Assembly-CSharp.LoadBoost.mm</AssemblyName>
<Description>Speed up startup</Description>
</PropertyGroup>
<Import Project="..\Mu3Mods.csproj" />
</Project>

View File

@ -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<int, FumenAnalysisData> _fumenAnalysisData;
private void InitCache() {
if(File.Exists("data_fumen_analysis_cache.bin")) {
System.Console.WriteLine("Loading FumenAnalysisData cache...");
_fumenAnalysisData = new Dictionary<int, FumenAnalysisData>();
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<int, FumenAnalysisData>();
}
}
private void SaveCache() {
System.Console.WriteLine($"Saving FumenAnalysisData cache...{Enumerable.First<KeyValuePair<int, FumenAnalysisData>>((IEnumerable<KeyValuePair<int, FumenAnalysisData>>)_fumenAnalysisData).Key},{Enumerable.First<KeyValuePair<int, FumenAnalysisData>>((IEnumerable<KeyValuePair<int, FumenAnalysisData>>)_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<int, FumenAnalysisData> 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);
}
}
}

View File

@ -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<string, object> _dataCache;
private static extern bool orig_Deserialize<T>(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<string, object>)new BinaryFormatter().Deserialize(serializationStream);
return;
}
_dataCache = new Dictionary<string, object>();
}
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<T>(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<T>(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;
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,11 @@
namespace MU3.Notes;
class patch_NotesManager: NotesManager {
private float _frame;
private float _frameReal;
private void progressFrameAndFrameReal() {
_frame = _frameReal;
}
}

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<AssemblyName>Assembly-CSharp.UnlockFramerate.mm</AssemblyName>
<Description>Unlock framerate</Description>
</PropertyGroup>
<Import Project="..\Mu3Mods.csproj" />
</Project>

View File

@ -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 */ }
}
}

View File

@ -0,0 +1,8 @@
<Project>
<PropertyGroup>
<AssemblyName>Assembly-CSharp.UnlockMasterDifficulty.mm</AssemblyName>
<Description>Unlock master difficulty</Description>
<ProjectGuid>{965FCDBC-12EA-4F31-AAF6-9C4C3B9F7022}</ProjectGuid>
</PropertyGroup>
<Import Project="..\Mu3Mods.csproj" />
</Project>