mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Maintain the current gameplay state in OsuGame
This commit is contained in:
@ -68,6 +68,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
|
||||
|
||||
private readonly Bindable<bool> isGameplay = new Bindable<bool>();
|
||||
|
||||
public int RestartCount;
|
||||
|
||||
[Resolved]
|
||||
@ -156,7 +158,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, OsuConfigManager config)
|
||||
private void load(AudioManager audio, OsuConfigManager config, OsuGame game)
|
||||
{
|
||||
Mods.Value = base.Mods.Value.Select(m => m.CreateCopy()).ToArray();
|
||||
|
||||
@ -172,6 +174,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
|
||||
|
||||
isGameplay.BindTo(game.IsGameplay);
|
||||
|
||||
DrawableRuleset = ruleset.CreateDrawableRulesetWith(playableBeatmap, Mods.Value);
|
||||
|
||||
ScoreProcessor = ruleset.CreateScoreProcessor();
|
||||
@ -219,9 +223,9 @@ namespace osu.Game.Screens.Play
|
||||
skipOverlay.Hide();
|
||||
}
|
||||
|
||||
DrawableRuleset.IsPaused.BindValueChanged(_ => updateOverlayActivationMode());
|
||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateOverlayActivationMode());
|
||||
breakTracker.IsBreakTime.BindValueChanged(_ => updateOverlayActivationMode());
|
||||
DrawableRuleset.IsPaused.BindValueChanged(_ => updateGameplayState());
|
||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateGameplayState());
|
||||
breakTracker.IsBreakTime.BindValueChanged(_ => updateGameplayState());
|
||||
|
||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
|
||||
|
||||
@ -353,14 +357,11 @@ namespace osu.Game.Screens.Play
|
||||
HUDOverlay.KeyCounter.IsCounting = !isBreakTime.NewValue;
|
||||
}
|
||||
|
||||
private void updateOverlayActivationMode()
|
||||
private void updateGameplayState()
|
||||
{
|
||||
bool canTriggerOverlays = DrawableRuleset.IsPaused.Value || breakTracker.IsBreakTime.Value;
|
||||
|
||||
if (DrawableRuleset.HasReplayLoaded.Value || canTriggerOverlays)
|
||||
OverlayActivationMode.Value = OverlayActivation.UserTriggered;
|
||||
else
|
||||
OverlayActivationMode.Value = OverlayActivation.Disabled;
|
||||
bool inGameplay = !DrawableRuleset.HasReplayLoaded.Value && !DrawableRuleset.IsPaused.Value && !breakTracker.IsBreakTime.Value;
|
||||
OverlayActivationMode.Value = inGameplay ? OverlayActivation.Disabled : OverlayActivation.UserTriggered;
|
||||
isGameplay.Value = inGameplay;
|
||||
}
|
||||
|
||||
private void updatePauseOnFocusLostState() =>
|
||||
@ -657,7 +658,7 @@ namespace osu.Game.Screens.Play
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToTrack>())
|
||||
mod.ApplyToTrack(musicController.CurrentTrack);
|
||||
|
||||
updateOverlayActivationMode();
|
||||
updateGameplayState();
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
@ -693,6 +694,9 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
musicController.ResetTrackAdjustments();
|
||||
|
||||
// Ensure we reset the IsGameplay state
|
||||
isGameplay.Value = false;
|
||||
|
||||
fadeOut();
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
Reference in New Issue
Block a user