From 55c0c6a1bbffebe94d7a620689e42d3525d3f84a Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 31 May 2019 17:43:58 +0200 Subject: [PATCH 1/9] Show changelog for current build by clicking on settings footer in settings overlay. --- osu.Game/Overlays/Settings/SettingsFooter.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index e8c2c1ffe8..33ad5b101b 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; @@ -17,8 +18,11 @@ namespace osu.Game.Overlays.Settings { public class SettingsFooter : FillFlowContainer { + private OsuGameBase game; + private ChangelogOverlay changelog; + [BackgroundDependencyLoader] - private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets) + private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets, ChangelogOverlay changelog) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -67,6 +71,17 @@ namespace osu.Game.Overlays.Settings Colour = DebugUtils.IsDebug ? colours.Red : Color4.White, }, }; + + this.game = game; + this.changelog = changelog; + } + + protected override bool OnClick(ClickEvent e) + { + if (!game.IsDeployedBuild) return base.OnClick(e); + + changelog?.ShowBuild("lazer", game.Version); + return base.OnClick(e); } } } From 0625f51e65447596f6f1a0a77faf130968958b84 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 31 May 2019 22:42:09 +0200 Subject: [PATCH 2/9] Allow dependencies to be null in certain cases (Unit tests) --- osu.Game/Overlays/Settings/SettingsFooter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 33ad5b101b..317ba2f92d 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Settings private OsuGameBase game; private ChangelogOverlay changelog; - [BackgroundDependencyLoader] + [BackgroundDependencyLoader(true)] private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets, ChangelogOverlay changelog) { RelativeSizeAxes = Axes.X; From 58564579e4f679e64d470eeda0a85dfe6e70b670 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 1 Jun 2019 08:46:38 +0200 Subject: [PATCH 3/9] Invert if statement --- osu.Game/Overlays/Settings/SettingsFooter.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 317ba2f92d..3e0eb6ffde 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -78,10 +78,11 @@ namespace osu.Game.Overlays.Settings protected override bool OnClick(ClickEvent e) { - if (!game.IsDeployedBuild) return base.OnClick(e); - - changelog?.ShowBuild("lazer", game.Version); - return base.OnClick(e); + if (game.IsDeployedBuild) + { + changelog?.ShowBuild("lazer", game.Version); + } + return true; } } } From 0a867e37aff8782cdc97e1e57f41703bfa429312 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 2 Jun 2019 12:40:18 +0200 Subject: [PATCH 4/9] Resolve dependencies via Resolved Attribute --- osu.Game/Overlays/Settings/SettingsFooter.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 3e0eb6ffde..306512802b 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -18,11 +18,14 @@ namespace osu.Game.Overlays.Settings { public class SettingsFooter : FillFlowContainer { - private OsuGameBase game; - private ChangelogOverlay changelog; + [Resolved] + private OsuGameBase game { get; set; } + + [Resolved(CanBeNull = true)] + private ChangelogOverlay changelog { get; set; } [BackgroundDependencyLoader(true)] - private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets, ChangelogOverlay changelog) + private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -71,9 +74,6 @@ namespace osu.Game.Overlays.Settings Colour = DebugUtils.IsDebug ? colours.Red : Color4.White, }, }; - - this.game = game; - this.changelog = changelog; } protected override bool OnClick(ClickEvent e) @@ -82,6 +82,7 @@ namespace osu.Game.Overlays.Settings { changelog?.ShowBuild("lazer", game.Version); } + return true; } } From d8f45f7299dd1531f7b5b485e9feaa6b7a7ba9ba Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 2 Jun 2019 15:17:03 +0200 Subject: [PATCH 5/9] Disallow null references for dependencies loaded via load() --- osu.Game/Overlays/Settings/SettingsFooter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 306512802b..8403f70f49 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Settings [Resolved(CanBeNull = true)] private ChangelogOverlay changelog { get; set; } - [BackgroundDependencyLoader(true)] + [BackgroundDependencyLoader] private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets) { RelativeSizeAxes = Axes.X; From 115a75e4c6604a214316e7e97752547b3610faff Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 13:16:05 +0900 Subject: [PATCH 6/9] Use a constant for lazer variables --- osu.Desktop/Overlays/VersionManager.cs | 2 +- osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs | 2 +- osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs | 2 +- osu.Game/OsuGameBase.cs | 2 ++ osu.Game/Overlays/Settings/SettingsFooter.cs | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index d2aad99f41..5a8cf32f14 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -120,7 +120,7 @@ namespace osu.Desktop.Overlays Activated = delegate { - changelog.ShowBuild("lazer", version); + changelog.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version); return true; }; } diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index d1a7730bee..0655611230 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.Online { Version = "2018.712.0", DisplayVersion = "2018.712.0", - UpdateStream = new APIUpdateStream { Name = "lazer" }, + UpdateStream = new APIUpdateStream { Name = OsuGameBase.CLIENT_STREAM_NAME }, ChangelogEntries = new List { new APIChangelogEntry diff --git a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs index ef204c7687..d9e48373bb 100644 --- a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs +++ b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs @@ -45,7 +45,7 @@ namespace osu.Game.Online.API.Requests.Responses case "cuttingedge": return new Color4(238, 170, 0, 255); - case "lazer": + case OsuGameBase.CLIENT_STREAM_NAME: return new Color4(237, 18, 33, 255); case "web": diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 7b9aed8364..00672e82bd 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -44,6 +44,8 @@ namespace osu.Game /// public class OsuGameBase : Framework.Game, ICanAcceptFiles { + public const string CLIENT_STREAM_NAME = "lazer"; + protected OsuConfigManager LocalConfig; protected BeatmapManager BeatmapManager; diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 8403f70f49..298991712b 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -80,7 +80,7 @@ namespace osu.Game.Overlays.Settings { if (game.IsDeployedBuild) { - changelog?.ShowBuild("lazer", game.Version); + changelog?.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, game.Version); } return true; From b249fb35446d1176a5bcdec7487fe1d949551e2e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 13:37:29 +0900 Subject: [PATCH 7/9] Update test scene to support dynamic compilation --- ...stSceneSettings.cs => TestSceneSettingsPanel.cs} | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) rename osu.Game.Tests/Visual/Settings/{TestSceneSettings.cs => TestSceneSettingsPanel.cs} (71%) diff --git a/osu.Game.Tests/Visual/Settings/TestSceneSettings.cs b/osu.Game.Tests/Visual/Settings/TestSceneSettingsPanel.cs similarity index 71% rename from osu.Game.Tests/Visual/Settings/TestSceneSettings.cs rename to osu.Game.Tests/Visual/Settings/TestSceneSettingsPanel.cs index 964754f8d0..27e3cc1590 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneSettings.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneSettingsPanel.cs @@ -1,20 +1,29 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; using osu.Game.Overlays; +using osu.Game.Overlays.Settings; namespace osu.Game.Tests.Visual.Settings { [TestFixture] - public class TestSceneSettings : OsuTestScene + public class TestSceneSettingsPanel : OsuTestScene { private readonly SettingsPanel settings; private readonly DialogOverlay dialogOverlay; - public TestSceneSettings() + public override IReadOnlyList RequiredTypes => new[] + { + typeof(SettingsFooter), + typeof(SettingsOverlay), + }; + + public TestSceneSettingsPanel() { settings = new SettingsOverlay { From 4e5788959ee6e72953e1a17a01ff20adc90e0840 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 13:38:06 +0900 Subject: [PATCH 8/9] Make clickable text actually a button --- osu.Game/Overlays/Settings/SettingsFooter.cs | 47 ++++++++++++++------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 298991712b..7a7f7bdf73 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -5,10 +5,10 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; using osuTK; using osuTK.Graphics; @@ -18,9 +18,6 @@ namespace osu.Game.Overlays.Settings { public class SettingsFooter : FillFlowContainer { - [Resolved] - private OsuGameBase game { get; set; } - [Resolved(CanBeNull = true)] private ChangelogOverlay changelog { get; set; } @@ -65,25 +62,49 @@ namespace osu.Game.Overlays.Settings Text = game.Name, Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), }, - new OsuSpriteText + new BuildDisplay(game.Version, DebugUtils.IsDebug) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Font = OsuFont.GetFont(size: 14), - Text = game.Version, - Colour = DebugUtils.IsDebug ? colours.Red : Color4.White, - }, + } }; } - protected override bool OnClick(ClickEvent e) + private class BuildDisplay : OsuAnimatedButton { - if (game.IsDeployedBuild) + private readonly string version; + private readonly bool isDebug; + + [Resolved] + private OsuColour colours { get; set; } + + public BuildDisplay(string version, bool isDebug) { - changelog?.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, game.Version); + this.version = version; + this.isDebug = isDebug; + + Content.RelativeSizeAxes = Axes.Y; + Content.AutoSizeAxes = AutoSizeAxes = Axes.X; + Height = 20; } - return true; + [BackgroundDependencyLoader(true)] + private void load(ChangelogOverlay changelog) + { + if (!isDebug) + Action = () => changelog?.ShowBuild(OsuGameBase.CLIENT_STREAM_NAME, version); + + Add(new OsuSpriteText + { + Font = OsuFont.GetFont(size: 16), + + Text = version, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Padding = new MarginPadding(5), + Colour = isDebug ? colours.Red : Color4.White, + }); + } } } } From 65e3b7c2ae35840c53f0bbd06c388997af9a2054 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 3 Jun 2019 13:58:55 +0900 Subject: [PATCH 9/9] Remove unused DI --- osu.Game/Overlays/Settings/SettingsFooter.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsFooter.cs b/osu.Game/Overlays/Settings/SettingsFooter.cs index 7a7f7bdf73..b5ee4b4f0c 100644 --- a/osu.Game/Overlays/Settings/SettingsFooter.cs +++ b/osu.Game/Overlays/Settings/SettingsFooter.cs @@ -18,9 +18,6 @@ namespace osu.Game.Overlays.Settings { public class SettingsFooter : FillFlowContainer { - [Resolved(CanBeNull = true)] - private ChangelogOverlay changelog { get; set; } - [BackgroundDependencyLoader] private void load(OsuGameBase game, OsuColour colours, RulesetStore rulesets) {