Moves TextFieldWidget defaults to metrics.yaml.

This commit is contained in:
reaperrr
2013-11-19 01:42:16 +01:00
parent e73b3705c6
commit f9c2e90c6b
5 changed files with 19 additions and 7 deletions

View File

@@ -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,
@@ -34,9 +34,9 @@ namespace OpenRA.Widgets
public int CursorPosition { get; set; }
public Func<bool> IsDisabled = () => false;
public Color TextColor = Color.White;
public Color DisabledColor = Color.Gray;
public string Font = "Regular";
public string Font = ChromeMetrics.Get<string>("TextfieldFont");
public Color TextColor = ChromeMetrics.Get<Color>("TextfieldColor");
public Color TextColorDisabled = ChromeMetrics.Get<Color>("TextfieldColorDisabled");
public TextFieldWidget() {}
protected TextFieldWidget(TextFieldWidget widget)
@@ -46,7 +46,7 @@ namespace OpenRA.Widgets
MaxLength = widget.MaxLength;
Font = widget.Font;
TextColor = widget.TextColor;
DisabledColor = widget.DisabledColor;
TextColorDisabled = widget.TextColorDisabled;
VisualHeight = widget.VisualHeight;
}
@@ -215,11 +215,11 @@ namespace OpenRA.Widgets
Bounds.Width - LeftMargin - RightMargin, Bounds.Bottom));
}
var color = disabled ? DisabledColor : TextColor;
var color = disabled ? TextColorDisabled : TextColor;
font.DrawText(apparentText, textPos, color);
if (showCursor && HasKeyboardFocus)
font.DrawText("|", new float2(textPos.X + cursorPosition.X - 2, textPos.Y), Color.White);
font.DrawText("|", new float2(textPos.X + cursorPosition.X - 2, textPos.Y), TextColor);
if (textSize.X > Bounds.Width - LeftMargin - RightMargin)
Game.Renderer.DisableScissor();