Skip to content

Commit

Permalink
Add option to pause the practice timer while the pause menu is open
Browse files Browse the repository at this point in the history
  • Loading branch information
bobofromkirby64 committed Mar 6, 2024
1 parent b3783ff commit 02f7236
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Content/Text/English.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"SpeedrunUtils_OptionsTitle": "SpeedrunUtils Options",
"SpeedrunUtils_PauseOptions": "SpeedrunUtils Options",
"SpeedrunUtils_RecollectItems": "Recollect Collectibles",
"SpeedrunUtils_PracticeTimer": "Practice Timer"
"SpeedrunUtils_PracticeTimer": "Practice Timer",
"SpeedrunUtils_PracticeTimer_PauseInMenu": "Pause the timer while the menu is open"
},
"Dialog":
{
Expand Down
8 changes: 8 additions & 0 deletions Source/Data/Save.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public void ResetSpeedrunPracticeTime()
/// </summary>
public bool SpeedrunPracticeTimer { get; set; } = false;

// If the Speedrun Timer should be paused when it is in "practice" mode and the pause menu is open
public bool SpeedrunPracticeTimerPauseInMenu { get; set; } = false;

/// <summary>
/// 0-10 Music volume level
/// </summary>
Expand Down Expand Up @@ -179,6 +182,11 @@ public void ToggleSpeedrunPracticeTime()
SpeedrunPracticeTimer = !SpeedrunPracticeTimer;
}

public void ToggleSpeedrunPracticeTimerPauseInMenu()
{
SpeedrunPracticeTimerPauseInMenu = !SpeedrunPracticeTimerPauseInMenu;
}

public TimeSpan GetCurrentDisplayTime()
{
return SpeedrunPracticeTimer
Expand Down
3 changes: 2 additions & 1 deletion Source/Scenes/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public World(EntryInfo entry)
speedrunMenu.Title = Loc.Str("SpeedrunUtils_OptionsTitle");
speedrunMenu.Add(new Menu.Toggle(Loc.Str("SpeedrunUtils_RecollectItems"), Save.Instance.ToggleSpeedrunRecollectItems, () => Save.Instance.SpeedrunRecollectItems));
speedrunMenu.Add(new Menu.Toggle(Loc.Str("SpeedrunUtils_PracticeTimer"), Save.Instance.ToggleSpeedrunPracticeTime, () => Save.Instance.SpeedrunPracticeTimer));
speedrunMenu.Add(new Menu.Toggle(Loc.Str("SpeedrunUtils_PracticeTimer_PauseInMenu"), Save.Instance.ToggleSpeedrunPracticeTimerPauseInMenu, () => Save.Instance.SpeedrunPracticeTimerPauseInMenu));

pauseMenu.Title = Loc.Str("PauseTitle");
pauseMenu.Add(new Menu.Option(Loc.Str("PauseResume"), () => SetPaused(false)));
Expand Down Expand Up @@ -300,7 +301,7 @@ public override void Update()
}

// increment practice timer (if not in the ending area)
if (IsPlayerActive && !IsInEndingArea)
if (IsPlayerActive && !IsInEndingArea && !(Save.Instance.SpeedrunPracticeTimerPauseInMenu && Paused))
{
Save.CurrentRecord.SpeedrunPracticeTime += TimeSpan.FromSeconds(Time.Delta);
}
Expand Down

0 comments on commit 02f7236

Please sign in to comment.