Add ISoundLoader
The interface is to be implemented by all sound loaders, just like ISpriteLoader. All loading goes through the interface. This would allow mods to create their own sound loaders outside the engine. Also add a SoundFormats property to mod.yaml, where mods can define what sound loaders they will need. This requires Game.Sound to be initialized after the ModData is loaded.
This commit is contained in:
@@ -25,6 +25,7 @@ namespace OpenRA
|
||||
public readonly ObjectCreator ObjectCreator;
|
||||
public readonly WidgetLoader WidgetLoader;
|
||||
public readonly MapCache MapCache;
|
||||
public readonly ISoundLoader[] SoundLoaders;
|
||||
public readonly ISpriteLoader[] SpriteLoaders;
|
||||
public readonly ISpriteSequenceLoader SpriteSequenceLoader;
|
||||
public readonly RulesetCache RulesetCache;
|
||||
@@ -60,6 +61,18 @@ namespace OpenRA
|
||||
RulesetCache.LoadingProgress += HandleLoadingProgress;
|
||||
MapCache = new MapCache(this);
|
||||
|
||||
var soundLoaders = new List<ISoundLoader>();
|
||||
foreach (var format in Manifest.SoundFormats)
|
||||
{
|
||||
var loader = ObjectCreator.FindType(format + "Loader");
|
||||
if (loader == null || !loader.GetInterfaces().Contains(typeof(ISoundLoader)))
|
||||
throw new InvalidOperationException("Unable to find a sound loader for type '{0}'.".F(format));
|
||||
|
||||
soundLoaders.Add((ISoundLoader)ObjectCreator.CreateBasic(loader));
|
||||
}
|
||||
|
||||
SoundLoaders = soundLoaders.ToArray();
|
||||
|
||||
var spriteLoaders = new List<ISpriteLoader>();
|
||||
foreach (var format in Manifest.SpriteFormats)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user