private void OnImportMapPath(string path) { string extension = Path.GetExtension(path); switch (extension.ToLower()) { case ".vol": List <string> fileNames = new List <string>(); // Get list of map names from the archive VolFile vol = new VolFile(path); for (int i = 0; i < vol.GetCount(); ++i) { string name = vol.GetName(i); if (Path.GetExtension(name).ToLower() == ".map") { fileNames.Add(name); } } // Open list of map names for selection ListSelectDialog.Create(fileNames, "Select Map", "Import", (string mapName) => OnImportMapSelected(vol, mapName), () => { interactable = true; vol.Dispose(); }); break; default: CreateNew_NoRefresh(); interactable = true; if (UserData.current.ImportMap(path)) { interactable = false; m_MapRenderer.Refresh(() => { interactable = true; Debug.Log("Import Complete."); }); } else { // Import failed interactable = false; m_MapRenderer.Refresh(() => { interactable = true; Debug.LogError("Failed to read map: " + path); }); } break; } }
private void OnImportMapSelected(VolFile volFile, string mapName) { interactable = true; Stream mapStream = volFile.OpenStream(mapName); if (!UserData.current.ImportMap(mapStream)) { Debug.LogError("Failed to read map: " + mapName); volFile.Dispose(); return; } volFile.Dispose(); interactable = false; m_MapRenderer.Refresh(() => { interactable = true; Debug.Log("Import map complete."); }); }