TechTree now works in lower-case, the same as the rest of the game.
This commit is contained in:
@@ -19,6 +19,7 @@ namespace OpenRa.Game.GameRules
|
|||||||
}
|
}
|
||||||
|
|
||||||
public readonly string Name;
|
public readonly string Name;
|
||||||
|
public readonly string Description = "";
|
||||||
|
|
||||||
public readonly int Ammo = -1;
|
public readonly int Ammo = -1;
|
||||||
public readonly ArmorType Armor = ArmorType.none;
|
public readonly ArmorType Armor = ArmorType.none;
|
||||||
|
|||||||
2
OpenRa.Game/MainWindow.cs
Normal file → Executable file
2
OpenRa.Game/MainWindow.cs
Normal file → Executable file
@@ -62,7 +62,7 @@ using System.Runtime.InteropServices;
|
|||||||
game.world.Add( jeep );
|
game.world.Add( jeep );
|
||||||
var tank = new Actor( "3tnk", new int2( 12, 7 ), game.players[ 1 ] );
|
var tank = new Actor( "3tnk", new int2( 12, 7 ), game.players[ 1 ] );
|
||||||
game.world.Add( tank );
|
game.world.Add( tank );
|
||||||
tank.traits.Get<Traits.AttackTurreted>().target = jeep;
|
//tank.traits.Get<Traits.AttackTurreted>().target = jeep;
|
||||||
|
|
||||||
sidebar = new Sidebar(renderer, game);
|
sidebar = new Sidebar(renderer, game);
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,9 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
void LoadSprites(string filename)
|
void LoadSprites(string filename)
|
||||||
{
|
{
|
||||||
foreach (string line in Util.ReadAllLines(FileSystem.Open(filename)))
|
foreach (string l in Util.ReadAllLines(FileSystem.Open(filename)))
|
||||||
{
|
{
|
||||||
|
var line = l.ToLowerInvariant();
|
||||||
string key = line.Substring(0, line.IndexOf(','));
|
string key = line.Substring(0, line.IndexOf(','));
|
||||||
int secondComma = line.IndexOf(',', line.IndexOf(',') + 1);
|
int secondComma = line.IndexOf(',', line.IndexOf(',') + 1);
|
||||||
string group = line.Substring(secondComma + 1, line.Length - secondComma - 1);
|
string group = line.Substring(secondComma + 1, line.Length - secondComma - 1);
|
||||||
|
|||||||
45
OpenRa.Game/TechTree/Item.cs
Normal file → Executable file
45
OpenRa.Game/TechTree/Item.cs
Normal file → Executable file
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRa.FileFormats;
|
using OpenRa.FileFormats;
|
||||||
using OpenRa.Game.GameRules;
|
using OpenRa.Game.GameRules;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace OpenRa.TechTree
|
namespace OpenRa.TechTree
|
||||||
{
|
{
|
||||||
@@ -11,10 +12,10 @@ namespace OpenRa.TechTree
|
|||||||
|
|
||||||
public bool IsStructure { get { return isStructure; } }
|
public bool IsStructure { get { return isStructure; } }
|
||||||
|
|
||||||
public Item(string tag, string friendlyName, UnitInfo unitInfo, bool isStructure)
|
public Item(string tag, UnitInfo unitInfo, bool isStructure)
|
||||||
{
|
{
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.friendlyName = friendlyName;
|
this.friendlyName = unitInfo.Description;
|
||||||
this.isStructure = isStructure;
|
this.isStructure = isStructure;
|
||||||
|
|
||||||
owner = ParseOwner(unitInfo.Owner, unitInfo.DoubleOwned);
|
owner = ParseOwner(unitInfo.Owner, unitInfo.DoubleOwned);
|
||||||
@@ -40,38 +41,40 @@ namespace OpenRa.TechTree
|
|||||||
|
|
||||||
static Tuple<string[],string[]> ParsePrerequisites(string prerequisites, string tag)
|
static Tuple<string[],string[]> ParsePrerequisites(string prerequisites, string tag)
|
||||||
{
|
{
|
||||||
List<string> allied = new List<string>(prerequisites.ToUpper().Split(
|
Debug.WriteLine( tag );
|
||||||
|
List<string> allied = new List<string>(prerequisites.ToLowerInvariant().Split(
|
||||||
new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
|
new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
|
||||||
|
|
||||||
List<string> soviet = new List<string>(allied);
|
List<string> soviet = new List<string>(allied);
|
||||||
|
|
||||||
if (allied.Remove("STEK"))
|
if (allied.Remove("stek"))
|
||||||
allied.Add("ATEK");
|
allied.Add("atek");
|
||||||
|
|
||||||
if (soviet.Remove("ATEK"))
|
if (soviet.Remove("atek"))
|
||||||
soviet.Add("STEK");
|
soviet.Add("stek");
|
||||||
|
|
||||||
if (soviet.Remove("TENT"))
|
if (soviet.Remove("tent"))
|
||||||
soviet.Add("BARR");
|
soviet.Add("barr");
|
||||||
|
|
||||||
if (allied.Remove("BARR"))
|
if (allied.Remove("barr"))
|
||||||
allied.Add("TENT");
|
allied.Add("tent");
|
||||||
|
|
||||||
if ((tag.Length == 2 && tag[0] == 'E') || tag == "MEDI" || tag == "THF" || tag == "SPY")
|
// TODO: rewrite this based on "InfantryTypes" in units.ini
|
||||||
|
if ((tag.Length == 2 && tag[0] == 'e') || tag == "medi" || tag == "thf" || tag == "spy")
|
||||||
{
|
{
|
||||||
if (!allied.Contains("TENT"))
|
if (!allied.Contains("tent"))
|
||||||
allied.Add("TENT");
|
allied.Add("tent");
|
||||||
if (!soviet.Contains("BARR"))
|
if (!soviet.Contains("barr"))
|
||||||
soviet.Add("BARR");
|
soviet.Add("barr");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == "LST")
|
if (tag == "lst")
|
||||||
{
|
{
|
||||||
if (!soviet.Contains("SPEN"))
|
if (!soviet.Contains("spen"))
|
||||||
soviet.Add("SPEN");
|
soviet.Add("spen");
|
||||||
|
|
||||||
if (!allied.Contains("SYRD"))
|
if (!allied.Contains("syrd"))
|
||||||
allied.Add("SYRD");
|
allied.Add("syrd");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Tuple<string[], string[]>(
|
return new Tuple<string[], string[]>(
|
||||||
|
|||||||
@@ -54,13 +54,13 @@ namespace OpenRa.TechTree
|
|||||||
.Concat( Lines( "infantry.txt", false ) );
|
.Concat( Lines( "infantry.txt", false ) );
|
||||||
|
|
||||||
foreach (Tuple<string, string, bool> p in definitions)
|
foreach (Tuple<string, string, bool> p in definitions)
|
||||||
objects.Add(p.a, new Item(p.a, p.b, Rules.UnitInfo[p.a], p.c));
|
objects.Add(p.a.ToLowerInvariant(), new Item(p.a.ToLowerInvariant(), Rules.UnitInfo[p.a.ToLowerInvariant()], p.c));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Build(string key, bool force)
|
public bool Build(string key, bool force)
|
||||||
{
|
{
|
||||||
if( string.IsNullOrEmpty( key ) ) return false;
|
if( string.IsNullOrEmpty( key ) ) return false;
|
||||||
key = key.ToUpperInvariant();
|
key = key.ToLowerInvariant();
|
||||||
Item b = objects[ key ];
|
Item b = objects[ key ];
|
||||||
if (!force && !b.CanBuild) return false;
|
if (!force && !b.CanBuild) return false;
|
||||||
built.Add(key);
|
built.Add(key);
|
||||||
@@ -75,7 +75,7 @@ namespace OpenRa.TechTree
|
|||||||
|
|
||||||
public bool Unbuild(string key)
|
public bool Unbuild(string key)
|
||||||
{
|
{
|
||||||
key = key.ToUpperInvariant();
|
key = key.ToLowerInvariant();
|
||||||
Item b = objects[key];
|
Item b = objects[key];
|
||||||
if (!built.Contains(key)) return false;
|
if (!built.Contains(key)) return false;
|
||||||
built.Remove(key);
|
built.Remove(key);
|
||||||
|
|||||||
Reference in New Issue
Block a user