Remove unnecessary loading mod exceptions, log missing icon.png
This commit is contained in:
@@ -80,7 +80,7 @@ namespace OpenRA
|
||||
mod.Icon = sheetBuilder.Add(bitmap);
|
||||
}
|
||||
|
||||
mods.Add(ExternalMod.MakeKey(mod), mod);
|
||||
mods[ExternalMod.MakeKey(mod)] = mod;
|
||||
}
|
||||
|
||||
internal void Register(Manifest mod)
|
||||
|
||||
@@ -375,7 +375,10 @@ namespace OpenRA
|
||||
ModData = null;
|
||||
|
||||
if (mod == null)
|
||||
throw new InvalidOperationException("Game.Mod argument missing or mod could not be found.");
|
||||
throw new InvalidOperationException("Game.Mod argument missing.");
|
||||
|
||||
if (!Mods.ContainsKey(mod))
|
||||
throw new InvalidOperationException("Unknown or invalid mod '{0}'.".F(mod));
|
||||
|
||||
Console.WriteLine("Loading mod: {0}", mod);
|
||||
|
||||
|
||||
@@ -69,27 +69,39 @@ namespace OpenRA
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
throw new InvalidDataException(path + " is not a valid mod package");
|
||||
{
|
||||
Log.Write("debug", path + " is not a valid mod package");
|
||||
return null;
|
||||
}
|
||||
|
||||
package = new Folder(path);
|
||||
if (!package.Contains("mod.yaml"))
|
||||
throw new InvalidDataException(path + " is not a valid mod package");
|
||||
if (package.Contains("mod.yaml"))
|
||||
{
|
||||
var manifest = new Manifest(id, package);
|
||||
|
||||
if (package.Contains("icon.png"))
|
||||
{
|
||||
using (var stream = package.GetStream("icon.png"))
|
||||
if (stream != null)
|
||||
using (var bitmap = new Bitmap(stream))
|
||||
icons[id] = sheetBuilder.Add(bitmap);
|
||||
|
||||
return new Manifest(id, package);
|
||||
}
|
||||
catch (Exception)
|
||||
else if (!manifest.Metadata.Hidden)
|
||||
Log.Write("debug", "Mod '{0}' is missing 'icon.png'.".F(path));
|
||||
|
||||
return manifest;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Write("debug", "Load mod '{0}': {1}".F(path, e));
|
||||
}
|
||||
|
||||
if (package != null)
|
||||
package.Dispose();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<string, Manifest> GetInstalledMods(IEnumerable<string> searchPaths, IEnumerable<string> explicitPaths)
|
||||
{
|
||||
@@ -100,9 +112,6 @@ namespace OpenRA
|
||||
foreach (var pair in candidates)
|
||||
{
|
||||
var mod = LoadMod(pair.First, pair.Second);
|
||||
|
||||
// Mods in the support directory and oramod packages (which are listed later
|
||||
// in the CandidateMods list) override mods in the main install.
|
||||
if (mod != null)
|
||||
ret[pair.First] = mod;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user