private void LoadFile(string filename) { loaded = false; UseWaitCursor = true; Enabled = false; LevelData.leveltexs = null; cam = new EditorCamera(EditorOptions.RenderDrawDistance); if (LandTable.CheckLevelFile(filename)) { LevelData.geo = LandTable.LoadFromFile(filename); } else { byte[] file = File.ReadAllBytes(filename); if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase)) { file = FraGag.Compression.Prs.Decompress(file); } using (LevelFileDialog dlg = new LevelFileDialog()) { dlg.ShowDialog(this); LevelData.geo = new LandTable(file, (int)dlg.NumericUpDown1.Value, (uint)dlg.numericUpDown2.Value, (LandTableFormat)dlg.comboBox2.SelectedIndex); } } LevelData.ClearLevelItems(); for (int i = 0; i < LevelData.geo.COL.Count; i++) { LevelData.AddLevelItem((new LevelItem(LevelData.geo.COL[i], i, selectedItems))); } LevelData.TextureBitmaps = new Dictionary <string, BMPInfo[]>(); LevelData.Textures = new Dictionary <string, Texture[]>(); using (OpenFileDialog a = new OpenFileDialog() { DefaultExt = "pvm", Filter = "Texture Files|*.pvm;*.gvm;*.prs" }) { if (!string.IsNullOrEmpty(LevelData.geo.TextureFileName)) { a.FileName = LevelData.geo.TextureFileName + ".pvm"; } else { a.FileName = string.Empty; } if (a.ShowDialog(this) == DialogResult.OK) { BMPInfo[] TexBmps = TextureArchive.GetTextures(a.FileName); Texture[] texs = new Texture[TexBmps.Length]; for (int j = 0; j < TexBmps.Length; j++) { texs[j] = TexBmps[j].Image.ToTexture(d3ddevice); } string texname = Path.GetFileNameWithoutExtension(a.FileName); if (!LevelData.TextureBitmaps.ContainsKey(texname)) { LevelData.TextureBitmaps.Add(texname, TexBmps); } if (!LevelData.Textures.ContainsKey(texname)) { LevelData.Textures.Add(texname, texs); } LevelData.leveltexs = texname; } } loaded = true; transformGizmo = new TransformGizmo(); gizmoSpaceComboBox.Enabled = false; gizmoSpaceComboBox.SelectedIndex = 0; clearLevelToolStripMenuItem.Enabled = LevelData.geo != null; calculateAllBoundsToolStripMenuItem.Enabled = LevelData.geo != null; statsToolStripMenuItem.Enabled = LevelData.geo != null; selectedItems.SelectionChanged += SelectionChanged; UseWaitCursor = false; Enabled = editInfoToolStripMenuItem.Enabled = saveToolStripMenuItem.Enabled = exportToolStripMenuItem.Enabled = importToolStripMenuItem.Enabled = true; DrawLevel(); }