1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 23:37:26 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs

280 lines
16 KiB
C#
Raw Normal View History

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