1
0
forked from akanyan/mu3-mods

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