public static void ImportExpansionPdb(string strFile) { PdbPacker pdbp = new PdbPacker(strFile); ArrayList alsTileSets = new ArrayList(); for (int i = 0; i < pdbp.Count; i++) { PdbPacker.File file = pdbp[i]; if (!file.str.EndsWith(".lvl")) { continue; } // Load up the pieces Ini ini = Ini.LoadBinary(new MemoryStream(file.ab)); string strTileMapFilename = ini["General"]["TileMap"].Value; TileMap tmap = TileMap.Load(new MemoryStream(pdbp[strTileMapFilename].ab)); // First, tell the active LevelDoc not to switch its templates based on the following // template load LevelDoc lvldActive = (LevelDoc)DocManager.GetActiveDocument(typeof(LevelDoc)); if (lvldActive != null) { lvldActive.SwitchTemplatesEnabled = false; } // If the TileSet for this level is not yet available, load it now TemplateDoc tmpd = (TemplateDoc)DocManager.OpenDocument(tmap.Filename.Replace(".tset", ".tc")); TileSet tset = null; foreach (TileSet tsetT in alsTileSets) { if (tsetT.FileName == tmap.Filename) { tset = tsetT; break; } } if (tset == null) { tset = new TileSet(tmpd, tmap.Filename); alsTileSets.Add(tset); } // Re-enable template switching if (lvldActive != null) { lvldActive.SwitchTemplatesEnabled = true; } // Create a new level description, and deduce which templates are in it, with what visibility LevelDoc lvld = (LevelDoc)DocManager.NewDocument(typeof(LevelDoc), null); lvld.OutputFilename = file.str; ImportTileMap(tmap, tset, tmpd, lvld); // Walls are stored in the terrain map. Load them. string strTrmapFilename = ini["General"]["TerrainMap"].Value; TerrainMap trmap = TerrainMap.Load(new MemoryStream(pdbp[strTrmapFilename].ab)); ImportWalls(trmap, lvld); // Load everything else lvld.LoadIni(ini); } }