From 6fdaf025182f29e39243240dff05d85ac6820810 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 Feb 2021 17:57:23 +0900 Subject: [PATCH 01/10] Hook up room-level max attempts to UI --- .../Screens/OnlinePlay/OnlinePlayComposite.cs | 3 ++ .../PlaylistsMatchSettingsOverlay.cs | 45 +++++++------------ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs b/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs index 64792a32f3..b2f3e4a1d9 100644 --- a/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs +++ b/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs @@ -39,6 +39,9 @@ namespace osu.Game.Screens.OnlinePlay [Resolved(typeof(Room))] protected Bindable MaxParticipants { get; private set; } + [Resolved(typeof(Room))] + protected Bindable MaxAttempts { get; private set; } + [Resolved(typeof(Room))] protected Bindable EndDate { get; private set; } diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs index 01f9920609..bf85ecf13d 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs @@ -42,15 +42,13 @@ namespace osu.Game.Screens.OnlinePlay.Playlists public Action EditPlaylist; - public OsuTextBox NameField, MaxParticipantsField; + public OsuTextBox NameField, MaxParticipantsField, MaxAttemptsField; public OsuDropdown DurationField; public RoomAvailabilityPicker AvailabilityPicker; - public GameTypePicker TypePicker; public TriangleButton ApplyButton; public OsuSpriteText ErrorText; - private OsuSpriteText typeLabel; private LoadingLayer loadingLayer; private DrawableRoomPlaylist playlist; private OsuSpriteText playlistLength; @@ -134,6 +132,15 @@ namespace osu.Game.Screens.OnlinePlay.Playlists } } }, + new Section("Allowed attempts (across all playlist items)") + { + Child = MaxAttemptsField = new SettingsNumberTextBox + { + RelativeSizeAxes = Axes.X, + TabbableContentContainer = this, + PlaceholderText = "Unlimited", + }, + }, new Section("Room visibility") { Alpha = disabled_alpha, @@ -142,30 +149,6 @@ namespace osu.Game.Screens.OnlinePlay.Playlists Enabled = { Value = false } }, }, - new Section("Game type") - { - Alpha = disabled_alpha, - Child = new FillFlowContainer - { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Direction = FillDirection.Vertical, - Spacing = new Vector2(7), - Children = new Drawable[] - { - TypePicker = new GameTypePicker - { - RelativeSizeAxes = Axes.X, - Enabled = { Value = false } - }, - typeLabel = new OsuSpriteText - { - Font = OsuFont.GetFont(size: 14), - Colour = colours.Yellow - }, - }, - }, - }, new Section("Max participants") { Alpha = disabled_alpha, @@ -294,10 +277,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists loadingLayer = new LoadingLayer(true) }; - TypePicker.Current.BindValueChanged(type => typeLabel.Text = type.NewValue?.Name ?? string.Empty, true); RoomName.BindValueChanged(name => NameField.Text = name.NewValue, true); Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true); - Type.BindValueChanged(type => TypePicker.Current.Value = type.NewValue, true); MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true); Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue ?? TimeSpan.FromMinutes(30), true); @@ -326,13 +307,17 @@ namespace osu.Game.Screens.OnlinePlay.Playlists RoomName.Value = NameField.Text; Availability.Value = AvailabilityPicker.Current.Value; - Type.Value = TypePicker.Current.Value; if (int.TryParse(MaxParticipantsField.Text, out int max)) MaxParticipants.Value = max; else MaxParticipants.Value = null; + if (int.TryParse(MaxAttemptsField.Text, out max)) + MaxAttempts.Value = max; + else + MaxAttempts.Value = null; + Duration.Value = DurationField.Current.Value; manager?.CreateRoom(currentRoom.Value, onSuccess, onError); From 90acdd4361550d251ede8fc93db8edda2c5a38d2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 Feb 2021 18:06:52 +0900 Subject: [PATCH 02/10] Display the correct error message on score submission failure The server will return a valid error message in most cases here. We may eventually want to add some fallback message for cases an error may occur that isn't of [InvariantException](https://github.com/ppy/osu-web/blob/3169b33ccc4c540be5f20136393ad5f00d635ff9/app/Exceptions/InvariantException.php#L9-L10) type, but I'm not 100% sure how to identify these just yet. --- osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs index 2c3e7a12e2..7936ab8ecd 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs @@ -65,7 +65,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists { failed = true; - Logger.Error(e, "Failed to retrieve a score submission token.\n\nThis may happen if you are running an old or non-official release of osu! (ie. you are self-compiling)."); + Logger.Log($"You are not able to submit a score: {e.Message}", LoggingTarget.Information, LogLevel.Important); Schedule(() => { From 96d20bf6072aa181b6fb5662ddc32024be2d61bf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 Feb 2021 18:24:51 +0900 Subject: [PATCH 03/10] Reduce height of ModeTypeInfo to match adjacent text sections --- osu.Game/Screens/OnlinePlay/Components/ModeTypeInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/OnlinePlay/Components/ModeTypeInfo.cs b/osu.Game/Screens/OnlinePlay/Components/ModeTypeInfo.cs index 03b27b605c..2026106c42 100644 --- a/osu.Game/Screens/OnlinePlay/Components/ModeTypeInfo.cs +++ b/osu.Game/Screens/OnlinePlay/Components/ModeTypeInfo.cs @@ -12,7 +12,7 @@ namespace osu.Game.Screens.OnlinePlay.Components { public class ModeTypeInfo : OnlinePlayComposite { - private const float height = 30; + private const float height = 28; private const float transition_duration = 100; private Container drawableRuleset; From 9b209d67dc83568751994c1af8a0713f19339979 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 Feb 2021 18:44:13 +0900 Subject: [PATCH 04/10] Match size of participants text with host display --- osu.Game/Screens/OnlinePlay/Lounge/Components/ParticipantInfo.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/OnlinePlay/Lounge/Components/ParticipantInfo.cs b/osu.Game/Screens/OnlinePlay/Lounge/Components/ParticipantInfo.cs index 0d5ce65d5a..bc4506b78e 100644 --- a/osu.Game/Screens/OnlinePlay/Lounge/Components/ParticipantInfo.cs +++ b/osu.Game/Screens/OnlinePlay/Lounge/Components/ParticipantInfo.cs @@ -63,7 +63,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components summary = new OsuSpriteText { Text = "0 participants", - Font = OsuFont.GetFont(size: 14) } }, }, From fc3adaf6123e9f697b85d7c8fa566e111f1eb05b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 Feb 2021 18:44:35 +0900 Subject: [PATCH 05/10] Show maximum attempt count in room display (when not unlimited) --- .../Components/RoomLocalUserInfo.cs | 50 +++++++++++++++++++ .../OnlinePlay/Lounge/Components/RoomInfo.cs | 39 ++++++--------- 2 files changed, 66 insertions(+), 23 deletions(-) create mode 100644 osu.Game/Screens/OnlinePlay/Components/RoomLocalUserInfo.cs diff --git a/osu.Game/Screens/OnlinePlay/Components/RoomLocalUserInfo.cs b/osu.Game/Screens/OnlinePlay/Components/RoomLocalUserInfo.cs new file mode 100644 index 0000000000..f52e59b0c8 --- /dev/null +++ b/osu.Game/Screens/OnlinePlay/Components/RoomLocalUserInfo.cs @@ -0,0 +1,50 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.OnlinePlay.Components +{ + public class RoomLocalUserInfo : OnlinePlayComposite + { + private OsuSpriteText attemptDisplay; + + public RoomLocalUserInfo() + { + AutoSizeAxes = Axes.Both; + } + + [BackgroundDependencyLoader] + private void load() + { + InternalChild = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + attemptDisplay = new OsuSpriteText + { + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14) + }, + } + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + MaxAttempts.BindValueChanged(attempts => + { + attemptDisplay.Text = attempts.NewValue == null + ? string.Empty + : $"Maximum attempts: {attempts.NewValue:N0}"; + }, true); + } + } +} diff --git a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomInfo.cs b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomInfo.cs index 0a17702f2a..a0a7f2dc28 100644 --- a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomInfo.cs +++ b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomInfo.cs @@ -20,41 +20,34 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components { AutoSizeAxes = Axes.Y; + RoomLocalUserInfo localUserInfo; RoomStatusInfo statusInfo; ModeTypeInfo typeInfo; ParticipantInfo participantInfo; InternalChild = new FillFlowContainer { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, RelativeSizeAxes = Axes.X, + Spacing = new Vector2(0, 10), AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 4), Children = new Drawable[] { + roomName = new OsuTextFlowContainer(t => t.Font = OsuFont.GetFont(size: 30)) + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, + participantInfo = new ParticipantInfo(), new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Children = new Drawable[] { - new FillFlowContainer - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Children = new Drawable[] - { - roomName = new OsuTextFlowContainer(t => t.Font = OsuFont.GetFont(size: 30)) - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - }, - statusInfo = new RoomStatusInfo(), - } - }, + statusInfo = new RoomStatusInfo(), typeInfo = new ModeTypeInfo { Anchor = Anchor.BottomRight, @@ -62,20 +55,21 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components } } }, - participantInfo = new ParticipantInfo(), + localUserInfo = new RoomLocalUserInfo(), } }; - statusElements.AddRange(new Drawable[] { statusInfo, typeInfo, participantInfo }); + statusElements.AddRange(new Drawable[] + { + statusInfo, typeInfo, participantInfo, localUserInfo + }); } protected override void LoadComplete() { base.LoadComplete(); - if (RoomID.Value == null) statusElements.ForEach(e => e.FadeOut()); - RoomID.BindValueChanged(id => { if (id.NewValue == null) @@ -83,7 +77,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components else statusElements.ForEach(e => e.FadeIn(100)); }, true); - RoomName.BindValueChanged(name => { roomName.Text = name.NewValue ?? "No room selected"; From 3fe190cfbe7c5fb3c6d2863ea53a33b370ea03cd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Feb 2021 22:00:16 +0900 Subject: [PATCH 06/10] Show original error message on web exceptions (or is no message is returned) --- osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs index 7936ab8ecd..dc98eb8687 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; using System.Linq; +using System.Net; using System.Threading; using System.Threading.Tasks; using osu.Framework.Allocation; @@ -65,7 +66,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists { failed = true; - Logger.Log($"You are not able to submit a score: {e.Message}", LoggingTarget.Information, LogLevel.Important); + if (e is WebException || string.IsNullOrEmpty(e.Message)) + Logger.Error(e, "Failed to retrieve a score submission token.\n\nThis may happen if you are running an old or non-official release of osu! (ie. you are self-compiling)."); + else + Logger.Log($"You are not able to submit a score: {e.Message}", level: LogLevel.Important); Schedule(() => { From 9d7164816cf073be96b07353d6d996c50086ad71 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Feb 2021 22:02:40 +0900 Subject: [PATCH 07/10] Add reverse binding for max attempts (currently unused but good for safety) --- .../OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs index bf85ecf13d..56d3143f59 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsMatchSettingsOverlay.cs @@ -280,6 +280,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists RoomName.BindValueChanged(name => NameField.Text = name.NewValue, true); Availability.BindValueChanged(availability => AvailabilityPicker.Current.Value = availability.NewValue, true); MaxParticipants.BindValueChanged(count => MaxParticipantsField.Text = count.NewValue?.ToString(), true); + MaxAttempts.BindValueChanged(count => MaxAttemptsField.Text = count.NewValue?.ToString(), true); Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue ?? TimeSpan.FromMinutes(30), true); playlist.Items.BindTo(Playlist); From 95ad7ea8f7667a5e3faacbcbe696ef09b5b38354 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 5 Feb 2021 18:44:26 +0900 Subject: [PATCH 08/10] Fix mods on participant panels flashing when changed --- .../Multiplayer/Participants/ParticipantPanel.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs index 2983d1268d..0ee1b6d684 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs @@ -162,15 +162,20 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants const double fade_time = 50; - var ruleset = rulesets.GetRuleset(Room.Settings.RulesetID).CreateInstance(); - userStateDisplay.Status = User.State; - userModsDisplay.Current.Value = User.Mods.Select(m => m.ToMod(ruleset)).ToList(); if (Room.Host?.Equals(User) == true) crown.FadeIn(fade_time); else crown.FadeOut(fade_time); + + // If the mods are updated at the end of the frame, the flow container will skip a reflow cycle: https://github.com/ppy/osu-framework/issues/4187 + // This looks particularly jarring here, so re-schedule the update to that start of our frame as a fix. + Schedule(() => + { + var ruleset = rulesets.GetRuleset(Room.Settings.RulesetID).CreateInstance(); + userModsDisplay.Current.Value = User.Mods.Select(m => m.ToMod(ruleset)).ToList(); + }); } public MenuItem[] ContextMenuItems From 0679901e4d3048552b9e89ace1896958189c6d4e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 Feb 2021 22:53:40 +0900 Subject: [PATCH 09/10] Update error handling --- osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs index dc98eb8687..33200ca076 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs @@ -66,8 +66,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists { failed = true; - if (e is WebException || string.IsNullOrEmpty(e.Message)) - Logger.Error(e, "Failed to retrieve a score submission token.\n\nThis may happen if you are running an old or non-official release of osu! (ie. you are self-compiling)."); + if (string.IsNullOrEmpty(e.Message)) + Logger.Error(e, "Failed to retrieve a score submission token."); else Logger.Log($"You are not able to submit a score: {e.Message}", level: LogLevel.Important); From 7f82a06a61284b89a99a5b95cbae09cf428fa159 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 5 Feb 2021 23:08:31 +0900 Subject: [PATCH 10/10] Remove no longer used using directive --- osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs index 33200ca076..38eae2346a 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; using System.Linq; -using System.Net; using System.Threading; using System.Threading.Tasks; using osu.Framework.Allocation;