Refactor int -> TerrainType. This had a bigger footprint than i initially intended.

This commit is contained in:
Paul Chote
2010-03-21 18:46:02 +13:00
parent 5b2dbc2389
commit 15a7eed603
13 changed files with 98 additions and 95 deletions

View File

@@ -21,12 +21,12 @@
using System.Collections.Generic;
using System.IO;
using System.Drawing;
using System;
namespace OpenRA.FileFormats
{
public class TerrainColorSet
{
public readonly Dictionary<int, Color> colors = new Dictionary<int, Color>();
public readonly Dictionary<TerrainType, Color> colors = new Dictionary<TerrainType, Color>();
string NextLine( StreamReader reader )
{
@@ -51,17 +51,17 @@ namespace OpenRA.FileFormats
string line = NextLine( file );
if( line == null )
break;
string[] entries = line.Split(',');
int key = int.Parse(entries[0]);
Color val = Color.FromArgb(int.Parse(entries[1]),int.Parse(entries[2]),int.Parse(entries[3]));
string[] kv = line.Split('=');
TerrainType key = (TerrainType)Enum.Parse(typeof(TerrainType),kv[0]);
string[] entries = kv[1].Split(',');
Color val = Color.FromArgb(int.Parse(entries[0]),int.Parse(entries[1]),int.Parse(entries[2]));
colors.Add(key,val);
}
file.Close();
}
public Color ColorForTerrainType(int type)
public Color ColorForTerrainType(TerrainType type)
{
return colors[type];
}