Unstatic GlobalFileSystem and rename it to FileSystem

Add a ModFiles field on ModData and move all access to the file system to go through that.
This commit is contained in:
Pavel Penev
2015-10-09 13:55:08 +03:00
parent 5684bcec1c
commit 1b88d24cfa
46 changed files with 154 additions and 172 deletions

View File

@@ -39,14 +39,14 @@ namespace OpenRA.FileSystem
// Build the index and dispose the stream, it is no longer needed after this // Build the index and dispose the stream, it is no longer needed after this
List<IdxEntry> entries; List<IdxEntry> entries;
using (var indexStream = GlobalFileSystem.Open(indexFilename)) using (var indexStream = Game.ModData.ModFiles.Open(indexFilename))
entries = new IdxReader(indexStream).Entries; entries = new IdxReader(indexStream).Entries;
index = entries.ToDictionaryWithConflictLog(x => x.Hash, index = entries.ToDictionaryWithConflictLog(x => x.Hash,
"{0} (bag format)".F(filename), "{0} (bag format)".F(filename),
null, x => "(offs={0}, len={1})".F(x.Offset, x.Length)); null, x => "(offs={0}, len={1})".F(x.Offset, x.Length));
s = GlobalFileSystem.Open(filename); s = Game.ModData.ModFiles.Open(filename);
} }
public int Priority { get { return 1000 + bagFilePriority; } } public int Priority { get { return 1000 + bagFilePriority; } }
@@ -159,9 +159,9 @@ namespace OpenRA.FileSystem
public IEnumerable<string> AllFileNames() public IEnumerable<string> AllFileNames()
{ {
var lookup = new Dictionary<uint, string>(); var lookup = new Dictionary<uint, string>();
if (GlobalFileSystem.Exists("global mix database.dat")) if (Game.ModData.ModFiles.Exists("global mix database.dat"))
{ {
var db = new XccGlobalDatabase(GlobalFileSystem.Open("global mix database.dat")); var db = new XccGlobalDatabase(Game.ModData.ModFiles.Open("global mix database.dat"));
foreach (var e in db.Entries) foreach (var e in db.Entries)
{ {
var hash = IdxEntry.HashFilename(e, PackageHashType.CRC32); var hash = IdxEntry.HashFilename(e, PackageHashType.CRC32);
@@ -175,7 +175,7 @@ namespace OpenRA.FileSystem
public void Write(Dictionary<string, byte[]> contents) public void Write(Dictionary<string, byte[]> contents)
{ {
GlobalFileSystem.Unmount(this); Game.ModData.ModFiles.Unmount(this);
throw new NotImplementedException("Updating bag files unsupported"); throw new NotImplementedException("Updating bag files unsupported");
} }

View File

@@ -27,7 +27,7 @@ namespace OpenRA.FileSystem
Name = filename; Name = filename;
Priority = priority; Priority = priority;
s = GlobalFileSystem.Open(filename); s = Game.ModData.ModFiles.Open(filename);
try try
{ {
if (s.ReadASCII(4) != "BIGF") if (s.ReadASCII(4) != "BIGF")

View File

@@ -29,7 +29,7 @@ namespace OpenRA.FileSystem
this.filename = filename; this.filename = filename;
this.priority = priority; this.priority = priority;
s = GlobalFileSystem.Open(filename); s = Game.ModData.ModFiles.Open(filename);
try try
{ {
filenames = new List<string>(); filenames = new List<string>();

View File

@@ -17,34 +17,16 @@ using OpenRA.Primitives;
namespace OpenRA.FileSystem namespace OpenRA.FileSystem
{ {
public static class GlobalFileSystem public class FileSystem
{ {
public static List<IFolder> MountedFolders = new List<IFolder>(); public readonly List<string> FolderPaths = new List<string>();
static Cache<uint, List<IFolder>> classicHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>()); public readonly List<IFolder> MountedFolders = new List<IFolder>();
static Cache<uint, List<IFolder>> crcHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>());
public static List<string> FolderPaths = new List<string>(); static readonly Dictionary<string, Assembly> AssemblyCache = new Dictionary<string, Assembly>();
static void MountInner(IFolder folder) int order;
{ Cache<uint, List<IFolder>> crcHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>());
MountedFolders.Add(folder); Cache<uint, List<IFolder>> classicHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>());
foreach (var hash in folder.ClassicHashes())
{
var l = classicHashIndex[hash];
if (!l.Contains(folder))
l.Add(folder);
}
foreach (var hash in folder.CrcHashes())
{
var l = crcHashIndex[hash];
if (!l.Contains(folder))
l.Add(folder);
}
}
static int order = 0;
public static IFolder CreatePackage(string filename, int order, Dictionary<string, byte[]> content) public static IFolder CreatePackage(string filename, int order, Dictionary<string, byte[]> content)
{ {
@@ -99,7 +81,13 @@ namespace OpenRA.FileSystem
return new Folder(filename, order); return new Folder(filename, order);
} }
public static void Mount(string name, string annotation = null) public void Mount(IFolder mount)
{
if (!MountedFolders.Contains(mount))
MountedFolders.Add(mount);
}
public void Mount(string name, string annotation = null)
{ {
var optional = name.StartsWith("~"); var optional = name.StartsWith("~");
if (optional) if (optional)
@@ -117,7 +105,34 @@ namespace OpenRA.FileSystem
a(); a();
} }
public static void UnmountAll() void MountInner(IFolder folder)
{
MountedFolders.Add(folder);
foreach (var hash in folder.ClassicHashes())
{
var folderList = classicHashIndex[hash];
if (!folderList.Contains(folder))
folderList.Add(folder);
}
foreach (var hash in folder.CrcHashes())
{
var folderList = crcHashIndex[hash];
if (!folderList.Contains(folder))
folderList.Add(folder);
}
}
public bool Unmount(IFolder mount)
{
if (MountedFolders.Contains(mount))
mount.Dispose();
return MountedFolders.RemoveAll(f => f == mount) > 0;
}
public void UnmountAll()
{ {
foreach (var folder in MountedFolders) foreach (var folder in MountedFolders)
folder.Dispose(); folder.Dispose();
@@ -128,20 +143,7 @@ namespace OpenRA.FileSystem
crcHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>()); crcHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>());
} }
public static bool Unmount(IFolder mount) public void LoadFromManifest(Manifest manifest)
{
if (MountedFolders.Contains(mount))
mount.Dispose();
return MountedFolders.RemoveAll(f => f == mount) > 0;
}
public static void Mount(IFolder mount)
{
if (!MountedFolders.Contains(mount)) MountedFolders.Add(mount);
}
public static void LoadFromManifest(Manifest manifest)
{ {
UnmountAll(); UnmountAll();
foreach (var dir in manifest.Folders) foreach (var dir in manifest.Folders)
@@ -151,7 +153,7 @@ namespace OpenRA.FileSystem
Mount(pkg.Key, pkg.Value); Mount(pkg.Key, pkg.Value);
} }
static Stream GetFromCache(PackageHashType type, string filename) Stream GetFromCache(PackageHashType type, string filename)
{ {
var index = type == PackageHashType.CRC32 ? crcHashIndex : classicHashIndex; var index = type == PackageHashType.CRC32 ? crcHashIndex : classicHashIndex;
var folder = index[PackageEntry.HashFilename(filename, type)] var folder = index[PackageEntry.HashFilename(filename, type)]
@@ -164,7 +166,7 @@ namespace OpenRA.FileSystem
return null; return null;
} }
public static Stream Open(string filename) public Stream Open(string filename)
{ {
Stream s; Stream s;
if (!TryOpen(filename, out s)) if (!TryOpen(filename, out s))
@@ -173,7 +175,7 @@ namespace OpenRA.FileSystem
return s; return s;
} }
public static bool TryOpen(string name, out Stream s) public bool TryOpen(string name, out Stream s)
{ {
var filename = name; var filename = name;
var foldername = string.Empty; var foldername = string.Empty;
@@ -217,7 +219,7 @@ namespace OpenRA.FileSystem
return false; return false;
} }
public static bool Exists(string name) public bool Exists(string name)
{ {
var explicitFolder = name.Contains(':') && !Directory.Exists(Path.GetDirectoryName(name)); var explicitFolder = name.Contains(':') && !Directory.Exists(Path.GetDirectoryName(name));
if (explicitFolder) if (explicitFolder)
@@ -231,8 +233,6 @@ namespace OpenRA.FileSystem
return MountedFolders.Any(f => f.Exists(name)); return MountedFolders.Any(f => f.Exists(name));
} }
static Dictionary<string, Assembly> assemblyCache = new Dictionary<string, Assembly>();
public static Assembly ResolveAssembly(object sender, ResolveEventArgs e) public static Assembly ResolveAssembly(object sender, ResolveEventArgs e)
{ {
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
@@ -243,15 +243,15 @@ namespace OpenRA.FileSystem
var filename = frags[0] + ".dll"; var filename = frags[0] + ".dll";
Assembly a; Assembly a;
if (assemblyCache.TryGetValue(filename, out a)) if (AssemblyCache.TryGetValue(filename, out a))
return a; return a;
if (Exists(filename)) if (Game.ModData.ModFiles.Exists(filename))
using (var s = Open(filename)) using (var s = Game.ModData.ModFiles.Open(filename))
{ {
var buf = s.ReadBytes((int)s.Length); var buf = s.ReadBytes((int)s.Length);
a = Assembly.Load(buf); a = Assembly.Load(buf);
assemblyCache.Add(filename, a); AssemblyCache.Add(filename, a);
return a; return a;
} }

View File

@@ -14,11 +14,10 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using ICSharpCode.SharpZipLib.Zip.Compression; using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
namespace OpenRA.FileSystem namespace OpenRA.FileSystem
{ {
public class InstallShieldCABExtractor : IDisposable, IFolder public class InstallShieldCABExtractor : IFolder
{ {
const uint FileSplit = 0x1; const uint FileSplit = 0x1;
const uint FileObfuscated = 0x2; const uint FileObfuscated = 0x2;
@@ -277,7 +276,7 @@ namespace OpenRA.FileSystem
cabFile.Dispose(); cabFile.Dispose();
++volumeNumber; ++volumeNumber;
cabFile = GlobalFileSystem.Open("{0}{1}.cab".F(commonName, volumeNumber)); cabFile = Game.ModData.ModFiles.Open("{0}{1}.cab".F(commonName, volumeNumber));
if (cabFile.ReadUInt32() != 0x28635349) if (cabFile.ReadUInt32() != 0x28635349)
throw new InvalidDataException("Not an Installshield CAB package"); throw new InvalidDataException("Not an Installshield CAB package");
@@ -341,7 +340,7 @@ namespace OpenRA.FileSystem
var fileGroupOffsets = new List<uint>(); var fileGroupOffsets = new List<uint>();
this.priority = priority; this.priority = priority;
hdrFile = GlobalFileSystem.Open(hdrFilename); hdrFile = Game.ModData.ModFiles.Open(hdrFilename);
// Strips archive number AND file extension // Strips archive number AND file extension
commonName = Regex.Replace(hdrFilename, @"\d*\.[^\.]*$", ""); commonName = Regex.Replace(hdrFilename, @"\d*\.[^\.]*$", "");

View File

@@ -31,7 +31,7 @@ namespace OpenRA.FileSystem
filenames = new List<string>(); filenames = new List<string>();
s = GlobalFileSystem.Open(filename); s = Game.ModData.ModFiles.Open(filename);
try try
{ {
// Parse package header // Parse package header

View File

@@ -57,7 +57,7 @@ namespace OpenRA.FileSystem
this.priority = priority; this.priority = priority;
this.type = type; this.type = type;
s = GlobalFileSystem.Open(filename); s = Game.ModData.ModFiles.Open(filename);
try try
{ {
// Detect format type // Detect format type
@@ -223,9 +223,9 @@ namespace OpenRA.FileSystem
} }
} }
if (GlobalFileSystem.Exists("global mix database.dat")) if (Game.ModData.ModFiles.Exists("global mix database.dat"))
{ {
var db = new XccGlobalDatabase(GlobalFileSystem.Open("global mix database.dat")); var db = new XccGlobalDatabase(Game.ModData.ModFiles.Open("global mix database.dat"));
foreach (var e in db.Entries) foreach (var e in db.Entries)
{ {
var hash = PackageEntry.HashFilename(e, type); var hash = PackageEntry.HashFilename(e, type);
@@ -249,7 +249,7 @@ namespace OpenRA.FileSystem
{ {
// Cannot modify existing mixfile - rename existing file and // Cannot modify existing mixfile - rename existing file and
// create a new one with original content plus modifications // create a new one with original content plus modifications
GlobalFileSystem.Unmount(this); Game.ModData.ModFiles.Unmount(this);
// TODO: Add existing data to the contents list // TODO: Add existing data to the contents list
if (index.Count > 0) if (index.Count > 0)

View File

@@ -34,7 +34,7 @@ namespace OpenRA.FileSystem
this.priority = priority; this.priority = priority;
index = new Dictionary<string, Entry>(); index = new Dictionary<string, Entry>();
stream = GlobalFileSystem.Open(filename); stream = Game.ModData.ModFiles.Open(filename);
try try
{ {
index = new Dictionary<string, Entry>(); index = new Dictionary<string, Entry>();

View File

@@ -17,7 +17,6 @@ using System.Linq;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
using OpenRA.Chat; using OpenRA.Chat;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Network; using OpenRA.Network;
using OpenRA.Primitives; using OpenRA.Primitives;
@@ -196,7 +195,7 @@ namespace OpenRA
{ {
Console.WriteLine("Platform is {0}", Platform.CurrentPlatform); Console.WriteLine("Platform is {0}", Platform.CurrentPlatform);
AppDomain.CurrentDomain.AssemblyResolve += GlobalFileSystem.ResolveAssembly; AppDomain.CurrentDomain.AssemblyResolve += FileSystem.FileSystem.ResolveAssembly;
InitializeSettings(args); InitializeSettings(args);
@@ -219,7 +218,7 @@ namespace OpenRA
GeoIP.Initialize(); GeoIP.Initialize();
GlobalFileSystem.Mount(Platform.GameDir); // Needed to access shaders ModData.ModFiles.Mount(Platform.GameDir); // Needed to access shaders
var renderers = new[] { Settings.Graphics.Renderer, "Default", null }; var renderers = new[] { Settings.Graphics.Renderer, "Default", null };
foreach (var r in renderers) foreach (var r in renderers)
{ {
@@ -280,7 +279,11 @@ namespace OpenRA
OrderManager.Dispose(); OrderManager.Dispose();
if (ModData != null) if (ModData != null)
{
ModData.ModFiles.UnmountAll();
ModData.Dispose(); ModData.Dispose();
}
ModData = null; ModData = null;
// Fall back to default if the mod doesn't exist or has missing prerequisites. // Fall back to default if the mod doesn't exist or has missing prerequisites.

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileSystem;
namespace OpenRA.GameRules namespace OpenRA.GameRules
{ {
@@ -36,11 +35,11 @@ namespace OpenRA.GameRules
public void Load() public void Load()
{ {
if (!GlobalFileSystem.Exists(Filename)) if (!Game.ModData.ModFiles.Exists(Filename))
return; return;
Exists = true; Exists = true;
using (var s = GlobalFileSystem.Open(Filename)) using (var s = Game.ModData.ModFiles.Open(Filename))
{ {
if (Filename.ToLowerInvariant().EndsWith("wav")) if (Filename.ToLowerInvariant().EndsWith("wav"))
Length = (int)WavLoader.WaveLength(s); Length = (int)WavLoader.WaveLength(s);

View File

@@ -9,6 +9,7 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
namespace OpenRA.Graphics namespace OpenRA.Graphics
@@ -110,7 +111,9 @@ namespace OpenRA.Graphics
sheet = cachedSheets[mi.Src]; sheet = cachedSheets[mi.Src];
else else
{ {
sheet = new Sheet(SheetType.BGRA, mi.Src); using (var stream = Game.ModData.ModFiles.Open(mi.Src))
sheet = new Sheet(SheetType.BGRA, stream);
cachedSheets.Add(mi.Src, sheet); cachedSheets.Add(mi.Src, sheet);
} }

View File

@@ -10,10 +10,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileSystem;
using OpenRA.Primitives;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {
@@ -42,7 +39,7 @@ namespace OpenRA.Graphics
var palettes = new Dictionary<string, ImmutablePalette>(); var palettes = new Dictionary<string, ImmutablePalette>();
foreach (var p in nodesDict["Palettes"].Nodes) foreach (var p in nodesDict["Palettes"].Nodes)
palettes.Add(p.Key, new ImmutablePalette(GlobalFileSystem.Open(p.Value.Value), shadowIndex)); palettes.Add(p.Key, new ImmutablePalette(modData.ModFiles.Open(p.Value.Value), shadowIndex));
Palettes = palettes.AsReadOnly(); Palettes = palettes.AsReadOnly();

View File

@@ -11,8 +11,9 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using OpenRA.FileSystem;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {
@@ -47,9 +48,8 @@ namespace OpenRA.Graphics
Size = texture.Size; Size = texture.Size;
} }
public Sheet(SheetType type, string filename) public Sheet(SheetType type, Stream stream)
{ {
using (var stream = GlobalFileSystem.Open(filename))
using (var bitmap = (Bitmap)Image.FromStream(stream)) using (var bitmap = (Bitmap)Image.FromStream(stream))
{ {
Size = bitmap.Size; Size = bitmap.Size;

View File

@@ -11,7 +11,6 @@
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using OpenRA.FileSystem;
using OpenRA.Primitives; using OpenRA.Primitives;
namespace OpenRA.Graphics namespace OpenRA.Graphics
@@ -66,7 +65,7 @@ namespace OpenRA.Graphics
public static ISpriteFrame[] GetFrames(string filename, ISpriteLoader[] loaders) public static ISpriteFrame[] GetFrames(string filename, ISpriteLoader[] loaders)
{ {
using (var stream = GlobalFileSystem.Open(filename)) using (var stream = Game.ModData.ModFiles.Open(filename))
{ {
ISpriteFrame[] frames; ISpriteFrame[] frames;
foreach (var loader in loaders) foreach (var loader in loaders)

View File

@@ -13,7 +13,6 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileSystem;
using OpenRA.Primitives; using OpenRA.Primitives;
namespace OpenRA.Graphics namespace OpenRA.Graphics
@@ -217,9 +216,9 @@ namespace OpenRA.Graphics
{ {
VxlReader vxl; VxlReader vxl;
HvaReader hva; HvaReader hva;
using (var s = GlobalFileSystem.Open(files.First + ".vxl")) using (var s = Game.ModData.ModFiles.Open(files.First + ".vxl"))
vxl = new VxlReader(s); vxl = new VxlReader(s);
using (var s = GlobalFileSystem.Open(files.Second + ".hva")) using (var s = Game.ModData.ModFiles.Open(files.Second + ".hva"))
hva = new HvaReader(s, files.Second + ".hva"); hva = new HvaReader(s, files.Second + ".hva");
return new Voxel(this, vxl, hva); return new Voxel(this, vxl, hva);
} }

View File

@@ -317,7 +317,7 @@ namespace OpenRA
public Map(string path) public Map(string path)
{ {
Path = path; Path = path;
Container = GlobalFileSystem.OpenPackage(path, null, int.MaxValue); Container = FileSystem.FileSystem.OpenPackage(path, null, int.MaxValue);
AssertExists("map.yaml"); AssertExists("map.yaml");
AssertExists("map.bin"); AssertExists("map.bin");
@@ -650,7 +650,7 @@ namespace OpenRA
Path = toPath; Path = toPath;
// Create a new map package // Create a new map package
Container = GlobalFileSystem.CreatePackage(Path, int.MaxValue, entries); Container = FileSystem.FileSystem.CreatePackage(Path, int.MaxValue, entries);
} }
// Update existing package // Update existing package

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using OpenRA.FileSystem;
namespace OpenRA namespace OpenRA
{ {
@@ -230,12 +229,6 @@ namespace OpenRA
return ret; return ret;
} }
public static List<MiniYamlNode> FromFileInPackage(string path)
{
using (var stream = GlobalFileSystem.Open(path))
return FromLines(stream.ReadAllLines(), path);
}
public static Dictionary<string, MiniYaml> DictFromFile(string path) public static Dictionary<string, MiniYaml> DictFromFile(string path)
{ {
return FromFile(path).ToDictionary(x => x.Key, x => x.Value); return FromFile(path).ToDictionary(x => x.Key, x => x.Value);

View File

@@ -13,9 +13,9 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Widgets; using OpenRA.Widgets;
using FS = OpenRA.FileSystem.FileSystem;
namespace OpenRA namespace OpenRA
{ {
@@ -31,8 +31,9 @@ namespace OpenRA
public ILoadScreen LoadScreen { get; private set; } public ILoadScreen LoadScreen { get; private set; }
public VoxelLoader VoxelLoader { get; private set; } public VoxelLoader VoxelLoader { get; private set; }
public CursorProvider CursorProvider { get; private set; } public CursorProvider CursorProvider { get; private set; }
public FS ModFiles = new FS();
Lazy<Ruleset> defaultRules; readonly Lazy<Ruleset> defaultRules;
public Ruleset DefaultRules { get { return defaultRules.Value; } } public Ruleset DefaultRules { get { return defaultRules.Value; } }
public ModData(string mod, bool useLoadScreen = false) public ModData(string mod, bool useLoadScreen = false)
@@ -95,7 +96,7 @@ namespace OpenRA
public void MountFiles() public void MountFiles()
{ {
GlobalFileSystem.LoadFromManifest(Manifest); ModFiles.LoadFromManifest(Manifest);
} }
public void InitializeLoaders() public void InitializeLoaders()
@@ -166,10 +167,10 @@ namespace OpenRA
// Reinitialize all our assets // Reinitialize all our assets
InitializeLoaders(); InitializeLoaders();
GlobalFileSystem.LoadFromManifest(Manifest); ModFiles.LoadFromManifest(Manifest);
// Mount map package so custom assets can be used. TODO: check priority. // Mount map package so custom assets can be used. TODO: check priority.
GlobalFileSystem.Mount(GlobalFileSystem.OpenPackage(map.Path, null, int.MaxValue)); ModFiles.Mount(FS.OpenPackage(map.Path, null, int.MaxValue));
using (new Support.PerfTimer("Map.PreloadRules")) using (new Support.PerfTimer("Map.PreloadRules"))
map.PreloadRules(); map.PreloadRules();

View File

@@ -95,6 +95,7 @@
<Compile Include="Actor.cs" /> <Compile Include="Actor.cs" />
<Compile Include="CacheStorage.cs" /> <Compile Include="CacheStorage.cs" />
<Compile Include="FileSystem\IdxEntry.cs" /> <Compile Include="FileSystem\IdxEntry.cs" />
<Compile Include="FileSystem\IFolder.cs" />
<Compile Include="LogProxy.cs" /> <Compile Include="LogProxy.cs" />
<Compile Include="FileFormats\IdxReader.cs" /> <Compile Include="FileFormats\IdxReader.cs" />
<Compile Include="FileSystem\BagFile.cs" /> <Compile Include="FileSystem\BagFile.cs" />
@@ -321,7 +322,7 @@
<Compile Include="Settings.cs" /> <Compile Include="Settings.cs" />
<Compile Include="Graphics\PlayerColorRemap.cs" /> <Compile Include="Graphics\PlayerColorRemap.cs" />
<Compile Include="Graphics\Palette.cs" /> <Compile Include="Graphics\Palette.cs" />
<Compile Include="FileSystem\GlobalFileSystem.cs" /> <Compile Include="FileSystem\FileSystem.cs" />
<Compile Include="FileFormats\ReplayMetadata.cs" /> <Compile Include="FileFormats\ReplayMetadata.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -11,12 +11,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Eluant; using Eluant;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Primitives; using OpenRA.Primitives;
using OpenRA.Support; using OpenRA.Support;
@@ -133,7 +130,7 @@ namespace OpenRA.Scripting
.ToArray(); .ToArray();
runtime.Globals["GameDir"] = Platform.GameDir; runtime.Globals["GameDir"] = Platform.GameDir;
runtime.DoBuffer(GlobalFileSystem.Open(Platform.ResolvePath(".", "lua", "scriptwrapper.lua")).ReadAllText(), "scriptwrapper.lua").Dispose(); runtime.DoBuffer(Game.ModData.ModFiles.Open(Platform.ResolvePath(".", "lua", "scriptwrapper.lua")).ReadAllText(), "scriptwrapper.lua").Dispose();
tick = (LuaFunction)runtime.Globals["Tick"]; tick = (LuaFunction)runtime.Globals["Tick"];
// Register globals // Register globals
@@ -172,7 +169,7 @@ namespace OpenRA.Scripting
using (var loadScript = (LuaFunction)runtime.Globals["ExecuteSandboxedScript"]) using (var loadScript = (LuaFunction)runtime.Globals["ExecuteSandboxedScript"])
{ {
foreach (var s in scripts) foreach (var s in scripts)
loadScript.Call(s, GlobalFileSystem.Open(s).ReadAllText()).Dispose(); loadScript.Call(s, Game.ModData.ModFiles.Open(s).ReadAllText()).Dispose();
} }
} }

View File

@@ -9,14 +9,11 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileSystem;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Primitives; using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA namespace OpenRA
{ {
@@ -48,17 +45,17 @@ namespace OpenRA
ISoundSource LoadSound(string filename) ISoundSource LoadSound(string filename)
{ {
if (!GlobalFileSystem.Exists(filename)) if (!Game.ModData.ModFiles.Exists(filename))
{ {
Log.Write("sound", "LoadSound, file does not exist: {0}", filename); Log.Write("sound", "LoadSound, file does not exist: {0}", filename);
return null; return null;
} }
if (filename.ToLowerInvariant().EndsWith("wav")) if (filename.ToLowerInvariant().EndsWith("wav"))
using (var s = GlobalFileSystem.Open(filename)) using (var s = Game.ModData.ModFiles.Open(filename))
return LoadWave(new WavLoader(s)); return LoadWave(new WavLoader(s));
using (var s = GlobalFileSystem.Open(filename)) using (var s = Game.ModData.ModFiles.Open(filename))
return LoadSoundRaw(AudLoader.LoadSound(s), 1, 16, 22050); return LoadSoundRaw(AudLoader.LoadSound(s), 1, 16, 22050);
} }

View File

@@ -11,6 +11,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.LoadScreens; using OpenRA.Mods.Common.LoadScreens;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -41,7 +42,9 @@ namespace OpenRA.Mods.Cnc
r = Game.Renderer; r = Game.Renderer;
if (r == null) return; if (r == null) return;
sheet = new Sheet(SheetType.BGRA, Platform.ResolvePath(loadInfo["Image"])); using (var stream = File.OpenRead(Platform.ResolvePath(loadInfo["Image"])))
sheet = new Sheet(SheetType.BGRA, stream);
var res = r.Resolution; var res = r.Resolution;
bounds = new Rectangle(0, 0, res.Width, res.Height); bounds = new Rectangle(0, 0, res.Width, res.Height);

View File

@@ -14,7 +14,6 @@ using System.IO;
using System.Linq; using System.Linq;
using ICSharpCode.SharpZipLib; using ICSharpCode.SharpZipLib;
using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Zip;
using OpenRA.FileSystem;
namespace OpenRA.Mods.Common namespace OpenRA.Mods.Common
{ {
@@ -46,9 +45,9 @@ namespace OpenRA.Mods.Common
Directory.CreateDirectory(destPath); Directory.CreateDirectory(destPath);
Log.Write("debug", "Mounting {0}".F(srcPath)); Log.Write("debug", "Mounting {0}".F(srcPath));
GlobalFileSystem.Mount(srcPath); Game.ModData.ModFiles.Mount(srcPath);
Log.Write("debug", "Mounting {0}".F(package)); Log.Write("debug", "Mounting {0}".F(package));
GlobalFileSystem.Mount(package, annotation); Game.ModData.ModFiles.Mount(package, annotation);
foreach (var directory in filesByDirectory) foreach (var directory in filesByDirectory)
{ {
@@ -71,7 +70,7 @@ namespace OpenRA.Mods.Common
Directory.CreateDirectory(containingDir); Directory.CreateDirectory(containingDir);
using (var sourceStream = GlobalFileSystem.Open(file)) using (var sourceStream = Game.ModData.ModFiles.Open(file))
using (var destStream = File.Create(dest)) using (var destStream = File.Create(dest))
{ {
Log.Write("debug", "Extracting {0} to {1}".F(file, dest)); Log.Write("debug", "Extracting {0} to {1}".F(file, dest));

View File

@@ -8,12 +8,10 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileSystem;
using OpenRA.Mods.Common.Widgets.Logic; using OpenRA.Mods.Common.Widgets.Logic;
using OpenRA.Widgets; using OpenRA.Widgets;

View File

@@ -11,6 +11,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -40,7 +41,9 @@ namespace OpenRA.Mods.Common.LoadScreens
if (info.ContainsKey("Image")) if (info.ContainsKey("Image"))
{ {
sheet = new Sheet(SheetType.BGRA, Platform.ResolvePath(info["Image"])); using (var stream = File.OpenRead(Platform.ResolvePath(info["Image"])))
sheet = new Sheet(SheetType.BGRA, stream);
logo = new Sprite(sheet, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha); logo = new Sprite(sheet, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha);
stripe = new Sprite(sheet, new Rectangle(256, 0, 256, 256), TextureChannel.Alpha); stripe = new Sprite(sheet, new Rectangle(256, 0, 256, 256), TextureChannel.Alpha);
stripeRect = new Rectangle(0, r.Resolution.Height / 2 - 128, r.Resolution.Width, 256); stripeRect = new Rectangle(0, r.Resolution.Height / 2 - 128, r.Resolution.Width, 256);

View File

@@ -10,6 +10,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -22,11 +23,15 @@ namespace OpenRA.Mods.Common.LoadScreens
public void Init(Manifest m, Dictionary<string, string> info) public void Init(Manifest m, Dictionary<string, string> info)
{ {
var sheet = new Sheet(SheetType.BGRA, info["Image"]);
var res = Game.Renderer.Resolution; var res = Game.Renderer.Resolution;
bounds = new Rectangle(0, 0, res.Width, res.Height); bounds = new Rectangle(0, 0, res.Width, res.Height);
using (var stream = File.OpenRead(info["Image"]))
{
var sheet = new Sheet(SheetType.BGRA, stream);
sprite = new Sprite(sheet, new Rectangle(0, 0, 1024, 480), TextureChannel.Alpha); sprite = new Sprite(sheet, new Rectangle(0, 0, 1024, 480), TextureChannel.Alpha);
} }
}
public void Display() public void Display()
{ {

View File

@@ -14,7 +14,6 @@ using System.IO;
using Eluant; using Eluant;
using OpenRA.Effects; using OpenRA.Effects;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileSystem;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Effects;
@@ -165,10 +164,10 @@ namespace OpenRA.Mods.Common.Scripting
else else
onCompleteRadar = () => { }; onCompleteRadar = () => { };
Stream s = null; Stream s;
try try
{ {
s = GlobalFileSystem.Open(movie); s = Game.ModData.ModFiles.Open(movie);
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
@@ -43,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
public void LoadPalettes(WorldRenderer wr) public void LoadPalettes(WorldRenderer wr)
{ {
wr.AddPalette(info.Name, new ImmutablePalette(GlobalFileSystem.Open(world.TileSet.Palette), info.ShadowIndex), info.AllowModifiers); wr.AddPalette(info.Name, new ImmutablePalette(Game.ModData.ModFiles.Open(world.TileSet.Palette), info.ShadowIndex), info.AllowModifiers);
} }
public IEnumerable<string> PaletteNames { get { yield return info.Name; } } public IEnumerable<string> PaletteNames { get { yield return info.Name; } }

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
@@ -49,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
public void LoadPalettes(WorldRenderer wr) public void LoadPalettes(WorldRenderer wr)
{ {
if (info.Tileset == null || info.Tileset.ToLowerInvariant() == world.Map.Tileset.ToLowerInvariant()) if (info.Tileset == null || info.Tileset.ToLowerInvariant() == world.Map.Tileset.ToLowerInvariant())
wr.AddPalette(info.Name, new ImmutablePalette(GlobalFileSystem.Open(info.Filename), info.ShadowIndex), info.AllowModifiers); wr.AddPalette(info.Name, new ImmutablePalette(Game.ModData.ModFiles.Open(info.Filename), info.ShadowIndex), info.AllowModifiers);
} }
public IEnumerable<string> PaletteNames public IEnumerable<string> PaletteNames

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
@@ -41,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
public void LoadPalettes(WorldRenderer wr) public void LoadPalettes(WorldRenderer wr)
{ {
var filename = world.TileSet.PlayerPalette ?? world.TileSet.Palette; var filename = world.TileSet.PlayerPalette ?? world.TileSet.Palette;
wr.AddPalette(info.Name, new ImmutablePalette(GlobalFileSystem.Open(filename), info.ShadowIndex), info.AllowModifiers); wr.AddPalette(info.Name, new ImmutablePalette(Game.ModData.ModFiles.Open(filename), info.ShadowIndex), info.AllowModifiers);
} }
} }
} }

View File

@@ -30,6 +30,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
var relativePath = args[1]; var relativePath = args[1];
var projectPath = Path.GetFullPath(relativePath); var projectPath = Path.GetFullPath(relativePath);
// HACK: The engine code assumes that Game.modData is set.
Game.ModData = modData;
var console = new StyleCopConsole(null, false, null, null, true); var console = new StyleCopConsole(null, false, null, null, true);
var project = new CodeProject(0, projectPath, new Configuration(null)); var project = new CodeProject(0, projectPath, new Configuration(null));
foreach (var filePath in Directory.GetFiles(projectPath, "*.cs", SearchOption.AllDirectories)) foreach (var filePath in Directory.GetFiles(projectPath, "*.cs", SearchOption.AllDirectories))

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Linq; using System.Linq;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
namespace OpenRA.Mods.Common.UtilityCommands namespace OpenRA.Mods.Common.UtilityCommands
@@ -29,7 +28,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
{ {
// HACK: The engine code assumes that Game.modData is set. // HACK: The engine code assumes that Game.modData is set.
Game.ModData = modData; Game.ModData = modData;
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest); Game.ModData.ModFiles.LoadFromManifest(Game.ModData.Manifest);
Game.ModData.SpriteSequenceLoader.OnMissingSpriteError = s => Console.WriteLine("\t" + s); Game.ModData.SpriteSequenceLoader.OnMissingSpriteError = s => Console.WriteLine("\t" + s);
foreach (var t in Game.ModData.Manifest.TileSets) foreach (var t in Game.ModData.Manifest.TileSets)

View File

@@ -28,11 +28,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
public void Run(ModData modData, string[] args) public void Run(ModData modData, string[] args)
{ {
var files = args.Skip(1); var files = args.Skip(1);
GlobalFileSystem.LoadFromManifest(modData.Manifest); modData.ModFiles.LoadFromManifest(modData.Manifest);
foreach (var f in files) foreach (var f in files)
{ {
var src = GlobalFileSystem.Open(f); var src = modData.ModFiles.Open(f);
if (src == null) if (src == null)
throw new InvalidOperationException("File not found: {0}".F(f)); throw new InvalidOperationException("File not found: {0}".F(f));
var data = src.ReadAllBytes(); var data = src.ReadAllBytes();

View File

@@ -13,7 +13,6 @@ using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
namespace OpenRA.Mods.Common.UtilityCommands namespace OpenRA.Mods.Common.UtilityCommands
@@ -32,7 +31,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
{ {
// HACK: The engine code assumes that Game.modData is set. // HACK: The engine code assumes that Game.modData is set.
Game.ModData = modData; Game.ModData = modData;
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest); modData.ModFiles.LoadFromManifest(Game.ModData.Manifest);
var imageField = typeof(TerrainTemplateInfo).GetField("Image"); var imageField = typeof(TerrainTemplateInfo).GetField("Image");
var pickAnyField = typeof(TerrainTemplateInfo).GetField("PickAny"); var pickAnyField = typeof(TerrainTemplateInfo).GetField("PickAny");
@@ -56,7 +55,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
foreach (var ext in exts) foreach (var ext in exts)
{ {
Stream s; Stream s;
if (GlobalFileSystem.TryOpen(template.Images[0] + ext, out s)) if (modData.ModFiles.TryOpen(template.Images[0] + ext, out s))
s.Dispose(); s.Dispose();
else else
continue; continue;

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.IO; using System.IO;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
namespace OpenRA.Mods.Common.UtilityCommands namespace OpenRA.Mods.Common.UtilityCommands
@@ -30,9 +29,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
Game.ModData = modData; Game.ModData = modData;
var map = new Map(args[1]); var map = new Map(args[1]);
GlobalFileSystem.UnmountAll(); modData.ModFiles.UnmountAll();
foreach (var dir in Game.ModData.Manifest.Folders) foreach (var dir in Game.ModData.Manifest.Folders)
GlobalFileSystem.Mount(dir); modData.ModFiles.Mount(dir);
var minimap = Minimap.RenderMapPreview(map.Rules.TileSets[map.Tileset], map, true); var minimap = Minimap.RenderMapPreview(map.Rules.TileSets[map.Tileset], map, true);

View File

@@ -14,7 +14,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives; using OpenRA.Primitives;
@@ -130,7 +129,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
public void ConvertIniMap(string iniFile) public void ConvertIniMap(string iniFile)
{ {
using (var stream = GlobalFileSystem.Open(iniFile)) using (var stream = Game.ModData.ModFiles.Open(iniFile))
{ {
var file = new IniFile(stream); var file = new IniFile(stream);
var basic = file.GetSection("Basic"); var basic = file.GetSection("Basic");
@@ -162,7 +161,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
else else
{ {
// CnC // CnC
using (var s = GlobalFileSystem.Open(iniFile.Substring(0, iniFile.Length - 4) + ".bin")) using (var s = Game.ModData.ModFiles.Open(iniFile.Substring(0, iniFile.Length - 4) + ".bin"))
UnpackCncTileData(s); UnpackCncTileData(s);
ReadCncOverlay(file); ReadCncOverlay(file);
ReadCncTrees(file); ReadCncTrees(file);

View File

@@ -13,7 +13,6 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.SpriteLoaders; using OpenRA.Mods.Common.SpriteLoaders;
using OpenRA.Traits; using OpenRA.Traits;
@@ -41,14 +40,14 @@ namespace OpenRA.Mods.Common.UtilityCommands
var srcMod = args[1].Split(':')[0]; var srcMod = args[1].Split(':')[0];
Game.ModData = new ModData(srcMod); Game.ModData = new ModData(srcMod);
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest); Game.ModData.ModFiles.LoadFromManifest(Game.ModData.Manifest);
var srcRules = Game.ModData.RulesetCache.Load(); var srcRules = Game.ModData.RulesetCache.Load();
var srcPaletteInfo = srcRules.Actors["player"].TraitInfo<PlayerColorPaletteInfo>(); var srcPaletteInfo = srcRules.Actors["player"].TraitInfo<PlayerColorPaletteInfo>();
var srcRemapIndex = srcPaletteInfo.RemapIndex; var srcRemapIndex = srcPaletteInfo.RemapIndex;
var destMod = args[2].Split(':')[0]; var destMod = args[2].Split(':')[0];
Game.ModData = new ModData(destMod); Game.ModData = new ModData(destMod);
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest); Game.ModData.ModFiles.LoadFromManifest(Game.ModData.Manifest);
var destRules = Game.ModData.RulesetCache.Load(); var destRules = Game.ModData.RulesetCache.Load();
var destPaletteInfo = destRules.Actors["player"].TraitInfo<PlayerColorPaletteInfo>(); var destPaletteInfo = destRules.Actors["player"].TraitInfo<PlayerColorPaletteInfo>();
var destRemapIndex = destPaletteInfo.RemapIndex; var destRemapIndex = destPaletteInfo.RemapIndex;

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
this.world = world; this.world = world;
panel = widget; panel = widget;
assetSource = GlobalFileSystem.MountedFolders.First(); assetSource = Game.ModData.ModFiles.MountedFolders.First();
var ticker = panel.GetOrNull<LogicTickerWidget>("ANIMATION_TICKER"); var ticker = panel.GetOrNull<LogicTickerWidget>("ANIMATION_TICKER");
if (ticker != null) if (ticker != null)
@@ -306,7 +306,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (string.IsNullOrEmpty(filename)) if (string.IsNullOrEmpty(filename))
return false; return false;
if (!GlobalFileSystem.Exists(filename)) if (!Game.ModData.ModFiles.Exists(filename))
return false; return false;
if (Path.GetExtension(filename.ToLowerInvariant()) == ".vqa") if (Path.GetExtension(filename.ToLowerInvariant()) == ".vqa")
@@ -345,7 +345,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// TODO: Re-enable "All Packages" once list generation is done in a background thread // TODO: Re-enable "All Packages" once list generation is done in a background thread
// var sources = new[] { (IFolder)null }.Concat(GlobalFileSystem.MountedFolders); // var sources = new[] { (IFolder)null }.Concat(GlobalFileSystem.MountedFolders);
var sources = GlobalFileSystem.MountedFolders; var sources = Game.ModData.ModFiles.MountedFolders;
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem); dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem);
return true; return true;
} }

View File

@@ -10,7 +10,6 @@
#endregion #endregion
using System; using System;
using OpenRA.FileSystem;
using OpenRA.Widgets; using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic namespace OpenRA.Mods.Common.Widgets.Logic
@@ -32,7 +31,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var template = scrollPanel.Get<LabelWidget>("CREDITS_TEMPLATE"); var template = scrollPanel.Get<LabelWidget>("CREDITS_TEMPLATE");
scrollPanel.RemoveChildren(); scrollPanel.RemoveChildren();
var lines = GlobalFileSystem.Open("AUTHORS").ReadAllLines(); var lines = Game.ModData.ModFiles.Open("AUTHORS").ReadAllLines();
foreach (var l in lines) foreach (var l in lines)
{ {
// Improve the formatting // Improve the formatting

View File

@@ -14,7 +14,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Network; using OpenRA.Network;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -171,11 +170,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var briefingVideo = selectedMapPreview.Map.Videos.Briefing; var briefingVideo = selectedMapPreview.Map.Videos.Briefing;
var briefingVideoVisible = briefingVideo != null; var briefingVideoVisible = briefingVideo != null;
var briefingVideoDisabled = !(briefingVideoVisible && GlobalFileSystem.Exists(briefingVideo)); var briefingVideoDisabled = !(briefingVideoVisible && Game.ModData.ModFiles.Exists(briefingVideo));
var infoVideo = selectedMapPreview.Map.Videos.BackgroundInfo; var infoVideo = selectedMapPreview.Map.Videos.BackgroundInfo;
var infoVideoVisible = infoVideo != null; var infoVideoVisible = infoVideo != null;
var infoVideoDisabled = !(infoVideoVisible && GlobalFileSystem.Exists(infoVideo)); var infoVideoDisabled = !(infoVideoVisible && Game.ModData.ModFiles.Exists(infoVideo));
startBriefingVideoButton.IsVisible = () => briefingVideoVisible && playingVideo != PlayingVideo.Briefing; startBriefingVideoButton.IsVisible = () => briefingVideoVisible && playingVideo != PlayingVideo.Briefing;
startBriefingVideoButton.IsDisabled = () => briefingVideoDisabled || playingVideo != PlayingVideo.None; startBriefingVideoButton.IsDisabled = () => briefingVideoDisabled || playingVideo != PlayingVideo.None;
@@ -295,7 +294,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return; return;
var gameStartVideo = selectedMapPreview.Map.Videos.GameStart; var gameStartVideo = selectedMapPreview.Map.Videos.GameStart;
if (gameStartVideo != null && GlobalFileSystem.Exists(gameStartVideo)) if (gameStartVideo != null && Game.ModData.ModFiles.Exists(gameStartVideo))
{ {
var fsPlayer = fullscreenVideoPlayer.Get<VqaPlayerWidget>("PLAYER"); var fsPlayer = fullscreenVideoPlayer.Get<VqaPlayerWidget>("PLAYER");
fullscreenVideoPlayer.Visible = true; fullscreenVideoPlayer.Visible = true;

View File

@@ -11,7 +11,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -50,7 +49,7 @@ namespace OpenRA.Mods.Common.Widgets
{ {
if (filename == cachedVideo) if (filename == cachedVideo)
return; return;
var video = new VqaReader(GlobalFileSystem.Open(filename)); var video = new VqaReader(Game.ModData.ModFiles.Open(filename));
cachedVideo = filename; cachedVideo = filename;
Open(video); Open(video);

View File

@@ -10,7 +10,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -44,7 +43,7 @@ namespace OpenRA.Mods.D2k.Traits
public void LoadPalettes(WorldRenderer wr) public void LoadPalettes(WorldRenderer wr)
{ {
var colors = new uint[Palette.Size]; var colors = new uint[Palette.Size];
using (var s = GlobalFileSystem.Open(info.Filename)) using (var s = Game.ModData.ModFiles.Open(info.Filename))
{ {
s.Seek(info.Offset, SeekOrigin.Begin); s.Seek(info.Offset, SeekOrigin.Begin);

View File

@@ -10,7 +10,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using OpenRA.FileSystem;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
@@ -44,7 +43,7 @@ namespace OpenRA.Mods.D2k.Traits
public void LoadPalettes(WorldRenderer wr) public void LoadPalettes(WorldRenderer wr)
{ {
var colors = new uint[Palette.Size]; var colors = new uint[Palette.Size];
using (var s = GlobalFileSystem.Open(info.Filename)) using (var s = Game.ModData.ModFiles.Open(info.Filename))
{ {
s.Seek(info.Offset, SeekOrigin.Begin); s.Seek(info.Offset, SeekOrigin.Begin);

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.FileSystem;
namespace OpenRA.Mods.TS.UtilityCommands namespace OpenRA.Mods.TS.UtilityCommands
{ {
@@ -31,7 +30,7 @@ namespace OpenRA.Mods.TS.UtilityCommands
// HACK: The engine code assumes that Game.modData is set. // HACK: The engine code assumes that Game.modData is set.
Game.ModData = modData; Game.ModData = modData;
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest); Game.ModData.ModFiles.LoadFromManifest(Game.ModData.Manifest);
var file = new IniFile(File.Open(args[1], FileMode.Open)); var file = new IniFile(File.Open(args[1], FileMode.Open));
var extension = args[2]; var extension = args[2];
@@ -73,10 +72,10 @@ namespace OpenRA.Mods.TS.UtilityCommands
for (var i = 1; i <= sectionCount; i++, templateIndex++) for (var i = 1; i <= sectionCount; i++, templateIndex++)
{ {
var templateFilename = "{0}{1:D2}.{2}".F(sectionFilename, i, extension); var templateFilename = "{0}{1:D2}.{2}".F(sectionFilename, i, extension);
if (!GlobalFileSystem.Exists(templateFilename)) if (!Game.ModData.ModFiles.Exists(templateFilename))
continue; continue;
using (var s = GlobalFileSystem.Open(templateFilename)) using (var s = Game.ModData.ModFiles.Open(templateFilename))
{ {
Console.WriteLine("\tTemplate@{0}:", templateIndex); Console.WriteLine("\tTemplate@{0}:", templateIndex);
Console.WriteLine("\t\tCategory: {0}", sectionCategory); Console.WriteLine("\t\tCategory: {0}", sectionCategory);
@@ -88,7 +87,7 @@ namespace OpenRA.Mods.TS.UtilityCommands
for (var v = 'a'; v <= 'z'; v++) for (var v = 'a'; v <= 'z'; v++)
{ {
var variant = "{0}{1:D2}{2}.{3}".F(sectionFilename, i, v, extension); var variant = "{0}{1:D2}{2}.{3}".F(sectionFilename, i, v, extension);
if (GlobalFileSystem.Exists(variant)) if (Game.ModData.ModFiles.Exists(variant))
images.Add(variant); images.Add(variant);
} }

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using OpenRA.FileSystem;
using OpenTK.Graphics.OpenGL; using OpenTK.Graphics.OpenGL;
namespace OpenRA.Platforms.Default namespace OpenRA.Platforms.Default
@@ -28,7 +27,7 @@ namespace OpenRA.Platforms.Default
string ext = type == ShaderType.VertexShader ? "vert" : "frag"; string ext = type == ShaderType.VertexShader ? "vert" : "frag";
string filename = "glsl{0}{1}.{2}".F(Path.DirectorySeparatorChar, name, ext); string filename = "glsl{0}{1}.{2}".F(Path.DirectorySeparatorChar, name, ext);
string code; string code;
using (var file = new StreamReader(GlobalFileSystem.Open(filename))) using (var file = new StreamReader(Game.ModData.ModFiles.Open(filename)))
code = file.ReadToEnd(); code = file.ReadToEnd();
var shader = GL.CreateShader(type); var shader = GL.CreateShader(type);

View File

@@ -11,7 +11,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.FileSystem;
namespace OpenRA.Utility namespace OpenRA.Utility
{ {
@@ -35,7 +34,7 @@ namespace OpenRA.Utility
return; return;
} }
AppDomain.CurrentDomain.AssemblyResolve += GlobalFileSystem.ResolveAssembly; AppDomain.CurrentDomain.AssemblyResolve += FileSystem.FileSystem.ResolveAssembly;
Log.AddChannel("perf", null); Log.AddChannel("perf", null);
Log.AddChannel("debug", null); Log.AddChannel("debug", null);