From dbc42fd59e1b1b786a84b8d672b2502d5924ce95 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 17 May 2019 18:09:11 +0900 Subject: [PATCH] Remove StreamColour class and implement locally --- osu.Game/Graphics/StreamColour.cs | 43 ------------------- .../API/Requests/Responses/APIUpdateStream.cs | 32 ++++++++++++++ .../Changelog/ChangelogContentGroup.cs | 4 +- osu.Game/Overlays/Changelog/StreamBadge.cs | 2 +- 4 files changed, 35 insertions(+), 46 deletions(-) delete mode 100644 osu.Game/Graphics/StreamColour.cs diff --git a/osu.Game/Graphics/StreamColour.cs b/osu.Game/Graphics/StreamColour.cs deleted file mode 100644 index b7740c3be0..0000000000 --- a/osu.Game/Graphics/StreamColour.cs +++ /dev/null @@ -1,43 +0,0 @@ -// 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.Graphics.Colour; -using System.Collections.Generic; -using osuTK.Graphics; - -namespace osu.Game.Graphics -{ - public class StreamColour - { - public static readonly Color4 STABLE = new Color4(102, 204, 255, 255); - public static readonly Color4 STABLEFALLBACK = new Color4(34, 153, 187, 255); - public static readonly Color4 BETA = new Color4(255, 221, 85, 255); - public static readonly Color4 CUTTINGEDGE = new Color4(238, 170, 0, 255); - public static readonly Color4 LAZER = new Color4(237, 18, 33, 255); - public static readonly Color4 WEB = new Color4(136, 102, 238, 255); - - private static readonly Dictionary colours = new Dictionary - { - { "stable40", STABLE }, - { "Stable", STABLE }, - { "stable", STABLEFALLBACK }, - { "Stable Fallback", STABLEFALLBACK }, - { "beta40", BETA }, - { "Beta", BETA }, - { "cuttingedge", CUTTINGEDGE }, - { "Cutting Edge", CUTTINGEDGE }, - { "lazer", LAZER }, - { "Lazer", LAZER }, - { "web", WEB }, - }; - - public static ColourInfo FromStreamName(string name) - { - if (!string.IsNullOrEmpty(name)) - if (colours.TryGetValue(name, out ColourInfo colour)) - return colour; - - return new Color4(0, 0, 0, 255); - } - } -} diff --git a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs index 25f1a413d6..4c65b562dd 100644 --- a/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs +++ b/osu.Game/Online/API/Requests/Responses/APIUpdateStream.cs @@ -3,6 +3,8 @@ using System; using Newtonsoft.Json; +using osu.Framework.Graphics.Colour; +using osuTK.Graphics; namespace osu.Game.Online.API.Requests.Responses { @@ -30,5 +32,35 @@ namespace osu.Game.Online.API.Requests.Responses return Id == other.Id; } + + public ColourInfo Colour + { + get + { + switch (Name) + { + case "stable40": + return new Color4(102, 204, 255, 255); + + case "stable": + return new Color4(34, 153, 187, 255); + + case "beta40": + return new Color4(255, 221, 85, 255); + + case "cuttingedge": + return new Color4(238, 170, 0, 255); + + case "lazer": + return new Color4(237, 18, 33, 255); + + case "web": + return new Color4(136, 102, 238, 255); + + default: + return new Color4(0, 0, 0, 255); + } + } + } } } diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index 9f3da7eade..52186ec37c 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -75,7 +75,7 @@ namespace osu.Game.Overlays.Changelog { Text = build.DisplayVersion, Font = OsuFont.GetFont(weight: FontWeight.Light, size: 24), - Colour = StreamColour.FromStreamName(build.UpdateStream.Name), + Colour = build.UpdateStream.Colour, }, } }, @@ -156,7 +156,7 @@ namespace osu.Game.Overlays.Changelog { Text = build.DisplayVersion, Font = OsuFont.GetFont(weight: FontWeight.Light, size: 19), - Colour = StreamColour.FromStreamName(build.UpdateStream.Name), + Colour = build.UpdateStream.Colour, }, }, } diff --git a/osu.Game/Overlays/Changelog/StreamBadge.cs b/osu.Game/Overlays/Changelog/StreamBadge.cs index 2be6aba926..61bdf9f537 100644 --- a/osu.Game/Overlays/Changelog/StreamBadge.cs +++ b/osu.Game/Overlays/Changelog/StreamBadge.cs @@ -73,7 +73,7 @@ namespace osu.Game.Overlays.Changelog lineBadge = new LineBadge(false) { Anchor = Anchor.TopCentre, - Colour = StreamColour.FromStreamName(stream.Name), + Colour = stream.Colour, UncollapsedSize = 4, CollapsedSize = 2, },