-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4e7e96
commit d20366d
Showing
3 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
osu.Game.Rulesets.Karaoke/Overlays/Changelog/ChangelogBadgeInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Collections.Generic; | ||
using osu.Framework.Extensions.Color4Extensions; | ||
using osuTK.Graphics; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Overlays.Changelog; | ||
|
||
public class ChangelogBadgeInfo | ||
{ | ||
// follow the definition in the https://github.com/karaoke-dev/karaoke-dev.github.io/blob/master/layouts/partials/script/badge.html | ||
private static readonly IDictionary<string, string> colour_mappings = new Dictionary<string, string> | ||
{ | ||
{ "outdated", "#808080" }, | ||
{ "rejected", "#FF0000" }, | ||
}; | ||
|
||
public Color4 Color { get; init; } = Color4.White; | ||
|
||
public string Text { get; init; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Trying to parse the badge from the text. | ||
/// </summary> | ||
/// <example> | ||
/// [outdated]<br/> | ||
/// [rejected] | ||
/// </example> | ||
/// <param name="text">Link text</param> | ||
/// <returns></returns> | ||
public static ChangelogBadgeInfo? GetBadgeInfoFromLink(string text) | ||
{ | ||
if (!colour_mappings.TryGetValue(text, out string? repoUrl)) | ||
return null; | ||
|
||
return new ChangelogBadgeInfo | ||
{ | ||
Text = text, | ||
Color = Color4Extensions.FromHex(repoUrl), | ||
}; | ||
} | ||
} |