Allow Labels to use any defined font. Add a new font type.
This commit is contained in:
@@ -35,7 +35,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
public ITexture PaletteTexture;
|
||||
|
||||
public readonly SpriteFont RegularFont, BoldFont, TitleFont, TinyFont, TinyBoldFont;
|
||||
public readonly SpriteFont RegularFont, BoldFont, TitleFont, TinyFont, TinyBoldFont, BigBoldFont;
|
||||
|
||||
internal const int TempBufferSize = 8192;
|
||||
const int TempBufferCount = 8;
|
||||
@@ -57,6 +57,7 @@ namespace OpenRA.Graphics
|
||||
RegularFont = new SpriteFont("FreeSans.ttf", 14);
|
||||
BoldFont = new SpriteFont("FreeSansBold.ttf", 14);
|
||||
TitleFont = new SpriteFont("titles.ttf", 48);
|
||||
BigBoldFont = new SpriteFont("FreeSansBold.ttf", 24);
|
||||
TinyFont = new SpriteFont("FreeSans.ttf", 10);
|
||||
TinyBoldFont = new SpriteFont("FreeSansBold.ttf", 10);
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
public enum TextAlign { Left, Center, Right }
|
||||
public enum TextVAlign { Top, Middle, Bottom }
|
||||
public enum LabelFont { Regular, Bold, Title, Tiny, TinyBold, BigBold }
|
||||
|
||||
public string Text = null;
|
||||
public string Background = null;
|
||||
public TextAlign Align = TextAlign.Left;
|
||||
public TextVAlign VAlign = TextVAlign.Middle;
|
||||
public LabelFont Font = LabelFont.Regular;
|
||||
public bool Bold = false;
|
||||
public bool Contrast = false;
|
||||
public bool WordWrap = false;
|
||||
@@ -55,7 +57,29 @@ namespace OpenRA.Widgets
|
||||
if (bg != null)
|
||||
WidgetUtils.DrawPanel(bg, RenderBounds );
|
||||
|
||||
var font = (Bold) ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
|
||||
if (Font == LabelFont.Regular && Bold)
|
||||
Font = LabelFont.Bold;
|
||||
|
||||
// TODO: Hardcoded font types are stupid
|
||||
SpriteFont font = Game.Renderer.RegularFont;
|
||||
switch (Font)
|
||||
{
|
||||
case LabelFont.Bold:
|
||||
font = Game.Renderer.BoldFont;
|
||||
break;
|
||||
case LabelFont.Tiny:
|
||||
font = Game.Renderer.TinyFont;
|
||||
break;
|
||||
case LabelFont.TinyBold:
|
||||
font = Game.Renderer.TinyBoldFont;
|
||||
break;
|
||||
case LabelFont.Title:
|
||||
font = Game.Renderer.TitleFont;
|
||||
break;
|
||||
case LabelFont.BigBold:
|
||||
font = Game.Renderer.BigBoldFont;
|
||||
break;
|
||||
}
|
||||
var text = GetText();
|
||||
if (text == null)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user