public void OnCDNSearchDone(object sender, EventArgs args) { CDNScanDoneArgs scanResult = (CDNScanDoneArgs)args; if (cdnWindow != null) { EventManager.CDNScanDone -= OnCDNSearchDone; cdnWindow.Close(); cdnWindow = null; } if (scanResult.BestHost != null) { Program.Settings.RemoteHost = scanResult.BestHost; Program.Settings.RemoteHostPath = scanResult.HostPath; Program.Settings.ShowSourceSelector = false; Program.Settings.UseRemote = selectedDirectory == null; Program.Settings.WoWDirectory = selectedDirectory; Program.Settings.Persist(); selectionDone = true; DeferToParent(); } else { Alert.Show("Unable to locate a responsive CDN server. Ensure you are connected to the internet and that the Blizzard servers are not under maintenance, then try again. Otherwise, use a different data source method."); } }
private void OnCASCLoadDone(object sender, EventArgs e) { EventManager.CASCLoadDone -= OnCASCLoadDone; if (loadingWindow != null) { loadingWindow.Close(); loadingWindow = null; } if (!((CASCLoadDoneArgs)e).Success) throw new Exception("CASC engine blew up."); UpdateRemoteVersionsField(); }
private void OnFileExtractComplete(object sender, EventArgs rawArgs) { FileExtractCompleteArgs args = (FileExtractCompleteArgs)rawArgs; if (args.RunnerID == runnerID) { extractRunner = null; loadingWindow.Close(); loadingWindow = null; if (args.Success) ShowDBCFile(Path.Combine(Constants.TEMP_DIRECTORY, args.File.FullName)); else throw new Exception("Unable to extract DBC file -> " + args.File.FullName); } }
private void UI_SourceOptions_Done_Click(object sender, EventArgs e) { bool useRemote = UI_SourceOption_Remote.Checked; if (useRemote) { selectedDirectory = null; EventManager.CDNScanDone += OnCDNSearchDone; new RunnerCDNCheck().Begin(); cdnWindow = new LoadingWindow("C'Thun is searching for the closest Blizzard server to you!", "Did you know: Poking an Old God with a stick will result in rapid death."); cdnWindow.ShowDialog(); } else { string selectedDirectory = UI_DirectoryField.Text; // Ensure the user didn't leave the field "blank". if (selectedDirectory == string.Empty || selectedDirectory == Constants.DIRECTORY_PLACEHOLDER || selectedDirectory == null) { ShowBalloon("There must always be, a Lich K-- .. I mean, this can't be blank!", UI_DirectorySelectButton); return; } // Ensure the given directory actually exists. if (!Directory.Exists(selectedDirectory)) { ShowBalloon("The directory you selected could not be found, even by Brann Bronzebeard!", UI_DirectorySelectButton); return; } // Rough check to see if we picked a valid installation. string buildFile = Path.Combine(selectedDirectory, Constants.WOW_BUILD_FILE); if (!File.Exists(buildFile)) { ShowBalloon("That does not appear to be a valid World of Warcraft installation..", UI_DirectorySelectButton); return; } this.selectedDirectory = selectedDirectory; // We need a valid CDN even for the local installation. EventManager.CDNScanDone += OnCDNSearchDone; new RunnerCDNCheck().Begin(); cdnWindow = new LoadingWindow("C'Thun is checking your local installation!", "Did you know: Shgla'yos plahf mh'naus."); cdnWindow.ShowDialog(); } }
private void BeginMapExport(string fileName) { // Calculate which tiles we want (map viewer -> ADT) List<Point> points = new List<Point>(); Point mapPoint = mapStartPoints[selectedMapName]; foreach (Point point in overlay.Points) points.Add(new Point(mapPoint.X + (point.X / 256), mapPoint.Y + (point.Y / 256))); exportRunner = new RunnerMapExport(selectedMapName, fileName, points); exportRunner.Begin(); loadingWindow = new LoadingWindow(string.Format("Exporting {0}...", selectedMapName), "Depending on map size, this may take a while.", true, exportCancelCallback); loadingWindow.ShowDialog(); }
private void UI_ExportImageButton_Click(object sender, EventArgs e) { if (selectedMapName == null) { UI_ExportImageButton.Enabled = false; return; } UI_SaveDialog.Filter = "Portal Network Graphics (*.png)|*.png"; UI_SaveDialog.FileName = selectedMapName + ".png"; if (UI_SaveDialog.ShowDialog() == DialogResult.OK) { imageExportRunner = new RunnerExport2DMap(UI_SaveDialog.FileName, canvas); imageExportRunner.Begin(); loadingWindow = new LoadingWindow(string.Format("Exporting {0} as a 2D image...", selectedMapName), "This probably won't take too long!", true, imageExportCancelCallback); loadingWindow.ShowDialog(); } }
private void CloseLoadingWindow() { if (loadingWindow != null) { if (!loadingWindow.IsDisposed && loadingWindow.Visible) loadingWindow.Close(); loadingWindow = null; } }
private void UI_FileList_AfterSelect(object sender, TreeViewEventArgs e) { if (UI_FileList.SelectedNode != null && UI_FileList.SelectedNode.Tag is CASCFile) { selectedFile = null; selectedDbcFile = null; CASCFile cascFile = (CASCFile)UI_FileList.SelectedNode.Tag; string tempPath = Path.Combine(Constants.TEMP_DIRECTORY, cascFile.FullName); selectedFile = cascFile; if (!File.Exists(tempPath)) { extractRunner = new RunnerExtractItem(cascFile); runnerID = extractRunner.runnerID; extractRunner.Begin(); loadingWindow = new LoadingWindow("Loading DBC file: " + cascFile.Name, "Life advice: Avoid dragon's breath.", true, cancelCallback); loadingWindow.ShowDialog(); } else { ShowDBCFile(tempPath); } } }
private void UI_FileList_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode node = UI_FileList.SelectedNode; if (node != null && node.Tag is CASCFile) { CASCFile file = (CASCFile)node.Tag; TerminateRunners(); extractModelFile = null; extractSkinFile = null; selectedFileName = file.Name; string skinFile = skinPattern.Replace(file.FullName, "00.skin"); runner = new RunnerExtractItemUnsafe(file.FullName, skinFile); runner.Begin(); loadingWindow = new LoadingWindow(string.Format("Loading {0} model...", Path.GetFileNameWithoutExtension(selectedFileName)), "Extracting from data source...", true, cancelCallback); loadingWindow.ShowDialog(); } }
private void UI_FileList_AfterSelect(object sender, TreeViewEventArgs e) { if (UI_FileList.SelectedNode != null && UI_FileList.SelectedNode.Tag is CASCFile) { // Dispose current loaded file. if (loadedFile != null) { loadedFile.flush(); loadedFile = null; } TerminateRunners(); CASCFile entry = (CASCFile)UI_FileList.SelectedNode.Tag; string rootBase = Path.GetFileNameWithoutExtension(entry.FullName); currentFiles = new List<CASCFile>(); currentFiles.Add(entry); // Root file. // Collect group files for extraction. if (groupFiles.ContainsKey(rootBase)) foreach (CASCFile groupFile in groupFiles[rootBase]) currentFiles.Add(groupFile); wmoDoneCount = 0; wmoRunner = new RunnerExtractItem(currentFiles.ToArray()); wmoRunner.CacheCheck = true; wmoRunner.Begin(); loadingWindow = new LoadingWindow("Loading WMO file: " + entry.Name, "No peons were harmed in the making of this software.", true, cancelCallback); loadingWindow.ShowDialog(); } }
private void UI_ExportObjButton_Click(object sender, EventArgs e) { UI_ExportSaveDialog.Filter = "WaveFront OBJ (*.obj)|*.obj"; UI_ExportSaveDialog.FileName = Path.GetFileNameWithoutExtension(loadedFile.BaseName) + ".obj"; if (UI_ExportSaveDialog.ShowDialog() == DialogResult.OK) { EventManager.ExportBLPtoPNGComplete += OnExportBLPtoPNGComplete; WaveFrontWriter writer = new WaveFrontWriter(UI_ExportSaveDialog.FileName, texManager); foreach (Mesh mesh in meshes) if (mesh.ShouldRender) writer.addMesh(mesh); writer.Write(); writer.Close(); loadingWindow = new LoadingWindow("Exporting WMO as WaveFront OBJ...", "*Loud disconcerting grinding of cogs*"); loadingWindow.ShowDialog(); } }
private void OnExportBLPtoPNGComplete(object sender, EventArgs e) { ExportBLPtoPNGArgs args = (ExportBLPtoPNGArgs)e; EventManager.ExportBLPtoPNGComplete -= OnExportBLPtoPNGComplete; if (!args.Success) Alert.Show("Unable to export textures!"); loadingWindow.Close(); loadingWindow = null; }
private void CreateWMOMesh() { loadingWindow.Close(); loadingWindow = null; if (loadedFile == null) return; Log.Write("CreateWMOMesh: Created new meshes from WMO data..."); texManager.clear(); // Clear any existing textures from the GL. meshes.Clear(); // Clear existing meshes. UI_MeshList.Items.Clear(); // Load all textures into the texture manager. Chunk_MOTX texChunk = (Chunk_MOTX)loadedFile.getChunk(Chunk_MOTX.Magic); foreach (KeyValuePair<int, string> tex in texChunk.textures.raw()) texManager.addTexture(tex.Key, Path.Combine(Constants.TEMP_DIRECTORY, tex.Value)); Chunk_MOGN nameChunk = (Chunk_MOGN)loadedFile.getChunk(Chunk_MOGN.Magic); // Material register. Chunk_MOMT matChunk = (Chunk_MOMT)loadedFile.getChunk(Chunk_MOMT.Magic); foreach (Chunk_Base rawChunk in loadedFile.getChunksByID(Chunk_MOGP.Magic)) { Chunk_MOGP chunk = (Chunk_MOGP)rawChunk; string meshName = nameChunk.data.get((int)chunk.groupNameIndex); // Skip antiportals. if (meshName.ToLower().Equals("antiportal")) continue; Mesh mesh = new Mesh(meshName); // Populate mesh with vertices. Chunk_MOVT vertChunk = (Chunk_MOVT)chunk.getChunk(Chunk_MOVT.Magic); foreach (Position vertPos in vertChunk.vertices) mesh.addVert(vertPos); // Populate mesh with UVs. Chunk_MOTV uvChunk = (Chunk_MOTV)chunk.getChunk(Chunk_MOTV.Magic); foreach (UV uv in uvChunk.uvData) mesh.addUV(uv); // Populate mesh with normals. Chunk_MONR normChunk = (Chunk_MONR)chunk.getChunk(Chunk_MONR.Magic); foreach (Position norm in normChunk.normals) mesh.addNormal(norm); // Populate mesh with triangles (faces). Chunk_MOVI faceChunk = (Chunk_MOVI)chunk.getChunk(Chunk_MOVI.Magic); Chunk_MOPY faceMatChunk = (Chunk_MOPY)chunk.getChunk(Chunk_MOPY.Magic); for (int i = 0; i < faceChunk.positions.Length; i++) { FacePosition position = faceChunk.positions[i]; FaceInfo info = faceMatChunk.faceInfo[i]; if (info.materialID != 0xFF) // 0xFF (255) identifies a collision face. { Material mat = matChunk.materials[info.materialID]; uint texID = texManager.getTexture((int)mat.texture1.offset); mesh.addFace(texID, mat.texture2.colour, position.point1, position.point2, position.point3); } } Log.Write("CreateWMOMesh: " + mesh.ToAdvancedString()); meshes.Add(mesh); UI_MeshList.Items.Add(mesh); } for (int i = 0; i < UI_MeshList.Items.Count; i++) UI_MeshList.SetItemChecked(i, true); // Reset 3D autoRotate = true; rotationY = 0f; //rotationZ = 0f; zoom = 1f; }
private void CancelExtraction() { TerminateRunners(); if (loadingWindow != null) { if (!loadingWindow.IsDisposed && loadingWindow.Visible) loadingWindow.Close(); loadingWindow = null; } }
private void RebootCASC() { // Delete compiled listfile cache. if (File.Exists(Constants.LIST_FILE_BIN)) File.Delete(Constants.LIST_FILE_BIN); ShouldRebootCASC = false; EventManager.CASCLoadDone += OnCASCLoadDone; new RunnerInitializeCASC().Begin(); loadingWindow = new LoadingWindow("Reinitializing CASC file engine...", "Non-interesting fact: C'Thun does not like cherry ice cream."); loadingWindow.ShowDialog(); }
private void CreateWMOMesh() { loadingWindow.Close(); loadingWindow = null; if (loadedFile == null) { return; } Log.Write("CreateWMOMesh: Created new meshes from WMO data..."); texManager.clear(); // Clear any existing textures from the GL. meshes.Clear(); // Clear existing meshes. UI_MeshList.Items.Clear(); // Load all textures into the texture manager. Chunk_MOTX texChunk = (Chunk_MOTX)loadedFile.getChunk(Chunk_MOTX.Magic); foreach (KeyValuePair <int, string> tex in texChunk.textures.raw()) { texManager.addTexture(tex.Key, Path.Combine(Constants.TEMP_DIRECTORY, tex.Value)); } Chunk_MOGN nameChunk = (Chunk_MOGN)loadedFile.getChunk(Chunk_MOGN.Magic); // Material register. Chunk_MOMT matChunk = (Chunk_MOMT)loadedFile.getChunk(Chunk_MOMT.Magic); foreach (Chunk_Base rawChunk in loadedFile.getChunksByID(Chunk_MOGP.Magic)) { Chunk_MOGP chunk = (Chunk_MOGP)rawChunk; string meshName = nameChunk.data.get((int)chunk.groupNameIndex); // Skip antiportals. if (meshName.ToLower().Equals("antiportal")) { continue; } Mesh mesh = new Mesh(meshName); // Populate mesh with vertices. Chunk_MOVT vertChunk = (Chunk_MOVT)chunk.getChunk(Chunk_MOVT.Magic); foreach (Position vertPos in vertChunk.vertices) { mesh.addVert(vertPos); } // Populate mesh with UVs. Chunk_MOTV uvChunk = (Chunk_MOTV)chunk.getChunk(Chunk_MOTV.Magic); foreach (UV uv in uvChunk.uvData) { mesh.addUV(uv); } // Populate mesh with normals. Chunk_MONR normChunk = (Chunk_MONR)chunk.getChunk(Chunk_MONR.Magic); foreach (Position norm in normChunk.normals) { mesh.addNormal(norm); } // Populate mesh with triangles (faces). Chunk_MOVI faceChunk = (Chunk_MOVI)chunk.getChunk(Chunk_MOVI.Magic); Chunk_MOPY faceMatChunk = (Chunk_MOPY)chunk.getChunk(Chunk_MOPY.Magic); for (int i = 0; i < faceChunk.positions.Length; i++) { FacePosition position = faceChunk.positions[i]; FaceInfo info = faceMatChunk.faceInfo[i]; if (info.materialID != 0xFF) // 0xFF (255) identifies a collision face. { Material mat = matChunk.materials[info.materialID]; uint texID = texManager.getTexture((int)mat.texture1.offset); mesh.addFace(texID, mat.texture2.colour, position.point1, position.point2, position.point3); } } Log.Write("CreateWMOMesh: " + mesh.ToAdvancedString()); meshes.Add(mesh); UI_MeshList.Items.Add(mesh); } for (int i = 0; i < UI_MeshList.Items.Count; i++) { UI_MeshList.SetItemChecked(i, true); } // Reset 3D autoRotate = true; rotationY = 0f; //rotationZ = 0f; zoom = 1f; }