Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
HyphenationJpn Class Reference
Inheritance diagram for HyphenationJpn:

Public Member Functions

void _SetText (string str, bool useHypenation)
 
float GetWidth ()
 

Public Attributes

int padding
 
bool useParentWidth = true
 
bool usePreferredWidth = true
 
bool evaluateLate
 

Properties

RectTransform _RectTransform [get]
 
Text _Text [get]
 

Private Member Functions

void UpdateText (string str)
 
float GetSpaceWidth ()
 
float GetTextWidth (string message)
 
string GetFormatedText (string msg)
 
List< string > GetWordList (string tmpText)
 

Static Private Member Functions

static bool CHECK_HYP_FRONT (char str)
 
static bool CHECK_HYP_BACK (char str)
 
static bool IsLatin (char s)
 

Private Attributes

string text
 
bool useHypenation
 
RectTransform _rectTransform
 
Text _text
 
float width
 

Static Private Attributes

static readonly string RITCH_TEXT_REPLACE = "(\<color=.*\>|</color>|\<size=.n\\>|</size>|<b>|</b>|<i>|</i>)"
 
static readonly char[] HYP_FRONT = ",)]}、。)〕〉》」』】〙〗〟’”⦆»ァィゥェォッャュョヮヵヶっぁぃぅぇぉっゃゅょゎ‐゠–〜ー?!!?‼⁇⁈⁉・:;。.".ToCharArray()
 
static readonly char[] HYP_BACK = "(([{〔〈《「『【〘〖〝‘“⦅«".ToCharArray()
 
static readonly char[] HYP_LATIN = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<>=/().,".ToCharArray()
 

Detailed Description

Definition at line 10 of file HyphenationJpn.cs.

Member Function Documentation

◆ _SetText()

void HyphenationJpn._SetText ( string  str,
bool  useHypenation 
)
inline

Definition at line 70 of file HyphenationJpn.cs.

71 {
72 text = str;
73 this.useHypenation = useHypenation;
74 if (!useHypenation)
75 {
76 _Text.horizontalOverflow = HorizontalWrapMode.Wrap;
77 _Text.text = text;
78 return;
79 }
80 _Text.text = text;
81 width = GetWidth();
82 if (width < 50f)
83 {
84 this.RebuildLayoutTo<Canvas>();
85 this.RebuildLayout();
86 width = GetWidth();
87 if (width < 50f)
88 {
90 {
91 width = GetWidth();
93 this.RebuildLayout();
94 });
95 }
96 else
97 {
99 this.RebuildLayout();
100 }
101 }
102 else
103 {
105 }
106 }
List< Action > actionsNextFrame
Definition: BaseCore.cs:31
static BaseCore Instance
Definition: BaseCore.cs:11
void UpdateText(string str)

References BaseCore.actionsNextFrame, GetWidth(), BaseCore.Instance, text, UpdateText(), useHypenation, and width.

Referenced by UIText.SetText().

◆ CHECK_HYP_BACK()

static bool HyphenationJpn.CHECK_HYP_BACK ( char  str)
inlinestaticprivate

Definition at line 224 of file HyphenationJpn.cs.

225 {
226 return Array.Exists(HYP_BACK, (char item) => item == str);
227 }
static readonly char[] HYP_BACK

References HYP_BACK, and item.

Referenced by GetWordList().

◆ CHECK_HYP_FRONT()

static bool HyphenationJpn.CHECK_HYP_FRONT ( char  str)
inlinestaticprivate

Definition at line 219 of file HyphenationJpn.cs.

220 {
221 return Array.Exists(HYP_FRONT, (char item) => item == str);
222 }
static readonly char[] HYP_FRONT

References HYP_FRONT, and item.

Referenced by GetWordList().

◆ GetFormatedText()

string HyphenationJpn.GetFormatedText ( string  msg)
inlineprivate

Definition at line 148 of file HyphenationJpn.cs.

