tidy silly Enum.GetValues type nonsense

This commit is contained in:
Chris Forbes
2011-12-31 11:02:38 +13:00
parent 004c59d273
commit 809b716d0d
4 changed files with 5 additions and 4 deletions

View File

@@ -208,5 +208,6 @@ namespace OpenRA
public static class Enum<T>
{
public static T Parse(string s) { return (T)Enum.Parse(typeof(T), s); }
public static T[] GetValues() { return (T[])Enum.GetValues(typeof(T)); }
}
}

View File

@@ -9,9 +9,9 @@
#endregion
using System.Linq;
using OpenRA.Traits;
using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{

View File

@@ -122,7 +122,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
void ShowDropDown(Player p, DropDownButtonWidget dropdown)
{
var stances = Enum.GetValues(typeof(Stance)).OfType<Stance>();
var stances = Enum<Stance>.GetValues();
Func<Stance, ScrollItemWidget, ScrollItemWidget> setupItem = (s, template) =>
{
var item = ScrollItemWidget.Setup(template,

View File

@@ -132,7 +132,7 @@ namespace OpenRA.Mods.RA.Widgets
if (actor.First == null)
return true;
var stances = (UnitStance[])Enum.GetValues(typeof(UnitStance));
var stances = Enum<UnitStance>.GetValues();
var nextStance = stances.Concat(stances).SkipWhile(s => s != actor.Second.predictedStance).Skip(1).First();