Makes TimerWidget LabelWidget-based for better customizability. Sets defaults for LabelWidget in metrics.yaml.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -23,10 +23,10 @@ namespace OpenRA.Widgets
|
||||
[Translate] public string Text = null;
|
||||
public TextAlign Align = TextAlign.Left;
|
||||
public TextVAlign VAlign = TextVAlign.Middle;
|
||||
public string Font = "Regular";
|
||||
public Color Color = Color.White;
|
||||
public bool Contrast = false;
|
||||
public Color ContrastColor = Color.Black;
|
||||
public string Font = ChromeMetrics.Get<string>("TextFont");
|
||||
public Color TextColor = ChromeMetrics.Get<Color>("TextColor");
|
||||
public bool Contrast = ChromeMetrics.Get<bool>("TextContrast");
|
||||
public Color ContrastColor = ChromeMetrics.Get<Color>("TextContrastColor");
|
||||
public bool WordWrap = false;
|
||||
public Func<string> GetText;
|
||||
public Func<Color> GetColor;
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Widgets
|
||||
public LabelWidget()
|
||||
{
|
||||
GetText = () => Text;
|
||||
GetColor = () => Color;
|
||||
GetColor = () => TextColor;
|
||||
GetContrastColor = () => ContrastColor;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Widgets
|
||||
Text = other.Text;
|
||||
Align = other.Align;
|
||||
Font = other.Font;
|
||||
Color = other.Color;
|
||||
TextColor = other.TextColor;
|
||||
Contrast = other.Contrast;
|
||||
ContrastColor = other.ContrastColor;
|
||||
WordWrap = other.WordWrap;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -8,20 +8,28 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Widgets
|
||||
{
|
||||
public class TimerWidget : Widget
|
||||
public class TimerWidget : LabelWidget
|
||||
{
|
||||
public override void Draw()
|
||||
{
|
||||
var font = Game.Renderer.Fonts["Title"];
|
||||
SpriteFont font = Game.Renderer.Fonts[Font];
|
||||
var rb = RenderBounds;
|
||||
var color = GetColor();
|
||||
var contrast = GetContrastColor();
|
||||
|
||||
var s = WidgetUtils.FormatTime(Game.LocalTick) + (Game.orderManager.world.Paused?" (paused)":"");
|
||||
var pos = new float2(rb.Left - font.Measure(s).X / 2, rb.Top);
|
||||
font.DrawTextWithContrast(s, pos, Color.White, Color.Black, 1);
|
||||
if (Contrast)
|
||||
font.DrawTextWithContrast(s, pos, color, contrast, 1);
|
||||
else
|
||||
font.DrawText(s, pos, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user