@@ -77,8 +77,7 @@ private Intro intro
7777
7878 public float ToolbarOffset => Toolbar . Position . Y + Toolbar . DrawHeight ;
7979
80- public readonly BindableBool HideOverlaysOnEnter = new BindableBool ( ) ;
81- public readonly BindableBool AllowOpeningOverlays = new BindableBool ( true ) ;
80+ public readonly Bindable < OverlayActivation > OverlayActivationMode = new Bindable < OverlayActivation > ( ) ;
8281
8382 private OsuScreen screenStack ;
8483
@@ -94,6 +93,8 @@ private Intro intro
9493
9594 private SettingsOverlay settings ;
9695
96+ private readonly List < OverlayContainer > overlays = new List < OverlayContainer > ( ) ;
97+
9798 // todo: move this to SongSelect once Screen has the ability to unsuspend.
9899 public readonly Bindable < IEnumerable < Mod > > SelectedMods = new Bindable < IEnumerable < Mod > > ( new List < Mod > ( ) ) ;
99100
@@ -106,6 +107,17 @@ public OsuGame(string[] args = null)
106107
107108 public void ToggleDirect ( ) => direct . ToggleVisibility ( ) ;
108109
110+ /// <summary>
111+ /// Close all game-wide overlays.
112+ /// </summary>
113+ /// <param name="toolbar">Whether the toolbar should also be hidden.</param>
114+ public void CloseAllOverlays ( bool toolbar = true )
115+ {
116+ foreach ( var o in overlays )
117+ o . State = Visibility . Hidden ;
118+ if ( toolbar ) Toolbar . State = Visibility . Hidden ;
119+ }
120+
109121 private DependencyContainer dependencies ;
110122
111123 protected override IReadOnlyDependencyContainer CreateLocalDependencies ( IReadOnlyDependencyContainer parent ) =>
@@ -251,7 +263,7 @@ protected override void LoadComplete()
251263 Depth = - 5 ,
252264 OnHome = delegate
253265 {
254- hideAllOverlays ( ) ;
266+ CloseAllOverlays ( false ) ;
255267 intro ? . ChildScreen ? . MakeCurrent ( ) ;
256268 } ,
257269 } , overlayContent . Add ) ;
@@ -308,6 +320,8 @@ protected override void LoadComplete()
308320
309321 // ensure only one of these overlays are open at once.
310322 var singleDisplayOverlays = new OverlayContainer [ ] { chat , social , direct } ;
323+ overlays . AddRange ( singleDisplayOverlays ) ;
324+
311325 foreach ( var overlay in singleDisplayOverlays )
312326 {
313327 overlay . StateChanged += state =>
@@ -323,6 +337,8 @@ protected override void LoadComplete()
323337 }
324338
325339 var singleDisplaySideOverlays = new OverlayContainer [ ] { settings , notifications } ;
340+ overlays . AddRange ( singleDisplaySideOverlays ) ;
341+
326342 foreach ( var overlay in singleDisplaySideOverlays )
327343 {
328344 overlay . StateChanged += state =>
@@ -339,6 +355,8 @@ protected override void LoadComplete()
339355
340356 // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time.
341357 var informationalOverlays = new OverlayContainer [ ] { beatmapSetOverlay , userProfile } ;
358+ overlays . AddRange ( informationalOverlays ) ;
359+
342360 foreach ( var overlay in informationalOverlays )
343361 {
344362 overlay . StateChanged += state =>
@@ -353,6 +371,11 @@ protected override void LoadComplete()
353371 } ;
354372 }
355373
374+ OverlayActivationMode . ValueChanged += v =>
375+ {
376+ if ( v != OverlayActivation . All ) CloseAllOverlays ( ) ;
377+ } ;
378+
356379 void updateScreenOffset ( )
357380 {
358381 float offset = 0 ;
@@ -367,21 +390,6 @@ void updateScreenOffset()
367390
368391 settings . StateChanged += _ => updateScreenOffset ( ) ;
369392 notifications . StateChanged += _ => updateScreenOffset ( ) ;
370-
371- notifications . Enabled . BindTo ( AllowOpeningOverlays ) ;
372-
373- HideOverlaysOnEnter . ValueChanged += hide =>
374- {
375- //central game screen change logic.
376- if ( hide )
377- {
378- hideAllOverlays ( ) ;
379- musicController . State = Visibility . Hidden ;
380- Toolbar . State = Visibility . Hidden ;
381- }
382- else
383- Toolbar . State = Visibility . Visible ;
384- } ;
385393 }
386394
387395 private void forwardLoggedErrorsToNotifications ( )
@@ -498,16 +506,6 @@ protected override void OnActivated()
498506 private OsuScreen currentScreen ;
499507 private FrameworkConfigManager frameworkConfig ;
500508
501- private void hideAllOverlays ( )
502- {
503- settings . State = Visibility . Hidden ;
504- chat . State = Visibility . Hidden ;
505- direct . State = Visibility . Hidden ;
506- social . State = Visibility . Hidden ;
507- userProfile . State = Visibility . Hidden ;
508- notifications . State = Visibility . Hidden ;
509- }
510-
511509 protected override bool OnExiting ( )
512510 {
513511 if ( screenStack . ChildScreen == null ) return false ;
0 commit comments