celeste-avali-skin/SourceCode/Misc.cs

57 lines
2.2 KiB
C#

using System.Collections.Generic;
using Microsoft.Xna.Framework;
using YamlDotNet.Serialization;
using Monocle;
using CC = Celeste.Mod.AvaliSkin.AvaliSkinSettings.ColorChoice;
namespace Celeste.Mod.AvaliSkin {
public static class Misc {
public static string DialogOrKey(this string key, Language lang = null) {
return key.DialogCleanOrNull(lang) ?? key;
}
}
// This is a "never/empty type" in C#. It is impossible to construct.
// Used in cases where a variable should never be initialized.
public enum Void {}
public class ColorUtil {
public static Color SettingToColor(CC col) {
switch (col) {
case CC.Beige: return new Color(162, 133, 92);
case CC.Black: return new Color(0, 0, 0);
case CC.BlueDark: return new Color(22, 42, 162);
case CC.BlueLight: return new Color(50, 151, 223);
case CC.Brown: return new Color(98, 75, 33);
case CC.Cyan: return new Color(26, 225, 225);
case CC.GreenDark: return new Color(41, 132, 49);
case CC.GreenLight: return new Color(59, 219, 47);
case CC.GreyDark: return new Color(60, 60, 60);
case CC.GreyLight: return new Color(168, 168, 168);
case CC.Magenta: return new Color(228, 14, 155);
case CC.Orange: return new Color(237, 147, 32);
case CC.Pink: return new Color(233, 106, 252);
case CC.Purple: return new Color(190, 23, 214);
case CC.Red: return new Color(238, 17, 34);
case CC.Turquoise: return new Color(26, 213, 137);
case CC.White: return new Color(255, 255, 255);
case CC.Yellow: return new Color(244, 226, 15);
default: return new Color(26, 213, 137);
}
}
public static string ColorToHex(Color color) {
return $"#{color.R:x2}{color.G:x2}{color.B:x2}";
}
public static Color HexToColor(string hex) {
return Monocle.Calc.HexToColor(hex);
}
}
}