149 {
150 if (string.IsNullOrEmpty(msg))
151 {
152 return string.Empty;
153 }
154 msg = Regex.Replace(msg, "\\n", "〒");
155 float num = width;
156 float spaceWidth = GetSpaceWidth();
157 _Text.horizontalOverflow = HorizontalWrapMode.Overflow;
158 StringBuilder stringBuilder = new StringBuilder();
159 float num2 = 0f;
160 foreach (string word in GetWordList(msg))
161 {
162 string text = word;
163 num2 += GetTextWidth(text);
164 if (text.StartsWith("〒"))
165 {
166 num2 = 0f;
167 stringBuilder.AppendLine();
168 text = text.Replace("〒", "");
169 }
170 if (text == "〒")
171 {
172 num2 = 0f;
173 stringBuilder.AppendLine();
174 continue;
175 }
176 if (text == " ")
177 {
178 num2 += spaceWidth;
179 }
180 if (num2 > num - (float)padding)
181 {
182 stringBuilder.Append(Environment.NewLine);
183 num2 = GetTextWidth(text);
184 }
185 stringBuilder.Append(text);
186 }
187 return stringBuilder.ToString();
188 }
List< string > GetWordList(string tmpText)
float GetTextWidth(string message)
float GetSpaceWidth()

References GetSpaceWidth(), GetTextWidth(), GetWordList(), padding, text, and width.

Referenced by UpdateText().

◆ GetSpaceWidth()

float HyphenationJpn.GetSpaceWidth ( )
inlineprivate

Definition at line 131 of file HyphenationJpn.cs.

132 {
133 float textWidth = GetTextWidth("m m");
134 float textWidth2 = GetTextWidth("mm");
135 return textWidth - textWidth2;
136 }

References GetTextWidth().

Referenced by GetFormatedText().

◆ GetTextWidth()

float HyphenationJpn.GetTextWidth ( string  message)
inlineprivate

Definition at line 138 of file HyphenationJpn.cs.

139 {
140 if (_text.supportRichText)
141 {
142 message = Regex.Replace(message, RITCH_TEXT_REPLACE, string.Empty);
143 }
144 _Text.text = message;
145 return _Text.preferredWidth;
146 }
static readonly string RITCH_TEXT_REPLACE

References _text, _Text, Empty, and RITCH_TEXT_REPLACE.

Referenced by GetFormatedText(), and GetSpaceWidth().

◆ GetWidth()

float HyphenationJpn.GetWidth ( )
inline

Definition at line 108 of file HyphenationJpn.cs.

109 {
111 {
112 LayoutElement component = GetComponent<LayoutElement>();
113 if ((bool)component && component.enabled && component.preferredWidth != -1f)
114 {
115 return component.preferredWidth;
116 }
117 }
118 if ((bool)base.transform.parent && useParentWidth)
119 {
120 LayoutGroup component2 = base.transform.parent.GetComponent<LayoutGroup>();
121 float num = base.transform.parent.Rect().rect.width;
122 if ((bool)component2)
123 {
124 num = num - (float)component2.padding.left - (float)component2.padding.right;
125 }
126 return num;
127 }
128 return _RectTransform.rect.width;
129 }
RectTransform _RectTransform

References _RectTransform, useParentWidth, and usePreferredWidth.

Referenced by _SetText().

◆ GetWordList()

List< string > HyphenationJpn.GetWordList ( string  tmpText)
inlineprivate

Definition at line 190 of file HyphenationJpn.cs.

191 {
192 List<string> list = new List<string>();
193 StringBuilder stringBuilder = new StringBuilder();
194 char c = '\0';
195 bool flag = false;
196 for (int i = 0; i < tmpText.Length; i++)
197 {
198 char c2 = tmpText[i];
199 char c3 = ((i < tmpText.Length - 1) ? tmpText[i + 1] : c);
200 char c4 = ((i <= 0) ? c : (c4 = tmpText[i - 1]));
201 if (c2 == '<')
202 {
203 flag = true;
204 }
205 if (c2 == '>')
206 {
207 flag = false;
208 }
209 stringBuilder.Append(c2);
210 if (!flag && ((IsLatin(c2) && IsLatin(c4) && IsLatin(c2) && !IsLatin(c4)) || (!IsLatin(c2) && CHECK_HYP_BACK(c4)) || (!IsLatin(c3) && !CHECK_HYP_FRONT(c3) && !CHECK_HYP_BACK(c2)) || i == tmpText.Length - 1))
211 {
212 list.Add(stringBuilder.ToString());
213 stringBuilder = new StringBuilder();
214 }
215 }
216 return list;
217 }
static bool CHECK_HYP_BACK(char str)
static bool IsLatin(char s)
static bool CHECK_HYP_FRONT(char str)

