forked from akanyan/mu3-mods
feat!: rename and reorganize
This commit is contained in:
8
Fixes/LoadBoost/LoadBoost.csproj
Normal file
8
Fixes/LoadBoost/LoadBoost.csproj
Normal file
@ -0,0 +1,8 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Assembly-CSharp.LoadBoost.mm</AssemblyName>
|
||||
<Description>Speed up startup</Description>
|
||||
<OutCategory>fixes</OutCategory>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\..\Mu3Mods.csproj" />
|
||||
</Project>
|
71
Fixes/LoadBoost/MU3.Data/patch_DataManager.cs
Normal file
71
Fixes/LoadBoost/MU3.Data/patch_DataManager.cs
Normal file
@ -0,0 +1,71 @@
|
||||
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 string _fileName;
|
||||
|
||||
private void initCache() {
|
||||
if(File.Exists(_fileName)) {
|
||||
System.Console.WriteLine("Loading chart analysis cache...");
|
||||
_fumenAnalysisData = new Dictionary<int, FumenAnalysisData>();
|
||||
using FileStream input = File.OpenRead(_fileName);
|
||||
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
|
||||
});
|
||||
}
|
||||
} else {
|
||||
_fumenAnalysisData = new Dictionary<int, FumenAnalysisData>();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveCache() {
|
||||
System.Console.WriteLine($"Saving chart analysis cache...{Enumerable.First(_fumenAnalysisData).Key},{Enumerable.First(_fumenAnalysisData).Value.notesDesignerName}");
|
||||
if(File.Exists(_fileName)) {
|
||||
File.Delete(_fileName);
|
||||
}
|
||||
using FileStream fileStream = File.OpenWrite(_fileName);
|
||||
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();
|
||||
}
|
||||
|
||||
private extern void orig_makeFumenAnalysisDataList();
|
||||
|
||||
private void makeFumenAnalysisDataList() {
|
||||
using IniFile iniFile = new("mu3.ini");
|
||||
_fileName = Path.Combine(iniFile.getValue("Extra", "CacheDir", "."), "data_fumen_analysis_cache.bin");
|
||||
|
||||
try {
|
||||
if(patch_DataStudioManager.needSave || !File.Exists(_fileName)) {
|
||||
orig_makeFumenAnalysisDataList();
|
||||
saveCache();
|
||||
} else {
|
||||
initCache();
|
||||
}
|
||||
} catch(Exception value) {
|
||||
System.Console.WriteLine(value);
|
||||
}
|
||||
}
|
||||
}
|
66
Fixes/LoadBoost/MU3.Data/patch_DataStudioManager.cs
Normal file
66
Fixes/LoadBoost/MU3.Data/patch_DataStudioManager.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
namespace MU3.Data;
|
||||
|
||||
public class patch_DataStudioManager: DataStudioManager {
|
||||
public static bool needSave;
|
||||
private static string _fileName;
|
||||
private static Dictionary<string, object> _dataCache;
|
||||
|
||||
private static void initCache() {
|
||||
using IniFile iniFile = new("mu3.ini");
|
||||
var dir = iniFile.getValue("Extra", "CacheDir", ".");
|
||||
Directory.CreateDirectory(dir);
|
||||
_fileName = Path.Combine(dir, "data_cache.bin");
|
||||
|
||||
if(File.Exists(_fileName)) {
|
||||
System.Console.WriteLine("Loading data cache...");
|
||||
using FileStream serializationStream = File.OpenRead(_fileName);
|
||||
_dataCache = (Dictionary<string, object>)new BinaryFormatter().Deserialize(serializationStream);
|
||||
return;
|
||||
}
|
||||
_dataCache = new();
|
||||
}
|
||||
|
||||
private static void saveCache() {
|
||||
if(_fileName == "") {
|
||||
return;
|
||||
}
|
||||
if(File.Exists(_fileName)) {
|
||||
File.Delete(_fileName);
|
||||
}
|
||||
using FileStream serializationStream = File.OpenWrite(_fileName);
|
||||
new BinaryFormatter().Serialize(serializationStream, _dataCache);
|
||||
}
|
||||
|
||||
private static extern bool orig_Deserialize<T>(string filePath, out T dsr) where T : new();
|
||||
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(filePath, out dsr)) {
|
||||
needSave = true;
|
||||
_dataCache.Add(filePath, dsr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public extern bool orig_IsLoaded();
|
||||
public new bool IsLoaded() {
|
||||
if(orig_IsLoaded()) {
|
||||
if(needSave) {
|
||||
System.Console.WriteLine("Saving data cache...");
|
||||
saveCache();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
16
Fixes/LoadBoost/MU3.Sequence/patch_Initialize.cs
Normal file
16
Fixes/LoadBoost/MU3.Sequence/patch_Initialize.cs
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user