StyleCop clean Map/*.cs files

This commit is contained in:
Matthias Mailänder
2013-08-25 14:30:00 +02:00
parent ae00cb3adf
commit ba13c1d982
16 changed files with 68 additions and 72 deletions

View File

@@ -23,14 +23,14 @@ namespace OpenRA.FileFormats
Dictionary<ushort, List<byte[]>> templates;
public Size TileSize;
List<byte[]> LoadTemplate(string filename, string[] exts, Cache<string, R8Reader> r8Cache, int[] frames)
List<byte[]> LoadTemplate(string filename, string[] exts, Cache<string, R8Reader> r8cache, int[] frames)
{
if (exts.Contains(".R8") && FileSystem.Exists(filename+".R8"))
if (exts.Contains(".R8") && FileSystem.Exists(filename + ".R8"))
{
var data = new List<byte[]>();
foreach (var f in frames)
data.Add(f >= 0 ? r8Cache[filename][f].Image : null);
data.Add(f >= 0 ? r8cache[filename][f].Image : null);
return data;
}
@@ -45,9 +45,9 @@ namespace OpenRA.FileFormats
this.TileSize = tileSize;
templates = new Dictionary<ushort, List<byte[]>>();
var r8Cache = new Cache<string, R8Reader>(s => new R8Reader(FileSystem.OpenWithExts(s, ".R8")));
var r8cache = new Cache<string, R8Reader>(s => new R8Reader(FileSystem.OpenWithExts(s, ".R8")));
foreach (var t in TileSet.Templates)
templates.Add(t.Key, LoadTemplate(t.Value.Image, tileset.Extensions, r8Cache, t.Value.Frames));
templates.Add(t.Key, LoadTemplate(t.Value.Image, tileset.Extensions, r8cache, t.Value.Frames));
}
public Bitmap RenderTemplate(ushort id, Palette p)

View File

@@ -8,8 +8,8 @@
*/
#endregion
using System.Drawing;
using System;
using System.Drawing;
namespace OpenRA.FileFormats
{
@@ -30,8 +30,8 @@ namespace OpenRA.FileFormats
// ColorRamp naming retained for backward compatibility
public bool LockColor = false;
public HSLColor ColorRamp = new HSLColor(0,0,238);
public HSLColor Color { get { return ColorRamp; } set { ColorRamp = value; }}
public HSLColor ColorRamp = new HSLColor(0, 0, 238);
public HSLColor Color { get { return ColorRamp; } set { ColorRamp = value; } }
public bool LockSpawn = false;
public int Spawn = 0;
@@ -39,10 +39,10 @@ namespace OpenRA.FileFormats
public bool LockTeam = false;
public int Team = 0;
public string[] Allies = {};
public string[] Enemies = {};
public string[] Allies = { };
public string[] Enemies = { };
public PlayerReference() {}
public PlayerReference() { }
public PlayerReference(MiniYaml my) { FieldLoader.Load(this, my); }
public override string ToString() { return Name; }

View File

@@ -16,7 +16,7 @@ namespace OpenRA.FileFormats
public readonly int2 Location;
public readonly int Depth;
public SmudgeReference( string type, int2 location, int depth )
public SmudgeReference(string type, int2 location, int depth)
{
Type = type;
Location = location;

View File

@@ -12,15 +12,15 @@ namespace OpenRA.FileFormats
{
public struct TileReference<T, U>
{
public T type;
public U index;
public T Type;
public U Index;
public TileReference(T t, U i)
{
type = t;
index = i;
Type = t;
Index = i;
}
public override int GetHashCode() { return type.GetHashCode() ^ index.GetHashCode(); }
public override int GetHashCode() { return Type.GetHashCode() ^ Index.GetHashCode(); }
}
}

View File

@@ -25,7 +25,7 @@ namespace OpenRA.FileFormats
public Color Color;
public string CustomCursor;
public TerrainTypeInfo() {}
public TerrainTypeInfo() { }
public TerrainTypeInfo(MiniYaml my) { FieldLoader.Load(this, my); }
public MiniYaml Save() { return FieldSaver.Save(this); }
@@ -43,7 +43,7 @@ namespace OpenRA.FileFormats
[FieldLoader.LoadUsing("LoadTiles")]
public Dictionary<byte, string> Tiles = new Dictionary<byte, string>();
public TileTemplate() {}
public TileTemplate() { }
public TileTemplate(MiniYaml my) { FieldLoader.Load(this, my); }
static object LoadTiles(MiniYaml y)
@@ -87,9 +87,9 @@ namespace OpenRA.FileFormats
public Dictionary<ushort, TileTemplate> Templates = new Dictionary<ushort, TileTemplate>();
public string[] EditorTemplateOrder;
static readonly string[] fields = {"Name", "TileSize", "Id", "SheetSize", "Palette", "Extensions"};
static readonly string[] Fields = { "Name", "TileSize", "Id", "SheetSize", "Palette", "Extensions" };
public TileSet() {}
public TileSet() { }
public TileSet(string filepath)
{
@@ -112,9 +112,9 @@ namespace OpenRA.FileFormats
var root = new List<MiniYamlNode>();
var gen = new List<MiniYamlNode>();
foreach (var field in fields)
foreach (var field in Fields)
{
FieldInfo f = this.GetType().GetField(field);
var f = this.GetType().GetField(field);
if (f.GetValue(this) == null)
continue;
@@ -123,23 +123,19 @@ namespace OpenRA.FileFormats
root.Add(new MiniYamlNode("General", null, gen));
root.Add(new MiniYamlNode( "Terrain", null,
Terrain.Select(t => new MiniYamlNode(
"TerrainType@{0}".F(t.Value.Type),
t.Value.Save())).ToList()));
root.Add(new MiniYamlNode("Terrain", null,
Terrain.Select(t => new MiniYamlNode("TerrainType@{0}".F(t.Value.Type), t.Value.Save())).ToList()));
root.Add(new MiniYamlNode("Templates", null,
Templates.Select(t => new MiniYamlNode(
"Template@{0}".F(t.Value.Id),
t.Value.Save())).ToList()));
Templates.Select(t => new MiniYamlNode("Template@{0}".F(t.Value.Id), t.Value.Save())).ToList()));
root.WriteToFile(filepath);
}
public string GetTerrainType(TileReference<ushort, byte> r)
{
var tt = Templates[r.type].Tiles;
var tt = Templates[r.Type].Tiles;
string ret;
if (!tt.TryGetValue(r.index, out ret))
if (!tt.TryGetValue(r.Index, out ret))
return "Clear"; // Default walkable
return ret;