diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 64f8d4415b..5119f262d5 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -51,6 +51,7 @@ using osu.Game.Screens.Select; using osu.Game.Updater; using osu.Game.Utils; using LogLevel = osu.Framework.Logging.LogLevel; +using osu.Game.Users; namespace osu.Game { @@ -961,11 +962,15 @@ namespace osu.Game LocalUserPlaying.Value = false; if (current is IOsuScreen currentOsuScreen) + { OverlayActivationMode.UnbindFrom(currentOsuScreen.OverlayActivationMode); + API.Activity.UnbindFrom(currentOsuScreen.Activity); + } if (newScreen is IOsuScreen newOsuScreen) { OverlayActivationMode.BindTo(newOsuScreen.OverlayActivationMode); + ((IBindable)API.Activity).BindTo(newOsuScreen.Activity); MusicController.AllowRateAdjustments = newOsuScreen.AllowRateAdjustments; diff --git a/osu.Game/Screens/IOsuScreen.cs b/osu.Game/Screens/IOsuScreen.cs index e19037c2c4..cc8778d9ae 100644 --- a/osu.Game/Screens/IOsuScreen.cs +++ b/osu.Game/Screens/IOsuScreen.cs @@ -6,6 +6,7 @@ using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Overlays; using osu.Game.Rulesets; +using osu.Game.Users; namespace osu.Game.Screens { @@ -43,6 +44,11 @@ namespace osu.Game.Screens /// IBindable OverlayActivationMode { get; } + /// + /// The current for this screen. + /// + IBindable Activity { get; } + /// /// The amount of parallax to be applied while this screen is displayed. /// diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index a44d14fb5c..9b508c0cba 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -14,7 +14,6 @@ using osu.Game.Rulesets; using osu.Game.Screens.Menu; using osu.Game.Overlays; using osu.Game.Users; -using osu.Game.Online.API; using osu.Game.Rulesets.Mods; namespace osu.Game.Screens @@ -63,22 +62,12 @@ namespace osu.Game.Screens /// protected virtual UserActivity InitialActivity => null; - private UserActivity activity; - /// /// The current for this screen. /// - protected UserActivity Activity - { - get => activity; - set - { - if (value == activity) return; + protected readonly Bindable Activity; - activity = value; - updateActivity(); - } - } + IBindable IOsuScreen.Activity => Activity; /// /// Whether to disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children). @@ -135,15 +124,13 @@ namespace osu.Game.Screens [Resolved(canBeNull: true)] private OsuLogo logo { get; set; } - [Resolved(canBeNull: true)] - private IAPIProvider api { get; set; } - protected OsuScreen() { Anchor = Anchor.Centre; Origin = Anchor.Centre; OverlayActivationMode = new Bindable(InitialOverlayActivationMode); + Activity = new Bindable(); } [BackgroundDependencyLoader(true)] @@ -158,8 +145,6 @@ namespace osu.Game.Screens sampleExit?.Play(); applyArrivingDefaults(true); - updateActivity(); - base.OnResuming(last); } @@ -176,8 +161,8 @@ namespace osu.Game.Screens backgroundStack?.Push(localBackground = CreateBackground()); - if (activity == null) - Activity = InitialActivity; + if (Activity.Value == null) + Activity.Value = InitialActivity; base.OnEntering(last); } @@ -196,12 +181,6 @@ namespace osu.Game.Screens return false; } - private void updateActivity() - { - if (api != null) - api.Activity.Value = activity; - } - /// /// Fired when this screen was entered or resumed and the logo state is required to be adjusted. ///