Refactor Package -> MixFile; group filesystem related classes in FileFormats.

This commit is contained in:
Paul Chote
2010-11-09 11:00:55 +13:00
parent 26cbb9d9c6
commit 356c750b23
12 changed files with 28 additions and 24 deletions

View File

@@ -39,7 +39,7 @@ namespace OpenRA.FileFormats
static IFolder OpenPackage(string filename)
{
if (filename.EndsWith(".mix"))
return new Package(filename, order++);
return new MixFile(filename, order++);
else if (filename.EndsWith(".zip"))
return new CompressedPackage(filename, order++);
else

View File

@@ -23,7 +23,7 @@ namespace OpenRA.FileFormats
int Priority { get; }
}
public class Package : IFolder
public class MixFile : IFolder
{
readonly Dictionary<uint, PackageEntry> index;
readonly bool isRmix, isEncrypted;
@@ -31,7 +31,7 @@ namespace OpenRA.FileFormats
readonly Stream s;
int priority;
public Package(string filename, int priority)
public MixFile(string filename, int priority)
{
this.priority = priority;
s = FileSystem.Open(filename);

View File

@@ -17,7 +17,7 @@ namespace OpenRA.FileFormats
{
public class MapStub
{
public IFolder Package { get; protected set; }
public IFolder Container { get; protected set; }
// Yaml map data
public string Uid { get; protected set; }
@@ -39,13 +39,13 @@ namespace OpenRA.FileFormats
public int Height { get { return BottomRight.Y - TopLeft.Y; } }
public MapStub() {} // Hack for the editor - not used for anything important
public MapStub(IFolder package)
public MapStub(IFolder container)
{
Package = package;
var yaml = MiniYaml.FromStream(Package.GetContent("map.yaml"));
Container = container;
var yaml = MiniYaml.FromStream(Container.GetContent("map.yaml"));
FieldLoader.Load( this, new MiniYaml( null, yaml ) );
Uid = Package.GetContent("map.uid").ReadAllText();
Uid = Container.GetContent("map.uid").ReadAllText();
}
static object LoadWaypoints( MiniYaml y )

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -59,8 +59,6 @@
<Compile Include="Evaluator.cs" />
<Compile Include="Exts.cs" />
<Compile Include="FieldLoader.cs" />
<Compile Include="FileSystem.cs" />
<Compile Include="Folder.cs" />
<Compile Include="Graphics\IGraphicsDevice.cs" />
<Compile Include="Graphics\IInputHandler.cs" />
<Compile Include="Graphics\Vertex.cs" />
@@ -68,8 +66,6 @@
<Compile Include="MiniYaml.cs" />
<Compile Include="Mod.cs" />
<Compile Include="PackageEntry.cs" />
<Compile Include="Package.cs" />
<Compile Include="PackageWriter.cs" />
<Compile Include="Palette.cs" />
<Compile Include="PlayerColorRemap.cs" />
<Compile Include="Primitives\DisposableAction.cs" />
@@ -101,8 +97,12 @@
<Compile Include="Map\MapStub.cs" />
<Compile Include="Map\SmudgeReference.cs" />
<Compile Include="Map\PlayerReference.cs" />
<Compile Include="CompressedPackage.cs" />
<Compile Include="Graphics\VqaReader.cs" />
<Compile Include="Filesystem\MixFile.cs" />
<Compile Include="Filesystem\FileSystem.cs" />
<Compile Include="Filesystem\Folder.cs" />
<Compile Include="Filesystem\PackageWriter.cs" />
<Compile Include="Filesystem\CompressedPackage.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -112,4 +112,7 @@
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Folder Include="Filesystem\" />
</ItemGroup>
</Project>