mirror of
https://github.com/hykilpikonna/AquaDX.git
synced 2026-08-09 04:29:03 -05:00
[F] Sudden changes in headphone volume (#9)
* [F] Sudden changes in headphone volume * [F]: Should rst _volumeFadeInState when logging out * [F]: Reset _volumeFadeInState in GameOver
This commit is contained in:
parent
f6e8f4e926
commit
d00f70d0ba
|
|
@ -4,6 +4,7 @@ using HarmonyLib;
|
|||
using MAI2.Util;
|
||||
using Manager;
|
||||
using Monitor;
|
||||
using Monitor.ModeSelect;
|
||||
using Process;
|
||||
using Process.Information;
|
||||
|
||||
|
|
@ -14,6 +15,12 @@ namespace AquaMai.Mods.Tweaks.TimeSaving;
|
|||
zh: "登录完成后直接进入选歌界面")]
|
||||
public class EntryToMusicSelection
|
||||
{
|
||||
private static int[] _timers = new int[2];
|
||||
|
||||
private static CommonValue[] _volumeFadeIns = { new CommonValue(), new CommonValue() };
|
||||
|
||||
private static readonly bool[] _volumeFadeInState = new bool[2];
|
||||
|
||||
/*
|
||||
* Highly experimental, may well break some stuff
|
||||
* Works by overriding the info screen (where it shows new events and stuff)
|
||||
|
|
@ -25,16 +32,6 @@ public class EntryToMusicSelection
|
|||
public static bool OnUpdate(InformationProcess __instance, ProcessDataContainer ___container)
|
||||
{
|
||||
GameManager.SetMaxTrack();
|
||||
// Set headphone volume
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
var userData = UserDataManager.Instance.GetUserData(i);
|
||||
if (userData.IsEntry)
|
||||
{
|
||||
OptionHeadphonevolumeID headPhoneVolume = userData.Option.HeadPhoneVolume;
|
||||
SoundManager.SetHeadPhoneVolume(i, headPhoneVolume.GetValue());
|
||||
}
|
||||
}
|
||||
___container.processManager.AddProcess(new MusicSelectProcess(___container));
|
||||
___container.processManager.ReleaseProcess(__instance);
|
||||
return false;
|
||||
|
|
@ -49,4 +46,63 @@ public class EntryToMusicSelection
|
|||
if (index >= 0) return;
|
||||
userData.MapList.Clear();
|
||||
}
|
||||
|
||||
// Gradually increase headphone volume
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(MusicSelectProcess), "OnUpdate")]
|
||||
public static void MusicSelectProcessOnUpdate()
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (_volumeFadeInState[i] && _timers[i] == 0) continue;
|
||||
|
||||
if (_timers[i] > 0)
|
||||
{
|
||||
_timers[i]--;
|
||||
}
|
||||
|
||||
if (_volumeFadeInState[i])
|
||||
{
|
||||
if (_timers[i] == 0)
|
||||
{
|
||||
SoundManager.SetHeadPhoneVolume(i, _volumeFadeIns[i].end);
|
||||
}
|
||||
else if (!_volumeFadeIns[i].UpdateValue())
|
||||
{
|
||||
SoundManager.SetHeadPhoneVolume(i, _volumeFadeIns[i].current);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var userData = UserDataManager.Instance.GetUserData(i);
|
||||
if (!userData.IsEntry) continue;
|
||||
var value = userData.Option.HeadPhoneVolume.GetValue();
|
||||
if (GameManager.IsSelectContinue[i])
|
||||
{
|
||||
_volumeFadeIns[i].start = value;
|
||||
_volumeFadeIns[i].current = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_volumeFadeIns[i].start = 0.05f;
|
||||
_volumeFadeIns[i].current = 0.05f;
|
||||
}
|
||||
|
||||
_volumeFadeIns[i].end = value;
|
||||
_volumeFadeIns[i].diff = (_volumeFadeIns[i].end - _volumeFadeIns[i].start) / 90f;
|
||||
_timers[i] = 90;
|
||||
_volumeFadeInState[i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameOverProcess), "OnStart")]
|
||||
public static void GameOverProcessOnStart()
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
_volumeFadeInState[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user