Squashes 146 commits from battle-engine-extraction. Net: 2,045 files changed, +11,896 / -158,687 lines. Ships engine passes 4-7 (dead-code cull, view-layer stub, receive-path shrink) plus the Phase-5 AsyncLocal ambient deletion that turns concurrent battles into a type-system property rather than a scope contract. ## What landed **Passes 4-7 (chunks 1-34):** Extended the Phase-4 const-false collapse into a cascading cull across the skill graph, view layer, and receive-path periphery. Six mode flags (IsWatchBattle/IsReplayBattle/IsAdmin/IsAdminWatch/IsPuzzleQuest/ IsAINetwork) became `const false`, every guarded block deleted. Field*.cs subclass ctors + BackGroundBase + ObjectChecker culled to no-ops. Mulligan family reworked to take a mgr param through IMulliganMgr.InitMulligan. Emotion/Recovery/Resource clusters null-stubbed. Prediction/OperationSimulator/ skill filters converted from static ambient reads to per-mgr reads via SkillPrm.ownerCard.SelfBattlePlayer.BattleMgr / ins.BattleMgr / this.BattleMgr. **Phase-5 ambient rip (chunks 35-47):** Deleted BattleAmbient / BattleAmbient- Context / TestBattleScope in full. Every per-battle mutable slot now lives on the mgr instance itself: mgr.InstanceIsForecast / InstanceIsRandomDraw / InstanceRecoveryInfo / InstanceViewerId / InstanceNetworkAgent / GameMgr BattleManagerBase.GetIns() returns null unconditionally; the residual static flags + 3 façades (Certification.ViewerId, Data.BattleRecoveryInfo, ToolboxGame.RealTimeNetworkAgent) are null-tolerant defaults kept for the handful of engine-internal readers that still reference their types. Zero BattleAmbient references anywhere in engine + node + tests. Added pre-seeded GameMgr ctor overload threaded through the mgr chain (BattleManagerBase → SingleBattleMgr / NetworkBattleManagerBase → NetworkStandard- BattleMgr → HeadlessBattleMgr / HeadlessNetworkBattleMgr). Fixtures build a GameMgr, seed it via HeadlessEngineEnv.SeedCharaIds/SeedNetUser, and pass it to the mgr's ctor — no ambient reach. Node side (SVSim.BattleNode/SessionBattleEngine): _ctx replaced with a plain GameMgr field; 34 `using var _ambient = BattleAmbient.Enter(_ctx)` scope wraps ripped from every accessor and mutator; EngineGlobalInit.WirePerSessionGameMgr takes GameMgr as a param and runs from SessionBattleEngine.SetupInternal BEFORE mgr construction. Test side: TestBattleScope deleted; 18 fixture [SetUp]s migrated to `HeadlessEngineEnv.EnsureProcessGlobals()`; MultiInstanceEngineTests rewritten around per-mgr construction (GetIns() → null is the pinned invariant). ## Regression fixes - **chunk-48** (MulliganCtrl): chunk-35's `= null` stubs on card lookups broke the live receive-driven Deal path (BattlePlayerBase.DrawCard NRE'd downstream of NetworkPlayerMulliganCtrl.StartMulliganVfx). Restored the three lookups via `_battlePlayer.BattleMgr.GetBattleCardIdx`. Engine tests were satisfied by the WireMulliganPhase seam; unit tests exposed the live-path gap. ## Ship state - SVSim.BattleEngine.Tests: 56/56 pass, 2 skip - SVSim.UnitTests: 1554/1554 pass (was 1523/31-fail before chunk 48) - Solution build: 0 source warnings (40 pre-existing NU1902 MessagePack CVEs in SVSim.EmulatedEntrypoint, unrelated) - Sequential PVP smoke: verified live (two back-to-back battles, no regression on cleanup/spinup) - Concurrent PVP smoke: verified live Adds tools/engine-port/ClosureAnalyzer/ — the Roslyn transitive-type-closure analyzer needed to make future cascade cleanup safe (per feedback memory "Engine cleanup needs closure tool" from the 2026-06-28 pass-3 failure). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1431 lines
32 KiB
C#
1431 lines
32 KiB
C#
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
using Wizard;
|
|
|
|
public static class NGUIText
|
|
{
|
|
public enum Alignment
|
|
{
|
|
Automatic,
|
|
Left,
|
|
Center,
|
|
Right,
|
|
Justified
|
|
}
|
|
|
|
public enum SymbolStyle
|
|
{
|
|
None,
|
|
Normal,
|
|
Colored
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public static UIFont bitmapFont;
|
|
|
|
public static UnityEngine.Font dynamicFont;
|
|
|
|
public static GlyphInfo glyph = new GlyphInfo();
|
|
|
|
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 float baseline = 0f;
|
|
|
|
public static bool useSymbols = false;
|
|
|
|
private static BetterList<Color> mColors = new BetterList<Color>();
|
|
|
|
private static float mAlpha = 1f;
|
|
|
|
private static CharacterInfo mTempChar;
|
|
|
|
private static BetterList<float> mSizes = new BetterList<float>();
|
|
|
|
public static void Update(UIWidget.Pivot piv)
|
|
{
|
|
Update(request: true, piv);
|
|
}
|
|
|
|
public static void Update(bool request, UIWidget.Pivot piv)
|
|
{
|
|
finalSize = Mathf.RoundToInt((float)fontSize / pixelDensity);
|
|
finalSpacingX = spacingX * fontScale;
|
|
finalLineHeight = ((float)fontSize + spacingY) * fontScale;
|
|
useSymbols = bitmapFont != null && bitmapFont.hasSymbols && encoding && symbolStyle != SymbolStyle.None;
|
|
UnityEngine.Font font = dynamicFont;
|
|
if (!(font != null && request))
|
|
{
|
|
return;
|
|
}
|
|
font.RequestCharactersInTexture(")_-", finalSize, fontStyle);
|
|
if (!font.GetCharacterInfo(')', out mTempChar, finalSize, fontStyle) || (float)mTempChar.maxY == 0f)
|
|
{
|
|
font.RequestCharactersInTexture("A", finalSize, fontStyle);
|
|
if (!font.GetCharacterInfo('A', out mTempChar, finalSize, fontStyle))
|
|
{
|
|
baseline = 0f;
|
|
return;
|
|
}
|
|
}
|
|
float num = mTempChar.maxY;
|
|
float num2 = mTempChar.minY;
|
|
if (piv == UIWidget.Pivot.Center)
|
|
{
|
|
baseline = Mathf.Round(num + ((float)finalSize - num + num2) * 0.5f + spacingY * 0.5f);
|
|
}
|
|
else
|
|
{
|
|
baseline = Mathf.Round(num + ((float)finalSize - num + num2) * 0.5f);
|
|
}
|
|
}
|
|
|
|
public static void Prepare(string text)
|
|
{
|
|
if (dynamicFont != null)
|
|
{
|
|
dynamicFont.RequestCharactersInTexture(text, finalSize, fontStyle);
|
|
}
|
|
if (dynamicFont != null)
|
|
{
|
|
dynamicFont.RequestCharactersInTexture(text, fontSize, fontStyle);
|
|
}
|
|
}
|
|
|
|
public static BMSymbol GetSymbol(string text, int index, int textLength)
|
|
{
|
|
if (!(bitmapFont != null))
|
|
{
|
|
return null;
|
|
}
|
|
return bitmapFont.MatchSymbol(text, index, textLength);
|
|
}
|
|
|
|
private static float GetCharacterAdvance(char c)
|
|
{
|
|
if (dynamicFont.GetCharacterInfo(c, out var info, fontSize, fontStyle))
|
|
{
|
|
return (float)info.advance * fontScale;
|
|
}
|
|
return 0f;
|
|
}
|
|
|
|
public static float GetGlyphWidth(int ch, int prev)
|
|
{
|
|
if (bitmapFont != null)
|
|
{
|
|
bool flag = false;
|
|
if (ch == 8201)
|
|
{
|
|
flag = true;
|
|
ch = 32;
|
|
}
|
|
BMGlyph bMGlyph = bitmapFont.bmFont.GetGlyph(ch);
|
|
if (bMGlyph != null)
|
|
{
|
|
int num = bMGlyph.advance;
|
|
if (flag)
|
|
{
|
|
num >>= 1;
|
|
}
|
|
return fontScale * (float)((prev != 0) ? (num + bMGlyph.GetKerning(prev)) : bMGlyph.advance);
|
|
}
|
|
}
|
|
else if (dynamicFont != null)
|
|
{
|
|
return GetCharacterAdvance((char)ch);
|
|
}
|
|
return 0f;
|
|
}
|
|
|
|
public static GlyphInfo GetGlyph(int ch, int prev)
|
|
{
|
|
if (bitmapFont != null)
|
|
{
|
|
bool flag = false;
|
|
if (ch == 8201)
|
|
{
|
|
flag = true;
|
|
ch = 32;
|
|
}
|
|
BMGlyph bMGlyph = bitmapFont.bmFont.GetGlyph(ch);
|
|
if (bMGlyph != null)
|
|
{
|
|
int num = ((prev != 0) ? bMGlyph.GetKerning(prev) : 0);
|
|
glyph.v0.x = ((prev != 0) ? (bMGlyph.offsetX + num) : bMGlyph.offsetX);
|
|
glyph.v1.y = -bMGlyph.offsetY;
|
|
glyph.v1.x = glyph.v0.x + (float)bMGlyph.width;
|
|
glyph.v0.y = glyph.v1.y - (float)bMGlyph.height;
|
|
glyph.u0.x = bMGlyph.x;
|
|
glyph.u0.y = bMGlyph.y + bMGlyph.height;
|
|
glyph.u2.x = bMGlyph.x + bMGlyph.width;
|
|
glyph.u2.y = bMGlyph.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 num2 = bMGlyph.advance;
|
|
if (flag)
|
|
{
|
|
num2 >>= 1;
|
|
}
|
|
glyph.advance = num2 + num;
|
|
glyph.channel = bMGlyph.channel;
|
|
if (fontScale != 1f)
|
|
{
|
|
glyph.v0 *= fontScale;
|
|
glyph.v1 *= fontScale;
|
|
glyph.advance *= fontScale;
|
|
}
|
|
return glyph;
|
|
}
|
|
}
|
|
else if (dynamicFont != null && dynamicFont.GetCharacterInfo((char)ch, out mTempChar, finalSize, fontStyle))
|
|
{
|
|
glyph.v0.x = mTempChar.minX;
|
|
glyph.v1.x = mTempChar.maxX;
|
|
glyph.v0.y = (float)mTempChar.maxY - baseline;
|
|
glyph.v1.y = (float)mTempChar.minY - baseline;
|
|
glyph.u0 = mTempChar.uvTopLeft;
|
|
glyph.u1 = mTempChar.uvBottomLeft;
|
|
glyph.u2 = mTempChar.uvBottomRight;
|
|
glyph.u3 = mTempChar.uvTopRight;
|
|
glyph.advance = mTempChar.advance;
|
|
glyph.channel = 0;
|
|
glyph.v0.x = Mathf.Round(glyph.v0.x);
|
|
glyph.v0.y = Mathf.Round(glyph.v0.y);
|
|
glyph.v1.x = Mathf.Round(glyph.v1.x);
|
|
glyph.v1.y = Mathf.Round(glyph.v1.y);
|
|
float num3 = fontScale * pixelDensity;
|
|
if (num3 != 1f)
|
|
{
|
|
glyph.v0 *= num3;
|
|
glyph.v1 *= num3;
|
|
glyph.advance *= num3;
|
|
}
|
|
glyph.advance = GetCharacterAdvance((char)ch);
|
|
return glyph;
|
|
}
|
|
glyph.v0.x = 0f;
|
|
glyph.v1.x = 0f;
|
|
glyph.v0.y = 0f;
|
|
glyph.v1.y = 0f;
|
|
glyph.u0 = Vector2.zero;
|
|
glyph.u1 = Vector2.zero;
|
|
glyph.u2 = Vector2.zero;
|
|
glyph.u3 = Vector2.zero;
|
|
glyph.advance = 0f;
|
|
glyph.channel = 0;
|
|
return glyph;
|
|
}
|
|
|
|
[DebuggerHidden]
|
|
[DebuggerStepThrough]
|
|
public static Color ParseColor24(string text, int offset)
|
|
{
|
|
int num = (NGUIMath.HexToDecimal(text[offset]) << 4) | NGUIMath.HexToDecimal(text[offset + 1]);
|
|
int num2 = (NGUIMath.HexToDecimal(text[offset + 2]) << 4) | NGUIMath.HexToDecimal(text[offset + 3]);
|
|
int num3 = (NGUIMath.HexToDecimal(text[offset + 4]) << 4) | NGUIMath.HexToDecimal(text[offset + 5]);
|
|
float num4 = 0.003921569f;
|
|
return new Color(num4 * (float)num, num4 * (float)num2, num4 * (float)num3);
|
|
}
|
|
|
|
[DebuggerHidden]
|
|
[DebuggerStepThrough]
|
|
public static Color ParseColor32(string text, int offset)
|
|
{
|
|
int num = (NGUIMath.HexToDecimal(text[offset]) << 4) | NGUIMath.HexToDecimal(text[offset + 1]);
|
|
int num2 = (NGUIMath.HexToDecimal(text[offset + 2]) << 4) | NGUIMath.HexToDecimal(text[offset + 3]);
|
|
int num3 = (NGUIMath.HexToDecimal(text[offset + 4]) << 4) | NGUIMath.HexToDecimal(text[offset + 5]);
|
|
int num4 = (NGUIMath.HexToDecimal(text[offset + 6]) << 4) | NGUIMath.HexToDecimal(text[offset + 7]);
|
|
float num5 = 0.003921569f;
|
|
return new Color(num5 * (float)num, num5 * (float)num2, num5 * (float)num3, num5 * (float)num4);
|
|
}
|
|
|
|
[DebuggerHidden]
|
|
[DebuggerStepThrough]
|
|
public static string EncodeColor(Color c)
|
|
{
|
|
return EncodeColor24(c);
|
|
}
|
|
|
|
[DebuggerHidden]
|
|
[DebuggerStepThrough]
|
|
public static string EncodeColor24(Color c)
|
|
{
|
|
return NGUIMath.DecimalToHex24(0xFFFFFF & (NGUIMath.ColorToInt(c) >> 8));
|
|
}
|
|
|
|
[DebuggerHidden]
|
|
[DebuggerStepThrough]
|
|
public static string EncodeColor32(Color c)
|
|
{
|
|
return NGUIMath.DecimalToHex32(NGUIMath.ColorToInt(c));
|
|
}
|
|
|
|
public static bool ParseSymbol(string text, ref int index)
|
|
{
|
|
int sub = 1;
|
|
bool bold = false;
|
|
bool italic = false;
|
|
bool underline = false;
|
|
bool strike = false;
|
|
bool ignoreColor = false;
|
|
return RubyText.ParseSymbol(text, ref index, null, premultiply: false, ref sub, ref bold, ref italic, ref underline, ref strike, ref ignoreColor);
|
|
}
|
|
|
|
[DebuggerHidden]
|
|
[DebuggerStepThrough]
|
|
public static bool IsHex(char ch)
|
|
{
|
|
if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
|
|
{
|
|
if (ch >= 'A')
|
|
{
|
|
return ch <= 'F';
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static string StripSymbols(string text)
|
|
{
|
|
if (text != null)
|
|
{
|
|
int num = 0;
|
|
int length = text.Length;
|
|
while (num < length)
|
|
{
|
|
if (text[num] == '[')
|
|
{
|
|
int sub = 0;
|
|
bool bold = false;
|
|
bool italic = false;
|
|
bool underline = false;
|
|
bool strike = false;
|
|
bool ignoreColor = false;
|
|
int index = num;
|
|
if (RubyText.ParseSymbol(text, ref index, null, premultiply: false, ref sub, ref bold, ref italic, ref underline, ref strike, ref ignoreColor))
|
|
{
|
|
text = text.Remove(num, index - num);
|
|
length = text.Length;
|
|
continue;
|
|
}
|
|
}
|
|
num++;
|
|
}
|
|
}
|
|
return text;
|
|
}
|
|
|
|
public static void Align(BetterList<Vector3> verts, int indexOffset, float printedWidth, int elements = 4)
|
|
{
|
|
switch (alignment)
|
|
{
|
|
case Alignment.Right:
|
|
{
|
|
float num12 = (float)rectWidth - printedWidth;
|
|
if (!(num12 < 0f))
|
|
{
|
|
for (int j = indexOffset; j < verts.size; j++)
|
|
{
|
|
verts.buffer[j].x += num12;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case Alignment.Center:
|
|
{
|
|
float num9 = ((float)rectWidth - printedWidth) * 0.5f;
|
|
if (!(num9 < 0f))
|
|
{
|
|
int num10 = Mathf.RoundToInt((float)rectWidth - printedWidth);
|
|
int num11 = Mathf.RoundToInt(rectWidth);
|
|
bool flag = (num10 & 1) == 1;
|
|
bool flag2 = (num11 & 1) == 1;
|
|
if ((flag && !flag2) || (!flag && flag2))
|
|
{
|
|
num9 += 0.5f * fontScale;
|
|
}
|
|
for (int i = indexOffset; i < verts.size; i++)
|
|
{
|
|
verts.buffer[i].x += num9;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case Alignment.Justified:
|
|
{
|
|
if (printedWidth < (float)rectWidth * 0.65f || ((float)rectWidth - printedWidth) * 0.5f < 1f)
|
|
{
|
|
break;
|
|
}
|
|
int num = (verts.size - indexOffset) / elements;
|
|
if (num < 1)
|
|
{
|
|
break;
|
|
}
|
|
float num2 = 1f / (float)(num - 1);
|
|
float num3 = (float)rectWidth / printedWidth;
|
|
int num4 = indexOffset + elements;
|
|
int num5 = 1;
|
|
while (num4 < verts.size)
|
|
{
|
|
float x = verts.buffer[num4].x;
|
|
float x2 = verts.buffer[num4 + elements / 2].x;
|
|
float num6 = x2 - x;
|
|
float num7 = x * num3;
|
|
float a = num7 + num6;
|
|
float num8 = x2 * num3;
|
|
float b = num8 - num6;
|
|
float t = (float)num5 * num2;
|
|
x2 = Mathf.Lerp(a, num8, t);
|
|
x = Mathf.Lerp(num7, b, t);
|
|
x = Mathf.Round(x);
|
|
x2 = Mathf.Round(x2);
|
|
switch (elements)
|
|
{
|
|
case 4:
|
|
verts.buffer[num4++].x = x;
|
|
verts.buffer[num4++].x = x;
|
|
verts.buffer[num4++].x = x2;
|
|
verts.buffer[num4++].x = x2;
|
|
break;
|
|
case 2:
|
|
verts.buffer[num4++].x = x;
|
|
verts.buffer[num4++].x = x2;
|
|
break;
|
|
case 1:
|
|
verts.buffer[num4++].x = x;
|
|
break;
|
|
}
|
|
num5++;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static int GetExactCharacterIndex(BetterList<Vector3> verts, BetterList<int> indices, Vector2 pos)
|
|
{
|
|
for (int i = 0; i < indices.size; i++)
|
|
{
|
|
int num = i << 1;
|
|
int i2 = num + 1;
|
|
float x = verts[num].x;
|
|
if (pos.x < x)
|
|
{
|
|
continue;
|
|
}
|
|
float x2 = verts[i2].x;
|
|
if (pos.x > x2)
|
|
{
|
|
continue;
|
|
}
|
|
float y = verts[num].y;
|
|
if (!(pos.y < y))
|
|
{
|
|
float y2 = verts[i2].y;
|
|
if (!(pos.y > y2))
|
|
{
|
|
return indices[i];
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public static int GetApproximateCharacterIndex(BetterList<Vector3> verts, BetterList<int> indices, Vector2 pos)
|
|
{
|
|
float num = float.MaxValue;
|
|
float num2 = float.MaxValue;
|
|
int i = 0;
|
|
for (int j = 0; j < verts.size; j++)
|
|
{
|
|
float num3 = Mathf.Abs(pos.y - verts[j].y);
|
|
if (!(num3 > num2))
|
|
{
|
|
float num4 = Mathf.Abs(pos.x - verts[j].x);
|
|
if (num3 < num2)
|
|
{
|
|
num2 = num3;
|
|
num = num4;
|
|
i = j;
|
|
}
|
|
else if (num4 < num)
|
|
{
|
|
num = num4;
|
|
i = j;
|
|
}
|
|
}
|
|
}
|
|
return indices[i];
|
|
}
|
|
|
|
[DebuggerHidden]
|
|
[DebuggerStepThrough]
|
|
private static bool IsSpace(int ch)
|
|
{
|
|
if (ch != 32 && ch != 8202 && ch != 8203)
|
|
{
|
|
return ch == 8201;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
[DebuggerHidden]
|
|
[DebuggerStepThrough]
|
|
public static void EndLine(ref StringBuilder s)
|
|
{
|
|
int num = s.Length - 1;
|
|
if (num > 0 && IsSpace(s[num]))
|
|
{
|
|
s[num] = '\n';
|
|
}
|
|
else
|
|
{
|
|
s.Append('\n');
|
|
}
|
|
}
|
|
|
|
[DebuggerHidden]
|
|
[DebuggerStepThrough]
|
|
private static void ReplaceSpaceWithNewline(ref StringBuilder s)
|
|
{
|
|
int num = s.Length - 1;
|
|
if (num > 0 && IsSpace(s[num]))
|
|
{
|
|
s[num] = '\n';
|
|
}
|
|
}
|
|
|
|
public static Vector2 CalculatePrintedSize(string text)
|
|
{
|
|
Vector2 zero = Vector2.zero;
|
|
if (!string.IsNullOrEmpty(text))
|
|
{
|
|
if (encoding)
|
|
{
|
|
text = StripSymbols(text);
|
|
}
|
|
Prepare(text);
|
|
float num = 0f;
|
|
float num2 = 0f;
|
|
float num3 = 0f;
|
|
int length = text.Length;
|
|
int num4 = 0;
|
|
int prev = 0;
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
num4 = text[i];
|
|
if (num4 == 10)
|
|
{
|
|
if (num > num3)
|
|
{
|
|
num3 = num;
|
|
}
|
|
num = 0f;
|
|
num2 += finalLineHeight;
|
|
}
|
|
else
|
|
{
|
|
if (num4 < 32)
|
|
{
|
|
continue;
|
|
}
|
|
BMSymbol bMSymbol = (useSymbols ? GetSymbol(text, i, length) : null);
|
|
if (bMSymbol == null)
|
|
{
|
|
float glyphWidth = GetGlyphWidth(num4, prev);
|
|
if (glyphWidth == 0f)
|
|
{
|
|
continue;
|
|
}
|
|
glyphWidth += finalSpacingX;
|
|
if (Mathf.RoundToInt(num + glyphWidth) > regionWidth)
|
|
{
|
|
if (num > num3)
|
|
{
|
|
num3 = num - finalSpacingX;
|
|
}
|
|
num = glyphWidth;
|
|
num2 += finalLineHeight;
|
|
}
|
|
else
|
|
{
|
|
num += glyphWidth;
|
|
}
|
|
prev = num4;
|
|
continue;
|
|
}
|
|
float num5 = finalSpacingX + (float)bMSymbol.advance * fontScale;
|
|
if (Mathf.RoundToInt(num + num5) > regionWidth)
|
|
{
|
|
if (num > num3)
|
|
{
|
|
num3 = num - finalSpacingX;
|
|
}
|
|
num = num5;
|
|
num2 += finalLineHeight;
|
|
}
|
|
else
|
|
{
|
|
num += num5;
|
|
}
|
|
i += bMSymbol.sequence.Length - 1;
|
|
prev = 0;
|
|
}
|
|
}
|
|
zero.x = ((num > num3) ? (num - finalSpacingX) : num3);
|
|
zero.y = num2 + finalLineHeight;
|
|
zero.x += 0.5f;
|
|
zero.y += 0.5f;
|
|
}
|
|
return zero;
|
|
}
|
|
|
|
public static int CalculateOffsetToFit(string text)
|
|
{
|
|
if (string.IsNullOrEmpty(text) || regionWidth < 1)
|
|
{
|
|
return 0;
|
|
}
|
|
Prepare(text);
|
|
int length = text.Length;
|
|
int prev = 0;
|
|
int i = 0;
|
|
for (int length2 = text.Length; i < length2; i++)
|
|
{
|
|
BMSymbol bMSymbol = (useSymbols ? GetSymbol(text, i, length) : null);
|
|
if (bMSymbol == null)
|
|
{
|
|
char num = text[i];
|
|
float glyphWidth = GetGlyphWidth(num, prev);
|
|
if (glyphWidth != 0f)
|
|
{
|
|
mSizes.Add(finalSpacingX + glyphWidth);
|
|
}
|
|
prev = num;
|
|
continue;
|
|
}
|
|
mSizes.Add(finalSpacingX + (float)bMSymbol.advance * fontScale);
|
|
int j = 0;
|
|
for (int num2 = bMSymbol.sequence.Length - 1; j < num2; j++)
|
|
{
|
|
mSizes.Add(0f);
|
|
}
|
|
i += bMSymbol.sequence.Length - 1;
|
|
prev = 0;
|
|
}
|
|
float num3 = regionWidth;
|
|
int num4 = mSizes.size;
|
|
while (num4 > 0 && num3 > 0f)
|
|
{
|
|
num3 -= mSizes[--num4];
|
|
}
|
|
mSizes.Clear();
|
|
if (num3 < 0f)
|
|
{
|
|
num4++;
|
|
}
|
|
return num4;
|
|
}
|
|
|
|
public static bool WrapText(string text, out string finalText, bool wrapLineColors = false)
|
|
{
|
|
return WrapText(text, out finalText, keepCharCount: false, wrapLineColors);
|
|
}
|
|
|
|
public static bool WrapText(string text, out string finalText, bool keepCharCount, bool wrapLineColors, bool useEllipsis = false)
|
|
{
|
|
if (regionWidth < 1 || regionHeight < 1 || finalLineHeight < 1f)
|
|
{
|
|
finalText = "";
|
|
return false;
|
|
}
|
|
float num = ((maxLines > 0) ? Mathf.Min(regionHeight, finalLineHeight * (float)maxLines) : ((float)regionHeight));
|
|
int num2 = ((maxLines > 0) ? maxLines : 1000000);
|
|
num2 = Mathf.FloorToInt(Mathf.Min(num2, num / finalLineHeight) + 0.01f);
|
|
if (num2 == 0)
|
|
{
|
|
finalText = "";
|
|
return false;
|
|
}
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
text = " ";
|
|
}
|
|
Prepare(text);
|
|
StringBuilder s = new StringBuilder();
|
|
int length = text.Length;
|
|
float num3 = regionWidth;
|
|
int num4 = 0;
|
|
int i = 0;
|
|
int num5 = 1;
|
|
int prev = 0;
|
|
bool flag = true;
|
|
bool flag2 = true;
|
|
bool flag3 = false;
|
|
Color color = tint;
|
|
int sub = 0;
|
|
bool bold = false;
|
|
bool italic = false;
|
|
bool underline = false;
|
|
bool strike = false;
|
|
bool ignoreColor = false;
|
|
if (!useSymbols)
|
|
{
|
|
wrapLineColors = false;
|
|
}
|
|
if (wrapLineColors)
|
|
{
|
|
mColors.Add(color);
|
|
s.Append("[");
|
|
s.Append(EncodeColor(color));
|
|
s.Append("]");
|
|
}
|
|
bool flag4 = !Global.IsWordBreakLanguage();
|
|
for (; i < length; i++)
|
|
{
|
|
char c = text[i];
|
|
if (flag4 && c > '')
|
|
{
|
|
flag3 = true;
|
|
}
|
|
if (c == '\n')
|
|
{
|
|
if (num5 == num2)
|
|
{
|
|
break;
|
|
}
|
|
num3 = regionWidth;
|
|
if (num4 < i)
|
|
{
|
|
s.Append(text.Substring(num4, i - num4 + 1));
|
|
}
|
|
else
|
|
{
|
|
s.Append(c);
|
|
}
|
|
if (wrapLineColors)
|
|
{
|
|
for (int j = 0; j < mColors.size; j++)
|
|
{
|
|
s.Insert(s.Length - 1, "[-]");
|
|
}
|
|
for (int k = 0; k < mColors.size; k++)
|
|
{
|
|
s.Append("[");
|
|
s.Append(EncodeColor(mColors[k]));
|
|
s.Append("]");
|
|
}
|
|
}
|
|
flag = true;
|
|
num5++;
|
|
num4 = i + 1;
|
|
prev = 0;
|
|
continue;
|
|
}
|
|
if (encoding)
|
|
{
|
|
if (!wrapLineColors)
|
|
{
|
|
if (ParseSymbol(text, ref i))
|
|
{
|
|
i--;
|
|
continue;
|
|
}
|
|
}
|
|
else if (RubyText.ParseSymbol(text, ref i, mColors, premultiply, ref sub, ref bold, ref italic, ref underline, ref strike, ref ignoreColor))
|
|
{
|
|
if (ignoreColor)
|
|
{
|
|
color = mColors[mColors.size - 1];
|
|
color.a *= mAlpha * tint.a;
|
|
}
|
|
else
|
|
{
|
|
color = tint * mColors[mColors.size - 1];
|
|
color.a *= mAlpha;
|
|
}
|
|
int l = 0;
|
|
for (int num6 = mColors.size - 2; l < num6; l++)
|
|
{
|
|
color.a *= mColors[l].a;
|
|
}
|
|
i--;
|
|
continue;
|
|
}
|
|
}
|
|
BMSymbol bMSymbol = (useSymbols ? GetSymbol(text, i, length) : null);
|
|
float num7;
|
|
if (bMSymbol == null)
|
|
{
|
|
float glyphWidth = GetGlyphWidth(c, prev);
|
|
if (glyphWidth == 0f && !IsSpace(c))
|
|
{
|
|
continue;
|
|
}
|
|
num7 = finalSpacingX + glyphWidth;
|
|
}
|
|
else
|
|
{
|
|
num7 = finalSpacingX + (float)bMSymbol.advance * fontScale;
|
|
}
|
|
num3 -= num7;
|
|
if (IsSpace(c) && !flag3 && num4 < i)
|
|
{
|
|
int num8 = i - num4 + 1;
|
|
if (num5 == num2 && num3 <= 0f && i < length)
|
|
{
|
|
char c2 = text[i];
|
|
if (c2 < ' ' || IsSpace(c2))
|
|
{
|
|
num8--;
|
|
}
|
|
}
|
|
s.Append(text.Substring(num4, num8));
|
|
flag = false;
|
|
num4 = i + 1;
|
|
prev = c;
|
|
}
|
|
if (num3 < 0f)
|
|
{
|
|
if (!flag && num5 != num2)
|
|
{
|
|
flag = true;
|
|
num3 = regionWidth;
|
|
i = num4 - 1;
|
|
prev = 0;
|
|
if (num5++ == num2)
|
|
{
|
|
break;
|
|
}
|
|
if (keepCharCount)
|
|
{
|
|
ReplaceSpaceWithNewline(ref s);
|
|
}
|
|
else
|
|
{
|
|
EndLine(ref s);
|
|
}
|
|
if (wrapLineColors)
|
|
{
|
|
for (int m = 0; m < mColors.size; m++)
|
|
{
|
|
s.Insert(s.Length - 1, "[-]");
|
|
}
|
|
for (int n = 0; n < mColors.size; n++)
|
|
{
|
|
s.Append("[");
|
|
s.Append(EncodeColor(mColors[n]));
|
|
s.Append("]");
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
if (useEllipsis && num5 == num2 && i > 1)
|
|
{
|
|
float num9 = GetGlyphWidth(46, 46) * 3f;
|
|
if (num9 < (float)regionWidth)
|
|
{
|
|
num3 += num7;
|
|
int num10 = i;
|
|
int num11 = 0;
|
|
while (num10 > 1 && num3 < num9)
|
|
{
|
|
num10--;
|
|
char prev2 = text[num10 - 1];
|
|
char ch = text[num10];
|
|
bool flag5 = num3 == 0f && IsSpace(ch);
|
|
num3 += GetGlyphWidth(ch, prev2);
|
|
if (num10 < num4 && !flag5)
|
|
{
|
|
num11++;
|
|
}
|
|
}
|
|
if (num3 >= num9)
|
|
{
|
|
if (num11 > 0)
|
|
{
|
|
s.Length = Mathf.Max(0, s.Length - num11);
|
|
}
|
|
s.Append(text.Substring(num4, Mathf.Max(0, num10 - num4)));
|
|
while (s.Length > 0 && IsSpace(s[s.Length - 1]))
|
|
{
|
|
StringBuilder stringBuilder = s;
|
|
int length2 = stringBuilder.Length - 1;
|
|
stringBuilder.Length = length2;
|
|
}
|
|
s.Append("...");
|
|
num5++;
|
|
num4 = (i = num10);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
s.Append(text.Substring(num4, Mathf.Max(0, i - num4)));
|
|
bool flag6 = IsSpace(c);
|
|
if (!flag6 && !flag3)
|
|
{
|
|
flag2 = false;
|
|
}
|
|
if (wrapLineColors && mColors.size > 0)
|
|
{
|
|
s.Append("[-]");
|
|
}
|
|
if (num5++ == num2)
|
|
{
|
|
num4 = i;
|
|
break;
|
|
}
|
|
if (keepCharCount)
|
|
{
|
|
ReplaceSpaceWithNewline(ref s);
|
|
}
|
|
else
|
|
{
|
|
EndLine(ref s);
|
|
}
|
|
if (wrapLineColors)
|
|
{
|
|
for (int num12 = 0; num12 < mColors.size; num12++)
|
|
{
|
|
s.Insert(s.Length - 1, "[-]");
|
|
}
|
|
for (int num13 = 0; num13 < mColors.size; num13++)
|
|
{
|
|
s.Append("[");
|
|
s.Append(EncodeColor(mColors[num13]));
|
|
s.Append("]");
|
|
}
|
|
}
|
|
flag = true;
|
|
if (flag6)
|
|
{
|
|
num4 = i + 1;
|
|
num3 = regionWidth;
|
|
}
|
|
else
|
|
{
|
|
num4 = i;
|
|
num3 = (float)regionWidth - num7;
|
|
}
|
|
prev = 0;
|
|
}
|
|
else
|
|
{
|
|
prev = c;
|
|
}
|
|
if (bMSymbol != null)
|
|
{
|
|
i += bMSymbol.length - 1;
|
|
prev = 0;
|
|
}
|
|
}
|
|
if (num4 < i)
|
|
{
|
|
s.Append(text.Substring(num4, i - num4));
|
|
}
|
|
if (wrapLineColors && mColors.size > 0)
|
|
{
|
|
s.Append("[-]");
|
|
}
|
|
finalText = s.ToString();
|
|
mColors.Clear();
|
|
if (flag2)
|
|
{
|
|
if (i != length)
|
|
{
|
|
return num5 <= Mathf.Min(maxLines, num2);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static void PrintApproximateCharacterPositions(string text, BetterList<Vector3> verts, BetterList<int> indices)
|
|
{
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
text = " ";
|
|
}
|
|
Prepare(text);
|
|
float num = 0f;
|
|
float num2 = 0f;
|
|
float num3 = 0f;
|
|
float num4 = (float)fontSize * fontScale * 0.5f;
|
|
int length = text.Length;
|
|
int size = verts.size;
|
|
int num5 = 0;
|
|
int prev = 0;
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
num5 = text[i];
|
|
verts.Add(new Vector3(num, 0f - num2 - num4));
|
|
indices.Add(i);
|
|
if (num5 == 10)
|
|
{
|
|
if (num > num3)
|
|
{
|
|
num3 = num;
|
|
}
|
|
if (alignment != Alignment.Left)
|
|
{
|
|
Align(verts, size, num - finalSpacingX, 1);
|
|
size = verts.size;
|
|
}
|
|
num = 0f;
|
|
num2 += finalLineHeight;
|
|
prev = 0;
|
|
continue;
|
|
}
|
|
if (num5 < 32)
|
|
{
|
|
prev = 0;
|
|
continue;
|
|
}
|
|
if (encoding && ParseSymbol(text, ref i))
|
|
{
|
|
i--;
|
|
continue;
|
|
}
|
|
BMSymbol bMSymbol = (useSymbols ? GetSymbol(text, i, length) : null);
|
|
if (bMSymbol == null)
|
|
{
|
|
float glyphWidth = GetGlyphWidth(num5, prev);
|
|
if (glyphWidth == 0f)
|
|
{
|
|
continue;
|
|
}
|
|
glyphWidth += finalSpacingX;
|
|
if (Mathf.RoundToInt(num + glyphWidth) > regionWidth)
|
|
{
|
|
if (num == 0f)
|
|
{
|
|
return;
|
|
}
|
|
if (alignment != Alignment.Left && size < verts.size)
|
|
{
|
|
Align(verts, size, num - finalSpacingX, 1);
|
|
size = verts.size;
|
|
}
|
|
num = glyphWidth;
|
|
num2 += finalLineHeight;
|
|
}
|
|
else
|
|
{
|
|
num += glyphWidth;
|
|
}
|
|
verts.Add(new Vector3(num, 0f - num2 - num4));
|
|
indices.Add(i + 1);
|
|
prev = num5;
|
|
continue;
|
|
}
|
|
float num6 = (float)bMSymbol.advance * fontScale + finalSpacingX;
|
|
if (Mathf.RoundToInt(num + num6) > regionWidth)
|
|
{
|
|
if (num == 0f)
|
|
{
|
|
return;
|
|
}
|
|
if (alignment != Alignment.Left && size < verts.size)
|
|
{
|
|
Align(verts, size, num - finalSpacingX, 1);
|
|
size = verts.size;
|
|
}
|
|
num = num6;
|
|
num2 += finalLineHeight;
|
|
}
|
|
else
|
|
{
|
|
num += num6;
|
|
}
|
|
verts.Add(new Vector3(num, 0f - num2 - num4));
|
|
indices.Add(i + 1);
|
|
i += bMSymbol.sequence.Length - 1;
|
|
prev = 0;
|
|
}
|
|
if (alignment != Alignment.Left && size < verts.size)
|
|
{
|
|
Align(verts, size, num - finalSpacingX, 1);
|
|
}
|
|
}
|
|
|
|
public static void PrintExactCharacterPositions(string text, BetterList<Vector3> verts, BetterList<int> indices)
|
|
{
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
text = " ";
|
|
}
|
|
Prepare(text);
|
|
float num = (float)fontSize * fontScale;
|
|
float num2 = 0f;
|
|
float num3 = 0f;
|
|
float num4 = 0f;
|
|
int length = text.Length;
|
|
int size = verts.size;
|
|
int num5 = 0;
|
|
int prev = 0;
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
num5 = text[i];
|
|
if (num5 == 10)
|
|
{
|
|
if (num2 > num4)
|
|
{
|
|
num4 = num2;
|
|
}
|
|
if (alignment != Alignment.Left)
|
|
{
|
|
Align(verts, size, num2 - finalSpacingX, 2);
|
|
size = verts.size;
|
|
}
|
|
num2 = 0f;
|
|
num3 += finalLineHeight;
|
|
prev = 0;
|
|
continue;
|
|
}
|
|
if (num5 < 32)
|
|
{
|
|
prev = 0;
|
|
continue;
|
|
}
|
|
if (encoding && ParseSymbol(text, ref i))
|
|
{
|
|
i--;
|
|
continue;
|
|
}
|
|
BMSymbol bMSymbol = (useSymbols ? GetSymbol(text, i, length) : null);
|
|
if (bMSymbol == null)
|
|
{
|
|
float glyphWidth = GetGlyphWidth(num5, prev);
|
|
if (glyphWidth == 0f)
|
|
{
|
|
continue;
|
|
}
|
|
float num6 = glyphWidth + finalSpacingX;
|
|
if (Mathf.RoundToInt(num2 + num6) > regionWidth)
|
|
{
|
|
if (num2 == 0f)
|
|
{
|
|
return;
|
|
}
|
|
if (alignment != Alignment.Left && size < verts.size)
|
|
{
|
|
Align(verts, size, num2 - finalSpacingX, 2);
|
|
size = verts.size;
|
|
}
|
|
num2 = 0f;
|
|
num3 += finalLineHeight;
|
|
prev = 0;
|
|
i--;
|
|
}
|
|
else
|
|
{
|
|
indices.Add(i);
|
|
verts.Add(new Vector3(num2, 0f - num3 - num));
|
|
verts.Add(new Vector3(num2 + num6, 0f - num3));
|
|
prev = num5;
|
|
num2 += num6;
|
|
}
|
|
continue;
|
|
}
|
|
float num7 = (float)bMSymbol.advance * fontScale + finalSpacingX;
|
|
if (Mathf.RoundToInt(num2 + num7) > regionWidth)
|
|
{
|
|
if (num2 == 0f)
|
|
{
|
|
return;
|
|
}
|
|
if (alignment != Alignment.Left && size < verts.size)
|
|
{
|
|
Align(verts, size, num2 - finalSpacingX, 2);
|
|
size = verts.size;
|
|
}
|
|
num2 = 0f;
|
|
num3 += finalLineHeight;
|
|
prev = 0;
|
|
i--;
|
|
}
|
|
else
|
|
{
|
|
indices.Add(i);
|
|
verts.Add(new Vector3(num2, 0f - num3 - num));
|
|
verts.Add(new Vector3(num2 + num7, 0f - num3));
|
|
i += bMSymbol.sequence.Length - 1;
|
|
num2 += num7;
|
|
prev = 0;
|
|
}
|
|
}
|
|
if (alignment != Alignment.Left && size < verts.size)
|
|
{
|
|
Align(verts, size, num2 - finalSpacingX, 2);
|
|
}
|
|
}
|
|
|
|
public static void PrintCaretAndSelection(string text, int start, int end, BetterList<Vector3> caret, BetterList<Vector3> highlight)
|
|
{
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
text = " ";
|
|
}
|
|
Prepare(text);
|
|
int num = end;
|
|
if (start > end)
|
|
{
|
|
end = start;
|
|
start = num;
|
|
}
|
|
float num2 = 0f;
|
|
float num3 = 0f;
|
|
float num4 = 0f;
|
|
float num5 = (float)fontSize * fontScale;
|
|
int indexOffset = caret?.size ?? 0;
|
|
int num6 = highlight?.size ?? 0;
|
|
int length = text.Length;
|
|
int i = 0;
|
|
int num7 = 0;
|
|
int prev = 0;
|
|
bool flag = false;
|
|
bool flag2 = false;
|
|
Vector2 vector = Vector2.zero;
|
|
Vector2 vector2 = Vector2.zero;
|
|
for (; i < length; i++)
|
|
{
|
|
if (caret != null && !flag2 && num <= i)
|
|
{
|
|
flag2 = true;
|
|
caret.Add(new Vector3(num2 - 1f, 0f - num3 - num5));
|
|
caret.Add(new Vector3(num2 - 1f, 0f - num3));
|
|
caret.Add(new Vector3(num2 + 1f, 0f - num3));
|
|
caret.Add(new Vector3(num2 + 1f, 0f - num3 - num5));
|
|
}
|
|
num7 = text[i];
|
|
if (num7 == 10)
|
|
{
|
|
if (num2 > num4)
|
|
{
|
|
num4 = num2;
|
|
}
|
|
if (caret != null && flag2)
|
|
{
|
|
if (alignment != Alignment.Left)
|
|
{
|
|
Align(caret, indexOffset, num2 - finalSpacingX);
|
|
}
|
|
caret = null;
|
|
}
|
|
if (highlight != null)
|
|
{
|
|
if (flag)
|
|
{
|
|
flag = false;
|
|
highlight.Add(vector2);
|
|
highlight.Add(vector);
|
|
}
|
|
else if (start <= i && end > i)
|
|
{
|
|
highlight.Add(new Vector3(num2, 0f - num3 - num5));
|
|
highlight.Add(new Vector3(num2, 0f - num3));
|
|
highlight.Add(new Vector3(num2 + 2f, 0f - num3));
|
|
highlight.Add(new Vector3(num2 + 2f, 0f - num3 - num5));
|
|
}
|
|
if (alignment != Alignment.Left && num6 < highlight.size)
|
|
{
|
|
Align(highlight, num6, num2 - finalSpacingX);
|
|
num6 = highlight.size;
|
|
}
|
|
}
|
|
num2 = 0f;
|
|
num3 += finalLineHeight;
|
|
prev = 0;
|
|
continue;
|
|
}
|
|
if (num7 < 32)
|
|
{
|
|
prev = 0;
|
|
continue;
|
|
}
|
|
if (encoding && ParseSymbol(text, ref i))
|
|
{
|
|
i--;
|
|
continue;
|
|
}
|
|
BMSymbol bMSymbol = (useSymbols ? GetSymbol(text, i, length) : null);
|
|
float num8 = ((bMSymbol != null) ? ((float)bMSymbol.advance * fontScale) : GetGlyphWidth(num7, prev));
|
|
if (num8 == 0f)
|
|
{
|
|
continue;
|
|
}
|
|
float num9 = num2;
|
|
float num10 = num2 + num8;
|
|
float num11 = 0f - num3 - num5;
|
|
float num12 = 0f - num3;
|
|
if (Mathf.RoundToInt(num10 + finalSpacingX) > regionWidth)
|
|
{
|
|
if (num2 == 0f)
|
|
{
|
|
return;
|
|
}
|
|
if (num2 > num4)
|
|
{
|
|
num4 = num2;
|
|
}
|
|
if (caret != null && flag2)
|
|
{
|
|
if (alignment != Alignment.Left)
|
|
{
|
|
Align(caret, indexOffset, num2 - finalSpacingX);
|
|
}
|
|
caret = null;
|
|
}
|
|
if (highlight != null)
|
|
{
|
|
if (flag)
|
|
{
|
|
flag = false;
|
|
highlight.Add(vector2);
|
|
highlight.Add(vector);
|
|
}
|
|
else if (start <= i && end > i)
|
|
{
|
|
highlight.Add(new Vector3(num2, 0f - num3 - num5));
|
|
highlight.Add(new Vector3(num2, 0f - num3));
|
|
highlight.Add(new Vector3(num2 + 2f, 0f - num3));
|
|
highlight.Add(new Vector3(num2 + 2f, 0f - num3 - num5));
|
|
}
|
|
if (alignment != Alignment.Left && num6 < highlight.size)
|
|
{
|
|
Align(highlight, num6, num2 - finalSpacingX);
|
|
num6 = highlight.size;
|
|
}
|
|
}
|
|
num9 -= num2;
|
|
num10 -= num2;
|
|
num11 -= finalLineHeight;
|
|
num12 -= finalLineHeight;
|
|
num2 = 0f;
|
|
num3 += finalLineHeight;
|
|
}
|
|
num2 += num8 + finalSpacingX;
|
|
if (highlight != null)
|
|
{
|
|
if (start > i || end <= i)
|
|
{
|
|
if (flag)
|
|
{
|
|
flag = false;
|
|
highlight.Add(vector2);
|
|
highlight.Add(vector);
|
|
}
|
|
}
|
|
else if (!flag)
|
|
{
|
|
flag = true;
|
|
highlight.Add(new Vector3(num9, num11));
|
|
highlight.Add(new Vector3(num9, num12));
|
|
}
|
|
}
|
|
vector = new Vector2(num10, num11);
|
|
vector2 = new Vector2(num10, num12);
|
|
prev = num7;
|
|
}
|
|
if (caret != null)
|
|
{
|
|
if (!flag2)
|
|
{
|
|
caret.Add(new Vector3(num2 - 1f, 0f - num3 - num5));
|
|
caret.Add(new Vector3(num2 - 1f, 0f - num3));
|
|
caret.Add(new Vector3(num2 + 1f, 0f - num3));
|
|
caret.Add(new Vector3(num2 + 1f, 0f - num3 - num5));
|
|
}
|
|
if (alignment != Alignment.Left)
|
|
{
|
|
Align(caret, indexOffset, num2 - finalSpacingX);
|
|
}
|
|
}
|
|
if (highlight != null)
|
|
{
|
|
if (flag)
|
|
{
|
|
highlight.Add(vector2);
|
|
highlight.Add(vector);
|
|
}
|
|
else if (start < i && end == i)
|
|
{
|
|
highlight.Add(new Vector3(num2, 0f - num3 - num5));
|
|
highlight.Add(new Vector3(num2, 0f - num3));
|
|
highlight.Add(new Vector3(num2 + 2f, 0f - num3));
|
|
highlight.Add(new Vector3(num2 + 2f, 0f - num3 - num5));
|
|
}
|
|
if (alignment != Alignment.Left && num6 < highlight.size)
|
|
{
|
|
Align(highlight, num6, num2 - finalSpacingX);
|
|
}
|
|
}
|
|
}
|
|
}
|