From 689866f5dd4ae6a494112296f024e414ca41cd7e Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 17 Jul 2017 20:25:57 +0200 Subject: [PATCH 01/31] minor improvements --- osu.Game/OsuGame.cs | 2 +- osu.Game/Overlays/Profile/ProfileHeader.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 6bec2cb184..13f49b75e6 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -175,7 +175,7 @@ namespace osu.Game LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); - LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -1 }, mainContent.Add); + LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); LoadComponentAsync(settings = new SettingsOverlay { Depth = -1 }, overlayContent.Add); LoadComponentAsync(musicController = new MusicController { diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 17493d5078..d1c3a2178e 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -29,6 +29,7 @@ namespace osu.Game.Overlays.Profile private readonly SpriteText levelText; private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; private readonly Box colourBar; + private readonly DrawableFlag countryFlag; private const float cover_height = 350; private const float info_height = 150; @@ -123,7 +124,7 @@ namespace osu.Game.Overlays.Profile Origin = Anchor.BottomLeft, Y = -48 }, - new DrawableFlag(user.Country?.FlagName ?? "__") + countryFlag = new DrawableFlag(user.Country?.FlagName ?? "__") { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -350,6 +351,7 @@ namespace osu.Game.Overlays.Profile { infoTextLeft.AddText("from "); infoTextLeft.AddText(user.Country.FullName, boldItalic); + countryFlag.FlagName = user.Country.FlagName; } infoTextLeft.NewParagraph(); @@ -390,7 +392,7 @@ namespace osu.Game.Overlays.Profile scoreText.Add(createScoreText("Ranked Score")); scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0"))); scoreText.Add(createScoreText("Accuracy")); - scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy}%")); + scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy.ToString("0.##")}%")); scoreText.Add(createScoreText("Play Count")); scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0"))); scoreText.Add(createScoreText("Total Score")); From b9eb7a8445e6534a3d3e6c5c5c9c3d6d9f28d92c Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 17 Jul 2017 20:26:55 +0200 Subject: [PATCH 02/31] make chat message users open UserProfileOverlay --- osu.Game/Overlays/Chat/ChatLine.cs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index 3aaca7593c..c59a589fba 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -8,6 +8,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; namespace osu.Game.Overlays.Chat { @@ -68,6 +69,8 @@ namespace osu.Game.Overlays.Chat private const float message_padding = 200; private const float text_size = 20; + private UserProfileOverlay profileOverlay; + public ChatLine(Message message) { Message = message; @@ -94,15 +97,20 @@ namespace osu.Game.Overlays.Chat TextSize = text_size * 0.75f, Alpha = 0.4f, }, - new OsuSpriteText + new ClickableContainer { - Font = @"Exo2.0-BoldItalic", - Text = $@"{Message.Sender.Username}:", - Colour = getUsernameColour(Message), - TextSize = text_size, + AutoSizeAxes = Axes.Both, Origin = Anchor.TopRight, Anchor = Anchor.TopRight, - } + Child = new OsuSpriteText + { + Font = @"Exo2.0-BoldItalic", + Text = $@"{Message.Sender.Username}:", + Colour = getUsernameColour(Message), + TextSize = text_size, + }, + Action = () => profileOverlay?.ShowUser(Message.Sender), + }, } }, new Container @@ -123,5 +131,11 @@ namespace osu.Game.Overlays.Chat } }; } + + [BackgroundDependencyLoader(permitNulls: true)] + private void load(UserProfileOverlay profileOverlay) + { + this.profileOverlay = profileOverlay; + } } } From edd4e622cf09ec0ddf162fdb2a747bf790b8c4a2 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 17 Jul 2017 20:31:10 +0200 Subject: [PATCH 03/31] add hyper links to twitter, website and skype --- osu.Game/Overlays/Profile/ProfileHeader.cs | 44 ++++++++++++++++++---- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index d1c3a2178e..60ba8a5fd6 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -12,16 +12,19 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; +using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Users; +using System.Diagnostics; namespace osu.Game.Overlays.Profile { public class ProfileHeader : Container { - private readonly OsuTextFlowContainer infoTextLeft, infoTextRight; + private readonly OsuTextFlowContainer infoTextLeft; + private readonly LinkFlowContainer infoTextRight; private readonly FillFlowContainer scoreText, scoreNumberText; private readonly Container coverContainer, chartContainer, supporterTag; @@ -159,7 +162,7 @@ namespace osu.Game.Overlays.Profile ParagraphSpacing = 0.8f, LineSpacing = 0.2f }, - infoTextRight = new OsuTextFlowContainer(t => + infoTextRight = new LinkFlowContainer(t => { t.TextSize = 14; t.Font = @"Exo2.0-RegularItalic"; @@ -380,9 +383,9 @@ namespace osu.Game.Overlays.Profile tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation); infoTextRight.NewParagraph(); if (!string.IsNullOrEmpty(user.Twitter)) - tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter); - tryAddInfoRightLine(FontAwesome.fa_globe, user.Website); - tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype); + tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter, @"http://twitter.com/" + user.Twitter); + tryAddInfoRightLine(FontAwesome.fa_globe, user.Website, user.Website); + tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype, @"skype:" + user.Skype + @"?chat"); if (user.Statistics != null) { @@ -435,12 +438,12 @@ namespace osu.Game.Overlays.Profile Text = text }; - private void tryAddInfoRightLine(FontAwesome icon, string str) + private void tryAddInfoRightLine(FontAwesome icon, string str, string url = null) { if (string.IsNullOrEmpty(str)) return; infoTextRight.AddIcon(icon); - infoTextRight.AddText(" " + str); + infoTextRight.AddLink(" " + str, url); infoTextRight.NewLine(); } @@ -481,5 +484,32 @@ namespace osu.Game.Overlays.Profile badge.Texture = textures.Get($"Grades/{grade}"); } } + + private class LinkFlowContainer : OsuTextFlowContainer + { + public override bool HandleInput => true; + + public LinkFlowContainer(Action defaultCreationParameters = null) : base(defaultCreationParameters) + { + } + + protected override SpriteText CreateSpriteText() => new SpriteLink(); + + public void AddLink(string text, string url) => AddText(text, link => ((SpriteLink)link).Url = url); + + private class SpriteLink : SpriteText + { + public override bool HandleInput => Url != null; + + public string Url; + + protected override bool OnClick(InputState state) + { + Process.Start(Url); + return true; + } + } + + } } } From 80dc8887694a76b93b40739a85d274720ecd8b39 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 17 Jul 2017 21:11:54 +0200 Subject: [PATCH 04/31] address CI concerns --- osu.Game/Overlays/Profile/ProfileHeader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 60ba8a5fd6..c218275c27 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -18,6 +18,7 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Users; using System.Diagnostics; +using System.Globalization; namespace osu.Game.Overlays.Profile { @@ -395,7 +396,7 @@ namespace osu.Game.Overlays.Profile scoreText.Add(createScoreText("Ranked Score")); scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0"))); scoreText.Add(createScoreText("Accuracy")); - scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy.ToString("0.##")}%")); + scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy.ToString("0.##", CultureInfo.CurrentCulture)}%")); scoreText.Add(createScoreText("Play Count")); scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0"))); scoreText.Add(createScoreText("Total Score")); From 9c70d03a336d3dacb8998fd38beb66e226fab6d0 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 17 Jul 2017 21:12:50 +0200 Subject: [PATCH 05/31] replace SpriteText with OsuSpriteText --- osu.Game/Overlays/Profile/ProfileHeader.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index c218275c27..4abe991205 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -498,7 +498,7 @@ namespace osu.Game.Overlays.Profile public void AddLink(string text, string url) => AddText(text, link => ((SpriteLink)link).Url = url); - private class SpriteLink : SpriteText + private class SpriteLink : OsuSpriteText { public override bool HandleInput => Url != null; @@ -510,7 +510,6 @@ namespace osu.Game.Overlays.Profile return true; } } - } } } From ae58e181784d1d8a40cd8245376f64472c206e6d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 10:41:52 +0900 Subject: [PATCH 06/31] Reorder code based on depth (and avoid possible conflicts) --- osu.Game/OsuGame.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 13f49b75e6..4e99a44a07 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -175,11 +175,11 @@ namespace osu.Game LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); - LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); LoadComponentAsync(settings = new SettingsOverlay { Depth = -1 }, overlayContent.Add); + LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); LoadComponentAsync(musicController = new MusicController { - Depth = -2, + Depth = -3, Position = new Vector2(0, Toolbar.HEIGHT), Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -187,14 +187,14 @@ namespace osu.Game LoadComponentAsync(notificationManager = new NotificationManager { - Depth = -2, + Depth = -3, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }, overlayContent.Add); LoadComponentAsync(dialogOverlay = new DialogOverlay { - Depth = -4, + Depth = -5, }, overlayContent.Add); Logger.NewEntry += entry => @@ -221,7 +221,7 @@ namespace osu.Game LoadComponentAsync(Toolbar = new Toolbar { - Depth = -3, + Depth = -4, OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); }, }, overlayContent.Add); From 4229f933fe155e57f8da2346391c9264dee3db87 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 10:51:11 +0900 Subject: [PATCH 07/31] Rename link class, add hover colour --- osu.Game/Overlays/Profile/ProfileHeader.cs | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 4abe991205..b3bf2386c7 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -494,21 +494,41 @@ namespace osu.Game.Overlays.Profile { } - protected override SpriteText CreateSpriteText() => new SpriteLink(); + protected override SpriteText CreateSpriteText() => new LinkText(); - public void AddLink(string text, string url) => AddText(text, link => ((SpriteLink)link).Url = url); + public void AddLink(string text, string url) => AddText(text, link => ((LinkText)link).Url = url); - private class SpriteLink : OsuSpriteText + private class LinkText : OsuSpriteText { public override bool HandleInput => Url != null; public string Url; + private Color4 hoverColour; + + protected override bool OnHover(InputState state) + { + FadeColour(hoverColour, 500, EasingTypes.OutQuint); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + FadeColour(Color4.White, 500, EasingTypes.OutQuint); + base.OnHoverLost(state); + } + protected override bool OnClick(InputState state) { Process.Start(Url); return true; } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + hoverColour = colours.Yellow; + } } } } From 2eccb3822a1d26ab04bb85af15cb2b211e4fe0e5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 11:07:52 +0900 Subject: [PATCH 08/31] Make link text not suck --- osu.Game/Overlays/Profile/ProfileHeader.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index b3bf2386c7..7888b87ac4 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -379,13 +379,21 @@ namespace osu.Game.Overlays.Profile infoTextLeft.AddText(string.Join(", ", user.PlayStyle), boldItalic); } + string websiteWithoutProtcol = user.Website; + if (!string.IsNullOrEmpty(websiteWithoutProtcol)) + { + int protocolIndex = websiteWithoutProtcol.IndexOf("//", StringComparison.Ordinal); + if (protocolIndex >= 0) + websiteWithoutProtcol = websiteWithoutProtcol.Substring(protocolIndex + 2); + } + tryAddInfoRightLine(FontAwesome.fa_map_marker, user.Location); tryAddInfoRightLine(FontAwesome.fa_heart_o, user.Intrerests); tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation); infoTextRight.NewParagraph(); if (!string.IsNullOrEmpty(user.Twitter)) - tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter, @"http://twitter.com/" + user.Twitter); - tryAddInfoRightLine(FontAwesome.fa_globe, user.Website, user.Website); + tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}"); + tryAddInfoRightLine(FontAwesome.fa_globe, websiteWithoutProtcol, user.Website); tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype, @"skype:" + user.Skype + @"?chat"); if (user.Statistics != null) From 2c5019ff7c3f5becc059f1b81107d2c0dd7456f9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 19 Jul 2017 18:22:46 +0900 Subject: [PATCH 09/31] Forward action in saner way --- osu.Game/Overlays/Chat/ChatLine.cs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index 1756c640b0..c08e62428b 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -11,6 +12,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics.Effects; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Allocation; +using osu.Game.Users; namespace osu.Game.Overlays.Chat { @@ -62,7 +64,8 @@ namespace osu.Game.Overlays.Chat private const float message_padding = 200; private const float text_size = 20; - private UserProfileOverlay profileOverlay; + private Action loadProfile; + private Color4 customUsernameColour; public ChatLine(Message message) @@ -76,9 +79,10 @@ namespace osu.Game.Overlays.Chat } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, UserProfileOverlay profile) { customUsernameColour = colours.ChatBlue; + loadProfile = u => profile?.ShowUser(u); } protected override void LoadComplete() @@ -88,8 +92,6 @@ namespace osu.Game.Overlays.Chat bool hasBackground = !string.IsNullOrEmpty(Message.Sender.Colour); Drawable username = new OsuSpriteText { - Origin = Anchor.TopRight, - Anchor = Anchor.TopRight, Font = @"Exo2.0-BoldItalic", Text = $@"{Message.Sender.Username}" + (hasBackground ? "" : ":"), Colour = hasBackground ? customUsernameColour : username_colours[Message.UserId % username_colours.Length], @@ -133,7 +135,7 @@ namespace osu.Game.Overlays.Chat new Container { Size = new Vector2(message_padding, text_size), - Children = new[] + Children = new Drawable[] { new OsuSpriteText { @@ -150,8 +152,8 @@ namespace osu.Game.Overlays.Chat AutoSizeAxes = Axes.Both, Origin = Anchor.TopRight, Anchor = Anchor.TopRight, - Child = username - Action = () => profileOverlay?.ShowUser(Message.Sender), + Child = username, + Action = () => loadProfile(Message.Sender), }, } }, @@ -173,11 +175,5 @@ namespace osu.Game.Overlays.Chat } }; } - - [BackgroundDependencyLoader(permitNulls: true)] - private void load(UserProfileOverlay profileOverlay) - { - this.profileOverlay = profileOverlay; - } } } From d75e439f94c95b076e98c387c9c92ab13efee4b1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 20 Jul 2017 01:27:27 +0930 Subject: [PATCH 10/31] Fix Player crashing due to null BeatmapInfo (now unused). --- osu.Game/Screens/Play/Player.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 7bd310e168..4b04b3b2ea 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -35,8 +35,6 @@ namespace osu.Game.Screens.Play internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor; - public BeatmapInfo BeatmapInfo; - public Action RestartRequested; internal override bool AllowBeatmapRulesetChange => false; @@ -85,7 +83,7 @@ namespace osu.Game.Screens.Play { if (!Beatmap.Value.WithStoryboard) // we need to ensure the storyboard is loaded. - Beatmap.Value = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true); + Beatmap.Value = beatmaps.GetWorkingBeatmap(Beatmap.Value.BeatmapInfo, withStoryboard: true); if (Beatmap.Value.Beatmap == null) throw new InvalidOperationException("Beatmap was not loaded"); From b016103894ab3872815326942f9f8e2532a45023 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 20 Jul 2017 01:03:00 +0200 Subject: [PATCH 11/31] add link to user page --- osu.Game/Overlays/Profile/ProfileHeader.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 7888b87ac4..a636bd5a21 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -19,6 +19,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Users; using System.Diagnostics; using System.Globalization; +using osu.Framework.Graphics.Cursor; namespace osu.Game.Overlays.Profile { @@ -119,9 +120,10 @@ namespace osu.Game.Overlays.Profile } } }, - new OsuSpriteText + new LinkFlowContainer.LinkText { Text = user.Username, + Url = $@"https://osu.ppy.sh/users/{user.Id}", TextSize = 30, Font = @"Exo2.0-RegularItalic", Anchor = Anchor.BottomLeft, @@ -506,7 +508,7 @@ namespace osu.Game.Overlays.Profile public void AddLink(string text, string url) => AddText(text, link => ((LinkText)link).Url = url); - private class LinkText : OsuSpriteText + public class LinkText : OsuSpriteText { public override bool HandleInput => Url != null; From e0fb2563b590620d094a4daa98930a32c5b000f9 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 20 Jul 2017 01:08:26 +0200 Subject: [PATCH 12/31] remove using --- osu.Game/Overlays/Profile/ProfileHeader.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index a636bd5a21..21bfd5afd6 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -19,7 +19,6 @@ using osu.Game.Graphics.Sprites; using osu.Game.Users; using System.Diagnostics; using System.Globalization; -using osu.Framework.Graphics.Cursor; namespace osu.Game.Overlays.Profile { From fd518e2294823091f36a4f7dab3e567f492ae322 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 20 Jul 2017 01:57:46 +0200 Subject: [PATCH 13/31] Don't start a beatmap's track until the intro is done playing --- osu.Game/Screens/Menu/Intro.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 4ab157db05..aeb5282666 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -121,7 +121,9 @@ namespace osu.Game.Screens.Menu Scheduler.AddDelayed(delegate { - track.Start(); + // Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Manu. + if (menuMusic) + track.Start(); LoadComponentAsync(mainMenu = new MainMenu()); From d69470f2ae24619e343bfbe37e421504d76755dc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 09:22:39 +0900 Subject: [PATCH 14/31] Fix TestWorkingBeatmap broken by attempting to load storyboard --- osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 9 ++++++--- osu.Game/Database/DatabaseWorkingBeatmap.cs | 6 +++--- osu.Game/Screens/Play/Player.cs | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs index b45574b761..580e062aaf 100644 --- a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs @@ -10,7 +10,7 @@ namespace osu.Desktop.VisualTests.Beatmaps public class TestWorkingBeatmap : WorkingBeatmap { public TestWorkingBeatmap(Beatmap beatmap) - : base(beatmap.BeatmapInfo) + : base(beatmap.BeatmapInfo, true) { this.beatmap = beatmap; } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 0e8d8a9546..0362d06c66 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -22,14 +22,17 @@ namespace osu.Game.Beatmaps public readonly Bindable> Mods = new Bindable>(new Mod[] { }); - public readonly bool WithStoryboard; + /// + /// Denotes whether extras like storyboards have been loaded for this . + /// + public bool FullyLoaded { get; protected set; } - protected WorkingBeatmap(BeatmapInfo beatmapInfo, bool withStoryboard = false) + protected WorkingBeatmap(BeatmapInfo beatmapInfo, bool fullyLoaded = false) { BeatmapInfo = beatmapInfo; BeatmapSetInfo = beatmapInfo.BeatmapSet; Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo.Metadata; - WithStoryboard = withStoryboard; + FullyLoaded = fullyLoaded; Mods.ValueChanged += mods => applyRateAdjustments(); } diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index 2acae9c340..01a8509c3e 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -14,8 +14,8 @@ namespace osu.Game.Database { private readonly BeatmapDatabase database; - public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, bool withStoryboard = false) - : base(beatmapInfo, withStoryboard) + public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, bool fullyLoaded = false) + : base(beatmapInfo, fullyLoaded) { this.database = database; } @@ -37,7 +37,7 @@ namespace osu.Game.Database beatmap = decoder.Decode(stream); } - if (beatmap == null || !WithStoryboard || BeatmapSetInfo.StoryboardFile == null) + if (beatmap == null || !FullyLoaded || BeatmapSetInfo.StoryboardFile == null) return beatmap; using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile))) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 4b04b3b2ea..40f24a77c9 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -81,8 +81,8 @@ namespace osu.Game.Screens.Play try { - if (!Beatmap.Value.WithStoryboard) - // we need to ensure the storyboard is loaded. + if (!Beatmap.Value.FullyLoaded) + // we need to ensure extras like storyboards are loaded. Beatmap.Value = beatmaps.GetWorkingBeatmap(Beatmap.Value.BeatmapInfo, withStoryboard: true); if (Beatmap.Value.Beatmap == null) From 8d727b898f36cdc081fb27e2fe89b8dd09f80b45 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 09:23:11 +0900 Subject: [PATCH 15/31] Don't rely on BeatmapSetInfo being present --- osu.Game/Screens/Select/SongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index d28a84217b..ea012f45e4 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -189,7 +189,7 @@ namespace osu.Game.Screens.Select private void carouselBeatmapsLoaded() { - if (Beatmap.Value != null && !Beatmap.Value.BeatmapSetInfo.DeletePending) + if (Beatmap.Value != null && Beatmap.Value.BeatmapSetInfo?.DeletePending != false) carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false); else carousel.SelectNext(); From d6968ca09cf0d8137034768266da2ee5a6b7ff05 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 11:01:50 +0900 Subject: [PATCH 16/31] Remove FullyLoaded logic Always parse storyboards for now. Let's not optimise this until it is necessary. It was leading to weird threading problems due to the load call in Player's async load method. --- osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 8 +------- osu.Game/Database/BeatmapDatabase.cs | 2 +- osu.Game/Database/DatabaseWorkingBeatmap.cs | 6 +++--- osu.Game/Screens/Play/Player.cs | 6 +----- 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs index 580e062aaf..b45574b761 100644 --- a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs @@ -10,7 +10,7 @@ namespace osu.Desktop.VisualTests.Beatmaps public class TestWorkingBeatmap : WorkingBeatmap { public TestWorkingBeatmap(Beatmap beatmap) - : base(beatmap.BeatmapInfo, true) + : base(beatmap.BeatmapInfo) { this.beatmap = beatmap; } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 0362d06c66..4dd624c14e 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -22,17 +22,11 @@ namespace osu.Game.Beatmaps public readonly Bindable> Mods = new Bindable>(new Mod[] { }); - /// - /// Denotes whether extras like storyboards have been loaded for this . - /// - public bool FullyLoaded { get; protected set; } - - protected WorkingBeatmap(BeatmapInfo beatmapInfo, bool fullyLoaded = false) + protected WorkingBeatmap(BeatmapInfo beatmapInfo) { BeatmapInfo = beatmapInfo; BeatmapSetInfo = beatmapInfo.BeatmapSet; Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo.Metadata; - FullyLoaded = fullyLoaded; Mods.ValueChanged += mods => applyRateAdjustments(); } diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index b31b71a728..84a7096da4 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -291,7 +291,7 @@ namespace osu.Game.Database if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; - WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard); + WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo); previous?.TransferTo(working); diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index 01a8509c3e..25944faa42 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -14,8 +14,8 @@ namespace osu.Game.Database { private readonly BeatmapDatabase database; - public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, bool fullyLoaded = false) - : base(beatmapInfo, fullyLoaded) + public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo) + : base(beatmapInfo) { this.database = database; } @@ -37,7 +37,7 @@ namespace osu.Game.Database beatmap = decoder.Decode(stream); } - if (beatmap == null || !FullyLoaded || BeatmapSetInfo.StoryboardFile == null) + if (beatmap == null || BeatmapSetInfo.StoryboardFile == null) return beatmap; using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile))) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 40f24a77c9..1711ee027a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -70,7 +70,7 @@ namespace osu.Game.Screens.Play private bool loadedSuccessfully => HitRenderer?.Objects.Any() == true; [BackgroundDependencyLoader(permitNulls: true)] - private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, OsuGame osu) + private void load(AudioManager audio, OsuConfigManager config, OsuGame osu) { dimLevel = config.GetBindable(OsuSetting.DimLevel); mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); @@ -81,10 +81,6 @@ namespace osu.Game.Screens.Play try { - if (!Beatmap.Value.FullyLoaded) - // we need to ensure extras like storyboards are loaded. - Beatmap.Value = beatmaps.GetWorkingBeatmap(Beatmap.Value.BeatmapInfo, withStoryboard: true); - if (Beatmap.Value.Beatmap == null) throw new InvalidOperationException("Beatmap was not loaded"); From 15eb6954da6d41f0f451a9528af8e4be887f966e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 11:50:31 +0900 Subject: [PATCH 17/31] Fix hitting down and enter at song select causing a hard-crash Carousel was not aware of the disabled beatmap change state. Also it was being set too late (in an async load) so wasn't useful. It's now pre-emptively set in PlaySongSelect before loading Player. --- osu.Game/Screens/Select/BeatmapCarousel.cs | 4 ++++ osu.Game/Screens/Select/PlaySongSelect.cs | 1 + osu.Game/Screens/Select/SongSelect.cs | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index e135fefc6d..90b9808da5 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -25,6 +25,8 @@ namespace osu.Game.Screens.Select { public BeatmapInfo SelectedBeatmap => selectedPanel?.Beatmap; + public override bool HandleInput => AllowSelection; + public Action BeatmapsChanged; public IEnumerable Beatmaps @@ -228,6 +230,8 @@ namespace osu.Game.Screens.Select private ScheduledDelegate filterTask; + public bool AllowSelection = true; + public void Filter(FilterCriteria newCriteria = null, bool debounce = true) { if (newCriteria != null) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 51f570e901..e393caf931 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -105,6 +105,7 @@ namespace osu.Game.Screens.Select if (player != null) return; Beatmap.Value.Track.Looping = false; + Beatmap.Disabled = true; LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player)); } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ea012f45e4..0d0b15d91e 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -110,7 +110,7 @@ namespace osu.Game.Screens.Select Origin = Anchor.CentreRight, SelectionChanged = carouselSelectionChanged, BeatmapsChanged = carouselBeatmapsLoaded, - StartRequested = carouselRaisedStart + StartRequested = carouselRaisedStart, }); Add(FilterControl = new FilterControl { @@ -185,6 +185,9 @@ namespace osu.Game.Screens.Select carousel.Beatmaps = database.GetAllWithChildren(b => !b.DeletePending); Beatmap.ValueChanged += beatmap_ValueChanged; + + Beatmap.DisabledChanged += disabled => carousel.AllowSelection = !disabled; + carousel.AllowSelection = !Beatmap.Disabled; } private void carouselBeatmapsLoaded() From c13098118478568718f64d72df1b32a76d213392 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 14:05:42 +0900 Subject: [PATCH 18/31] Fix WorkingBeatmap being loaded twice when using MusicController at SongSelect --- osu.Game/Screens/Select/SongSelect.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ea012f45e4..4f6f1a5c76 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -221,11 +221,16 @@ namespace osu.Game.Screens.Select { Action performLoad = delegate { - bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID; + // We may be arriving here due to another component changing the bindable Beatmap. + // In these cases, the other component has already loaded the beatmap, so we don't need to do so again. + if (!beatmap.Equals(Beatmap.Value.BeatmapInfo)) + { + bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID; - Beatmap.Value = database.GetWorkingBeatmap(beatmap, Beatmap); + Beatmap.Value = database.GetWorkingBeatmap(beatmap, Beatmap); + ensurePlayingSelected(preview); + } - ensurePlayingSelected(preview); changeBackground(Beatmap.Value); }; From a59557f03926159ba379e8a77df19cdf892a9894 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 15:12:20 +0900 Subject: [PATCH 19/31] Fix selection not being reset correct when changing between rulesets Carousels filtered to results with no maps visible were not being handled correctly in a few different ways. This covers all those scenarios. --- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index e135fefc6d..d2984ec2ae 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -133,7 +133,7 @@ namespace osu.Game.Screens.Select public void SelectNext(int direction = 1, bool skipDifficulties = true) { - if (groups.Count == 0) + if (groups.Count == 0 || groups.All(g => g.State == BeatmapGroupState.Hidden)) { selectedGroup = null; selectedPanel = null; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ea012f45e4..15bdc08eea 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -229,6 +229,13 @@ namespace osu.Game.Screens.Select changeBackground(Beatmap.Value); }; + selectionChangedDebounce?.Cancel(); + + if (beatmap?.Equals(beatmapNoDebounce) == true) + return; + + beatmapNoDebounce = beatmap; + if (beatmap == null) { if (!Beatmap.IsDefault) @@ -236,18 +243,11 @@ namespace osu.Game.Screens.Select } else { - selectionChangedDebounce?.Cancel(); - - if (beatmap.Equals(beatmapNoDebounce)) - return; - if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID) sampleChangeDifficulty.Play(); else sampleChangeBeatmap.Play(); - beatmapNoDebounce = beatmap; - if (beatmap == Beatmap.Value.BeatmapInfo) performLoad(); else From 61c665f239b3ca57364954ae7e2213205838371a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 15:16:07 +0900 Subject: [PATCH 20/31] Add required null check --- osu.Game/Screens/Select/SongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4f6f1a5c76..e3e588c000 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -223,7 +223,7 @@ namespace osu.Game.Screens.Select { // We may be arriving here due to another component changing the bindable Beatmap. // In these cases, the other component has already loaded the beatmap, so we don't need to do so again. - if (!beatmap.Equals(Beatmap.Value.BeatmapInfo)) + if (beatmap?.Equals(Beatmap.Value.BeatmapInfo) != true) { bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID; From 4f102561827c17d98d7fc4a27a40e401f2a217cc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 15:34:44 +0900 Subject: [PATCH 21/31] Remove unnecessary count check --- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index d2984ec2ae..b5855fe0e0 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -133,7 +133,7 @@ namespace osu.Game.Screens.Select public void SelectNext(int direction = 1, bool skipDifficulties = true) { - if (groups.Count == 0 || groups.All(g => g.State == BeatmapGroupState.Hidden)) + if (groups.All(g => g.State == BeatmapGroupState.Hidden)) { selectedGroup = null; selectedPanel = null; From 67b95926c4b79ac727009f22d23b970cfb5ef142 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 16:45:44 +0900 Subject: [PATCH 22/31] Remove usage of SetExclusive Also immediately disposes WorkingBeatmaps on ValueChanged. --- osu-framework | 2 +- osu.Game/OsuGameBase.cs | 11 +++++++++++ osu.Game/Overlays/Music/PlaylistOverlay.cs | 2 +- osu.Game/Screens/Menu/Intro.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 2 +- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/osu-framework b/osu-framework index 6b44a9f807..a7edf9bb3b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 6b44a9f807fadcb3b3f044780d7e27d62ffe80ac +Subproject commit a7edf9bb3bae6908f316ba0ee9dacdbbb66e8c19 diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 939c4a4915..99b015dd79 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -133,9 +133,20 @@ namespace osu.Game Token = LocalConfig.Get(OsuSetting.Token) }); + Beatmap.ValueChanged += b => + { + // this disposal is done to stop the audio track. + // it may not be exactly what we want for cases beatmaps are reused, as it will + // trigger a fresh load of contained resources. + lastBeatmap?.Dispose(); + lastBeatmap = b; + }; + API.Register(this); } + private WorkingBeatmap lastBeatmap; + public void APIStateChanged(APIAccess api, APIState state) { switch (state) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 87c0afebf7..e936fa6209 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -158,7 +158,7 @@ namespace osu.Game.Overlays.Music Task.Run(() => { var track = beatmapBacking.Value.Track; - trackManager.SetExclusive(track); + trackManager.AddItem(track); track.Start(); }).ContinueWith(task => Schedule(task.ThrowIfFaulted), TaskContinuationOptions.OnlyOnFaulted); } diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index aeb5282666..0998a4e64c 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -106,7 +106,7 @@ namespace osu.Game.Screens.Menu Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); track = Beatmap.Value.Track; - trackManager.SetExclusive(track); + trackManager.AddItem(track); welcome = audio.Sample.Get(@"welcome"); seeya = audio.Sample.Get(@"seeya"); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 40f24a77c9..ea163bca3a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -120,7 +120,7 @@ namespace osu.Game.Screens.Play if (track != null) { - audio.Track.SetExclusive(track); + audio.Track.AddItem(track); adjustableSourceClock = track; } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ea012f45e4..7e50ab6e2b 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -358,7 +358,7 @@ namespace osu.Game.Screens.Select { Track track = Beatmap.Value.Track; - trackManager.SetExclusive(track); + trackManager.AddItem(track); if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime); track.Start(); From 3bdd4d7d02aa19162e941bbada7632878a6a7dc8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 17:46:23 +0900 Subject: [PATCH 23/31] Centralise TrackManager.AddItem logic to avoid duplicate adds --- osu.Game/OsuGameBase.cs | 15 +++++++++++---- osu.Game/Overlays/Music/PlaylistOverlay.cs | 13 +------------ osu.Game/Screens/Menu/Intro.cs | 3 --- osu.Game/Screens/Play/Player.cs | 3 --- osu.Game/Screens/Select/SongSelect.cs | 11 +++++------ 5 files changed, 17 insertions(+), 28 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 99b015dd79..7a2d91d733 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -135,10 +135,17 @@ namespace osu.Game Beatmap.ValueChanged += b => { - // this disposal is done to stop the audio track. - // it may not be exactly what we want for cases beatmaps are reused, as it will - // trigger a fresh load of contained resources. - lastBeatmap?.Dispose(); + // compare to last baetmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) + if (lastBeatmap?.Track != b.Track) + { + // this disposal is done to stop the audio track. + // it may not be exactly what we want for cases beatmaps are reused, as it will + // trigger a fresh load of contained resources. + lastBeatmap?.Dispose(); + + Audio.Track.AddItem(b.Track); + } + lastBeatmap = b; }; diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index e936fa6209..1e4c3c5ff6 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -3,9 +3,7 @@ using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; using osu.Framework.Allocation; -using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -15,7 +13,6 @@ using osu.Game.Database; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; -using osu.Framework.Extensions; using osu.Framework.Input; using osu.Framework.Graphics.Shapes; @@ -30,7 +27,6 @@ namespace osu.Game.Overlays.Music private FilterControl filter; private PlaylistList list; - private TrackManager trackManager; private BeatmapDatabase beatmaps; private readonly Bindable beatmapBacking = new Bindable(); @@ -43,7 +39,6 @@ namespace osu.Game.Overlays.Music { this.inputManager = inputManager; this.beatmaps = beatmaps; - trackManager = game.Audio.Track; Children = new Drawable[] { @@ -154,13 +149,7 @@ namespace osu.Game.Overlays.Music private void playSpecified(BeatmapInfo info) { beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking); - - Task.Run(() => - { - var track = beatmapBacking.Value.Track; - trackManager.AddItem(track); - track.Start(); - }).ContinueWith(task => Schedule(task.ThrowIfFaulted), TaskContinuationOptions.OnlyOnFaulted); + beatmapBacking.Value.Track.Start(); } } diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 0998a4e64c..6e42a1bae9 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -72,8 +72,6 @@ namespace osu.Game.Screens.Menu menuVoice = config.GetBindable(OsuSetting.MenuVoice); menuMusic = config.GetBindable(OsuSetting.MenuMusic); - var trackManager = audio.Track; - BeatmapSetInfo setInfo = null; if (!menuMusic) @@ -106,7 +104,6 @@ namespace osu.Game.Screens.Menu Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]); track = Beatmap.Value.Track; - trackManager.AddItem(track); welcome = audio.Sample.Get(@"welcome"); seeya = audio.Sample.Get(@"seeya"); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ea163bca3a..4bbb47d419 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -119,10 +119,7 @@ namespace osu.Game.Screens.Play Track track = Beatmap.Value.Track; if (track != null) - { - audio.Track.AddItem(track); adjustableSourceClock = track; - } adjustableSourceClock = (IAdjustableClock)track ?? new StopwatchClock(); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 7e50ab6e2b..40cf586c06 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -32,7 +32,6 @@ namespace osu.Game.Screens.Select protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(); private readonly BeatmapCarousel carousel; - private TrackManager trackManager; private DialogOverlay dialogOverlay; private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245); @@ -174,7 +173,6 @@ namespace osu.Game.Screens.Select database.BeatmapSetAdded += onBeatmapSetAdded; database.BeatmapSetRemoved += onBeatmapSetRemoved; - trackManager = audio.Track; dialogOverlay = dialog; sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty"); @@ -358,10 +356,11 @@ namespace osu.Game.Screens.Select { Track track = Beatmap.Value.Track; - trackManager.AddItem(track); - - if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime); - track.Start(); + if (!track.IsRunning) + { + if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime); + track.Start(); + } } private void removeBeatmapSet(BeatmapSetInfo beatmapSet) From 577740d32985fec1c3d44c37d6d16cc420723a59 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 18:07:51 +0900 Subject: [PATCH 24/31] Fix footer button light fading incorrectly Logic was reliant on HoverLost coming before Hover events, which has since changed. Was also able to tidy this code up a bit in the process. --- osu.Game/Screens/Select/Footer.cs | 39 +++++++++++++------------------ 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index ddb808c5e4..33252f78f8 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Linq; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; @@ -31,7 +32,7 @@ namespace osu.Game.Screens.Select public Action OnBack; public Action OnStart; - private readonly FillFlowContainer buttons; + private readonly FillFlowContainer buttons; public OsuLogo StartButton; @@ -43,29 +44,21 @@ namespace osu.Game.Screens.Select /// Higher depth to be put on the left, and lower to be put on the right. /// Notice this is different to ! /// - public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) + public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) => buttons.Add(new FooterButton { - var button = new FooterButton - { - Text = text, - Height = play_song_select_button_height, - Width = play_song_select_button_width, - Depth = depth, - SelectedColour = colour, - DeselectedColour = colour.Opacity(0.5f), - Hotkey = hotkey, - }; + Text = text, + Height = play_song_select_button_height, + Width = play_song_select_button_width, + Depth = depth, + SelectedColour = colour, + DeselectedColour = colour.Opacity(0.5f), + Hotkey = hotkey, + Hovered = updateModeLight, + HoverLost = updateModeLight, + Action = action, + }); - button.Hovered = () => updateModeLight(button); - button.HoverLost = () => updateModeLight(); - button.Action = action; - buttons.Add(button); - } - - private void updateModeLight(FooterButton button = null) - { - modeLight.FadeColour(button?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint); - } + private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint); public Footer() { @@ -111,7 +104,7 @@ namespace osu.Game.Screens.Select Spacing = new Vector2(padding, 0), Children = new Drawable[] { - buttons = new FillFlowContainer + buttons = new FillFlowContainer { Direction = FillDirection.Horizontal, Spacing = new Vector2(0.2f, 0), From 6e0b7b81f8de1ae95b6d78ddde7afc665c232bb6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 19:10:20 +0900 Subject: [PATCH 25/31] Switch to correct ruleset when changing beatmap This is only really noticeable when using the MusicController to change tracks while at song select. --- osu.Game/Screens/Select/SongSelect.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 15bdc08eea..4ecbd91b11 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -243,6 +243,8 @@ namespace osu.Game.Screens.Select } else { + ruleset.Value = beatmap.Ruleset; + if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID) sampleChangeDifficulty.Play(); else From b25188895b168bcaa1eb19494559c388eab9fd2d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 19:32:17 +0900 Subject: [PATCH 26/31] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index a7edf9bb3b..2d2e2fe698 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a7edf9bb3bae6908f316ba0ee9dacdbbb66e8c19 +Subproject commit 2d2e2fe698ab32d80d5e856f52c8c398ceb35540 From 22f3e97241e88310c4a9a760088bfd6a77380bf8 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 20 Jul 2017 17:15:39 +0200 Subject: [PATCH 27/31] Small optimization to the main menu intro seeking. --- osu.Game/Screens/Menu/MainMenu.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index df9b304a47..def9c13c10 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -94,9 +94,7 @@ namespace osu.Game.Screens.Menu { if (!track.IsRunning) { - track.Seek(metadata.PreviewTime); - if (metadata.PreviewTime == -1) - track.Seek(track.Length * 0.4f); + track.Seek(metadata.PreviewTime != -1 ? metadata.PreviewTime : 0.4f * track.Length); track.Start(); } } From fb2f1224b315a77adce9b2270f33a636601965e9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Jul 2017 05:58:58 +0900 Subject: [PATCH 28/31] Fix carousel filter debounce causing a race condition Clicking a ruleset button on toolbar would schedule a delayed filter of carousel, which could in turn trigger a beatmap change after pushing a Player. This resolves that by forcing any pending operations to complete. --- osu.Game/Screens/Select/BeatmapCarousel.cs | 4 ++++ osu.Game/Screens/Select/SongSelect.cs | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 0dc5d8074d..96069d8d18 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -232,6 +232,8 @@ namespace osu.Game.Screens.Select public bool AllowSelection = true; + public bool PendingFilter => filterTask?.Completed == false; + public void Filter(FilterCriteria newCriteria = null, bool debounce = true) { if (newCriteria != null) @@ -263,6 +265,8 @@ namespace osu.Game.Screens.Select }; filterTask?.Cancel(); + filterTask = null; + if (debounce) filterTask = Scheduler.AddDelayed(perform, 250); else diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 9e1d230124..59bbb3b3e9 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -198,13 +198,16 @@ namespace osu.Game.Screens.Select private void carouselRaisedStart() { - var pendingSelection = selectionChangedDebounce; - selectionChangedDebounce = null; + if (carousel.PendingFilter) + // if we have a pending filter operation, we want to run it now. + // it could change selection (ie. if the ruleset has been changed). + carousel.Filter(null, false); - if (pendingSelection?.Completed == false) + if (selectionChangedDebounce?.Completed == false) { - pendingSelection.RunTask(); - pendingSelection.Cancel(); // cancel the already scheduled task. + selectionChangedDebounce.RunTask(); + selectionChangedDebounce.Cancel(); // cancel the already scheduled task. + selectionChangedDebounce = null; } OnSelected(); From b4dddc98eeedb09a232f36eb84015d06e3684bd0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Jul 2017 06:15:44 +0900 Subject: [PATCH 29/31] Fix selection changing on entering song select Conditional was backwards, easy fix. --- osu.Game/Screens/Select/SongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 9e1d230124..90057cf638 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -190,7 +190,7 @@ namespace osu.Game.Screens.Select private void carouselBeatmapsLoaded() { - if (Beatmap.Value != null && Beatmap.Value.BeatmapSetInfo?.DeletePending != false) + if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false) carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false); else carousel.SelectNext(); From f7b64a458a33fa862fe63b7763acf213f840bddf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Jul 2017 10:08:39 +0900 Subject: [PATCH 30/31] Fix incorrect end time calculation in SongProgressGraph --- osu.Game/Screens/Play/SongProgressGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SongProgressGraph.cs b/osu.Game/Screens/Play/SongProgressGraph.cs index 9251ca33a4..541065e532 100644 --- a/osu.Game/Screens/Play/SongProgressGraph.cs +++ b/osu.Game/Screens/Play/SongProgressGraph.cs @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Play return; var firstHit = objects.First().StartTime; - var lastHit = (objects.Last() as IHasEndTime)?.EndTime ?? 0; + var lastHit = objects.Max(o => (o as IHasEndTime)?.EndTime ?? o.StartTime); if (lastHit == 0) lastHit = objects.Last().StartTime; From 12b6b80d5cd2a85dcca2d714d5b11685e828955d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Jul 2017 17:20:52 +0900 Subject: [PATCH 31/31] Make method to flush filter requests --- osu.Game/Screens/Select/BeatmapCarousel.cs | 6 +++++- osu.Game/Screens/Select/SongSelect.cs | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 96069d8d18..b696d637e6 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -232,7 +232,11 @@ namespace osu.Game.Screens.Select public bool AllowSelection = true; - public bool PendingFilter => filterTask?.Completed == false; + public void FlushPendingFilters() + { + if (filterTask?.Completed == false) + Filter(null, false); + } public void Filter(FilterCriteria newCriteria = null, bool debounce = true) { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 59bbb3b3e9..2b2ba83043 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -198,10 +198,9 @@ namespace osu.Game.Screens.Select private void carouselRaisedStart() { - if (carousel.PendingFilter) - // if we have a pending filter operation, we want to run it now. - // it could change selection (ie. if the ruleset has been changed). - carousel.Filter(null, false); + // if we have a pending filter operation, we want to run it now. + // it could change selection (ie. if the ruleset has been changed). + carousel.FlushPendingFilters(); if (selectionChangedDebounce?.Completed == false) {