From ab32e962ca90a4a73ce88e7ec9f90f0dd4de7ff8 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 28 May 2017 00:37:55 -0300 Subject: [PATCH 01/89] Make BeatmapOnlineInfo and BeatmapSetOnlineInfo separate classes, -OnlineWorkingBeatmap --- .../Tests/TestCaseDirect.cs | 56 +++++++++---------- osu.Game/Database/BeatmapMetadata.cs | 6 +- osu.Game/Database/BeatmapOnlineInfo.cs | 20 ++----- osu.Game/Database/BeatmapSetInfo.cs | 3 + osu.Game/Database/BeatmapSetOnlineInfo.cs | 38 +++++++++++++ osu.Game/Database/OnlineWorkingBeatmap.cs | 37 ------------ osu.Game/Overlays/Direct/DirectGridPanel.cs | 4 +- osu.Game/Overlays/Direct/DirectListPanel.cs | 4 +- osu.Game/Overlays/Direct/DirectPanel.cs | 20 ++++++- osu.Game/osu.Game.csproj | 2 +- 10 files changed, 102 insertions(+), 88 deletions(-) create mode 100644 osu.Game/Database/BeatmapSetOnlineInfo.cs delete mode 100644 osu.Game/Database/OnlineWorkingBeatmap.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index 4cda14559f..9315e75254 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -48,6 +48,13 @@ namespace osu.Desktop.VisualTests.Tests Author = @"RLC", Source = @"", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, + Preview = @"https://b.ppy.sh/preview/578332.mp3", + PlayCount = 97, + FavouriteCount = 72, + }, Beatmaps = new List { new BeatmapInfo @@ -55,13 +62,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 5.35f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, - Preview = @"https://b.ppy.sh/preview/578332.mp3", - PlayCount = 97, - FavouriteCount = 72, - }, }, }, }, @@ -74,6 +74,13 @@ namespace osu.Desktop.VisualTests.Tests Author = @"Sotarks", Source = @"ぎんぎつね", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, + Preview = @"https//b.ppy.sh/preview/599627.mp3", + PlayCount = 3082, + FavouriteCount = 14, + }, Beatmaps = new List { new BeatmapInfo @@ -81,13 +88,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 5.81f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, - Preview = @"https//b.ppy.sh/preview/599627.mp3", - PlayCount = 3082, - FavouriteCount = 14, - }, }, }, }, @@ -100,6 +100,13 @@ namespace osu.Desktop.VisualTests.Tests Author = @"Cerulean Veyron", Source = @"", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, + Preview = @"https//b.ppy.sh/preview/513268.mp3", + PlayCount = 2762, + FavouriteCount = 15, + }, Beatmaps = new List { new BeatmapInfo @@ -107,13 +114,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 0.9f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, - Preview = @"https//b.ppy.sh/preview/513268.mp3", - PlayCount = 2762, - FavouriteCount = 15, - }, }, new BeatmapInfo { @@ -141,6 +141,13 @@ namespace osu.Desktop.VisualTests.Tests Author = @"[Kamiya]", Source = @"小林さんちのメイドラゴン", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, + Preview = @"https//b.ppy.sh/preview/586841.mp3", + PlayCount = 62317, + FavouriteCount = 161, + }, Beatmaps = new List { new BeatmapInfo @@ -148,13 +155,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 1.26f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, - Preview = @"https//b.ppy.sh/preview/586841.mp3", - PlayCount = 62317, - FavouriteCount = 161, - }, }, new BeatmapInfo { diff --git a/osu.Game/Database/BeatmapMetadata.cs b/osu.Game/Database/BeatmapMetadata.cs index 04700b3caa..a038b9cd19 100644 --- a/osu.Game/Database/BeatmapMetadata.cs +++ b/osu.Game/Database/BeatmapMetadata.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Linq; +using Newtonsoft.Json; using SQLite.Net.Attributes; namespace osu.Game.Database @@ -17,7 +18,10 @@ namespace osu.Game.Database public string TitleUnicode { get; set; } public string Artist { get; set; } public string ArtistUnicode { get; set; } + + [JsonProperty(@"creator")] public string Author { get; set; } + public string Source { get; set; } public string Tags { get; set; } public int PreviewTime { get; set; } @@ -35,4 +39,4 @@ namespace osu.Game.Database Tags }.Where(s => !string.IsNullOrEmpty(s)).ToArray(); } -} \ No newline at end of file +} diff --git a/osu.Game/Database/BeatmapOnlineInfo.cs b/osu.Game/Database/BeatmapOnlineInfo.cs index bcb2ef16ac..7740545d6e 100644 --- a/osu.Game/Database/BeatmapOnlineInfo.cs +++ b/osu.Game/Database/BeatmapOnlineInfo.cs @@ -11,28 +11,16 @@ namespace osu.Game.Database /// public class BeatmapOnlineInfo { - /// - /// The different sizes of cover art for this beatmap: cover, cover@2x, card, card@2x, list, list@2x. - /// - [JsonProperty(@"covers")] - public IEnumerable Covers { get; set; } - - /// - /// A small sample clip of this beatmap's song. - /// - [JsonProperty(@"previewUrl")] - public string Preview { get; set; } - /// /// The amount of plays this beatmap has. /// - [JsonProperty(@"play_count")] + [JsonProperty(@"playcount")] public int PlayCount { get; set; } /// - /// The amount of people who have favourited this map. + /// The amount of passes this beatmap has. /// - [JsonProperty(@"favourite_count")] - public int FavouriteCount { get; set; } + [JsonProperty(@"passcount")] + public int PassCount { get; set; } } } diff --git a/osu.Game/Database/BeatmapSetInfo.cs b/osu.Game/Database/BeatmapSetInfo.cs index 0875d3c01f..cf983d18d7 100644 --- a/osu.Game/Database/BeatmapSetInfo.cs +++ b/osu.Game/Database/BeatmapSetInfo.cs @@ -24,6 +24,9 @@ namespace osu.Game.Database [OneToMany(CascadeOperations = CascadeOperation.All)] public List Beatmaps { get; set; } + [Ignore] + public BeatmapSetOnlineInfo OnlineInfo { get; set; } + public double MaxStarDifficulty => Beatmaps.Max(b => b.StarDifficulty); [Indexed] diff --git a/osu.Game/Database/BeatmapSetOnlineInfo.cs b/osu.Game/Database/BeatmapSetOnlineInfo.cs new file mode 100644 index 0000000000..b1807868ad --- /dev/null +++ b/osu.Game/Database/BeatmapSetOnlineInfo.cs @@ -0,0 +1,38 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace osu.Game.Database +{ + /// + /// Beatmap set info retrieved for previewing locally without having the set downloaded. + /// + public class BeatmapSetOnlineInfo + { + /// + /// The different sizes of cover art for this beatmap: cover, cover@2x, card, card@2x, list, list@2x. + /// + [JsonProperty(@"covers")] + public IEnumerable Covers { get; set; } + + /// + /// A small sample clip of this beatmap's song. + /// + [JsonProperty(@"previewUrl")] + public string Preview { get; set; } + + /// + /// The amount of plays this set has. + /// + [JsonProperty(@"play_count")] + public int PlayCount { get; set; } + + /// + /// The amount of people who have favourited this map. + /// + [JsonProperty(@"favourite_count")] + public int FavouriteCount { get; set; } + } +} diff --git a/osu.Game/Database/OnlineWorkingBeatmap.cs b/osu.Game/Database/OnlineWorkingBeatmap.cs deleted file mode 100644 index 1465c59434..0000000000 --- a/osu.Game/Database/OnlineWorkingBeatmap.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System.Linq; -using osu.Framework.Audio.Track; -using osu.Framework.Graphics.Textures; -using osu.Game.Beatmaps; - -namespace osu.Game.Database -{ - internal class OnlineWorkingBeatmap : WorkingBeatmap - { - private readonly TextureStore textures; - private readonly TrackManager tracks; - - public OnlineWorkingBeatmap(BeatmapInfo beatmapInfo, TextureStore textures, TrackManager tracks) : base(beatmapInfo) - { - this.textures = textures; - this.tracks = tracks; - } - - protected override Beatmap GetBeatmap() - { - return new Beatmap(); - } - - protected override Texture GetBackground() - { - return textures.Get(BeatmapInfo.OnlineInfo.Covers.FirstOrDefault()); - } - - protected override Track GetTrack() - { - return tracks.Get(BeatmapInfo.OnlineInfo.Preview); - } - } -} diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 4be68157d7..1301d961f3 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -180,11 +180,11 @@ namespace osu.Game.Overlays.Direct Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding }, Children = new[] { - new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0) + new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0) { Margin = new MarginPadding { Right = 1 }, }, - new Statistic(FontAwesome.fa_heart, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.FavouriteCount ?? 0), + new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0), }, }, }; diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index 48636a5228..aae906a644 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -104,11 +104,11 @@ namespace osu.Game.Overlays.Direct Margin = new MarginPadding { Right = height - vertical_padding * 2 + vertical_padding }, Children = new Drawable[] { - new Statistic(FontAwesome.fa_play_circle, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.PlayCount ?? 0) + new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0) { Margin = new MarginPadding { Right = 1 }, }, - new Statistic(FontAwesome.fa_heart, SetInfo.Beatmaps.FirstOrDefault()?.OnlineInfo.FavouriteCount ?? 0), + new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0), new FillFlowContainer { Anchor = Anchor.TopRight, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 8a56cf392e..61cdbf1b4c 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using OpenTK; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -36,7 +37,7 @@ namespace osu.Game.Overlays.Direct protected Drawable GetBackground(TextureStore textures) { - return new AsyncLoadWrapper(new BeatmapBackgroundSprite(new OnlineWorkingBeatmap(SetInfo.Beatmaps.FirstOrDefault(), textures, null)) + return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo) { FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), @@ -84,5 +85,22 @@ namespace osu.Game.Overlays.Direct Value = value; } } + + private class BeatmapSetBackgroundSprite : Sprite + { + private readonly BeatmapSetInfo set; + + public BeatmapSetBackgroundSprite(BeatmapSetInfo set) + { + this.set = set; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + if (set.OnlineInfo?.Covers.FirstOrDefault() != null) + Texture = textures.Get(set.OnlineInfo.Covers.First()); + } + } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 25b692151f..0481044c3c 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -445,11 +445,11 @@ - + From 8745948a01ceb49d34af56f754f6ea72d05e0f08 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 28 May 2017 02:26:25 -0300 Subject: [PATCH 02/89] Basic searching in osu!direct, move BeatmapSetOnlineInfo covers into their own class --- .../Tests/TestCaseDirect.cs | 8 +- osu.Game/Database/BeatmapSetOnlineInfo.cs | 22 ++++- .../API/Requests/GetBeatmapSetsRequest.cs | 86 +++++++++++++++++++ osu.Game/Overlays/Direct/DirectPanel.cs | 4 +- osu.Game/Overlays/Direct/FilterControl.cs | 2 + osu.Game/Overlays/DirectOverlay.cs | 36 +++++++- osu.Game/osu.Game.csproj | 1 + 7 files changed, 150 insertions(+), 9 deletions(-) create mode 100644 osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index 9315e75254..0531ab0aaa 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -50,7 +50,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, + Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, Preview = @"https://b.ppy.sh/preview/578332.mp3", PlayCount = 97, FavouriteCount = 72, @@ -76,7 +76,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, + Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, Preview = @"https//b.ppy.sh/preview/599627.mp3", PlayCount = 3082, FavouriteCount = 14, @@ -102,7 +102,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, + Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, Preview = @"https//b.ppy.sh/preview/513268.mp3", PlayCount = 2762, FavouriteCount = 15, @@ -143,7 +143,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapSetOnlineInfo { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, + Covers = new BeatmapSetOnlineCovers { Card = @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, Preview = @"https//b.ppy.sh/preview/586841.mp3", PlayCount = 62317, FavouriteCount = 161, diff --git a/osu.Game/Database/BeatmapSetOnlineInfo.cs b/osu.Game/Database/BeatmapSetOnlineInfo.cs index b1807868ad..87859bf761 100644 --- a/osu.Game/Database/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Database/BeatmapSetOnlineInfo.cs @@ -12,10 +12,10 @@ namespace osu.Game.Database public class BeatmapSetOnlineInfo { /// - /// The different sizes of cover art for this beatmap: cover, cover@2x, card, card@2x, list, list@2x. + /// The different sizes of cover art for this beatmap. /// [JsonProperty(@"covers")] - public IEnumerable Covers { get; set; } + public BeatmapSetOnlineCovers Covers { get; set; } /// /// A small sample clip of this beatmap's song. @@ -35,4 +35,22 @@ namespace osu.Game.Database [JsonProperty(@"favourite_count")] public int FavouriteCount { get; set; } } + + public class BeatmapSetOnlineCovers + { + public string Cover { get; set; } + + [JsonProperty(@"cover@2x")] + public string Cover2x { get; set; } + + public string Card { get; set; } + + [JsonProperty(@"card@2x")] + public string Card2x { get; set; } + + public string List { get; set; } + + [JsonProperty(@"list@2x")] + public string List2x { get; set; } + } } diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs new file mode 100644 index 0000000000..5bdf3062cf --- /dev/null +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -0,0 +1,86 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json; +using osu.Game.Database; + +namespace osu.Game.Online.API.Requests +{ + public class GetBeatmapSetsRequest : APIRequest> + { + private readonly string query; + + public GetBeatmapSetsRequest(string query) + { + this.query = System.Uri.EscapeDataString(query); + } + + protected override string Target => $@"beatmapsets/search?q={query}"; + } + + public class GetBeatmapSetsResponse : BeatmapMetadata + { + [JsonProperty(@"covers")] + private BeatmapSetOnlineCovers covers { get; set; } + + [JsonProperty(@"previewUrl")] + private string preview { get; set; } + + [JsonProperty(@"play_count")] + private int playCount { get; set; } + + [JsonProperty(@"favourite_count")] + private int favouriteCount { get; set; } + + [JsonProperty(@"beatmaps")] + private IEnumerable beatmaps { get; set; } + + public BeatmapSetInfo ToSetInfo(RulesetDatabase rulesets) + { + return new BeatmapSetInfo + { + Metadata = this, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = covers, + Preview = preview, + PlayCount = playCount, + FavouriteCount = favouriteCount, + }, + Beatmaps = beatmaps.Select(b => b.ToBeatmap(rulesets)).ToList(), + }; + } + + private class GetBeatmapSetsBeatmapResponse : BeatmapMetadata + { + [JsonProperty(@"playcount")] + private int playCount { get; set; } + + [JsonProperty(@"passcount")] + private int passCount { get; set; } + + [JsonProperty(@"mode_int")] + private int ruleset { get; set; } + + [JsonProperty(@"difficulty_rating")] + private double starDifficulty { get; set; } + + public BeatmapInfo ToBeatmap(RulesetDatabase rulesets) + { + return new BeatmapInfo + { + Metadata = this, + Ruleset = rulesets.GetRuleset(ruleset), + StarDifficulty = starDifficulty, + OnlineInfo = new BeatmapOnlineInfo + { + PlayCount = playCount, + PassCount = passCount, + }, + }; + } + } + } +} diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 61cdbf1b4c..cf969df303 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -98,8 +98,8 @@ namespace osu.Game.Overlays.Direct [BackgroundDependencyLoader] private void load(TextureStore textures) { - if (set.OnlineInfo?.Covers.FirstOrDefault() != null) - Texture = textures.Get(set.OnlineInfo.Covers.First()); + if (set.OnlineInfo?.Covers?.Card != null) + Texture = textures.Get(set.OnlineInfo.Covers.Card); } } } diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 735e14b8c1..db2adbb462 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -129,6 +129,8 @@ namespace osu.Game.Overlays.Direct protected override Color4 BackgroundUnfocused => backgroundColour; protected override Color4 BackgroundFocused => backgroundColour; + protected override bool AllowCommit => true; + private Color4 backgroundColour; [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 0930c825b6..9dab21e428 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -13,6 +13,8 @@ using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; using osu.Game.Overlays.Direct; using Container = osu.Framework.Graphics.Containers.Container; @@ -24,6 +26,9 @@ namespace osu.Game.Overlays public static readonly int WIDTH_PADDING = 80; private const float panel_padding = 10f; + private APIAccess api; + private RulesetDatabase rulesets; + private readonly FilterControl filter; private readonly FillFlowContainer resultCountsContainer; private readonly OsuSpriteText resultCountsText; @@ -38,6 +43,17 @@ namespace osu.Game.Overlays if (beatmapSets?.Equals(value) ?? false) return; beatmapSets = value; + if (BeatmapSets == null) + { + foreach (var p in panels.Children) + { + p.FadeOut(200); + p.Expire(); + } + + return; + } + recreatePanels(filter.DisplayStyle.Value); } } @@ -155,14 +171,17 @@ namespace osu.Game.Overlays filter.Search.Exit = Hide; filter.Search.Current.ValueChanged += text => { if (text != string.Empty) header.Tabs.Current.Value = DirectTab.Search; }; + filter.Search.OnCommit = (sender, text) => updateSets(); filter.DisplayStyle.ValueChanged += recreatePanels; updateResultCounts(); } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, APIAccess api, RulesetDatabase rulesets) { + this.api = api; + this.rulesets = rulesets; resultCountsContainer.Colour = colours.Yellow; } @@ -187,6 +206,21 @@ namespace osu.Game.Overlays panels.Children = BeatmapSets.Select(b => displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)new DirectGridPanel(b) { Width = 400 } : new DirectListPanel(b)); } + private GetBeatmapSetsRequest getSetsRequest; + private void updateSets() + { + if (!IsLoaded) return; + + BeatmapSets = null; + getSetsRequest?.Cancel(); + + if (api == null || filter.Search.Text == string.Empty) return; + + getSetsRequest = new GetBeatmapSetsRequest(filter.Search.Text); + getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); + api.Queue(getSetsRequest); + } + protected override bool OnFocus(InputState state) { filter.Search.TriggerFocus(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0481044c3c..092e1c0509 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -450,6 +450,7 @@ + From 95cfce29509a25045417df9b4b0a93fa86eefd5d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sun, 28 May 2017 02:43:37 -0300 Subject: [PATCH 03/89] Rank status filtering --- osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs | 6 ++++-- osu.Game/Overlays/DirectOverlay.cs | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs index 5bdf3062cf..ce5c9f0939 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -11,13 +11,15 @@ namespace osu.Game.Online.API.Requests public class GetBeatmapSetsRequest : APIRequest> { private readonly string query; + private readonly RankStatus rankStatus; - public GetBeatmapSetsRequest(string query) + public GetBeatmapSetsRequest(string query, RankStatus rankStatus = RankStatus.Any) { this.query = System.Uri.EscapeDataString(query); + this.rankStatus = rankStatus; } - protected override string Target => $@"beatmapsets/search?q={query}"; + protected override string Target => $@"beatmapsets/search?q={query}&s={(int)rankStatus}"; } public class GetBeatmapSetsResponse : BeatmapMetadata diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 9dab21e428..41b58b7282 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -172,6 +172,7 @@ namespace osu.Game.Overlays filter.Search.Exit = Hide; filter.Search.Current.ValueChanged += text => { if (text != string.Empty) header.Tabs.Current.Value = DirectTab.Search; }; filter.Search.OnCommit = (sender, text) => updateSets(); + filter.RankStatusDropdown.Current.ValueChanged += rankStatus => updateSets(); filter.DisplayStyle.ValueChanged += recreatePanels; updateResultCounts(); @@ -216,7 +217,7 @@ namespace osu.Game.Overlays if (api == null || filter.Search.Text == string.Empty) return; - getSetsRequest = new GetBeatmapSetsRequest(filter.Search.Text); + getSetsRequest = new GetBeatmapSetsRequest(filter.Search.Text, filter.RankStatusDropdown.Current.Value); getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); api.Queue(getSetsRequest); } From 212b2c114206628c5030ff214bace924ad30a5bc Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 1 Jun 2017 04:45:46 -0300 Subject: [PATCH 04/89] Initial layout and animation --- osu-resources | 2 +- .../Tests/TestCaseMedalOverlay.cs | 28 +++ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/Overlays/MedalOverlay.cs | 212 ++++++++++++++++++ .../Overlays/MedalSplash/DrawableMedal.cs | 147 ++++++++++++ osu.Game/Users/Medal.cs | 11 + osu.Game/osu.Game.csproj | 3 + 7 files changed, 403 insertions(+), 1 deletion(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs create mode 100644 osu.Game/Overlays/MedalOverlay.cs create mode 100644 osu.Game/Overlays/MedalSplash/DrawableMedal.cs create mode 100644 osu.Game/Users/Medal.cs diff --git a/osu-resources b/osu-resources index 9f46a456dc..37e9e96d01 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit 9f46a456dc3a56dcbff09671a3f588b16a464106 +Subproject commit 37e9e96d011ba7faeb4a302e65fb7bdb4dc16690 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs new file mode 100644 index 0000000000..581675e66a --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Game.Overlays; +using osu.Game.Users; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseMedalOverlay : TestCase + { + public override string Description => @"medal get!"; + + public override void Reset() + { + base.Reset(); + + MedalOverlay overlay; + Add(overlay = new MedalOverlay(new Medal + { + Name = @"Animations", + Description = @"More complex than you think.", + })); + + AddStep(@"show", overlay.Show); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 5a532d7234..52e429efd8 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -224,6 +224,7 @@ + diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs new file mode 100644 index 0000000000..2d2a32fa4f --- /dev/null +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -0,0 +1,212 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Sprites; +using osu.Game.Users; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Overlays.MedalSplash; +using osu.Framework.Allocation; +using osu.Framework.Audio.Sample; +using osu.Framework.Audio; +using osu.Framework.Graphics.Textures; +using osu.Framework.Graphics.Transforms; +using osu.Framework.Input; +using OpenTK.Input; + +namespace osu.Game.Overlays +{ + public class MedalOverlay : FocusedOverlayContainer + { + public const float DISC_SIZE = 400; + + private const float border_width = 5; + + private readonly Box background; + private readonly FillFlowContainer backgroundStrip; + private readonly BackgroundStrip leftStrip, rightStrip; + private readonly CircularContainer disc; + private readonly Sprite innerSpin, outterSpin; + private readonly DrawableMedal drawableMedal; + + private SampleChannel getSample; + + protected override bool BlockPassThroughKeyboard => true; + + public MedalOverlay(Medal medal) + { + RelativeSizeAxes = Axes.Both; + Alpha = 0f; + + Children = new Drawable[] + { + background = new Box + { + Name = @"dim", + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(60), + }, + outterSpin = new Sprite + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(DISC_SIZE + 500), + Alpha = 0f, + }, + backgroundStrip = new FillFlowContainer + { + Name = @"background strip", + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Width = 0f, + Height = border_width, + Alpha = 0f, + Direction = FillDirection.Horizontal, + Children = new[] + { + leftStrip = new BackgroundStrip(0f, 1f), + rightStrip = new BackgroundStrip(1f, 0f), + }, + }, + disc = new CircularContainer + { + Name = @"content", + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Alpha = 0f, + Masking = true, + BorderColour = Color4.White, + BorderThickness = border_width, + Size = new Vector2(DISC_SIZE), + Scale = new Vector2(0.8f), + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"05262f"), + }, + new Triangles + { + RelativeSizeAxes = Axes.Both, + TriangleScale = 2, + ColourDark = OsuColour.FromHex(@"04222b"), + ColourLight = OsuColour.FromHex(@"052933"), + }, + innerSpin = new Sprite + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(1.05f), + Alpha = 0.25f, + }, + drawableMedal = new DrawableMedal(medal) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + }, + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, TextureStore textures, AudioManager audio) + { + getSample = audio.Sample.Get(@"MedalSplash/medal-get"); + innerSpin.Texture = outterSpin.Texture = textures.Get(@"MedalSplash/disc-spin"); + + disc.EdgeEffect = leftStrip.EdgeEffect = rightStrip.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Colour = colours.Blue.Opacity(0.5f), + Radius = 50, + }; + } + + protected override void PopIn() + { + base.PopIn(); + + FadeIn(200); + background.FlashColour(Color4.White.Opacity(0.25f), 400); + + double duration1 = 400; + double duration2 = 900; + double duration3 = 900; + double duration4 = 1000; + + getSample.Play(); + Delay(200, true); + + innerSpin.Transforms.Add(new TransformRotation + { + StartValue = 0, + EndValue = 359, + StartTime = Clock.TimeInfo.Current, + EndTime = Clock.TimeInfo.Current + 20000, + LoopCount = -1, + }); + + outterSpin.Transforms.Add(new TransformRotation + { + StartValue = 0, + EndValue = 359, + StartTime = Clock.TimeInfo.Current, + EndTime = Clock.TimeInfo.Current + 40000, + LoopCount = -1, + }); + + disc.FadeIn(duration1); + backgroundStrip.FadeIn(duration1); + backgroundStrip.ResizeWidthTo(1f, duration1 * 2, EasingTypes.OutQuint); + outterSpin.FadeTo(0.1f, duration1 * 2); + disc.ScaleTo(1f, duration1 * 2, EasingTypes.OutElastic); + + Delay(duration1 + 200, true); + drawableMedal.ChangeState(DrawableMedal.DisplayState.Icon, duration2); + + Delay(duration2, true); + drawableMedal.ChangeState(DrawableMedal.DisplayState.MedalUnlocked, duration3); + + Delay(duration3, true); + drawableMedal.ChangeState(DrawableMedal.DisplayState.Full, duration4); + } + + protected override void PopOut() + { + base.PopOut(); + + FadeOut(200); + } + + private class BackgroundStrip : Container + { + public BackgroundStrip(float start, float end) + { + RelativeSizeAxes = Axes.Both; + Width = 0.5f; + ColourInfo = ColourInfo.GradientHorizontal(Color4.White.Opacity(start), Color4.White.Opacity(end)); + Masking = true; + + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + } + }; + } + } + } +} diff --git a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs new file mode 100644 index 0000000000..c85adc4f2a --- /dev/null +++ b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs @@ -0,0 +1,147 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Sprites; +using osu.Game.Users; + +namespace osu.Game.Overlays.MedalSplash +{ + public class DrawableMedal : Container + { + private const float scale_when_unlocked = 0.76f; + private const float scale_when_full = 0.6f; + + private readonly Container medal; + private readonly Sprite medalGlow; + private readonly OsuSpriteText unlocked, name; + private readonly Paragraph description; + private readonly FillFlowContainer infoFlow; + private readonly IEnumerable descriptionSprites; + + public DrawableMedal(Medal medal) + { + Position = new Vector2(0f, MedalOverlay.DISC_SIZE / 2); + + Children = new Drawable[] + { + this.medal = new Container + { + Anchor = Anchor.TopCentre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Alpha = 0f, + Children = new[] + { + medalGlow = new Sprite + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + }, + }, + unlocked = new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = "Medal Unlocked".ToUpper(), + TextSize = 24, + Font = @"Exo2.0-Light", + Alpha = 0f, + Scale = new Vector2(1 / scale_when_unlocked), + }, + infoFlow = new FillFlowContainer + { + Anchor = Anchor.TopCentre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Width = 0.6f, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0f, 5f), + Children = new Drawable[] + { + name = new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = medal.Name, + TextSize = 20, + Font = @"Exo2.0-Bold", + Alpha = 0f, + Scale = new Vector2(1 / scale_when_full), + }, + description = new Paragraph + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Alpha = 0f, + Scale = new Vector2(1 / scale_when_full), + }, + }, + }, + }; + + descriptionSprites = description.AddText(medal.Description, s => + { + s.Anchor = Anchor.TopCentre; + s.Origin = Anchor.TopCentre; + s.TextSize = 16; + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, TextureStore textures) + { + medalGlow.Texture = textures.Get(@"MedalSplash/medal-glow"); + + foreach (var s in descriptionSprites) + s.Colour = colours.BlueLight; + + var pos = new Vector2(0f, medal.Size.Y / 2 + 10); + unlocked.Position = pos; + pos.Y += 90; + infoFlow.Position = pos; + } + + public void ChangeState(DisplayState newState, double duration) + { + switch (newState) + { + case DisplayState.Icon: + medal.Scale = Vector2.Zero; + medal.ScaleTo(1, duration, EasingTypes.OutElastic); + medal.FadeInFromZero(duration); + break; + case DisplayState.MedalUnlocked: + ScaleTo(scale_when_unlocked, duration, EasingTypes.OutExpo); + MoveToY(MedalOverlay.DISC_SIZE / 2 - 30, duration, EasingTypes.OutExpo); + unlocked.FadeInFromZero(duration); + break; + case DisplayState.Full: + ScaleTo(scale_when_full, duration, EasingTypes.OutExpo); + MoveToY(MedalOverlay.DISC_SIZE / 2 - 60, duration, EasingTypes.OutExpo); + name.FadeInFromZero(duration); + description.FadeInFromZero(duration * 2); + break; + } + } + + public enum DisplayState + { + Icon, + MedalUnlocked, + Full, + } + } +} diff --git a/osu.Game/Users/Medal.cs b/osu.Game/Users/Medal.cs new file mode 100644 index 0000000000..5ac6eceddc --- /dev/null +++ b/osu.Game/Users/Medal.cs @@ -0,0 +1,11 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Users +{ + public class Medal + { + public string Name { get; set; } + public string Description { get; set; } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0ec0624978..93d0652aa9 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -452,6 +452,9 @@ + + + From 94b3320e58df6801d1d4ccb2430d3da2388cc5c2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 09:45:12 -0300 Subject: [PATCH 05/89] Center direct panel covers --- osu.Game/Overlays/Direct/DirectPanel.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index cf969df303..f7ff88c24a 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -39,6 +39,8 @@ namespace osu.Game.Overlays.Direct { return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo) { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), }) { RelativeSizeAxes = Axes.Both }; From 3ed740676fce10ae90c1508827e150ffdbbf69ed Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 10:19:17 -0300 Subject: [PATCH 06/89] DirectSortCritera -> DirectSortCriteria --- osu.Game/Overlays/Direct/FilterControl.cs | 6 +++--- osu.Game/Overlays/DirectOverlay.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 455d0ab77b..ac9b7b1a1e 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -13,12 +13,12 @@ using osu.Game.Overlays.SearchableList; namespace osu.Game.Overlays.Direct { - public class FilterControl : SearchableListFilterControl + public class FilterControl : SearchableListFilterControl { private FillFlowContainer modeButtons; protected override Color4 BackgroundColour => OsuColour.FromHex(@"384552"); - protected override DirectSortCritera DefaultTab => DirectSortCritera.Title; + protected override DirectSortCriteria DefaultTab => DirectSortCriteria.Title; protected override Drawable CreateSupplementaryControls() { modeButtons = new FillFlowContainer @@ -94,7 +94,7 @@ namespace osu.Game.Overlays.Direct } } - public enum DirectSortCritera + public enum DirectSortCriteria { Title, Artist, diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index fb33c72b5e..c7c8a1f0ed 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -16,7 +16,7 @@ using osu.Game.Overlays.Direct; using osu.Game.Overlays.SearchableList; using OpenTK.Graphics; -namespace osu.Game.Overlays +namespace osu.Game.Overlaysi { public class DirectOverlay : SearchableListOverlay { @@ -29,7 +29,7 @@ namespace osu.Game.Overlays private readonly OsuSpriteText resultCountsText; private readonly FillFlowContainer panels; - protected override Color4 BackgroundColour => OsuColour.FromHex(@"485e74"); + protected override Color4 BackgroundColour => OsuColour.FromHexi(@"485e74"); protected override Color4 TrianglesColourLight => OsuColour.FromHex(@"465b71"); protected override Color4 TrianglesColourDark => OsuColour.FromHex(@"3f5265"); From f7f4f5e1552e2d52a88c5754685b6262e498a2a4 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 10:40:18 -0300 Subject: [PATCH 07/89] Request sorting, fix VS Code's "refactoring" --- .../Online/API/Requests/GetBeatmapSetsRequest.cs | 13 +++++++++++-- osu.Game/Overlays/Direct/FilterControl.cs | 2 +- osu.Game/Overlays/DirectOverlay.cs | 11 ++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs index ce5c9f0939..536da0cc1c 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using osu.Game.Database; +using osu.Game.Overlays; +using osu.Game.Overlays.Direct; namespace osu.Game.Online.API.Requests { @@ -12,14 +14,21 @@ namespace osu.Game.Online.API.Requests { private readonly string query; private readonly RankStatus rankStatus; + private readonly DirectSortCriteria sortCriteria; + private readonly SortDirection direction; + private string directionString => direction == SortDirection.Descending ? @"desc" : @"asc"; - public GetBeatmapSetsRequest(string query, RankStatus rankStatus = RankStatus.Any) + public GetBeatmapSetsRequest(string query, RankStatus rankStatus = RankStatus.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending) { this.query = System.Uri.EscapeDataString(query); this.rankStatus = rankStatus; + this.sortCriteria = sortCriteria; + this.direction = direction; + + System.Console.WriteLine(Target); } - protected override string Target => $@"beatmapsets/search?q={query}&s={(int)rankStatus}"; + protected override string Target => $@"beatmapsets/search?q={query}&s={(int)rankStatus}&sort={sortCriteria.ToString().ToLower()}_{directionString}"; } public class GetBeatmapSetsResponse : BeatmapMetadata diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index ac9b7b1a1e..31727e2adc 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Direct private FillFlowContainer modeButtons; protected override Color4 BackgroundColour => OsuColour.FromHex(@"384552"); - protected override DirectSortCriteria DefaultTab => DirectSortCriteria.Title; + protected override DirectSortCriteria DefaultTab => DirectSortCriteria.Ranked; protected override Drawable CreateSupplementaryControls() { modeButtons = new FillFlowContainer diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index c7c8a1f0ed..c1ef6930b2 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -16,9 +16,9 @@ using osu.Game.Overlays.Direct; using osu.Game.Overlays.SearchableList; using OpenTK.Graphics; -namespace osu.Game.Overlaysi +namespace osu.Game.Overlays { - public class DirectOverlay : SearchableListOverlay + public class DirectOverlay : SearchableListOverlay { private const float panel_padding = 10f; @@ -29,12 +29,12 @@ namespace osu.Game.Overlaysi private readonly OsuSpriteText resultCountsText; private readonly FillFlowContainer panels; - protected override Color4 BackgroundColour => OsuColour.FromHexi(@"485e74"); + protected override Color4 BackgroundColour => OsuColour.FromHex(@"485e74"); protected override Color4 TrianglesColourLight => OsuColour.FromHex(@"465b71"); protected override Color4 TrianglesColourDark => OsuColour.FromHex(@"3f5265"); protected override SearchableListHeader CreateHeader() => new Header(); - protected override SearchableListFilterControl CreateFilterControl() => new FilterControl(); + protected override SearchableListFilterControl CreateFilterControl() => new FilterControl(); private IEnumerable beatmapSets; public IEnumerable BeatmapSets @@ -117,6 +117,7 @@ namespace osu.Game.Overlaysi Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; Filter.Search.OnCommit = (sender, text) => updateSets(); + Filter.Tabs.Current.ValueChanged += sortCriteria => updateSets(); Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); @@ -162,7 +163,7 @@ namespace osu.Game.Overlaysi if (api == null || Filter.Search.Text == string.Empty) return; - getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, Filter.DisplayStyleControl.Dropdown.Current.Value); + getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); api.Queue(getSetsRequest); } From 312fd16631559871a425888834c60de79c6e5c2e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 11:00:05 -0300 Subject: [PATCH 08/89] Ruleset filtering --- osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs | 8 ++++---- osu.Game/Overlays/Direct/FilterControl.cs | 6 ++++-- osu.Game/Overlays/DirectOverlay.cs | 7 ++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs index 536da0cc1c..f3f670138a 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -13,22 +13,22 @@ namespace osu.Game.Online.API.Requests public class GetBeatmapSetsRequest : APIRequest> { private readonly string query; + private readonly RulesetInfo ruleset; private readonly RankStatus rankStatus; private readonly DirectSortCriteria sortCriteria; private readonly SortDirection direction; private string directionString => direction == SortDirection.Descending ? @"desc" : @"asc"; - public GetBeatmapSetsRequest(string query, RankStatus rankStatus = RankStatus.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending) + public GetBeatmapSetsRequest(string query, RulesetInfo ruleset, RankStatus rankStatus = RankStatus.Any, DirectSortCriteria sortCriteria = DirectSortCriteria.Ranked, SortDirection direction = SortDirection.Descending) { this.query = System.Uri.EscapeDataString(query); + this.ruleset = ruleset; this.rankStatus = rankStatus; this.sortCriteria = sortCriteria; this.direction = direction; - - System.Console.WriteLine(Target); } - protected override string Target => $@"beatmapsets/search?q={query}&s={(int)rankStatus}&sort={sortCriteria.ToString().ToLower()}_{directionString}"; + protected override string Target => $@"beatmapsets/search?q={query}&m={ruleset.ID ?? 0}&s={(int)rankStatus}&sort={sortCriteria.ToString().ToLower()}_{directionString}"; } public class GetBeatmapSetsResponse : BeatmapMetadata diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 31727e2adc..b6682a2768 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -10,11 +10,13 @@ using osu.Framework.Graphics.Containers; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Overlays.SearchableList; +using osu.Game.Rulesets; namespace osu.Game.Overlays.Direct { public class FilterControl : SearchableListFilterControl { + public readonly Bindable Ruleset = new Bindable(); private FillFlowContainer modeButtons; protected override Color4 BackgroundColour => OsuColour.FromHex(@"384552"); @@ -35,10 +37,10 @@ namespace osu.Game.Overlays.Direct { DisplayStyleControl.Dropdown.AccentColour = colours.BlueDark; - var b = new Bindable(); //backup bindable incase the game is null + Ruleset.BindTo(game?.Ruleset ?? new Bindable()); foreach (var r in rulesets.AllRulesets) { - modeButtons.Add(new RulesetToggleButton(game?.Ruleset ?? b, r)); + modeButtons.Add(new RulesetToggleButton(Ruleset, r)); } } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index c1ef6930b2..a487bc6af3 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -117,6 +117,7 @@ namespace osu.Game.Overlays Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; Filter.Search.OnCommit = (sender, text) => updateSets(); + ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); Filter.Tabs.Current.ValueChanged += sortCriteria => updateSets(); Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); @@ -163,7 +164,11 @@ namespace osu.Game.Overlays if (api == null || Filter.Search.Text == string.Empty) return; - getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction + getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, + ((FilterControl)Filter).Ruleset.Value, + Filter.DisplayStyleControl.Dropdown.Current.Value, + Filter.Tabs.Current.Value); //todo: sort direction + getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); api.Queue(getSetsRequest); } From a4be5c8a785c9af8c91ddbc619d9057682ebe5d5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 11:13:12 -0300 Subject: [PATCH 09/89] Fix being able to start typing something, change other filters, and have the search use the currently typing query --- osu.Game/Overlays/DirectOverlay.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index a487bc6af3..c2c7c0e306 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -116,7 +116,11 @@ namespace osu.Game.Overlays Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; - Filter.Search.OnCommit = (sender, text) => updateSets(); + Filter.Search.OnCommit = (sender, text) => + { + lastQuery = Filter.Search.Text; + updateSets(); + }; ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); Filter.Tabs.Current.ValueChanged += sortCriteria => updateSets(); Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; @@ -155,6 +159,7 @@ namespace osu.Game.Overlays } private GetBeatmapSetsRequest getSetsRequest; + private string lastQuery; private void updateSets() { if (!IsLoaded) return; @@ -164,7 +169,7 @@ namespace osu.Game.Overlays if (api == null || Filter.Search.Text == string.Empty) return; - getSetsRequest = new GetBeatmapSetsRequest(Filter.Search.Text, + getSetsRequest = new GetBeatmapSetsRequest(lastQuery, ((FilterControl)Filter).Ruleset.Value, Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction From add08e65ffd7e61084f690f8ecbc74917105bc18 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 11:30:52 -0300 Subject: [PATCH 10/89] Result counts displaying --- osu.Game/Database/BeatmapMetadata.cs | 2 ++ osu.Game/Overlays/DirectOverlay.cs | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/osu.Game/Database/BeatmapMetadata.cs b/osu.Game/Database/BeatmapMetadata.cs index a038b9cd19..ccf1a99c2c 100644 --- a/osu.Game/Database/BeatmapMetadata.cs +++ b/osu.Game/Database/BeatmapMetadata.cs @@ -23,6 +23,8 @@ namespace osu.Game.Database public string Author { get; set; } public string Source { get; set; } + + [JsonProperty(@"tags")] public string Tags { get; set; } public int PreviewTime { get; set; } public string AudioFile { get; set; } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index c2c7c0e306..5619d567f7 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -165,6 +165,7 @@ namespace osu.Game.Overlays if (!IsLoaded) return; BeatmapSets = null; + ResultAmounts = null; getSetsRequest?.Cancel(); if (api == null || Filter.Search.Text == string.Empty) return; @@ -174,10 +175,29 @@ namespace osu.Game.Overlays Filter.DisplayStyleControl.Dropdown.Current.Value, Filter.Tabs.Current.Value); //todo: sort direction - getSetsRequest.Success += r => BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); + getSetsRequest.Success += r => + { + BeatmapSets = r?.Select(response => response.ToSetInfo(rulesets)); + + var artists = new List(); + var songs = new List(); + var tags = new List(); + foreach (var s in BeatmapSets) + { + artists.Add(s.Metadata.Artist); + songs.Add(s.Metadata.Title); + tags.AddRange(s.Metadata.Tags.Split(' ')); + } + + ResultAmounts = new ResultCounts(distinctCount(artists), + distinctCount(songs), + distinctCount(tags)); + }; api.Queue(getSetsRequest); } + private int distinctCount(List list) => list.Distinct().ToArray().Length; + public class ResultCounts { public readonly int Artists; From ddc4d45ae88b239485218160435a2c377d0fb5d8 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 11:39:04 -0300 Subject: [PATCH 11/89] Unused usings --- osu.Game/Database/BeatmapOnlineInfo.cs | 1 - osu.Game/Database/BeatmapSetOnlineInfo.cs | 1 - osu.Game/Overlays/Direct/DirectGridPanel.cs | 1 - osu.Game/Overlays/Direct/DirectListPanel.cs | 1 - osu.Game/Overlays/Direct/DirectPanel.cs | 1 - osu.Game/Overlays/Direct/FilterControl.cs | 1 - 6 files changed, 6 deletions(-) diff --git a/osu.Game/Database/BeatmapOnlineInfo.cs b/osu.Game/Database/BeatmapOnlineInfo.cs index 7740545d6e..f4e70388f5 100644 --- a/osu.Game/Database/BeatmapOnlineInfo.cs +++ b/osu.Game/Database/BeatmapOnlineInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using Newtonsoft.Json; -using System.Collections.Generic; namespace osu.Game.Database { diff --git a/osu.Game/Database/BeatmapSetOnlineInfo.cs b/osu.Game/Database/BeatmapSetOnlineInfo.cs index 87859bf761..28461c0447 100644 --- a/osu.Game/Database/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Database/BeatmapSetOnlineInfo.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using Newtonsoft.Json; -using System.Collections.Generic; namespace osu.Game.Database { diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 1301d961f3..4a1fad41d9 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index aae906a644..fc44004df6 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -14,7 +14,6 @@ using osu.Game.Database; using osu.Framework.Allocation; using osu.Framework.Localisation; using osu.Framework.Graphics.Textures; -using System.Linq; using osu.Framework.Input; namespace osu.Game.Overlays.Direct diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index f7ff88c24a..1c007dd534 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using System.Linq; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index b6682a2768..ea5936b85a 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Overlays.SearchableList; -using osu.Game.Rulesets; namespace osu.Game.Overlays.Direct { From d54100613442034d67cb5fea5770c0d5ed07e4c9 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 7 Jun 2017 12:15:11 -0300 Subject: [PATCH 12/89] Use 2x size covers in list view --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 2 +- osu.Game/Overlays/Direct/DirectListPanel.cs | 2 +- osu.Game/Overlays/Direct/DirectPanel.cs | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 4a1fad41d9..5a1bb609b2 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Direct RelativeSizeAxes = Axes.Both, Colour = Color4.Black, }, - GetBackground(textures), + GetBackground(textures, false), new Box { RelativeSizeAxes = Axes.Both, diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index fc44004df6..c4b941a362 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Direct RelativeSizeAxes = Axes.Both, Colour = Color4.Black, }, - GetBackground(textures), + GetBackground(textures, true), new Box { RelativeSizeAxes = Axes.Both, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 1c007dd534..45ca51b4b0 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -34,9 +34,9 @@ namespace osu.Game.Overlays.Direct return icons; } - protected Drawable GetBackground(TextureStore textures) + protected Drawable GetBackground(TextureStore textures, bool doubleSize) { - return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo) + return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo, doubleSize) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -90,17 +90,19 @@ namespace osu.Game.Overlays.Direct private class BeatmapSetBackgroundSprite : Sprite { private readonly BeatmapSetInfo set; + private readonly bool doubleSize; - public BeatmapSetBackgroundSprite(BeatmapSetInfo set) + public BeatmapSetBackgroundSprite(BeatmapSetInfo set, bool doubleSize) { this.set = set; + this.doubleSize = doubleSize; } [BackgroundDependencyLoader] private void load(TextureStore textures) { if (set.OnlineInfo?.Covers?.Card != null) - Texture = textures.Get(set.OnlineInfo.Covers.Card); + Texture = textures.Get(doubleSize ? set.OnlineInfo.Covers.Card2x : set.OnlineInfo.Covers.Card); } } } From 1162df96be1c3a8043ea6803da1f2d8628a2f38f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 8 Jun 2017 05:08:12 -0300 Subject: [PATCH 13/89] Use DelayedLoadWrapper in DirectPanel backgrounds --- osu.Game/Overlays/Direct/DirectPanel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 45ca51b4b0..958fb7ac51 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -36,13 +36,13 @@ namespace osu.Game.Overlays.Direct protected Drawable GetBackground(TextureStore textures, bool doubleSize) { - return new AsyncLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo, doubleSize) + return new DelayedLoadWrapper(new BeatmapSetBackgroundSprite(SetInfo, doubleSize) { Anchor = Anchor.Centre, Origin = Anchor.Centre, FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), - }) { RelativeSizeAxes = Axes.Both }; + }) { RelativeSizeAxes = Axes.Both, TimeBeforeLoad = 300 }; } public class Statistic : FillFlowContainer From 70e12e5d9bee55bcc9e0382ff5a3440378fd88f0 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 8 Jun 2017 06:21:45 -0300 Subject: [PATCH 14/89] Make the header tabs work --- osu.Game/Overlays/Direct/FilterControl.cs | 1 + osu.Game/Overlays/Direct/Header.cs | 6 +++--- osu.Game/Overlays/DirectOverlay.cs | 22 ++++++++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index ea5936b85a..3667359d94 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -103,5 +103,6 @@ namespace osu.Game.Overlays.Direct Difficulty, Ranked, Rating, + Plays, } } diff --git a/osu.Game/Overlays/Direct/Header.cs b/osu.Game/Overlays/Direct/Header.cs index 000ef473cc..4310a9329f 100644 --- a/osu.Game/Overlays/Direct/Header.cs +++ b/osu.Game/Overlays/Direct/Header.cs @@ -30,10 +30,10 @@ namespace osu.Game.Overlays.Direct { Search, [Description("Newest Maps")] - NewestMaps, + NewestMaps = (int)DirectSortCriteria.Ranked, [Description("Top Rated")] - TopRated, + TopRated = (int)DirectSortCriteria.Rating, [Description("Most Played")] - MostPlayed + MostPlayed = (int)DirectSortCriteria.Plays, } } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 5619d567f7..b6c8e30764 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -114,7 +114,15 @@ namespace osu.Game.Overlays }, }; - Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; }; + Header.Tabs.Current.ValueChanged += tab => + { + if (tab != DirectTab.Search) + { + Filter.Search.Text = lastQuery = string.Empty; + Filter.Tabs.Current.Value = (DirectSortCriteria)Header.Tabs.Current.Value; + updateSets(); + } + }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; Filter.Search.OnCommit = (sender, text) => { @@ -122,7 +130,13 @@ namespace osu.Game.Overlays updateSets(); }; ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); - Filter.Tabs.Current.ValueChanged += sortCriteria => updateSets(); + Filter.Tabs.Current.ValueChanged += sortCriteria => + { + if (Header.Tabs.Current.Value != DirectTab.Search && sortCriteria != (DirectSortCriteria)Header.Tabs.Current.Value) + Header.Tabs.Current.Value = DirectTab.Search; + + updateSets(); + }; Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); @@ -159,7 +173,7 @@ namespace osu.Game.Overlays } private GetBeatmapSetsRequest getSetsRequest; - private string lastQuery; + private string lastQuery = string.Empty; private void updateSets() { if (!IsLoaded) return; @@ -168,7 +182,7 @@ namespace osu.Game.Overlays ResultAmounts = null; getSetsRequest?.Cancel(); - if (api == null || Filter.Search.Text == string.Empty) return; + if (api == null || Filter.Search.Text == string.Empty && Header.Tabs.Current.Value == DirectTab.Search) return; getSetsRequest = new GetBeatmapSetsRequest(lastQuery, ((FilterControl)Filter).Ruleset.Value, From bb103d7878d011f0f43c4adf4c39af863c67db8e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 8 Jun 2017 06:31:37 -0300 Subject: [PATCH 15/89] Fix being able to commit with an empty query and clearing the results --- osu.Game/Overlays/DirectOverlay.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index b6c8e30764..5e9cc4076d 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -176,18 +176,18 @@ namespace osu.Game.Overlays private string lastQuery = string.Empty; private void updateSets() { - if (!IsLoaded) return; + if (!IsLoaded || Header.Tabs.Current.Value == DirectTab.Search && Filter.Search.Text == string.Empty) return; BeatmapSets = null; ResultAmounts = null; getSetsRequest?.Cancel(); - if (api == null || Filter.Search.Text == string.Empty && Header.Tabs.Current.Value == DirectTab.Search) return; + if (api == null) return; getSetsRequest = new GetBeatmapSetsRequest(lastQuery, ((FilterControl)Filter).Ruleset.Value, Filter.DisplayStyleControl.Dropdown.Current.Value, - Filter.Tabs.Current.Value); //todo: sort direction + Filter.Tabs.Current.Value); //todo: sort direction (?) getSetsRequest.Success += r => { From 30fe7315ee60fd0483abc824fabe412b7d34b858 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 8 Jun 2017 06:47:21 -0300 Subject: [PATCH 16/89] Small cleanup --- osu.Game/Overlays/DirectOverlay.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 5e9cc4076d..4f5bbca219 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -114,6 +114,11 @@ namespace osu.Game.Overlays }, }; + Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; + ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); + Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; + Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); + Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) @@ -123,13 +128,13 @@ namespace osu.Game.Overlays updateSets(); } }; - Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; }; + Filter.Search.OnCommit = (sender, text) => { lastQuery = Filter.Search.Text; updateSets(); }; - ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets(); + Filter.Tabs.Current.ValueChanged += sortCriteria => { if (Header.Tabs.Current.Value != DirectTab.Search && sortCriteria != (DirectSortCriteria)Header.Tabs.Current.Value) @@ -137,8 +142,6 @@ namespace osu.Game.Overlays updateSets(); }; - Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; - Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets(); updateResultCounts(); } @@ -176,7 +179,7 @@ namespace osu.Game.Overlays private string lastQuery = string.Empty; private void updateSets() { - if (!IsLoaded || Header.Tabs.Current.Value == DirectTab.Search && Filter.Search.Text == string.Empty) return; + if (!IsLoaded || Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || lastQuery == string.Empty)) return; BeatmapSets = null; ResultAmounts = null; From 15cd4f77b2eb40506f985860d18c5084e2f74efd Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 23 Jun 2017 22:35:06 -0300 Subject: [PATCH 17/89] Proper dismissing. --- osu.Game/Overlays/MedalOverlay.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 2d2a32fa4f..a796da82b9 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -19,6 +19,7 @@ using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using OpenTK.Input; +using System.Linq; namespace osu.Game.Overlays { @@ -37,7 +38,16 @@ namespace osu.Game.Overlays private SampleChannel getSample; - protected override bool BlockPassThroughKeyboard => true; + protected override bool OnClick(InputState state) + { + dismiss(); + return true; + } + + protected override void OnFocusLost(InputState state) + { + if (state.Keyboard.Keys.Contains(Key.Escape)) dismiss(); + } public MedalOverlay(Medal medal) { @@ -189,6 +199,12 @@ namespace osu.Game.Overlays FadeOut(200); } + private void dismiss() + { + if (drawableMedal.Transforms.Count != 0) return; + Hide(); + } + private class BackgroundStrip : Container { public BackgroundStrip(float start, float end) From 3c97f0482655b2cb049ee5447c04db1e0618630a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 23 Jun 2017 23:18:44 -0300 Subject: [PATCH 18/89] Particles. --- osu.Game/Overlays/MedalOverlay.cs | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index a40d9bffda..6cb7e7662b 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -21,6 +21,8 @@ using osu.Framework.Input; using OpenTK.Input; using System.Linq; using osu.Framework.Graphics.Shapes; +using System; +using osu.Framework.MathUtils; namespace osu.Game.Overlays { @@ -144,6 +146,13 @@ namespace osu.Game.Overlays }; } + protected override void Update() + { + base.Update(); + + Add(new MedalParticle(RNG.Next(0, 359))); + } + protected override void PopIn() { base.PopIn(); @@ -225,5 +234,36 @@ namespace osu.Game.Overlays }; } } + + private class MedalParticle : CircularContainer + { + private readonly float direction; + + private Vector2 positionForOffset(float offset) => new Vector2((float)(offset * Math.Sin(direction)), (float)(offset * Math.Cos(direction))); + + public MedalParticle(float direction) + { + this.direction = direction; + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + Position = positionForOffset(DISC_SIZE / 2); + Masking = true; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Glow, + Colour = colours.Blue.Opacity(0.5f), + Radius = 5, + }; + + MoveTo(positionForOffset(DISC_SIZE / 2 + 200), 500); + FadeOut(500); + Expire(); + } + } } } From c71f34c50796eea717378dede6cb101dd31f6e4a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 23 Jun 2017 23:51:28 -0300 Subject: [PATCH 19/89] Make the background strip expand from the disc edges. --- osu.Game/Overlays/MedalOverlay.cs | 43 ++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 6cb7e7662b..ecd9a0af2f 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays private const float border_width = 5; private readonly Box background; - private readonly FillFlowContainer backgroundStrip; + private readonly Container backgroundStrip; private readonly BackgroundStrip leftStrip, rightStrip; private readonly CircularContainer disc; private readonly Sprite innerSpin, outterSpin; @@ -72,20 +72,44 @@ namespace osu.Game.Overlays Size = new Vector2(DISC_SIZE + 500), Alpha = 0f, }, - backgroundStrip = new FillFlowContainer + backgroundStrip = new Container { Name = @"background strip", Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.X, - Width = 0f, Height = border_width, Alpha = 0f, - Direction = FillDirection.Horizontal, Children = new[] { - leftStrip = new BackgroundStrip(0f, 1f), - rightStrip = new BackgroundStrip(1f, 0f), + new Container + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.CentreRight, + Width = 0.5f, + Padding = new MarginPadding { Right = DISC_SIZE / 2 }, + Children = new[] + { + leftStrip = new BackgroundStrip(0f, 1f) + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.CentreLeft, + Width = 0.5f, + Padding = new MarginPadding { Left = DISC_SIZE / 2 }, + Children = new[] + { + rightStrip = new BackgroundStrip(1f, 0f), + }, + }, }, }, disc = new CircularContainer @@ -187,12 +211,13 @@ namespace osu.Game.Overlays }); disc.FadeIn(duration1); - backgroundStrip.FadeIn(duration1); - backgroundStrip.ResizeWidthTo(1f, duration1 * 2, EasingTypes.OutQuint); outterSpin.FadeTo(0.1f, duration1 * 2); disc.ScaleTo(1f, duration1 * 2, EasingTypes.OutElastic); Delay(duration1 + 200, true); + backgroundStrip.FadeIn(duration2); + leftStrip.ResizeWidthTo(1f, duration2, EasingTypes.OutQuint); + rightStrip.ResizeWidthTo(1f, duration2, EasingTypes.OutQuint); drawableMedal.ChangeState(DrawableMedal.DisplayState.Icon, duration2); Delay(duration2, true); @@ -220,7 +245,7 @@ namespace osu.Game.Overlays public BackgroundStrip(float start, float end) { RelativeSizeAxes = Axes.Both; - Width = 0.5f; + Width = 0f; ColourInfo = ColourInfo.GradientHorizontal(Color4.White.Opacity(start), Color4.White.Opacity(end)); Masking = true; From 0133f9c0869d4ff7123d049a1c1623f9a2c0acee Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 01:19:44 -0300 Subject: [PATCH 20/89] Medal sprite, make MedalOverlay auto-show when loaded. --- .../Tests/TestCaseMedalOverlay.cs | 6 ++--- osu.Game/Overlays/MedalOverlay.cs | 2 ++ .../Overlays/MedalSplash/DrawableMedal.cs | 23 +++++++++++++------ osu.Game/Users/Medal.cs | 2 ++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs index 581675e66a..ac983277a4 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs @@ -15,14 +15,12 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - MedalOverlay overlay; - Add(overlay = new MedalOverlay(new Medal + Add(new MedalOverlay(new Medal { Name = @"Animations", + InternalName = @"all-intro-doubletime", Description = @"More complex than you think.", })); - - AddStep(@"show", overlay.Show); } } } diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index ecd9a0af2f..d9c949a0da 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -168,6 +168,8 @@ namespace osu.Game.Overlays Colour = colours.Blue.Opacity(0.5f), Radius = 50, }; + + Show(); } protected override void Update() diff --git a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs index ba2e3964a4..e230b9de9b 100644 --- a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs +++ b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs @@ -19,8 +19,9 @@ namespace osu.Game.Overlays.MedalSplash private const float scale_when_unlocked = 0.76f; private const float scale_when_full = 0.6f; - private readonly Container medal; - private readonly Sprite medalGlow; + private readonly Medal medal; + private readonly Container medalContainer; + private readonly Sprite medalGlow, medalSprite; private readonly OsuSpriteText unlocked, name; private readonly TextFlowContainer description; private readonly FillFlowContainer infoFlow; @@ -28,11 +29,12 @@ namespace osu.Game.Overlays.MedalSplash public DrawableMedal(Medal medal) { + this.medal = medal; Position = new Vector2(0f, MedalOverlay.DISC_SIZE / 2); Children = new Drawable[] { - this.medal = new Container + this.medalContainer = new Container { Anchor = Anchor.TopCentre, Origin = Anchor.Centre, @@ -40,6 +42,12 @@ namespace osu.Game.Overlays.MedalSplash Alpha = 0f, Children = new[] { + medalSprite = new Sprite + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(0.81f), + }, medalGlow = new Sprite { Anchor = Anchor.Centre, @@ -102,12 +110,13 @@ namespace osu.Game.Overlays.MedalSplash [BackgroundDependencyLoader] private void load(OsuColour colours, TextureStore textures) { + medalSprite.Texture = textures.Get(medal.ImageUrl); medalGlow.Texture = textures.Get(@"MedalSplash/medal-glow"); foreach (var s in descriptionSprites) s.Colour = colours.BlueLight; - var pos = new Vector2(0f, medal.Size.Y / 2 + 10); + var pos = new Vector2(0f, medalContainer.Size.Y / 2 + 10); unlocked.Position = pos; pos.Y += 90; infoFlow.Position = pos; @@ -118,9 +127,9 @@ namespace osu.Game.Overlays.MedalSplash switch (newState) { case DisplayState.Icon: - medal.Scale = Vector2.Zero; - medal.ScaleTo(1, duration, EasingTypes.OutElastic); - medal.FadeInFromZero(duration); + medalContainer.Scale = Vector2.Zero; + medalContainer.ScaleTo(1, duration, EasingTypes.OutElastic); + medalContainer.FadeInFromZero(duration); break; case DisplayState.MedalUnlocked: ScaleTo(scale_when_unlocked, duration, EasingTypes.OutExpo); diff --git a/osu.Game/Users/Medal.cs b/osu.Game/Users/Medal.cs index 5ac6eceddc..aa7382b457 100644 --- a/osu.Game/Users/Medal.cs +++ b/osu.Game/Users/Medal.cs @@ -6,6 +6,8 @@ namespace osu.Game.Users public class Medal { public string Name { get; set; } + public string InternalName { get; set; } + public string ImageUrl => $@"https://s.ppy.sh/images/medals-client/{InternalName}@2x.png"; public string Description { get; set; } } } From b2c516238e70f4b19950dbde62701df3eb4dd3e2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 01:48:55 -0300 Subject: [PATCH 21/89] Cleanup. --- osu.Game/Overlays/MedalOverlay.cs | 15 ++++++++++----- osu.Game/Overlays/MedalSplash/DrawableMedal.cs | 14 ++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index d9c949a0da..617a5f7d0b 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays private const float border_width = 5; private readonly Box background; - private readonly Container backgroundStrip; + private readonly Container backgroundStrip, particleContainer; private readonly BackgroundStrip leftStrip, rightStrip; private readonly CircularContainer disc; private readonly Sprite innerSpin, outterSpin; @@ -61,7 +61,6 @@ namespace osu.Game.Overlays { background = new Box { - Name = @"dim", RelativeSizeAxes = Axes.Both, Colour = Color4.Black.Opacity(60), }, @@ -74,7 +73,6 @@ namespace osu.Game.Overlays }, backgroundStrip = new Container { - Name = @"background strip", Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.X, @@ -112,9 +110,12 @@ namespace osu.Game.Overlays }, }, }, + particleContainer = new Container + { + RelativeSizeAxes = Axes.Both, + }, disc = new CircularContainer { - Name = @"content", Anchor = Anchor.Centre, Origin = Anchor.Centre, Alpha = 0f, @@ -168,7 +169,11 @@ namespace osu.Game.Overlays Colour = colours.Blue.Opacity(0.5f), Radius = 50, }; + } + protected override void LoadComplete() + { + base.LoadComplete(); Show(); } @@ -176,7 +181,7 @@ namespace osu.Game.Overlays { base.Update(); - Add(new MedalParticle(RNG.Next(0, 359))); + particleContainer.Add(new MedalParticle(RNG.Next(0, 359))); } protected override void PopIn() diff --git a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs index e230b9de9b..e385601f6d 100644 --- a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs +++ b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.MedalSplash Children = new Drawable[] { - this.medalContainer = new Container + medalContainer = new Container { Anchor = Anchor.TopCentre, Origin = Anchor.Centre, @@ -63,7 +63,7 @@ namespace osu.Game.Overlays.MedalSplash TextSize = 24, Font = @"Exo2.0-Light", Alpha = 0f, - Scale = new Vector2(1 / scale_when_unlocked), + Scale = new Vector2(1f / scale_when_unlocked), }, infoFlow = new FillFlowContainer { @@ -84,7 +84,7 @@ namespace osu.Game.Overlays.MedalSplash TextSize = 20, Font = @"Exo2.0-Bold", Alpha = 0f, - Scale = new Vector2(1 / scale_when_full), + Scale = new Vector2(1f / scale_when_full), }, description = new TextFlowContainer { @@ -93,7 +93,7 @@ namespace osu.Game.Overlays.MedalSplash RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Alpha = 0f, - Scale = new Vector2(1 / scale_when_full), + Scale = new Vector2(1f / scale_when_full), }, }, }, @@ -116,10 +116,8 @@ namespace osu.Game.Overlays.MedalSplash foreach (var s in descriptionSprites) s.Colour = colours.BlueLight; - var pos = new Vector2(0f, medalContainer.Size.Y / 2 + 10); - unlocked.Position = pos; - pos.Y += 90; - infoFlow.Position = pos; + unlocked.Position = new Vector2(0f, medalContainer.Size.Y / 2 + 10); + infoFlow.Position = new Vector2(0f, unlocked.Position.Y + 90); } public void ChangeState(DisplayState newState, double duration) From 0de55776c03bfbb7f47e467c5dac68f40c35f6cc Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 05:05:48 -0300 Subject: [PATCH 22/89] Update DrawableRoom design. --- .../Tests/TestCaseDrawableRoom.cs | 130 +++++++---- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 212 ++++++++++++++---- osu.Game/Screens/Multiplayer/RoomInspector.cs | 1 - 3 files changed, 254 insertions(+), 89 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs index 43a8069720..db8b712638 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs @@ -8,6 +8,7 @@ using osu.Game.Screens.Multiplayer; using osu.Game.Online.Multiplayer; using osu.Game.Users; using osu.Game.Database; +using osu.Framework.Allocation; namespace osu.Desktop.VisualTests.Tests { @@ -15,74 +16,105 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Select your favourite room"; + private RulesetDatabase rulesets; + public override void Reset() { base.Reset(); DrawableRoom first; - DrawableRoom second; Add(new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Y, - Width = 500f, + Width = 580f, Direction = FillDirection.Vertical, Children = new Drawable[] { - first = new DrawableRoom(new Room()), - second = new DrawableRoom(new Room()), + first = new DrawableRoom(new Room + { + Name = { Value = @"Great Room Right Here" }, + Host = { Value = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" } } }, + Status = { Value = new RoomStatusOpen() }, + Type = { Value = new GameTypeTeamVersus() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 4.65, + Ruleset = rulesets.GetRuleset(3), + Metadata = new BeatmapMetadata + { + Title = @"Critical Crystal", + Artist = @"Seiryu", + }, + OnlineInfo = new BeatmapOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/376340/covers/cover.jpg?1456478455" }, + }, + }, + }, + Participants = + { + Value = new[] + { + new User { GlobalRank = 1355 }, + new User { GlobalRank = 8756 }, + }, + }, + }), + new DrawableRoom(new Room + { + Name = { Value = @"Relax It's The Weekend" }, + Host = { Value = new User { Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" } } }, + Status = { Value = new RoomStatusPlaying() }, + Type = { Value = new GameTypeTagTeam() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 1.96, + Ruleset = rulesets.GetRuleset(0), + Metadata = new BeatmapMetadata + { + Title = @"Serendipity", + Artist = @"ZAQ", + }, + OnlineInfo = new BeatmapOnlineInfo + { + Covers = new[] { @"https://assets.ppy.sh//beatmaps/526839/covers/cover.jpg?1493815706" }, + }, + }, + }, + Participants = + { + Value = new[] + { + new User { GlobalRank = 578975 }, + new User { GlobalRank = 24554 }, + }, + }, + }), } }); - first.Room.Name.Value = @"Great Room Right Here"; - first.Room.Host.Value = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" } }; - first.Room.Status.Value = new RoomStatusOpen(); - first.Room.Beatmap.Value = new BeatmapInfo + AddStep(@"change title", () => first.Room.Name.Value = @"I Changed Name"); + AddStep(@"change host", () => first.Room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } }); + AddStep(@"change status", () => first.Room.Status.Value = new RoomStatusPlaying()); + AddStep(@"change type", () => first.Room.Type.Value = new GameTypeVersus()); + AddStep(@"change beatmap", () => first.Room.Beatmap.Value = null); + AddStep(@"change participants", () => first.Room.Participants.Value = new[] { - Metadata = new BeatmapMetadata - { - Title = @"Seiryu", - Artist = @"Critical Crystal", - }, - }; - - second.Room.Name.Value = @"Relax It's The Weekend"; - second.Room.Host.Value = new User { Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" } }; - second.Room.Status.Value = new RoomStatusPlaying(); - second.Room.Beatmap.Value = new BeatmapInfo - { - Metadata = new BeatmapMetadata - { - Title = @"Serendipity", - Artist = @"ZAQ", - }, - }; - - AddStep(@"change state", () => - { - first.Room.Status.Value = new RoomStatusPlaying(); + new User { GlobalRank = 1254 }, + new User { GlobalRank = 123189 }, }); + } - AddStep(@"change name", () => - { - first.Room.Name.Value = @"I Changed Name"; - }); - - AddStep(@"change host", () => - { - first.Room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } }; - }); - - AddStep(@"change beatmap", () => - { - first.Room.Beatmap.Value = null; - }); - - AddStep(@"change state", () => - { - first.Room.Status.Value = new RoomStatusOpen(); - }); + [BackgroundDependencyLoader] + private void load(RulesetDatabase rulesets) + { + this.rulesets = rulesets; } } } diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index 71114dd3a3..bd58fafd12 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -1,14 +1,18 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Textures; using osu.Framework.Localisation; +using osu.Game.Beatmaps.Drawables; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; @@ -19,22 +23,36 @@ namespace osu.Game.Screens.Multiplayer { public class DrawableRoom : ClickableContainer { - private const float content_padding = 5; - private const float height = 90; + private const float transition_duration = 100; + private const float content_padding = 10; + private const float height = 100; + private const float side_strip_width = 5; + private const float cover_width = 145; + private const float ruleset_height = 30; private readonly Box sideStrip; - private readonly UpdateableAvatar avatar; + private readonly Container coverContainer, rulesetContainer, gameTypeContainer; private readonly OsuSpriteText name; private readonly Container flagContainer; private readonly OsuSpriteText host; - private readonly OsuSpriteText rankBounds; + private readonly FillFlowContainer levelRangeContainer; + private readonly OsuSpriteText levelRangeLower; + private readonly OsuSpriteText levelRangeHigher; private readonly OsuSpriteText status; private readonly FillFlowContainer beatmapInfoFlow; private readonly OsuSpriteText beatmapTitle; private readonly OsuSpriteText beatmapDash; private readonly OsuSpriteText beatmapArtist; + private readonly Bindable nameBind = new Bindable(); + private readonly Bindable hostBind = new Bindable(); + private readonly Bindable statusBind = new Bindable(); + private readonly Bindable typeBind = new Bindable(); + private readonly Bindable beatmapBind = new Bindable(); + private readonly Bindable participantsBind = new Bindable(); + private OsuColour colours; + private TextureStore textures; private LocalisationEngine localisation; public readonly Room Room; @@ -59,24 +77,36 @@ namespace osu.Game.Screens.Multiplayer new Box { RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(34), + Colour = OsuColour.FromHex(@"212121"), }, sideStrip = new Box { RelativeSizeAxes = Axes.Y, - Width = content_padding, + Width = side_strip_width, }, - avatar = new UpdateableAvatar + new Container { - Size = new Vector2(Height - content_padding * 2), + Width = cover_width, + RelativeSizeAxes = Axes.Y, Masking = true, - CornerRadius = 5f, - Margin = new MarginPadding { Left = content_padding * 2, Top = content_padding }, + Margin = new MarginPadding { Left = side_strip_width }, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + coverContainer = new Container + { + RelativeSizeAxes = Axes.Both, + }, + }, }, new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = content_padding, Bottom = content_padding, Left = Height + content_padding * 2, Right = content_padding }, + Padding = new MarginPadding { Top = content_padding, Bottom = content_padding, Left = side_strip_width + cover_width + content_padding, Right = content_padding }, Children = new Drawable[] { new FillFlowContainer @@ -100,20 +130,30 @@ namespace osu.Game.Screens.Multiplayer new FillFlowContainer { AutoSizeAxes = Axes.X, - RelativeSizeAxes = Axes.Y, + Height = 15f, Direction = FillDirection.Horizontal, Spacing = new Vector2(5f, 0f), Children = new Drawable[] { flagContainer = new Container { - Width = 30f, + Width = 22f, RelativeSizeAxes = Axes.Y, }, - new Container + new Container //todo: team banners { - Width = 40f, + Width = 38f, RelativeSizeAxes = Axes.Y, + CornerRadius = 2f, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"ad387e"), + }, + }, }, new OsuSpriteText { @@ -131,13 +171,40 @@ namespace osu.Game.Screens.Multiplayer }, }, }, - rankBounds = new OsuSpriteText + levelRangeContainer = new FillFlowContainer { Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, - Text = "#0 - #0", - TextSize = 14, - Margin = new MarginPadding { Right = 10 }, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + new OsuSpriteText + { + Text = "#", + TextSize = 14, + }, + levelRangeLower = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + new OsuSpriteText + { + Text = " - ", + TextSize = 14, + }, + new OsuSpriteText + { + Text = "#", + TextSize = 14, + }, + levelRangeHigher = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + }, }, }, }, @@ -150,7 +217,6 @@ namespace osu.Game.Screens.Multiplayer RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, - Margin = new MarginPadding { Bottom = content_padding }, Children = new Drawable[] { status = new OsuSpriteText @@ -173,7 +239,7 @@ namespace osu.Game.Screens.Multiplayer beatmapDash = new OsuSpriteText { TextSize = 14, - Font = @"Exo2.0-RegularItalic", + Font = @"Exo2.0-BoldItalic", }, beatmapArtist = new OsuSpriteText { @@ -184,26 +250,64 @@ namespace osu.Game.Screens.Multiplayer }, }, }, + new FillFlowContainer + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Height = ruleset_height, + Direction = FillDirection.Horizontal, + LayoutDuration = transition_duration, + Spacing = new Vector2(5f, 0f), + Children = new[] + { + rulesetContainer = new Container + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + }, + gameTypeContainer = new Container + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + }, + }, + }, }, }, }; - Room.Name.ValueChanged += displayName; - Room.Host.ValueChanged += displayUser; - Room.Status.ValueChanged += displayStatus; - Room.Beatmap.ValueChanged += displayBeatmap; + nameBind.ValueChanged += displayName; + hostBind.ValueChanged += displayUser; + participantsBind.ValueChanged += displayParticipants; + + nameBind.BindTo(Room.Name); + hostBind.BindTo(Room.Host); + statusBind.BindTo(Room.Status); + typeBind.BindTo(Room.Type); + beatmapBind.BindTo(Room.Beatmap); + participantsBind.BindTo(Room.Participants); } [BackgroundDependencyLoader] - private void load(OsuColour colours, LocalisationEngine localisation) + private void load(OsuColour colours, TextureStore textures, LocalisationEngine localisation) { this.localisation = localisation; + this.textures = textures; this.colours = colours; - beatmapInfoFlow.Colour = rankBounds.Colour = colours.Gray9; + beatmapInfoFlow.Colour = levelRangeContainer.Colour = colours.Gray9; host.Colour = colours.Blue; - displayStatus(Room.Status.Value); + //binded here instead of ctor because dependencies are needed + statusBind.ValueChanged += displayStatus; + typeBind.ValueChanged += displayGameType; + beatmapBind.ValueChanged += displayBeatmap; + + statusBind.TriggerChange(); + typeBind.TriggerChange(); + beatmapBind.TriggerChange(); } private void displayName(string value) @@ -213,7 +317,6 @@ namespace osu.Game.Screens.Multiplayer private void displayUser(User value) { - avatar.User = value; host.Text = value.Username; flagContainer.Children = new[] { new DrawableFlag(value.Country?.FlagName ?? @"__") { RelativeSizeAxes = Axes.Both } }; } @@ -227,33 +330,64 @@ namespace osu.Game.Screens.Multiplayer d.FadeColour(value.GetAppropriateColour(colours), 100); } + private void displayGameType(GameType value) + { + gameTypeContainer.Children = new[] + { + new DrawableGameType(value) + { + Size = new Vector2(ruleset_height), + }, + }; + } + private void displayBeatmap(BeatmapInfo value) { if (value != null) { + coverContainer.FadeIn(transition_duration); + coverContainer.Children = new[] + { + new AsyncLoadWrapper(new BeatmapBackgroundSprite(new OnlineWorkingBeatmap(value, textures, null)) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), + }) { RelativeSizeAxes = Axes.Both } + }; + + rulesetContainer.FadeIn(transition_duration); + rulesetContainer.Children = new[] + { + new DifficultyIcon(value) + { + Size = new Vector2(ruleset_height), + } + }; + beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title); beatmapDash.Text = @" - "; beatmapArtist.Current = localisation.GetUnicodePreference(value.Metadata.ArtistUnicode, value.Metadata.Artist); } else { + coverContainer.FadeOut(transition_duration); + rulesetContainer.FadeOut(transition_duration); + beatmapTitle.Current = null; beatmapArtist.Current = null; - beatmapTitle.Text = @"Changing map"; - beatmapDash.Text = string.Empty; - beatmapArtist.Text = string.Empty; + beatmapTitle.Text = "Changing map"; + beatmapDash.Text = beatmapArtist.Text = string.Empty; } } - protected override void Dispose(bool isDisposing) + private void displayParticipants(User[] value) { - Room.Name.ValueChanged -= displayName; - Room.Host.ValueChanged -= displayUser; - Room.Status.ValueChanged -= displayStatus; - Room.Beatmap.ValueChanged -= displayBeatmap; - - base.Dispose(isDisposing); + var ranks = value.Select(u => u.GlobalRank); + levelRangeLower.Text = ranks.Min().ToString(); + levelRangeHigher.Text = ranks.Max().ToString(); } } } diff --git a/osu.Game/Screens/Multiplayer/RoomInspector.cs b/osu.Game/Screens/Multiplayer/RoomInspector.cs index 2181f37be9..508128c749 100644 --- a/osu.Game/Screens/Multiplayer/RoomInspector.cs +++ b/osu.Game/Screens/Multiplayer/RoomInspector.cs @@ -331,7 +331,6 @@ namespace osu.Game.Screens.Multiplayer }, levelRangeHigher = new OsuSpriteText { - Text = "6251", TextSize = 14, Font = @"Exo2.0-Bold", }, From 05b5fe8ae7cfff1d9caed9037d951b31345576ed Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 05:21:42 -0300 Subject: [PATCH 23/89] Share host/participant info displaying. --- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 105 +------------ .../Screens/Multiplayer/ParticipantInfo.cs | 142 ++++++++++++++++++ osu.Game/Screens/Multiplayer/RoomInspector.cs | 110 +------------- osu.Game/osu.Game.csproj | 1 + 4 files changed, 156 insertions(+), 202 deletions(-) create mode 100644 osu.Game/Screens/Multiplayer/ParticipantInfo.cs diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index bd58fafd12..507e0039e1 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -33,11 +32,7 @@ namespace osu.Game.Screens.Multiplayer private readonly Box sideStrip; private readonly Container coverContainer, rulesetContainer, gameTypeContainer; private readonly OsuSpriteText name; - private readonly Container flagContainer; - private readonly OsuSpriteText host; - private readonly FillFlowContainer levelRangeContainer; - private readonly OsuSpriteText levelRangeLower; - private readonly OsuSpriteText levelRangeHigher; + private readonly ParticipantInfo participantInfo; private readonly OsuSpriteText status; private readonly FillFlowContainer beatmapInfoFlow; private readonly OsuSpriteText beatmapTitle; @@ -121,93 +116,7 @@ namespace osu.Game.Screens.Multiplayer { TextSize = 18, }, - new Container - { - RelativeSizeAxes = Axes.X, - Height = 20f, - Children = new Drawable[] - { - new FillFlowContainer - { - AutoSizeAxes = Axes.X, - Height = 15f, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5f, 0f), - Children = new Drawable[] - { - flagContainer = new Container - { - Width = 22f, - RelativeSizeAxes = Axes.Y, - }, - new Container //todo: team banners - { - Width = 38f, - RelativeSizeAxes = Axes.Y, - CornerRadius = 2f, - Masking = true, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"ad387e"), - }, - }, - }, - new OsuSpriteText - { - Text = "hosted by", - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = 14, - }, - host = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = 14, - Font = @"Exo2.0-BoldItalic", - }, - }, - }, - levelRangeContainer = new FillFlowContainer - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new[] - { - new OsuSpriteText - { - Text = "#", - TextSize = 14, - }, - levelRangeLower = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-Bold", - }, - new OsuSpriteText - { - Text = " - ", - TextSize = 14, - }, - new OsuSpriteText - { - Text = "#", - TextSize = 14, - }, - levelRangeHigher = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-Bold", - }, - }, - }, - }, - }, + participantInfo = new ParticipantInfo(), }, }, new FillFlowContainer @@ -297,8 +206,7 @@ namespace osu.Game.Screens.Multiplayer this.textures = textures; this.colours = colours; - beatmapInfoFlow.Colour = levelRangeContainer.Colour = colours.Gray9; - host.Colour = colours.Blue; + beatmapInfoFlow.Colour = colours.Gray9; //binded here instead of ctor because dependencies are needed statusBind.ValueChanged += displayStatus; @@ -317,8 +225,7 @@ namespace osu.Game.Screens.Multiplayer private void displayUser(User value) { - host.Text = value.Username; - flagContainer.Children = new[] { new DrawableFlag(value.Country?.FlagName ?? @"__") { RelativeSizeAxes = Axes.Both } }; + participantInfo.Host = value; } private void displayStatus(RoomStatus value) @@ -385,9 +292,7 @@ namespace osu.Game.Screens.Multiplayer private void displayParticipants(User[] value) { - var ranks = value.Select(u => u.GlobalRank); - levelRangeLower.Text = ranks.Min().ToString(); - levelRangeHigher.Text = ranks.Max().ToString(); + participantInfo.Participants = value; } } } diff --git a/osu.Game/Screens/Multiplayer/ParticipantInfo.cs b/osu.Game/Screens/Multiplayer/ParticipantInfo.cs new file mode 100644 index 0000000000..cd9101d5ad --- /dev/null +++ b/osu.Game/Screens/Multiplayer/ParticipantInfo.cs @@ -0,0 +1,142 @@ +using System.Collections.Generic; +using System.Linq; +using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Users; + +namespace osu.Game.Screens.Multiplayer +{ + public class ParticipantInfo : Container + { + private readonly Container flagContainer; + private readonly OsuSpriteText host; + private readonly FillFlowContainer levelRangeContainer; + private readonly OsuSpriteText levelRangeLower; + private readonly OsuSpriteText levelRangeHigher; + + public User Host + { + set + { + host.Text = value.Username; + flagContainer.Children = new[] { new DrawableFlag(value.Country?.FlagName ?? @"__") { RelativeSizeAxes = Axes.Both } }; + } + } + + public IEnumerable Participants + { + set + { + var ranks = value.Select(u => u.GlobalRank); + levelRangeLower.Text = ranks.Min().ToString(); + levelRangeHigher.Text = ranks.Max().ToString(); + } + } + + public ParticipantInfo(string rankPrefix = null) + { + RelativeSizeAxes = Axes.X; + Height = 15f; + + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5f, 0f), + Children = new Drawable[] + { + flagContainer = new Container + { + Width = 22f, + RelativeSizeAxes = Axes.Y, + }, + new Container //todo: team banners + { + Width = 38f, + RelativeSizeAxes = Axes.Y, + CornerRadius = 2f, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"ad387e"), + }, + }, + }, + new OsuSpriteText + { + Text = "hosted by", + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 14, + }, + host = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 14, + Font = @"Exo2.0-BoldItalic", + }, + }, + }, + levelRangeContainer = new FillFlowContainer + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + new OsuSpriteText + { + Text = rankPrefix, + TextSize = 14, + }, + new OsuSpriteText + { + Text = "#", + TextSize = 14, + }, + levelRangeLower = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + new OsuSpriteText + { + Text = " - ", + TextSize = 14, + }, + new OsuSpriteText + { + Text = "#", + TextSize = 14, + }, + levelRangeHigher = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + levelRangeContainer.Colour = colours.Gray9; + host.Colour = colours.Blue; + } + } +} diff --git a/osu.Game/Screens/Multiplayer/RoomInspector.cs b/osu.Game/Screens/Multiplayer/RoomInspector.cs index 508128c749..d840495765 100644 --- a/osu.Game/Screens/Multiplayer/RoomInspector.cs +++ b/osu.Game/Screens/Multiplayer/RoomInspector.cs @@ -30,9 +30,10 @@ namespace osu.Game.Screens.Multiplayer private const float ruleset_height = 30; private readonly Box statusStrip; - private readonly Container coverContainer, rulesetContainer, gameTypeContainer, flagContainer; - private readonly FillFlowContainer topFlow, levelRangeContainer, participantsFlow; - private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor, host, levelRangeLower, levelRangeHigher; + private readonly Container coverContainer, rulesetContainer, gameTypeContainer; + private readonly FillFlowContainer topFlow, participantsFlow; + private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor; + private readonly ParticipantInfo participantInfo; private readonly ScrollContainer participantsScroll; private readonly Bindable nameBind = new Bindable(); @@ -252,90 +253,7 @@ namespace osu.Game.Screens.Multiplayer Padding = contentPadding, Children = new Drawable[] { - new FillFlowContainer - { - AutoSizeAxes = Axes.X, - Height = 15f, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5f, 0f), - Children = new Drawable[] - { - flagContainer = new Container - { - Width = 22f, - RelativeSizeAxes = Axes.Y, - }, - new Container //todo: team banners - { - Width = 38f, - RelativeSizeAxes = Axes.Y, - CornerRadius = 2f, - Masking = true, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"ad387e"), - }, - }, - }, - new OsuSpriteText - { - Text = "hosted by", - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = 14, - }, - host = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = 14, - Font = @"Exo2.0-BoldItalic", - }, - }, - }, - levelRangeContainer = new FillFlowContainer - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new[] - { - new OsuSpriteText - { - Text = "Rank Range ", - TextSize = 14, - }, - new OsuSpriteText - { - Text = "#", - TextSize = 14, - }, - levelRangeLower = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-Bold", - }, - new OsuSpriteText - { - Text = " - ", - TextSize = 14, - }, - new OsuSpriteText - { - Text = "#", - TextSize = 14, - }, - levelRangeHigher = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-Bold", - }, - }, - }, + participantInfo = new ParticipantInfo(@"Rank Range "), }, }, }, @@ -372,8 +290,7 @@ namespace osu.Game.Screens.Multiplayer this.colours = colours; this.textures = textures; - beatmapAuthor.Colour = levelRangeContainer.Colour = colours.Gray9; - host.Colour = colours.Blue; + beatmapAuthor.Colour = colours.Gray9; //binded here instead of ctor because dependencies are needed statusBind.ValueChanged += displayStatus; @@ -399,14 +316,7 @@ namespace osu.Game.Screens.Multiplayer private void displayUser(User value) { - host.Text = value.Username; - flagContainer.Children = new[] - { - new DrawableFlag(value.Country?.FlagName ?? @"__") - { - RelativeSizeAxes = Axes.Both, - }, - }; + participantInfo.Host = value; } private void displayStatus(RoomStatus value) @@ -489,11 +399,7 @@ namespace osu.Game.Screens.Multiplayer private void displayParticipants(User[] value) { participants.Text = value.Length.ToString(); - - var ranks = value.Select(u => u.GlobalRank); - levelRangeLower.Text = ranks.Min().ToString(); - levelRangeHigher.Text = ranks.Max().ToString(); - + participantInfo.Participants = value; participantsFlow.Children = value.Select(u => new UserTile(u)); } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 64b81ddc6a..4e015242e2 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -490,6 +490,7 @@ + From 35951ffc40053e1a03570a26081a6ca87438c6b0 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 05:23:31 -0300 Subject: [PATCH 24/89] Line endings. --- .../Screens/Multiplayer/ParticipantInfo.cs | 284 +++++++++--------- 1 file changed, 142 insertions(+), 142 deletions(-) diff --git a/osu.Game/Screens/Multiplayer/ParticipantInfo.cs b/osu.Game/Screens/Multiplayer/ParticipantInfo.cs index cd9101d5ad..c1a031f8cb 100644 --- a/osu.Game/Screens/Multiplayer/ParticipantInfo.cs +++ b/osu.Game/Screens/Multiplayer/ParticipantInfo.cs @@ -1,142 +1,142 @@ -using System.Collections.Generic; -using System.Linq; -using OpenTK; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Users; - -namespace osu.Game.Screens.Multiplayer -{ - public class ParticipantInfo : Container - { - private readonly Container flagContainer; - private readonly OsuSpriteText host; - private readonly FillFlowContainer levelRangeContainer; - private readonly OsuSpriteText levelRangeLower; - private readonly OsuSpriteText levelRangeHigher; - - public User Host - { - set - { - host.Text = value.Username; - flagContainer.Children = new[] { new DrawableFlag(value.Country?.FlagName ?? @"__") { RelativeSizeAxes = Axes.Both } }; - } - } - - public IEnumerable Participants - { - set - { - var ranks = value.Select(u => u.GlobalRank); - levelRangeLower.Text = ranks.Min().ToString(); - levelRangeHigher.Text = ranks.Max().ToString(); - } - } - - public ParticipantInfo(string rankPrefix = null) - { - RelativeSizeAxes = Axes.X; - Height = 15f; - - Children = new Drawable[] - { - new FillFlowContainer - { - AutoSizeAxes = Axes.X, - RelativeSizeAxes = Axes.Y, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5f, 0f), - Children = new Drawable[] - { - flagContainer = new Container - { - Width = 22f, - RelativeSizeAxes = Axes.Y, - }, - new Container //todo: team banners - { - Width = 38f, - RelativeSizeAxes = Axes.Y, - CornerRadius = 2f, - Masking = true, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"ad387e"), - }, - }, - }, - new OsuSpriteText - { - Text = "hosted by", - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = 14, - }, - host = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - TextSize = 14, - Font = @"Exo2.0-BoldItalic", - }, - }, - }, - levelRangeContainer = new FillFlowContainer - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new[] - { - new OsuSpriteText - { - Text = rankPrefix, - TextSize = 14, - }, - new OsuSpriteText - { - Text = "#", - TextSize = 14, - }, - levelRangeLower = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-Bold", - }, - new OsuSpriteText - { - Text = " - ", - TextSize = 14, - }, - new OsuSpriteText - { - Text = "#", - TextSize = 14, - }, - levelRangeHigher = new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-Bold", - }, - }, - }, - }; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - levelRangeContainer.Colour = colours.Gray9; - host.Colour = colours.Blue; - } - } -} +using System.Collections.Generic; +using System.Linq; +using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Users; + +namespace osu.Game.Screens.Multiplayer +{ + public class ParticipantInfo : Container + { + private readonly Container flagContainer; + private readonly OsuSpriteText host; + private readonly FillFlowContainer levelRangeContainer; + private readonly OsuSpriteText levelRangeLower; + private readonly OsuSpriteText levelRangeHigher; + + public User Host + { + set + { + host.Text = value.Username; + flagContainer.Children = new[] { new DrawableFlag(value.Country?.FlagName ?? @"__") { RelativeSizeAxes = Axes.Both } }; + } + } + + public IEnumerable Participants + { + set + { + var ranks = value.Select(u => u.GlobalRank); + levelRangeLower.Text = ranks.Min().ToString(); + levelRangeHigher.Text = ranks.Max().ToString(); + } + } + + public ParticipantInfo(string rankPrefix = null) + { + RelativeSizeAxes = Axes.X; + Height = 15f; + + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5f, 0f), + Children = new Drawable[] + { + flagContainer = new Container + { + Width = 22f, + RelativeSizeAxes = Axes.Y, + }, + new Container //todo: team banners + { + Width = 38f, + RelativeSizeAxes = Axes.Y, + CornerRadius = 2f, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"ad387e"), + }, + }, + }, + new OsuSpriteText + { + Text = "hosted by", + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 14, + }, + host = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 14, + Font = @"Exo2.0-BoldItalic", + }, + }, + }, + levelRangeContainer = new FillFlowContainer + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + new OsuSpriteText + { + Text = rankPrefix, + TextSize = 14, + }, + new OsuSpriteText + { + Text = "#", + TextSize = 14, + }, + levelRangeLower = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + new OsuSpriteText + { + Text = " - ", + TextSize = 14, + }, + new OsuSpriteText + { + Text = "#", + TextSize = 14, + }, + levelRangeHigher = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + levelRangeContainer.Colour = colours.Gray9; + host.Colour = colours.Blue; + } + } +} From fe875957a708bbd4093bfa611ffabd967b3ecbd6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 05:43:52 -0300 Subject: [PATCH 25/89] Share ruleset and type displaying, fix tag team icon. --- osu.Game/Online/Multiplayer/GameType.cs | 24 +++++- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 45 ++-------- osu.Game/Screens/Multiplayer/ModeTypeInfo.cs | 82 +++++++++++++++++++ osu.Game/Screens/Multiplayer/RoomInspector.cs | 33 ++------ osu.Game/osu.Game.csproj | 1 + 5 files changed, 118 insertions(+), 67 deletions(-) create mode 100644 osu.Game/Screens/Multiplayer/ModeTypeInfo.cs diff --git a/osu.Game/Online/Multiplayer/GameType.cs b/osu.Game/Online/Multiplayer/GameType.cs index 4d1a6c4839..22e2ffac31 100644 --- a/osu.Game/Online/Multiplayer/GameType.cs +++ b/osu.Game/Online/Multiplayer/GameType.cs @@ -52,10 +52,32 @@ namespace osu.Game.Online.Multiplayer public override string Name => "Tag Team"; public override Drawable GetIcon(OsuColour colours, float size) { - return new VersusRow(colours.Blue, colours.Blue, size * 0.6f) + return new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(2f), + Children = new[] + { + new TextAwesome + { + Icon = FontAwesome.fa_refresh, + TextSize = size * 0.75f, + Colour = colours.Blue, + Shadow = false, + UseFullGlyphHeight = false, + }, + new TextAwesome + { + Icon = FontAwesome.fa_refresh, + TextSize = size * 0.75f, + Colour = colours.Pink, + Shadow = false, + UseFullGlyphHeight = false, + }, + }, }; } } diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index 507e0039e1..8a970427e5 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -27,12 +27,12 @@ namespace osu.Game.Screens.Multiplayer private const float height = 100; private const float side_strip_width = 5; private const float cover_width = 145; - private const float ruleset_height = 30; private readonly Box sideStrip; - private readonly Container coverContainer, rulesetContainer, gameTypeContainer; + private readonly Container coverContainer; private readonly OsuSpriteText name; private readonly ParticipantInfo participantInfo; + private readonly ModeTypeInfo modeTypeInfo; private readonly OsuSpriteText status; private readonly FillFlowContainer beatmapInfoFlow; private readonly OsuSpriteText beatmapTitle; @@ -159,29 +159,10 @@ namespace osu.Game.Screens.Multiplayer }, }, }, - new FillFlowContainer + modeTypeInfo = new ModeTypeInfo { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, - Height = ruleset_height, - Direction = FillDirection.Horizontal, - LayoutDuration = transition_duration, - Spacing = new Vector2(5f, 0f), - Children = new[] - { - rulesetContainer = new Container - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - }, - gameTypeContainer = new Container - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - }, - }, }, }, }, @@ -239,17 +220,13 @@ namespace osu.Game.Screens.Multiplayer private void displayGameType(GameType value) { - gameTypeContainer.Children = new[] - { - new DrawableGameType(value) - { - Size = new Vector2(ruleset_height), - }, - }; + modeTypeInfo.Type = value; } private void displayBeatmap(BeatmapInfo value) { + modeTypeInfo.Beatmap = value; + if (value != null) { coverContainer.FadeIn(transition_duration); @@ -264,15 +241,6 @@ namespace osu.Game.Screens.Multiplayer }) { RelativeSizeAxes = Axes.Both } }; - rulesetContainer.FadeIn(transition_duration); - rulesetContainer.Children = new[] - { - new DifficultyIcon(value) - { - Size = new Vector2(ruleset_height), - } - }; - beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title); beatmapDash.Text = @" - "; beatmapArtist.Current = localisation.GetUnicodePreference(value.Metadata.ArtistUnicode, value.Metadata.Artist); @@ -280,7 +248,6 @@ namespace osu.Game.Screens.Multiplayer else { coverContainer.FadeOut(transition_duration); - rulesetContainer.FadeOut(transition_duration); beatmapTitle.Current = null; beatmapArtist.Current = null; diff --git a/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs b/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs new file mode 100644 index 0000000000..07e62d4d2f --- /dev/null +++ b/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs @@ -0,0 +1,82 @@ +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Database; +using osu.Game.Online.Multiplayer; + +namespace osu.Game.Screens.Multiplayer +{ + public class ModeTypeInfo : Container + { + private const float height = 30; + private const float transition_duration = 100; + + private readonly Container rulesetContainer, gameTypeContainer; + + public BeatmapInfo Beatmap + { + set + { + if (value != null) + { + rulesetContainer.FadeIn(transition_duration); + rulesetContainer.Children = new[] + { + new DifficultyIcon(value) + { + Size = new Vector2(height), + } + }; + } + else + { + rulesetContainer.FadeOut(transition_duration); + } + } + } + + public GameType Type + { + set + { + gameTypeContainer.Children = new[] + { + new DrawableGameType(value) + { + Size = new Vector2(height), + }, + }; + } + } + + public ModeTypeInfo() + { + AutoSizeAxes = Axes.Both; + + Children = new[] + { + new FillFlowContainer + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + LayoutDuration = transition_duration, + Spacing = new Vector2(5f, 0f), + Children = new[] + { + rulesetContainer = new Container + { + AutoSizeAxes = Axes.Both, + }, + gameTypeContainer = new Container + { + AutoSizeAxes = Axes.Both, + }, + }, + }, + }; + } + } +} diff --git a/osu.Game/Screens/Multiplayer/RoomInspector.cs b/osu.Game/Screens/Multiplayer/RoomInspector.cs index d840495765..3ed0b78f36 100644 --- a/osu.Game/Screens/Multiplayer/RoomInspector.cs +++ b/osu.Game/Screens/Multiplayer/RoomInspector.cs @@ -27,11 +27,11 @@ namespace osu.Game.Screens.Multiplayer { private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 }; private const float transition_duration = 100; - private const float ruleset_height = 30; private readonly Box statusStrip; private readonly Container coverContainer, rulesetContainer, gameTypeContainer; private readonly FillFlowContainer topFlow, participantsFlow; + private readonly ModeTypeInfo modeTypeInfo; private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor; private readonly ParticipantInfo participantInfo; private readonly ScrollContainer participantsScroll; @@ -191,20 +191,13 @@ namespace osu.Game.Screens.Multiplayer new FillFlowContainer { AutoSizeAxes = Axes.X, - Height = ruleset_height, + Height = 30, Direction = FillDirection.Horizontal, LayoutDuration = transition_duration, Spacing = new Vector2(5f, 0f), Children = new Drawable[] { - rulesetContainer = new Container - { - AutoSizeAxes = Axes.Both, - }, - gameTypeContainer = new Container - { - AutoSizeAxes = Axes.Both, - }, + modeTypeInfo = new ModeTypeInfo(), new Container { AutoSizeAxes = Axes.X, @@ -329,17 +322,13 @@ namespace osu.Game.Screens.Multiplayer private void displayGameType(GameType value) { - gameTypeContainer.Children = new[] - { - new DrawableGameType(value) - { - Size = new Vector2(ruleset_height), - }, - }; + modeTypeInfo.Type = value; } private void displayBeatmap(BeatmapInfo value) { + modeTypeInfo.Beatmap = value; + if (value != null) { coverContainer.FadeIn(transition_duration); @@ -354,15 +343,6 @@ namespace osu.Game.Screens.Multiplayer }) { RelativeSizeAxes = Axes.Both } }; - rulesetContainer.FadeIn(transition_duration); - rulesetContainer.Children = new[] - { - new DifficultyIcon(value) - { - Size = new Vector2(ruleset_height), - } - }; - beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title); beatmapDash.Text = @" - "; beatmapArtist.Current = localisation.GetUnicodePreference(value.Metadata.ArtistUnicode, value.Metadata.Artist); @@ -371,7 +351,6 @@ namespace osu.Game.Screens.Multiplayer else { coverContainer.FadeOut(transition_duration); - rulesetContainer.FadeOut(transition_duration); beatmapTitle.Current = null; beatmapArtist.Current = null; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 4e015242e2..553e55c83e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -491,6 +491,7 @@ + From bcd82a02f499308fbe9c7e29be4fe4797e429d74 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 05:45:34 -0300 Subject: [PATCH 26/89] Licenses. --- osu.Game/Screens/Multiplayer/ModeTypeInfo.cs | 5 ++++- osu.Game/Screens/Multiplayer/ParticipantInfo.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs b/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs index 07e62d4d2f..ca93163ac3 100644 --- a/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs +++ b/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs @@ -1,4 +1,7 @@ -using OpenTK; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps.Drawables; diff --git a/osu.Game/Screens/Multiplayer/ParticipantInfo.cs b/osu.Game/Screens/Multiplayer/ParticipantInfo.cs index c1a031f8cb..639f29567f 100644 --- a/osu.Game/Screens/Multiplayer/ParticipantInfo.cs +++ b/osu.Game/Screens/Multiplayer/ParticipantInfo.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; using System.Linq; using OpenTK; using osu.Framework.Allocation; From 9f417743b641a7faf19907ad8ff52e06515f448a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 05:54:00 -0300 Subject: [PATCH 27/89] Cleanup. --- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 13 ++++--------- osu.Game/Screens/Multiplayer/ModeTypeInfo.cs | 2 +- osu.Game/Screens/Multiplayer/RoomInspector.cs | 5 ++--- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index 8a970427e5..eb66fd3d2a 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -30,14 +30,10 @@ namespace osu.Game.Screens.Multiplayer private readonly Box sideStrip; private readonly Container coverContainer; - private readonly OsuSpriteText name; + private readonly OsuSpriteText name, status, beatmapTitle, beatmapDash, beatmapArtist; + private readonly FillFlowContainer beatmapInfoFlow; private readonly ParticipantInfo participantInfo; private readonly ModeTypeInfo modeTypeInfo; - private readonly OsuSpriteText status; - private readonly FillFlowContainer beatmapInfoFlow; - private readonly OsuSpriteText beatmapTitle; - private readonly OsuSpriteText beatmapDash; - private readonly OsuSpriteText beatmapArtist; private readonly Bindable nameBind = new Bindable(); private readonly Bindable hostBind = new Bindable(); @@ -170,6 +166,7 @@ namespace osu.Game.Screens.Multiplayer nameBind.ValueChanged += displayName; hostBind.ValueChanged += displayUser; + typeBind.ValueChanged += displayGameType; participantsBind.ValueChanged += displayParticipants; nameBind.BindTo(Room.Name); @@ -191,11 +188,9 @@ namespace osu.Game.Screens.Multiplayer //binded here instead of ctor because dependencies are needed statusBind.ValueChanged += displayStatus; - typeBind.ValueChanged += displayGameType; beatmapBind.ValueChanged += displayBeatmap; statusBind.TriggerChange(); - typeBind.TriggerChange(); beatmapBind.TriggerChange(); } @@ -238,7 +233,7 @@ namespace osu.Game.Screens.Multiplayer Origin = Anchor.Centre, FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), - }) { RelativeSizeAxes = Axes.Both } + }) { RelativeSizeAxes = Axes.Both }, }; beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title); diff --git a/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs b/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs index ca93163ac3..fbb15ec2c5 100644 --- a/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs +++ b/osu.Game/Screens/Multiplayer/ModeTypeInfo.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Multiplayer new DifficultyIcon(value) { Size = new Vector2(height), - } + }, }; } else diff --git a/osu.Game/Screens/Multiplayer/RoomInspector.cs b/osu.Game/Screens/Multiplayer/RoomInspector.cs index 3ed0b78f36..2c9ee9dfe6 100644 --- a/osu.Game/Screens/Multiplayer/RoomInspector.cs +++ b/osu.Game/Screens/Multiplayer/RoomInspector.cs @@ -272,6 +272,7 @@ namespace osu.Game.Screens.Multiplayer nameBind.ValueChanged += displayName; hostBind.ValueChanged += displayUser; + typeBind.ValueChanged += displayGameType; maxParticipantsBind.ValueChanged += displayMaxParticipants; participantsBind.ValueChanged += displayParticipants; } @@ -287,11 +288,9 @@ namespace osu.Game.Screens.Multiplayer //binded here instead of ctor because dependencies are needed statusBind.ValueChanged += displayStatus; - typeBind.ValueChanged += displayGameType; beatmapBind.ValueChanged += displayBeatmap; statusBind.TriggerChange(); - typeBind.TriggerChange(); beatmapBind.TriggerChange(); } @@ -340,7 +339,7 @@ namespace osu.Game.Screens.Multiplayer Origin = Anchor.Centre, FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), - }) { RelativeSizeAxes = Axes.Both } + }) { RelativeSizeAxes = Axes.Both }, }; beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title); From 68915d79a6e4f5c42226815174d06d147aadb670 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 06:03:40 -0300 Subject: [PATCH 28/89] Remove unused fields. --- osu.Game/Screens/Multiplayer/RoomInspector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Multiplayer/RoomInspector.cs b/osu.Game/Screens/Multiplayer/RoomInspector.cs index 2c9ee9dfe6..92bb92fbb9 100644 --- a/osu.Game/Screens/Multiplayer/RoomInspector.cs +++ b/osu.Game/Screens/Multiplayer/RoomInspector.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Multiplayer private const float transition_duration = 100; private readonly Box statusStrip; - private readonly Container coverContainer, rulesetContainer, gameTypeContainer; + private readonly Container coverContainer; private readonly FillFlowContainer topFlow, participantsFlow; private readonly ModeTypeInfo modeTypeInfo; private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor; From 091d786d47546d66260b17eb750a89269599ed10 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 18:37:28 -0300 Subject: [PATCH 29/89] Split long MarginPadding onto multiple lines. --- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index eb66fd3d2a..d1b6b5079b 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -97,7 +97,13 @@ namespace osu.Game.Screens.Multiplayer new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = content_padding, Bottom = content_padding, Left = side_strip_width + cover_width + content_padding, Right = content_padding }, + Padding = new MarginPadding + { + Top = content_padding, + Bottom = content_padding, + Left = side_strip_width + cover_width + content_padding, + Right = content_padding, + }, Children = new Drawable[] { new FillFlowContainer From 5e1cb14e624ccba84795c88762a6aa6aaee69334 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 24 Jun 2017 19:11:02 -0300 Subject: [PATCH 30/89] Use Vertical instead of Top and Bottom. --- osu.Game/Screens/Multiplayer/DrawableRoom.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Multiplayer/DrawableRoom.cs b/osu.Game/Screens/Multiplayer/DrawableRoom.cs index d1b6b5079b..b88341bee1 100644 --- a/osu.Game/Screens/Multiplayer/DrawableRoom.cs +++ b/osu.Game/Screens/Multiplayer/DrawableRoom.cs @@ -99,8 +99,7 @@ namespace osu.Game.Screens.Multiplayer RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { - Top = content_padding, - Bottom = content_padding, + Vertical = content_padding, Left = side_strip_width + cover_width + content_padding, Right = content_padding, }, From b105d6d7415956e68ab3c2679e445c2899393ed5 Mon Sep 17 00:00:00 2001 From: Vlad K Date: Tue, 27 Jun 2017 02:10:00 +0300 Subject: [PATCH 31/89] Insert icon into osu exe --- osu.Desktop/OsuGameDesktop.cs | 3 ++- osu.Desktop/osu.Desktop.csproj | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 299f64d998..536fe40c6a 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -12,6 +12,7 @@ using System.Drawing; using System.IO; using System.Threading.Tasks; using osu.Game.Screens.Menu; +using System.Resources; namespace osu.Desktop { @@ -45,7 +46,7 @@ namespace osu.Desktop { desktopWindow.CursorState |= CursorState.Hidden; - desktopWindow.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); + desktopWindow.Icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream(this.GetType(), "lazer.ico")); desktopWindow.Title = Name; desktopWindow.DragEnter += dragEnter; diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 5ac888b515..e69603602c 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -232,7 +232,7 @@ - +