rewrite basically
This commit is contained in:
parent
0e244bc16b
commit
6738890408
@ -1,40 +1,45 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System;
|
||||||
using UnityEngine;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace MU3.Operation;
|
namespace MU3.Operation;
|
||||||
|
|
||||||
class patch_OperationManager: OperationManager {
|
class patch_OperationManager: OperationManager {
|
||||||
private static readonly string CurrentSongIndexFilePath = "BepInEx/monomod/AttractVideoPlayer.currentSongIndex.txt";
|
private static readonly string _fname = "data_advert_cache.txt";
|
||||||
private ReadOnlyCollection<MovieData> _movieDataList;
|
private ReadOnlyCollection<MovieData> _movieDataList;
|
||||||
|
private int _movieIndex;
|
||||||
|
|
||||||
|
~patch_OperationManager() {
|
||||||
|
try {
|
||||||
|
File.WriteAllText(_fname, _movieIndex.ToString());
|
||||||
|
} catch(Exception) {}
|
||||||
|
}
|
||||||
|
public int MovieIndex {
|
||||||
|
set {
|
||||||
|
_movieIndex = (value + _movieDataList.Count) % _movieDataList.Count;
|
||||||
|
}
|
||||||
|
get {
|
||||||
|
return _movieIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
public new MovieData movieData {
|
public new MovieData movieData {
|
||||||
get {
|
get {
|
||||||
if(_movieDataList.Count > 0) {
|
if(_movieDataList.Count > 0) {
|
||||||
int currentSongIndex = 0;
|
return _movieDataList[_movieIndex];
|
||||||
try {
|
|
||||||
currentSongIndex = int.Parse(System.IO.File.ReadAllText(CurrentSongIndexFilePath));
|
|
||||||
} catch(System.Exception) {
|
|
||||||
saveCurrentSongIndex(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(currentSongIndex < 0) {
|
|
||||||
currentSongIndex = _movieDataList.Count - 1;
|
|
||||||
saveCurrentSongIndex(currentSongIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(currentSongIndex >= _movieDataList.Count) {
|
|
||||||
currentSongIndex = 0;
|
|
||||||
saveCurrentSongIndex(currentSongIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.Log("currentSongIndex: " + currentSongIndex);
|
|
||||||
|
|
||||||
return _movieDataList[currentSongIndex];
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveCurrentSongIndex(int currentSongIndex) {
|
public extern void orig_initialize();
|
||||||
System.IO.File.WriteAllText(CurrentSongIndexFilePath, currentSongIndex.ToString());
|
|
||||||
|
public new void initialize() {
|
||||||
|
orig_initialize();
|
||||||
|
try {
|
||||||
|
_movieIndex = Math.Max(0, int.Parse(File.ReadAllText(_fname)));
|
||||||
|
} catch(Exception) {
|
||||||
|
_movieIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,18 +1,18 @@
|
|||||||
using MU3.AM;
|
using MU3.Util;
|
||||||
using MU3.Operation;
|
|
||||||
using MU3.Util;
|
|
||||||
|
|
||||||
namespace MU3.Sequence;
|
namespace MU3.Sequence;
|
||||||
|
|
||||||
class patch_Advertise: Advertise {
|
class patch_Advertise: Advertise {
|
||||||
private bool checkButtonOrAime() {
|
// Exclude Back/Left/Right
|
||||||
if(SingletonStateMachine<AMManager, AMManager.EState>.instance.aimeReader.advCheck()) {
|
private bool anyKeyDown() {
|
||||||
Singleton<OperationManager>.instance.loginType = OperationManager.LoginType.Aime;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
UIInput instance = Singleton<UIInput>.instance;
|
UIInput instance = Singleton<UIInput>.instance;
|
||||||
if(instance.getTriggerOn(UIInput.Key.Decision) || instance.getTriggerOn(UIInput.Key.OptionBackward) || instance.getTriggerOn(UIInput.Key.OptionForward) || instance.getTriggerOn(UIInput.Key.SkipRight) || instance.getTriggerOn(UIInput.Key.MenuLeft) || instance.getTriggerOn(UIInput.Key.MenuRight)) {
|
if(instance.getTriggerOn(UIInput.Key.Decision)
|
||||||
Singleton<OperationManager>.instance.loginType = OperationManager.LoginType.Button;
|
|| instance.getTriggerOn(UIInput.Key.OptionBackward)
|
||||||
|
|| instance.getTriggerOn(UIInput.Key.OptionForward)
|
||||||
|
|| instance.getTriggerOn(UIInput.Key.SkipLeft)
|
||||||
|
|| instance.getTriggerOn(UIInput.Key.SkipRight)
|
||||||
|
|| instance.getTriggerOn(UIInput.Key.MenuLeft)
|
||||||
|
|| instance.getTriggerOn(UIInput.Key.MenuRight)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,47 +1,32 @@
|
|||||||
using MU3.Util;
|
using MU3.Operation;
|
||||||
|
using MU3.Util;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace MU3;
|
namespace MU3;
|
||||||
|
|
||||||
class patch_AdvManager: AdvManager {
|
class patch_AdvManager: AdvManager {
|
||||||
private static readonly string CurrentSongIndexFilePath = "BepInEx/monomod/AttractVideoPlayer.currentSongIndex.txt";
|
|
||||||
private static readonly float DelayBetweenButtonPress = 0.5f;
|
|
||||||
private float lastButtonPressedTime = 0f;
|
|
||||||
|
|
||||||
private GameObject objMovie;
|
private GameObject objMovie;
|
||||||
private CriManaMovieMaterial movieController;
|
private CriManaMovieMaterial movieController;
|
||||||
private extern bool orig_initMovie();
|
|
||||||
public new bool initMovie() {
|
|
||||||
return orig_initMovie();
|
|
||||||
}
|
|
||||||
|
|
||||||
private extern bool orig_exec();
|
private extern bool orig_exec();
|
||||||
public new bool exec() {
|
public new bool exec() {
|
||||||
if(Time.time - lastButtonPressedTime > DelayBetweenButtonPress) {
|
if(movieController?.player?.status == CriMana.Player.Status.Playing) {
|
||||||
if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.Service)) {
|
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.Service)) {
|
||||||
lastButtonPressedTime = Time.time;
|
movieController.player.Pause(!movieController.player.IsPaused());
|
||||||
|
} else if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.L2)) {
|
||||||
movieController?.player.Pause(!movieController.player.IsPaused());
|
addMovieOffset(-1);
|
||||||
} else if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.L2)) {
|
} else if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.L3)) {
|
||||||
lastButtonPressedTime = Time.time;
|
addMovieOffset(1);
|
||||||
|
|
||||||
addOffsetToCurrentSongIndexAndPlayMovie(-1);
|
|
||||||
} else if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.L3)) {
|
|
||||||
lastButtonPressedTime = Time.time;
|
|
||||||
|
|
||||||
addOffsetToCurrentSongIndexAndPlayMovie(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return orig_exec();
|
return orig_exec();
|
||||||
}
|
}
|
||||||
public void addOffsetToCurrentSongIndexAndPlayMovie(int offset) {
|
public void addMovieOffset(int offset) {
|
||||||
try {
|
var om = (patch_OperationManager)Singleton<OperationManager>.instance;
|
||||||
int currentSongIndex = int.Parse(System.IO.File.ReadAllText(CurrentSongIndexFilePath)) + offset;
|
om.MovieIndex += offset;
|
||||||
System.IO.File.WriteAllText(CurrentSongIndexFilePath, currentSongIndex.ToString());
|
|
||||||
} catch(System.Exception) { }
|
|
||||||
|
|
||||||
movieController?.Stop();
|
movieController.Stop();
|
||||||
Utility.destroyGameObject(ref movieController);
|
Utility.destroyGameObject(ref movieController);
|
||||||
Utility.destroyGameObject(ref objMovie);
|
Utility.destroyGameObject(ref objMovie);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user