diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 02c2158383..b7b523a94d 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -237,19 +237,19 @@ public override IEnumerable GetDefaultKeyBindings(int variant = 0) { LeftKeys = new[] { - InputKey.Number1, - InputKey.Number2, - InputKey.Number3, - InputKey.Number4, + InputKey.Q, + InputKey.W, + InputKey.E, + InputKey.R, }, RightKeys = new[] { - InputKey.Z, InputKey.X, InputKey.C, - InputKey.V + InputKey.V, + InputKey.B }, - SpecialKey = InputKey.Tilde, + SpecialKey = InputKey.S, SpecialAction = ManiaAction.Special1, NormalActionStart = ManiaAction.Key1 }.GenerateKeyBindingsFor(keys, out var nextNormal); @@ -265,12 +265,12 @@ public override IEnumerable GetDefaultKeyBindings(int variant = 0) }, RightKeys = new[] { - InputKey.O, - InputKey.P, - InputKey.BracketLeft, - InputKey.BracketRight + InputKey.K, + InputKey.L, + InputKey.Semicolon, + InputKey.Quote }, - SpecialKey = InputKey.BackSlash, + SpecialKey = InputKey.I, SpecialAction = ManiaAction.Special2, NormalActionStart = nextNormal }.GenerateKeyBindingsFor(keys, out _); diff --git a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs index 658f678b10..7a8570c09b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChangelogOverlay.cs @@ -13,7 +13,7 @@ namespace osu.Game.Tests.Visual.Online [TestFixture] public class TestSceneChangelogOverlay : OsuTestScene { - private ChangelogOverlay changelog; + private TestChangelogOverlay changelog; public override IReadOnlyList RequiredTypes => new[] { @@ -29,23 +29,40 @@ public class TestSceneChangelogOverlay : OsuTestScene protected override bool UseOnlineAPI => true; - protected override void LoadComplete() + [SetUp] + public void SetUp() => Schedule(() => { - base.LoadComplete(); + Child = changelog = new TestChangelogOverlay(); + }); - Add(changelog = new ChangelogOverlay()); - AddStep(@"Show", changelog.Show); - AddStep(@"Hide", changelog.Hide); + [Test] + public void ShowWithNoFetch() + { + AddStep(@"Show", () => changelog.Show()); + AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0); + AddAssert(@"listing displayed", () => changelog.Current.Value == null); + AddAssert(@"no stream selected", () => changelog.Header.Streams.Current.Value == null); + } - AddWaitStep("wait for hide", 3); + [Test] + public void ShowWithListing() + { + AddStep(@"Show with listing", () => changelog.ShowListing()); + AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0); + AddAssert(@"listing displayed", () => changelog.Current.Value == null); + AddAssert(@"no stream selected", () => changelog.Header.Streams.Current.Value == null); + } + [Test] + public void ShowWithBuild() + { AddStep(@"Show with Lazer 2018.712.0", () => { changelog.ShowBuild(new APIChangelogBuild { Version = "2018.712.0", DisplayVersion = "2018.712.0", - UpdateStream = new APIUpdateStream { Name = OsuGameBase.CLIENT_STREAM_NAME }, + UpdateStream = new APIUpdateStream { Id = 7, Name = OsuGameBase.CLIENT_STREAM_NAME }, ChangelogEntries = new List { new APIChangelogEntry @@ -56,19 +73,16 @@ protected override void LoadComplete() } } }); - changelog.Show(); }); - AddWaitStep("wait for show", 3); - AddStep(@"Hide", changelog.Hide); - AddWaitStep("wait for hide", 3); - - AddStep(@"Show with listing", () => - { - changelog.ShowListing(); - changelog.Show(); - }); + AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0); + AddAssert(@"correct build displayed", () => changelog.Current.Value.Version == "2018.712.0"); + AddAssert(@"correct stream selected", () => changelog.Header.Streams.Current.Value.Id == 7); + } + [Test] + public void TestHTMLUnescaping() + { AddStep(@"Ensure HTML string unescaping", () => { changelog.ShowBuild(new APIChangelogBuild @@ -97,5 +111,12 @@ protected override void LoadComplete() }); }); } + + private class TestChangelogOverlay : ChangelogOverlay + { + public new List Streams => base.Streams; + + public new ChangelogHeader Header => base.Header; + } } } diff --git a/osu.Game.Tests/Visual/Online/TestSceneFullscreenOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneFullscreenOverlay.cs index fe8437be17..e60adcee34 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFullscreenOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFullscreenOverlay.cs @@ -41,6 +41,7 @@ protected override void LoadComplete() private class TestFullscreenOverlay : FullscreenOverlay { public TestFullscreenOverlay() + : base(OverlayColourScheme.Pink) { Children = new Drawable[] { diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs index 63b46c991f..f825e4f1e9 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs @@ -31,6 +31,9 @@ public class TestSceneUserProfileHeader : OsuTestScene typeof(ProfileHeaderButton) }; + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green); + [Resolved] private IAPIProvider api { get; set; } diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBreadcrumbControl.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBreadcrumbControl.cs index 19eebc89b6..3967b62c95 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBreadcrumbControl.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBreadcrumbControl.cs @@ -1,9 +1,11 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; @@ -12,11 +14,11 @@ namespace osu.Game.Tests.Visual.UserInterface [TestFixture] public class TestSceneBreadcrumbControl : OsuTestScene { - private readonly BreadcrumbControl breadcrumbs; + private readonly TestBreadcrumbControl breadcrumbs; public TestSceneBreadcrumbControl() { - Add(breadcrumbs = new BreadcrumbControl + Add(breadcrumbs = new TestBreadcrumbControl { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -25,8 +27,13 @@ public TestSceneBreadcrumbControl() }); AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click); + assertVisible(1); + AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The); + assertVisible(2); + AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles); + assertVisible(3); } [BackgroundDependencyLoader] @@ -35,11 +42,27 @@ private void load(OsuColour colours) breadcrumbs.StripColour = colours.Blue; } + private void assertVisible(int count) => AddAssert($"first {count} item(s) visible", () => + { + for (int i = 0; i < count; i++) + { + if (breadcrumbs.GetDrawable((BreadcrumbTab)i).State != Visibility.Visible) + return false; + } + + return true; + }); + private enum BreadcrumbTab { Click, The, Circles, } + + private class TestBreadcrumbControl : BreadcrumbControl + { + public BreadcrumbTabItem GetDrawable(BreadcrumbTab tab) => (BreadcrumbTabItem)TabContainer.First(t => t.Value == tab); + } } } diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index 53a40f5613..c8298543a1 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -3,7 +3,6 @@ using System; using osu.Game.Beatmaps; -using osuTK; using osuTK.Graphics; namespace osu.Game.Graphics @@ -78,46 +77,6 @@ public Color4 ForDifficultyRating(DifficultyRating difficulty, bool useLighterCo } } - public Color4 ForOverlayElement(OverlayColourScheme colourScheme, float saturation, float lightness, float opacity = 1) => Color4.FromHsl(new Vector4(getBaseHue(colourScheme), saturation, lightness, opacity)); - - // See https://github.com/ppy/osu-web/blob/4218c288292d7c810b619075471eaea8bbb8f9d8/app/helpers.php#L1463 - private static float getBaseHue(OverlayColourScheme colourScheme) - { - float hue; - - switch (colourScheme) - { - default: - throw new ArgumentException($@"{colourScheme} colour scheme does not provide a hue value in {nameof(getBaseHue)}."); - - case OverlayColourScheme.Red: - hue = 0; - break; - - case OverlayColourScheme.Pink: - hue = 333; - break; - - case OverlayColourScheme.Orange: - hue = 46; - break; - - case OverlayColourScheme.Green: - hue = 115; - break; - - case OverlayColourScheme.Purple: - hue = 255; - break; - - case OverlayColourScheme.Blue: - hue = 200; - break; - } - - return hue / 360f; - } - // See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less public readonly Color4 PurpleLighter = FromHex(@"eeeeff"); public readonly Color4 PurpleLight = FromHex(@"aa88ff"); @@ -220,14 +179,4 @@ private static float getBaseHue(OverlayColourScheme colourScheme) public readonly Color4 ContextMenuGray = FromHex(@"223034"); } - - public enum OverlayColourScheme - { - Red, - Pink, - Orange, - Green, - Purple, - Blue - } } diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index 7f20c30048..3ad36577b5 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -90,7 +90,7 @@ public Task TakeScreenshotAsync() => Task.Run(async () => { ScheduledDelegate waitDelegate = host.DrawThread.Scheduler.AddDelayed(() => { - if (framesWaited++ < frames_to_wait) + if (framesWaited++ >= frames_to_wait) // ReSharper disable once AccessToDisposedClosure framesWaitedEvent.Set(); }, 10, true); diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index e2438cc4cd..84429bf5bd 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -34,13 +34,13 @@ public BreadcrumbControl() var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[index.NewValue]); - t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; - t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, Easing.OutQuint); + t.State = tIndex > tabIndex ? Visibility.Hidden : Visibility.Visible; + t.Chevron.FadeTo(tIndex >= tabIndex ? 0f : 1f, 500, Easing.OutQuint); } }; } - protected class BreadcrumbTabItem : OsuTabItem, IStateful + public class BreadcrumbTabItem : OsuTabItem, IStateful { protected virtual float ChevronSize => 10; diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 50fb2782d4..e4e928df18 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -34,6 +34,7 @@ public class BeatmapSetOverlay : FullscreenOverlay public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; public BeatmapSetOverlay() + : base(OverlayColourScheme.Blue) { OsuScrollContainer scroll; Info info; diff --git a/osu.Game/Overlays/BreadcrumbControlOverlayHeader.cs b/osu.Game/Overlays/BreadcrumbControlOverlayHeader.cs index 2e50c19729..c3f35b4313 100644 --- a/osu.Game/Overlays/BreadcrumbControlOverlayHeader.cs +++ b/osu.Game/Overlays/BreadcrumbControlOverlayHeader.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays @@ -15,15 +14,10 @@ public abstract class BreadcrumbControlOverlayHeader : OverlayHeader protected override TabControl CreateTabControl() => BreadcrumbControl = new OverlayHeaderBreadcrumbControl(); - protected BreadcrumbControlOverlayHeader(OverlayColourScheme colourScheme) - : base(colourScheme) - { - } - [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OverlayColourProvider colourProvider) { - BreadcrumbControl.AccentColour = colours.ForOverlayElement(ColourScheme, 1, 0.75f); + BreadcrumbControl.AccentColour = colourProvider.Highlight1; } public class OverlayHeaderBreadcrumbControl : BreadcrumbControl diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index d5e0890b4d..7755c0f64b 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -9,7 +10,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; @@ -26,7 +26,6 @@ public class ChangelogHeader : BreadcrumbControlOverlayHeader private const string listing_string = "listing"; public ChangelogHeader() - : base(OverlayColourScheme.Purple) { BreadcrumbControl.AddItem(listing_string); BreadcrumbControl.Current.ValueChanged += e => @@ -39,7 +38,7 @@ public ChangelogHeader() Streams.Current.ValueChanged += e => { - if (e.NewValue?.LatestBuild != null && e.NewValue != Current.Value?.UpdateStream) + if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Current.Value?.UpdateStream)) Current.Value = e.NewValue.LatestBuild; }; } @@ -56,7 +55,7 @@ private void showBuild(ValueChangedEvent e) BreadcrumbControl.AddItem(e.NewValue.ToString()); BreadcrumbControl.Current.Value = e.NewValue.ToString(); - Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == e.NewValue.UpdateStream.Name); + updateCurrentStream(); title.Version = e.NewValue.UpdateStream.DisplayName; } @@ -82,6 +81,20 @@ private void showBuild(ValueChangedEvent e) protected override ScreenTitle CreateTitle() => title = new ChangelogHeaderTitle(); + public void Populate(List streams) + { + Streams.Populate(streams); + updateCurrentStream(); + } + + private void updateCurrentStream() + { + if (Current.Value == null) + return; + + Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Current.Value.UpdateStream.Name); + } + public class HeaderBackground : Sprite { public HeaderBackground() diff --git a/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs b/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs index 2b48811bd6..ca57ba24e2 100644 --- a/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs +++ b/osu.Game/Overlays/Changelog/UpdateStreamBadgeArea.cs @@ -29,8 +29,6 @@ public UpdateStreamBadgeArea() public void Populate(List streams) { - Current.Value = null; - foreach (APIUpdateStream updateStream in streams) AddItem(updateStream); } diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 15b0079277..90ba206077 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -26,7 +26,7 @@ public class ChangelogOverlay : FullscreenOverlay { public readonly Bindable Current = new Bindable(); - private ChangelogHeader header; + protected ChangelogHeader Header; private Container content; @@ -34,16 +34,16 @@ public class ChangelogOverlay : FullscreenOverlay private List builds; - private List streams; + protected List Streams; + + public ChangelogOverlay() + : base(OverlayColourScheme.Purple) + { + } [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colour) { - Waves.FirstWaveColour = colour.GreyVioletLight; - Waves.SecondWaveColour = colour.GreyViolet; - Waves.ThirdWaveColour = colour.GreyVioletDark; - Waves.FourthWaveColour = colour.GreyVioletDarker; - Children = new Drawable[] { new Box @@ -62,7 +62,7 @@ private void load(AudioManager audio, OsuColour colour) Direction = FillDirection.Vertical, Children = new Drawable[] { - header = new ChangelogHeader + Header = new ChangelogHeader { ListingSelected = ShowListing, }, @@ -78,7 +78,7 @@ private void load(AudioManager audio, OsuColour colour) sampleBack = audio.Samples.Get(@"UI/generic-select-soft"); - header.Current.BindTo(Current); + Header.Current.BindTo(Current); Current.BindValueChanged(e => { @@ -117,7 +117,7 @@ public void ShowBuild([NotNull] string updateStream, [NotNull] string version) performAfterFetch(() => { var build = builds.Find(b => b.Version == version && b.UpdateStream.Name == updateStream) - ?? streams.Find(s => s.Name == updateStream)?.LatestBuild; + ?? Streams.Find(s => s.Name == updateStream)?.LatestBuild; if (build != null) ShowBuild(build); @@ -179,9 +179,9 @@ private Task fetchListing() res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); builds = res.Builds; - streams = res.Streams; + Streams = res.Streams; - header.Streams.Populate(res.Streams); + Header.Populate(res.Streams); tcs.SetResult(true); }); diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 9daf55c796..e4cef319fe 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -84,14 +84,8 @@ public ResultCounts ResultAmounts } public DirectOverlay() + : base(OverlayColourScheme.Blue) { - // osu!direct colours are not part of the standard palette - - Waves.FirstWaveColour = OsuColour.FromHex(@"19b0e2"); - Waves.SecondWaveColour = OsuColour.FromHex(@"2280a2"); - Waves.ThirdWaveColour = OsuColour.FromHex(@"005774"); - Waves.FourthWaveColour = OsuColour.FromHex(@"003a4e"); - ScrollFlow.Children = new Drawable[] { resultCountsContainer = new FillFlowContainer diff --git a/osu.Game/Overlays/FullscreenOverlay.cs b/osu.Game/Overlays/FullscreenOverlay.cs index 0911ee84de..959f6749d2 100644 --- a/osu.Game/Overlays/FullscreenOverlay.cs +++ b/osu.Game/Overlays/FullscreenOverlay.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; -using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Online.API; using osuTK.Graphics; @@ -18,12 +17,12 @@ public abstract class FullscreenOverlay : WaveOverlayContainer, IOnlineComponent [Resolved] protected IAPIProvider API { get; private set; } - protected FullscreenOverlay() + [Cached] + private readonly OverlayColourProvider colourProvider; + + protected FullscreenOverlay(OverlayColourScheme colourScheme) { - Waves.FirstWaveColour = OsuColour.Gray(0.4f); - Waves.SecondWaveColour = OsuColour.Gray(0.3f); - Waves.ThirdWaveColour = OsuColour.Gray(0.2f); - Waves.FourthWaveColour = OsuColour.Gray(0.1f); + colourProvider = new OverlayColourProvider(colourScheme); RelativeSizeAxes = Axes.Both; RelativePositionAxes = Axes.Both; @@ -41,6 +40,15 @@ protected FullscreenOverlay() }; } + [BackgroundDependencyLoader] + private void load() + { + Waves.FirstWaveColour = colourProvider.Light4; + Waves.SecondWaveColour = colourProvider.Light3; + Waves.ThirdWaveColour = colourProvider.Dark4; + Waves.FourthWaveColour = colourProvider.Dark3; + } + public override void Show() { if (State.Value == Visibility.Visible) diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs index 03dc64b3bd..1152d9044b 100644 --- a/osu.Game/Overlays/News/NewsHeader.cs +++ b/osu.Game/Overlays/News/NewsHeader.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using System; @@ -23,7 +22,6 @@ public class NewsHeader : BreadcrumbControlOverlayHeader public Action ShowFrontPage; public NewsHeader() - : base(OverlayColourScheme.Purple) { BreadcrumbControl.AddItem(front_page_string); diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs index e7471cb21d..6dde300556 100644 --- a/osu.Game/Overlays/NewsOverlay.cs +++ b/osu.Game/Overlays/NewsOverlay.cs @@ -21,6 +21,11 @@ public class NewsOverlay : FullscreenOverlay public readonly Bindable Current = new Bindable(null); + public NewsOverlay() + : base(OverlayColourScheme.Purple) + { + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { diff --git a/osu.Game/Overlays/OverlayColourProvider.cs b/osu.Game/Overlays/OverlayColourProvider.cs new file mode 100644 index 0000000000..9816f313ad --- /dev/null +++ b/osu.Game/Overlays/OverlayColourProvider.cs @@ -0,0 +1,80 @@ +// 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 osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays +{ + public class OverlayColourProvider + { + private readonly OverlayColourScheme colourScheme; + + public OverlayColourProvider(OverlayColourScheme colourScheme) + { + this.colourScheme = colourScheme; + } + + public Color4 Highlight1 => getColour(1, 0.7f); + public Color4 Content1 => getColour(0.4f, 1); + public Color4 Content2 => getColour(0.4f, 0.9f); + public Color4 Light1 => getColour(0.4f, 0.8f); + public Color4 Light2 => getColour(0.4f, 0.75f); + public Color4 Light3 => getColour(0.4f, 0.7f); + public Color4 Light4 => getColour(0.4f, 0.5f); + public Color4 Dark1 => getColour(0.2f, 0.35f); + public Color4 Dark2 => getColour(0.2f, 0.3f); + public Color4 Dark3 => getColour(0.2f, 0.25f); + public Color4 Dark4 => getColour(0.2f, 0.2f); + public Color4 Dark5 => getColour(0.2f, 0.15f); + public Color4 Dark6 => getColour(0.2f, 0.1f); + public Color4 Foreground1 => getColour(0.1f, 0.6f); + public Color4 Background1 => getColour(0.1f, 0.4f); + public Color4 Background2 => getColour(0.1f, 0.3f); + public Color4 Background3 => getColour(0.1f, 0.25f); + public Color4 Background4 => getColour(0.1f, 0.2f); + public Color4 Background5 => getColour(0.1f, 0.15f); + public Color4 Background6 => getColour(0.1f, 0.1f); + + private Color4 getColour(float saturation, float lightness) => Color4.FromHsl(new Vector4(getBaseHue(colourScheme), saturation, lightness, 1)); + + // See https://github.com/ppy/osu-web/blob/4218c288292d7c810b619075471eaea8bbb8f9d8/app/helpers.php#L1463 + private static float getBaseHue(OverlayColourScheme colourScheme) + { + switch (colourScheme) + { + default: + throw new ArgumentException($@"{colourScheme} colour scheme does not provide a hue value in {nameof(getBaseHue)}."); + + case OverlayColourScheme.Red: + return 0; + + case OverlayColourScheme.Pink: + return 333 / 360f; + + case OverlayColourScheme.Orange: + return 46 / 360f; + + case OverlayColourScheme.Green: + return 115 / 360f; + + case OverlayColourScheme.Purple: + return 255 / 360f; + + case OverlayColourScheme.Blue: + return 200 / 360f; + } + } + } + + public enum OverlayColourScheme + { + Red, + Pink, + Orange, + Green, + Purple, + Blue + } +} diff --git a/osu.Game/Overlays/OverlayHeader.cs b/osu.Game/Overlays/OverlayHeader.cs index c9547bb5b8..bc58a17401 100644 --- a/osu.Game/Overlays/OverlayHeader.cs +++ b/osu.Game/Overlays/OverlayHeader.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; -using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osuTK.Graphics; @@ -25,12 +24,8 @@ protected float BackgroundHeight set => background.Height = value; } - protected OverlayColourScheme ColourScheme { get; } - - protected OverlayHeader(OverlayColourScheme colourScheme) + protected OverlayHeader() { - ColourScheme = colourScheme; - RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -89,11 +84,11 @@ protected OverlayHeader(OverlayColourScheme colourScheme) } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OverlayColourProvider colourProvider) { - titleBackground.Colour = colours.ForOverlayElement(ColourScheme, 0.2f, 0.15f); - title.AccentColour = colours.ForOverlayElement(ColourScheme, 1, 0.7f); - controlBackground.Colour = colours.ForOverlayElement(ColourScheme, 0.2f, 0.2f); + titleBackground.Colour = colourProvider.Dark5; + title.AccentColour = colourProvider.Highlight1; + controlBackground.Colour = colourProvider.Dark4; } protected abstract Drawable CreateBackground(); diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index b550d7d823..f8eb03770a 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -24,7 +24,6 @@ public class ProfileHeader : TabControlOverlayHeader private DetailHeaderContainer detailHeaderContainer; public ProfileHeader() - : base(OverlayColourScheme.Green) { BackgroundHeight = 150; diff --git a/osu.Game/Overlays/RankingsOverlay.cs b/osu.Game/Overlays/RankingsOverlay.cs index c8874ef891..1ab18b8c15 100644 --- a/osu.Game/Overlays/RankingsOverlay.cs +++ b/osu.Game/Overlays/RankingsOverlay.cs @@ -25,7 +25,6 @@ public class RankingsOverlay : FullscreenOverlay private readonly Bindable ruleset = new Bindable(); private readonly BasicScrollContainer scrollFlow; - private readonly Box background; private readonly Container tableContainer; private readonly DimmedLoadingLayer loading; @@ -36,12 +35,14 @@ public class RankingsOverlay : FullscreenOverlay private IAPIProvider api { get; set; } public RankingsOverlay() + : base(OverlayColourScheme.Green) { Children = new Drawable[] { - background = new Box + new Box { RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(0.1f), }, scrollFlow = new BasicScrollContainer { @@ -85,17 +86,6 @@ public RankingsOverlay() }; } - [BackgroundDependencyLoader] - private void load(OsuColour colour) - { - Waves.FirstWaveColour = colour.Green; - Waves.SecondWaveColour = colour.GreenLight; - Waves.ThirdWaveColour = colour.GreenDark; - Waves.FourthWaveColour = colour.GreenDarker; - - background.Colour = OsuColour.Gray(0.1f); - } - protected override void LoadComplete() { Country.BindValueChanged(_ => diff --git a/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs b/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs index 5975e94ffc..0783c64c20 100644 --- a/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs +++ b/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs @@ -16,6 +16,11 @@ namespace osu.Game.Overlays.SearchableList public abstract class SearchableListOverlay : FullscreenOverlay { public const float WIDTH_PADDING = 80; + + protected SearchableListOverlay(OverlayColourScheme colourScheme) + : base(colourScheme) + { + } } public abstract class SearchableListOverlay : SearchableListOverlay @@ -35,7 +40,8 @@ public abstract class SearchableListOverlay : Searchab protected abstract SearchableListHeader CreateHeader(); protected abstract SearchableListFilterControl CreateFilterControl(); - protected SearchableListOverlay() + protected SearchableListOverlay(OverlayColourScheme colourScheme) + : base(colourScheme) { Children = new Drawable[] { diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index 0c99962def..9a523bc1bc 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -52,12 +52,8 @@ public User[] Users } public SocialOverlay() + : base(OverlayColourScheme.Pink) { - Waves.FirstWaveColour = OsuColour.FromHex(@"cb5fa0"); - Waves.SecondWaveColour = OsuColour.FromHex(@"b04384"); - Waves.ThirdWaveColour = OsuColour.FromHex(@"9b2b6e"); - Waves.FourthWaveColour = OsuColour.FromHex(@"6d214d"); - Add(loading = new LoadingAnimation()); Filter.Search.Current.ValueChanged += text => diff --git a/osu.Game/Overlays/TabControlOverlayHeader.cs b/osu.Game/Overlays/TabControlOverlayHeader.cs index 8f3aa896ee..0c55b8383b 100644 --- a/osu.Game/Overlays/TabControlOverlayHeader.cs +++ b/osu.Game/Overlays/TabControlOverlayHeader.cs @@ -16,15 +16,10 @@ public abstract class TabControlOverlayHeader : OverlayHeader protected override TabControl CreateTabControl() => TabControl = new OverlayHeaderTabControl(); - protected TabControlOverlayHeader(OverlayColourScheme colourScheme) - : base(colourScheme) - { - } - [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OverlayColourProvider colourProvider) { - TabControl.AccentColour = colours.ForOverlayElement(ColourScheme, 1, 0.75f); + TabControl.AccentColour = colourProvider.Highlight1; } public class OverlayHeaderTabControl : OverlayTabControl diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index a34fc619a8..07c0dbed43 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -29,6 +29,11 @@ public class UserProfileOverlay : FullscreenOverlay public const float CONTENT_X_MARGIN = 70; + public UserProfileOverlay() + : base(OverlayColourScheme.Green) + { + } + public void ShowUser(long userId) => ShowUser(new User { Id = userId }); public void ShowUser(User user, bool fetchOnline = true) diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 8ccc2af93b..8eafaa88ec 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -45,7 +45,7 @@ public class ScoreProcessor : JudgementProcessor public readonly Bindable Rank = new Bindable(ScoreRank.X); /// - /// THe highest combo achieved by this score. + /// The highest combo achieved by this score. /// public readonly BindableInt HighestCombo = new BindableInt(); diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index 15ea20084d..6d131bf423 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -298,6 +298,7 @@ GL GLSL HID + HTML HUD ID IL