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

@@ -9,6 +9,7 @@
#endregion
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace OpenRA.Graphics
@@ -110,7 +111,9 @@ namespace OpenRA.Graphics
sheet = cachedSheets[mi.Src];
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);
}

View File

@@ -10,10 +10,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileSystem;
using OpenRA.Primitives;
namespace OpenRA.Graphics
{
@@ -42,7 +39,7 @@ namespace OpenRA.Graphics
var palettes = new Dictionary<string, ImmutablePalette>();
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();

View File

@@ -11,8 +11,9 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using OpenRA.FileSystem;
namespace OpenRA.Graphics
{
@@ -47,9 +48,8 @@ namespace OpenRA.Graphics
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))
{
Size = bitmap.Size;

View File

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

View File

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