feat: various enhancements
* AttractVideoPlayer,LoadBoost: allow setting a cache directory * AttractVideoPlayer: color leds * BetterGiveUp: prevent multiple restarts in a row * use GetTriggerOn in general where applicable
This commit is contained in:
parent
8cbc7e8b86
commit
4ad595f6c3
@ -5,18 +5,22 @@ using System.IO;
|
|||||||
namespace MU3.Operation;
|
namespace MU3.Operation;
|
||||||
|
|
||||||
class patch_OperationManager: OperationManager {
|
class patch_OperationManager: OperationManager {
|
||||||
private static readonly string _fname = "data_advert_cache.txt";
|
|
||||||
private ReadOnlyCollection<MovieData> _movieDataList;
|
private ReadOnlyCollection<MovieData> _movieDataList;
|
||||||
private int _movieIndex;
|
private int _movieIndex;
|
||||||
|
private string _fileName;
|
||||||
|
|
||||||
~patch_OperationManager() {
|
~patch_OperationManager() {
|
||||||
try {
|
try {
|
||||||
File.WriteAllText(_fname, _movieIndex.ToString());
|
File.WriteAllText(_fileName, MovieIndex.ToString());
|
||||||
} catch(Exception) {}
|
} catch(Exception) { }
|
||||||
}
|
}
|
||||||
public int MovieIndex {
|
public int MovieIndex {
|
||||||
set {
|
set {
|
||||||
|
if(_movieDataList.Count > 0) {
|
||||||
_movieIndex = (value + _movieDataList.Count) % _movieDataList.Count;
|
_movieIndex = (value + _movieDataList.Count) % _movieDataList.Count;
|
||||||
|
} else {
|
||||||
|
_movieIndex = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
get {
|
get {
|
||||||
return _movieIndex;
|
return _movieIndex;
|
||||||
@ -25,7 +29,7 @@ class patch_OperationManager: OperationManager {
|
|||||||
public new MovieData movieData {
|
public new MovieData movieData {
|
||||||
get {
|
get {
|
||||||
if(_movieDataList.Count > 0) {
|
if(_movieDataList.Count > 0) {
|
||||||
return _movieDataList[_movieIndex];
|
return _movieDataList[MovieIndex];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -35,8 +39,12 @@ class patch_OperationManager: OperationManager {
|
|||||||
|
|
||||||
public new void initialize() {
|
public new void initialize() {
|
||||||
orig_initialize();
|
orig_initialize();
|
||||||
|
|
||||||
|
using IniFile iniFile = new("mu3.ini");
|
||||||
|
_fileName = Path.Combine(iniFile.getValue("Extra", "CacheDir", "."), "data_advert_cache.txt");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_movieIndex = Math.Max(0, int.Parse(File.ReadAllText(_fname)));
|
_movieIndex = Math.Max(0, int.Parse(File.ReadAllText(_fileName)));
|
||||||
} catch(Exception) {
|
} catch(Exception) {
|
||||||
_movieIndex = 0;
|
_movieIndex = 0;
|
||||||
}
|
}
|
||||||
|
@ -32,4 +32,22 @@ class patch_AdvManager: AdvManager {
|
|||||||
|
|
||||||
initMovie();
|
initMovie();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public extern bool orig_initMovie();
|
||||||
|
public new bool initMovie() {
|
||||||
|
UIInput instance = Singleton<UIInput>.instance;
|
||||||
|
instance.setLedColor(UIInput.Key.L2, new Color(0f, 0.7f, 0f));
|
||||||
|
instance.setLedColor(UIInput.Key.L3, new Color(0f, 0.7f, 0f));
|
||||||
|
|
||||||
|
return orig_initMovie();
|
||||||
|
}
|
||||||
|
|
||||||
|
public extern void orig_exitMovie();
|
||||||
|
public new void exitMovie() {
|
||||||
|
orig_exitMovie();
|
||||||
|
|
||||||
|
UIInput instance = Singleton<UIInput>.instance;
|
||||||
|
instance.setLedColor(UIInput.Key.L2, Color.black);
|
||||||
|
instance.setLedColor(UIInput.Key.L3, Color.black);
|
||||||
|
}
|
||||||
}
|
}
|
@ -13,6 +13,7 @@ class patch_PlayMusic: PlayMusic {
|
|||||||
public static bool QuickSkip = false;
|
public static bool QuickSkip = false;
|
||||||
private GameEngine _gameEngine;
|
private GameEngine _gameEngine;
|
||||||
private SessionInfo _sessionInfo;
|
private SessionInfo _sessionInfo;
|
||||||
|
private bool _pressedYellow;
|
||||||
private bool _isRolling;
|
private bool _isRolling;
|
||||||
private float _totalRollingFrame;
|
private float _totalRollingFrame;
|
||||||
private DateTime _rollingStartTime;
|
private DateTime _rollingStartTime;
|
||||||
@ -30,11 +31,13 @@ class patch_PlayMusic: PlayMusic {
|
|||||||
return min + (max - min) * Math.Pow(progress, 2.0);
|
return min + (max - min) * Math.Pow(progress, 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsHolding() {
|
private bool IsHolding() {
|
||||||
return Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuLeft) ^ Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight);
|
return Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuLeft)
|
||||||
|
^ (_pressedYellow && Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuRight));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartRolling() {
|
private void StartRolling() {
|
||||||
|
_pressedYellow = false;
|
||||||
_isRolling = true;
|
_isRolling = true;
|
||||||
_totalRollingFrame = ntMgr.getCurrentFrame();
|
_totalRollingFrame = ntMgr.getCurrentFrame();
|
||||||
_rollingStartTime = CustomDateTime.Now;
|
_rollingStartTime = CustomDateTime.Now;
|
||||||
@ -60,6 +63,9 @@ class patch_PlayMusic: PlayMusic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Execute_Play() {
|
private void Execute_Play() {
|
||||||
|
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight)) {
|
||||||
|
_pressedYellow = true;
|
||||||
|
}
|
||||||
if(_isRolling) {
|
if(_isRolling) {
|
||||||
TimeSpan timeSpan = CustomDateTime.Now - _rollingStartTime;
|
TimeSpan timeSpan = CustomDateTime.Now - _rollingStartTime;
|
||||||
if(timeSpan <= ROLL_DURATION) {
|
if(timeSpan <= ROLL_DURATION) {
|
||||||
|
@ -7,13 +7,15 @@ namespace MU3.Data;
|
|||||||
|
|
||||||
public class patch_DataManager: DataManager {
|
public class patch_DataManager: DataManager {
|
||||||
private Dictionary<int, FumenAnalysisData> _fumenAnalysisData;
|
private Dictionary<int, FumenAnalysisData> _fumenAnalysisData;
|
||||||
|
private string _fileName;
|
||||||
|
|
||||||
private void InitCache() {
|
private void initCache() {
|
||||||
if(File.Exists("data_fumen_analysis_cache.bin")) {
|
if(File.Exists(_fileName)) {
|
||||||
System.Console.WriteLine("Loading FumenAnalysisData cache...");
|
System.Console.WriteLine("Loading chart analysis cache...");
|
||||||
_fumenAnalysisData = new Dictionary<int, FumenAnalysisData>();
|
_fumenAnalysisData = new Dictionary<int, FumenAnalysisData>();
|
||||||
using(FileStream input = File.OpenRead("data_fumen_analysis_cache.bin")) {
|
using FileStream input = File.OpenRead(_fileName);
|
||||||
using BinaryReader binaryReader = new BinaryReader(input);
|
using BinaryReader binaryReader = new BinaryReader(input);
|
||||||
|
|
||||||
while(binaryReader.BaseStream.Position < binaryReader.BaseStream.Length) {
|
while(binaryReader.BaseStream.Position < binaryReader.BaseStream.Length) {
|
||||||
int key = binaryReader.ReadInt32();
|
int key = binaryReader.ReadInt32();
|
||||||
bool isExist = binaryReader.ReadBoolean();
|
bool isExist = binaryReader.ReadBoolean();
|
||||||
@ -27,19 +29,17 @@ public class patch_DataManager: DataManager {
|
|||||||
notesDesignerName = notesDesignerName
|
notesDesignerName = notesDesignerName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
System.Console.WriteLine("Success");
|
|
||||||
} else {
|
} else {
|
||||||
_fumenAnalysisData = new Dictionary<int, FumenAnalysisData>();
|
_fumenAnalysisData = new Dictionary<int, FumenAnalysisData>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveCache() {
|
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}");
|
System.Console.WriteLine($"Saving chart analysis cache...{Enumerable.First(_fumenAnalysisData).Key},{Enumerable.First(_fumenAnalysisData).Value.notesDesignerName}");
|
||||||
if(File.Exists("data_fumen_analysis_cache.bin")) {
|
if(File.Exists(_fileName)) {
|
||||||
File.Delete("data_fumen_analysis_cache.bin");
|
File.Delete(_fileName);
|
||||||
}
|
}
|
||||||
using(FileStream fileStream = File.OpenWrite("data_fumen_analysis_cache.bin")) {
|
using FileStream fileStream = File.OpenWrite(_fileName);
|
||||||
using BinaryWriter binaryWriter = new BinaryWriter(fileStream);
|
using BinaryWriter binaryWriter = new BinaryWriter(fileStream);
|
||||||
foreach(KeyValuePair<int, FumenAnalysisData> fumenAnalysisDatum in _fumenAnalysisData) {
|
foreach(KeyValuePair<int, FumenAnalysisData> fumenAnalysisDatum in _fumenAnalysisData) {
|
||||||
binaryWriter.Write(fumenAnalysisDatum.Key);
|
binaryWriter.Write(fumenAnalysisDatum.Key);
|
||||||
@ -50,18 +50,19 @@ public class patch_DataManager: DataManager {
|
|||||||
}
|
}
|
||||||
fileStream.Flush();
|
fileStream.Flush();
|
||||||
}
|
}
|
||||||
System.Console.WriteLine("Success");
|
|
||||||
}
|
|
||||||
|
|
||||||
private extern void orig_makeFumenAnalysisDataList();
|
private extern void orig_makeFumenAnalysisDataList();
|
||||||
|
|
||||||
private void makeFumenAnalysisDataList() {
|
private void makeFumenAnalysisDataList() {
|
||||||
|
using IniFile iniFile = new("mu3.ini");
|
||||||
|
_fileName = Path.Combine(iniFile.getValue("Extra", "CacheDir", "."), "data_fumen_analysis_cache.bin");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(DataStudioManager.needSave || !File.Exists("data_fumen_analysis_cache.bin")) {
|
if(patch_DataStudioManager.needSave || !File.Exists(_fileName)) {
|
||||||
orig_makeFumenAnalysisDataList();
|
orig_makeFumenAnalysisDataList();
|
||||||
SaveCache();
|
saveCache();
|
||||||
} else {
|
} else {
|
||||||
InitCache();
|
initCache();
|
||||||
}
|
}
|
||||||
} catch(Exception value) {
|
} catch(Exception value) {
|
||||||
System.Console.WriteLine(value);
|
System.Console.WriteLine(value);
|
||||||
|
@ -4,40 +4,46 @@ using System.Runtime.Serialization.Formatters.Binary;
|
|||||||
|
|
||||||
namespace MU3.Data;
|
namespace MU3.Data;
|
||||||
|
|
||||||
public class DataStudioManager {
|
public class patch_DataStudioManager: DataStudioManager {
|
||||||
public static bool needSave;
|
public static bool needSave;
|
||||||
|
private static string _fileName;
|
||||||
private static Dictionary<string, object> _dataCache;
|
private static Dictionary<string, object> _dataCache;
|
||||||
|
|
||||||
private static extern bool orig_Deserialize<T>(string filePath, out T dsr) where T : new();
|
private static extern bool orig_Deserialize<T>(string filePath, out T dsr) where T : new();
|
||||||
|
|
||||||
private static void InitCache() {
|
private static void initCache() {
|
||||||
if(File.Exists("data_cache.bin")) {
|
using IniFile iniFile = new("mu3.ini");
|
||||||
System.Console.WriteLine("Loading cache...");
|
_fileName = Path.Combine(iniFile.getValue("Extra", "CacheDir", "."), "data_cache.bin");
|
||||||
using FileStream serializationStream = File.OpenRead("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);
|
_dataCache = (Dictionary<string, object>)new BinaryFormatter().Deserialize(serializationStream);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_dataCache = new Dictionary<string, object>();
|
_dataCache = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SaveCache() {
|
private static void saveCache() {
|
||||||
if(File.Exists("data_cache.bin")) {
|
if(_fileName == "") {
|
||||||
File.Delete("data_cache.bin");
|
return;
|
||||||
}
|
}
|
||||||
using FileStream serializationStream = File.OpenWrite("data_cache.bin");
|
if(File.Exists(_fileName)) {
|
||||||
|
File.Delete(_fileName);
|
||||||
|
}
|
||||||
|
using FileStream serializationStream = File.OpenWrite(_fileName);
|
||||||
new BinaryFormatter().Serialize(serializationStream, _dataCache);
|
new BinaryFormatter().Serialize(serializationStream, _dataCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool 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) {
|
if(_dataCache == null) {
|
||||||
InitCache();
|
initCache();
|
||||||
}
|
}
|
||||||
if(_dataCache.ContainsKey(filePath)) {
|
if(_dataCache.ContainsKey(filePath)) {
|
||||||
dsr = (T)_dataCache[filePath];
|
dsr = (T)_dataCache[filePath];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(orig_Deserialize<T>(filePath, out dsr)) {
|
if(orig_Deserialize(filePath, out dsr)) {
|
||||||
needSave = true;
|
needSave = true;
|
||||||
_dataCache.Add(filePath, dsr);
|
_dataCache.Add(filePath, dsr);
|
||||||
return true;
|
return true;
|
||||||
@ -47,11 +53,11 @@ public class DataStudioManager {
|
|||||||
|
|
||||||
public extern bool orig_IsLoaded();
|
public extern bool orig_IsLoaded();
|
||||||
|
|
||||||
public bool IsLoaded() {
|
public new bool IsLoaded() {
|
||||||
if(orig_IsLoaded()) {
|
if(orig_IsLoaded()) {
|
||||||
if(needSave) {
|
if(needSave) {
|
||||||
System.Console.WriteLine("Saving cache...");
|
System.Console.WriteLine("Saving data cache...");
|
||||||
SaveCache();
|
saveCache();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ class patch_PlayMusic: PlayMusic {
|
|||||||
}
|
}
|
||||||
public override bool updateState(float deltaTime = -1f) {
|
public override bool updateState(float deltaTime = -1f) {
|
||||||
pauseTimer += deltaTime;
|
pauseTimer += deltaTime;
|
||||||
if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.Service) && !Singleton<UIInput>.instance.getStateOn(UIInput.Key.Test)) {
|
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.Service) && !Singleton<UIInput>.instance.getStateOn(UIInput.Key.Test)) {
|
||||||
if((!Paused && pauseTimer >= PAUSE_CD) || (Paused && pauseTimer >= UNPAUSE_CD)) {
|
if((!Paused && pauseTimer >= PAUSE_CD) || (Paused && pauseTimer >= UNPAUSE_CD)) {
|
||||||
Paused = !Paused;
|
Paused = !Paused;
|
||||||
pgm.pause(Paused);
|
pgm.pause(Paused);
|
||||||
|
@ -4,10 +4,4 @@
|
|||||||
<Description>Platinum early/late</Description>
|
<Description>Platinum early/late</Description>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="..\Mu3Mods.csproj" />
|
<Import Project="..\Mu3Mods.csproj" />
|
||||||
<ItemGroup>
|
|
||||||
<None Remove="MU3\patch_UIResultTechScore.experiment" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="MU3\patch_UIResultTechScore.experiment" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
@ -16,7 +16,7 @@ class patch_Scene_30_NoticeReward: Scene_30_NoticeReward {
|
|||||||
SingletonMonoBehaviour<SystemUI>.instance.Panel.pushState(0, show: true);
|
SingletonMonoBehaviour<SystemUI>.instance.Panel.pushState(0, show: true);
|
||||||
}
|
}
|
||||||
private void Update() {
|
private void Update() {
|
||||||
if(_mode.get() < (int)State.FadeOut && Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuLeft)) {
|
if(_mode.get() < (int)State.FadeOut && Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuLeft)) {
|
||||||
Skipped = true;
|
Skipped = true;
|
||||||
_mode.set(State.FadeOut);
|
_mode.set(State.FadeOut);
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,7 +11,7 @@ class patch_PlayMusic: PlayMusic {
|
|||||||
private void Execute_StartCutscene() {
|
private void Execute_StartCutscene() {
|
||||||
orig_Execute_StartCutscene();
|
orig_Execute_StartCutscene();
|
||||||
ForceSkipped = false;
|
ForceSkipped = false;
|
||||||
if(Singleton<Sys.System>.instance.config.isQuickStart || Singleton<UIInput>.instance.getStateOn(UIInput.Key.MenuLeft)) {
|
if(Singleton<Sys.System>.instance.config.isQuickStart || Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuLeft)) {
|
||||||
ForceSkipped = true;
|
ForceSkipped = true;
|
||||||
_gameEngine.skipStartCutscene();
|
_gameEngine.skipStartCutscene();
|
||||||
setNextState(EState.Countdown);
|
setNextState(EState.Countdown);
|
||||||
|
Loading…
Reference in New Issue
Block a user