Merge branch 'master' into fix-ss-click-crash

This commit is contained in:
Dan Balasescu
2020-01-27 15:40:45 +09:00
committed by GitHub
27 changed files with 241 additions and 166 deletions

View File

@ -237,19 +237,19 @@ namespace osu.Game.Rulesets.Mania
{ {
LeftKeys = new[] LeftKeys = new[]
{ {
InputKey.Number1, InputKey.Q,
InputKey.Number2, InputKey.W,
InputKey.Number3, InputKey.E,
InputKey.Number4, InputKey.R,
}, },
RightKeys = new[] RightKeys = new[]
{ {
InputKey.Z,
InputKey.X, InputKey.X,
InputKey.C, InputKey.C,
InputKey.V InputKey.V,
InputKey.B
}, },
SpecialKey = InputKey.Tilde, SpecialKey = InputKey.S,
SpecialAction = ManiaAction.Special1, SpecialAction = ManiaAction.Special1,
NormalActionStart = ManiaAction.Key1 NormalActionStart = ManiaAction.Key1
}.GenerateKeyBindingsFor(keys, out var nextNormal); }.GenerateKeyBindingsFor(keys, out var nextNormal);
@ -265,12 +265,12 @@ namespace osu.Game.Rulesets.Mania
}, },
RightKeys = new[] RightKeys = new[]
{ {
InputKey.O, InputKey.K,
InputKey.P, InputKey.L,
InputKey.BracketLeft, InputKey.Semicolon,
InputKey.BracketRight InputKey.Quote
}, },
SpecialKey = InputKey.BackSlash, SpecialKey = InputKey.I,
SpecialAction = ManiaAction.Special2, SpecialAction = ManiaAction.Special2,
NormalActionStart = nextNormal NormalActionStart = nextNormal
}.GenerateKeyBindingsFor(keys, out _); }.GenerateKeyBindingsFor(keys, out _);

View File

@ -13,7 +13,7 @@ namespace osu.Game.Tests.Visual.Online
[TestFixture] [TestFixture]
public class TestSceneChangelogOverlay : OsuTestScene public class TestSceneChangelogOverlay : OsuTestScene
{ {
private ChangelogOverlay changelog; private TestChangelogOverlay changelog;
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
@ -29,23 +29,40 @@ namespace osu.Game.Tests.Visual.Online
protected override bool UseOnlineAPI => true; protected override bool UseOnlineAPI => true;
protected override void LoadComplete() [SetUp]
public void SetUp() => Schedule(() =>
{ {
base.LoadComplete(); Child = changelog = new TestChangelogOverlay();
});
Add(changelog = new ChangelogOverlay()); [Test]
AddStep(@"Show", changelog.Show); public void ShowWithNoFetch()
AddStep(@"Hide", changelog.Hide); {
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", () => AddStep(@"Show with Lazer 2018.712.0", () =>
{ {
changelog.ShowBuild(new APIChangelogBuild changelog.ShowBuild(new APIChangelogBuild
{ {
Version = "2018.712.0", Version = "2018.712.0",
DisplayVersion = "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<APIChangelogEntry> ChangelogEntries = new List<APIChangelogEntry>
{ {
new APIChangelogEntry new APIChangelogEntry
@ -56,19 +73,16 @@ namespace osu.Game.Tests.Visual.Online
} }
} }
}); });
changelog.Show();
}); });
AddWaitStep("wait for show", 3); AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0);
AddStep(@"Hide", changelog.Hide); AddAssert(@"correct build displayed", () => changelog.Current.Value.Version == "2018.712.0");
AddWaitStep("wait for hide", 3); AddAssert(@"correct stream selected", () => changelog.Header.Streams.Current.Value.Id == 7);
}
AddStep(@"Show with listing", () =>
{
changelog.ShowListing();
changelog.Show();
});
[Test]
public void TestHTMLUnescaping()
{
AddStep(@"Ensure HTML string unescaping", () => AddStep(@"Ensure HTML string unescaping", () =>
{ {
changelog.ShowBuild(new APIChangelogBuild changelog.ShowBuild(new APIChangelogBuild
@ -97,5 +111,12 @@ namespace osu.Game.Tests.Visual.Online
}); });
}); });
} }
private class TestChangelogOverlay : ChangelogOverlay
{
public new List<APIUpdateStream> Streams => base.Streams;
public new ChangelogHeader Header => base.Header;
}
} }
} }

