Skip to content

Commit 3d51c0b

Browse files
committed
Use IFileSystemLoader for remaster content.
1 parent b5addb9 commit 3d51c0b

9 files changed

+110
-640
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#region Copyright & License Information
2+
/*
3+
* Copyright (c) The OpenRA Developers and Contributors
4+
* This file is part of OpenRA, which is free software. It is made
5+
* available to you under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation, either version 3 of
7+
* the License, or (at your option) any later version. For more
8+
* information, see COPYING.
9+
*/
10+
#endregion
11+
12+
using System.Collections.Generic;
13+
using System.IO;
14+
using System.Linq;
15+
using OpenRA.Mods.Common.FileSystem;
16+
using OpenRA.Mods.Common.Installer;
17+
18+
namespace OpenRA.Mods.Mobius.FileSystem
19+
{
20+
public class RemasterFileSystemLoader : IFileSystemLoader, IFileSystemExternalContent
21+
{
22+
[FieldLoader.Require]
23+
public readonly string RemasterDataMount = null;
24+
public readonly string InstallPromptMod = "cnccontent";
25+
public readonly Dictionary<string, string> Packages = null;
26+
public readonly Dictionary<string, string> RemasterPackages = null;
27+
28+
[FieldLoader.LoadUsing(nameof(LoadSources))]
29+
readonly Dictionary<string, ModContent.ModSource> sources = null;
30+
31+
static object LoadSources(MiniYaml yaml)
32+
{
33+
var ret = new Dictionary<string, ModContent.ModSource>();
34+
var sourcesNode = yaml.Nodes.Single(n => n.Key == "Sources");
35+
foreach (var s in sourcesNode.Value.Nodes)
36+
ret.Add(s.Key, new ModContent.ModSource(s.Value, null));
37+
38+
return ret;
39+
}
40+
41+
bool contentAvailable = true;
42+
43+
public void Mount(OpenRA.FileSystem.FileSystem fileSystem, ObjectCreator objectCreator)
44+
{
45+
if (Packages != null)
46+
foreach (var kv in Packages)
47+
fileSystem.Mount(kv.Key, kv.Value);
48+
49+
if (RemasterPackages == null)
50+
return;
51+
52+
foreach (var kv in sources)
53+
{
54+
var sourceResolver = objectCreator.CreateObject<ISourceResolver>($"{kv.Value.Type.Value}SourceResolver");
55+
var path = sourceResolver.FindSourcePath(kv.Value);
56+
if (path != null)
57+
{
58+
var dataPath = Path.Combine(path, "Data");
59+
if (!Directory.Exists(dataPath))
60+
{
61+
contentAvailable = false;
62+
continue;
63+
}
64+
65+
fileSystem.Mount(dataPath, RemasterDataMount);
66+
foreach (var p in RemasterPackages)
67+
{
68+
var package = fileSystem.OpenPackage(p.Key);
69+
if (package == null)
70+
{
71+
contentAvailable = false;
72+
continue;
73+
}
74+
75+
fileSystem.Mount(package, p.Value);
76+
}
77+
}
78+
}
79+
}
80+
81+
bool IFileSystemExternalContent.InstallContentIfRequired(ModData modData)
82+
{
83+
if (!contentAvailable)
84+
Game.InitializeMod(InstallPromptMod, new Arguments());
85+
86+
return !contentAvailable;
87+
}
88+
}
89+
}

OpenRA.Mods.Mobius/RemasterLoadScreen.cs

-27
This file was deleted.

OpenRA.Mods.Mobius/RemasterPackages.cs

-74
This file was deleted.

OpenRA.Mods.Mobius/UtilityCommands/RemasterCheckMissingSprites.cs

-91
This file was deleted.

OpenRA.Mods.Mobius/UtilityCommands/RemasterDumpSequenceSheetsCommand.cs

-77
This file was deleted.

0 commit comments

Comments
 (0)