Skip to content

Commit

Permalink
Fix song speed being reset for real
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Apr 8, 2024
1 parent 5d71ac5 commit 947c302
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 0 additions & 2 deletions Assets/Script/Gameplay/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,7 @@ private bool EndSong()

public void ForceQuitSong()
{
var speed = GlobalVariables.State.SongSpeed;
GlobalVariables.State = PersistentState.Default;
GlobalVariables.State.SongSpeed = speed;
GlobalVariables.Instance.LoadScene(SceneIndex.Menu);
}

Expand Down
8 changes: 7 additions & 1 deletion Assets/Script/Menu/DifficultySelect/DifficultySelectMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ namespace YARG.Menu.DifficultySelect
{
public class DifficultySelectMenu : MonoBehaviour
{
/// <summary>
/// The saved song speed value
/// </summary>
private static float _songSpeed = 1f;

private enum State
{
Main,
Expand Down Expand Up @@ -100,7 +105,7 @@ private void OnEnable()
})
}, false));

_speedInput.text = $"{(int)(GlobalVariables.State.SongSpeed * 100f)}%";
_speedInput.text = $"{(int)(_songSpeed * 100f)}%";

// ChangePlayer(0) will update for the current player
_playerIndex = 0;
Expand Down Expand Up @@ -377,6 +382,7 @@ private void ChangePlayer(int add)
// The max speed that the game can keep up with is 4995%
float speed = float.Parse(_speedInput.text.TrimEnd('%')) / 100f;
speed = Mathf.Clamp(speed, 0.1f, 49.95f);
_songSpeed = speed;
GlobalVariables.State.SongSpeed = speed;

GlobalVariables.Instance.LoadScene(SceneIndex.Gameplay);
Expand Down

0 comments on commit 947c302

Please sign in to comment.