// Token: 0x06000338 RID: 824 RVA: 0x000258A4 File Offset: 0x00023AA4 public string GetEndOfLineThatFits(string text, float maxWidth, bool encoding, UIFont.SymbolStyle symbolStyle) { if (this.mReplacement != null) { return(this.mReplacement.GetEndOfLineThatFits(text, maxWidth, encoding, symbolStyle)); } int num = Mathf.RoundToInt(maxWidth * (float)this.size); if (num < 1) { return(text); } int length = text.Length; int num2 = num; BMGlyph bmglyph = null; int num3 = length; bool flag = encoding && symbolStyle != UIFont.SymbolStyle.None && this.hasSymbols; bool isDynamic = this.isDynamic; if (isDynamic) { this.mDynamicFont.textureRebuildCallback = new Font.FontTextureRebuildCallback(this.OnFontChanged); this.mDynamicFont.RequestCharactersInTexture(text, this.mDynamicFontSize, this.mDynamicFontStyle); this.mDynamicFont.textureRebuildCallback = null; } while (num3 > 0 && num2 > 0) { char c = text[--num3]; BMSymbol bmsymbol = (!flag) ? null : this.MatchSymbol(text, num3, length); int num4 = this.mSpacingX; if (!isDynamic) { if (bmsymbol != null) { num4 += bmsymbol.advance; } else { BMGlyph glyph = this.mFont.GetGlyph((int)c); if (glyph == null) { bmglyph = null; continue; } num4 += glyph.advance + ((bmglyph != null) ? bmglyph.GetKerning((int)c) : 0); bmglyph = glyph; } } else if (this.mDynamicFont.GetCharacterInfo(c, out UIFont.mChar, this.mDynamicFontSize, this.mDynamicFontStyle)) { num4 += (int)UIFont.mChar.width; } num2 -= num4; } if (num2 < 0) { num3++; } return(text.Substring(num3, length - num3)); }
public override void OnFill(MeshBuffer m) { if (this.mFont == null) { return; } Color color = (!this.mInvisibleHack ? base.color : Color.clear); this.MakePositionPerfect(); UIWidget.Pivot pivot = base.pivot; int num = m.vSize; if (pivot != UIWidget.Pivot.Left && pivot != UIWidget.Pivot.TopLeft && pivot != UIWidget.Pivot.BottomLeft) { if (pivot == UIWidget.Pivot.Right || pivot == UIWidget.Pivot.TopRight || pivot == UIWidget.Pivot.BottomRight) { UIFont uIFont = this.mFont; string str = this.processedText; bool flag = this.mEncoding; UIFont.SymbolStyle symbolStyle = this.mSymbols; Vector2 vector2 = this.relativeSize; uIFont.Print(str, color, m, flag, symbolStyle, UIFont.Alignment.Right, Mathf.RoundToInt(vector2.x * (float)this.mFont.size), ref this.mSelection, this.mCarratChar, this.mHighlightTextColor, this.mHighlightColor, this.mHighlightChar, this.mHighlightCharSplit); } else { UIFont uIFont1 = this.mFont; string str1 = this.processedText; bool flag1 = this.mEncoding; UIFont.SymbolStyle symbolStyle1 = this.mSymbols; Vector2 vector21 = this.relativeSize; uIFont1.Print(str1, color, m, flag1, symbolStyle1, UIFont.Alignment.Center, Mathf.RoundToInt(vector21.x * (float)this.mFont.size), ref this.mSelection, this.mCarratChar, this.mHighlightTextColor, this.mHighlightColor, this.mHighlightChar, this.mHighlightCharSplit); } } else if (!this.mOverflowRight) { this.mFont.Print(this.processedText, color, m, this.mEncoding, this.mSymbols, UIFont.Alignment.Left, 0, ref this.mSelection, this.mCarratChar, this.mHighlightTextColor, this.mHighlightColor, this.mHighlightChar, this.mHighlightCharSplit); } else { UIFont uIFont2 = this.mFont; string str2 = this.processedText; bool flag2 = this.mEncoding; UIFont.SymbolStyle symbolStyle2 = this.mSymbols; Vector2 vector22 = this.relativeSize; uIFont2.Print(str2, color, m, flag2, symbolStyle2, UIFont.Alignment.LeftOverflowRight, Mathf.RoundToInt(vector22.x * (float)this.mFont.size), ref this.mSelection, this.mCarratChar, this.mHighlightTextColor, this.mHighlightColor, this.mHighlightChar, this.mHighlightCharSplit); } m.ApplyEffect(base.cachedTransform, num, this.effectStyle, this.effectColor, (float)this.mFont.size); }
public UILabel() : base(UIWidget.WidgetFlags.CustomMaterialGet | UIWidget.WidgetFlags.CustomRelativeSize) { this.mText = string.Empty; this.mEncoding = true; this.mEffectColor = Color.black; this.mSymbols = UIFont.SymbolStyle.Uncolored; this.mCarratChar = '|'; this.mHighlightTextColor = Color.cyan; this.mHighlightColor = Color.black; this.mHighlightChar = '|'; this.mHighlightCharSplit = 0.5f; this.mMultiline = true; this.mShouldBeProcessed = true; this.mLastScale = Vector3.one; this.mLastText = string.Empty; this.mLastEncoding = true; this.mLastColor = Color.black; this.mSize = Vector3.zero; }
public override void OnFill(BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols) { if (mFont == null) { return; } Pivot pivot = base.pivot; int size = verts.size; Color c = base.color; c.a *= mPanel.alpha; if (font.premultipliedAlpha) { c = NGUITools.ApplyPMA(c); } switch (pivot) { case Pivot.TopLeft: case Pivot.Left: case Pivot.BottomLeft: mFont.Print(this.processedText, c, verts, uvs, cols, mEncoding, mSymbols, UIFont.Alignment.Left, 0, mPremultiply); break; case Pivot.TopRight: case Pivot.Right: case Pivot.BottomRight: { UIFont uIFont2 = mFont; string processedText2 = this.processedText; Color32 color2 = c; bool encoding2 = mEncoding; UIFont.SymbolStyle symbolStyle2 = mSymbols; Vector2 relativeSize2 = this.relativeSize; uIFont2.Print(processedText2, color2, verts, uvs, cols, encoding2, symbolStyle2, UIFont.Alignment.Right, Mathf.RoundToInt(relativeSize2.x * (float)mFont.size), mPremultiply); break; } default: { UIFont uIFont = mFont; string processedText = this.processedText; Color32 color = c; bool encoding = mEncoding; UIFont.SymbolStyle symbolStyle = mSymbols; Vector2 relativeSize = this.relativeSize; uIFont.Print(processedText, color, verts, uvs, cols, encoding, symbolStyle, UIFont.Alignment.Center, Mathf.RoundToInt(relativeSize.x * (float)mFont.size), mPremultiply); break; } } if (effectStyle != 0) { int size2 = verts.size; float num = 1f / (float)mFont.size; float num2 = num * mEffectDistance.x; float num3 = num * mEffectDistance.y; ApplyShadow(verts, uvs, cols, size, size2, num2, 0f - num3); if (effectStyle == Effect.Outline) { size = size2; size2 = verts.size; ApplyShadow(verts, uvs, cols, size, size2, 0f - num2, num3); size = size2; size2 = verts.size; ApplyShadow(verts, uvs, cols, size, size2, num2, num3); size = size2; size2 = verts.size; ApplyShadow(verts, uvs, cols, size, size2, 0f - num2, 0f - num3); } } }
protected override bool DrawProperties() { mLabel = mWidget as UILabel; ComponentSelector.Draw <UIFont>(mLabel.font, OnSelectFont); if (mLabel.font != null) { GUI.skin.textArea.wordWrap = true; string text = string.IsNullOrEmpty(mLabel.text) ? "" : mLabel.text; text = EditorGUILayout.TextArea(mLabel.text, GUI.skin.textArea, GUILayout.Height(100f)); if (!text.Equals(mLabel.text)) { RegisterUndo(); mLabel.text = text; } GUILayout.BeginHorizontal(); int len = EditorGUILayout.IntField("Max Width", mLabel.lineWidth, GUILayout.Width(120f)); GUILayout.Label("pixels"); GUILayout.EndHorizontal(); if (len != mLabel.lineWidth && len >= 0f) { RegisterUndo(); mLabel.lineWidth = len; } GUILayout.BeginHorizontal(); len = EditorGUILayout.IntField("Max Height", mLabel.lineHeight, GUILayout.Width(120f)); GUILayout.Label("pixels"); GUILayout.EndHorizontal(); if (len != mLabel.lineHeight && len >= 0f) { RegisterUndo(); mLabel.lineHeight = len; } int count = EditorGUILayout.IntField("Max Lines", mLabel.maxLineCount, GUILayout.Width(100f)); if (count != mLabel.maxLineCount) { RegisterUndo(); mLabel.maxLineCount = count; } GUILayout.BeginHorizontal(); bool shrinkToFit = EditorGUILayout.Toggle("Shrink to Fit", mLabel.shrinkToFit, GUILayout.Width(100f)); GUILayout.Label("- adjust scale to fit"); GUILayout.EndHorizontal(); // Gradual Color GUILayout.BeginHorizontal(); bool gradual = EditorGUILayout.Toggle("Gradual Color", mLabel.EnableGradual, GUILayout.Width(100f)); if (gradual) { Color c = EditorGUILayout.ColorField("Start Color", mLabel.GradualColor); if (mLabel.GradualColor != c) { RegisterUndo(); mLabel.GradualColor = c; } } if (mLabel.EnableGradual != gradual) { RegisterUndo(); mLabel.EnableGradual = gradual; } GUILayout.EndHorizontal(); if (shrinkToFit != mLabel.shrinkToFit) { RegisterUndo(); mLabel.shrinkToFit = shrinkToFit; if (!shrinkToFit) { mLabel.MakePixelPerfect(); } } // Only input fields need this setting exposed, and they have their own "is password" setting, so hiding it here. //GUILayout.BeginHorizontal(); //bool password = EditorGUILayout.Toggle("Password", mLabel.password, GUILayout.Width(100f)); //GUILayout.Label("- hide characters"); //GUILayout.EndHorizontal(); //if (password != mLabel.password) { RegisterUndo(); mLabel.password = password; } GUILayout.BeginHorizontal(); bool encoding = EditorGUILayout.Toggle("Encoding", mLabel.supportEncoding, GUILayout.Width(100f)); GUILayout.Label("- use emoticons and colors"); GUILayout.EndHorizontal(); if (encoding != mLabel.supportEncoding) { RegisterUndo(); mLabel.supportEncoding = encoding; } //GUILayout.EndHorizontal(); if (encoding && mLabel.font.hasSymbols) { UIFont.SymbolStyle sym = (UIFont.SymbolStyle)EditorGUILayout.EnumPopup("Symbols", mLabel.symbolStyle, GUILayout.Width(170f)); if (sym != mLabel.symbolStyle) { RegisterUndo(); mLabel.symbolStyle = sym; } } GUILayout.BeginHorizontal(); { UILabel.Effect effect = (UILabel.Effect)EditorGUILayout.EnumPopup("Effect", mLabel.effectStyle, GUILayout.Width(170f)); if (effect != mLabel.effectStyle) { RegisterUndo(); mLabel.effectStyle = effect; } if (effect != UILabel.Effect.None) { Color c = EditorGUILayout.ColorField(mLabel.effectColor); if (mLabel.effectColor != c) { RegisterUndo(); mLabel.effectColor = c; } } } GUILayout.EndHorizontal(); if (mLabel.effectStyle != UILabel.Effect.None) { GUILayout.Label("Distance", GUILayout.Width(70f)); GUILayout.Space(-10f); GUILayout.BeginHorizontal(); GUILayout.Space(70f); Vector2 offset = EditorGUILayout.Vector2Field("", mLabel.effectDistance); GUILayout.Space(20f); if (offset != mLabel.effectDistance) { RegisterUndo(); mLabel.effectDistance = offset; } GUILayout.EndHorizontal(); } return(true); } EditorGUILayout.Space(); return(false); }
override protected bool DrawProperties() { mLabel = mWidget as UILabel; ComponentSelector.Draw <UIFont>(mLabel.font, OnSelectFont); if (mLabel.font != null) { GUI.skin.textArea.wordWrap = true; string text = string.IsNullOrEmpty(mLabel.text) ? "" : mLabel.text; text = EditorGUILayout.TextArea(mLabel.text, GUI.skin.textArea, GUILayout.Height(100f)); if (!text.Equals(mLabel.text)) { RegisterUndo(); mLabel.text = text; } GUILayout.Label("Language Key"); string language = string.IsNullOrEmpty(mLabel.language) ? "" : mLabel.language; language = EditorGUILayout.TextArea(mLabel.language, GUI.skin.textArea, GUILayout.Height(30f)); if (!language.Equals(mLabel.language)) { RegisterUndo(); mLabel.language = language; } GUILayout.BeginHorizontal(); int len = EditorGUILayout.IntField("Max Width", mLabel.lineWidth, GUILayout.Width(120f)); GUILayout.Label("pixels"); GUILayout.EndHorizontal(); if (len != mLabel.lineWidth) { RegisterUndo(); mLabel.lineWidth = len; } int count = EditorGUILayout.IntField("Max Lines", mLabel.maxLineCount, GUILayout.Width(100f)); if (count != mLabel.maxLineCount) { RegisterUndo(); mLabel.maxLineCount = count; } GUILayout.BeginHorizontal(); bool shrinkToFit = EditorGUILayout.Toggle("Shrink to Fit", mLabel.shrinkToFit, GUILayout.Width(100f)); GUILayout.Label("- adjust scale if doesn't fit"); GUILayout.EndHorizontal(); if (shrinkToFit != mLabel.shrinkToFit) { RegisterUndo(); mLabel.shrinkToFit = shrinkToFit; } GUILayout.BeginHorizontal(); bool password = EditorGUILayout.Toggle("Password", mLabel.password, GUILayout.Width(100f)); GUILayout.Label("- hide characters"); GUILayout.EndHorizontal(); if (password != mLabel.password) { RegisterUndo(); mLabel.password = password; } GUILayout.BeginHorizontal(); bool encoding = EditorGUILayout.Toggle("Encoding", mLabel.supportEncoding, GUILayout.Width(100f)); GUILayout.Label("- use emoticons and colors"); GUILayout.EndHorizontal(); if (encoding != mLabel.supportEncoding) { RegisterUndo(); mLabel.supportEncoding = encoding; } GUILayout.BeginHorizontal(); bool isReload = EditorGUILayout.Toggle("Reload Language", false, GUILayout.Width(130f)); if (isReload) { ReLoadLanguage(); if (mLabel.language != "") { mLabel.language = mLabel.language; } } GUILayout.EndHorizontal(); //GUILayout.EndHorizontal(); if (encoding && mLabel.font.hasSymbols) { UIFont.SymbolStyle sym = (UIFont.SymbolStyle)EditorGUILayout.EnumPopup("Symbols", mLabel.symbolStyle, GUILayout.Width(170f)); if (sym != mLabel.symbolStyle) { RegisterUndo(); mLabel.symbolStyle = sym; } } GUILayout.BeginHorizontal(); { UILabel.Effect effect = (UILabel.Effect)EditorGUILayout.EnumPopup("Effect", mLabel.effectStyle, GUILayout.Width(170f)); if (effect != mLabel.effectStyle) { RegisterUndo(); mLabel.effectStyle = effect; } if (effect != UILabel.Effect.None) { Color c = EditorGUILayout.ColorField(mLabel.effectColor); if (mLabel.effectColor != c) { RegisterUndo(); mLabel.effectColor = c; } } } GUILayout.EndHorizontal(); if (mLabel.effectStyle != UILabel.Effect.None) { GUILayout.Label("Distance", GUILayout.Width(70f)); //GUILayout.Space(-34f); //GUILayout.BeginHorizontal(); //GUILayout.Space(70f); Vector2 offset = EditorGUILayout.Vector2Field("", mLabel.effectDistance); //GUILayout.Space(20f); if (offset != mLabel.effectDistance) { RegisterUndo(); mLabel.effectDistance = offset; } //GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GameColor.GColor mLabelColor = (GameColor.GColor)EditorGUILayout.EnumPopup("LabelColor", mLabel.labelColor, GUILayout.Width(170f)); if (mLabelColor != mLabel.labelColor) { mLabel.color = GameColor.GetColor(mLabelColor); RegisterUndo(); mLabel.labelColor = mLabelColor; } GUILayout.EndHorizontal(); return(true); } EditorGUILayout.Space(); return(false); }
// Token: 0x0600033E RID: 830 RVA: 0x00025F34 File Offset: 0x00024134 public void Print(string text, Color32 color, BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols, bool encoding, UIFont.SymbolStyle symbolStyle, UIFont.Alignment alignment, int lineWidth, bool premultiply) { if (this.mReplacement != null) { this.mReplacement.Print(text, color, verts, uvs, cols, encoding, symbolStyle, alignment, lineWidth, premultiply); } else if (text != null) { if (!this.isValid) { Debug.LogError("Attempting to print using an invalid font!"); return; } bool isDynamic = this.isDynamic; if (isDynamic) { this.mDynamicFont.textureRebuildCallback = new Font.FontTextureRebuildCallback(this.OnFontChanged); this.mDynamicFont.RequestCharactersInTexture(text, this.mDynamicFontSize, this.mDynamicFontStyle); this.mDynamicFont.textureRebuildCallback = null; } this.mColors.Clear(); this.mColors.Add(color); int size = this.size; Vector2 vector = (size <= 0) ? Vector2.one : new Vector2(1f / (float)size, 1f / (float)size); int size2 = verts.size; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = size + this.mSpacingY; Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; Vector2 zero3 = Vector2.zero; Vector2 zero4 = Vector2.zero; float num6 = this.uvRect.width / (float)this.mFont.texWidth; float num7 = this.mUVRect.height / (float)this.mFont.texHeight; int length = text.Length; bool flag = encoding && symbolStyle != UIFont.SymbolStyle.None && this.hasSymbols && this.sprite != null; for (int i = 0; i < length; i++) { char c = text[i]; if (c == '\n') { if (num2 > num) { num = num2; } if (alignment != UIFont.Alignment.Left) { this.Align(verts, size2, alignment, num2, lineWidth); size2 = verts.size; } num2 = 0; num3 += num5; num4 = 0; } else if (c < ' ') { num4 = 0; } else { if (encoding && c == '[') { int num8 = NGUITools.ParseSymbol(text, i, this.mColors, premultiply); if (num8 > 0) { color = this.mColors[this.mColors.Count - 1]; i += num8 - 1; goto IL_96C; } } if (!isDynamic) { BMSymbol bmsymbol = (!flag) ? null : this.MatchSymbol(text, i, length); if (bmsymbol == null) { BMGlyph glyph = this.mFont.GetGlyph((int)c); if (glyph == null) { goto IL_96C; } if (num4 != 0) { num2 += glyph.GetKerning(num4); } if (c == ' ') { num2 += this.mSpacingX + glyph.advance; num4 = (int)c; goto IL_96C; } zero.x = vector.x * (float)(num2 + glyph.offsetX); zero.y = -vector.y * (float)(num3 + glyph.offsetY); zero2.x = zero.x + vector.x * (float)glyph.width; zero2.y = zero.y - vector.y * (float)glyph.height; zero3.x = this.mUVRect.xMin + num6 * (float)glyph.x; zero3.y = this.mUVRect.yMax - num7 * (float)glyph.y; zero4.x = zero3.x + num6 * (float)glyph.width; zero4.y = zero3.y - num7 * (float)glyph.height; num2 += this.mSpacingX + glyph.advance; num4 = (int)c; if (glyph.channel == 0 || glyph.channel == 15) { for (int j = 0; j < 4; j++) { cols.Add(color); } } else { Color color2 = color; color2 *= 0.49f; switch (glyph.channel) { case 1: color2.b += 0.51f; break; case 2: color2.g += 0.51f; break; case 4: color2.r += 0.51f; break; case 8: color2.a += 0.51f; break; } for (int k = 0; k < 4; k++) { cols.Add(color2); } } } else { zero.x = vector.x * (float)(num2 + bmsymbol.offsetX); zero.y = -vector.y * (float)(num3 + bmsymbol.offsetY); zero2.x = zero.x + vector.x * (float)bmsymbol.width; zero2.y = zero.y - vector.y * (float)bmsymbol.height; Rect uvRect = bmsymbol.uvRect; zero3.x = uvRect.xMin; zero3.y = uvRect.yMax; zero4.x = uvRect.xMax; zero4.y = uvRect.yMin; num2 += this.mSpacingX + bmsymbol.advance; i += bmsymbol.length - 1; num4 = 0; if (symbolStyle == UIFont.SymbolStyle.Colored) { for (int l = 0; l < 4; l++) { cols.Add(color); } } else { Color32 item = Color.white; item.a = color.a; for (int m = 0; m < 4; m++) { cols.Add(item); } } } verts.Add(new Vector3(zero2.x, zero.y)); verts.Add(new Vector3(zero2.x, zero2.y)); verts.Add(new Vector3(zero.x, zero2.y)); verts.Add(new Vector3(zero.x, zero.y)); uvs.Add(new Vector2(zero4.x, zero3.y)); uvs.Add(new Vector2(zero4.x, zero4.y)); uvs.Add(new Vector2(zero3.x, zero4.y)); uvs.Add(new Vector2(zero3.x, zero3.y)); } else if (this.mDynamicFont.GetCharacterInfo(c, out UIFont.mChar, this.mDynamicFontSize, this.mDynamicFontStyle)) { zero.x = vector.x * ((float)num2 + UIFont.mChar.vert.xMin); zero.y = -vector.y * ((float)num3 - UIFont.mChar.vert.yMax + this.mDynamicFontOffset); zero2.x = zero.x + vector.x * UIFont.mChar.vert.width; zero2.y = zero.y - vector.y * UIFont.mChar.vert.height; zero3.x = UIFont.mChar.uv.xMin; zero3.y = UIFont.mChar.uv.yMin; zero4.x = UIFont.mChar.uv.xMax; zero4.y = UIFont.mChar.uv.yMax; num2 += this.mSpacingX + (int)UIFont.mChar.width; for (int n = 0; n < 4; n++) { cols.Add(color); } if (UIFont.mChar.flipped) { uvs.Add(new Vector2(zero3.x, zero4.y)); uvs.Add(new Vector2(zero3.x, zero3.y)); uvs.Add(new Vector2(zero4.x, zero3.y)); uvs.Add(new Vector2(zero4.x, zero4.y)); } else { uvs.Add(new Vector2(zero4.x, zero3.y)); uvs.Add(new Vector2(zero3.x, zero3.y)); uvs.Add(new Vector2(zero3.x, zero4.y)); uvs.Add(new Vector2(zero4.x, zero4.y)); } verts.Add(new Vector3(zero2.x, zero.y)); verts.Add(new Vector3(zero.x, zero.y)); verts.Add(new Vector3(zero.x, zero2.y)); verts.Add(new Vector3(zero2.x, zero2.y)); } } IL_96C :; } if (alignment != UIFont.Alignment.Left && size2 < verts.size) { this.Align(verts, size2, alignment, num2, lineWidth); size2 = verts.size; } } }
// Token: 0x06000339 RID: 825 RVA: 0x00025A5C File Offset: 0x00023C5C public string WrapText(string text, float maxWidth, int maxLineCount, bool encoding, UIFont.SymbolStyle symbolStyle) { if (this.mReplacement != null) { return(this.mReplacement.WrapText(text, maxWidth, maxLineCount, encoding, symbolStyle)); } int num = Mathf.RoundToInt(maxWidth * (float)this.size); if (num < 1) { return(text); } StringBuilder stringBuilder = new StringBuilder(); int length = text.Length; int num2 = num; int num3 = 0; int num4 = 0; int i = 0; bool flag = true; bool flag2 = maxLineCount != 1; int num5 = 1; bool flag3 = encoding && symbolStyle != UIFont.SymbolStyle.None && this.hasSymbols; bool isDynamic = this.isDynamic; if (isDynamic) { this.mDynamicFont.textureRebuildCallback = new Font.FontTextureRebuildCallback(this.OnFontChanged); this.mDynamicFont.RequestCharactersInTexture(text, this.mDynamicFontSize, this.mDynamicFontStyle); this.mDynamicFont.textureRebuildCallback = null; } while (i < length) { char c = text[i]; if (c == '\n') { if (!flag2 || num5 == maxLineCount) { break; } num2 = num; if (num4 < i) { stringBuilder.Append(text.Substring(num4, i - num4 + 1)); } else { stringBuilder.Append(c); } flag = true; num5++; num4 = i + 1; num3 = 0; } else { if (c == ' ' && num3 != 32 && num4 < i) { stringBuilder.Append(text.Substring(num4, i - num4 + 1)); flag = false; num4 = i + 1; num3 = (int)c; } if (encoding && c == '[' && i + 2 < length) { if (text[i + 1] == '-' && text[i + 2] == ']') { i += 2; goto IL_3E7; } if (i + 7 < length && text[i + 7] == ']' && NGUITools.EncodeColor(NGUITools.ParseColor(text, i + 1)) == text.Substring(i + 1, 6).ToUpper()) { i += 7; goto IL_3E7; } } BMSymbol bmsymbol = (!flag3) ? null : this.MatchSymbol(text, i, length); int num6 = this.mSpacingX; if (!isDynamic) { if (bmsymbol != null) { num6 += bmsymbol.advance; } else { BMGlyph bmglyph = (bmsymbol != null) ? null : this.mFont.GetGlyph((int)c); if (bmglyph == null) { goto IL_3E7; } num6 += ((num3 == 0) ? bmglyph.advance : (bmglyph.advance + bmglyph.GetKerning(num3))); } } else if (this.mDynamicFont.GetCharacterInfo(c, out UIFont.mChar, this.mDynamicFontSize, this.mDynamicFontStyle)) { num6 += Mathf.RoundToInt(UIFont.mChar.width); } num2 -= num6; if (num2 < 0) { if (flag || !flag2 || num5 == maxLineCount) { stringBuilder.Append(text.Substring(num4, Mathf.Max(0, i - num4))); if (!flag2 || num5 == maxLineCount) { num4 = i; break; } UIFont.EndLine(ref stringBuilder); flag = true; num5++; if (c == ' ') { num4 = i + 1; num2 = num; } else { num4 = i; num2 = num - num6; } num3 = 0; } else { while (num4 < length && text[num4] == ' ') { num4++; } flag = true; num2 = num; i = num4 - 1; num3 = 0; if (!flag2 || num5 == maxLineCount) { break; } num5++; UIFont.EndLine(ref stringBuilder); goto IL_3E7; } } else { num3 = (int)c; } if (!isDynamic && bmsymbol != null) { i += bmsymbol.length - 1; num3 = 0; } } IL_3E7: i++; } if (num4 < i) { stringBuilder.Append(text.Substring(num4, i - num4)); } return(stringBuilder.ToString()); }
// Token: 0x06000336 RID: 822 RVA: 0x000255F0 File Offset: 0x000237F0 public Vector2 CalculatePrintedSize(string text, bool encoding, UIFont.SymbolStyle symbolStyle) { if (this.mReplacement != null) { return(this.mReplacement.CalculatePrintedSize(text, encoding, symbolStyle)); } Vector2 zero = Vector2.zero; bool isDynamic = this.isDynamic; if (isDynamic || (this.mFont != null && this.mFont.isValid && !string.IsNullOrEmpty(text))) { if (encoding) { text = NGUITools.StripSymbols(text); } if (isDynamic) { this.mDynamicFont.textureRebuildCallback = new Font.FontTextureRebuildCallback(this.OnFontChanged); this.mDynamicFont.RequestCharactersInTexture(text, this.mDynamicFontSize, this.mDynamicFontStyle); this.mDynamicFont.textureRebuildCallback = null; } int length = text.Length; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int size = this.size; int num5 = size + this.mSpacingY; bool flag = encoding && symbolStyle != UIFont.SymbolStyle.None && this.hasSymbols; for (int i = 0; i < length; i++) { char c = text[i]; if (c == '\n') { if (num2 > num) { num = num2; } num2 = 0; num3 += num5; num4 = 0; } else if (c < ' ') { num4 = 0; } else if (!isDynamic) { BMSymbol bmsymbol = (!flag) ? null : this.MatchSymbol(text, i, length); if (bmsymbol == null) { BMGlyph glyph = this.mFont.GetGlyph((int)c); if (glyph != null) { num2 += this.mSpacingX + ((num4 == 0) ? glyph.advance : (glyph.advance + glyph.GetKerning(num4))); num4 = (int)c; } } else { num2 += this.mSpacingX + bmsymbol.width; i += bmsymbol.length - 1; num4 = 0; } } else if (this.mDynamicFont.GetCharacterInfo(c, out UIFont.mChar, this.mDynamicFontSize, this.mDynamicFontStyle)) { num2 += (int)((float)this.mSpacingX + UIFont.mChar.width); } } float num6 = (size <= 0) ? 1f : (1f / (float)size); zero.x = num6 * (float)((num2 <= num) ? num : num2); zero.y = num6 * (float)(num3 + num5); } return(zero); }
override protected bool OnDrawProperties() { mLabel = mWidget as UILabel; ComponentSelector.Draw <UIFont>(mLabel.font, OnSelectFont); if (mLabel.font == null) { return(false); } GUI.skin.textArea.wordWrap = true; string text = string.IsNullOrEmpty(mLabel.text) ? "" : mLabel.text; text = EditorGUILayout.TextArea(mLabel.text, GUI.skin.textArea, GUILayout.Height(100f)); if (!text.Equals(mLabel.text)) { RegisterUndo(); mLabel.text = text; } GUILayout.BeginHorizontal(); { int len = EditorGUILayout.IntField("Line Width", mLabel.lineWidth, GUILayout.Width(120f)); if (len != mLabel.lineWidth) { RegisterUndo(); mLabel.lineWidth = len; } int count = EditorGUILayout.IntField("Line Count", mLabel.maxLineCount, GUILayout.Width(100f)); if (count != mLabel.maxLineCount) { RegisterUndo(); mLabel.maxLineCount = count; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); bool password = EditorGUILayout.Toggle("Password", mLabel.password, GUILayout.Width(120f)); if (password != mLabel.password) { RegisterUndo(); mLabel.password = password; } bool encoding = EditorGUILayout.Toggle("Encoding", mLabel.supportEncoding, GUILayout.Width(100f)); if (encoding != mLabel.supportEncoding) { RegisterUndo(); mLabel.supportEncoding = encoding; } GUILayout.EndHorizontal(); if (encoding) { UIFont.SymbolStyle sym = (UIFont.SymbolStyle)EditorGUILayout.EnumPopup("Symbols", mLabel.symbolStyle, GUILayout.Width(170f)); if (sym != mLabel.symbolStyle) { RegisterUndo(); mLabel.symbolStyle = sym; } } GUILayout.BeginHorizontal(); { UILabel.Effect effect = (UILabel.Effect)EditorGUILayout.EnumPopup("Effect", mLabel.effectStyle, GUILayout.Width(170f)); if (effect != mLabel.effectStyle) { RegisterUndo(); mLabel.effectStyle = effect; } if (effect != UILabel.Effect.None) { Color c = EditorGUILayout.ColorField(mLabel.effectColor); if (mLabel.effectColor != c) { RegisterUndo(); mLabel.effectColor = c; } } } GUILayout.EndHorizontal(); return(true); }
protected override bool DrawProperties() { mLabel = mWidget as UILabel; ComponentSelector.Draw <UIFont>(mLabel.font, OnSelectFont); if (mLabel.font != null) { GUI.skin.textArea.wordWrap = true; string text = string.IsNullOrEmpty(mLabel.text) ? "" : mLabel.text; text = EditorGUILayout.TextArea(mLabel.text, GUI.skin.textArea, GUILayout.Height(100f)); if (!text.Equals(mLabel.text)) { RegisterUndo(); mLabel.text = text; } UILabel.Overflow ov = (UILabel.Overflow)EditorGUILayout.EnumPopup("Overflow", mLabel.overflowMethod); if (ov != mLabel.overflowMethod) { RegisterUndo(); mLabel.overflowMethod = ov; } // Only input fields need this setting exposed, and they have their own "is password" setting, so hiding it here. //GUILayout.BeginHorizontal(); //bool password = EditorGUILayout.Toggle("Password", mLabel.password, GUILayout.Width(100f)); //GUILayout.Label("- hide characters"); //GUILayout.EndHorizontal(); //if (password != mLabel.password) { RegisterUndo(); mLabel.password = password; } GUILayout.BeginHorizontal(); bool encoding = EditorGUILayout.Toggle("Encoding", mLabel.supportEncoding, GUILayout.Width(100f)); GUILayout.Label("use emoticons and colors"); GUILayout.EndHorizontal(); if (encoding != mLabel.supportEncoding) { RegisterUndo(); mLabel.supportEncoding = encoding; } //GUILayout.EndHorizontal(); if (encoding && mLabel.font.hasSymbols) { UIFont.SymbolStyle sym = (UIFont.SymbolStyle)EditorGUILayout.EnumPopup("Symbols", mLabel.symbolStyle, GUILayout.Width(170f)); if (sym != mLabel.symbolStyle) { RegisterUndo(); mLabel.symbolStyle = sym; } } GUILayout.BeginHorizontal(); { UILabel.Effect effect = (UILabel.Effect)EditorGUILayout.EnumPopup("Effect", mLabel.effectStyle, GUILayout.Width(170f)); if (effect != mLabel.effectStyle) { RegisterUndo(); mLabel.effectStyle = effect; } if (effect != UILabel.Effect.None) { Color c = EditorGUILayout.ColorField(mLabel.effectColor); if (mLabel.effectColor != c) { RegisterUndo(); mLabel.effectColor = c; } } } GUILayout.EndHorizontal(); if (mLabel.effectStyle != UILabel.Effect.None) { #if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 GUILayout.Label("Distance", GUILayout.Width(70f)); GUILayout.Space(-34f); GUILayout.BeginHorizontal(); GUILayout.Space(70f); Vector2 offset = EditorGUILayout.Vector2Field("", mLabel.effectDistance); GUILayout.Space(20f); GUILayout.EndHorizontal(); #else Vector2 offset = mLabel.effectDistance; GUILayout.BeginHorizontal(); GUILayout.Label("Distance", GUILayout.Width(76f)); offset.x = EditorGUILayout.FloatField(offset.x); offset.y = EditorGUILayout.FloatField(offset.y); GUILayout.Space(18f); GUILayout.EndHorizontal(); #endif if (offset != mLabel.effectDistance) { RegisterUndo(); mLabel.effectDistance = offset; } } int count = EditorGUILayout.IntField("Max Lines", mLabel.maxLineCount, GUILayout.Width(100f)); if (count != mLabel.maxLineCount) { RegisterUndo(); mLabel.maxLineCount = count; } return(true); } EditorGUILayout.Space(); return(false); }
override protected bool DrawProperties() { mLabel = mWidget as UILabel; ComponentSelector.Draw <UIFont>(mLabel.font, OnSelectFont); if (mLabel.font == null) { return(false); } GUI.skin.textArea.wordWrap = true; string text = string.IsNullOrEmpty(mLabel.text) ? "" : mLabel.text; text = EditorGUILayout.TextArea(mLabel.text, GUI.skin.textArea, GUILayout.Height(100f)); if (!text.Equals(mLabel.text)) { RegisterUndo(); mLabel.text = text; } EditorGUILayout.LabelField("*Language Id代替text序列化"); EditorGUILayout.LabelField("*固定内容直接把中文表id填到Language Id"); GUILayout.BeginHorizontal(); int languageId = EditorGUILayout.IntField("Language Id", mLabel.LanguageId, GUILayout.Width(220f)); if (languageId != mLabel.LanguageId) { SystemSwitch.ReleaseMode = false; SystemSwitch.UseHmf = false; UILabel.GetContent = Mogo.GameData.LanguageData.GetContent; RegisterUndo(); mLabel.LanguageId = languageId; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { int len = EditorGUILayout.IntField("Line Width", mLabel.lineWidth, GUILayout.Width(120f)); if (len != mLabel.lineWidth) { RegisterUndo(); mLabel.lineWidth = len; } int count = EditorGUILayout.IntField("Line Count", mLabel.maxLineCount, GUILayout.Width(120f)); if (count != mLabel.maxLineCount) { RegisterUndo(); mLabel.maxLineCount = count; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { int len = EditorGUILayout.IntField("Spacing X", mLabel.spacingX, GUILayout.Width(120f)); if (len != mLabel.spacingX) { RegisterUndo(); mLabel.spacingX = len; } int count = EditorGUILayout.IntField("Spacing Y", mLabel.spacingY, GUILayout.Width(120f)); if (count != mLabel.spacingY) { RegisterUndo(); mLabel.spacingY = count; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); bool password = EditorGUILayout.Toggle("Password", mLabel.password, GUILayout.Width(120f)); if (password != mLabel.password) { RegisterUndo(); mLabel.password = password; } bool encoding = EditorGUILayout.Toggle("Encoding", mLabel.supportEncoding, GUILayout.Width(100f)); if (encoding != mLabel.supportEncoding) { RegisterUndo(); mLabel.supportEncoding = encoding; } bool tranlateReturn = EditorGUILayout.Toggle("TranslateReturn", mLabel.TranslateReturn, GUILayout.Width(120f)); if (tranlateReturn != mLabel.TranslateReturn) { RegisterUndo(); mLabel.TranslateReturn = tranlateReturn; } GUILayout.EndHorizontal(); if (encoding && mLabel.font.hasSymbols) { UIFont.SymbolStyle sym = (UIFont.SymbolStyle)EditorGUILayout.EnumPopup("Symbols", mLabel.symbolStyle, GUILayout.Width(170f)); if (sym != mLabel.symbolStyle) { RegisterUndo(); mLabel.symbolStyle = sym; } } GUILayout.BeginHorizontal(); { UILabel.Effect effect = (UILabel.Effect)EditorGUILayout.EnumPopup("Effect", mLabel.effectStyle, GUILayout.Width(170f)); if (effect != mLabel.effectStyle) { RegisterUndo(); mLabel.effectStyle = effect; } if (effect != UILabel.Effect.None) { Color c = EditorGUILayout.ColorField(mLabel.effectColor); if (mLabel.effectColor != c) { RegisterUndo(); mLabel.effectColor = c; } } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (mLabel.effectStyle != UILabel.Effect.None) { GUILayout.BeginHorizontal(); GUILayout.Label("Distance", GUILayout.Width(70f)); Vector2 offset = EditorGUILayout.Vector2Field("", mLabel.effectDistance); GUILayout.Space(20f); if (offset != mLabel.effectDistance) { RegisterUndo(); mLabel.effectDistance = offset; } GUILayout.EndHorizontal(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { int len = EditorGUILayout.IntField("TextChangeWidth", mLabel.ChangeTextWidth, GUILayout.Width(120f)); if (len != mLabel.ChangeTextWidth) { RegisterUndo(); mLabel.ChangeTextWidth = len; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("一秒变样式", GUILayout.Width(75f)); //if (GUILayout.Button("36标题", GUILayout.Width(50f))) // ExportScenesManager.SetUIHeadText(mLabel.gameObject); //if (GUILayout.Button("30标题", GUILayout.Width(50f))) // ExportScenesManager.SetUI30TitleText(mLabel.gameObject); //if (GUILayout.Button("28标题", GUILayout.Width(50f))) // ExportScenesManager.SetUI28TitleText(mLabel.gameObject); //GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal(); //GUILayout.Label("", GUILayout.Width(75f)); //if (GUILayout.Button("26标题", GUILayout.Width(50f))) // ExportScenesManager.SetUI26TitleText(mLabel.gameObject); //if (GUILayout.Button("通用", GUILayout.Width(50f))) // ExportScenesManager.SetUICommonText(mLabel.gameObject); //if (GUILayout.Button("A标签", GUILayout.Width(50f))) // ExportScenesManager.SetUIAHorizontalUpButtonText(mLabel.gameObject); //GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal(); //GUILayout.Label("", GUILayout.Width(75f)); //if (GUILayout.Button("绿色", GUILayout.Width(60f))) // ExportScenesManager.SetUIGreenText(mLabel.gameObject); //if (GUILayout.Button("红色", GUILayout.Width(60f))) // ExportScenesManager.SetUIRedText(mLabel.gameObject); //if (GUILayout.Button("icon", GUILayout.Width(60f))) // ExportScenesManager.SetUIIconNumText(mLabel.gameObject); //GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal(); //GUILayout.Label("", GUILayout.Width(75f)); //if (GUILayout.Button("底纹按钮", GUILayout.Width(60f))) // ExportScenesManager.SetUINormalButtonText(mLabel.gameObject); //if (GUILayout.Button("主右上", GUILayout.Width(60f))) // ExportScenesManager.SetUIMainRightUpText(mLabel.gameObject); //if (GUILayout.Button("主右", GUILayout.Width(60f))) // ExportScenesManager.SetUIMainRightText(mLabel.gameObject); //GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal(); //GUILayout.Label("", GUILayout.Width(75f)); //if (GUILayout.Button("底纹按钮", GUILayout.Width(60f))) // ExportScenesManager.SetUINormalButtonText(mLabel.gameObject); //if (GUILayout.Button("双字加空格", GUILayout.Width(75f))) //{ // RegisterUndo(); // mLabel.ChangeTextWidth = 100; // mLabel.text = mLabel.text; //} GUILayout.EndHorizontal(); return(true); }
override protected bool DrawProperties() { mLabel = mWidget as EmojiUILabel; ComponentSelector.Draw <UIFont>(mLabel.font, OnSelectFont); if (mLabel.font == null) { return(false); } GUI.skin.textArea.wordWrap = true; string text = string.IsNullOrEmpty(mLabel.text) ? "" : mLabel.text; text = EditorGUILayout.TextArea(mLabel.text, GUI.skin.textArea, GUILayout.Height(100f)); if (!text.Equals(mLabel.text)) { RegisterUndo(); mLabel.text = text; } EditorGUILayout.LabelField("*Language Id代替text序列化"); EditorGUILayout.LabelField("*固定内容直接把中文表id填到Language Id"); GUILayout.BeginHorizontal(); int languageId = EditorGUILayout.IntField("Language Id", mLabel.LanguageId, GUILayout.Width(220f)); if (languageId != mLabel.LanguageId) { SystemSwitch.ReleaseMode = false; SystemSwitch.UseHmf = false; UILabel.GetContent = Mogo.GameData.LanguageData.GetContent; RegisterUndo(); mLabel.LanguageId = languageId; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { int len = EditorGUILayout.IntField("Line Width", mLabel.lineWidth, GUILayout.Width(120f)); if (len != mLabel.lineWidth) { RegisterUndo(); mLabel.lineWidth = len; } int count = EditorGUILayout.IntField("Line Count", mLabel.maxLineCount, GUILayout.Width(120f)); if (count != mLabel.maxLineCount) { RegisterUndo(); mLabel.maxLineCount = count; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { int len = EditorGUILayout.IntField("Spacing X", mLabel.spacingX, GUILayout.Width(120f)); if (len != mLabel.spacingX) { RegisterUndo(); mLabel.spacingX = len; } int count = EditorGUILayout.IntField("Spacing Y", mLabel.spacingY, GUILayout.Width(120f)); if (count != mLabel.spacingY) { RegisterUndo(); mLabel.spacingY = count; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); bool password = EditorGUILayout.Toggle("Password", mLabel.password, GUILayout.Width(120f)); if (password != mLabel.password) { RegisterUndo(); mLabel.password = password; } bool encoding = EditorGUILayout.Toggle("Encoding", mLabel.supportEncoding, GUILayout.Width(100f)); if (encoding != mLabel.supportEncoding) { RegisterUndo(); mLabel.supportEncoding = encoding; } bool tranlateReturn = EditorGUILayout.Toggle("TranslateReturn", mLabel.TranslateReturn, GUILayout.Width(120f)); if (tranlateReturn != mLabel.TranslateReturn) { RegisterUndo(); mLabel.TranslateReturn = tranlateReturn; } GUILayout.EndHorizontal(); if (encoding && mLabel.font.hasSymbols) { UIFont.SymbolStyle sym = (UIFont.SymbolStyle)EditorGUILayout.EnumPopup("Symbols", mLabel.symbolStyle, GUILayout.Width(170f)); if (sym != mLabel.symbolStyle) { RegisterUndo(); mLabel.symbolStyle = sym; } } GUILayout.BeginHorizontal(); { EmojiUILabel.Effect effect = (EmojiUILabel.Effect)EditorGUILayout.EnumPopup("Effect", mLabel.effectStyle, GUILayout.Width(170f)); if (effect != mLabel.effectStyle) { RegisterUndo(); mLabel.effectStyle = effect; } if (effect != EmojiUILabel.Effect.None) { Color c = EditorGUILayout.ColorField(mLabel.effectColor); if (mLabel.effectColor != c) { RegisterUndo(); mLabel.effectColor = c; } } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (mLabel.effectStyle != EmojiUILabel.Effect.None) { GUILayout.BeginHorizontal(); GUILayout.Label("Distance", GUILayout.Width(70f)); Vector2 offset = EditorGUILayout.Vector2Field("", mLabel.effectDistance); GUILayout.Space(20f); if (offset != mLabel.effectDistance) { RegisterUndo(); mLabel.effectDistance = offset; } GUILayout.EndHorizontal(); } GUILayout.EndHorizontal(); return(true); }