T LoadSound <T>(string filename, MusicInfo m, Func <ISoundFormat, T> loadFormat) { if (!fileSystem.Exists(filename)) { Log.Write("sound", "LoadSound, file does not exist: {0}", filename); return(default(T)); } using (var stream = fileSystem.Open(filename)) { ISoundFormat soundFormat; foreach (var loader in loaders) { stream.Position = 0; if (loader.TryParseSound(stream, out soundFormat, m)) { var source = loadFormat(soundFormat); soundFormat.Dispose(); return(source); } } } throw new InvalidDataException(filename + " is not a valid sound file!"); }
Voxel LoadFile(Pair<string, string> files) { VxlReader vxl; HvaReader hva; using (var s = fileSystem.Open(files.First + ".vxl")) vxl = new VxlReader(s); using (var s = fileSystem.Open(files.Second + ".hva")) hva = new HvaReader(s, files.Second + ".hva"); return new Voxel(this, vxl, hva); }
void CheckMapYaml(Action <string> emitError, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml ruleDefinitions) { if (ruleDefinitions == null) { return; } var files = modData.Manifest.Rules.AsEnumerable(); if (ruleDefinitions.Value != null) { var mapFiles = FieldLoader.GetValue <string[]>("value", ruleDefinitions.Value); files = files.Append(mapFiles); } var nodes = new List <MiniYamlNode>(); foreach (var f in files) { nodes.AddRange(MiniYaml.FromStream(fileSystem.Open(f), f)); } nodes.AddRange(ruleDefinitions.Nodes); Run(emitError, nodes); }
public static bool DefinesUnsafeCustomRules(ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml mapRules, MiniYaml mapWeapons, MiniYaml mapVoices, MiniYaml mapNotifications, MiniYaml mapSequences) { // Maps that define any weapon, voice, notification, or sequence overrides are always flagged if (AnyCustomYaml(mapWeapons) || AnyCustomYaml(mapVoices) || AnyCustomYaml(mapNotifications) || AnyCustomYaml(mapSequences)) { return(true); } // Any trait overrides that aren't explicitly whitelisted are flagged if (mapRules != null) { if (AnyFlaggedTraits(modData, mapRules.Nodes)) { return(true); } if (mapRules.Value != null) { var mapFiles = FieldLoader.GetValue <string[]>("value", mapRules.Value); foreach (var f in mapFiles) { if (AnyFlaggedTraits(modData, MiniYaml.FromStream(fileSystem.Open(f), f))) { return(true); } } } } return(false); }
ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem) { var colors = new uint[Palette.Size]; var mobd = new Mobd(fileSystem.Open(Filename) as SegmentStream, Version.KKND2); var frame = mobd.Animations.FirstOrDefault(a => a.Frames.Length > 0) ?? mobd.HardcodedAnimations.FirstOrDefault(a => a.Frames.Length > 0); var palette = frame.Frames.First().RenderFlags.Palette; // TODO when we have all kknd2 palettes done, remove this. It will simply extract palettes for easier determination of player indices. /*if (Filename != null) { * var bitmap = new Bitmap(palette.Length / 8, 8); * for (var i = 1; i < palette.Length; i++) * bitmap.SetPixel(i % bitmap.Width, i / bitmap.Width, palette[i]); * bitmap.Save(Filename.Substring(8) + ".png"); * bitmap.Dispose(); * }*/ for (var i = 1; i < Math.Min(colors.Length, palette.Length); i++) { colors[i] = palette[i]; } return(new ImmutablePalette(colors)); }
ISoundSource LoadSound(ISoundLoader[] loaders, IReadOnlyFileSystem fileSystem, string filename) { if (!fileSystem.Exists(filename)) { Log.Write("sound", "LoadSound, file does not exist: {0}", filename); return(null); } using (var stream = fileSystem.Open(filename)) { ISoundFormat soundFormat; foreach (var loader in loaders) { stream.Position = 0; if (loader.TryParseSound(stream, out soundFormat)) { var source = soundEngine.AddSoundSourceFromMemory( soundFormat.GetPCMInputStream().ReadAllBytes(), soundFormat.Channels, soundFormat.SampleBits, soundFormat.SampleRate); soundFormat.Dispose(); return(source); } } } throw new InvalidDataException(filename + " is not a valid sound file!"); }
ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem) { var colors = new uint[Palette.Size]; if (fileSystem.Open(this.Filename) is not SegmentStream segmentStream) { return(new(colors)); } var mobd = new Mobd(segmentStream); var frame = mobd.RotationalAnimations.FirstOrDefault(a => a.Frames.Length > 0) ?? mobd.SimpleAnimations.FirstOrDefault(a => a.Frames.Length > 0); if (frame == null) { return(new(colors)); } var palette = frame.Frames.FirstOrDefault()?.RenderFlags.Palette; if (palette == null) { return(new(colors)); } for (var i = 1; i < Math.Min(colors.Length, palette.Length); i++) { colors[i] = palette[i]; } return(new(colors)); }
public static bool DefinesUnsafeCustomRules(ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml mapRules, MiniYaml mapWeapons, MiniYaml mapVoices, MiniYaml mapNotifications, MiniYaml mapSequences) { if (AnyCustomYaml(mapWeapons) || AnyCustomYaml(mapVoices) || AnyCustomYaml(mapNotifications) || AnyCustomYaml(mapSequences)) { return(true); } if (mapRules != null) { if (AnyFlaggedTraits(modData, mapRules.Nodes)) { return(true); } if (mapRules.Value != null) { var mapFiles = FieldLoader.GetValue <string[]>("value", mapRules.Value); foreach (var f in mapFiles) { if (AnyFlaggedTraits(modData, MiniYaml.FromStream(fileSystem.Open(f), f))) { return(true); } } } } return(false); }
public static void Initialize(ModData modData) { if (Initialized) { return; } Deinitialize(); fileSystem = modData.DefaultFileSystem; collections = new Dictionary <string, Collection>(); cachedSheets = new Dictionary <string, Sheet>(); cachedSheets2d = new Dictionary <string, SheetCache>(); cachedSprites = new Dictionary <string, Dictionary <string, Sprite> >(); var chrome = MiniYaml.Merge(modData.Manifest.Chrome .Select(s => MiniYaml.FromStream(fileSystem.Open(s), s))); foreach (var c in chrome) { LoadCollection(c.Key, c.Value); } Initialized = true; }
ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem) { using (var s = fileSystem.Open(Filename)) { s.Seek(56, SeekOrigin.Begin); var cpal = s.ReadASCII(4); if (cpal != "data") { throw new InvalidDataException(); } var something = s.ReadUInt32(); var framePalettes = new List <uint>(); var colors = 256; var paletteData = new Color[colors]; for (var c = 0; c < colors; c++) { var red = s.ReadByte(); var green = s.ReadByte(); var blue = s.ReadByte(); paletteData[c] = Color.FromArgb(red, green, blue); var reserved = s.ReadByte(); // var un = s.ReadUInt32(); // framePalettes[c] = un; } return(new ImmutablePalette(paletteData.Select(d => (uint)d.ToArgb()).ToArray())); } }
ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem) { using (var s = fileSystem.Open(Filename)) { return(PaletteFromDrFile.PaletteFromStream(s, this)); } }
public D2IngameCashCounterLogic(Widget widget, World world, WorldRenderer worldRenderer) { this.world = world; player = world.LocalPlayer; playerResources = player.PlayerActor.Trait <PlayerResources>(); playerResources.AssignDelegates(TakeCash, TakeCash, TakeCash, TakeCash); displayResources = playerResources.Cash + playerResources.Resources; cashLabel = playerResources.Resources.ToString(); displayLabel = cashLabel.F(displayResources); DuneMusic.Init(44100, "", DuneMusic.DuneMusicOplEmu.kOplEmuNuked); IReadOnlyFileSystem fileSystem = Game.ModData.DefaultFileSystem; using (var stream = fileSystem.Open("DUNE1.ADL")) { DuneMusic.InsertMemoryFile("test", stream.ReadAllBytes()); byte[] temp = new byte[1800880]; UIntPtr temp3; temp3 = (UIntPtr)1000000; temp3 = DuneMusic.SynthesizeAudio("test", 52, -1, temp, (UIntPtr)temp.Length); //stclick = new MemoryStream(temp); soundSource = Game.Sound.soundEngine.AddSoundSourceFromMemory(temp, 2, 16, 44100); //ISound temp2 = Game.Sound.soundEngine.Play2D(Game.LocalTick, soundSource, false, true, WPos.Zero, 100, false); } //cash.GetText = () => displayLabel; //cash.GetTooltipText = () => "Silo Usage: {0}/{1}".F(playerResources.Resources, playerResources.ResourceCapacity); }
public static void Initialize(ModData modData) { Deinitialize(); // Load higher resolution images if available on HiDPI displays if (Game.Renderer != null) { dpiScale = Game.Renderer.WindowScale; } fileSystem = modData.DefaultFileSystem; collections = new Dictionary <string, Collection>(); cachedSheets = new Dictionary <string, Pair <Sheet, int> >(); cachedSprites = new Dictionary <string, Dictionary <string, Sprite> >(); cachedPanelSprites = new Dictionary <string, Sprite[]>(); cachedCollectionSheets = new Dictionary <Collection, Pair <Sheet, int> >(); Collections = new ReadOnlyDictionary <string, Collection>(collections); var chrome = MiniYaml.Merge(modData.Manifest.Chrome .Select(s => MiniYaml.FromStream(fileSystem.Open(s), s))); foreach (var c in chrome) { if (!c.Key.StartsWith("^", StringComparison.Ordinal)) { LoadCollection(c.Key, c.Value); } } }
public TileSet(IReadOnlyFileSystem fileSystem, string filePath) { var yaml = MiniYaml.DictFromStream(fileSystem.Open(filePath), filePath); //General Info FieldLoader.Load(this, yaml["General"]); //Terrain Types TerrainInfo = yaml["Terrain"].ToDictionary().Values.Select(y => new TerrainTypeInfo(y)).OrderBy(tt => tt.Type).ToArray(); if (TerrainInfo.Length >= byte.MaxValue) { throw new InvalidOperationException("Too many terrain types."); } for (byte i = 0; i < TerrainInfo.Length; i++) { var tt = TerrainInfo[i].Type; if (terrainIndexByType.ContainsKey(tt)) { throw new InvalidOperationException("Duplicate terrain type '{0}' in '{1}'".F(tt, filePath)); } terrainIndexByType.Add(tt, i); } defaultWalkableTerrainIndex = GetTerrainIndex("Clear"); //Templates Templates = yaml["Templates"].ToDictionary().Values.Select(y => new TerrainTemplateInfo(this, y)).ToDictionary(t => t.Id).AsReadOnly(); }
public static Sprite GetImage(string collectionName, string imageName) { if (string.IsNullOrEmpty(collectionName)) { return(null); } // Cached sprite Dictionary <string, Sprite> cachedCollection; Sprite sprite; if (cachedSprites.TryGetValue(collectionName, out cachedCollection) && cachedCollection.TryGetValue(imageName, out sprite)) { return(sprite); } Collection collection; if (!collections.TryGetValue(collectionName, out collection)) { Log.Write("debug", "Could not find collection '{0}'", collectionName); return(null); } MappedImage mi; if (!collection.Regions.TryGetValue(imageName, out mi)) { return(null); } // Cached sheet Sheet sheet; if (cachedSheets.ContainsKey(mi.Src)) { sheet = cachedSheets[mi.Src]; } else { using (var stream = fileSystem.Open(mi.Src)) sheet = new Sheet(SheetType.BGRA, stream); cachedSheets.Add(mi.Src, sheet); } // Cache the sprite if (cachedCollection == null) { cachedCollection = new Dictionary <string, Sprite>(); cachedSprites.Add(collectionName, cachedCollection); } var image = mi.GetImage(sheet); cachedCollection.Add(imageName, image); return(image); }
ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem) { using (var s = fileSystem.Open(Filename)) { var cpal = s.ReadASCII(4); if (cpal != "CPAL") { throw new InvalidDataException(); } var framePalettes = new List <uint[]>(); var paletteCount = s.ReadUInt32(); for (var p = 0; p < paletteCount; p++) { var ppal = s.ReadASCII(4); if (ppal != "PPAL") { throw new InvalidDataException(); } var offset = s.ReadUInt32(); var head = s.ReadASCII(4); if (head != "head") { throw new InvalidDataException(); } var bytesPerEntry = s.ReadUInt32(); var unknown = s.ReadUInt32(); var data = s.ReadASCII(4); if (data != "data") { throw new InvalidDataException(); } var paletteSize = s.ReadUInt32(); var colors = paletteSize / bytesPerEntry; var paletteData = new Color[colors]; for (var c = 0; c < colors; c++) { var red = s.ReadByte(); var green = s.ReadByte(); var blue = s.ReadByte(); paletteData[c] = Color.FromArgb(red, green, blue); var reserved = s.ReadByte(); } framePalettes.Add(paletteData.Select(d => (uint)d.ToArgb()).ToArray()); } return(new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => (i == TransparentIndex) ? 0 : framePalettes[Number][i]))); } }
void CheckMapYaml(Action<string> emitError, Action<string> emitWarning, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml weaponDefinitions) { if (weaponDefinitions == null) return; var mapFiles = FieldLoader.GetValue<string[]>("value", weaponDefinitions.Value); foreach (var f in mapFiles) CheckWeapons(MiniYaml.FromStream(fileSystem.Open(f), f), emitError, emitWarning, modData); if (weaponDefinitions.Nodes.Any()) CheckWeapons(weaponDefinitions.Nodes, emitError, emitWarning, modData); }
ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem) { var png = new Png(fileSystem.Open(Filename)); var colors = new uint[Palette.Size]; for (var i = 0; i < png.Palette.Length; i++) { colors[i] = (uint)png.Palette[i].ToArgb(); } return(new ImmutablePalette(colors)); }
public static ISpriteFrame[] GetFrames(IReadOnlyFileSystem fileSystem, string filename, ISpriteLoader[] loaders, out TypeDictionary metadata) { using (var stream = fileSystem.Open(filename)) { var spriteFrames = GetFrames(stream, loaders, filename, out metadata); if (spriteFrames == null) { throw new InvalidDataException(filename + " is not a valid sprite file!"); } return(spriteFrames); } }
public static List <MiniYamlNode> Load(IReadOnlyFileSystem fileSystem, IEnumerable <string> files, MiniYaml mapRules) { if (mapRules != null && mapRules.Value != null) { var mapFiles = FieldLoader.GetValue <string[]>("value", mapRules.Value); files = files.Append(mapFiles); } var yaml = files.Select(s => FromStream(fileSystem.Open(s), s)); if (mapRules != null && mapRules.Nodes.Any()) { yaml = yaml.Append(mapRules.Nodes); } return(Merge(yaml)); }
ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem) { var png = new Png(fileSystem.Open(Filename)); if (png.Palette == null) { throw new InvalidOperationException("Unable to load palette `{0}` from non-paletted png `{1}`".F(Name, Filename)); } var colors = new uint[Palette.Size]; for (var i = 0; i < png.Palette.Length; i++) { colors[i] = (uint)png.Palette[i].ToArgb(); } return(new ImmutablePalette(colors)); }
ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem) { var colors = new uint[Palette.Size]; using (var s = fileSystem.Open(Filename)) { for (var i = 0; i < 256; i++) { var r = s.ReadUInt8(); var g = s.ReadUInt8(); var b = s.ReadUInt8(); var a = s.ReadUInt8(); colors[i] = (uint)Color.FromArgb(a == 4 ? 0xff : 0x00, r, g, b).ToArgb(); } } return(new ImmutablePalette(colors)); }
public void SetCustomRules(ModData modData, IReadOnlyFileSystem fileSystem, Dictionary <string, MiniYaml> yaml) { RuleDefinitions = LoadRuleSection(yaml, "Rules"); WeaponDefinitions = LoadRuleSection(yaml, "Weapons"); VoiceDefinitions = LoadRuleSection(yaml, "Voices"); MusicDefinitions = LoadRuleSection(yaml, "Music"); NotificationDefinitions = LoadRuleSection(yaml, "Notifications"); SequenceDefinitions = LoadRuleSection(yaml, "Sequences"); ModelSequenceDefinitions = LoadRuleSection(yaml, "ModelSequences"); try { // PERF: Implement a minimal custom loader for custom world and player actors to minimize loading time // This assumes/enforces that these actor types can only inherit abstract definitions (starting with ^) if (RuleDefinitions != null) { var files = modData.Manifest.Rules.AsEnumerable(); if (RuleDefinitions.Value != null) { var mapFiles = FieldLoader.GetValue <string[]>("value", RuleDefinitions.Value); files = files.Append(mapFiles); } var sources = files.Select(s => MiniYaml.FromStream(fileSystem.Open(s), s).Where(IsLoadableRuleDefinition).ToList()); if (RuleDefinitions.Nodes.Any()) { sources = sources.Append(RuleDefinitions.Nodes.Where(IsLoadableRuleDefinition).ToList()); } var yamlNodes = MiniYaml.Merge(sources); WorldActorInfo = new ActorInfo(modData.ObjectCreator, "world", yamlNodes.First(n => n.Key.ToLowerInvariant() == "world").Value); PlayerActorInfo = new ActorInfo(modData.ObjectCreator, "player", yamlNodes.First(n => n.Key.ToLowerInvariant() == "player").Value); return; } } catch (Exception e) { Log.Write("debug", "Failed to load rules for `{0}` with error: {1}", Title, e.Message); } WorldActorInfo = modData.DefaultRules.Actors[SystemActors.World]; PlayerActorInfo = modData.DefaultRules.Actors[SystemActors.Player]; }
void CheckMapYaml(Action <string> emitError, ModData modData, IReadOnlyFileSystem fileSystem, MiniYaml ruleDefinitions) { if (ruleDefinitions == null) { return; } var mapFiles = FieldLoader.GetValue <string[]>("value", ruleDefinitions.Value); foreach (var f in mapFiles) { CheckActors(MiniYaml.FromStream(fileSystem.Open(f), f), emitError, modData); } if (ruleDefinitions.Nodes.Any()) { CheckActors(ruleDefinitions.Nodes, emitError, modData); } }
static Pair <Sheet, int> SheetForCollection(Collection c) { Pair <Sheet, int> sheetDensity; // Outer cache avoids recalculating image names if (!cachedCollectionSheets.TryGetValue(c, out sheetDensity)) { var image = c.Image; var density = 1; if (dpiScale > 2 && !string.IsNullOrEmpty(c.Image3x)) { image = c.Image3x; density = 3; } else if (dpiScale > 1 && !string.IsNullOrEmpty(c.Image2x)) { image = c.Image2x; density = 2; } // Inner cache makes sure we share sheets between collections if (!cachedSheets.TryGetValue(image, out sheetDensity)) { Sheet sheet; using (var stream = fileSystem.Open(image)) sheet = new Sheet(SheetType.BGRA, stream); sheet.GetTexture().ScaleFilter = TextureScaleFilter.Linear; sheetDensity = Pair.New(sheet, density); cachedSheets.Add(image, sheetDensity); } cachedCollectionSheets.Add(c, sheetDensity); } return(sheetDensity); }
public DefaultTerrain(IReadOnlyFileSystem fileSystem, string filepath) { var yaml = MiniYaml.FromStream(fileSystem.Open(filepath), filepath) .ToDictionary(x => x.Key, x => x.Value); // General info FieldLoader.Load(this, yaml["General"]); // TerrainTypes TerrainInfo = yaml["Terrain"].ToDictionary().Values .Select(y => new TerrainTypeInfo(y)) .OrderBy(tt => tt.Type) .ToArray(); if (TerrainInfo.Length >= byte.MaxValue) { throw new YamlException("Too many terrain types."); } for (byte i = 0; i < TerrainInfo.Length; i++) { var tt = TerrainInfo[i].Type; if (terrainIndexByType.ContainsKey(tt)) { throw new YamlException($"Duplicate terrain type '{tt}' in '{filepath}'."); } terrainIndexByType.Add(tt, i); } defaultWalkableTerrainIndex = GetTerrainIndex("Clear"); // Templates Templates = yaml["Templates"].ToDictionary().Values .Select(y => (TerrainTemplateInfo) new DefaultTerrainTemplateInfo(this, y)).ToDictionary(t => t.Id); }
public static void Initialize(ModData modData) { Deinitialize(); fileSystem = modData.DefaultFileSystem; collections = new Dictionary <string, D2Collection>(); Collections = new ReadOnlyDictionary <string, D2Collection>(collections); cachedCollectionSheets = new Dictionary <D2Collection, Sheet>(); cachedSheets = new Dictionary <string, Sheet>(); cachedSprites = new Dictionary <string, Sprite>(); var chrome = MiniYaml.Merge(modData.Manifest.Chrome .Select(s => MiniYaml.FromStream(fileSystem.Open(s), s))); foreach (var c in chrome) { if (!c.Key.StartsWith("^", StringComparison.Ordinal)) { LoadCollection(c.Key, c.Value); } } }
IEnumerable <MessageContext> GetMessageContext(string language, string[] translations, IReadOnlyFileSystem fileSystem) { var backfall = translations.Where(t => t.EndsWith("en.ftl")); var paths = translations.Where(t => t.EndsWith(language + ".ftl")); foreach (var path in paths.Concat(backfall)) { var stream = fileSystem.Open(path); using (var reader = new StreamReader(stream)) { var options = new MessageContextOptions { UseIsolating = false }; var messageContext = new MessageContext(language, options); var errors = messageContext.AddMessages(reader); foreach (var error in errors) { Log.Write("debug", error.ToString()); } yield return(messageContext); } } }
ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem) { var colors = new uint[Palette.Size]; using (var reader = new BinaryReader(fileSystem.Open(Filename))) { reader.BaseStream.Position = 8; for (var i = 0; i < colors.Length; i++) { var r = reader.ReadByte() << 2; var g = reader.ReadByte() << 2; var b = reader.ReadByte() << 2; colors[i] = (uint)((r << 16) | (g << 8) | (b << 0) | (0xff << 24)); } } if (Filename.EndsWith(".spr")) { colors[0] = 0; } return(new ImmutablePalette(colors)); }
public TileSet(IReadOnlyFileSystem fileSystem, string filepath) { var yaml = MiniYaml.DictFromStream(fileSystem.Open(filepath)); // General info FieldLoader.Load(this, yaml["General"]); // TerrainTypes TerrainInfo = yaml["Terrain"].ToDictionary().Values .Select(y => new TerrainTypeInfo(y)) .OrderBy(tt => tt.Type) .ToArray(); if (TerrainInfo.Length >= byte.MaxValue) throw new InvalidDataException("Too many terrain types."); for (byte i = 0; i < TerrainInfo.Length; i++) { var tt = TerrainInfo[i].Type; if (terrainIndexByType.ContainsKey(tt)) throw new InvalidDataException("Duplicate terrain type '{0}' in '{1}'.".F(tt, filepath)); terrainIndexByType.Add(tt, i); } defaultWalkableTerrainIndex = GetTerrainIndex("Clear"); // Templates Templates = yaml["Templates"].ToDictionary().Values .Select(y => new TerrainTemplateInfo(this, y)).ToDictionary(t => t.Id).AsReadOnly(); }
public static ISpriteFrame[] GetFrames(IReadOnlyFileSystem fileSystem, string filename, ISpriteLoader[] loaders) { using (var stream = fileSystem.Open(filename)) { var spriteFrames = GetFrames(stream, loaders); if (spriteFrames == null) throw new InvalidDataException(filename + " is not a valid sprite file!"); return spriteFrames; } }
public static void Initialize(ModData modData) { Deinitialize(); fileSystem = modData.DefaultFileSystem; collections = new Dictionary<string, Collection>(); cachedSheets = new Dictionary<string, Sheet>(); cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>(); var chrome = MiniYaml.Merge(modData.Manifest.Chrome .Select(s => MiniYaml.FromStream(fileSystem.Open(s), s))); foreach (var c in chrome) LoadCollection(c.Key, c.Value); }
ISoundSource LoadSound(ISoundLoader[] loaders, IReadOnlyFileSystem fileSystem, string filename) { if (!fileSystem.Exists(filename)) { Log.Write("sound", "LoadSound, file does not exist: {0}", filename); return null; } using (var stream = fileSystem.Open(filename)) { ISoundFormat soundFormat; foreach (var loader in Game.ModData.SoundLoaders) { stream.Position = 0; if (loader.TryParseSound(stream, out soundFormat)) return soundEngine.AddSoundSourceFromMemory( soundFormat.GetPCMInputStream().ReadAllBytes(), soundFormat.Channels, soundFormat.SampleBits, soundFormat.SampleRate); } } throw new InvalidDataException(filename + " is not a valid sound file!"); }
ImmutablePalette IProvidesCursorPaletteInfo.ReadPalette(IReadOnlyFileSystem fileSystem) { return(new ImmutablePalette(fileSystem.Open(Filename), ShadowIndex)); }