xml -> ini conversion tool

This commit is contained in:
Chris Forbes
2009-11-29 10:44:12 +13:00
parent 54074de6cf
commit b4b3877d05
7 changed files with 553 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
namespace OpenRa.FileFormats
{
public class IniWriter
{
readonly string Filename;
public IniWriter(string filename) { Filename = Path.GetFullPath(filename); }
public void Set(string section, string key, string value)
{
WritePrivateProfileString(section, key, value, Filename);
}
public string Get(string section, string key, string defaultValue)
{
var sb = new StringBuilder(1024);
GetPrivateProfileString(section, key, defaultValue, sb, sb.Length, Filename);
return sb.ToString();
}
public string Get(string section, string key)
{
return Get(section, key, "");
}
[DllImport("kernel32")]
static extern int WritePrivateProfileString(string section, string key, string value, string filename);
[DllImport("kernel32")]
static extern int GetPrivateProfileString(string section, string key, string defaultValue,
StringBuilder value, int length, string filename);
}
}

View File

@@ -54,6 +54,7 @@
<Compile Include="Format40.cs" />
<Compile Include="Format80.cs" />
<Compile Include="IniFile.cs" />
<Compile Include="IniWriter.cs" />
<Compile Include="Map.cs" />
<Compile Include="PackageEntry.cs" />
<Compile Include="Package.cs" />

View File

@@ -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}") = "SequenceConverter", "SequenceConverter\SequenceConverter.csproj", "{65230462-5ECC-4441-B6FF-E0E025C4C4EB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug (x86)|Any CPU = Debug (x86)|Any CPU
@@ -158,6 +160,27 @@ 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
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug (x86)|Any CPU.ActiveCfg = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug (x86)|Any CPU.Build.0 = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug (x86)|Mixed Platforms.Build.0 = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug (x86)|Win32.ActiveCfg = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug (x86)|Win32.Build.0 = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Debug|Win32.ActiveCfg = Debug|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Release (x86)|Any CPU.ActiveCfg = Release|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Release (x86)|Any CPU.Build.0 = Release|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Release (x86)|Mixed Platforms.ActiveCfg = Release|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Release (x86)|Mixed Platforms.Build.0 = Release|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Release (x86)|Win32.ActiveCfg = Release|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Release|Any CPU.Build.0 = Release|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{65230462-5ECC-4441-B6FF-E0E025C4C4EB}.Release|Win32.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using OpenRa.FileFormats;
namespace SequenceConverter
{
class Program
{
static void Main(string[] args)
{
var xmlfile = args[0];
var inifile = args[1];
var doc = new XmlDocument();
doc.Load(xmlfile);
var ini = new IniWriter(inifile);
foreach (var e in doc.SelectNodes(".//unit/sequence").Cast<XmlElement>())
ini.Set(
string.Format("Sequence.{0}",
(e.ParentNode as XmlElement).GetAttribute("name")),
e.GetAttribute("name"),
BuildSequenceValue(e));
}
static string BuildSequenceValue(XmlElement e)
{
var range = string.Format(
"{0},{1}",
e.GetAttribute("start"),
e.HasAttribute("length") ? e.GetAttribute("length") : "1");
return e.HasAttribute("src")
? range + "," + e.GetAttribute("src")
: range;
}
}
}

View File

@@ -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("SequenceConverter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SequenceConverter")]
[assembly: AssemblyCopyright("Copyright © 2009")]
[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("f1405991-fe9e-4730-bee2-c3b0880c4c9e")]
// 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")]

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{65230462-5ECC-4441-B6FF-E0E025C4C4EB}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SequenceConverter</RootNamespace>
<AssemblyName>SequenceConverter</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRa.DataStructures\OpenRa.DataStructures.csproj">
<Project>{2F9E7A23-56C0-4286-9C8E-1060A9B2F073}</Project>
<Name>OpenRa.DataStructures</Name>
</ProjectReference>
<ProjectReference Include="..\OpenRa.FileFormats\OpenRa.FileFormats.csproj">
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
<Name>OpenRa.FileFormats</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

343
sequences.ini Normal file
View File

