attribute individual fields, not the class

This commit is contained in:
Bob
2010-08-27 19:13:42 +12:00
committed by Chris Forbes
parent 29a77f7c5c
commit 9fedeefdbc
6 changed files with 52 additions and 71 deletions

View File

@@ -12,12 +12,11 @@ using OpenRA.FileFormats;
namespace OpenRA.GameRules
{
[FieldLoader.Foo()]
public class MusicInfo
{
public readonly string Filename = null;
public readonly string Title = null;
public readonly int Length = 0; // seconds
[FieldLoader.Load] public readonly string Filename = null;
[FieldLoader.Load] public readonly string Title = null;
[FieldLoader.Load] public readonly int Length = 0; // seconds
public MusicInfo( string key, MiniYaml value )
{

View File

@@ -15,17 +15,21 @@ using System;
namespace OpenRA.GameRules
{
[FieldLoader.Foo( "DisableVariants" )]
public class VoiceInfo
{
public readonly Dictionary<string,string[]> Variants;
public readonly Dictionary<string,string[]> Voices;
public readonly string DefaultVariant = ".aud" ;
public readonly string[] DisableVariants = { };
Func<MiniYaml, string, Dictionary<string, string[]>> Load = (y,name) => (y.NodesDict.ContainsKey(name))? y.NodesDict[name].NodesDict.ToDictionary(a => a.Key,
a => (string[])FieldLoader.GetValue( "(value)", typeof(string[]), a.Value.Value ))
: new Dictionary<string, string[]>();
[FieldLoader.Load] public readonly string[] DisableVariants = { };
static Dictionary<string, string[]> Load( MiniYaml y, string name )
{
return y.NodesDict.ContainsKey( name )
? y.NodesDict[ name ].NodesDict.ToDictionary(
a => a.Key,
a => (string[])FieldLoader.GetValue( "(value)", typeof( string[] ), a.Value.Value ) )
: new Dictionary<string, string[]>();
}
public readonly Lazy<Dictionary<string, VoicePool>> Pools;

View File

@@ -19,20 +19,19 @@ using OpenRA.FileFormats;
namespace OpenRA
{
[FieldLoader.Foo( "Selectable", "MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight" )]
public class Map
{
public IFolder Package;
public string Uid;
// Yaml map data
public bool Selectable = true;
public int MapFormat;
public string Title;
public string Description;
public string Author;
public int PlayerCount;
public string Tileset;
[FieldLoader.Load] public bool Selectable = true;
[FieldLoader.Load] public int MapFormat;
[FieldLoader.Load] public string Title;
[FieldLoader.Load] public string Description;
[FieldLoader.Load] public string Author;
[FieldLoader.Load] public int PlayerCount;
[FieldLoader.Load] public string Tileset;
public Dictionary<string, PlayerReference> Players = new Dictionary<string, PlayerReference>();
public Dictionary<string, ActorReference> Actors = new Dictionary<string, ActorReference>();
@@ -44,10 +43,10 @@ namespace OpenRA
// Binary map data
public byte TileFormat = 1;
public int2 MapSize;
[FieldLoader.Load] public int2 MapSize;
public int2 TopLeft;
public int2 BottomRight;
[FieldLoader.Load] public int2 TopLeft;
[FieldLoader.Load] public int2 BottomRight;
public TileReference<ushort, byte>[,] MapTiles;
public TileReference<byte, byte>[,] MapResources;