Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
155 lines
2.2 KiB
C#
155 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class BMFont
|
|
{
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
private int mSize = 16;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
private int mBase;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
private int mWidth;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
private int mHeight;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
private string mSpriteName;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
private List<BMGlyph> mSaved = new List<BMGlyph>();
|
|
|
|
private Dictionary<int, BMGlyph> mDict = new Dictionary<int, BMGlyph>();
|
|
|
|
public bool isValid => mSaved.Count > 0;
|
|
|
|
public int charSize
|
|
{
|
|
get
|
|
{
|
|
return mSize;
|
|
}
|
|
set
|
|
{
|
|
mSize = value;
|
|
}
|
|
}
|
|
|
|
public int baseOffset
|
|
{
|
|
get
|
|
{
|
|
return mBase;
|
|
}
|
|
set
|
|
{
|
|
mBase = value;
|
|
}
|
|
}
|
|
|
|
public int texWidth
|
|
{
|
|
get
|
|
{
|
|
return mWidth;
|
|
}
|
|
set
|
|
{
|
|
mWidth = value;
|
|
}
|
|
}
|
|
|
|
public int texHeight
|
|
{
|
|
get
|
|
{
|
|
return mHeight;
|
|
}
|
|
set
|
|
{
|
|
mHeight = value;
|
|
}
|
|
}
|
|
|
|
public int glyphCount
|
|
{
|
|
get
|
|
{
|
|
if (!isValid)
|
|
{
|
|
return 0;
|
|
}
|
|
return mSaved.Count;
|
|
}
|
|
}
|
|
|
|
public string spriteName
|
|
{
|
|
get
|
|
{
|
|
return mSpriteName;
|
|
}
|
|
set
|
|
{
|
|
mSpriteName = value;
|
|
}
|
|
}
|
|
|
|
public List<BMGlyph> glyphs => mSaved;
|
|
|
|
public BMGlyph GetGlyph(int index, bool createIfMissing)
|
|
{
|
|
BMGlyph value = null;
|
|
if (mDict.Count == 0)
|
|
{
|
|
int i = 0;
|
|
for (int count = mSaved.Count; i < count; i++)
|
|
{
|
|
BMGlyph bMGlyph = mSaved[i];
|
|
mDict.Add(bMGlyph.index, bMGlyph);
|
|
}
|
|
}
|
|
if (!mDict.TryGetValue(index, out value) && createIfMissing)
|
|
{
|
|
value = new BMGlyph();
|
|
value.index = index;
|
|
mSaved.Add(value);
|
|
mDict.Add(index, value);
|
|
}
|
|
return value;
|
|
}
|
|
|
|
public BMGlyph GetGlyph(int index)
|
|
{
|
|
return GetGlyph(index, createIfMissing: false);
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
mDict.Clear();
|
|
mSaved.Clear();
|
|
}
|
|
|
|
public void Trim(int xMin, int yMin, int xMax, int yMax)
|
|
{
|
|
if (isValid)
|
|
{
|
|
int i = 0;
|
|
for (int count = mSaved.Count; i < count; i++)
|
|
{
|
|
mSaved[i]?.Trim(xMin, yMin, xMax, yMax);
|
|
}
|
|
}
|
|
}
|
|
}
|