-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBMFont.cs
104 lines (90 loc) · 2.2 KB
/
BMFont.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Decompiled with JetBrains decompiler
// Type: BMFont
// Assembly: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
using System;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class BMFont
{
[HideInInspector]
[SerializeField]
private int mBase;
private Dictionary<int, BMGlyph> mDict = new Dictionary<int, BMGlyph>();
[HideInInspector]
[SerializeField]
private int mHeight;
[HideInInspector]
[SerializeField]
private List<BMGlyph> mSaved = new List<BMGlyph>();
[HideInInspector]
[SerializeField]
private int mSize;
[HideInInspector]
[SerializeField]
private string mSpriteName;
[HideInInspector]
[SerializeField]
private int mWidth;
public void Clear()
{
this.mDict.Clear();
this.mSaved.Clear();
}
public BMGlyph GetGlyph(int index) => this.GetGlyph(index, false);
public BMGlyph GetGlyph(int index, bool createIfMissing)
{
BMGlyph glyph = (BMGlyph) null;
if (this.mDict.Count == 0)
{
int index1 = 0;
for (int count = this.mSaved.Count; index1 < count; ++index1)
{
BMGlyph bmGlyph = this.mSaved[index1];
this.mDict.Add(bmGlyph.index, bmGlyph);
}
}
if (!this.mDict.TryGetValue(index, out glyph) & createIfMissing)
{
glyph = new BMGlyph() { index = index };
this.mSaved.Add(glyph);
this.mDict.Add(index, glyph);
}
return glyph;
}
public void Trim(int xMin, int yMin, int xMax, int yMax)
{
if (!this.isValid)
return;
int index = 0;
for (int count = this.mSaved.Count; index < count; ++index)
this.mSaved[index]?.Trim(xMin, yMin, xMax, yMax);
}
public int baseOffset
{
get => this.mBase;
set => this.mBase = value;
}
public int charSize
{
get => this.mSize;
set => this.mSize = value;
}
public int glyphCount => this.isValid ? this.mSaved.Count : 0;
public bool isValid => this.mSaved.Count > 0;
public string spriteName
{
get => this.mSpriteName;
set => this.mSpriteName = value;
}
public int texHeight
{
get => this.mHeight;
set => this.mHeight = value;
}
public int texWidth
{
get => this.mWidth;
set => this.mWidth = value;
}
}