Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
CoreExtension.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5public static class CoreExtension
6{
7 public static Color GetFixedColor(Color c, bool dark)
8 {
9 float num = 0.5f;
10 SkinColorProfile @default = (dark ? SkinManager.Instance.skinDark.colors : SkinManager.CurrentSkin.colors)._default;
11 float num2 = 1f + @default.contrast;
12 num = ((!(c.r + c.g + c.b > 1.5f)) ? (0.5f - @default.strength) : (0.5f + @default.strength));
13 c.r = Mathf.Clamp((c.r - 0.5f) * num2 + num, 0f, 1f);
14 c.g = Mathf.Clamp((c.g - 0.5f) * num2 + num, 0f, 1f);
15 c.b = Mathf.Clamp((c.b - 0.5f) * num2 + num, 0f, 1f);
16 return c;
17 }
18
19 public static string TagColorGoodBad(this string s, Func<bool> funcGood, bool dark = false)
20 {
21 SkinColorProfile @default = (dark ? SkinManager.Instance.skinDark.colors : SkinManager.CurrentSkin.colors)._default;
22 return "<color=" + GetFixedColor(funcGood() ? @default.textGood : @default.textBad, dark).ToHex() + ">" + s + "</color>";
23 }
24
25 public static string TagColorGoodBad(this string s, Func<bool> funcGood, Func<bool> funcBad, bool dark = false)
26 {
27 SkinColorProfile @default = (dark ? SkinManager.Instance.skinDark.colors : SkinManager.CurrentSkin.colors)._default;
28 bool flag = funcGood();
29 bool flag2 = funcBad();
30 if (!flag && !flag2)
31 {
32 return s;
33 }
34 return "<color=" + GetFixedColor(flag ? @default.textGood : @default.textBad, dark).ToHex() + ">" + s + "</color>";
35 }
36
37 public static UICurrency AttachCurrency(this Window window)
38 {
39 return Util.Instantiate<UICurrency>("UI/Util/UICurrency", window.transform);
40 }
41
42 public static string TagColor(this string s, FontColor c, SkinColorProfile colors = null)
43 {
44 return s.TagColor((colors ?? SkinManager.CurrentColors).GetTextColor(c));
45 }
46
47 public static string TagColor(this string text, Func<bool> funcGood, SkinColorProfile colors = null)
48 {
49 SkinColorProfile skinColorProfile = colors ?? SkinManager.CurrentColors;
50 return text.TagColor(funcGood() ? skinColorProfile.textGood : skinColorProfile.textBad);
51 }
52
53 public static string TagColor(this string text, Func<bool> funcGood, Func<bool> funcBad, SkinColorProfile colors = null)
54 {
55 SkinColorProfile skinColorProfile = colors ?? SkinManager.CurrentColors;
56 return text.TagColor(funcGood() ? skinColorProfile.textGood : ((funcBad != null && funcBad()) ? skinColorProfile.textBad : skinColorProfile.textDefault));
57 }
58
59 public static void Sort(this List<Thing> things, UIList.SortMode m, bool ascending = false)
60 {
61 foreach (Thing thing in things)
62 {
63 thing.SetSortVal(m);
64 }
65 things.Sort(delegate(Thing a, Thing b)
66 {
67 if (m == UIList.SortMode.ByName)
68 {
69 if (ascending)
70 {
71 return string.Compare(a.GetName(NameStyle.FullNoArticle, 1), b.GetName(NameStyle.FullNoArticle, 1));
72 }
73 return string.Compare(b.GetName(NameStyle.FullNoArticle, 1), a.GetName(NameStyle.FullNoArticle, 1));
74 }
75 if (a.sortVal == b.sortVal)
76 {
77 return b.SecondaryCompare(m, a);
78 }
79 return (!ascending) ? (a.sortVal - b.sortVal) : (b.sortVal - a.sortVal);
80 });
81 }
82}
FontColor
Definition: FontColor.cs:2
NameStyle
Definition: NameStyle.cs:2
int sortVal
Definition: Card.cs:97
virtual void SetSortVal(UIList.SortMode m, CurrencyType currency=CurrencyType.Money)
Definition: Card.cs:6857
static Color GetFixedColor(Color c, bool dark)
Definition: CoreExtension.cs:7
static string TagColor(this string text, Func< bool > funcGood, Func< bool > funcBad, SkinColorProfile colors=null)
static string TagColor(this string text, Func< bool > funcGood, SkinColorProfile colors=null)
static void Sort(this List< Thing > things, UIList.SortMode m, bool ascending=false)
static string TagColorGoodBad(this string s, Func< bool > funcGood, Func< bool > funcBad, bool dark=false)
static UICurrency AttachCurrency(this Window window)
static string TagColor(this string s, FontColor c, SkinColorProfile colors=null)
static string TagColorGoodBad(this string s, Func< bool > funcGood, bool dark=false)
static SkinColorProfile CurrentColors
Definition: SkinManager.cs:84
static SkinRootStatic CurrentSkin
Definition: SkinManager.cs:82
SkinColors colors
Definition: Thing.cs:8
override string GetName(NameStyle style, int _num=-1)
Definition: Thing.cs:494
Definition: UIList.cs:9
SortMode
Definition: UIList.cs:27
Definition: Window.cs:13