generated from OpenRA/OpenRAModSDK
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
476 additions
and
1,327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#region Copyright & License Information | ||
/* | ||
* Copyright (c) The OpenRA Developers and Contributors | ||
* This file is part of OpenRA, which is free software. It is made | ||
* available to you under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation, either version 3 of | ||
* the License, or (at your option) any later version. For more | ||
* information, see COPYING. | ||
*/ | ||
#endregion | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using OpenRA.Mods.Common; | ||
using OpenRA.Mods.Common.FileSystem; | ||
using OpenRA.Mods.Common.Installer; | ||
|
||
namespace OpenRA.Mods.Mobius.FileSystem | ||
{ | ||
public class RemasterFileSystemLoader : IFileSystemLoader, IFileSystemExternalContent | ||
{ | ||
[FieldLoader.Require] | ||
public readonly string RemasterDataMount = null; | ||
public readonly string InstallPromptMod = "remaster-content"; | ||
public readonly Dictionary<string, string> Packages = null; | ||
public readonly Dictionary<string, string> RemasterPackages = null; | ||
|
||
[FieldLoader.LoadUsing(nameof(LoadSources))] | ||
readonly Dictionary<string, ModContent.ModSource> sources = null; | ||
|
||
static object LoadSources(MiniYaml yaml) | ||
{ | ||
var ret = new Dictionary<string, ModContent.ModSource>(); | ||
var sourcesNode = yaml.Nodes.Single(n => n.Key == "Sources"); | ||
foreach (var s in sourcesNode.Value.Nodes) | ||
ret.Add(s.Key, new ModContent.ModSource(s.Value)); | ||
|
||
return ret; | ||
} | ||
|
||
bool contentAvailable = true; | ||
|
||
public void Mount(OpenRA.FileSystem.FileSystem fileSystem, ObjectCreator objectCreator) | ||
{ | ||
if (Packages != null) | ||
foreach (var kv in Packages) | ||
fileSystem.Mount(kv.Key, kv.Value); | ||
|
||
if (RemasterPackages == null) | ||
return; | ||
|
||
foreach (var kv in sources) | ||
{ | ||
var sourceResolver = objectCreator.CreateObject<ISourceResolver>($"{kv.Value.Type.Value}SourceResolver"); | ||
var path = sourceResolver.FindSourcePath(kv.Value); | ||
if (path != null) | ||
{ | ||
var dataPath = Path.Combine(path, "Data"); | ||
if (!Directory.Exists(dataPath)) | ||
{ | ||
contentAvailable = false; | ||
continue; | ||
} | ||
|
||
fileSystem.Mount(dataPath, RemasterDataMount); | ||
foreach (var p in RemasterPackages) | ||
{ | ||
var package = fileSystem.OpenPackage(p.Key); | ||
if (package == null) | ||
{ | ||
contentAvailable = false; | ||
continue; | ||
} | ||
|
||
fileSystem.Mount(package, p.Value); | ||
} | ||
} | ||
} | ||
} | ||
|
||
bool IFileSystemExternalContent.InstallContentIfRequired(ModData modData) | ||
{ | ||
if (!contentAvailable) | ||
Game.InitializeMod(InstallPromptMod, new Arguments()); | ||
|
||
return !contentAvailable; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.