Sprite[] LoadSprites(string filename) { // TODO: Cleanly abstract file type detection if (filename.ToLower().EndsWith("r8")) { var r8 = new R8Reader(FileSystem.Open(filename)); return r8.Select(a => SheetBuilder.Add(a.Image, a.Size, a.Offset)).ToArray(); } BinaryReader reader = new BinaryReader(FileSystem.OpenWithExts(filename, exts)); var ImageCount = reader.ReadUInt16(); if (ImageCount == 0) { var shp = new ShpTSReader(FileSystem.OpenWithExts(filename, exts)); return shp.Select(a => SheetBuilder.Add(a.Image, shp.Size)).ToArray(); } else { var shp = new ShpReader(FileSystem.OpenWithExts(filename, exts)); return shp.Frames.Select(a => SheetBuilder.Add(a.Image, shp.Size)).ToArray(); } }
public void OpenSHP(string filename) { tmPlay.Enabled = false; tbPlay.Enabled = false; cbLoop.Enabled = false; cbLoop.Checked = false; bPNG = false; tbPlay.Value = 1; tbPlay.Maximum = 1; fnum = 1; FileStream F = new FileStream(filename, FileMode.Open, FileAccess.Read); FileStream S = new FileStream(filename, FileMode.Open, FileAccess.Read); BinaryReader rdr = new BinaryReader(S); int ImageCount = rdr.ReadUInt16(); rdr.Close(); S.Close(); if (ImageCount == 0) { shp = new ShpTSReader(F); oldshp = false; } else { shpold = new ShpReader(F); oldshp = true; } Text = sname + sver + " - " + filename; ApplyNewPalette(lastpal); tbPlay.Enabled = true; cbLoop.Enabled = true; }