public bool LoadTileSheets() { string[] files = null; try { files = Directory.GetFiles(Constants.Paths.TileDirectory); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Exception while reading directory: " + e.Message); return(false); } if (files != null) { foreach (string file in files) { if (file.EndsWith(".jts", StringComparison.OrdinalIgnoreCase)) { TileSheet newTileSheet = TileSheet.ReadFromFile(file); if (newTileSheet != null) { try { TileContent.Load <Texture2D>(newTileSheet.TextureKey); } catch (ContentLoadException e) { System.Diagnostics.Debug.WriteLine("Error while reading file" + newTileSheet.TextureKey + ": " + e.Message); Exit(); } TileSheets.Add(newTileSheet.TextureKey, newTileSheet); newTileSheet.GetTexture = GetTileSheet; } } } } return(true); }
public void Load(Stream stream) { using (BinaryReader reader = new BinaryReader(stream)) { if (new string(reader.ReadChars(6)) != "tBIN10") { throw new Exception("File is not a tbin file."); } Id = ReadStringAndLength(reader); Description = ReadStringAndLength(reader); Properties = ReadProperties(reader); int count = reader.ReadInt32(); for (int i = 0; i < count; ++i) { TileSheets.Add(ReadTileSheet(reader)); } count = reader.ReadInt32(); for (int i = 0; i < count; ++i) { Layers.Add(ReadLayer(reader)); } } }
// Read all tile sheets from ROM. private void ReadTileSheets(Rom rom) { List <int> addressesPC = new List <int> (); foreach (TileSet t in TileSets) { int address = Tools.LRtoPC(t.SceSheetPtr); if (address != 0) // Skip invalid addresses { addressesPC.Add(address); } } Tools.RemoveDuplicates(addressesPC); TileSheets.Clear(); TileSheets.Add(new CompressedTileSheet()); TileSheets [0].ReadFromROM(rom, TileSheet.CreAddressPC); for (int n = 0; n < addressesPC.Count; n++) { TileSheets.Add(new CompressedTileSheet()); TileSheets [n + 1].ReadFromROM(rom, addressesPC [n]); } }