From ab0bb8b678c0d0a34845a40bf7b19cb53009eeeb Mon Sep 17 00:00:00 2001 From: naoey Date: Wed, 12 Jun 2019 01:31:57 +0530 Subject: [PATCH 01/15] Implement replay downloading with ArchiveDownloadModelManager --- .../API/Requests/DownloadReplayRequest.cs | 13 +++++ .../Requests/Responses/APILegacyScoreInfo.cs | 5 +- osu.Game/OsuGameBase.cs | 2 +- osu.Game/Scoring/ScoreInfo.cs | 4 +- osu.Game/Scoring/ScoreManager.cs | 10 ++-- osu.Game/Screens/Play/ReplayDownloadButton.cs | 53 +++++++++++++++++++ osu.Game/Screens/Play/SoloResults.cs | 22 ++++++++ 7 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 osu.Game/Online/API/Requests/DownloadReplayRequest.cs create mode 100644 osu.Game/Screens/Play/ReplayDownloadButton.cs diff --git a/osu.Game/Online/API/Requests/DownloadReplayRequest.cs b/osu.Game/Online/API/Requests/DownloadReplayRequest.cs new file mode 100644 index 0000000000..11747f4f5f --- /dev/null +++ b/osu.Game/Online/API/Requests/DownloadReplayRequest.cs @@ -0,0 +1,13 @@ +using osu.Game.Scoring; +namespace osu.Game.Online.API.Requests +{ + public class DownloadReplayRequest : ArchiveDownloadModelRequest + { + public DownloadReplayRequest(ScoreInfo score) + : base(score) + { + } + + protected override string Target => $@"scores/{Info.Ruleset.ShortName}/{Info.OnlineScoreID}/download"; + } +} diff --git a/osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs b/osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs index 3060300077..5a18cf63f9 100644 --- a/osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs +++ b/osu.Game/Online/API/Requests/Responses/APILegacyScoreInfo.cs @@ -32,12 +32,15 @@ namespace osu.Game.Online.API.Requests.Responses set => User = value; } - [JsonProperty(@"score_id")] + [JsonProperty(@"id")] private long onlineScoreID { set => OnlineScoreID = value; } + [JsonProperty(@"replay")] + public bool Replay { get; set; } + [JsonProperty(@"created_at")] private DateTimeOffset date { diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 3bdf37d769..f589ba8a5a 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -170,7 +170,7 @@ namespace osu.Game dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage)); // ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup() - dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Host.Storage, contextFactory, Host)); + dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Host.Storage, API, contextFactory, Host)); dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, contextFactory, RulesetStore, API, Audio, Host, defaultBeatmap)); // this should likely be moved to ArchiveModelManager when another case appers where it is necessary diff --git a/osu.Game/Scoring/ScoreInfo.cs b/osu.Game/Scoring/ScoreInfo.cs index 8bdc30ac94..266725a739 100644 --- a/osu.Game/Scoring/ScoreInfo.cs +++ b/osu.Game/Scoring/ScoreInfo.cs @@ -16,7 +16,7 @@ using osu.Game.Rulesets.Scoring; namespace osu.Game.Scoring { - public class ScoreInfo : IHasFiles, IHasPrimaryKey, ISoftDelete + public class ScoreInfo : IHasFiles, IHasPrimaryKey, ISoftDelete, IEquatable { public int ID { get; set; } @@ -182,5 +182,7 @@ namespace osu.Game.Scoring } public override string ToString() => $"{User} playing {Beatmap}"; + + public bool Equals(ScoreInfo other) => other?.OnlineScoreID == OnlineScoreID; } } diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index 6b737dc734..6d2ade5ecd 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -11,12 +11,14 @@ using osu.Framework.Platform; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.IO.Archives; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; using osu.Game.Rulesets; using osu.Game.Scoring.Legacy; namespace osu.Game.Scoring { - public class ScoreManager : ArchiveModelManager + public class ScoreManager : ArchiveDownloadModelManager { public override string[] HandledExtensions => new[] { ".osr" }; @@ -27,8 +29,8 @@ namespace osu.Game.Scoring private readonly RulesetStore rulesets; private readonly Func beatmaps; - public ScoreManager(RulesetStore rulesets, Func beatmaps, Storage storage, IDatabaseContextFactory contextFactory, IIpcHost importHost = null) - : base(storage, contextFactory, new ScoreStore(contextFactory, storage), importHost) + public ScoreManager(RulesetStore rulesets, Func beatmaps, Storage storage, IAPIProvider api, IDatabaseContextFactory contextFactory, IIpcHost importHost = null) + : base(storage, contextFactory, api, new ScoreStore(contextFactory, storage), importHost) { this.rulesets = rulesets; this.beatmaps = beatmaps; @@ -60,5 +62,7 @@ namespace osu.Game.Scoring public IEnumerable QueryScores(Expression> query) => ModelStore.ConsumableItems.AsNoTracking().Where(query); public ScoreInfo Query(Expression> query) => ModelStore.ConsumableItems.AsNoTracking().FirstOrDefault(query); + + protected override ArchiveDownloadModelRequest CreateDownloadRequest(ScoreInfo score, object[] options) => new DownloadReplayRequest(score); } } diff --git a/osu.Game/Screens/Play/ReplayDownloadButton.cs b/osu.Game/Screens/Play/ReplayDownloadButton.cs new file mode 100644 index 0000000000..14a6f942eb --- /dev/null +++ b/osu.Game/Screens/Play/ReplayDownloadButton.cs @@ -0,0 +1,53 @@ +using osu.Framework.Allocation; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online; +using osu.Game.Scoring; + +namespace osu.Game.Screens.Play +{ + public class ReplayDownloadButton : DownloadTrackingComposite + { + [Resolved] + private OsuGame game { get; set; } + + [Resolved] + private ScoreManager scores { get; set; } + + public ReplayDownloadButton(ScoreInfo score) + : base(score) + { + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AddInternal(new TwoLayerButton + { + BackgroundColour = colours.Yellow, + Icon = FontAwesome.Solid.PlayCircle, + Text = @"Replay", + HoverColour = colours.YellowDark, + Action = onReplay, + }); + } + + private void onReplay() + { + if (scores.IsAvailableLocally(ModelInfo.Value)) + { + game.PresentScore(ModelInfo.Value); + return; + } + + scores.Download(ModelInfo.Value); + + scores.ItemAdded += (score, _) => + { + if (score.Equals(ModelInfo.Value)) + game.PresentScore(ModelInfo.Value); + }; + } + } +} diff --git a/osu.Game/Screens/Play/SoloResults.cs b/osu.Game/Screens/Play/SoloResults.cs index 2b9aec257c..5c747d2d31 100644 --- a/osu.Game/Screens/Play/SoloResults.cs +++ b/osu.Game/Screens/Play/SoloResults.cs @@ -2,6 +2,8 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Scoring; using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking.Types; @@ -10,11 +12,31 @@ namespace osu.Game.Screens.Play { public class SoloResults : Results { + [Resolved] + ScoreManager scores { get; set; } + public SoloResults(ScoreInfo score) : base(score) { } + [BackgroundDependencyLoader] + private void load() + { + if (scores.IsAvailableLocally(Score) || hasOnlineReplay) + { + AddInternal(new ReplayDownloadButton(Score) + { + Anchor = Framework.Graphics.Anchor.BottomRight, + Origin = Framework.Graphics.Anchor.BottomRight, + Height = 80, + Width = 100, + }); + } + } + + private bool hasOnlineReplay => Score is APILegacyScoreInfo apiScore && apiScore.OnlineScoreID != null && apiScore.Replay; + protected override IEnumerable CreateResultPages() => new IResultPageInfo[] { new ScoreOverviewPageInfo(Score, Beatmap.Value), From 53d6d74537c67512d7afc57746306fcdf6716243 Mon Sep 17 00:00:00 2001 From: naoey Date: Wed, 26 Jun 2019 21:10:21 +0530 Subject: [PATCH 02/15] Update to match upstream changes --- .../Online/API/Requests/DownloadReplayRequest.cs | 6 ++++-- osu.Game/Scoring/ScoreManager.cs | 4 ++-- osu.Game/Screens/Play/ReplayDownloadButton.cs | 14 ++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/osu.Game/Online/API/Requests/DownloadReplayRequest.cs b/osu.Game/Online/API/Requests/DownloadReplayRequest.cs index 11747f4f5f..0eacb4ed7b 100644 --- a/osu.Game/Online/API/Requests/DownloadReplayRequest.cs +++ b/osu.Game/Online/API/Requests/DownloadReplayRequest.cs @@ -1,13 +1,15 @@ using osu.Game.Scoring; namespace osu.Game.Online.API.Requests { - public class DownloadReplayRequest : ArchiveDownloadModelRequest + public class DownloadReplayRequest : ArchiveDownloadRequest { public DownloadReplayRequest(ScoreInfo score) : base(score) { } - protected override string Target => $@"scores/{Info.Ruleset.ShortName}/{Info.OnlineScoreID}/download"; + protected override string FileExtension => ".osr"; + + protected override string Target => $@"scores/{Model.Ruleset.ShortName}/{Model.OnlineScoreID}/download"; } } diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index 6d2ade5ecd..33be8c41ef 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -18,7 +18,7 @@ using osu.Game.Scoring.Legacy; namespace osu.Game.Scoring { - public class ScoreManager : ArchiveDownloadModelManager + public class ScoreManager : DownloadableArchiveModelManager { public override string[] HandledExtensions => new[] { ".osr" }; @@ -63,6 +63,6 @@ namespace osu.Game.Scoring public ScoreInfo Query(Expression> query) => ModelStore.ConsumableItems.AsNoTracking().FirstOrDefault(query); - protected override ArchiveDownloadModelRequest CreateDownloadRequest(ScoreInfo score, object[] options) => new DownloadReplayRequest(score); + protected override ArchiveDownloadRequest CreateDownloadRequest(ScoreInfo score, bool minimiseDownload) => new DownloadReplayRequest(score); } } diff --git a/osu.Game/Screens/Play/ReplayDownloadButton.cs b/osu.Game/Screens/Play/ReplayDownloadButton.cs index 14a6f942eb..51061e0660 100644 --- a/osu.Game/Screens/Play/ReplayDownloadButton.cs +++ b/osu.Game/Screens/Play/ReplayDownloadButton.cs @@ -35,18 +35,20 @@ namespace osu.Game.Screens.Play private void onReplay() { - if (scores.IsAvailableLocally(ModelInfo.Value)) + if (scores.IsAvailableLocally(Model.Value)) { - game.PresentScore(ModelInfo.Value); + game.PresentScore(Model.Value); return; } - scores.Download(ModelInfo.Value); + scores.Download(Model.Value); - scores.ItemAdded += (score, _) => + scores.ItemAdded += score => { - if (score.Equals(ModelInfo.Value)) - game.PresentScore(ModelInfo.Value); + if (score.Equals(Model.Value)) + // use the newly added score instead of ModelInfo.Score because that won't have the Files property populated + game.PresentScore(score); + //ReplayLoaded?.Invoke(scores.GetScore(score)); }; } } From bc52f765567a4954d116c140368a09f25b7cd149 Mon Sep 17 00:00:00 2001 From: naoey Date: Sat, 29 Jun 2019 10:55:30 +0530 Subject: [PATCH 03/15] Move replay button to score card --- .../Gameplay/TestSceneReplayDownloadButton.cs | 49 ++++++ osu.Game/Online/DownloadTrackingComposite.cs | 9 + osu.Game/Scoring/ScoreManager.cs | 2 + osu.Game/Screens/Play/ReplayDownloadButton.cs | 154 ++++++++++++++---- osu.Game/Screens/Play/SoloResults.cs | 17 -- .../Screens/Ranking/Pages/ScoreResultsPage.cs | 15 +- 6 files changed, 195 insertions(+), 51 deletions(-) create mode 100644 osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs new file mode 100644 index 0000000000..205d869efe --- /dev/null +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs @@ -0,0 +1,49 @@ +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Game.Online.API.Requests.Responses; +using osu.Game.Rulesets.Osu; +using osu.Game.Scoring; +using osu.Game.Screens.Play; +using osu.Game.Users; +using osuTK; +using System; +using System.Collections.Generic; + +namespace osu.Game.Tests.Visual.Gameplay +{ + [TestFixture] + public class TestSceneReplayDownloadButton : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(ReplayDownloadButton) + }; + + private ReplayDownloadButton downloadButton; + + public TestSceneReplayDownloadButton() + { + Add(new ReplayDownloadButton(getScoreInfo()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }); + } + + private ScoreInfo getScoreInfo() + { + return new APILegacyScoreInfo + { + ID = 1, + OnlineScoreID = 2553163309, + Ruleset = new OsuRuleset().RulesetInfo, + Replay = true, + User = new User + { + Id = 39828, + Username = @"WubWoofWolf", + } + }; + } + } +} diff --git a/osu.Game/Online/DownloadTrackingComposite.cs b/osu.Game/Online/DownloadTrackingComposite.cs index 5eb2bb74bb..f0375335da 100644 --- a/osu.Game/Online/DownloadTrackingComposite.cs +++ b/osu.Game/Online/DownloadTrackingComposite.cs @@ -54,6 +54,12 @@ namespace osu.Game.Online attachDownload(download); }; + manager.DownloadFailed += download => + { + if (download.Model.Equals(Model.Value)) + attachDownload(null); + }; + manager.ItemAdded += itemAdded; manager.ItemRemoved += itemRemoved; } @@ -109,6 +115,9 @@ namespace osu.Game.Online if (!s.Equals(Model.Value)) return; + // when model states are being updated from manager, update the model being held by us also so that it will + // be up do date when being consumed for reading files etc. + Model.Value = s; State.Value = state; }); diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index 33be8c41ef..2d82987da0 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -64,5 +64,7 @@ namespace osu.Game.Scoring public ScoreInfo Query(Expression> query) => ModelStore.ConsumableItems.AsNoTracking().FirstOrDefault(query); protected override ArchiveDownloadRequest CreateDownloadRequest(ScoreInfo score, bool minimiseDownload) => new DownloadReplayRequest(score); + + protected override bool CheckLocalAvailability(ScoreInfo model, IQueryable items) => items.Any(s => s.OnlineScoreID == model.OnlineScoreID); } } diff --git a/osu.Game/Screens/Play/ReplayDownloadButton.cs b/osu.Game/Screens/Play/ReplayDownloadButton.cs index 51061e0660..f56246e615 100644 --- a/osu.Game/Screens/Play/ReplayDownloadButton.cs +++ b/osu.Game/Screens/Play/ReplayDownloadButton.cs @@ -1,55 +1,147 @@ using osu.Framework.Allocation; -using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Graphics.UserInterface; +using osu.Game.Graphics.Containers; using osu.Game.Online; using osu.Game.Scoring; +using osuTK; +using osu.Framework.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; +using osu.Framework.Graphics.Effects; +using osuTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; namespace osu.Game.Screens.Play { - public class ReplayDownloadButton : DownloadTrackingComposite + public class ReplayDownloadButton : DownloadTrackingComposite, IHasTooltip { - [Resolved] + private const int size = 40; + + [Resolved(canBeNull: true)] private OsuGame game { get; set; } [Resolved] private ScoreManager scores { get; set; } + [Resolved] + private OsuColour colours { get; set; } + + private OsuClickableContainer button; + private SpriteIcon downloadIcon; + private SpriteIcon playIcon; + private ShakeContainer shakeContainer; + + public string TooltipText + { + get + { + if (scores.IsAvailableLocally(Model.Value)) + return @"Watch replay"; + + if (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) + return @"Download replay"; + + return @"Replay unavailable"; + } + } + public ReplayDownloadButton(ScoreInfo score) : base(score) { + Size = new Vector2(size); + CornerRadius = size / 2; + Masking = true; } - [BackgroundDependencyLoader] - private void load(OsuColour colours) + private bool hasReplay => (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) || scores.IsAvailableLocally(Model.Value); + + [BackgroundDependencyLoader(true)] + private void load() { - AddInternal(new TwoLayerButton + EdgeEffect = new EdgeEffectParameters { - BackgroundColour = colours.Yellow, - Icon = FontAwesome.Solid.PlayCircle, - Text = @"Replay", - HoverColour = colours.YellowDark, - Action = onReplay, - }); - } - - private void onReplay() - { - if (scores.IsAvailableLocally(Model.Value)) - { - game.PresentScore(Model.Value); - return; - } - - scores.Download(Model.Value); - - scores.ItemAdded += score => - { - if (score.Equals(Model.Value)) - // use the newly added score instead of ModelInfo.Score because that won't have the Files property populated - game.PresentScore(score); - //ReplayLoaded?.Invoke(scores.GetScore(score)); + Colour = Color4.Black.Opacity(0.4f), + Type = EdgeEffectType.Shadow, + Radius = 5, }; + + InternalChild = shakeContainer = new ShakeContainer + { + RelativeSizeAxes = Axes.Both, + Child = button = new OsuClickableContainer + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colours.GrayF, + }, + playIcon = new SpriteIcon + { + Icon = FontAwesome.Solid.Play, + Size = Vector2.Zero, + Colour = colours.Gray3, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + downloadIcon = new SpriteIcon + { + Icon = FontAwesome.Solid.FileDownload, + Size = Vector2.Zero, + Colour = colours.Gray3, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + }, + } + }; + + button.Action = () => + { + switch (State.Value) + { + case DownloadState.LocallyAvailable: + game.PresentScore(Model.Value); + break; + + case DownloadState.NotDownloaded: + scores.Download(Model.Value); + break; + + case DownloadState.Downloading: + shakeContainer.Shake(); + break; + } + }; + + State.BindValueChanged(state => + { + switch (state.NewValue) + { + case DownloadState.Downloading: + FadeEdgeEffectTo(colours.Yellow, 400, Easing.OutQuint); + button.Enabled.Value = false; + break; + + case DownloadState.LocallyAvailable: + playIcon.ResizeTo(13, 300, Easing.OutQuint); + downloadIcon.ResizeTo(Vector2.Zero, 300, Easing.OutExpo); + FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint); + button.Enabled.Value = true; + break; + + case DownloadState.NotDownloaded: + playIcon.ResizeTo(Vector2.Zero, 300, Easing.OutQuint); + downloadIcon.ResizeTo(13, 300, Easing.OutExpo); + FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint); + button.Enabled.Value = true; + break; + } + }, true); } } } diff --git a/osu.Game/Screens/Play/SoloResults.cs b/osu.Game/Screens/Play/SoloResults.cs index 5c747d2d31..e8f4a7e182 100644 --- a/osu.Game/Screens/Play/SoloResults.cs +++ b/osu.Game/Screens/Play/SoloResults.cs @@ -20,23 +20,6 @@ namespace osu.Game.Screens.Play { } - [BackgroundDependencyLoader] - private void load() - { - if (scores.IsAvailableLocally(Score) || hasOnlineReplay) - { - AddInternal(new ReplayDownloadButton(Score) - { - Anchor = Framework.Graphics.Anchor.BottomRight, - Origin = Framework.Graphics.Anchor.BottomRight, - Height = 80, - Width = 100, - }); - } - } - - private bool hasOnlineReplay => Score is APILegacyScoreInfo apiScore && apiScore.OnlineScoreID != null && apiScore.Replay; - protected override IEnumerable CreateResultPages() => new IResultPageInfo[] { new ScoreOverviewPageInfo(Score, Beatmap.Value), diff --git a/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs b/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs index a82156e34e..3068fd77e8 100644 --- a/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs +++ b/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs @@ -33,9 +33,12 @@ namespace osu.Game.Screens.Ranking.Pages private Container scoreContainer; private ScoreCounter scoreCounter; + private readonly ScoreInfo score; + public ScoreResultsPage(ScoreInfo score, WorkingBeatmap beatmap) : base(score, beatmap) { + this.score = score; } private FillFlowContainer statisticsContainer; @@ -163,9 +166,15 @@ namespace osu.Game.Screens.Ranking.Pages Direction = FillDirection.Horizontal, LayoutDuration = 200, LayoutEasing = Easing.OutQuint - } - } - } + }, + }, + }, + new ReplayDownloadButton(score) + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + Margin = new MarginPadding { Bottom = 10 }, + }, }; statisticsContainer.ChildrenEnumerable = Score.Statistics.OrderByDescending(p => p.Key).Select(s => new DrawableScoreStatistic(s)); From f9316bc038f8e68d030cc3bf0af7654a945bc407 Mon Sep 17 00:00:00 2001 From: naoey Date: Sat, 29 Jun 2019 11:09:39 +0530 Subject: [PATCH 04/15] Hack fix for models not updating correctly when added in DB --- osu.Game/Online/DownloadTrackingComposite.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Online/DownloadTrackingComposite.cs b/osu.Game/Online/DownloadTrackingComposite.cs index f0375335da..3d230c5475 100644 --- a/osu.Game/Online/DownloadTrackingComposite.cs +++ b/osu.Game/Online/DownloadTrackingComposite.cs @@ -117,6 +117,8 @@ namespace osu.Game.Online // when model states are being updated from manager, update the model being held by us also so that it will // be up do date when being consumed for reading files etc. + // the value -> null -> value change is to force the bindable to update the value instance + Model.Value = null; Model.Value = s; State.Value = state; }); From 424711d24be8ef4d0fa7175e659079178bc51847 Mon Sep 17 00:00:00 2001 From: naoey Date: Sat, 29 Jun 2019 12:26:37 +0530 Subject: [PATCH 05/15] Fix replay button shake container - Add license headers - Slightly reduce bottom margin of button in score screen --- .../Gameplay/TestSceneReplayDownloadButton.cs | 27 +++++- osu.Game/Screens/Play/ReplayDownloadButton.cs | 92 ++++++++++--------- .../Screens/Ranking/Pages/ScoreResultsPage.cs | 2 +- 3 files changed, 73 insertions(+), 48 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs index 205d869efe..9c87d4cd79 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs @@ -1,5 +1,9 @@ -using NUnit.Framework; +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; using osu.Framework.Graphics; +using osu.Game.Online; using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets.Osu; using osu.Game.Scoring; @@ -19,11 +23,19 @@ namespace osu.Game.Tests.Visual.Gameplay typeof(ReplayDownloadButton) }; - private ReplayDownloadButton downloadButton; + private TestReplayDownloadButton downloadButton; public TestSceneReplayDownloadButton() { - Add(new ReplayDownloadButton(getScoreInfo()) + createButton(); + AddStep(@"downloading state", () => downloadButton.SetDownloadState(DownloadState.Downloading)); + AddStep(@"locally available state", () => downloadButton.SetDownloadState(DownloadState.LocallyAvailable)); + AddStep(@"not downloaded state", () => downloadButton.SetDownloadState(DownloadState.NotDownloaded)); + } + + private void createButton() + { + AddStep(@"create button", () => Child = downloadButton = new TestReplayDownloadButton(getScoreInfo()) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -45,5 +57,14 @@ namespace osu.Game.Tests.Visual.Gameplay } }; } + + private class TestReplayDownloadButton : ReplayDownloadButton + { + public void SetDownloadState(DownloadState state) => State.Value = state; + + public TestReplayDownloadButton(ScoreInfo score) : base(score) + { + } + } } } diff --git a/osu.Game/Screens/Play/ReplayDownloadButton.cs b/osu.Game/Screens/Play/ReplayDownloadButton.cs index f56246e615..0d6a159523 100644 --- a/osu.Game/Screens/Play/ReplayDownloadButton.cs +++ b/osu.Game/Screens/Play/ReplayDownloadButton.cs @@ -1,4 +1,7 @@ -using osu.Framework.Allocation; +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics; @@ -12,6 +15,7 @@ using osu.Game.Online.API.Requests.Responses; using osu.Framework.Graphics.Effects; using osuTK.Graphics; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics.Containers; namespace osu.Game.Screens.Play { @@ -32,6 +36,7 @@ namespace osu.Game.Screens.Play private SpriteIcon downloadIcon; private SpriteIcon playIcon; private ShakeContainer shakeContainer; + private CircularContainer circle; public string TooltipText { @@ -50,9 +55,7 @@ namespace osu.Game.Screens.Play public ReplayDownloadButton(ScoreInfo score) : base(score) { - Size = new Vector2(size); - CornerRadius = size / 2; - Masking = true; + AutoSizeAxes = Axes.Both; } private bool hasReplay => (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) || scores.IsAvailableLocally(Model.Value); @@ -60,44 +63,48 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader(true)] private void load() { - EdgeEffect = new EdgeEffectParameters - { - Colour = Color4.Black.Opacity(0.4f), - Type = EdgeEffectType.Shadow, - Radius = 5, - }; - InternalChild = shakeContainer = new ShakeContainer { - RelativeSizeAxes = Axes.Both, - Child = button = new OsuClickableContainer + AutoSizeAxes = Axes.Both, + Child = circle = new CircularContainer { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] + Masking = true, + Size = new Vector2(size), + EdgeEffect = new EdgeEffectParameters { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = colours.GrayF, - }, - playIcon = new SpriteIcon - { - Icon = FontAwesome.Solid.Play, - Size = Vector2.Zero, - Colour = colours.Gray3, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, - downloadIcon = new SpriteIcon - { - Icon = FontAwesome.Solid.FileDownload, - Size = Vector2.Zero, - Colour = colours.Gray3, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, + Colour = Color4.Black.Opacity(0.4f), + Type = EdgeEffectType.Shadow, + Radius = 5, }, - } + Child = button = new OsuClickableContainer + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colours.GrayF, + }, + playIcon = new SpriteIcon + { + Icon = FontAwesome.Solid.Play, + Size = Vector2.Zero, + Colour = colours.Gray3, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + downloadIcon = new SpriteIcon + { + Icon = FontAwesome.Solid.FileDownload, + Size = Vector2.Zero, + Colour = colours.Gray3, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, + }, + } + }, }; button.Action = () => @@ -105,7 +112,7 @@ namespace osu.Game.Screens.Play switch (State.Value) { case DownloadState.LocallyAvailable: - game.PresentScore(Model.Value); + game?.PresentScore(Model.Value); break; case DownloadState.NotDownloaded: @@ -123,22 +130,19 @@ namespace osu.Game.Screens.Play switch (state.NewValue) { case DownloadState.Downloading: - FadeEdgeEffectTo(colours.Yellow, 400, Easing.OutQuint); - button.Enabled.Value = false; + circle.FadeEdgeEffectTo(colours.Yellow, 400, Easing.OutQuint); break; case DownloadState.LocallyAvailable: playIcon.ResizeTo(13, 300, Easing.OutQuint); downloadIcon.ResizeTo(Vector2.Zero, 300, Easing.OutExpo); - FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint); - button.Enabled.Value = true; + circle.FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint); break; case DownloadState.NotDownloaded: playIcon.ResizeTo(Vector2.Zero, 300, Easing.OutQuint); downloadIcon.ResizeTo(13, 300, Easing.OutExpo); - FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint); - button.Enabled.Value = true; + circle.FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint); break; } }, true); diff --git a/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs b/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs index 3068fd77e8..676c1e3adf 100644 --- a/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs +++ b/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs @@ -173,7 +173,7 @@ namespace osu.Game.Screens.Ranking.Pages { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - Margin = new MarginPadding { Bottom = 10 }, + Margin = new MarginPadding { Bottom = 5 }, }, }; From 7d9e21574477ab4fb4818fa66a82841dbe6a6563 Mon Sep 17 00:00:00 2001 From: naoey Date: Sat, 29 Jun 2019 12:29:12 +0530 Subject: [PATCH 06/15] Code quality fixes --- .../Visual/Gameplay/TestSceneReplayDownloadButton.cs | 4 ++-- osu.Game/Online/API/Requests/DownloadReplayRequest.cs | 6 +++++- osu.Game/Screens/Play/SoloResults.cs | 5 ----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs index 9c87d4cd79..0be848f1d5 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs @@ -9,7 +9,6 @@ using osu.Game.Rulesets.Osu; using osu.Game.Scoring; using osu.Game.Screens.Play; using osu.Game.Users; -using osuTK; using System; using System.Collections.Generic; @@ -62,7 +61,8 @@ namespace osu.Game.Tests.Visual.Gameplay { public void SetDownloadState(DownloadState state) => State.Value = state; - public TestReplayDownloadButton(ScoreInfo score) : base(score) + public TestReplayDownloadButton(ScoreInfo score) + : base(score) { } } diff --git a/osu.Game/Online/API/Requests/DownloadReplayRequest.cs b/osu.Game/Online/API/Requests/DownloadReplayRequest.cs index 0eacb4ed7b..6fd052653d 100644 --- a/osu.Game/Online/API/Requests/DownloadReplayRequest.cs +++ b/osu.Game/Online/API/Requests/DownloadReplayRequest.cs @@ -1,4 +1,8 @@ -using osu.Game.Scoring; +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Scoring; + namespace osu.Game.Online.API.Requests { public class DownloadReplayRequest : ArchiveDownloadRequest diff --git a/osu.Game/Screens/Play/SoloResults.cs b/osu.Game/Screens/Play/SoloResults.cs index e8f4a7e182..2b9aec257c 100644 --- a/osu.Game/Screens/Play/SoloResults.cs +++ b/osu.Game/Screens/Play/SoloResults.cs @@ -2,8 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; -using osu.Framework.Allocation; -using osu.Game.Online.API.Requests.Responses; using osu.Game.Scoring; using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking.Types; @@ -12,9 +10,6 @@ namespace osu.Game.Screens.Play { public class SoloResults : Results { - [Resolved] - ScoreManager scores { get; set; } - public SoloResults(ScoreInfo score) : base(score) { From d8f6bbc90e2648f6059b8cb9790d16390ff993e4 Mon Sep 17 00:00:00 2001 From: naoey Date: Sat, 29 Jun 2019 12:49:03 +0530 Subject: [PATCH 07/15] Disable replay button when replay is unavailable --- .../Gameplay/TestSceneReplayDownloadButton.cs | 18 +++++---- osu.Game/Screens/Play/ReplayDownloadButton.cs | 40 +++++++++++++++---- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs index 0be848f1d5..e71b2d596e 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs @@ -26,29 +26,33 @@ namespace osu.Game.Tests.Visual.Gameplay public TestSceneReplayDownloadButton() { - createButton(); + createButton(true); AddStep(@"downloading state", () => downloadButton.SetDownloadState(DownloadState.Downloading)); AddStep(@"locally available state", () => downloadButton.SetDownloadState(DownloadState.LocallyAvailable)); AddStep(@"not downloaded state", () => downloadButton.SetDownloadState(DownloadState.NotDownloaded)); + createButton(false); } - private void createButton() + private void createButton(bool withReplay) { - AddStep(@"create button", () => Child = downloadButton = new TestReplayDownloadButton(getScoreInfo()) + AddStep(withReplay ? @"create button with replay" : "create button without replay", () => { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, + Child = downloadButton = new TestReplayDownloadButton(getScoreInfo(withReplay)) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }; }); } - private ScoreInfo getScoreInfo() + private ScoreInfo getScoreInfo(bool replayAvailable) { return new APILegacyScoreInfo { ID = 1, OnlineScoreID = 2553163309, Ruleset = new OsuRuleset().RulesetInfo, - Replay = true, + Replay = replayAvailable, User = new User { Id = 39828, diff --git a/osu.Game/Screens/Play/ReplayDownloadButton.cs b/osu.Game/Screens/Play/ReplayDownloadButton.cs index 0d6a159523..d6ded27cdf 100644 --- a/osu.Game/Screens/Play/ReplayDownloadButton.cs +++ b/osu.Game/Screens/Play/ReplayDownloadButton.cs @@ -42,13 +42,17 @@ namespace osu.Game.Screens.Play { get { - if (scores.IsAvailableLocally(Model.Value)) - return @"Watch replay"; + switch (getReplayAvailability()) + { + case ReplayAvailability.Local: + return @"Watch replay"; - if (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) - return @"Download replay"; + case ReplayAvailability.Online: + return @"Download replay"; - return @"Replay unavailable"; + default: + return @"Replay unavailable"; + } } } @@ -58,8 +62,6 @@ namespace osu.Game.Screens.Play AutoSizeAxes = Axes.Both; } - private bool hasReplay => (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) || scores.IsAvailableLocally(Model.Value); - [BackgroundDependencyLoader(true)] private void load() { @@ -146,6 +148,30 @@ namespace osu.Game.Screens.Play break; } }, true); + + if (getReplayAvailability() == ReplayAvailability.NotAvailable) + { + button.Enabled.Value = false; + button.Alpha = 0.6f; + } + } + + private ReplayAvailability getReplayAvailability() + { + if (scores.IsAvailableLocally(Model.Value)) + return ReplayAvailability.Local; + + if (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) + return ReplayAvailability.Online; + + return ReplayAvailability.NotAvailable; + } + + private enum ReplayAvailability + { + Local, + Online, + NotAvailable, } } } From 6c81d5717849b41fa1f50dcb6c793659246378c6 Mon Sep 17 00:00:00 2001 From: naoey Date: Sat, 29 Jun 2019 16:08:48 +0530 Subject: [PATCH 08/15] Remove hacks for updating model info - Re-retrieve score from database when presenting scores --- osu.Game/Online/DownloadTrackingComposite.cs | 5 ----- osu.Game/OsuGame.cs | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/osu.Game/Online/DownloadTrackingComposite.cs b/osu.Game/Online/DownloadTrackingComposite.cs index 3d230c5475..786afdf450 100644 --- a/osu.Game/Online/DownloadTrackingComposite.cs +++ b/osu.Game/Online/DownloadTrackingComposite.cs @@ -115,11 +115,6 @@ namespace osu.Game.Online if (!s.Equals(Model.Value)) return; - // when model states are being updated from manager, update the model being held by us also so that it will - // be up do date when being consumed for reading files etc. - // the value -> null -> value change is to force the bindable to update the value instance - Model.Value = null; - Model.Value = s; State.Value = state; }); diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index f7f2e1b451..0d1fc704f1 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -261,8 +261,8 @@ namespace osu.Game /// public void PresentScore(ScoreInfo score) { - var databasedScore = ScoreManager.GetScore(score); - var databasedScoreInfo = databasedScore.ScoreInfo; + var databasedScoreInfo = ScoreManager.Query(s => s.OnlineScoreID == score.OnlineScoreID); + var databasedScore = ScoreManager.GetScore(databasedScoreInfo); if (databasedScore.Replay == null) { From 04c467fd812153d9733fcb2a4ca0c63e60af3daa Mon Sep 17 00:00:00 2001 From: naoey Date: Sat, 29 Jun 2019 16:10:16 +0530 Subject: [PATCH 09/15] Add comment --- osu.Game/OsuGame.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 0d1fc704f1..12291c430e 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -261,6 +261,8 @@ namespace osu.Game /// public void PresentScore(ScoreInfo score) { + // The given ScoreInfo may have missing properties if it was retrieved from online data. Re-retrieve it from the database + // to ensure all the required data for presenting a replay are present. var databasedScoreInfo = ScoreManager.Query(s => s.OnlineScoreID == score.OnlineScoreID); var databasedScore = ScoreManager.GetScore(databasedScoreInfo); From bfcbb47b77daef12d4cb703c50954f600d9f20d4 Mon Sep 17 00:00:00 2001 From: naoey Date: Sun, 30 Jun 2019 10:56:20 +0530 Subject: [PATCH 10/15] Clean up some more leftover code --- osu.Game/Screens/Play/ReplayDownloadButton.cs | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/osu.Game/Screens/Play/ReplayDownloadButton.cs b/osu.Game/Screens/Play/ReplayDownloadButton.cs index d6ded27cdf..d715f17109 100644 --- a/osu.Game/Screens/Play/ReplayDownloadButton.cs +++ b/osu.Game/Screens/Play/ReplayDownloadButton.cs @@ -21,17 +21,9 @@ namespace osu.Game.Screens.Play { public class ReplayDownloadButton : DownloadTrackingComposite, IHasTooltip { - private const int size = 40; - - [Resolved(canBeNull: true)] - private OsuGame game { get; set; } - [Resolved] private ScoreManager scores { get; set; } - [Resolved] - private OsuColour colours { get; set; } - private OsuClickableContainer button; private SpriteIcon downloadIcon; private SpriteIcon playIcon; @@ -42,7 +34,7 @@ namespace osu.Game.Screens.Play { get { - switch (getReplayAvailability()) + switch (replayAvailability) { case ReplayAvailability.Local: return @"Watch replay"; @@ -56,6 +48,20 @@ namespace osu.Game.Screens.Play } } + private ReplayAvailability replayAvailability + { + get + { + if (scores.IsAvailableLocally(Model.Value)) + return ReplayAvailability.Local; + + if (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) + return ReplayAvailability.Online; + + return ReplayAvailability.NotAvailable; + } + } + public ReplayDownloadButton(ScoreInfo score) : base(score) { @@ -63,7 +69,7 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader(true)] - private void load() + private void load(OsuGame game, OsuColour colours) { InternalChild = shakeContainer = new ShakeContainer { @@ -71,7 +77,7 @@ namespace osu.Game.Screens.Play Child = circle = new CircularContainer { Masking = true, - Size = new Vector2(size), + Size = new Vector2(40), EdgeEffect = new EdgeEffectParameters { Colour = Color4.Black.Opacity(0.4f), @@ -132,41 +138,32 @@ namespace osu.Game.Screens.Play switch (state.NewValue) { case DownloadState.Downloading: + playIcon.ResizeTo(Vector2.Zero, 400, Easing.OutQuint); + downloadIcon.ResizeTo(13, 400, Easing.OutQuint); circle.FadeEdgeEffectTo(colours.Yellow, 400, Easing.OutQuint); break; case DownloadState.LocallyAvailable: - playIcon.ResizeTo(13, 300, Easing.OutQuint); - downloadIcon.ResizeTo(Vector2.Zero, 300, Easing.OutExpo); + playIcon.ResizeTo(13, 400, Easing.OutQuint); + downloadIcon.ResizeTo(Vector2.Zero, 400, Easing.OutQuint); circle.FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint); break; case DownloadState.NotDownloaded: - playIcon.ResizeTo(Vector2.Zero, 300, Easing.OutQuint); - downloadIcon.ResizeTo(13, 300, Easing.OutExpo); + playIcon.ResizeTo(Vector2.Zero, 400, Easing.OutQuint); + downloadIcon.ResizeTo(13, 400, Easing.OutQuint); circle.FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint); break; } }, true); - if (getReplayAvailability() == ReplayAvailability.NotAvailable) + if (replayAvailability == ReplayAvailability.NotAvailable) { button.Enabled.Value = false; button.Alpha = 0.6f; } } - private ReplayAvailability getReplayAvailability() - { - if (scores.IsAvailableLocally(Model.Value)) - return ReplayAvailability.Local; - - if (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) - return ReplayAvailability.Online; - - return ReplayAvailability.NotAvailable; - } - private enum ReplayAvailability { Local, From ee516d2515c47a3b7728805b6b7f3c8332afb528 Mon Sep 17 00:00:00 2001 From: naoey Date: Tue, 2 Jul 2019 15:55:30 +0530 Subject: [PATCH 11/15] Make direct panel download and replay buttons share UI --- .../Gameplay/TestSceneReplayDownloadButton.cs | 2 + .../UserInterface/OsuDownloadButton.cs | 87 ++++++++++++++ osu.Game/Overlays/Direct/DownloadButton.cs | 61 ++-------- osu.Game/Screens/Play/ReplayDownloadButton.cs | 108 ++++-------------- .../Screens/Ranking/Pages/ScoreResultsPage.cs | 3 +- 5 files changed, 119 insertions(+), 142 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/OsuDownloadButton.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs index e71b2d596e..0dfcda122f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneReplayDownloadButton.cs @@ -9,6 +9,7 @@ using osu.Game.Rulesets.Osu; using osu.Game.Scoring; using osu.Game.Screens.Play; using osu.Game.Users; +using osuTK; using System; using System.Collections.Generic; @@ -41,6 +42,7 @@ namespace osu.Game.Tests.Visual.Gameplay { Anchor = Anchor.Centre, Origin = Anchor.Centre, + Size = new Vector2(80, 40), }; }); } diff --git a/osu.Game/Graphics/UserInterface/OsuDownloadButton.cs b/osu.Game/Graphics/UserInterface/OsuDownloadButton.cs new file mode 100644 index 0000000000..6e95c7e291 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/OsuDownloadButton.cs @@ -0,0 +1,87 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Game.Online; +using osuTK; + +namespace osu.Game.Graphics.UserInterface +{ + public class OsuDownloadButton : OsuAnimatedButton + { + public readonly Bindable State = new Bindable(); + + private readonly SpriteIcon icon; + private readonly SpriteIcon checkmark; + private readonly Box background; + + private OsuColour colours; + + public OsuDownloadButton() + { + Children = new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + Depth = float.MaxValue + }, + icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(13), + Icon = FontAwesome.Solid.Download, + }, + checkmark = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + X = 8, + Size = Vector2.Zero, + Icon = FontAwesome.Solid.Check, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + this.colours = colours; + + State.BindValueChanged(updateState, true); + } + + private void updateState(ValueChangedEvent state) + { + switch (state.NewValue) + { + case DownloadState.NotDownloaded: + background.FadeColour(colours.Gray4, 500, Easing.InOutExpo); + icon.MoveToX(0, 500, Easing.InOutExpo); + checkmark.ScaleTo(Vector2.Zero, 500, Easing.InOutExpo); + break; + + case DownloadState.Downloading: + background.FadeColour(colours.Blue, 500, Easing.InOutExpo); + icon.MoveToX(0, 500, Easing.InOutExpo); + checkmark.ScaleTo(Vector2.Zero, 500, Easing.InOutExpo); + break; + + case DownloadState.Downloaded: + background.FadeColour(colours.Yellow, 500, Easing.InOutExpo); + break; + + case DownloadState.LocallyAvailable: + background.FadeColour(colours.Green, 500, Easing.InOutExpo); + icon.MoveToX(-8, 500, Easing.InOutExpo); + checkmark.ScaleTo(new Vector2(13), 500, Easing.InOutExpo); + break; + } + } + } +} diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 81709187e7..9aec7bcd0c 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; @@ -10,7 +10,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Online; -using osuTK; namespace osu.Game.Overlays.Direct { @@ -25,7 +24,7 @@ namespace osu.Game.Overlays.Direct private OsuColour colours; private readonly ShakeContainer shakeContainer; - private readonly OsuAnimatedButton button; + private readonly OsuDownloadButton button; public DownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false) : base(beatmapSet) @@ -35,33 +34,10 @@ namespace osu.Game.Overlays.Direct InternalChild = shakeContainer = new ShakeContainer { RelativeSizeAxes = Axes.Both, - Child = button = new OsuAnimatedButton + Child = button = new OsuDownloadButton { RelativeSizeAxes = Axes.Both, - Children = new Drawable[] - { - background = new Box - { - RelativeSizeAxes = Axes.Both, - Depth = float.MaxValue - }, - icon = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(13), - Icon = FontAwesome.Solid.Download, - }, - checkmark = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - X = 8, - Size = Vector2.Zero, - Icon = FontAwesome.Solid.Check, - } - } - } + }, }; } @@ -69,7 +45,7 @@ namespace osu.Game.Overlays.Direct { base.LoadComplete(); - State.BindValueChanged(state => updateState(state.NewValue), true); + button.State.BindTo(State); FinishTransforms(true); } @@ -105,32 +81,11 @@ namespace osu.Game.Overlays.Direct }; } - private void updateState(DownloadState state) + protected override void Dispose(bool isDisposing) { - switch (state) - { - case DownloadState.NotDownloaded: - background.FadeColour(colours.Gray4, 500, Easing.InOutExpo); - icon.MoveToX(0, 500, Easing.InOutExpo); - checkmark.ScaleTo(Vector2.Zero, 500, Easing.InOutExpo); - break; + base.Dispose(isDisposing); - case DownloadState.Downloading: - background.FadeColour(colours.Blue, 500, Easing.InOutExpo); - icon.MoveToX(0, 500, Easing.InOutExpo); - checkmark.ScaleTo(Vector2.Zero, 500, Easing.InOutExpo); - break; - - case DownloadState.Downloaded: - background.FadeColour(colours.Yellow, 500, Easing.InOutExpo); - break; - - case DownloadState.LocallyAvailable: - background.FadeColour(colours.Green, 500, Easing.InOutExpo); - icon.MoveToX(-8, 500, Easing.InOutExpo); - checkmark.ScaleTo(new Vector2(13), 500, Easing.InOutExpo); - break; - } + button?.State.UnbindAll(); } } } diff --git a/osu.Game/Screens/Play/ReplayDownloadButton.cs b/osu.Game/Screens/Play/ReplayDownloadButton.cs index d715f17109..9655bde36a 100644 --- a/osu.Game/Screens/Play/ReplayDownloadButton.cs +++ b/osu.Game/Screens/Play/ReplayDownloadButton.cs @@ -2,57 +2,28 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Graphics.Cursor; -using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics; -using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Online; using osu.Game.Scoring; -using osuTK; -using osu.Framework.Graphics.Sprites; using osu.Game.Online.API.Requests.Responses; -using osu.Framework.Graphics.Effects; -using osuTK.Graphics; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Screens.Play { - public class ReplayDownloadButton : DownloadTrackingComposite, IHasTooltip + public class ReplayDownloadButton : DownloadTrackingComposite { [Resolved] private ScoreManager scores { get; set; } - private OsuClickableContainer button; - private SpriteIcon downloadIcon; - private SpriteIcon playIcon; + private OsuDownloadButton button; private ShakeContainer shakeContainer; - private CircularContainer circle; - - public string TooltipText - { - get - { - switch (replayAvailability) - { - case ReplayAvailability.Local: - return @"Watch replay"; - - case ReplayAvailability.Online: - return @"Download replay"; - - default: - return @"Replay unavailable"; - } - } - } private ReplayAvailability replayAvailability { get { - if (scores.IsAvailableLocally(Model.Value)) + if (State.Value == DownloadState.LocallyAvailable) return ReplayAvailability.Local; if (Model.Value is APILegacyScoreInfo apiScore && apiScore.Replay) @@ -65,54 +36,18 @@ namespace osu.Game.Screens.Play public ReplayDownloadButton(ScoreInfo score) : base(score) { - AutoSizeAxes = Axes.Both; } [BackgroundDependencyLoader(true)] - private void load(OsuGame game, OsuColour colours) + private void load(OsuGame game) { InternalChild = shakeContainer = new ShakeContainer { - AutoSizeAxes = Axes.Both, - Child = circle = new CircularContainer + RelativeSizeAxes = Axes.Both, + Child = button = new OsuDownloadButton { - Masking = true, - Size = new Vector2(40), - EdgeEffect = new EdgeEffectParameters - { - Colour = Color4.Black.Opacity(0.4f), - Type = EdgeEffectType.Shadow, - Radius = 5, - }, - Child = button = new OsuClickableContainer - { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = colours.GrayF, - }, - playIcon = new SpriteIcon - { - Icon = FontAwesome.Solid.Play, - Size = Vector2.Zero, - Colour = colours.Gray3, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, - downloadIcon = new SpriteIcon - { - Icon = FontAwesome.Solid.FileDownload, - Size = Vector2.Zero, - Colour = colours.Gray3, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }, - }, - } - }, + RelativeSizeAxes = Axes.Both, + } }; button.Action = () => @@ -127,32 +62,29 @@ namespace osu.Game.Screens.Play scores.Download(Model.Value); break; + case DownloadState.Downloaded: case DownloadState.Downloading: shakeContainer.Shake(); break; } }; - State.BindValueChanged(state => + State.BindValueChanged((state) => { - switch (state.NewValue) + button.State.Value = state.NewValue; + + switch (replayAvailability) { - case DownloadState.Downloading: - playIcon.ResizeTo(Vector2.Zero, 400, Easing.OutQuint); - downloadIcon.ResizeTo(13, 400, Easing.OutQuint); - circle.FadeEdgeEffectTo(colours.Yellow, 400, Easing.OutQuint); + case ReplayAvailability.Local: + button.TooltipText = @"Watch replay"; break; - case DownloadState.LocallyAvailable: - playIcon.ResizeTo(13, 400, Easing.OutQuint); - downloadIcon.ResizeTo(Vector2.Zero, 400, Easing.OutQuint); - circle.FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint); + case ReplayAvailability.Online: + button.TooltipText = @"Download replay"; break; - case DownloadState.NotDownloaded: - playIcon.ResizeTo(Vector2.Zero, 400, Easing.OutQuint); - downloadIcon.ResizeTo(13, 400, Easing.OutQuint); - circle.FadeEdgeEffectTo(Color4.Black.Opacity(0.4f), 400, Easing.OutQuint); + default: + button.TooltipText = @"Replay unavailable"; break; } }, true); diff --git a/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs b/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs index 676c1e3adf..7c35742ff6 100644 --- a/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs +++ b/osu.Game/Screens/Ranking/Pages/ScoreResultsPage.cs @@ -173,7 +173,8 @@ namespace osu.Game.Screens.Ranking.Pages { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - Margin = new MarginPadding { Bottom = 5 }, + Margin = new MarginPadding { Bottom = 10 }, + Size = new Vector2(50, 30), }, }; From eaa19d5a49faf44645e824ca48c62651249621d2 Mon Sep 17 00:00:00 2001 From: naoey Date: Tue, 2 Jul 2019 16:13:47 +0530 Subject: [PATCH 12/15] Remove unused/unnecessary fields --- osu.Game/Overlays/Direct/DownloadButton.cs | 10 +--------- osu.Game/Screens/Play/ReplayDownloadButton.cs | 7 ++----- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 9aec7bcd0c..6bac07fc88 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -3,8 +3,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -18,11 +16,7 @@ namespace osu.Game.Overlays.Direct protected bool DownloadEnabled => button.Enabled.Value; private readonly bool noVideo; - private readonly SpriteIcon icon; - private readonly SpriteIcon checkmark; - private readonly Box background; - private OsuColour colours; private readonly ShakeContainer shakeContainer; private readonly OsuDownloadButton button; @@ -50,10 +44,8 @@ namespace osu.Game.Overlays.Direct } [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, OsuGame game, BeatmapManager beatmaps) + private void load(OsuGame game, BeatmapManager beatmaps) { - this.colours = colours; - if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) { button.Enabled.Value = false; diff --git a/osu.Game/Screens/Play/ReplayDownloadButton.cs b/osu.Game/Screens/Play/ReplayDownloadButton.cs index 9655bde36a..5acf4e83d9 100644 --- a/osu.Game/Screens/Play/ReplayDownloadButton.cs +++ b/osu.Game/Screens/Play/ReplayDownloadButton.cs @@ -13,9 +13,6 @@ namespace osu.Game.Screens.Play { public class ReplayDownloadButton : DownloadTrackingComposite { - [Resolved] - private ScoreManager scores { get; set; } - private OsuDownloadButton button; private ShakeContainer shakeContainer; @@ -39,7 +36,7 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader(true)] - private void load(OsuGame game) + private void load(OsuGame game, ScoreManager scores) { InternalChild = shakeContainer = new ShakeContainer { @@ -69,7 +66,7 @@ namespace osu.Game.Screens.Play } }; - State.BindValueChanged((state) => + State.BindValueChanged(state => { button.State.Value = state.NewValue; From 1ff6a9d085da89471a8d608cd4dd72251cef4a52 Mon Sep 17 00:00:00 2001 From: naoey Date: Tue, 2 Jul 2019 16:25:40 +0530 Subject: [PATCH 13/15] Remove unused using --- osu.Game/Overlays/Direct/DownloadButton.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 6bac07fc88..dac1521bf3 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Beatmaps; -using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Online; From 23acddcb562fcdfd6d66e2182177901d1db55595 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Jul 2019 12:02:35 +0900 Subject: [PATCH 14/15] Rename download buttons to avoid ambiguity --- .../Visual/Online/TestSceneBeatmapSetOverlay.cs | 2 +- .../Visual/Online/TestSceneDirectDownloadButton.cs | 4 ++-- .../{OsuDownloadButton.cs => DownloadButton.cs} | 4 ++-- .../{DownloadButton.cs => HeaderDownloadButton.cs} | 4 ++-- osu.Game/Overlays/BeatmapSet/Header.cs | 9 ++++----- osu.Game/Overlays/Direct/DirectGridPanel.cs | 2 +- osu.Game/Overlays/Direct/DirectListPanel.cs | 4 ++-- .../{DownloadButton.cs => PanelDownloadButton.cs} | 10 +++++----- osu.Game/Screens/Play/ReplayDownloadButton.cs | 4 ++-- 9 files changed, 21 insertions(+), 22 deletions(-) rename osu.Game/Graphics/UserInterface/{OsuDownloadButton.cs => DownloadButton.cs} (96%) rename osu.Game/Overlays/BeatmapSet/Buttons/{DownloadButton.cs => HeaderDownloadButton.cs} (97%) rename osu.Game/Overlays/Direct/{DownloadButton.cs => PanelDownloadButton.cs} (86%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index c494f5ef33..a9c44c9020 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.Online typeof(BasicStats), typeof(BeatmapPicker), typeof(Details), - typeof(DownloadButton), + typeof(HeaderDownloadButton), typeof(FavouriteButton), typeof(Header), typeof(HeaderButton), diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs index 5a5833feb6..5b0c2d3c67 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs @@ -20,7 +20,7 @@ namespace osu.Game.Tests.Visual.Online { public override IReadOnlyList RequiredTypes => new[] { - typeof(DownloadButton) + typeof(PanelDownloadButton) }; private TestDownloadButton downloadButton; @@ -143,7 +143,7 @@ namespace osu.Game.Tests.Visual.Online return beatmap; } - private class TestDownloadButton : DownloadButton + private class TestDownloadButton : PanelDownloadButton { public new bool DownloadEnabled => base.DownloadEnabled; diff --git a/osu.Game/Graphics/UserInterface/OsuDownloadButton.cs b/osu.Game/Graphics/UserInterface/DownloadButton.cs similarity index 96% rename from osu.Game/Graphics/UserInterface/OsuDownloadButton.cs rename to osu.Game/Graphics/UserInterface/DownloadButton.cs index 6e95c7e291..41b90d3802 100644 --- a/osu.Game/Graphics/UserInterface/OsuDownloadButton.cs +++ b/osu.Game/Graphics/UserInterface/DownloadButton.cs @@ -11,7 +11,7 @@ using osuTK; namespace osu.Game.Graphics.UserInterface { - public class OsuDownloadButton : OsuAnimatedButton + public class DownloadButton : OsuAnimatedButton { public readonly Bindable State = new Bindable(); @@ -21,7 +21,7 @@ namespace osu.Game.Graphics.UserInterface private OsuColour colours; - public OsuDownloadButton() + public DownloadButton() { Children = new Drawable[] { diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs similarity index 97% rename from osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs rename to osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs index 3e8a5a8324..fe10287491 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs @@ -20,7 +20,7 @@ using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet.Buttons { - public class DownloadButton : BeatmapDownloadTrackingComposite, IHasTooltip + public class HeaderDownloadButton : BeatmapDownloadTrackingComposite, IHasTooltip { private readonly bool noVideo; @@ -31,7 +31,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons private ShakeContainer shakeContainer; private HeaderButton button; - public DownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false) + public HeaderDownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false) : base(beatmapSet) { this.noVideo = noVideo; diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 1c1167d08e..b50eac2c1a 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -18,7 +18,6 @@ using osu.Game.Overlays.BeatmapSet.Buttons; using osu.Game.Overlays.Direct; using osuTK; using osuTK.Graphics; -using DownloadButton = osu.Game.Overlays.BeatmapSet.Buttons.DownloadButton; namespace osu.Game.Overlays.BeatmapSet { @@ -268,7 +267,7 @@ namespace osu.Game.Overlays.BeatmapSet { case DownloadState.LocallyAvailable: // temporary for UX until new design is implemented. - downloadButtonsContainer.Child = new Direct.DownloadButton(BeatmapSet.Value) + downloadButtonsContainer.Child = new PanelDownloadButton(BeatmapSet.Value) { Width = 50, RelativeSizeAxes = Axes.Y @@ -278,13 +277,13 @@ namespace osu.Game.Overlays.BeatmapSet case DownloadState.Downloading: case DownloadState.Downloaded: // temporary to avoid showing two buttons for maps with novideo. will be fixed in new beatmap overlay design. - downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); + downloadButtonsContainer.Child = new HeaderDownloadButton(BeatmapSet.Value); break; default: - downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); + downloadButtonsContainer.Child = new HeaderDownloadButton(BeatmapSet.Value); if (BeatmapSet.Value.OnlineInfo.HasVideo) - downloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true)); + downloadButtonsContainer.Add(new HeaderDownloadButton(BeatmapSet.Value, true)); break; } } diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 5756a4593d..243e79eb9b 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -155,7 +155,7 @@ namespace osu.Game.Overlays.Direct }, }, }, - new DownloadButton(SetInfo) + new PanelDownloadButton(SetInfo) { Size = new Vector2(50, 30), Margin = new MarginPadding(horizontal_padding), diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index 6f3b5bc5f1..5757e1445b 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Direct private const float height = 70; private FillFlowContainer statusContainer; - protected DownloadButton DownloadButton; + protected PanelDownloadButton DownloadButton; private PlayButton playButton; private Box progressBar; @@ -150,7 +150,7 @@ namespace osu.Game.Overlays.Direct Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, AutoSizeAxes = Axes.Both, - Child = DownloadButton = new DownloadButton(SetInfo) + Child = DownloadButton = new PanelDownloadButton(SetInfo) { Size = new Vector2(height - vertical_padding * 3), Margin = new MarginPadding { Left = vertical_padding * 2, Right = vertical_padding }, diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/PanelDownloadButton.cs similarity index 86% rename from osu.Game/Overlays/Direct/DownloadButton.cs rename to osu.Game/Overlays/Direct/PanelDownloadButton.cs index dac1521bf3..017f92abaa 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/PanelDownloadButton.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; @@ -10,16 +10,16 @@ using osu.Game.Online; namespace osu.Game.Overlays.Direct { - public class DownloadButton : BeatmapDownloadTrackingComposite + public class PanelDownloadButton : BeatmapDownloadTrackingComposite { protected bool DownloadEnabled => button.Enabled.Value; private readonly bool noVideo; private readonly ShakeContainer shakeContainer; - private readonly OsuDownloadButton button; + private readonly DownloadButton button; - public DownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false) + public PanelDownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false) : base(beatmapSet) { this.noVideo = noVideo; @@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Direct InternalChild = shakeContainer = new ShakeContainer { RelativeSizeAxes = Axes.Both, - Child = button = new OsuDownloadButton + Child = button = new DownloadButton { RelativeSizeAxes = Axes.Both, }, diff --git a/osu.Game/Screens/Play/ReplayDownloadButton.cs b/osu.Game/Screens/Play/ReplayDownloadButton.cs index 5acf4e83d9..748fe8cc90 100644 --- a/osu.Game/Screens/Play/ReplayDownloadButton.cs +++ b/osu.Game/Screens/Play/ReplayDownloadButton.cs @@ -13,7 +13,7 @@ namespace osu.Game.Screens.Play { public class ReplayDownloadButton : DownloadTrackingComposite { - private OsuDownloadButton button; + private DownloadButton button; private ShakeContainer shakeContainer; private ReplayAvailability replayAvailability @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Play InternalChild = shakeContainer = new ShakeContainer { RelativeSizeAxes = Axes.Both, - Child = button = new OsuDownloadButton + Child = button = new DownloadButton { RelativeSizeAxes = Axes.Both, } From d22a1229cbba13668b9f2abd5b33a220041d9658 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Jul 2019 12:06:20 +0900 Subject: [PATCH 15/15] Remove unnecessary disposal --- osu.Game/Overlays/Direct/PanelDownloadButton.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/osu.Game/Overlays/Direct/PanelDownloadButton.cs b/osu.Game/Overlays/Direct/PanelDownloadButton.cs index 017f92abaa..4037cd46f3 100644 --- a/osu.Game/Overlays/Direct/PanelDownloadButton.cs +++ b/osu.Game/Overlays/Direct/PanelDownloadButton.cs @@ -71,12 +71,5 @@ namespace osu.Game.Overlays.Direct } }; } - - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - - button?.State.UnbindAll(); - } } }