Elin Decompiled Documentation EA 23.288 Nightly
Loading...
Searching...
No Matches
UIText.cs
Go to the documentation of this file.
1using System;
2using UnityEngine;
3using UnityEngine.UI;
4
5public class UIText : Text, IUISkin
6{
7 public static int globalSizeMod;
8
9 public string lang;
10
12
14
16
18
19 public int size;
20
22
24
26
27 public float orgSpacing;
28
29 [NonSerialized]
30 public int orgSize;
31
32 [NonSerialized]
33 public Color orgColor = Color.white;
34
35 protected override void Awake()
36 {
37 orgSize = size;
38 ApplySkin();
39 base.Awake();
40 }
41
42 public void ApplySkin()
43 {
44 if (!Application.isPlaying)
45 {
46 return;
47 }
49 int num = size + 19 + globalSizeMod;
50 SkinManager.FontSet fontSet = instance.fontSet;
51 FontSource fontSource = instance.FontList[0];
52 if (fontType != FontType.DontChange)
53 {
54 int num2 = 0;
55 switch (fontType)
56 {
57 case FontType.UI:
58 fontSource = fontSet.ui.source;
59 num2 = Mathf.Min(fontSet.ui.sizeMod, SkinManager.LimitFontSizeMod_UI);
60 break;
61 case FontType.Widget:
62 fontSource = fontSet.widget.source;
63 num2 = fontSet.widget.sizeMod;
64 break;
65 case FontType.Chatbox:
66 fontSource = fontSet.chatbox.source;
67 num2 = fontSet.chatbox.sizeMod;
68 break;
69 case FontType.Balloon:
70 fontSource = fontSet.balloon.source;
71 num2 = fontSet.balloon.sizeMod;
72 break;
73 case FontType.Dialog:
74 fontSource = fontSet.dialog.source;
75 num2 = fontSet.dialog.sizeMod;
76 break;
77 case FontType.News:
78 fontSource = fontSet.news.source;
79 num2 = fontSet.news.sizeMod;
80 break;
81 }
82 if (fontSource == null)
83 {
84 fontSource = instance.FontList[0];
85 }
86 base.font = fontSource.font;
87 num += fontSource.sizeFix + num2;
88 }
89 if (base.fontSize != num)
90 {
91 base.fontSize = num;
92 }
93 if (base.resizeTextForBestFit)
94 {
95 base.resizeTextMaxSize = base.fontSize;
96 }
97 if ((bool)button && (bool)button.skinRoot)
98 {
99 SkinAsset_Button skinAsset_Button = button.skinRoot.GetButton();
100 if (fontColor != 0)
101 {
102 this.color = skinAsset_Button.textColor;
103 }
104 Shadow component = GetComponent<Shadow>();
105 if (skinAsset_Button.textShadow)
106 {
107 if ((bool)component)
108 {
109 component.enabled = true;
110 component.effectColor = skinAsset_Button.textShadowColor;
111 }
112 }
113 else if ((bool)component)
114 {
115 component.enabled = false;
116 }
117 return;
118 }
119 if (orgSpacing == 0f)
120 {
121 orgSpacing = base.lineSpacing;
122 }
123 if (fontColor == FontColor.DontChange && orgColor == Color.white)
124 {
125 orgColor = this.color;
126 }
128 SkinColorProfile colors = obj.GetColors(skinType);
129 float num3 = 0.5f;
130 bool flag = fontColor == FontColor.DontChange;
131 float num4 = 1f + (flag ? 0f : colors.contrast) + fontSource.contrast;
132 obj.ApplySkin(this, fontSource);
133 Color color = (flag ? orgColor : colors.GetTextColor(fontColor));
134 if (base.fontStyle == FontStyle.Bold)
135 {
136 if (fontSource.alwaysBold)
137 {
138 base.fontStyle = FontStyle.Normal;
139 }
140 else
141 {
142 color.a *= fontSource.boldAlpha;
143 }
144 }
145 num3 = ((!(color.r + color.g + color.b > 1.5f)) ? (0.5f - (flag ? 0f : colors.strength) - (Lang.isJP ? (fontSource.strength + fontSource.strengthFixJP) : fontSource.strength)) : (0.5f + (flag ? 0f : colors.strength) + (Lang.isJP ? (fontSource.strength + fontSource.strengthFixJP) : fontSource.strength)));
146 color.r = (color.r - 0.5f) * num4 + num3;
147 color.g = (color.g - 0.5f) * num4 + num3;
148 color.b = (color.b - 0.5f) * num4 + num3;
149 this.color = color;
150 base.lineSpacing = orgSpacing * fontSource.lineSpacing;
151 _ = (bool)hyphenation;
152 }
153
154 protected override void OnEnable()
155 {
156 base.OnEnable();
157 if (!string.IsNullOrEmpty(lang))
158 {
159 m_Text = Lang.Get(lang);
160 }
161 }
162
163 public void SetText(string s)
164 {
165 if (s == null)
166 {
167 s = "";
168 }
169 if ((bool)hyphenation)
170 {
172 {
174 {
176 {
177 if (this != null)
178 {
180 hyphenation.RebuildLayoutTo<Canvas>();
181 }
182 });
183 }
184 else
185 {
187 }
188 }
189 else
190 {
191 base.horizontalOverflow = HorizontalWrapMode.Wrap;
192 text = s;
193 }
194 }
195 else
196 {
197 text = s;
198 }
199 lang = null;
200 OnSetText();
201 }
202
203 public void SetText(string s, Color c)
204 {
205 SetText(s);
206 fontColor = FontColor.DontChange;
207 orgColor = c;
208 color = c;
209 OnSetText();
210 }
211
212 public void SetText(string s, FontColor c)
213 {
214 SetText(s);
215 if (c != FontColor.Ignore)
216 {
217 fontColor = c;
218 ApplySkin();
219 }
220 OnSetText();
221 }
222
223 private void OnSetText()
224 {
225 if ((bool)typewriter)
226 {
228 }
229 }
230
231 public UIText SetSize(int a)
232 {
233 size = a;
234 ApplySkin();
235 return this;
236 }
237
238 public void SetColor(FontColor c)
239 {
240 fontColor = c;
241 ApplySkin();
242 }
243
244 public void SetLang(string idLang)
245 {
246 lang = idLang;
247 text = Lang.Get(lang);
248 }
249
250 public void OnChangeLanguage()
251 {
252 if (!string.IsNullOrEmpty(lang))
253 {
254 text = Lang.Get(lang);
255 }
256 }
257}
FontColor
Definition: FontColor.cs:2
FontType
Definition: FontType.cs:2
SkinType
Definition: SkinType.cs:2
static BaseCore Instance
Definition: BaseCore.cs:11
List< Action > actionsLateUpdate
Definition: BaseCore.cs:29
virtual void ApplySkin(UIImage t)
Definition: BaseSkinRoot.cs:16
virtual SkinColorProfile GetColors(SkinType type)
Definition: BaseSkinRoot.cs:11
virtual SkinAsset_Button GetButton()
Definition: BaseSkinRoot.cs:28
float strength
Definition: FontSource.cs:21
bool alwaysBold
Definition: FontSource.cs:15
float contrast
Definition: FontSource.cs:19
float strengthFixJP
Definition: FontSource.cs:23
float lineSpacing
Definition: FontSource.cs:25
float boldAlpha
Definition: FontSource.cs:17
Font font
Definition: FontSource.cs:9
void _SetText(string str, bool useHypenation)
bool hyphenation
Definition: LangSetting.cs:38
Definition: Lang.cs:7
static LangSetting setting
Definition: Lang.cs:55
static string Get(string id)
Definition: Lang.cs:94
static bool isJP
Definition: Lang.cs:39
Color GetTextColor(FontColor fontColor)
FontSet fontSet
Definition: SkinManager.cs:74
static SkinRootStatic CurrentSkin
Definition: SkinManager.cs:82
static SkinManager Instance
Definition: SkinManager.cs:78
List< FontSource > FontList
Definition: SkinManager.cs:80
static int LimitFontSizeMod_UI
Definition: SkinManager.cs:43
void OnSetText()
Definition: Typewriter.cs:38
BaseSkinRoot skinRoot
Definition: UIButton.cs:142
Definition: UIText.cs:6
int size
Definition: UIText.cs:19
void SetText(string s, Color c)
Definition: UIText.cs:203
void ApplySkin()
Definition: UIText.cs:42
Color orgColor
Definition: UIText.cs:33
UIButton button
Definition: UIText.cs:23
string lang
Definition: UIText.cs:9
FontType fontType
Definition: UIText.cs:13
void SetText(string s)
Definition: UIText.cs:163
SkinType skinType
Definition: UIText.cs:17
HyphenationJpn hyphenation
Definition: UIText.cs:21
void OnSetText()
Definition: UIText.cs:223
void SetColor(FontColor c)
Definition: UIText.cs:238
static int globalSizeMod
Definition: UIText.cs:7
void OnChangeLanguage()
Definition: UIText.cs:250
int orgSize
Definition: UIText.cs:30
override void Awake()
Definition: UIText.cs:35
float orgSpacing
Definition: UIText.cs:27
UIText SetSize(int a)
Definition: UIText.cs:231
BaseSkinRoot skinRoot
Definition: UIText.cs:11
void SetLang(string idLang)
Definition: UIText.cs:244
void SetText(string s, FontColor c)
Definition: UIText.cs:212
Typewriter typewriter
Definition: UIText.cs:25
override void OnEnable()
Definition: UIText.cs:154
FontColor fontColor
Definition: UIText.cs:15