View File

@ -41,6 +41,7 @@ namespace osu.Game.Tests.Visual.Online
private class TestFullscreenOverlay : FullscreenOverlay private class TestFullscreenOverlay : FullscreenOverlay
{ {
public TestFullscreenOverlay() public TestFullscreenOverlay()
: base(OverlayColourScheme.Pink)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -31,6 +31,9 @@ namespace osu.Game.Tests.Visual.Online
typeof(ProfileHeaderButton) typeof(ProfileHeaderButton)
}; };
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; }

View File

@ -1,9 +1,11 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -12,11 +14,11 @@ namespace osu.Game.Tests.Visual.UserInterface
[TestFixture] [TestFixture]
public class TestSceneBreadcrumbControl : OsuTestScene public class TestSceneBreadcrumbControl : OsuTestScene
{ {
private readonly BreadcrumbControl<BreadcrumbTab> breadcrumbs; private readonly TestBreadcrumbControl breadcrumbs;
public TestSceneBreadcrumbControl() public TestSceneBreadcrumbControl()
{ {
Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab> Add(breadcrumbs = new TestBreadcrumbControl
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -25,8 +27,13 @@ namespace osu.Game.Tests.Visual.UserInterface
}); });
AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click); AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click);
assertVisible(1);
AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The); AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The);
assertVisible(2);
AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles); AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles);
assertVisible(3);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -35,11 +42,27 @@ namespace osu.Game.Tests.Visual.UserInterface
breadcrumbs.StripColour = colours.Blue; 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 private enum BreadcrumbTab
{ {
Click, Click,
The, The,
Circles, Circles,
} }
private class TestBreadcrumbControl : BreadcrumbControl<BreadcrumbTab>
{
public BreadcrumbTabItem GetDrawable(BreadcrumbTab tab) => (BreadcrumbTabItem)TabContainer.First(t => t.Value == tab);
}
} }
} }

View File

@ -3,7 +3,6 @@
using System; using System;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Graphics namespace osu.Game.Graphics
@ -78,46 +77,6 @@ namespace osu.Game.Graphics
} }
} }
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 // See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less
public readonly Color4 PurpleLighter = FromHex(@"eeeeff"); public readonly Color4 PurpleLighter = FromHex(@"eeeeff");
public readonly Color4 PurpleLight = FromHex(@"aa88ff"); public readonly Color4 PurpleLight = FromHex(@"aa88ff");
@ -220,14 +179,4 @@ namespace osu.Game.Graphics
public readonly Color4 ContextMenuGray = FromHex(@"223034"); public readonly Color4 ContextMenuGray = FromHex(@"223034");
} }
public enum OverlayColourScheme
{
Red,
Pink,
Orange,
Green,
Purple,
Blue
}
} }

View File

