mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 10:17:19 +08:00
Initial integration of playlists with the new structure
This commit is contained in:
parent
568f1fd345
commit
66e11fe75e
@ -30,18 +30,13 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
|
|
||||||
public override string ShortTitle => "playlist";
|
public override string ShortTitle => "playlist";
|
||||||
|
|
||||||
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
[Resolved]
|
||||||
private Bindable<long?> roomId { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
[Resolved(typeof(Room), nameof(Room.Playlist))]
|
|
||||||
private BindableList<PlaylistItem> playlist { get; set; }
|
|
||||||
|
|
||||||
private readonly IBindable<bool> isIdle = new BindableBool();
|
private readonly IBindable<bool> isIdle = new BindableBool();
|
||||||
|
|
||||||
private RoomSettingsOverlay settingsOverlay;
|
|
||||||
private MatchLeaderboard leaderboard;
|
private MatchLeaderboard leaderboard;
|
||||||
private OverlinedHeader participantsHeader;
|
private OverlinedHeader participantsHeader;
|
||||||
private GridContainer mainContent;
|
|
||||||
private SelectionPollingComponent selectionPollingComponent;
|
private SelectionPollingComponent selectionPollingComponent;
|
||||||
|
|
||||||
public PlaylistsRoomSubScreen(Room room)
|
public PlaylistsRoomSubScreen(Room room)
|
||||||
@ -57,231 +52,21 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
if (idleTracker != null)
|
if (idleTracker != null)
|
||||||
isIdle.BindTo(idleTracker.IsIdle);
|
isIdle.BindTo(idleTracker.IsIdle);
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
AddInternal(selectionPollingComponent = new SelectionPollingComponent());
|
||||||
{
|
|
||||||
selectionPollingComponent = new SelectionPollingComponent(),
|
|
||||||
mainContent = new GridContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Content = new[]
|
|
||||||
{
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Padding = new MarginPadding
|
|
||||||
{
|
|
||||||
Horizontal = 105,
|
|
||||||
Vertical = 20
|
|
||||||
},
|
|
||||||
Child = new GridContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
RowDimensions = new[]
|
|
||||||
{
|
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
|
||||||
new Dimension(),
|
|
||||||
},
|
|
||||||
Content = new[]
|
|
||||||
{
|
|
||||||
new Drawable[] { new Match.Components.Header() },
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
participantsHeader = new OverlinedHeader("Participants")
|
|
||||||
{
|
|
||||||
ShowLine = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Margin = new MarginPadding { Top = 5 },
|
|
||||||
Child = new ParticipantsDisplay(Direction.Horizontal)
|
|
||||||
{
|
|
||||||
Details = { BindTarget = participantsHeader.Details }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
new GridContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Content = new[]
|
|
||||||
{
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Padding = new MarginPadding { Right = 5 },
|
|
||||||
Child = new GridContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Content = new[]
|
|
||||||
{
|
|
||||||
new Drawable[] { new OverlinedPlaylistHeader(), },
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
new DrawableRoomPlaylistWithResults
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Items = { BindTarget = playlist },
|
|
||||||
SelectedItem = { BindTarget = SelectedItem },
|
|
||||||
RequestShowResults = item =>
|
|
||||||
{
|
|
||||||
Debug.Assert(roomId.Value != null);
|
|
||||||
ParentScreen?.Push(new PlaylistsResultsScreen(null, roomId.Value.Value, item, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RowDimensions = new[]
|
|
||||||
{
|
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
|
||||||
new Dimension(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
new GridContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Content = new[]
|
|
||||||
{
|
|
||||||
new[]
|
|
||||||
{
|
|
||||||
UserModsSection = new FillFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Margin = new MarginPadding { Bottom = 10 },
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new OverlinedHeader("Extra mods"),
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Spacing = new Vector2(10, 0),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new UserModSelectButton
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Width = 90,
|
|
||||||
Text = "Select",
|
|
||||||
Action = ShowUserModSelect,
|
|
||||||
},
|
|
||||||
new ModDisplay
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Current = UserMods,
|
|
||||||
Scale = new Vector2(0.8f),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
new OverlinedHeader("Leaderboard")
|
|
||||||
},
|
|
||||||
new Drawable[] { leaderboard = new MatchLeaderboard { RelativeSizeAxes = Axes.Both }, },
|
|
||||||
new Drawable[] { new OverlinedHeader("Chat"), },
|
|
||||||
new Drawable[] { new MatchChatDisplay { RelativeSizeAxes = Axes.Both } }
|
|
||||||
},
|
|
||||||
RowDimensions = new[]
|
|
||||||
{
|
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
|
||||||
new Dimension(),
|
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
|
||||||
new Dimension(GridSizeMode.Relative, size: 0.4f, minSize: 120),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
null
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ColumnDimensions = new[]
|
|
||||||
{
|
|
||||||
new Dimension(GridSizeMode.Relative, size: 0.5f, maxSize: 400),
|
|
||||||
new Dimension(),
|
|
||||||
new Dimension(GridSizeMode.Relative, size: 0.5f, maxSize: 600),
|
|
||||||
new Dimension(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Drawable[]
|
|
||||||
{
|
|
||||||
new Footer { OnStart = StartPlay }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
RowDimensions = new[]
|
|
||||||
{
|
|
||||||
new Dimension(),
|
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
settingsOverlay = new PlaylistsRoomSettingsOverlay
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
EditPlaylist = () =>
|
|
||||||
{
|
|
||||||
if (this.IsCurrentScreen())
|
|
||||||
this.Push(new PlaylistsSongSelect());
|
|
||||||
},
|
|
||||||
State = { Value = roomId.Value == null ? Visibility.Visible : Visibility.Hidden }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private IAPIProvider api { get; set; }
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
isIdle.BindValueChanged(_ => updatePollingRate(), true);
|
isIdle.BindValueChanged(_ => updatePollingRate(), true);
|
||||||
|
RoomId.BindValueChanged(id =>
|
||||||
roomId.BindValueChanged(id =>
|
|
||||||
{
|
{
|
||||||
if (id.NewValue == null)
|
if (id.NewValue != null)
|
||||||
settingsOverlay.Show();
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
settingsOverlay.Hide();
|
|
||||||
|
|
||||||
// Set the first playlist item.
|
// Set the first playlist item.
|
||||||
// This is scheduled since updating the room and playlist may happen in an arbitrary order (via Room.CopyFrom()).
|
// This is scheduled since updating the room and playlist may happen in an arbitrary order (via Room.CopyFrom()).
|
||||||
Schedule(() => SelectedItem.Value = playlist.FirstOrDefault());
|
Schedule(() => SelectedItem.Value = Room.Playlist.FirstOrDefault());
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
@ -297,10 +82,167 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
Exited = () => leaderboard.RefreshScores()
|
Exited = () => leaderboard.RefreshScores()
|
||||||
});
|
});
|
||||||
|
|
||||||
protected override Drawable CreateMainContent() => Empty();
|
protected override Drawable CreateMainContent() => new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
RowDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(),
|
||||||
|
},
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[] { new Match.Components.Header() },
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
participantsHeader = new OverlinedHeader("Participants")
|
||||||
|
{
|
||||||
|
ShowLine = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Margin = new MarginPadding { Top = 5 },
|
||||||
|
Child = new ParticipantsDisplay(Direction.Horizontal)
|
||||||
|
{
|
||||||
|
Details = { BindTarget = participantsHeader.Details }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Padding = new MarginPadding { Right = 5 },
|
||||||
|
Child = new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[] { new OverlinedPlaylistHeader(), },
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new DrawableRoomPlaylistWithResults
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Items = { BindTarget = Room.Playlist },
|
||||||
|
SelectedItem = { BindTarget = SelectedItem },
|
||||||
|
RequestShowResults = item =>
|
||||||
|
{
|
||||||
|
Debug.Assert(RoomId.Value != null);
|
||||||
|
ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RowDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new[]
|
||||||
|
{
|
||||||
|
UserModsSection = new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Margin = new MarginPadding { Bottom = 10 },
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OverlinedHeader("Extra mods"),
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(10, 0),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new UserModSelectButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Width = 90,
|
||||||
|
Text = "Select",
|
||||||
|
Action = ShowUserModSelect,
|
||||||
|
},
|
||||||
|
new ModDisplay
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Current = UserMods,
|
||||||
|
Scale = new Vector2(0.8f),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new OverlinedHeader("Leaderboard")
|
||||||
|
},
|
||||||
|
new Drawable[] { leaderboard = new MatchLeaderboard { RelativeSizeAxes = Axes.Both }, },
|
||||||
|
new Drawable[] { new OverlinedHeader("Chat"), },
|
||||||
|
new Drawable[] { new MatchChatDisplay { RelativeSizeAxes = Axes.Both } }
|
||||||
|
},
|
||||||
|
RowDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(),
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(GridSizeMode.Relative, size: 0.4f, minSize: 120),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
null
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ColumnDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.Relative, size: 0.5f, maxSize: 400),
|
||||||
|
new Dimension(),
|
||||||
|
new Dimension(GridSizeMode.Relative, size: 0.5f, maxSize: 600),
|
||||||
|
new Dimension(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
protected override Drawable CreateFooter() => Empty();
|
protected override Drawable CreateFooter() => new Footer
|
||||||
|
{
|
||||||
|
OnStart = StartPlay
|
||||||
|
};
|
||||||
|
|
||||||
protected override RoomSettingsOverlay CreateRoomSettingsOverlay() => new PlaylistsRoomSettingsOverlay();
|
protected override RoomSettingsOverlay CreateRoomSettingsOverlay() => new PlaylistsRoomSettingsOverlay
|
||||||
|
{
|
||||||
|
EditPlaylist = () =>
|
||||||
|
{
|
||||||
|
if (this.IsCurrentScreen())
|
||||||
|
this.Push(new PlaylistsSongSelect());
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user