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 #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 * 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 * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
@@ -34,9 +34,9 @@ namespace OpenRA.Widgets
public int CursorPosition { get; set; } public int CursorPosition { get; set; }
public Func<bool> IsDisabled = () => false; public Func<bool> IsDisabled = () => false;
public Color TextColor = Color.White; public string Font = ChromeMetrics.Get<string>("TextfieldFont");
public Color DisabledColor = Color.Gray; public Color TextColor = ChromeMetrics.Get<Color>("TextfieldColor");
public string Font = "Regular"; public Color TextColorDisabled = ChromeMetrics.Get<Color>("TextfieldColorDisabled");
public TextFieldWidget() {} public TextFieldWidget() {}
protected TextFieldWidget(TextFieldWidget widget) protected TextFieldWidget(TextFieldWidget widget)
@@ -46,7 +46,7 @@ namespace OpenRA.Widgets
MaxLength = widget.MaxLength; MaxLength = widget.MaxLength;
Font = widget.Font; Font = widget.Font;
TextColor = widget.TextColor; TextColor = widget.TextColor;
DisabledColor = widget.DisabledColor; TextColorDisabled = widget.TextColorDisabled;
VisualHeight = widget.VisualHeight; VisualHeight = widget.VisualHeight;
} }
@@ -215,11 +215,11 @@ namespace OpenRA.Widgets
Bounds.Width - LeftMargin - RightMargin, Bounds.Bottom)); Bounds.Width - LeftMargin - RightMargin, Bounds.Bottom));
} }
var color = disabled ? DisabledColor : TextColor; var color = disabled ? TextColorDisabled : TextColor;
font.DrawText(apparentText, textPos, color); font.DrawText(apparentText, textPos, color);
if (showCursor && HasKeyboardFocus) 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) if (textSize.X > Bounds.Width - LeftMargin - RightMargin)
Game.Renderer.DisableScissor(); Game.Renderer.DisableScissor();

View File

@@ -11,6 +11,9 @@ Metrics:
HotkeyFont: Regular HotkeyFont: Regular
HotkeyColor: 255,255,255 HotkeyColor: 255,255,255
HotkeyColorDisabled: 128,128,128 HotkeyColorDisabled: 128,128,128
TextfieldFont: Regular
TextfieldColor: 255,255,255
TextfieldColorDisabled: 128,128,128
TextFont: Regular TextFont: Regular
TextColor: 255,255,255 TextColor: 255,255,255
TextContrast: false TextContrast: false

View File

@@ -11,6 +11,9 @@ Metrics:
HotkeyFont: Regular HotkeyFont: Regular
HotkeyColor: 255,255,255 HotkeyColor: 255,255,255
HotkeyColorDisabled: 128,128,128 HotkeyColorDisabled: 128,128,128
TextfieldFont: Regular
TextfieldColor: 255,255,255
TextfieldColorDisabled: 128,128,128
TextFont: Regular TextFont: Regular
TextColor: 255,255,255 TextColor: 255,255,255
TextContrast: false TextContrast: false

View File

@@ -11,6 +11,9 @@ Metrics:
HotkeyFont: Regular HotkeyFont: Regular
HotkeyColor: 255,255,255 HotkeyColor: 255,255,255
HotkeyColorDisabled: 128,128,128 HotkeyColorDisabled: 128,128,128
TextfieldFont: Regular
TextfieldColor: 255,255,255
TextfieldColorDisabled: 128,128,128
TextFont: Regular TextFont: Regular
TextColor: 255,255,255 TextColor: 255,255,255
TextContrast: false TextContrast: false

View File

@@ -11,6 +11,9 @@ Metrics:
HotkeyFont: Regular HotkeyFont: Regular
HotkeyColor: 255,255,255 HotkeyColor: 255,255,255
HotkeyColorDisabled: 128,128,128 HotkeyColorDisabled: 128,128,128
TextfieldFont: Regular
TextfieldColor: 255,255,255
TextfieldColorDisabled: 128,128,128
TextFont: Regular TextFont: Regular
TextColor: 255,255,255 TextColor: 255,255,255
TextContrast: false TextContrast: false