Use IReadOnlyFileSystem in UI code.
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.FileSystem;
|
||||||
|
|
||||||
namespace OpenRA.Graphics
|
namespace OpenRA.Graphics
|
||||||
{
|
{
|
||||||
@@ -24,17 +25,19 @@ namespace OpenRA.Graphics
|
|||||||
static Dictionary<string, Collection> collections;
|
static Dictionary<string, Collection> collections;
|
||||||
static Dictionary<string, Sheet> cachedSheets;
|
static Dictionary<string, Sheet> cachedSheets;
|
||||||
static Dictionary<string, Dictionary<string, Sprite>> cachedSprites;
|
static Dictionary<string, Dictionary<string, Sprite>> cachedSprites;
|
||||||
|
static IReadOnlyFileSystem fileSystem;
|
||||||
|
|
||||||
public static void Initialize(ModData modData)
|
public static void Initialize(ModData modData)
|
||||||
{
|
{
|
||||||
Deinitialize();
|
Deinitialize();
|
||||||
|
|
||||||
|
fileSystem = modData.DefaultFileSystem;
|
||||||
collections = new Dictionary<string, Collection>();
|
collections = new Dictionary<string, Collection>();
|
||||||
cachedSheets = new Dictionary<string, Sheet>();
|
cachedSheets = new Dictionary<string, Sheet>();
|
||||||
cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();
|
cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();
|
||||||
|
|
||||||
var chrome = MiniYaml.Merge(modData.Manifest.Chrome
|
var chrome = MiniYaml.Merge(modData.Manifest.Chrome
|
||||||
.Select(s => MiniYaml.FromStream(modData.ModFiles.Open(s))));
|
.Select(s => MiniYaml.FromStream(fileSystem.Open(s))));
|
||||||
|
|
||||||
foreach (var c in chrome)
|
foreach (var c in chrome)
|
||||||
LoadCollection(c.Key, c.Value);
|
LoadCollection(c.Key, c.Value);
|
||||||
@@ -107,7 +110,7 @@ namespace OpenRA.Graphics
|
|||||||
sheet = cachedSheets[mi.Src];
|
sheet = cachedSheets[mi.Src];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (var stream = Game.ModData.ModFiles.Open(mi.Src))
|
using (var stream = fileSystem.Open(mi.Src))
|
||||||
sheet = new Sheet(SheetType.BGRA, stream);
|
sheet = new Sheet(SheetType.BGRA, stream);
|
||||||
|
|
||||||
cachedSheets.Add(mi.Src, sheet);
|
cachedSheets.Add(mi.Src, sheet);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
data = new Dictionary<string, string>();
|
data = new Dictionary<string, string>();
|
||||||
var metrics = MiniYaml.Merge(modData.Manifest.ChromeMetrics.Select(
|
var metrics = MiniYaml.Merge(modData.Manifest.ChromeMetrics.Select(
|
||||||
y => MiniYaml.FromStream(modData.ModFiles.Open(y))));
|
y => MiniYaml.FromStream(modData.DefaultFileSystem.Open(y))));
|
||||||
foreach (var m in metrics)
|
foreach (var m in metrics)
|
||||||
foreach (var n in m.Value.Nodes)
|
foreach (var n in m.Value.Nodes)
|
||||||
data[n.Key] = n.Value.Value;
|
data[n.Key] = n.Value.Value;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
this.modData = modData;
|
this.modData = modData;
|
||||||
|
|
||||||
foreach (var file in modData.Manifest.ChromeLayout.Select(a => MiniYaml.FromStream(modData.ModFiles.Open(a))))
|
foreach (var file in modData.Manifest.ChromeLayout.Select(a => MiniYaml.FromStream(modData.DefaultFileSystem.Open(a))))
|
||||||
foreach (var w in file)
|
foreach (var w in file)
|
||||||
{
|
{
|
||||||
var key = w.Key.Substring(w.Key.IndexOf('@') + 1);
|
var key = w.Key.Substring(w.Key.IndexOf('@') + 1);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
r = Game.Renderer;
|
r = Game.Renderer;
|
||||||
if (r == null) return;
|
if (r == null) return;
|
||||||
|
|
||||||
using (var stream = modData.ModFiles.Open(info["Image"]))
|
using (var stream = modData.DefaultFileSystem.Open(info["Image"]))
|
||||||
sheet = new Sheet(SheetType.BGRA, stream);
|
sheet = new Sheet(SheetType.BGRA, stream);
|
||||||
|
|
||||||
var res = r.Resolution;
|
var res = r.Resolution;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
|
|
||||||
if (info.ContainsKey("Image"))
|
if (info.ContainsKey("Image"))
|
||||||
{
|
{
|
||||||
using (var stream = modData.ModFiles.Open(info["Image"]))
|
using (var stream = modData.DefaultFileSystem.Open(info["Image"]))
|
||||||
sheet = new Sheet(SheetType.BGRA, stream);
|
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);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
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 = modData.ModFiles.Open(info["Image"]))
|
using (var stream = modData.DefaultFileSystem.Open(info["Image"]))
|
||||||
{
|
{
|
||||||
var sheet = new Sheet(SheetType.BGRA, stream);
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user