Allow SheetBuilder to generate 1/2/4 channel sheets.
This makes the SpriteFont RBGA sprite hack explicit, and adds a DualIndexed option to be used by the voxel renderer.
This commit is contained in:
@@ -31,8 +31,10 @@ namespace OpenRA.Graphics
|
||||
glyphs = new Cache<Pair<char, Color>, GlyphInfo>(CreateGlyph,
|
||||
Pair<char,Color>.EqualityComparer);
|
||||
|
||||
// setup a 1-channel SheetBuilder for our private use
|
||||
if (builder == null) builder = new SheetBuilder(TextureChannel.Alpha);
|
||||
// setup a SheetBuilder for our private use
|
||||
// TODO: SheetBuilder state is leaked between mod switches
|
||||
if (builder == null)
|
||||
builder = new SheetBuilder(SheetType.BGRA);
|
||||
|
||||
PrecacheColor(Color.White);
|
||||
PrecacheColor(Color.Red);
|
||||
@@ -46,7 +48,7 @@ namespace OpenRA.Graphics
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public void DrawText (string text, float2 location, Color c)
|
||||
public void DrawText(string text, float2 location, Color c)
|
||||
{
|
||||
location.Y += size; // baseline vs top
|
||||
|
||||
@@ -84,7 +86,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
public int2 Measure(string text)
|
||||
{
|
||||
return new int2((int)text.Split( '\n' ).Max( s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance)), text.Split('\n').Count()*size);
|
||||
return new int2((int)text.Split('\n').Max(s => s.Sum(a => glyphs[Pair.New(a, Color.White)].Advance)), text.Split('\n').Count()*size);
|
||||
}
|
||||
|
||||
Cache<Pair<char,Color>, GlyphInfo> glyphs;
|
||||
|
||||
Reference in New Issue
Block a user