forked from akanyan/mu3-mods
feat: rework Pause
Now a dialog. * Also fix the new BetterGiveUp panic restart * Also move SortByInternal's PNG away from the root namespace
This commit is contained in:
@ -115,12 +115,24 @@ class patch_PlayMusic: PlayMusic {
|
||||
}
|
||||
}
|
||||
|
||||
private void listenForPanicRestart() {
|
||||
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight) && ntMgr.retireResult != RetireResult.None && !isPartyPlay()) {
|
||||
Singleton<GameSound>.instance.gameBGM.stop();
|
||||
setNextState(EState.Init);
|
||||
}
|
||||
}
|
||||
|
||||
private extern void orig_Execute_DispCombo();
|
||||
private void Execute_DispCombo() {
|
||||
orig_Execute_DispCombo();
|
||||
|
||||
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.MenuRight) && ntMgr.retireResult != RetireResult.None && !isPartyPlay()) {
|
||||
setNextState(EState.Init);
|
||||
}
|
||||
listenForPanicRestart();
|
||||
}
|
||||
|
||||
private extern void orig_Execute_DispFinish();
|
||||
private void Execute_DispFinish() {
|
||||
orig_Execute_DispFinish();
|
||||
|
||||
listenForPanicRestart();
|
||||
}
|
||||
}
|
@ -1,11 +1,87 @@
|
||||
using MU3.Sequence;
|
||||
using MU3.Collab;
|
||||
using MU3.DB;
|
||||
using MU3.Game;
|
||||
using MU3.Notes;
|
||||
using MU3.Util;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MU3.Battle;
|
||||
|
||||
class patch_GameEngine: GameEngine {
|
||||
private static readonly float PAUSE_CD = 5f;
|
||||
|
||||
private NotesManager _notesManager;
|
||||
|
||||
private static bool _paused;
|
||||
private float _pauseTimer;
|
||||
private UIDialog _dialog;
|
||||
|
||||
public extern void orig_reset();
|
||||
public new void reset() {
|
||||
orig_reset();
|
||||
patch_PlayMusic.Paused = false;
|
||||
togglePause(false);
|
||||
_pauseTimer = 0;
|
||||
|
||||
if(_dialog != null) {
|
||||
_dialog.forceCancel();
|
||||
_dialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
public extern void orig_execute();
|
||||
public new void execute() {
|
||||
if(_paused) {
|
||||
return;
|
||||
}
|
||||
|
||||
orig_execute();
|
||||
|
||||
_pauseTimer -= Time.deltaTime;
|
||||
|
||||
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.Service)) {
|
||||
if(_pauseTimer < 0f && !isPartyPlay() && notesManager.isPlaying) {
|
||||
togglePause(true);
|
||||
_dialog = UIDialog.create(DialogID.LackOfGP, "Pause", (int _, bool _) => togglePause(false));
|
||||
StartCoroutine(killTimer(_dialog));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void togglePause(bool value) {
|
||||
((patch_GameBGM)Singleton<GameSound>.instance.gameBGM).pause(value);
|
||||
_paused = value;
|
||||
_notesManager.setPause(value);
|
||||
_pauseTimer = PAUSE_CD;
|
||||
}
|
||||
|
||||
private IEnumerator killTimer(UIDialog dialog) {
|
||||
var fi = typeof(UIDialog).GetField("uiTimer_", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
if(fi == null) {
|
||||
yield break;
|
||||
}
|
||||
|
||||
int limit = 500;
|
||||
UITimer timer;
|
||||
do {
|
||||
yield return new WaitForEndOfFrame();
|
||||
timer = (UITimer)fi.GetValue(dialog);
|
||||
if(--limit == 0) {
|
||||
yield break;
|
||||
}
|
||||
} while(timer == null);
|
||||
|
||||
timer.Pause = true;
|
||||
timer.Show = false;
|
||||
timer.enabled = false;
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
private bool isPartyPlay() {
|
||||
Party.IManager manager = Party.get();
|
||||
return manager != null && manager.isJoinAndActive();
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
using MonoMod;
|
||||
using MU3.Battle;
|
||||
using MU3.Game;
|
||||
using MU3.Notes;
|
||||
using MU3.Util;
|
||||
|
||||
namespace MU3.Sequence;
|
||||
|
||||
class patch_PlayMusic: PlayMusic {
|
||||
private static readonly float PAUSE_CD = 5f;
|
||||
private static readonly float UNPAUSE_CD = 0.5f;
|
||||
private GameEngine _gameEngine;
|
||||
private NotesManager ntMgr => _gameEngine?.notesManager;
|
||||
private patch_GameBGM pgm => (patch_GameBGM)Singleton<GameSound>.instance.gameBGM;
|
||||
public static bool Paused = false;
|
||||
private float pauseTimer = 0f;
|
||||
|
||||
[MonoModIgnore]
|
||||
private extern bool isPartyPlay();
|
||||
|
||||
private extern void orig_Enter_SetupScene();
|
||||
private void Enter_SetupScene() {
|
||||
orig_Enter_SetupScene();
|
||||
Paused = false;
|
||||
}
|
||||
|
||||
public extern bool orig_updateState(float deltaTime = -1f);
|
||||
public override bool updateState(float deltaTime = -1f) {
|
||||
pauseTimer += deltaTime;
|
||||
if(Singleton<UIInput>.instance.getTriggerOn(UIInput.Key.Service) && !Singleton<UIInput>.instance.getStateOn(UIInput.Key.Test)) {
|
||||
if((!Paused && pauseTimer >= PAUSE_CD) || (Paused && pauseTimer >= UNPAUSE_CD) && !isPartyPlay()) {
|
||||
Paused = !Paused;
|
||||
pgm.pause(Paused);
|
||||
ntMgr.setPause(Paused);
|
||||
pauseTimer = 0f;
|
||||
}
|
||||
}
|
||||
return orig_updateState(deltaTime);
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
namespace MU3.Sound;
|
||||
|
||||
class patch_SoundManager: SoundManager {
|
||||
private extern HandleInfo orig_getHandle(Priority priority);
|
||||
private HandleInfo getHandle(Priority priority) => orig_getHandle(priority);
|
||||
private patch_SoundPlayer[] _soundPlayers;
|
||||
|
||||
public void pause(HandleInfo handle, bool val) {
|
||||
if(handle.Index < _soundPlayers.Length) {
|
||||
_soundPlayers[handle.Index].pause(val);
|
||||
|
@ -1,10 +0,0 @@
|
||||
using MU3.Sequence;
|
||||
|
||||
class patch_GameDeviceManager: GameDeviceManager {
|
||||
private extern void orig_update();
|
||||
private void update() {
|
||||
if(!patch_PlayMusic.Paused) {
|
||||
orig_update();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
public static class InternalSortPreview {
|
||||
namespace MU3.Mod;
|
||||
|
||||
public static class InternalSortPreview {
|
||||
// This really shouldn't be a png but it's just one texture
|
||||
public static byte[] Bytes = {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
@ -22,7 +22,7 @@ class patch_UISortButton: UISortButton {
|
||||
}
|
||||
|
||||
Texture2D tex = new Texture2D(2, 2);
|
||||
tex.LoadImage(InternalSortPreview.Bytes);
|
||||
tex.LoadImage(Mod.InternalSortPreview.Bytes);
|
||||
|
||||
newSprites[n] = Sprite.Create(tex, new Rect(0, 0, 254, 121), newSprites[0].pivot);
|
||||
|
||||
|
Reference in New Issue
Block a user