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