From df5645de174a08823208e09a7ba3ba59867594a1 Mon Sep 17 00:00:00 2001 From: RileyTheFox Date: Sat, 12 Oct 2024 23:40:07 +0100 Subject: [PATCH] Add configurable practice restart delay --- Assets/Script/Gameplay/Player/TrackPlayer.cs | 8 +++++++- Assets/Script/Gameplay/PracticeManager.cs | 4 ++-- Assets/Script/Settings/SettingsManager.Settings.cs | 3 ++- Assets/Script/Settings/SettingsManager.cs | 1 + Assets/StreamingAssets/lang/en-US.json | 4 ++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Assets/Script/Gameplay/Player/TrackPlayer.cs b/Assets/Script/Gameplay/Player/TrackPlayer.cs index 36c5d37cd..e06a2b219 100644 --- a/Assets/Script/Gameplay/Player/TrackPlayer.cs +++ b/Assets/Script/Gameplay/Player/TrackPlayer.cs @@ -11,6 +11,7 @@ using YARG.Gameplay.HUD; using YARG.Gameplay.Visuals; using YARG.Player; +using YARG.Settings; using YARG.Themes; namespace YARG.Gameplay.Player @@ -23,7 +24,7 @@ public abstract class TrackPlayer : BasePlayer public const float TRACK_WIDTH = 2f; - public double SpawnTimeOffset => (ZeroFadePosition + 2 + -STRIKE_LINE_POS) / NoteSpeed; + public double SpawnTimeOffset => (ZeroFadePosition + _spawnAheadDelay + -STRIKE_LINE_POS) / NoteSpeed; protected TrackView TrackView { get; private set; } @@ -66,6 +67,8 @@ public abstract class TrackPlayer : BasePlayer protected bool IsBass { get; private set; } + private float _spawnAheadDelay; + public virtual void Initialize(int index, YargPlayer player, SongChart chart, TrackView trackView, StemMixer mixer, int? lastHighScore) { @@ -85,6 +88,8 @@ public virtual void Initialize(int index, YargPlayer player, SongChart chart, Tr // Set fade information and highway length ZeroFadePosition = DEFAULT_ZERO_FADE_POS * Player.Profile.HighwayLength; FadeSize = Player.CameraPreset.FadeLength; + + _spawnAheadDelay = GameManager.IsPractice ? SettingsManager.Settings.PracticeRestartDelay.Value : 2; if (player.Profile.HighwayLength > 1) { FadeSize *= player.Profile.HighwayLength; @@ -319,6 +324,7 @@ protected override void UpdateNotes(double songTime) protected override void UpdateBeatlines(double time) { + YargLogger.LogFormatDebug("{0}, {1}", time, SpawnTimeOffset); while (BeatlineIndex < Beatlines.Count && Beatlines[BeatlineIndex].Time <= time + SpawnTimeOffset) { if (BeatlineIndex + 1 < Beatlines.Count && Beatlines[BeatlineIndex + 1].Time <= time + SpawnTimeOffset) diff --git a/Assets/Script/Gameplay/PracticeManager.cs b/Assets/Script/Gameplay/PracticeManager.cs index b11de7f6c..ce65f85ab 100644 --- a/Assets/Script/Gameplay/PracticeManager.cs +++ b/Assets/Script/Gameplay/PracticeManager.cs @@ -152,7 +152,7 @@ public void SetPracticeSection(uint tickStart, uint tickEnd, double timeStart, d GameManager.VocalTrack.AllowStarPower = allowPracticeSP; GameManager.VocalTrack.SetPracticeSection(tickStart, tickEnd); - GameManager.SetSongTime(timeStart); + GameManager.SetSongTime(timeStart, SettingsManager.Settings.PracticeRestartDelay.Value); _practiceHud.SetSections(GetSectionsInPractice(_sectionStartTick, _sectionEndTick)); HasSelectedSection = true; @@ -223,7 +223,7 @@ public void ResetPractice() } GameManager.VocalTrack.ResetPracticeSection(); - GameManager.SetSongTime(TimeStart); + GameManager.SetSongTime(TimeStart, SettingsManager.Settings.PracticeRestartDelay.Value); GameManager.Resume(); } diff --git a/Assets/Script/Settings/SettingsManager.Settings.cs b/Assets/Script/Settings/SettingsManager.Settings.cs index 965da28ab..4da9a4c82 100644 --- a/Assets/Script/Settings/SettingsManager.Settings.cs +++ b/Assets/Script/Settings/SettingsManager.Settings.cs @@ -81,7 +81,8 @@ public void OpenVenueFolder() public ToggleSetting VoiceActivatedVocalStarPower { get; } = new(true); - public SliderSetting ShowCursorTimer { get; } = new(2f, 0f, 5f); + public SliderSetting PracticeRestartDelay { get; } = new(2f, 0.5f, 5f); + public SliderSetting ShowCursorTimer { get; } = new(2f, 0f, 5f); public ToggleSetting PauseOnDeviceDisconnect { get; } = new(true); public ToggleSetting PauseOnFocusLoss { get; } = new(true); diff --git a/Assets/Script/Settings/SettingsManager.cs b/Assets/Script/Settings/SettingsManager.cs index 5b0715a60..9528fea64 100644 --- a/Assets/Script/Settings/SettingsManager.cs +++ b/Assets/Script/Settings/SettingsManager.cs @@ -56,6 +56,7 @@ public static partial class SettingsManager nameof(Settings.ReduceNoteSpeedByDifficulty), nameof(Settings.KickBounceMultiplier), nameof(Settings.VoiceActivatedVocalStarPower), + nameof(Settings.PracticeRestartDelay), nameof(Settings.ShowCursorTimer), nameof(Settings.PauseOnDeviceDisconnect), nameof(Settings.PauseOnFocusLoss), diff --git a/Assets/StreamingAssets/lang/en-US.json b/Assets/StreamingAssets/lang/en-US.json index 031a9b1d5..6dfef7613 100644 --- a/Assets/StreamingAssets/lang/en-US.json +++ b/Assets/StreamingAssets/lang/en-US.json @@ -714,6 +714,10 @@ "Sparse": "50, 100, 250, 500, ..." } }, + "PracticeRestartDelay": { + "Name": "Practice Restart Delay", + "Description": "The amount of time (in seconds) to delay the beginning of a section in Practice Mode." + }, "PreviewVolume": { "Name": "Preview Volume", "Description": "The preview volume while in the music library."