mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 08:02:55 +08:00
Fix initial RoomId state not being handled correctly
This commit is contained in:
parent
90a1be2e61
commit
568f1fd345
@ -44,6 +44,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
/// </summary>
|
||||
protected readonly Bindable<IReadOnlyList<Mod>> UserMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
protected readonly IBindable<long?> RoomId = new Bindable<long?>();
|
||||
|
||||
[Resolved]
|
||||
private MusicController music { get; set; }
|
||||
|
||||
@ -60,14 +62,15 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
|
||||
protected IBindable<BeatmapAvailability> BeatmapAvailability => BeatmapAvailabilityTracker.Availability;
|
||||
|
||||
private readonly Room room;
|
||||
public readonly Room Room;
|
||||
|
||||
private ModSelectOverlay userModsSelectOverlay;
|
||||
private RoomSettingsOverlay settingsOverlay;
|
||||
private Drawable mainContent;
|
||||
|
||||
protected RoomSubScreen(Room room)
|
||||
{
|
||||
this.room = room;
|
||||
Room = room;
|
||||
|
||||
Padding = new MarginPadding { Top = Header.HEIGHT };
|
||||
|
||||
@ -75,6 +78,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
SelectedItem = { BindTarget = SelectedItem }
|
||||
};
|
||||
|
||||
RoomId.BindTo(room.RoomID);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -82,8 +87,6 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
sampleStart = audio.Samples.Get(@"SongSelect/confirm-selection");
|
||||
|
||||
Drawable mainContent;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
BeatmapAvailabilityTracker,
|
||||
@ -122,7 +125,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new DrawableMatchRoom(room)
|
||||
new DrawableMatchRoom(Room)
|
||||
{
|
||||
MatchingFilter = true,
|
||||
OnEdit = () => settingsOverlay.Show()
|
||||
@ -175,10 +178,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
// Resolves 1px masking errors between the settings overlay and the room panel.
|
||||
Padding = new MarginPadding(-1),
|
||||
Child = settingsOverlay = CreateRoomSettingsOverlay().With(s =>
|
||||
{
|
||||
s.State.Value = room.RoomID.Value == null ? Visibility.Visible : Visibility.Hidden;
|
||||
})
|
||||
Child = settingsOverlay = CreateRoomSettingsOverlay()
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -191,25 +191,28 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (room.RoomID.Value == null)
|
||||
{
|
||||
// A new room is being created.
|
||||
// The main content should be hidden until the settings overlay is hidden, signaling the room is ready to be displayed.
|
||||
mainContent.Hide();
|
||||
|
||||
settingsOverlay.State.BindValueChanged(visibility =>
|
||||
{
|
||||
if (visibility.NewValue == Visibility.Hidden)
|
||||
mainContent.Show();
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
RoomId.BindValueChanged(id =>
|
||||
{
|
||||
if (id.NewValue == null)
|
||||
{
|
||||
// A new room is being created.
|
||||
// The main content should be hidden until the settings overlay is hidden, signaling the room is ready to be displayed.
|
||||
mainContent.Hide();
|
||||
settingsOverlay.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
mainContent.Show();
|
||||
settingsOverlay.Hide();
|
||||
}
|
||||
}, true);
|
||||
|
||||
SelectedItem.BindValueChanged(_ => Scheduler.AddOnce(selectedItemChanged));
|
||||
|
||||
managerUpdated = beatmapManager.ItemUpdated.GetBoundCopy();
|
||||
@ -220,7 +223,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
|
||||
public override bool OnBackButton()
|
||||
{
|
||||
if (room.RoomID.Value == null)
|
||||
if (Room.RoomID.Value == null)
|
||||
{
|
||||
// room has not been created yet; exit immediately.
|
||||
return base.OnBackButton();
|
||||
|
@ -42,8 +42,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
|
||||
public override string ShortTitle => "room";
|
||||
|
||||
public readonly Room Room;
|
||||
|
||||
[Resolved]
|
||||
private MultiplayerClient client { get; set; }
|
||||
|
||||
@ -61,8 +59,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
public MultiplayerMatchSubScreen(Room room)
|
||||
: base(room)
|
||||
{
|
||||
Room = room;
|
||||
|
||||
Title = room.RoomID.Value == null ? "New room" : room.Name.Value;
|
||||
Activity.Value = new UserActivity.InLobby(room);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user