Skip to content

Commit

Permalink
Add configurable practice restart delay
Browse files Browse the repository at this point in the history
  • Loading branch information
RileyTheFox committed Oct 12, 2024
1 parent 85b4282 commit df5645d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Assets/Script/Gameplay/Player/TrackPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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; }

Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Assets/Script/Gameplay/PracticeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -223,7 +223,7 @@ public void ResetPractice()
}
GameManager.VocalTrack.ResetPracticeSection();

GameManager.SetSongTime(TimeStart);
GameManager.SetSongTime(TimeStart, SettingsManager.Settings.PracticeRestartDelay.Value);
GameManager.Resume();
}

Expand Down
3 changes: 2 additions & 1 deletion Assets/Script/Settings/SettingsManager.Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Assets/Script/Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions Assets/StreamingAssets/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit df5645d

Please sign in to comment.