@@ -0,0 +1,343 @@
[Sequence.fcom]
idle=0,1
damaged-idle=1,1
make=0,1
[Sequence.fact]
idle=0,1
make=0,32,factmake
build=1,25
damaged-idle=26,1
damaged-build=27,25
[Sequence.proc]
idle=0,1
damaged-idle=1,1
make=0,*,procmake
[Sequence.silo]
idle=0,5
damaged-idle=5,5
make=0,*,silomake
[Sequence.powr]
idle=0,1
damaged-idle=1,1
make=0,*,powrmake
[Sequence.apwr]
idle=0,1
damaged-idle=1,1
make=0,*,apwrmake
[Sequence.barr]
idle=0,10
damaged-idle=10,10
make=0,*,barrmake
[Sequence.tent]
idle=0,10
damaged-idle=10,10
make=0,*,tentmake
[Sequence.kenn]
idle=0,1
damaged-idle=1,1
make=0,*,kennmake
[Sequence.dome]
idle=0,1
damaged-idle=1,1
make=0,*,domemake
[Sequence.atek]
idle=0,1
damaged-idle=1,1
make=0,*,atekmake
[Sequence.stek]
idle=0,1
damaged-idle=1,1
make=0,*,stekmake
[Sequence.weap]
idle=0,1
damaged-idle=1,1
make=0,*,weapmake
build-top=0,4,weap2
damaged-build-top=4,4,weap2
idle-top=0,1,weap2
damaged-idle-top=4,1,weap2
[Sequence.hpad]
idle=0,7
damaged-idle=7,7
make=0,*,hpadmake
[Sequence.afld]
idle=0,8
damaged-idle=8,8
make=0,*,afldmake
[Sequence.spen]
idle=0,1
damaged-idle=1,1
make=0,*,spenmake
[Sequence.syrd]
idle=0,1
damaged-idle=1,1
make=0,*,syrdmake
[Sequence.fix]
idle=0,1
damaged-idle=7,1
make=0,14,fixmake
active=1,6
damaged-active=8,6
[Sequence.gun]
idle=0,32
recoil=32,32
make=0,20,gunmake
damaged-idle=64,32
damaged-recoil=96,32
[Sequence.agun]
idle=0,32
damaged-idle=32,32
make=0,*,agunmake
[Sequence.sam]
idle=0,32
damaged-idle=34,32
make=0,*,sammake
[Sequence.ftur]
idle=0,1
damaged-idle=1,1
make=0,*,fturmake
[Sequence.tsla]
idle=0,1
damaged-idle=10,1
make=0,13,tslamake
active=1,9
damaged-active=11,9
[Sequence.pbox]
idle=0,1
damaged-idle=1,1
make=0,*,pboxmake
[Sequence.hbox]
idle=0,1
damaged-idle=1,1
make=0,*,hboxmake
[Sequence.gap]
idle=0,32
damaged-idle=32,32
make=0,*,gapmake
[Sequence.iron]
idle=0,11
damaged-idle=11,11
make=0,*,ironmake
[Sequence.pdox]
idle=0,29
damaged-idle=29,29
make=0,*,pdoxmake
[Sequence.mslo]
idle=0,1
damaged-idle=8,1
make=0,15,mslomake
active=1,7
damaged-active=9,7
[Sequence.mcv]
idle=0,*
[Sequence.truk]
idle=0,*
[Sequence.harv]
idle=0,32
harvest0=32,8
harvest1=40,8
harvest2=48,8
harvest3=56,8
harvest4=64,8
harvest5=72,8
harvest6=80,8
harvest7=88,8
empty=96,15
[Sequence.1tnk]
idle=0,32
turret=32,32
[Sequence.2tnk]
idle=0,32
turret=32,32
[Sequence.3tnk]
idle=0,32
turret=32,32
[Sequence.4tnk]
idle=0,32
turret=32,32
[Sequence.v2rl]
idle=0,32
empty-idle=32,32
aim=64,8
empty-aim=72,8
[Sequence.arty]
idle=0,32
[Sequence.jeep]
idle=0,32
turret=32,32
muzzle=0,48,minigun
[Sequence.apc]
idle=0,32
muzzle=0,48,minigun
[Sequence.mnly]
idle=0,32
[Sequence.mrj]
idle=0,32
spinner=32,32
[Sequence.mgg]
idle=0,32
spinner=32,8
[Sequence.ss]
idle=0,16
[Sequence.e1]
stand=0,8
stand2=8,8
run-0=16,6
run-1=22,6
run-2=28,6
run-3=34,6
run-4=40,6
run-5=46,6
run-6=52,6
run-7=58,6
shoot-0=64,8
shoot-1=72,8
shoot-2=80,8
shoot-3=88,8
shoot-4=96,8
shoot-5=104,8
shoot-6=112,8
shoot-7=120,8
stand3=128,16
crawl-0=144,4
crawl-1=148,4
crawl-2=152,4
crawl-3=156,4
crawl-4=160,4
crawl-5=164,4
crawl-6=168,4
crawl-7=172,4
standup-0=176,2
standup-1=178,2
standup-2=180,2
standup-3=182,2
standup-4=184,2
standup-5=186,2
standup-6=188,2
standup-7=190,2
prone-shoot-0=192,8
prone-shoot-1=200,8
prone-shoot-2=208,8
prone-shoot-3=216,8
prone-shoot-4=224,8
prone-shoot-5=232,8
prone-shoot-6=240,8
prone-shoot-7=248,8
idle1=256,16
idle2=272,16
die1=288,8
die2=296,8
die3=304,8
die4=312,12
die5=324,18
[Sequence.clock]
idle=0,*
[Sequence.120mm]
idle=0,1
[Sequence.e3]
stand=0,8
stand2=8,8
run-0=16,6
run-1=22,6
run-2=28,6
run-3=34,6
run-4=40,6
run-5=46,6
run-6=52,6
run-7=58,6
[Sequence.e6]
stand=0,8
stand2=8,8
run-0=16,6
run-1=22,6
run-2=28,6
run-3=34,6
run-4=40,6
run-6=54,6
run-7=60,6
die1=146,8
die2=154,8
die3=162,8
die4=170,12
die5=182,18
[Sequence.ca]
idle=0,16
turret=0,32,turr
[Sequence.dd]
idle=0,16
turret=0,32,ssam
[Sequence.pt]
idle=0,16
turret=0,32,mgun
[Sequence.medi]
stand=0,8
run-0=8,6
run-1=14,6
run-2=20,6
run-3=26,6
run-4=32,6
run-5=38,6
run-6=44,6
run-7=50,6
heal=56,58
standup-0=114,2
standup-1=116,2
standup-2=118,2
standup-3=120,2
standup-4=122,2
standup-5=124,2
standup-6=126,2
standup-7=128,2
die2=201,8
die3=209,8
die4=217,12
die5=229,18
[Sequence.explosion]
1=0,4,piff
2=0,8,piffpiff
3=0,14,napalm2
4=0,14,veh-hit3
5=0,22,veh-hit2
6w=0,27,atomsfx
1w=0,10,h2o_exp3
5w=0,10,h2o_exp1
3w=0,14,napalm2
6=0,27,atomsfx
4w=0,10,h2o_exp2
2w=0,10,h2o_exp3
7=0,18,fball1
[Sequence.lst]
idle=0,1
[Sequence.pips]
groups=8,10
ore=0,2
cargo=5,3
medic=20,1
ready=3,1
hold=4,1
[Sequence.mig]
idle=0,16
[Sequence.yak]
idle=0,16
[Sequence.heli]
idle=0,32
rotor=0,4,lrotor
slow-rotor=4,8,lrotor
[Sequence.hind]
idle=0,32
rotor=0,4,lrotor
slow-rotor=4,8,lrotor
[Sequence.tran]
idle=0,32
rotor=0,4,lrotor
rotor2=0,4,rrotor
slow-rotor=4,8,lrotor
slow-rotor2=4,8,rrotor
[Sequence.v2]
idle=0,32
[Sequence.flagfly]
idle=0,14
[Sequence.smoke_m]
idle=0,91
loop=49,42
end=0,26