References CHECK_HYP_BACK(), CHECK_HYP_FRONT(), and IsLatin().

Referenced by GetFormatedText().

◆ IsLatin()

static bool HyphenationJpn.IsLatin ( char  s)
inlinestaticprivate

Definition at line 229 of file HyphenationJpn.cs.

230 {
231 return false;
232 }

Referenced by GetWordList().

◆ UpdateText()

void HyphenationJpn.UpdateText ( string  str)
inlineprivate

Definition at line 62 of file HyphenationJpn.cs.

63 {
64 if (useHypenation)
65 {
66 _Text.text = GetFormatedText(str).IsEmpty(str);
67 }
68 }
string GetFormatedText(string msg)

References GetFormatedText(), and useHypenation.

Referenced by _SetText().

Member Data Documentation

◆ _rectTransform

RectTransform HyphenationJpn._rectTransform
private

Definition at line 24 of file HyphenationJpn.cs.

◆ _text

Text HyphenationJpn._text
private

Definition at line 26 of file HyphenationJpn.cs.

Referenced by GetTextWidth().

◆ evaluateLate

bool HyphenationJpn.evaluateLate

Definition at line 18 of file HyphenationJpn.cs.

Referenced by UIText.SetText().

◆ HYP_BACK

readonly char [] HyphenationJpn.HYP_BACK = "(([{〔〈《「『【〘〖〝‘“⦅«".ToCharArray()
staticprivate

Definition at line 34 of file HyphenationJpn.cs.

Referenced by CHECK_HYP_BACK().

◆ HYP_FRONT

readonly char [] HyphenationJpn.HYP_FRONT = ",)]}、。)〕〉》」』】〙〗〟’”⦆»ァィゥェォッャュョヮヵヶっぁぃぅぇぉっゃゅょゎ‐゠–〜ー?!!?‼⁇⁈⁉・:;。.".ToCharArray()
staticprivate

Definition at line 32 of file HyphenationJpn.cs.

Referenced by CHECK_HYP_FRONT().

◆ HYP_LATIN

readonly char [] HyphenationJpn.HYP_LATIN = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<>=/().,".ToCharArray()
staticprivate

Definition at line 36 of file HyphenationJpn.cs.

◆ padding

int HyphenationJpn.padding

Definition at line 12 of file HyphenationJpn.cs.

Referenced by GetFormatedText().

◆ RITCH_TEXT_REPLACE

readonly string HyphenationJpn.RITCH_TEXT_REPLACE = "(\<color=.*\>|</color>|\<size=.n\\>|</size>|<b>|</b>|<i>|</i>)"
staticprivate

Definition at line 30 of file HyphenationJpn.cs.

Referenced by GetTextWidth().

◆ text

string HyphenationJpn.text
private

Definition at line 20 of file HyphenationJpn.cs.

Referenced by _SetText(), and GetFormatedText().

◆ useHypenation

bool HyphenationJpn.useHypenation
private

Definition at line 22 of file HyphenationJpn.cs.

Referenced by _SetText(), and UpdateText().

◆ useParentWidth

bool HyphenationJpn.useParentWidth = true

Definition at line 14 of file HyphenationJpn.cs.

Referenced by GetWidth().

◆ usePreferredWidth

bool HyphenationJpn.usePreferredWidth = true

Definition at line 16 of file HyphenationJpn.cs.

Referenced by GetWidth().

◆ width

float HyphenationJpn.width
private

Definition at line 28 of file HyphenationJpn.cs.

Referenced by _SetText(), and GetFormatedText().

Property Documentation

◆ _RectTransform

RectTransform HyphenationJpn._RectTransform
getprivate

Definition at line 38 of file HyphenationJpn.cs.

39 {
40 get
41 {
42 if (_rectTransform == null)
43 {
44 _rectTransform = GetComponent<RectTransform>();
45 }
46 return _rectTransform;
47 }
48 }
RectTransform _rectTransform

Referenced by GetWidth().

◆ _Text

Text HyphenationJpn._Text
get

Definition at line 50 of file HyphenationJpn.cs.

51 {
52 get
53 {
54 if (_text == null)
55 {
56 _text = GetComponent<Text>();
57 }
58 return _text;
59 }
60 }

Referenced by GetTextWidth().


The documentation for this class was generated from the following file: