1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

Use BindValueChanged to show main content for new multiplayer and playlist rooms when the settings overlay is hidden.

This commit is contained in:
Mysfit 2021-01-19 08:52:43 -05:00
parent 6d1d488831
commit 33677f5770
2 changed files with 27 additions and 25 deletions

View File

@ -39,15 +39,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
private MultiplayerMatchSettingsOverlay settingsOverlay;
private readonly Bindable<Visibility> settingsOverlayVisibility = new Bindable<Visibility>();
private GridContainer subScreenContainer;
private IBindable<bool> isConnected;
[CanBeNull]
private IDisposable readyClickOperation;
private GridContainer mainContent;
public MultiplayerMatchSubScreen(Room room)
{
Title = room.RoomID.Value == null ? "New room" : room.Name.Value;
@ -59,7 +57,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
InternalChildren = new Drawable[]
{
subScreenContainer = new GridContainer
mainContent = new GridContainer
{
RelativeSizeAxes = Axes.Both,
Content = new[]
@ -183,9 +181,16 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
}
};
subScreenContainer.Hide();
settingsOverlayVisibility.BindTo(settingsOverlay.State);
settingsOverlayVisibility.ValueChanged += settingsOverlayVisibilityChanged;
if (client.Room == null)
{
mainContent.Hide();
settingsOverlay.State.BindValueChanged(visibility =>
{
if (visibility.NewValue == Visibility.Hidden)
mainContent.Show();
}, true);
}
}
protected override void LoadComplete()
@ -266,22 +271,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
readyClickOperation = null;
}
private void settingsOverlayVisibilityChanged(ValueChangedEvent<Visibility> settingsOverlayVisibilityChangedEvent)
{
if (client.Room != null)
{
subScreenContainer.Show();
settingsOverlayVisibility.ValueChanged -= settingsOverlayVisibilityChanged;
}
else
{
if (settingsOverlayVisibilityChangedEvent.NewValue == Visibility.Visible)
subScreenContainer.Hide();
else
subScreenContainer.Show();
}
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);

View File

@ -33,6 +33,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
private OverlinedHeader participantsHeader;
private GridContainer mainContent;
public PlaylistsRoomSubScreen(Room room)
{
Title = room.RoomID.Value == null ? "New playlist" : room.Name.Value;
@ -44,7 +46,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{
InternalChildren = new Drawable[]
{
new GridContainer
mainContent = new GridContainer
{
RelativeSizeAxes = Axes.Both,
Content = new[]
@ -190,6 +192,17 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
State = { Value = roomId.Value == null ? Visibility.Visible : Visibility.Hidden }
}
};
if (roomId.Value == null)
{
mainContent.Hide();
settingsOverlay.State.BindValueChanged(visibility =>
{
if (visibility.NewValue == Visibility.Hidden)
mainContent.Show();
}, true);
}
}
[Resolved]