cull(engine-cleanup): pass-9 cascade round 1 after UILabel stub
This commit is contained in:
@@ -22,30 +22,6 @@ public class BMSymbol
|
||||
|
||||
private Rect mUV;
|
||||
|
||||
public int length
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mLength == 0)
|
||||
{
|
||||
mLength = sequence.Length;
|
||||
}
|
||||
return mLength;
|
||||
}
|
||||
}
|
||||
|
||||
public int offsetX => mOffsetX;
|
||||
|
||||
public int offsetY => mOffsetY;
|
||||
|
||||
public int width => mWidth;
|
||||
|
||||
public int height => mHeight;
|
||||
|
||||
public int advance => mAdvance;
|
||||
|
||||
public Rect uvRect => mUV;
|
||||
|
||||
public void MarkAsChanged()
|
||||
{
|
||||
mIsValid = false;
|
||||
|
||||
@@ -69,18 +69,4 @@ public class BetterList<T>
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (buffer != null && index > -1 && index < size)
|
||||
{
|
||||
size--;
|
||||
buffer[index] = default(T);
|
||||
for (int i = index; i < size; i++)
|
||||
{
|
||||
buffer[i] = buffer[i + 1];
|
||||
}
|
||||
buffer[size] = default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,55 +29,6 @@ public static class NGUIMath
|
||||
return val;
|
||||
}
|
||||
|
||||
[DebuggerHidden]
|
||||
[DebuggerStepThrough]
|
||||
public static int HexToDecimal(char ch)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case '0':
|
||||
return 0;
|
||||
case '1':
|
||||
return 1;
|
||||
case '2':
|
||||
return 2;
|
||||
case '3':
|
||||
return 3;
|
||||
case '4':
|
||||
return 4;
|
||||
case '5':
|
||||
return 5;
|
||||
case '6':
|
||||
return 6;
|
||||
case '7':
|
||||
return 7;
|
||||
case '8':
|
||||
return 8;
|
||||
case '9':
|
||||
return 9;
|
||||
case 'A':
|
||||
case 'a':
|
||||
return 10;
|
||||
case 'B':
|
||||
case 'b':
|
||||
return 11;
|
||||
case 'C':
|
||||
case 'c':
|
||||
return 12;
|
||||
case 'D':
|
||||
case 'd':
|
||||
return 13;
|
||||
case 'E':
|
||||
case 'e':
|
||||
return 14;
|
||||
case 'F':
|
||||
case 'f':
|
||||
return 15;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
|
||||
public static Rect ConvertToTexCoords(Rect rect, int width, int height)
|
||||
{
|
||||
Rect result = rect;
|
||||
|
||||
@@ -8,67 +8,11 @@ using Wizard;
|
||||
|
||||
public static class NGUIText
|
||||
{
|
||||
public enum Alignment { Automatic, Left, Center, Right, Justified }
|
||||
public enum SymbolStyle { None, Normal, Colored }
|
||||
public enum Alignment { Left, Right, Justified }
|
||||
public enum SymbolStyle { None, Normal}
|
||||
|
||||
public class GlyphInfo
|
||||
{
|
||||
public Vector2 v0;
|
||||
public Vector2 v1;
|
||||
public Vector2 u0;
|
||||
public Vector2 u1;
|
||||
public Vector2 u2;
|
||||
public Vector2 u3;
|
||||
public float advance;
|
||||
public int channel;
|
||||
}
|
||||
|
||||
// Static fields — defaults matching original initializers
|
||||
public static UIFont bitmapFont;
|
||||
public static UnityEngine.Font dynamicFont;
|
||||
public static int fontSize = 16;
|
||||
public static float fontScale = 1f;
|
||||
public static float pixelDensity = 1f;
|
||||
public static FontStyle fontStyle = FontStyle.Normal;
|
||||
public static Alignment alignment = Alignment.Left;
|
||||
public static Color tint = Color.white;
|
||||
public static int rectWidth = 1000000;
|
||||
public static int rectHeight = 1000000;
|
||||
public static int regionWidth = 1000000;
|
||||
public static int regionHeight = 1000000;
|
||||
public static int maxLines = 0;
|
||||
public static bool gradient = false;
|
||||
public static Color gradientBottom = Color.white;
|
||||
public static Color gradientTop = Color.white;
|
||||
public static bool encoding = false;
|
||||
public static float spacingX = 0f;
|
||||
public static float spacingY = 0f;
|
||||
public static bool premultiply = false;
|
||||
public static SymbolStyle symbolStyle;
|
||||
public static int finalSize = 0;
|
||||
public static float finalSpacingX = 0f;
|
||||
public static float finalLineHeight = 0f;
|
||||
public static bool useSymbols = false;
|
||||
|
||||
// Static methods — all no-ops or default returns
|
||||
public static void Update(UIWidget.Pivot piv) { }
|
||||
public static void Update(bool request, UIWidget.Pivot piv) { }
|
||||
public static void Prepare(string text) { }
|
||||
public static BMSymbol GetSymbol(string text, int index, int textLength) => null;
|
||||
public static GlyphInfo GetGlyph(int ch, int prev) => null;
|
||||
public static Color ParseColor24(string text, int offset) => Color.white;
|
||||
public static Color ParseColor32(string text, int offset) => Color.white;
|
||||
public static string EncodeColor24(Color c) => "";
|
||||
public static string EncodeColor32(Color c) => "";
|
||||
public static bool IsHex(char ch) => false;
|
||||
public static void Align(BetterList<Vector3> verts, int indexOffset, float printedWidth, int elements = 4) { }
|
||||
public static int GetExactCharacterIndex(BetterList<Vector3> verts, BetterList<int> indices, Vector2 pos) => 0;
|
||||
public static int GetApproximateCharacterIndex(BetterList<Vector3> verts, BetterList<int> indices, Vector2 pos) => 0;
|
||||
public static Vector2 CalculatePrintedSize(string text) => Vector2.zero;
|
||||
public static int CalculateOffsetToFit(string text) => 0;
|
||||
public static bool WrapText(string text, out string finalText, bool wrapLineColors = false) { finalText = text; return false; }
|
||||
public static bool WrapText(string text, out string finalText, bool keepCharCount, bool wrapLineColors, bool useEllipsis = false) { finalText = text; return false; }
|
||||
public static void PrintApproximateCharacterPositions(string text, BetterList<Vector3> verts, BetterList<int> indices) { }
|
||||
public static void PrintExactCharacterPositions(string text, BetterList<Vector3> verts, BetterList<int> indices) { }
|
||||
public static void PrintCaretAndSelection(string text, int start, int end, BetterList<Vector3> caret, BetterList<Vector3> highlight) { }
|
||||
}
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class UICurveLabel : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private int _magnificationHeight;
|
||||
|
||||
[SerializeField]
|
||||
private AnimationCurve _animationCurve;
|
||||
|
||||
private float _timeIntervalCharacter;
|
||||
|
||||
public void Init(string text)
|
||||
{
|
||||
if (text.Length <= 1)
|
||||
{
|
||||
_timeIntervalCharacter = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timeIntervalCharacter = 1f / (float)(text.Length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public float GetTargetCharacterHeight(int inIndex)
|
||||
{
|
||||
return _animationCurve.Evaluate((float)inIndex * _timeIntervalCharacter) * (float)(-_magnificationHeight);
|
||||
}
|
||||
|
||||
private float GetTargetCharacterAnimationCurveValue(float inTime)
|
||||
{
|
||||
return _animationCurve.Evaluate(inTime * _timeIntervalCharacter);
|
||||
}
|
||||
|
||||
public Vector2[] SetTargetCharacterRotation(int inIndex, ref float v0x, ref float v0y, ref float v1x, ref float v1y)
|
||||
{
|
||||
Vector2 vector = default(Vector2);
|
||||
Vector2 vector2 = default(Vector2);
|
||||
if (inIndex == 0)
|
||||
{
|
||||
vector.x = 0f;
|
||||
vector.y = GetTargetCharacterAnimationCurveValue(0f);
|
||||
vector2.x = ((float)inIndex + 0.5f) * _timeIntervalCharacter;
|
||||
vector2.y = GetTargetCharacterAnimationCurveValue((float)inIndex + 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
vector.x = ((float)inIndex - 0.5f) * _timeIntervalCharacter;
|
||||
vector.y = GetTargetCharacterAnimationCurveValue((float)inIndex - 0.5f);
|
||||
vector2.x = (float)inIndex * _timeIntervalCharacter;
|
||||
vector2.y = GetTargetCharacterAnimationCurveValue(inIndex);
|
||||
}
|
||||
Vector2 vector3 = vector2 - vector;
|
||||
float num = Mathf.Atan2(vector3.y, vector3.x);
|
||||
float num2 = Mathf.Sin(num);
|
||||
float num3 = Mathf.Cos(num);
|
||||
Vector2 vector4 = new Vector2((v1x + v0x) / 2f, (v1y + v0y) / 2f);
|
||||
Vector2[] array = new Vector2[4];
|
||||
array[0].x = v0x;
|
||||
array[0].y = v0y;
|
||||
array[1].x = v0x;
|
||||
array[1].y = v1y;
|
||||
array[2].x = v1x;
|
||||
array[2].y = v1y;
|
||||
array[3].x = v1x;
|
||||
array[3].y = v0y;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
float num4 = array[i].x - vector4.x;
|
||||
float num5 = array[i].y - vector4.y;
|
||||
array[i].x = num3 * num4 - num2 * num5;
|
||||
array[i].y = num2 * num4 + num3 * num5;
|
||||
array[i].x += vector4.x;
|
||||
array[i].y += vector4.y;
|
||||
}
|
||||
Vector2[] array2 = new Vector2[4];
|
||||
if (num < (float)Math.PI / 2f)
|
||||
{
|
||||
return array;
|
||||
}
|
||||
if (num < (float)Math.PI)
|
||||
{
|
||||
array2[0] = array[3];
|
||||
array2[1] = array[0];
|
||||
array2[2] = array[1];
|
||||
array2[3] = array[2];
|
||||
}
|
||||
else if (num < 4.712389f)
|
||||
{
|
||||
array2[0] = array[2];
|
||||
array2[1] = array[3];
|
||||
array2[2] = array[0];
|
||||
array2[3] = array[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
array2[0] = array[1];
|
||||
array2[1] = array[2];
|
||||
array2[2] = array[3];
|
||||
array2[3] = array[0];
|
||||
}
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
array[j] = array2[j];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,4 @@ public class UIGeometry
|
||||
private BetterList<Vector3> mRtpVerts = new BetterList<Vector3>();
|
||||
|
||||
public bool hasVertices => verts.size > 0;
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
verts.Clear();
|
||||
uvs.Clear();
|
||||
cols.Clear();
|
||||
mRtpVerts.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ using Wizard;
|
||||
[AddComponentMenu("NGUI/UI/NGUI Label")]
|
||||
public class UILabel : UIWidget
|
||||
{
|
||||
public enum Effect { None, Outline, Outline8 }
|
||||
public enum Overflow { ShrinkContent, ClampContent, ResizeFreely, ResizeHeight }
|
||||
public enum Effect { None, Outline8 }
|
||||
public enum Overflow { ClampContent}
|
||||
public enum Crispness { }
|
||||
|
||||
// Backing field populated by the shim's Materialize() reflection path so material is non-null
|
||||
@@ -30,7 +30,6 @@ public class UILabel : UIWidget
|
||||
public bool overflowEllipsis;
|
||||
public int maxLineCount;
|
||||
public int fontSize;
|
||||
public int spacingX;
|
||||
public int spacingY;
|
||||
public NGUIText.Alignment alignment;
|
||||
public bool applyGradient;
|
||||
@@ -40,14 +39,6 @@ public class UILabel : UIWidget
|
||||
public UIFont bitmapFont;
|
||||
public UnityEngine.Font trueTypeFont;
|
||||
|
||||
// RubyText extension fields
|
||||
public bool IsRuby;
|
||||
public bool IsDot;
|
||||
public float RubyMargin;
|
||||
public float RubyScale;
|
||||
public float DotMargin;
|
||||
public float DotScale;
|
||||
|
||||
// Methods
|
||||
public void ProcessText() { }
|
||||
public void SetWrapText(string text) { }
|
||||
|
||||
@@ -181,18 +181,6 @@ public abstract class UIRect : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public bool isFullyAnchored
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((bool)leftAnchor.target && (bool)rightAnchor.target && (bool)topAnchor.target)
|
||||
{
|
||||
return bottomAnchor.target;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool isAnchoredHorizontally
|
||||
{
|
||||
get
|
||||
@@ -360,21 +348,6 @@ public abstract class UIRect : MonoBehaviour
|
||||
return position;
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
mUpdateFrame = -1;
|
||||
if (updateAnchors == AnchorUpdate.OnEnable)
|
||||
{
|
||||
mAnchorsCached = false;
|
||||
mUpdateAnchors = true;
|
||||
}
|
||||
if (mStarted)
|
||||
{
|
||||
OnInit();
|
||||
}
|
||||
mUpdateFrame = -1;
|
||||
}
|
||||
|
||||
protected virtual void OnInit()
|
||||
{
|
||||
mChanged = true;
|
||||
|
||||
@@ -128,19 +128,6 @@ public class UIRoot : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public float pixelSizeAdjustment
|
||||
{
|
||||
get
|
||||
{
|
||||
int num = Mathf.RoundToInt(NGUITools.screenSize.y);
|
||||
if (num != -1)
|
||||
{
|
||||
return GetPixelSizeAdjustment(num);
|
||||
}
|
||||
return 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public float GetPixelSizeAdjustment(int height)
|
||||
{
|
||||
height = Mathf.Max(2, height);
|
||||
|
||||
@@ -285,26 +285,6 @@ public class UIWidget : UIRect
|
||||
}
|
||||
}
|
||||
|
||||
public Pivot rawPivot
|
||||
{
|
||||
get
|
||||
{
|
||||
return mPivot;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (mPivot != value)
|
||||
{
|
||||
mPivot = value;
|
||||
if (autoResizeBoxCollider)
|
||||
{
|
||||
ResizeCollider();
|
||||
}
|
||||
MarkAsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Pivot pivot
|
||||
{
|
||||
get
|
||||
|
||||
@@ -1,871 +0,0 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Wizard;
|
||||
|
||||
public static class RubyText
|
||||
{
|
||||
private enum eSubscriptMode
|
||||
{
|
||||
}
|
||||
|
||||
private static Color mInvisible = new Color(0f, 0f, 0f, 0f);
|
||||
|
||||
private static float mAlpha = 1f;
|
||||
|
||||
private static Color32 s_c0;
|
||||
|
||||
private static Color32 s_c1;
|
||||
|
||||
private static BetterList<Color> mColors = new BetterList<Color>();
|
||||
|
||||
private static float[] mBoldOffset = new float[8] { -0.25f, 0f, 0.25f, 0f, 0f, -0.25f, 0f, 0.25f };
|
||||
|
||||
private static bool IsSpace(int ch)
|
||||
{
|
||||
if (ch != 32 && ch != 8202 && ch != 8203)
|
||||
{
|
||||
return ch == 8201;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool ParseSymbol(string text, ref int index, BetterList<Color> colors, bool premultiply, ref int sub, ref bool bold, ref bool italic, ref bool underline, ref bool strike, ref bool ignoreColor, ref float rubyTotalAdvanceRaw, ref float charWithRubyTotalAdvance, bool isRuby, ref bool isDot)
|
||||
{
|
||||
int length = text.Length;
|
||||
if (index + 1 < length && text.Substring(index, ">]".Length) == ">]")
|
||||
{
|
||||
if (isRuby)
|
||||
{
|
||||
sub = 4;
|
||||
}
|
||||
index += ">]".Length;
|
||||
return true;
|
||||
}
|
||||
if (index + 3 > length || text[index] != '[')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (text[index + 2] == ']')
|
||||
{
|
||||
if (text[index + 1] == '-')
|
||||
{
|
||||
if (colors != null && colors.size > 1)
|
||||
{
|
||||
colors.RemoveAt(colors.size - 1);
|
||||
}
|
||||
index += 3;
|
||||
return true;
|
||||
}
|
||||
switch (text.Substring(index, 3))
|
||||
{
|
||||
case "[1]":
|
||||
case "[2]":
|
||||
case "[3]":
|
||||
case "[4]":
|
||||
case "[5]":
|
||||
index += 3;
|
||||
return true;
|
||||
case "[b]":
|
||||
bold = true;
|
||||
index += 3;
|
||||
return true;
|
||||
case "[i]":
|
||||
italic = true;
|
||||
index += 3;
|
||||
return true;
|
||||
case "[u]":
|
||||
underline = true;
|
||||
index += 3;
|
||||
return true;
|
||||
case "[s]":
|
||||
strike = true;
|
||||
index += 3;
|
||||
return true;
|
||||
case "[c]":
|
||||
ignoreColor = true;
|
||||
index += 3;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (index + 4 > length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (text[index + 3] == ']')
|
||||
{
|
||||
switch (text.Substring(index, 4))
|
||||
{
|
||||
case "[/b]":
|
||||
bold = false;
|
||||
index += 4;
|
||||
return true;
|
||||
case "[/i]":
|
||||
italic = false;
|
||||
index += 4;
|
||||
return true;
|
||||
case "[/u]":
|
||||
underline = false;
|
||||
index += 4;
|
||||
return true;
|
||||
case "[/s]":
|
||||
strike = false;
|
||||
index += 4;
|
||||
return true;
|
||||
case "[/c]":
|
||||
ignoreColor = false;
|
||||
index += 4;
|
||||
return true;
|
||||
}
|
||||
char ch = text[index + 1];
|
||||
char ch2 = text[index + 2];
|
||||
if (NGUIText.IsHex(ch) && NGUIText.IsHex(ch2))
|
||||
{
|
||||
mAlpha = (float)((NGUIMath.HexToDecimal(ch) << 4) | NGUIMath.HexToDecimal(ch2)) / 255f;
|
||||
index += 4;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (index + 5 > length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (text[index + 4] == ']')
|
||||
{
|
||||
switch (text.Substring(index, 5))
|
||||
{
|
||||
case "[sub]":
|
||||
sub = 1;
|
||||
index += 5;
|
||||
return true;
|
||||
case "[sup]":
|
||||
sub = 2;
|
||||
index += 5;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (text[index + 4] == '<')
|
||||
{
|
||||
string text2 = text.Substring(index, 5);
|
||||
if (text2 != null && text2 == "[rub<")
|
||||
{
|
||||
index += "[rub<".Length;
|
||||
bool flag = false;
|
||||
rubyTotalAdvanceRaw = 0f;
|
||||
int num = 0;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = index; i + ">]".Length < length; i++)
|
||||
{
|
||||
char c = text[i];
|
||||
if (c == '\n')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (text.Substring(i, ">]".Length) == ">]")
|
||||
{
|
||||
break;
|
||||
}
|
||||
num++;
|
||||
if (!flag && IsFadeTagStart(text, i))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
if (c == ']')
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int prev = ((i > 0) ? text[i - 1] : '\0');
|
||||
rubyTotalAdvanceRaw += NGUIText.finalSpacingX + NGUIText.GetGlyph(c, prev).advance;
|
||||
stringBuilder.Append(c);
|
||||
}
|
||||
}
|
||||
if (isRuby)
|
||||
{
|
||||
bool flag2 = false;
|
||||
charWithRubyTotalAdvance = 0f;
|
||||
for (int j = index + num + ">]".Length; j < length; j++)
|
||||
{
|
||||
char c2 = text[j];
|
||||
if (c2 == '\n')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (j + "[/rub]".Length <= length && text.Substring(j, "[/rub]".Length) == "[/rub]")
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!flag2 && IsFadeTagStart(text, j))
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
if (c2 == ']')
|
||||
{
|
||||
flag2 = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int prev2 = ((j > 0) ? text[j - 1] : '\0');
|
||||
charWithRubyTotalAdvance += NGUIText.finalSpacingX + NGUIText.GetGlyph(c2, prev2).advance;
|
||||
}
|
||||
}
|
||||
if (stringBuilder.ToString() == "・")
|
||||
{
|
||||
isDot = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isDot = false;
|
||||
}
|
||||
sub = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (length > index + num + ">]".Length)
|
||||
{
|
||||
index += num + ">]".Length;
|
||||
}
|
||||
sub = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (index + 6 > length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (text[index + 5] == ']')
|
||||
{
|
||||
switch (text.Substring(index, 6))
|
||||
{
|
||||
case "[/sub]":
|
||||
sub = 0;
|
||||
index += 6;
|
||||
return true;
|
||||
case "[/sup]":
|
||||
sub = 0;
|
||||
index += 6;
|
||||
return true;
|
||||
case "[/rub]":
|
||||
sub = 0;
|
||||
index += 6;
|
||||
return true;
|
||||
case "[/url]":
|
||||
index += 6;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (text[index + 1] == 'u' && text[index + 2] == 'r' && text[index + 3] == 'l' && text[index + 4] == '=')
|
||||
{
|
||||
int num2 = text.IndexOf(']', index + 4);
|
||||
if (num2 != -1)
|
||||
{
|
||||
index = num2 + 1;
|
||||
return true;
|
||||
}
|
||||
index = text.Length;
|
||||
return true;
|
||||
}
|
||||
if (index + 8 > length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (text[index + 7] == ']')
|
||||
{
|
||||
Color color = NGUIText.ParseColor24(text, index + 1);
|
||||
if (NGUIText.EncodeColor24(color) != text.Substring(index + 1, 6).ToUpper())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (colors != null)
|
||||
{
|
||||
color.a = colors[colors.size - 1].a;
|
||||
if (premultiply && color.a != 1f)
|
||||
{
|
||||
color = Color.Lerp(mInvisible, color, color.a);
|
||||
}
|
||||
colors.Add(color);
|
||||
}
|
||||
index += 8;
|
||||
return true;
|
||||
}
|
||||
if (index + 10 > length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (text[index + 9] == ']')
|
||||
{
|
||||
Color color2 = NGUIText.ParseColor32(text, index + 1);
|
||||
if (NGUIText.EncodeColor32(color2) != text.Substring(index + 1, 8).ToUpper())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (colors != null)
|
||||
{
|
||||
if (premultiply && color2.a != 1f)
|
||||
{
|
||||
color2 = Color.Lerp(mInvisible, color2, color2.a);
|
||||
}
|
||||
colors.Add(color2);
|
||||
}
|
||||
index += 10;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsFadeTagStart(string text, int offset)
|
||||
{
|
||||
if (offset + 3 >= text.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (text[offset] == '[' && text[offset + 3] == ']' && NGUIText.IsHex(text[offset + 1]) && NGUIText.IsHex(text[offset + 2]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void PrintWithRuby(string text, BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols, UILabel uiLabel = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
UICurveLabel component = uiLabel.GetComponent<UICurveLabel>();
|
||||
if (component != null)
|
||||
{
|
||||
component.Init(text);
|
||||
}
|
||||
int size = verts.size;
|
||||
NGUIText.Prepare(text);
|
||||
mColors.Add(Color.white);
|
||||
mAlpha = 1f;
|
||||
int num = 0;
|
||||
int prev = 0;
|
||||
float num2 = 0f;
|
||||
float num3 = 0f;
|
||||
float num4 = 0f;
|
||||
float num5 = NGUIText.finalSize;
|
||||
Color a = NGUIText.tint * NGUIText.gradientBottom;
|
||||
Color b = NGUIText.tint * NGUIText.gradientTop;
|
||||
Color32 color = NGUIText.tint;
|
||||
int length = text.Length;
|
||||
Rect rect = default(Rect);
|
||||
float num6 = 0f;
|
||||
float num7 = 0f;
|
||||
float num8 = num5 * NGUIText.pixelDensity;
|
||||
bool flag = false;
|
||||
int sub = 0;
|
||||
bool bold = false;
|
||||
bool italic = false;
|
||||
bool underline = false;
|
||||
bool strike = false;
|
||||
bool ignoreColor = false;
|
||||
float num9 = 0f;
|
||||
float num10 = 0f;
|
||||
if (NGUIText.bitmapFont != null)
|
||||
{
|
||||
rect = NGUIText.bitmapFont.uvRect;
|
||||
num6 = rect.width / (float)NGUIText.bitmapFont.texWidth;
|
||||
num7 = rect.height / (float)NGUIText.bitmapFont.texHeight;
|
||||
}
|
||||
float num11 = 0f;
|
||||
float rubyTotalAdvanceRaw = 0f;
|
||||
float charWithRubyTotalAdvance = 0f;
|
||||
bool flag2 = false;
|
||||
bool isRuby = uiLabel.IsRuby;
|
||||
float num12 = NGUIText.fontScale * (float)NGUIText.fontSize * uiLabel.RubyMargin;
|
||||
float num13 = NGUIText.fontScale * (float)NGUIText.fontSize * uiLabel.DotMargin;
|
||||
bool isDot = false;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
num = text[i];
|
||||
num9 = num2;
|
||||
if (num == 10)
|
||||
{
|
||||
if (num2 > num4)
|
||||
{
|
||||
num4 = num2;
|
||||
}
|
||||
if (NGUIText.alignment != NGUIText.Alignment.Left)
|
||||
{
|
||||
NGUIText.Align(verts, size, CalcAlignPrintedWidth(num2, num10, isRuby));
|
||||
size = verts.size;
|
||||
}
|
||||
num2 = 0f;
|
||||
num3 += NGUIText.finalLineHeight;
|
||||
prev = 0;
|
||||
if (isRuby)
|
||||
{
|
||||
num11 = 0f;
|
||||
num10 = 0f;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (num < 32)
|
||||
{
|
||||
prev = num;
|
||||
continue;
|
||||
}
|
||||
if (NGUIText.encoding && ParseSymbol(text, ref i, mColors, NGUIText.premultiply, ref sub, ref bold, ref italic, ref underline, ref strike, ref ignoreColor, ref rubyTotalAdvanceRaw, ref charWithRubyTotalAdvance, isRuby, ref isDot))
|
||||
{
|
||||
Color color2;
|
||||
if (ignoreColor)
|
||||
{
|
||||
color2 = mColors[mColors.size - 1];
|
||||
color2.a *= mAlpha * NGUIText.tint.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
color2 = NGUIText.tint * mColors[mColors.size - 1];
|
||||
color2.a *= mAlpha;
|
||||
}
|
||||
color = color2;
|
||||
int j = 0;
|
||||
for (int num14 = mColors.size - 2; j < num14; j++)
|
||||
{
|
||||
color2.a *= mColors[j].a;
|
||||
}
|
||||
if (NGUIText.gradient)
|
||||
{
|
||||
a = NGUIText.gradientBottom * color2;
|
||||
b = NGUIText.gradientTop * color2;
|
||||
}
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
BMSymbol bMSymbol = (NGUIText.useSymbols ? NGUIText.GetSymbol(text, i, length) : null);
|
||||
float num15;
|
||||
float num16;
|
||||
float num18;
|
||||
float num17;
|
||||
if (bMSymbol != null)
|
||||
{
|
||||
num15 = num2 + (float)bMSymbol.offsetX * NGUIText.fontScale;
|
||||
num16 = num15 + (float)bMSymbol.width * NGUIText.fontScale;
|
||||
num17 = 0f - (num3 + (float)bMSymbol.offsetY * NGUIText.fontScale);
|
||||
num18 = num17 - (float)bMSymbol.height * NGUIText.fontScale;
|
||||
if (Mathf.RoundToInt(num2 + (float)bMSymbol.advance * NGUIText.fontScale) > NGUIText.regionWidth)
|
||||
{
|
||||
if (num2 == 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
|
||||
{
|
||||
NGUIText.Align(verts, size, CalcAlignPrintedWidth(num2, num10, isRuby));
|
||||
size = verts.size;
|
||||
}
|
||||
num15 -= num2;
|
||||
num16 -= num2;
|
||||
num18 -= NGUIText.finalLineHeight;
|
||||
num17 -= NGUIText.finalLineHeight;
|
||||
num2 = 0f;
|
||||
num3 += NGUIText.finalLineHeight;
|
||||
num9 = 0f;
|
||||
}
|
||||
verts.Add(new Vector3(num15, num18));
|
||||
verts.Add(new Vector3(num15, num17));
|
||||
verts.Add(new Vector3(num16, num17));
|
||||
verts.Add(new Vector3(num16, num18));
|
||||
num2 += NGUIText.finalSpacingX + (float)bMSymbol.advance * NGUIText.fontScale;
|
||||
i += bMSymbol.length - 1;
|
||||
prev = 0;
|
||||
if (uvs != null)
|
||||
{
|
||||
Rect uvRect = bMSymbol.uvRect;
|
||||
float xMin = uvRect.xMin;
|
||||
float yMin = uvRect.yMin;
|
||||
float xMax = uvRect.xMax;
|
||||
float yMax = uvRect.yMax;
|
||||
uvs.Add(new Vector2(xMin, yMin));
|
||||
uvs.Add(new Vector2(xMin, yMax));
|
||||
uvs.Add(new Vector2(xMax, yMax));
|
||||
uvs.Add(new Vector2(xMax, yMin));
|
||||
}
|
||||
if (cols == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (NGUIText.symbolStyle == NGUIText.SymbolStyle.Colored)
|
||||
{
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
cols.Add(color);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Color32 item = Color.white;
|
||||
item.a = color.a;
|
||||
for (int l = 0; l < 4; l++)
|
||||
{
|
||||
cols.Add(item);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
NGUIText.GlyphInfo glyph = NGUIText.GetGlyph(num, prev);
|
||||
if (glyph == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
prev = num;
|
||||
float num19 = uiLabel.RubyScale;
|
||||
float num20 = num12;
|
||||
if ((sub == 3 || sub == 4) && uiLabel.IsDot && isDot)
|
||||
{
|
||||
num19 = uiLabel.DotScale;
|
||||
num20 = num13;
|
||||
}
|
||||
switch (sub)
|
||||
{
|
||||
case 1:
|
||||
glyph.v0.x *= 0.75f;
|
||||
glyph.v0.y *= 0.75f;
|
||||
glyph.v1.x *= 0.75f;
|
||||
glyph.v1.y *= 0.75f;
|
||||
glyph.v0.y -= NGUIText.fontScale * (float)NGUIText.fontSize * 0.4f;
|
||||
glyph.v1.y -= NGUIText.fontScale * (float)NGUIText.fontSize * 0.4f;
|
||||
break;
|
||||
case 2:
|
||||
glyph.v0.x *= 0.75f;
|
||||
glyph.v0.y *= 0.75f;
|
||||
glyph.v1.x *= 0.75f;
|
||||
glyph.v1.y *= 0.75f;
|
||||
glyph.v0.y += NGUIText.fontScale * (float)NGUIText.fontSize * 0.05f;
|
||||
glyph.v1.y += NGUIText.fontScale * (float)NGUIText.fontSize * 0.05f;
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
glyph.v0.x *= num19;
|
||||
glyph.v0.y *= num19;
|
||||
glyph.v1.x *= num19;
|
||||
glyph.v1.y *= num19;
|
||||
glyph.v0.y += num20;
|
||||
glyph.v1.y += num20;
|
||||
float num21 = (num19 * rubyTotalAdvanceRaw - charWithRubyTotalAdvance) / 2f;
|
||||
glyph.v0.x -= num11 + num21;
|
||||
glyph.v1.x -= num11 + num21;
|
||||
flag2 = false;
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
if (!flag2)
|
||||
{
|
||||
flag2 = true;
|
||||
num11 += rubyTotalAdvanceRaw * num19;
|
||||
}
|
||||
glyph.v0.x -= num11;
|
||||
glyph.v1.x -= num11;
|
||||
break;
|
||||
case 0:
|
||||
if (isRuby)
|
||||
{
|
||||
glyph.v0.x -= num11;
|
||||
glyph.v1.x -= num11;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (component != null)
|
||||
{
|
||||
num3 = component.GetTargetCharacterHeight(i);
|
||||
num15 = glyph.v0.x + num2;
|
||||
num18 = glyph.v0.y - num3;
|
||||
num16 = glyph.v1.x + num2;
|
||||
num17 = glyph.v1.y - num3;
|
||||
}
|
||||
else
|
||||
{
|
||||
num15 = glyph.v0.x + num2;
|
||||
num18 = glyph.v0.y - num3;
|
||||
num16 = glyph.v1.x + num2;
|
||||
num17 = glyph.v1.y - num3;
|
||||
}
|
||||
float num22 = glyph.advance;
|
||||
if (NGUIText.finalSpacingX < 0f)
|
||||
{
|
||||
num22 += NGUIText.finalSpacingX;
|
||||
}
|
||||
if (Mathf.RoundToInt(num2 - num10 + num22) > NGUIText.regionWidth)
|
||||
{
|
||||
if (num2 == 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
|
||||
{
|
||||
NGUIText.Align(verts, size, CalcAlignPrintedWidth(num2, num10, isRuby));
|
||||
size = verts.size;
|
||||
}
|
||||
num15 -= num2;
|
||||
num16 -= num2;
|
||||
num18 -= NGUIText.finalLineHeight;
|
||||
num17 -= NGUIText.finalLineHeight;
|
||||
num2 = 0f;
|
||||
num3 += NGUIText.finalLineHeight;
|
||||
num9 = 0f;
|
||||
}
|
||||
if (IsSpace(num))
|
||||
{
|
||||
if (underline)
|
||||
{
|
||||
num = 95;
|
||||
}
|
||||
else if (strike)
|
||||
{
|
||||
num = 45;
|
||||
}
|
||||
}
|
||||
switch (sub)
|
||||
{
|
||||
case 0:
|
||||
case 4:
|
||||
num2 += NGUIText.finalSpacingX + glyph.advance;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
num2 += (NGUIText.finalSpacingX + glyph.advance) * 0.75f;
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
float num23 = (NGUIText.finalSpacingX + glyph.advance) * num19;
|
||||
num2 += num23;
|
||||
num10 += num23;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (IsSpace(num))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (uvs != null)
|
||||
{
|
||||
if (NGUIText.bitmapFont != null)
|
||||
{
|
||||
glyph.u0.x = rect.xMin + num6 * glyph.u0.x;
|
||||
glyph.u2.x = rect.xMin + num6 * glyph.u2.x;
|
||||
glyph.u0.y = rect.yMax - num7 * glyph.u0.y;
|
||||
glyph.u2.y = rect.yMax - num7 * glyph.u2.y;
|
||||
glyph.u1.x = glyph.u0.x;
|
||||
glyph.u1.y = glyph.u2.y;
|
||||
glyph.u3.x = glyph.u2.x;
|
||||
glyph.u3.y = glyph.u0.y;
|
||||
}
|
||||
int m = 0;
|
||||
for (int num24 = ((!bold) ? 1 : 4); m < num24; m++)
|
||||
{
|
||||
uvs.Add(glyph.u0);
|
||||
uvs.Add(glyph.u1);
|
||||
uvs.Add(glyph.u2);
|
||||
uvs.Add(glyph.u3);
|
||||
}
|
||||
}
|
||||
if (cols != null)
|
||||
{
|
||||
if (glyph.channel == 0 || glyph.channel == 15)
|
||||
{
|
||||
if (NGUIText.gradient)
|
||||
{
|
||||
float num25 = num8 + glyph.v0.y / NGUIText.fontScale;
|
||||
float num26 = num8 + glyph.v1.y / NGUIText.fontScale;
|
||||
num25 /= num8;
|
||||
num26 /= num8;
|
||||
s_c0 = Color.Lerp(a, b, num25);
|
||||
s_c1 = Color.Lerp(a, b, num26);
|
||||
int n = 0;
|
||||
for (int num27 = ((!bold) ? 1 : 4); n < num27; n++)
|
||||
{
|
||||
cols.Add(s_c0);
|
||||
cols.Add(s_c1);
|
||||
cols.Add(s_c1);
|
||||
cols.Add(s_c0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int num28 = 0;
|
||||
for (int num29 = (bold ? 16 : 4); num28 < num29; num28++)
|
||||
{
|
||||
cols.Add(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Color color3 = color;
|
||||
color3 *= 0.49f;
|
||||
switch (glyph.channel)
|
||||
{
|
||||
case 1:
|
||||
color3.b += 0.51f;
|
||||
break;
|
||||
case 2:
|
||||
color3.g += 0.51f;
|
||||
break;
|
||||
case 4:
|
||||
color3.r += 0.51f;
|
||||
break;
|
||||
case 8:
|
||||
color3.a += 0.51f;
|
||||
break;
|
||||
}
|
||||
Color32 item2 = color3;
|
||||
int num30 = 0;
|
||||
for (int num31 = (bold ? 16 : 4); num30 < num31; num30++)
|
||||
{
|
||||
cols.Add(item2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bold)
|
||||
{
|
||||
if (!italic)
|
||||
{
|
||||
if (component != null)
|
||||
{
|
||||
Vector2[] array = component.SetTargetCharacterRotation(i, ref num15, ref num18, ref num16, ref num17);
|
||||
verts.Add(new Vector3(array[0].x, array[0].y));
|
||||
verts.Add(new Vector3(array[1].x, array[1].y));
|
||||
verts.Add(new Vector3(array[2].x, array[2].y));
|
||||
verts.Add(new Vector3(array[3].x, array[3].y));
|
||||
}
|
||||
else
|
||||
{
|
||||
verts.Add(new Vector3(num15, num18));
|
||||
verts.Add(new Vector3(num15, num17));
|
||||
verts.Add(new Vector3(num16, num17));
|
||||
verts.Add(new Vector3(num16, num18));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float num32 = (float)NGUIText.fontSize * 0.1f * ((num17 - num18) / (float)NGUIText.fontSize);
|
||||
verts.Add(new Vector3(num15 - num32, num18));
|
||||
verts.Add(new Vector3(num15 + num32, num17));
|
||||
verts.Add(new Vector3(num16 + num32, num17));
|
||||
verts.Add(new Vector3(num16 - num32, num18));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int num33 = 0; num33 < 4; num33++)
|
||||
{
|
||||
float num34 = mBoldOffset[num33 * 2];
|
||||
float num35 = mBoldOffset[num33 * 2 + 1];
|
||||
float num36 = (italic ? ((float)NGUIText.fontSize * 0.1f * ((num17 - num18) / (float)NGUIText.fontSize)) : 0f);
|
||||
verts.Add(new Vector3(num15 + num34 - num36, num18 + num35));
|
||||
verts.Add(new Vector3(num15 + num34 + num36, num17 + num35));
|
||||
verts.Add(new Vector3(num16 + num34 + num36, num17 + num35));
|
||||
verts.Add(new Vector3(num16 + num34 - num36, num18 + num35));
|
||||
}
|
||||
}
|
||||
if (!(underline || strike))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
NGUIText.GlyphInfo glyph2 = NGUIText.GetGlyph(strike ? 45 : 95, prev);
|
||||
if (glyph2 == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (uvs != null)
|
||||
{
|
||||
if (NGUIText.bitmapFont != null)
|
||||
{
|
||||
glyph2.u0.x = rect.xMin + num6 * glyph2.u0.x;
|
||||
glyph2.u2.x = rect.xMin + num6 * glyph2.u2.x;
|
||||
glyph2.u0.y = rect.yMax - num7 * glyph2.u0.y;
|
||||
glyph2.u2.y = rect.yMax - num7 * glyph2.u2.y;
|
||||
}
|
||||
float x = (glyph2.u0.x + glyph2.u2.x) * 0.5f;
|
||||
int num37 = 0;
|
||||
for (int num38 = ((!bold) ? 1 : 4); num37 < num38; num37++)
|
||||
{
|
||||
uvs.Add(new Vector2(x, glyph2.u0.y));
|
||||
uvs.Add(new Vector2(x, glyph2.u2.y));
|
||||
uvs.Add(new Vector2(x, glyph2.u2.y));
|
||||
uvs.Add(new Vector2(x, glyph2.u0.y));
|
||||
}
|
||||
}
|
||||
if (flag && strike)
|
||||
{
|
||||
num18 = (0f - num3 + glyph2.v0.y) * 0.75f;
|
||||
num17 = (0f - num3 + glyph2.v1.y) * 0.75f;
|
||||
}
|
||||
else
|
||||
{
|
||||
num18 = 0f - num3 + glyph2.v0.y;
|
||||
num17 = 0f - num3 + glyph2.v1.y;
|
||||
}
|
||||
if (bold)
|
||||
{
|
||||
for (int num39 = 0; num39 < 4; num39++)
|
||||
{
|
||||
float num40 = mBoldOffset[num39 * 2];
|
||||
float num41 = mBoldOffset[num39 * 2 + 1];
|
||||
verts.Add(new Vector3(num9 + num40, num18 + num41));
|
||||
verts.Add(new Vector3(num9 + num40, num17 + num41));
|
||||
verts.Add(new Vector3(num2 + num40, num17 + num41));
|
||||
verts.Add(new Vector3(num2 + num40, num18 + num41));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
verts.Add(new Vector3(num9, num18));
|
||||
verts.Add(new Vector3(num9, num17));
|
||||
verts.Add(new Vector3(num2, num17));
|
||||
verts.Add(new Vector3(num2, num18));
|
||||
}
|
||||
if (NGUIText.gradient)
|
||||
{
|
||||
float num42 = num8 + glyph2.v0.y / NGUIText.fontScale;
|
||||
float num43 = num8 + glyph2.v1.y / NGUIText.fontScale;
|
||||
num42 /= num8;
|
||||
num43 /= num8;
|
||||
s_c0 = Color.Lerp(a, b, num42);
|
||||
s_c1 = Color.Lerp(a, b, num43);
|
||||
int num44 = 0;
|
||||
for (int num45 = ((!bold) ? 1 : 4); num44 < num45; num44++)
|
||||
{
|
||||
cols.Add(s_c0);
|
||||
cols.Add(s_c1);
|
||||
cols.Add(s_c1);
|
||||
cols.Add(s_c0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int num46 = 0;
|
||||
for (int num47 = (bold ? 16 : 4); num46 < num47; num46++)
|
||||
{
|
||||
cols.Add(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NGUIText.alignment != NGUIText.Alignment.Left && size < verts.size)
|
||||
{
|
||||
NGUIText.Align(verts, size, CalcAlignPrintedWidth(num2, num10, isRuby));
|
||||
size = verts.size;
|
||||
}
|
||||
mColors.Clear();
|
||||
}
|
||||
|
||||
private static float CalcAlignPrintedWidth(float textWidth, float rubyTextWidth, bool isRuby)
|
||||
{
|
||||
float num = textWidth - NGUIText.finalSpacingX;
|
||||
if (isRuby)
|
||||
{
|
||||
num -= rubyTextWidth;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user