feat: implement Pause, better InfiniteGP

This commit is contained in:
あかニャン 2024-07-02 10:34:51 +09:00
parent a31cf82029
commit cc6f7657c7
12 changed files with 181 additions and 14 deletions

View File

@ -51,6 +51,7 @@ public class patch_PlayMusic: PlayMusic {
private void EndRolling() {
_isRolling = false;
ntMgr.stopPlay();
ntMgr.setPause(false);
ntMgr.reset();
ntMgr.reloadScore(_gameEngine.IsStageDazzling);
_gameEngine.counters.reset();

View File

@ -2,7 +2,6 @@
#pragma warning disable CS0649
#pragma warning disable IDE0051
#pragma warning disable IDE1006
#pragma warning disable CS0108
#pragma warning disable CS0414
using MU3.Sequence;

View File

@ -1,5 +1,6 @@
#pragma warning disable CS0649
#pragma warning disable CS0626
using MU3.Util;
@ -10,7 +11,14 @@ public class patch_Scene_25_Login : Scene_25_Login {
Login = 2
}
private Mode<Scene_25_Login, State> mode_;
private extern void orig_invokeOnFinish(int status);
private void PurchaseGP_Init() {
mode_.set(State.Login);
}
private void invokeOnFinish(int status) {
orig_invokeOnFinish(status);
}
private void ExchangeGP_Init() {
invokeOnFinish(1);
}
}

View File

@ -0,0 +1,45 @@
#pragma warning disable CS0626
#pragma warning disable CS0649
using MU3.CustomUI;
using UnityEngine;
namespace MU3;
public class patch_UICredit: UICredit {
private Animator gpAnimator_;
private GameObject creditRoot_;
private MU3UICounter credit_;
private GameObject freePlayRoot_;
private GameObject gpRoot_;
private MU3UICounter gp_;
private MU3UICounter gpPlus_;
private MU3UICounter gpMinus_;
private MU3UIImageChanger netIcon_;
private void onUpdateGP(int value) { /* nop */ }
public extern void orig_initialize();
public new void initialize() {
orig_initialize();
DestroyImmediate(gpAnimator_);
creditRoot_.transform.localScale = new Vector3(0, 0, 0);
credit_.transform.localScale = new Vector3(0, 0, 0);
freePlayRoot_.transform.localScale = new Vector3(0, 0, 0);
gpRoot_.transform.localScale = new Vector3(0, 0, 0);
gp_.transform.localScale = new Vector3(0, 0, 0);
gpPlus_.transform.localScale = new Vector3(0, 0, 0);
gpMinus_.transform.localScale = new Vector3(0, 0, 0);
var tf = (RectTransform)netIcon_.transform;
tf.localPosition = new Vector3(35, netIcon_.transform.localPosition.y, netIcon_.transform.localPosition.z);
for(int i = 0; i < 3; ++i) {
tf.anchorMin = new Vector2(0f, 0.5f);
tf.anchorMax = new Vector2(1f, 0.5f);
tf = (RectTransform)tf.parent;
}
netIcon_.image.rectTransform.pivot = new Vector2(0f, 0.5f);
}
}

View File

@ -2,29 +2,28 @@
#pragma warning disable CS0649
#pragma warning disable IDE0051
#pragma warning disable IDE1006
#pragma warning disable CS0108
namespace MU3.User;
public class patch_UserManager: UserManager {
public const int DefaultGP = 666;
public new const int DefaultGP = 666;
private int _gp;
private OnUpdate _onUpdateGP;
private OnReset _onResetGP;
public void resetGP() {
_gp = 666;
public new void resetGP() {
_gp = 999;
if(_onResetGP != null) {
_onResetGP(_gp);
}
}
public int GP {
public new int GP {
get {
return _gp;
}
private set {
_gp = 666;
_gp = 999;
if(_onUpdateGP != null) {
_onUpdateGP(_gp);
}

View File

@ -0,0 +1,13 @@
#pragma warning disable CS0626
using MU3.Sequence;
namespace MU3.Battle;
public class patch_GameEngine: GameEngine {
public extern void orig_reset();
public new void reset() {
orig_reset();
patch_PlayMusic.Paused = false;
}
}

View File

@ -0,0 +1,15 @@
#pragma warning disable CS0649
using MU3.Sound;
using MU3.Util;
namespace MU3.Game;
public class patch_GameBGM: GameBGM {
private patch_SoundManager psm => ((patch_SoundManager)Singleton<SoundManager>.instance);
private HandleInfo _handle;
public void pause(bool val) {
psm.pause(_handle, val);
}
}

View File

@ -0,0 +1,40 @@
#pragma warning disable CS0626
#pragma warning disable CS0649
#pragma warning disable IDE0051
#pragma warning disable IDE1006
using MU3.Battle;
using MU3.Game;
using MU3.Notes;
using MU3.Util;
namespace MU3.Sequence;
public 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;
public extern bool orig_updateState(float deltaTime = -1f);
public extern void orig_destroy();
private extern void orig_Enter_SetupScene();
private void Enter_SetupScene() {
orig_Enter_SetupScene();
Paused = false;
}
public override bool updateState(float deltaTime = -1f) {
pauseTimer += deltaTime;
if(Singleton<UIInput>.instance.getStateOn(UIInput.Key.Service)) {
if((!Paused && pauseTimer >= PAUSE_CD) || (Paused && pauseTimer >= UNPAUSE_CD)) {
Paused = !Paused;
pgm.pause(Paused);
ntMgr.setPause(Paused);
pauseTimer = 0f;
}
}
return orig_updateState(deltaTime);
}
}

View File

@ -0,0 +1,13 @@
#pragma warning disable CS0626
#pragma warning disable CS0649
namespace MU3.Sound;
public 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) {
_soundPlayers[handle.Index].pause(val);
}
}

View File

@ -0,0 +1,18 @@
#pragma warning disable CS0626
#pragma warning disable CS0649
namespace MU3.Sound;
class patch_SoundPlayer: SoundPlayer {
private CriAtomExPlayer _player;
public extern void orig_stop();
public void pause(bool val) {
_player.Pause(val);
}
public new void stop() {
_player.Pause(false);
orig_stop();
}
}

View File

@ -0,0 +1,12 @@
#pragma warning disable CS0626
using MU3.Sequence;
public class patch_GameDeviceManager: GameDeviceManager {
private extern void orig_update();
private void update() {
if(!patch_PlayMusic.Paused) {
orig_update();
}
}
}

View File

@ -4,14 +4,14 @@ Miscellaneous mods for µ3/SDDT; mainly for my personal use, though suggestions/
### BetterGiveUp
Enables these buttons in music play:
Enables the following buttons in music play:
* Red menu: instant return to song select
* Yellow menu: instant restart
To avoid misclicks, you have to hold the button down for 1 second.
Based on GiveUp, but Better.
Based on GiveUp from the older modpack, but Better.
### ExportChartData
@ -19,7 +19,7 @@ Exports some useful chart data into a dollar-separated file (charts.csv) when th
### InfiniteGP
Self-explanatory. Saves you time.
Patches out GP and credits.
### LockSelectionTime
@ -29,6 +29,10 @@ Disables *all* timers. A replacement for LockSelectionTime from the older modpac
Replaces the in-game rating algorithm (OldBest30+NewBest15+Recent10) with Best45. Client-side and purely cosmetic.
### Pause
Enables pausing music play on FN2 (service button). Has an internal 5s cooldown.
### SkipLoginReward ⚠️
Skips login bonuses and event rewards. If you care about those things, don't use this one.