diff --git a/OpenRa.sln b/OpenRa.sln index 2d8e00e87b..ae77fb3c37 100644 --- a/OpenRa.sln +++ b/OpenRa.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SequenceEditor", "SequenceE EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Server", "OpenRA.Server\OpenRA.Server.csproj", "{76F621A1-3D8E-4A99-9F7E-B071EB657817}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesConverter", "RulesConverter\RulesConverter.csproj", "{BBE7C0D7-7529-4C34-9910-206866F204EF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug (x86)|Any CPU = Debug (x86)|Any CPU @@ -158,6 +160,26 @@ Global {76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|Mixed Platforms.Build.0 = Release|Any CPU {76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|Win32.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Any CPU.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Any CPU.Build.0 = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Mixed Platforms.Build.0 = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Win32.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Win32.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release (x86)|Any CPU.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release (x86)|Any CPU.Build.0 = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release (x86)|Mixed Platforms.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release (x86)|Mixed Platforms.Build.0 = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release (x86)|Win32.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release|Any CPU.Build.0 = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release|Win32.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs new file mode 100644 index 0000000000..08b6050598 --- /dev/null +++ b/RulesConverter/Program.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.FileFormats; +using System.IO; +using IjwFramework.Types; +using Yaml; + +namespace RulesConverter +{ + class Program + { + static void Main(string[] args) + { + FileSystem.Mount(new Folder("./")); + + var ruleStreams = args + .Where(a => a.EndsWith(".ini")) + .Select(a => FileSystem.Open(a)).ToArray(); + + var rules = new IniFile(ruleStreams); + + var outputFile = args.Single(a => a.EndsWith(".yaml")); + + var categoryMap = new Dictionary> + { + { "VehicleTypes", Pair.New( "DefaultVehicle", "Vehicle" ) }, + { "ShipTypes", Pair.New( "DefaultShip", "Ship" ) }, + { "PlaneTypes", Pair.New( "DefaultPlane", "Plane" ) }, + { "DefenseTypes", Pair.New( "DefaultDefense", "Defense" ) }, + { "BuildingTypes", Pair.New( "DefaultBuilding", "Building" ) }, + { "InfantryTypes", Pair.New( "DefaultInfantry", "Infantry" ) }, + }; + + using (var writer = File.CreateText(outputFile)) + { + foreach (var cat in categoryMap) + foreach (var item in rules.GetSection(cat.Key).Select(a => a.Key)) + { + var iniSection = rules.GetSection(item); + var yamlSection = new MappingNode(new Yaml.String(item), new Yaml.Null()); + var doc = new Yaml.Mapping(new[] { yamlSection }); + writer.Write(doc.Write()); + } + } + } + } +} diff --git a/RulesConverter/Properties/AssemblyInfo.cs b/RulesConverter/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..3209d221c5 --- /dev/null +++ b/RulesConverter/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("RulesConverter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RulesConverter")] +[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6b0eb619-b53d-4b2a-bbfd-585fcab99b22")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RulesConverter/RulesConverter.csproj b/RulesConverter/RulesConverter.csproj new file mode 100644 index 0000000000..207bcfcfbf --- /dev/null +++ b/RulesConverter/RulesConverter.csproj @@ -0,0 +1,77 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {BBE7C0D7-7529-4C34-9910-206866F204EF} + Exe + Properties + RulesConverter + RulesConverter + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\Ijw.DirectX\Ijw.Framework\IjwFramework\bin\Release\IjwFramework.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + False + ..\thirdparty\yaml\bin\Debug\Yaml.dll + + + + + + + + + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073} + OpenRa.DataStructures + + + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA} + OpenRa.FileFormats + + + + + \ No newline at end of file diff --git a/ra.yaml b/ra.yaml index c6e03e0b9b..6c6153d54e 100644 --- a/ra.yaml +++ b/ra.yaml @@ -4,14 +4,28 @@ Vehicles: V2RL: - Buildable: { Description="V2 Rocket", Prerequisites=[weap,dome], TechLevel=4, Cost=700, - LongDesc="Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" } - Unit: { HP=150, Armor=light, Crewed=yes, Voice=VehicleVoice } - Mobile: { Sight=5, ROT=5, Speed=7, UMT=Track } - AttackBase: { Primary=SCUD, Ammo=1 } - RenderUnitReload: {} - AutoTarget: {} - Repairable: {} - Chronoshiftable: {} - Passenger: {} - IronCurtainable: {} \ No newline at end of file + Buildable: + Description="V2 Rocket" + Prerequisites=[weap,dome] + TechLevel=4 + Cost=700, + LongDesc="Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" + Unit: + HP=150 + Armor=light + Crewed=yes + Voice=VehicleVoice + Mobile: + Sight=5 + ROT=5 + Speed=7 + UMT=Track + AttackBase: + Primary=SCUD + Ammo=1 + RenderUnitReload: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: \ No newline at end of file