git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1930 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -26,7 +26,7 @@ namespace OpenRa
|
||||
|
||||
public static float2 operator -(float2 a) { return new float2(-a.X, -a.Y); }
|
||||
|
||||
static float Lerp(float a, float b, float t) { return (1 - t) * a + t * b; }
|
||||
static float Lerp(float a, float b, float t) { return a + t * (b - a); }
|
||||
|
||||
public static float2 Lerp(float2 a, float2 b, float t)
|
||||
{
|
||||
|
||||
@@ -17,8 +17,15 @@ namespace OpenRa.FileFormats
|
||||
while( !reader.EndOfStream )
|
||||
{
|
||||
string line = reader.ReadLine();
|
||||
if( !ProcessEntry( line ) )
|
||||
ProcessSection( line );
|
||||
|
||||
if (line.Length == 0) continue;
|
||||
|
||||
switch (line[0])
|
||||
{
|
||||
case ';': break;
|
||||
case '[': ProcessSection(line); break;
|
||||
default: ProcessEntry(line); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +34,6 @@ namespace OpenRa.FileFormats
|
||||
|
||||
bool ProcessSection( string line )
|
||||
{
|
||||
if (string.IsNullOrEmpty(line) || line.StartsWith(";"))
|
||||
return false;
|
||||
|
||||
Match m = sectionPattern.Match( line );
|
||||
if( m == null || !m.Success )
|
||||
return false;
|
||||
@@ -43,9 +47,6 @@ namespace OpenRa.FileFormats
|
||||
|
||||
bool ProcessEntry( string line )
|
||||
{
|
||||
if (string.IsNullOrEmpty(line) || line.StartsWith(";"))
|
||||
return false;
|
||||
|
||||
Match m = entryPattern.Match( line );
|
||||
if( m == null || !m.Success )
|
||||
return false;
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace OpenRa.Game
|
||||
public readonly Sheet sheet;
|
||||
public readonly TextureChannel channel;
|
||||
public readonly RectangleF uv;
|
||||
public readonly float2 size;
|
||||
|
||||
internal Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
|
||||
{
|
||||
@@ -23,6 +24,8 @@ namespace OpenRa.Game
|
||||
(float)(bounds.Top + 0.5f) / sheet.Size.Height,
|
||||
(float)(bounds.Width) / sheet.Size.Width,
|
||||
(float)(bounds.Height) / sheet.Size.Height);
|
||||
|
||||
this.size = new float2(bounds.Size);
|
||||
}
|
||||
|
||||
public float2 MapTextureCoords(float2 p)
|
||||
@@ -31,6 +34,8 @@ namespace OpenRa.Game
|
||||
p.X > 0 ? uv.Right : uv.Left,
|
||||
p.Y > 0 ? uv.Bottom : uv.Top);
|
||||
}
|
||||
|
||||
public float2 Size { get { return size; } }
|
||||
}
|
||||
|
||||
public enum TextureChannel
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRa.Game
|
||||
public static Vertex MakeVertex(float2 o, float2 uv, Sprite r, int palette)
|
||||
{
|
||||
return new Vertex(
|
||||
float2.Lerp( o, o + new float2(r.bounds.Size), uv ),
|
||||
float2.Lerp( o, o + r.Size, uv ),
|
||||
r.MapTextureCoords(uv),
|
||||
EncodeVertexAttributes(r.channel, palette));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace OpenRa.TechTree
|
||||
{
|
||||
public class TechTree
|
||||
{
|
||||
static IniFile rules;
|
||||
static IniFile Rules { get { return rules ?? (rules = new IniFile(FileSystem.Open("rules.ini"))); } }
|
||||
|
||||
Dictionary<string, Item> objects = new Dictionary<string, Item>();
|
||||
public ICollection<string> built = new List<string>();
|
||||
|
||||
@@ -54,13 +57,12 @@ namespace OpenRa.TechTree
|
||||
|
||||
void LoadRules()
|
||||
{
|
||||
IniFile rulesFile = new IniFile(FileSystem.Open("rules.ini"));
|
||||
IEnumerable<Tuple<string, string, bool>> definitions = Concat(
|
||||
Lines("buildings.txt", true),
|
||||
Lines("units.txt", false));
|
||||
|
||||
foreach (Tuple<string, string, bool> p in definitions)
|
||||
objects.Add(p.a, new Item(p.a, p.b, rulesFile.GetSection(p.a), p.c));
|
||||
objects.Add(p.a, new Item(p.a, p.b, Rules.GetSection(p.a), p.c));
|
||||
}
|
||||
|
||||
public bool Build(string key, bool force)
|
||||
|
||||
Reference in New Issue
Block a user