@ -90,7 +90,7 @@ namespace osu.Game.Graphics
{ {
ScheduledDelegate waitDelegate = host.DrawThread.Scheduler.AddDelayed(() => ScheduledDelegate waitDelegate = host.DrawThread.Scheduler.AddDelayed(() =>
{ {
if (framesWaited++ < frames_to_wait) if (framesWaited++ >= frames_to_wait)
// ReSharper disable once AccessToDisposedClosure // ReSharper disable once AccessToDisposedClosure
framesWaitedEvent.Set(); framesWaitedEvent.Set();
}, 10, true); }, 10, true);

View File

@ -34,13 +34,13 @@ namespace osu.Game.Graphics.UserInterface
var tIndex = TabContainer.IndexOf(t); var tIndex = TabContainer.IndexOf(t);
var tabIndex = TabContainer.IndexOf(TabMap[index.NewValue]); var tabIndex = TabContainer.IndexOf(TabMap[index.NewValue]);
t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; t.State = tIndex > tabIndex ? Visibility.Hidden : Visibility.Visible;
t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, Easing.OutQuint); t.Chevron.FadeTo(tIndex >= tabIndex ? 0f : 1f, 500, Easing.OutQuint);
} }
}; };
} }
protected class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility> public class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
{ {
protected virtual float ChevronSize => 10; protected virtual float ChevronSize => 10;

View File

@ -34,6 +34,7 @@ namespace osu.Game.Overlays
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public BeatmapSetOverlay() public BeatmapSetOverlay()
: base(OverlayColourScheme.Blue)
{ {
OsuScrollContainer scroll; OsuScrollContainer scroll;
Info info; Info info;

View File

@ -4,7 +4,6 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays namespace osu.Game.Overlays
@ -15,15 +14,10 @@ namespace osu.Game.Overlays
protected override TabControl<string> CreateTabControl() => BreadcrumbControl = new OverlayHeaderBreadcrumbControl(); protected override TabControl<string> CreateTabControl() => BreadcrumbControl = new OverlayHeaderBreadcrumbControl();
protected BreadcrumbControlOverlayHeader(OverlayColourScheme colourScheme)
: base(colourScheme)
{
}
[BackgroundDependencyLoader] [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<string> public class OverlayHeaderBreadcrumbControl : BreadcrumbControl<string>

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -9,7 +10,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -26,7 +26,6 @@ namespace osu.Game.Overlays.Changelog
private const string listing_string = "listing"; private const string listing_string = "listing";
public ChangelogHeader() public ChangelogHeader()
: base(OverlayColourScheme.Purple)
{ {
BreadcrumbControl.AddItem(listing_string); BreadcrumbControl.AddItem(listing_string);
BreadcrumbControl.Current.ValueChanged += e => BreadcrumbControl.Current.ValueChanged += e =>
@ -39,7 +38,7 @@ namespace osu.Game.Overlays.Changelog
Streams.Current.ValueChanged += e => 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; Current.Value = e.NewValue.LatestBuild;
}; };
} }
@ -56,7 +55,7 @@ namespace osu.Game.Overlays.Changelog
BreadcrumbControl.AddItem(e.NewValue.ToString()); BreadcrumbControl.AddItem(e.NewValue.ToString());
BreadcrumbControl.Current.Value = 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; title.Version = e.NewValue.UpdateStream.DisplayName;
} }
@ -82,6 +81,20 @@ namespace osu.Game.Overlays.Changelog
protected override ScreenTitle CreateTitle() => title = new ChangelogHeaderTitle(); protected override ScreenTitle CreateTitle() => title = new ChangelogHeaderTitle();
public void Populate(List<APIUpdateStream> 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 class HeaderBackground : Sprite
{ {
public HeaderBackground() public HeaderBackground()

View File

@ -29,8 +29,6 @@ namespace osu.Game.Overlays.Changelog
public void Populate(List<APIUpdateStream> streams) public void Populate(List<APIUpdateStream> streams)
{ {
Current.Value = null;
foreach (APIUpdateStream updateStream in streams) foreach (APIUpdateStream updateStream in streams)
AddItem(updateStream); AddItem(updateStream);
} }

View File

@ -26,7 +26,7 @@ namespace osu.Game.Overlays
{ {
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>(); public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
private ChangelogHeader header; protected ChangelogHeader Header;
private Container<ChangelogContent> content; private Container<ChangelogContent> content;
@ -34,16 +34,16 @@ namespace osu.Game.Overlays
private List<APIChangelogBuild> builds; private List<APIChangelogBuild> builds;
private List<APIUpdateStream> streams; protected List<APIUpdateStream> Streams;
public ChangelogOverlay()
: base(OverlayColourScheme.Purple)
{
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, OsuColour colour) 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[] Children = new Drawable[]
{ {
new Box new Box
@ -62,7 +62,7 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
header = new ChangelogHeader Header = new ChangelogHeader
{ {
ListingSelected = ShowListing, ListingSelected = ShowListing,
}, },
@ -78,7 +78,7 @@ namespace osu.Game.Overlays
sampleBack = audio.Samples.Get(@"UI/generic-select-soft"); sampleBack = audio.Samples.Get(@"UI/generic-select-soft");
header.Current.BindTo(Current); Header.Current.BindTo(Current);
Current.BindValueChanged(e => Current.BindValueChanged(e =>
{ {
@ -117,7 +117,7 @@ namespace osu.Game.Overlays
performAfterFetch(() => performAfterFetch(() =>
{ {
var build = builds.Find(b => b.Version == version && b.UpdateStream.Name == updateStream) 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) if (build != null)
ShowBuild(build); ShowBuild(build);
@ -179,9 +179,9 @@ namespace osu.Game.Overlays
res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id)); res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id));
builds = res.Builds; builds = res.Builds;
streams = res.Streams; Streams = res.Streams;
header.Streams.Populate(res.Streams); Header.Populate(res.Streams);
tcs.SetResult(true); tcs.SetResult(true);
}); });

View File

@ -84,14 +84,8 @@ namespace osu.Game.Overlays
} }
public DirectOverlay() 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[] ScrollFlow.Children = new Drawable[]
{ {
resultCountsContainer = new FillFlowContainer resultCountsContainer = new FillFlowContainer

View File

@ -6,7 +6,6 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Online.API; using osu.Game.Online.API;
using osuTK.Graphics; using osuTK.Graphics;
@ -18,12 +17,12 @@ namespace osu.Game.Overlays
[Resolved] [Resolved]
protected IAPIProvider API { get; private set; } protected IAPIProvider API { get; private set; }
protected FullscreenOverlay() [Cached]
private readonly OverlayColourProvider colourProvider;
protected FullscreenOverlay(OverlayColourScheme colourScheme)
{ {
Waves.FirstWaveColour = OsuColour.Gray(0.4f); colourProvider = new OverlayColourProvider(colourScheme);
Waves.SecondWaveColour = OsuColour.Gray(0.3f);
Waves.ThirdWaveColour = OsuColour.Gray(0.2f);
Waves.FourthWaveColour = OsuColour.Gray(0.1f);
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
RelativePositionAxes = Axes.Both; RelativePositionAxes = Axes.Both;
@ -41,6 +40,15 @@ namespace osu.Game.Overlays
}; };
} }
[BackgroundDependencyLoader]
private void load()
{
Waves.FirstWaveColour = colourProvider.Light4;
Waves.SecondWaveColour = colourProvider.Light3;
Waves.ThirdWaveColour = colourProvider.Dark4;
Waves.FourthWaveColour = colourProvider.Dark3;
}
public override void Show() public override void Show()
{ {
if (State.Value == Visibility.Visible) if (State.Value == Visibility.Visible)

View File

@ -6,7 +6,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using System; using System;
@ -23,7 +22,6 @@ namespace osu.Game.Overlays.News
public Action ShowFrontPage; public Action ShowFrontPage;
public NewsHeader() public NewsHeader()
: base(OverlayColourScheme.Purple)
{ {
BreadcrumbControl.AddItem(front_page_string); BreadcrumbControl.AddItem(front_page_string);

View File

@ -21,6 +21,11 @@ namespace osu.Game.Overlays
public readonly Bindable<string> Current = new Bindable<string>(null); public readonly Bindable<string> Current = new Bindable<string>(null);
public NewsOverlay()
: base(OverlayColourScheme.Purple)
{
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {

View File

@ -0,0 +1,80 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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
}
}

View File

@ -7,7 +7,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osuTK.Graphics; using osuTK.Graphics;
@ -25,12 +24,8 @@ namespace osu.Game.Overlays
set => background.Height = value; set => background.Height = value;
} }
protected OverlayColourScheme ColourScheme { get; } protected OverlayHeader()
protected OverlayHeader(OverlayColourScheme colourScheme)
{ {
ColourScheme = colourScheme;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
@ -89,11 +84,11 @@ namespace osu.Game.Overlays
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
titleBackground.Colour = colours.ForOverlayElement(ColourScheme, 0.2f, 0.15f); titleBackground.Colour = colourProvider.Dark5;
title.AccentColour = colours.ForOverlayElement(ColourScheme, 1, 0.7f); title.AccentColour = colourProvider.Highlight1;
controlBackground.Colour = colours.ForOverlayElement(ColourScheme, 0.2f, 0.2f); controlBackground.Colour = colourProvider.Dark4;
} }
protected abstract Drawable CreateBackground(); protected abstract Drawable CreateBackground();

View File

@ -24,7 +24,6 @@ namespace osu.Game.Overlays.Profile
private DetailHeaderContainer detailHeaderContainer; private DetailHeaderContainer detailHeaderContainer;
public ProfileHeader() public ProfileHeader()
: base(OverlayColourScheme.Green)
{ {
BackgroundHeight = 150; BackgroundHeight = 150;

View File

@ -25,7 +25,6 @@ namespace osu.Game.Overlays
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>(); private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private readonly BasicScrollContainer scrollFlow; private readonly BasicScrollContainer scrollFlow;
private readonly Box background;
private readonly Container tableContainer; private readonly Container tableContainer;
private readonly DimmedLoadingLayer loading; private readonly DimmedLoadingLayer loading;
@ -36,12 +35,14 @@ namespace osu.Game.Overlays
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; }
public RankingsOverlay() public RankingsOverlay()
: base(OverlayColourScheme.Green)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
background = new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.1f),
}, },
scrollFlow = new BasicScrollContainer scrollFlow = new BasicScrollContainer
{ {
@ -85,17 +86,6 @@ namespace osu.Game.Overlays
}; };
} }
[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() protected override void LoadComplete()
{ {
Country.BindValueChanged(_ => Country.BindValueChanged(_ =>

View File

@ -16,6 +16,11 @@ namespace osu.Game.Overlays.SearchableList
public abstract class SearchableListOverlay : FullscreenOverlay public abstract class SearchableListOverlay : FullscreenOverlay
{ {
public const float WIDTH_PADDING = 80; public const float WIDTH_PADDING = 80;
protected SearchableListOverlay(OverlayColourScheme colourScheme)
: base(colourScheme)
{
}
} }
public abstract class SearchableListOverlay<THeader, TTab, TCategory> : SearchableListOverlay public abstract class SearchableListOverlay<THeader, TTab, TCategory> : SearchableListOverlay
@ -35,7 +40,8 @@ namespace osu.Game.Overlays.SearchableList
protected abstract SearchableListHeader<THeader> CreateHeader(); protected abstract SearchableListHeader<THeader> CreateHeader();
protected abstract SearchableListFilterControl<TTab, TCategory> CreateFilterControl(); protected abstract SearchableListFilterControl<TTab, TCategory> CreateFilterControl();
protected SearchableListOverlay() protected SearchableListOverlay(OverlayColourScheme colourScheme)
: base(colourScheme)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -52,12 +52,8 @@ namespace osu.Game.Overlays
} }
public SocialOverlay() 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()); Add(loading = new LoadingAnimation());
Filter.Search.Current.ValueChanged += text => Filter.Search.Current.ValueChanged += text =>

View File

@ -16,15 +16,10 @@ namespace osu.Game.Overlays
protected override TabControl<string> CreateTabControl() => TabControl = new OverlayHeaderTabControl(); protected override TabControl<string> CreateTabControl() => TabControl = new OverlayHeaderTabControl();
protected TabControlOverlayHeader(OverlayColourScheme colourScheme)
: base(colourScheme)
{
}
[BackgroundDependencyLoader] [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<string> public class OverlayHeaderTabControl : OverlayTabControl<string>

View File

@ -29,6 +29,11 @@ namespace osu.Game.Overlays
public const float CONTENT_X_MARGIN = 70; 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(long userId) => ShowUser(new User { Id = userId });
public void ShowUser(User user, bool fetchOnline = true) public void ShowUser(User user, bool fetchOnline = true)

View File

@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Scoring
public readonly Bindable<ScoreRank> Rank = new Bindable<ScoreRank>(ScoreRank.X); public readonly Bindable<ScoreRank> Rank = new Bindable<ScoreRank>(ScoreRank.X);
/// <summary> /// <summary>
/// THe highest combo achieved by this score. /// The highest combo achieved by this score.
/// </summary> /// </summary>
public readonly BindableInt HighestCombo = new BindableInt(); public readonly BindableInt HighestCombo = new BindableInt();

View File

@ -298,6 +298,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GL/@EntryIndexedValue">GL</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GL/@EntryIndexedValue">GL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GLSL/@EntryIndexedValue">GLSL</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GLSL/@EntryIndexedValue">GLSL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HID/@EntryIndexedValue">HID</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HID/@EntryIndexedValue">HID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HTML/@EntryIndexedValue">HTML</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HUD/@EntryIndexedValue">HUD</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HUD/@EntryIndexedValue">HUD</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IL/@EntryIndexedValue">IL</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IL/@EntryIndexedValue">IL</s:String>