Refactor update stream colour mapping code

This commit is contained in:
Bartłomiej Dach 2020-12-25 18:39:55 +01:00
parent b448fd1b8b
commit 0bd9f68cbd

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Framework.Graphics.Colour;
using osuTK.Graphics;
@ -27,34 +28,16 @@ namespace osu.Game.Online.API.Requests.Responses
public bool Equals(APIUpdateStream other) => Id == other?.Id;
public ColourInfo Colour
internal static readonly Dictionary<string, Color4> KNOWN_STREAMS = new Dictionary<string, Color4>
{
get
{
switch (Name)
{
case "stable40":
return new Color4(102, 204, 255, 255);
["stable40"] = new Color4(102, 204, 255, 255),
["stable"] = new Color4(34, 153, 187, 255),
["beta40"] = new Color4(255, 221, 85, 255),
["cuttingedge"] = new Color4(238, 170, 0, 255),
[OsuGameBase.CLIENT_STREAM_NAME] = new Color4(237, 18, 33, 255),
["web"] = new Color4(136, 102, 238, 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 OsuGameBase.CLIENT_STREAM_NAME:
return new Color4(237, 18, 33, 255);
case "web":
return new Color4(136, 102, 238, 255);
default:
return new Color4(0, 0, 0, 255);
}
}
}
public ColourInfo Colour => KNOWN_STREAMS.TryGetValue(Name, out var colour) ? colour : new Color4(0, 0, 0, 255);
}
}