2020-12-20 14:40:19 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 08:43:03 +00:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-05-29 00:01:56 +00:00
|
|
|
|
2020-05-28 13:25:00 +00:00
|
|
|
using System.Diagnostics;
|
2020-02-13 09:12:47 +00:00
|
|
|
using System.Linq;
|
2018-12-06 03:21:30 +00:00
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 10:04:31 +00:00
|
|
|
using osu.Framework.Bindables;
|
2018-05-29 01:11:01 +00:00
|
|
|
using osu.Framework.Graphics;
|
2018-05-29 05:42:52 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-12-17 02:51:28 +00:00
|
|
|
using osu.Framework.Screens;
|
2020-05-26 09:12:19 +00:00
|
|
|
using osu.Game.Online.API;
|
2020-12-25 04:38:11 +00:00
|
|
|
using osu.Game.Online.Rooms;
|
2020-12-25 15:50:00 +00:00
|
|
|
using osu.Game.Screens.OnlinePlay.Components;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Match;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
2020-02-14 11:48:09 +00:00
|
|
|
using osu.Game.Screens.Select;
|
2020-11-08 12:21:21 +00:00
|
|
|
using osu.Game.Users;
|
2020-12-25 15:50:00 +00:00
|
|
|
using Footer = osu.Game.Screens.OnlinePlay.Match.Components.Footer;
|
2018-05-29 00:01:56 +00:00
|
|
|
|
2020-12-25 15:50:00 +00:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Playlists
|
2018-05-29 00:01:56 +00:00
|
|
|
{
|
2020-12-25 04:11:21 +00:00
|
|
|
public class PlaylistsRoomSubScreen : RoomSubScreen
|
2018-05-29 00:01:56 +00:00
|
|
|
{
|
2019-02-07 10:52:33 +00:00
|
|
|
public override string Title { get; }
|
2019-02-05 10:00:01 +00:00
|
|
|
|
2020-12-24 15:08:45 +00:00
|
|
|
public override string ShortTitle => "playlist";
|
2018-12-04 08:43:44 +00:00
|
|
|
|
2019-02-05 10:00:01 +00:00
|
|
|
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
|
|
|
private Bindable<int?> roomId { get; set; }
|
2018-12-22 05:01:06 +00:00
|
|
|
|
2020-02-14 11:48:09 +00:00
|
|
|
private MatchSettingsOverlay settingsOverlay;
|
2020-07-07 10:23:11 +00:00
|
|
|
private MatchLeaderboard leaderboard;
|
2019-02-11 10:11:34 +00:00
|
|
|
|
2020-07-07 10:23:11 +00:00
|
|
|
private OverlinedHeader participantsHeader;
|
2020-05-19 07:44:22 +00:00
|
|
|
|
2020-12-25 04:11:21 +00:00
|
|
|
public PlaylistsRoomSubScreen(Room room)
|
2019-02-11 10:11:34 +00:00
|
|
|
{
|
2020-12-24 15:08:45 +00:00
|
|
|
Title = room.RoomID.Value == null ? "New playlist" : room.Name.Value;
|
2020-11-08 12:21:21 +00:00
|
|
|
Activity.Value = new UserActivity.InLobby(room);
|
2019-02-11 10:11:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2021-01-19 13:23:31 +00:00
|
|
|
new GridContainer
|
2018-05-29 05:42:52 +00:00
|
|
|
{
|
2019-02-11 10:11:34 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Content = new[]
|
2018-12-14 05:20:03 +00:00
|
|
|
{
|
2019-02-11 10:11:34 +00:00
|
|
|
new Drawable[]
|
2018-12-14 10:52:03 +00:00
|
|
|
{
|
2020-02-14 11:48:09 +00:00
|
|
|
new Container
|
2018-12-14 10:52:03 +00:00
|
|
|
{
|
2019-02-11 10:11:34 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-02-14 11:48:09 +00:00
|
|
|
Padding = new MarginPadding
|
2018-12-14 10:52:03 +00:00
|
|
|
{
|
2020-02-14 11:48:09 +00:00
|
|
|
Horizontal = 105,
|
|
|
|
Vertical = 20
|
|
|
|
},
|
|
|
|
Child = new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-07-07 10:23:11 +00:00
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(),
|
|
|
|
},
|
2020-02-14 11:48:09 +00:00
|
|
|
Content = new[]
|
2018-12-14 10:52:03 +00:00
|
|
|
{
|
2020-12-20 14:40:19 +00:00
|
|
|
new Drawable[] { new Match.Components.Header() },
|
2020-06-25 09:59:14 +00:00
|
|
|
new Drawable[]
|
|
|
|
{
|
2020-07-07 10:23:11 +00:00
|
|
|
participantsHeader = new OverlinedHeader("Participants")
|
|
|
|
{
|
|
|
|
ShowLine = false
|
|
|
|
}
|
2020-06-25 09:59:14 +00:00
|
|
|
},
|
2020-02-14 11:48:09 +00:00
|
|
|
new Drawable[]
|
2019-02-11 10:11:34 +00:00
|
|
|
{
|
2020-02-14 11:48:09 +00:00
|
|
|
new Container
|
2020-06-25 11:53:48 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2020-07-07 10:23:11 +00:00
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
Child = new ParticipantsDisplay(Direction.Horizontal)
|
2020-06-25 11:53:48 +00:00
|
|
|
{
|
2020-07-07 10:23:11 +00:00
|
|
|
Details = { BindTarget = participantsHeader.Details }
|
2020-06-25 11:53:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new GridContainer
|
2019-01-24 09:40:48 +00:00
|
|
|
{
|
2020-02-14 11:48:09 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-06-25 11:53:48 +00:00
|
|
|
Content = new[]
|
2020-02-14 11:48:09 +00:00
|
|
|
{
|
2020-06-25 11:53:48 +00:00
|
|
|
new Drawable[]
|
2020-02-14 11:48:09 +00:00
|
|
|
{
|
2020-06-25 11:53:48 +00:00
|
|
|
new Container
|
2020-02-14 11:48:09 +00:00
|
|
|
{
|
2020-06-25 11:53:48 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Right = 5 },
|
2020-06-25 13:22:19 +00:00
|
|
|
Child = new GridContainer
|
2020-02-14 11:48:09 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-06-25 13:22:19 +00:00
|
|
|
Content = new[]
|
|
|
|
{
|
2020-12-03 08:59:39 +00:00
|
|
|
new Drawable[] { new OverlinedPlaylistHeader(), },
|
2020-06-25 13:22:19 +00:00
|
|
|
new Drawable[]
|
|
|
|
{
|
2020-07-10 10:37:27 +00:00
|
|
|
new DrawableRoomPlaylistWithResults
|
2020-06-25 13:22:19 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-12-20 14:40:19 +00:00
|
|
|
Items = { BindTarget = Playlist },
|
2020-07-10 10:37:27 +00:00
|
|
|
SelectedItem = { BindTarget = SelectedItem },
|
|
|
|
RequestShowResults = item =>
|
|
|
|
{
|
|
|
|
Debug.Assert(roomId.Value != null);
|
2020-12-25 16:00:00 +00:00
|
|
|
ParentScreen?.Push(new PlaylistsResultsScreen(null, roomId.Value.Value, item, false));
|
2020-07-10 10:37:27 +00:00
|
|
|
}
|
2020-06-25 13:22:19 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
2020-07-10 06:37:08 +00:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2020-06-25 13:22:19 +00:00
|
|
|
new Dimension(),
|
|
|
|
}
|
2020-02-14 11:48:09 +00:00
|
|
|
}
|
|
|
|
},
|
2020-07-07 09:28:43 +00:00
|
|
|
null,
|
|
|
|
new GridContainer
|
2020-06-25 11:53:48 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-07-07 09:28:43 +00:00
|
|
|
Content = new[]
|
|
|
|
{
|
2020-07-07 10:23:11 +00:00
|
|
|
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 } }
|
2020-07-07 09:28:43 +00:00
|
|
|
},
|
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
2020-07-07 10:23:11 +00:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2020-07-07 09:28:43 +00:00
|
|
|
new Dimension(),
|
2020-07-07 10:23:11 +00:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2020-08-31 11:21:57 +00:00
|
|
|
new Dimension(GridSizeMode.Relative, size: 0.4f, minSize: 120),
|
2020-07-07 09:28:43 +00:00
|
|
|
}
|
2020-06-25 11:53:48 +00:00
|
|
|
},
|
2020-07-07 09:28:43 +00:00
|
|
|
null
|
2020-06-25 11:53:48 +00:00
|
|
|
},
|
2020-07-07 09:28:43 +00:00
|
|
|
},
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.Relative, size: 0.5f, maxSize: 400),
|
|
|
|
new Dimension(),
|
|
|
|
new Dimension(GridSizeMode.Relative, size: 0.5f, maxSize: 600),
|
|
|
|
new Dimension(),
|
2020-02-14 11:48:09 +00:00
|
|
|
}
|
2019-02-11 10:11:34 +00:00
|
|
|
}
|
2020-02-14 11:48:09 +00:00
|
|
|
}
|
2018-12-14 10:52:03 +00:00
|
|
|
},
|
2020-02-14 11:48:09 +00:00
|
|
|
}
|
2019-02-11 10:11:34 +00:00
|
|
|
}
|
2018-12-14 10:52:03 +00:00
|
|
|
},
|
2020-02-14 11:48:09 +00:00
|
|
|
new Drawable[]
|
|
|
|
{
|
2020-12-22 06:51:24 +00:00
|
|
|
new Footer
|
2020-02-14 11:48:09 +00:00
|
|
|
{
|
|
|
|
OnStart = onStart,
|
2020-02-14 14:39:39 +00:00
|
|
|
SelectedItem = { BindTarget = SelectedItem }
|
2020-02-14 11:48:09 +00:00
|
|
|
}
|
|
|
|
}
|
2019-02-05 10:00:01 +00:00
|
|
|
},
|
2019-02-11 10:11:34 +00:00
|
|
|
RowDimensions = new[]
|
2019-02-05 10:00:01 +00:00
|
|
|
{
|
2020-02-14 11:48:09 +00:00
|
|
|
new Dimension(),
|
2019-02-11 10:11:34 +00:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
2019-02-05 10:00:01 +00:00
|
|
|
}
|
2019-02-11 10:11:34 +00:00
|
|
|
},
|
2020-12-25 04:11:21 +00:00
|
|
|
settingsOverlay = new PlaylistsMatchSettingsOverlay
|
2019-02-11 10:11:34 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-02-14 11:48:09 +00:00
|
|
|
EditPlaylist = () => this.Push(new MatchSongSelect()),
|
|
|
|
State = { Value = roomId.Value == null ? Visibility.Visible : Visibility.Hidden }
|
|
|
|
}
|
2019-02-11 10:11:34 +00:00
|
|
|
};
|
|
|
|
}
|
2018-12-27 09:10:49 +00:00
|
|
|
|
2020-05-26 09:12:19 +00:00
|
|
|
[Resolved]
|
|
|
|
private IAPIProvider api { get; set; }
|
|
|
|
|
2019-02-12 04:02:33 +00:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2020-02-14 11:48:09 +00:00
|
|
|
roomId.BindValueChanged(id =>
|
|
|
|
{
|
|
|
|
if (id.NewValue == null)
|
|
|
|
settingsOverlay.Show();
|
|
|
|
else
|
2020-02-14 14:39:39 +00:00
|
|
|
{
|
2020-02-14 11:48:09 +00:00
|
|
|
settingsOverlay.Hide();
|
2020-02-14 14:39:39 +00:00
|
|
|
|
|
|
|
// Set the first playlist item.
|
|
|
|
// This is scheduled since updating the room and playlist may happen in an arbitrary order (via Room.CopyFrom()).
|
2020-12-20 14:40:19 +00:00
|
|
|
Schedule(() => SelectedItem.Value = Playlist.FirstOrDefault());
|
2020-02-14 14:39:39 +00:00
|
|
|
}
|
2020-02-14 11:48:09 +00:00
|
|
|
}, true);
|
2019-02-12 04:02:33 +00:00
|
|
|
}
|
|
|
|
|
2020-12-25 04:11:21 +00:00
|
|
|
private void onStart() => StartPlay(() => new PlaylistsPlayer(SelectedItem.Value)
|
2019-02-11 10:11:34 +00:00
|
|
|
{
|
2020-12-24 07:53:25 +00:00
|
|
|
Exited = () => leaderboard.RefreshScores()
|
|
|
|
});
|
2018-05-29 00:01:56 +00:00
|
|
|
}
|
|
|
|
}
|