diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs index 96e41eea7b..32a9672f74 100644 --- a/OpenRA.Game/Widgets/ButtonWidget.cs +++ b/OpenRA.Game/Widgets/ButtonWidget.cs @@ -20,8 +20,8 @@ namespace OpenRA.Widgets public string Key = null; public string Text = ""; public bool Depressed = false; - public int VisualHeight = ChromeMetrics.GetInt("ButtonDepth"); - public string Font = ChromeMetrics.GetString("ButtonFont"); + public int VisualHeight = ChromeMetrics.Get("ButtonDepth"); + public string Font = ChromeMetrics.Get("ButtonFont"); public Func GetText; public Func IsDisabled = () => false; public Action OnClick = () => {}; @@ -128,4 +128,4 @@ namespace OpenRA.Widgets WidgetUtils.DrawPanel(baseName + state, rect); } } -} \ No newline at end of file +} diff --git a/OpenRA.Game/Widgets/CheckboxWidget.cs b/OpenRA.Game/Widgets/CheckboxWidget.cs index e68d733705..2968c63e4d 100644 --- a/OpenRA.Game/Widgets/CheckboxWidget.cs +++ b/OpenRA.Game/Widgets/CheckboxWidget.cs @@ -19,7 +19,7 @@ namespace OpenRA.Widgets { public Func IsChecked = () => false; public int BaseLine = 1; - public bool HasPressedState = ChromeMetrics.GetBool("CheckboxPressedState"); + public bool HasPressedState = ChromeMetrics.Get("CheckboxPressedState"); public CheckboxWidget() : base() @@ -56,4 +56,4 @@ namespace OpenRA.Widgets public override Widget Clone() { return new CheckboxWidget(this); } } -} \ No newline at end of file +} diff --git a/OpenRA.Game/Widgets/ChromeMetrics.cs b/OpenRA.Game/Widgets/ChromeMetrics.cs index c0b9df3ab5..d39ea07457 100644 --- a/OpenRA.Game/Widgets/ChromeMetrics.cs +++ b/OpenRA.Game/Widgets/ChromeMetrics.cs @@ -30,19 +30,9 @@ namespace OpenRA.Widgets data[n.Key] = n.Value.Value; } - public static string GetString(string key) + public static T Get(string key) { - return data[key]; - } - - public static int GetInt(string key) - { - return int.Parse(data[key]); - } - - public static bool GetBool(string key) - { - return bool.Parse(data[key]); + return (T)FieldLoader.GetValue( key, typeof(T), data[key] ); } } } diff --git a/OpenRA.Game/Widgets/ScrollPanelWidget.cs b/OpenRA.Game/Widgets/ScrollPanelWidget.cs index 0db97d52bf..e4a1f05391 100644 --- a/OpenRA.Game/Widgets/ScrollPanelWidget.cs +++ b/OpenRA.Game/Widgets/ScrollPanelWidget.cs @@ -19,7 +19,7 @@ namespace OpenRA.Widgets public int ScrollbarWidth = 24; public float ScrollVelocity = 4f; public int ItemSpacing = 2; - public int ButtonDepth = ChromeMetrics.GetInt("ButtonDepth"); + public int ButtonDepth = ChromeMetrics.Get("ButtonDepth"); public string Background = "scrollpanel-bg"; public int ContentHeight = 0; protected float ListOffset = 0; @@ -189,4 +189,4 @@ namespace OpenRA.Widgets public override Widget Clone() { return new ScrollPanelWidget(this); } } -} \ No newline at end of file +}