2020-12-20 22:40:19 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-05-29 08:01:56 +08:00
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-05-28 21:25:00 +08:00
|
|
|
using System.Diagnostics;
|
2020-02-13 17:12:47 +08:00
|
|
|
using System.Linq;
|
2021-08-13 17:11:52 +08:00
|
|
|
using JetBrains.Annotations;
|
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;
|
2018-05-29 13:42:52 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-08-13 17:11:52 +08:00
|
|
|
using osu.Framework.Logging;
|
2018-12-17 10:51:28 +08:00
|
|
|
using osu.Framework.Screens;
|
2022-07-08 06:42:11 +08:00
|
|
|
using osu.Game.Graphics.Cursor;
|
2021-08-13 17:11:52 +08:00
|
|
|
using osu.Game.Input;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Components;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Match;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
2021-05-14 09:25:29 +08:00
|
|
|
using osu.Game.Screens.Play;
|
2021-02-16 14:14:56 +08:00
|
|
|
using osu.Game.Screens.Play.HUD;
|
2020-11-08 20:21:21 +08:00
|
|
|
using osu.Game.Users;
|
2021-02-16 14:14:56 +08:00
|
|
|
using osuTK;
|
2018-05-29 08:01:56 +08:00
|
|
|
|
2020-12-25 23:50:00 +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 partial 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
|
|
|
|
2020-12-24 23:08:45 +08:00
|
|
|
public override string ShortTitle => "playlist";
|
2018-12-04 16:43:44 +08:00
|
|
|
|
2021-08-13 17:11:52 +08:00
|
|
|
private readonly IBindable<bool> isIdle = new BindableBool();
|
|
|
|
|
2020-07-07 18:23:11 +08:00
|
|
|
private MatchLeaderboard leaderboard;
|
2021-08-13 17:11:52 +08:00
|
|
|
private SelectionPollingComponent selectionPollingComponent;
|
2021-01-19 21:52:43 +08:00
|
|
|
|
2021-10-26 17:13:28 +08:00
|
|
|
private FillFlowContainer progressSection;
|
|
|
|
|
2020-12-25 12:11:21 +08:00
|
|
|
public PlaylistsRoomSubScreen(Room room)
|
2021-08-18 15:35:18 +08:00
|
|
|
: base(room, false) // Editing is temporarily not allowed.
|
2019-02-11 18:11:34 +08:00
|
|
|
{
|
2020-12-24 23:08:45 +08:00
|
|
|
Title = room.RoomID.Value == null ? "New playlist" : room.Name.Value;
|
2020-11-08 20:21:21 +08:00
|
|
|
Activity.Value = new UserActivity.InLobby(room);
|
2019-02-11 18:11:34 +08:00
|
|
|
}
|
|
|
|
|
2021-08-13 17:11:52 +08:00
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
private void load([CanBeNull] IdleTracker idleTracker)
|
2019-02-11 18:11:34 +08:00
|
|
|
{
|
2021-08-13 17:11:52 +08:00
|
|
|
if (idleTracker != null)
|
|
|
|
isIdle.BindTo(idleTracker.IsIdle);
|
|
|
|
|
2021-08-19 15:40:27 +08:00
|
|
|
AddInternal(selectionPollingComponent = new SelectionPollingComponent(Room));
|
2021-08-18 15:09:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
isIdle.BindValueChanged(_ => updatePollingRate(), true);
|
|
|
|
RoomId.BindValueChanged(id =>
|
|
|
|
{
|
|
|
|
if (id.NewValue != null)
|
|
|
|
{
|
|
|
|
// 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 = Room.Playlist.FirstOrDefault());
|
|
|
|
}
|
|
|
|
}, true);
|
2021-10-26 17:13:28 +08:00
|
|
|
|
2022-06-24 20:25:23 +08:00
|
|
|
Room.MaxAttempts.BindValueChanged(_ => progressSection.Alpha = Room.MaxAttempts.Value != null ? 1 : 0, true);
|
2021-08-18 15:09:15 +08:00
|
|
|
}
|
|
|
|
|
2022-02-21 18:46:31 +08:00
|
|
|
protected override Drawable CreateMainContent() => new Container
|
2021-08-18 15:09:15 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-02-21 18:46:31 +08:00
|
|
|
Padding = new MarginPadding { Horizontal = 5, Vertical = 10 },
|
2022-07-08 06:42:11 +08:00
|
|
|
Child = new OsuContextMenuContainer
|
2019-02-11 18:11:34 +08:00
|
|
|
{
|
2022-02-21 18:46:31 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-07-08 06:42:11 +08:00
|
|
|
Child = new GridContainer
|
2021-08-18 15:09:15 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(),
|
|
|
|
new Dimension(GridSizeMode.Absolute, 10),
|
|
|
|
new Dimension(),
|
|
|
|
new Dimension(GridSizeMode.Absolute, 10),
|
|
|
|
new Dimension(),
|
|
|
|
},
|
|
|
|
Content = new[]
|
2021-08-18 15:09:15 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
new Drawable[]
|
2018-12-14 18:52:03 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
// Playlist items column
|
2024-02-21 04:18:37 +08:00
|
|
|
new GridContainer
|
2018-12-14 18:52:03 +08:00
|
|
|
{
|
2022-02-21 18:46:31 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-07-08 06:42:11 +08:00
|
|
|
Padding = new MarginPadding { Right = 5 },
|
2024-02-21 04:18:37 +08:00
|
|
|
Content = new[]
|
2020-02-14 19:48:09 +08:00
|
|
|
{
|
2024-02-21 04:18:37 +08:00
|
|
|
new Drawable[] { new OverlinedPlaylistHeader(), },
|
|
|
|
new Drawable[]
|
2020-07-07 18:23:11 +08:00
|
|
|
{
|
2024-02-21 04:18:37 +08:00
|
|
|
new DrawableRoomPlaylist
|
2020-06-25 17:59:14 +08:00
|
|
|
{
|
2024-02-21 04:18:37 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Items = { BindTarget = Room.Playlist },
|
|
|
|
SelectedItem = { BindTarget = SelectedItem },
|
|
|
|
AllowSelection = true,
|
|
|
|
AllowShowingResults = true,
|
|
|
|
RequestResults = item =>
|
2022-02-21 18:46:31 +08:00
|
|
|
{
|
2024-02-21 04:18:37 +08:00
|
|
|
Debug.Assert(RoomId.Value != null);
|
|
|
|
ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item, false));
|
2022-02-21 18:46:31 +08:00
|
|
|
}
|
2024-02-21 04:18:37 +08:00
|
|
|
}
|
2022-02-21 18:46:31 +08:00
|
|
|
},
|
2024-02-21 04:18:37 +08:00
|
|
|
},
|
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(),
|
2022-02-21 18:46:31 +08:00
|
|
|
}
|
2022-07-08 06:42:11 +08:00
|
|
|
},
|
|
|
|
// Spacer
|
|
|
|
null,
|
|
|
|
// Middle column (mods and leaderboard)
|
|
|
|
new GridContainer
|
2021-08-18 15:26:45 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Content = new[]
|
2021-08-18 15:09:15 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
new[]
|
2021-08-18 15:09:15 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
UserModsSection = new FillFlowContainer
|
2021-08-18 15:09:15 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Alpha = 0,
|
|
|
|
Margin = new MarginPadding { Bottom = 10 },
|
|
|
|
Children = new Drawable[]
|
2019-01-24 17:40:48 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
new OverlinedHeader("Extra mods"),
|
|
|
|
new FillFlowContainer
|
2021-08-18 15:26:45 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(10, 0),
|
|
|
|
Children = new Drawable[]
|
2022-02-21 18:46:31 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
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),
|
|
|
|
},
|
|
|
|
}
|
2022-02-21 18:46:31 +08:00
|
|
|
}
|
2021-08-18 15:26:45 +08:00
|
|
|
}
|
2022-07-08 06:42:11 +08:00
|
|
|
},
|
2022-02-21 18:46:31 +08:00
|
|
|
},
|
2022-07-08 06:42:11 +08:00
|
|
|
new Drawable[]
|
2021-10-26 15:36:54 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
progressSection = new FillFlowContainer
|
2022-02-21 18:46:31 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Alpha = 0,
|
|
|
|
Margin = new MarginPadding { Bottom = 10 },
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new OverlinedHeader("Progress"),
|
|
|
|
new RoomLocalUserInfo(),
|
|
|
|
}
|
|
|
|
},
|
2022-02-21 18:46:31 +08:00
|
|
|
},
|
2022-07-08 06:42:11 +08:00
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new OverlinedHeader("Leaderboard")
|
|
|
|
},
|
|
|
|
new Drawable[] { leaderboard = new MatchLeaderboard { RelativeSizeAxes = Axes.Both }, },
|
2021-10-26 15:36:54 +08:00
|
|
|
},
|
2022-07-08 06:42:11 +08:00
|
|
|
RowDimensions = new[]
|
2022-02-21 18:46:31 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(),
|
|
|
|
}
|
2021-10-26 15:36:54 +08:00
|
|
|
},
|
2022-07-08 06:42:11 +08:00
|
|
|
// Spacer
|
|
|
|
null,
|
|
|
|
// Main right column
|
|
|
|
new GridContainer
|
2022-02-21 18:46:31 +08:00
|
|
|
{
|
2022-07-08 06:42:11 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[] { new OverlinedHeader("Chat") },
|
|
|
|
new Drawable[] { new MatchChatDisplay(Room) { RelativeSizeAxes = Axes.Both } }
|
|
|
|
},
|
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension(),
|
|
|
|
}
|
2022-02-21 18:46:31 +08:00
|
|
|
},
|
|
|
|
},
|
2021-08-18 15:26:45 +08:00
|
|
|
},
|
2022-07-08 06:42:11 +08:00
|
|
|
}
|
2021-08-18 15:26:45 +08:00
|
|
|
}
|
2021-08-18 15:09:15 +08:00
|
|
|
};
|
2021-01-19 21:52:43 +08:00
|
|
|
|
2021-08-18 19:21:29 +08:00
|
|
|
protected override Drawable CreateFooter() => new PlaylistsRoomFooter
|
2021-08-13 17:11:52 +08:00
|
|
|
{
|
2021-08-18 15:09:15 +08:00
|
|
|
OnStart = StartPlay
|
|
|
|
};
|
2021-08-13 17:11:52 +08:00
|
|
|
|
2021-08-19 15:40:27 +08:00
|
|
|
protected override RoomSettingsOverlay CreateRoomSettingsOverlay(Room room) => new PlaylistsRoomSettingsOverlay(room)
|
2019-02-11 18:11:34 +08:00
|
|
|
{
|
2021-08-18 15:09:15 +08:00
|
|
|
EditPlaylist = () =>
|
|
|
|
{
|
|
|
|
if (this.IsCurrentScreen())
|
2021-08-24 12:29:19 +08:00
|
|
|
this.Push(new PlaylistsSongSelect(Room));
|
2021-08-18 15:09:15 +08:00
|
|
|
},
|
|
|
|
};
|
2021-08-18 19:21:29 +08:00
|
|
|
|
|
|
|
private void updatePollingRate()
|
|
|
|
{
|
|
|
|
selectionPollingComponent.TimeBetweenPolls.Value = isIdle.Value ? 30000 : 5000;
|
|
|
|
Logger.Log($"Polling adjusted (selection: {selectionPollingComponent.TimeBetweenPolls.Value})");
|
|
|
|
}
|
|
|
|
|
2021-08-24 12:22:06 +08:00
|
|
|
protected override Screen CreateGameplayScreen() => new PlayerLoader(() => new PlaylistsPlayer(Room, SelectedItem.Value)
|
2021-08-18 19:21:29 +08:00
|
|
|
{
|
2022-01-28 20:22:09 +08:00
|
|
|
Exited = () => leaderboard.RefetchScores()
|
2021-08-18 19:21:29 +08:00
|
|
|
});
|
2018-05-29 08:01:56 +08:00
|
|
|
}
|
|
|
|
}
|