From 689866f5dd4ae6a494112296f024e414ca41cd7e Mon Sep 17 00:00:00 2001 From: Jorolf Date: Mon, 17 Jul 2017 20:25:57 +0200 Subject: [PATCH 01/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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/15] 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 b016103894ab3872815326942f9f8e2532a45023 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 20 Jul 2017 01:03:00 +0200 Subject: [PATCH 10/15] 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 11/15] 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 67b95926c4b79ac727009f22d23b970cfb5ef142 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 16:45:44 +0900 Subject: [PATCH 12/15] 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 13/15] 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 14/15] 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 b25188895b168bcaa1eb19494559c388eab9fd2d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Jul 2017 19:32:17 +0900 Subject: [PATCH 15/15] 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