private void button5_Click(object sender, EventArgs e) { if (button5.Text == @"Start dumping all zone.obj file navmeshes") { button5.Text = @"Stop dumping all zone.obj file navmeshes"; Thread.Sleep(100); if (DumpMeshes.IsBusy) { DumpMeshes.CancelAsync(); } else { DumpMeshes.RunWorkerAsync(); } Logger.AddDebugText(rtbDebug, @"Dumping all zone.obj file navmeshes = True"); } else if (button5.Text == @"Stop dumping all zone.obj file navmeshes") { Logger.AddDebugText(rtbDebug, @"Dumping all zone.obj file navmeshes = false, Finishing off Current build."); DumpMeshes.CancelAsync(); NavBuilder.DumpingMesh = false; NavBuilder.UnloadMeshBuilder(); Thread.Sleep(200); button5.Text = @"Start dumping all zone.obj file navmeshes"; Thread.Sleep(200); } }
/// <summary> /// Handles the RunWorkerCompleted event of the DumpMeshes control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e"> /// The <see cref="System.ComponentModel.RunWorkerCompletedEventArgs"/> instance containing /// the event data. /// </param> private void DumpMeshes_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { Character.Logger.AddDebugText(rtbDebug, string.Format(@"No zone.obj files to dump meshes for, lets stop background worker.")); button5.Text = "Start dumping all zone.obj file navmeshes"; Thread.Sleep(200); DumpMeshes.CancelAsync(); }
/// <summary> /// Handles the Click event of the button5 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void button5_Click(object sender, EventArgs e) { if (button5.Text == "Start dumping all zone.obj file navmeshes" && !DumpMeshes.IsBusy) { button5.Text = "Stop dumping all zone.obj file navmeshes"; Thread.Sleep(100); DumpMeshes.RunWorkerAsync(); } else if (button5.Text == "Stop dumping all zone.obj file navmeshes") { DumpMeshes.CancelAsync(); Thread.Sleep(200); button5.Text = "Start dumping all zone.obj file navmeshes"; Thread.Sleep(200); } else if (button5.Text == "Stop dumping all zone.obj file navmeshes" && DumpMeshes.IsBusy) { DumpMeshes.CancelAsync(); Thread.Sleep(200); button5.Text = "Start dumping all zone.obj file navmeshes"; Thread.Sleep(200); } }
private void button3_Click(object sender, EventArgs e) { var openDialog = new OpenFileDialog(); var path = string.Format(Application.StartupPath + "\\Map Collision obj files\\"); openDialog.InitialDirectory = path; openDialog.FilterIndex = 0; if (openDialog.ShowDialog() != DialogResult.OK) { return; } var zoneFilename = openDialog.FileName; Logger.AddDebugText(rtbDebug, $@"Obj File Selected = {zoneFilename}"); try { var stopWatch = new Stopwatch(); var result = Path.GetFileName(zoneFilename); var result2 = result.Substring(0, result.LastIndexOf(".", StringComparison.Ordinal) + 1); if (File.Exists($@"{Application.StartupPath}\\Dumped NavMeshes\\{result2}nav")) { var box = MessageBox.Show($@"Are you sure you want to overwrite {result2}.nav", @"Question", MessageBoxButtons.YesNoCancel); if (box == DialogResult.Yes) { Logger.AddDebugText(rtbDebug, $@"Dumping NavMesh for {result}"); Thread.Sleep(100); if (!NavBuilder.DumpingMesh) { stopWatch.Start(); NavBuilder.Dump_NavMesh(zoneFilename); stopWatch.Stop(); var ts2 = stopWatch.Elapsed; // Format and display the TimeSpan value. var elapsedTime2 = $"{ts2.Hours:00}:{ts2.Minutes:00}:{ts2.Seconds:00}.{ts2.Milliseconds / 10:00}"; Logger.AddDebugText(rtbDebug, string.Format(@"Time Taken to dump mesh = " + elapsedTime2)); } } else if (box == DialogResult.Cancel) { DumpMeshes.CancelAsync(); return; } else if (box == DialogResult.No) { return; } } if (File.Exists($@"{Application.StartupPath}\\Dumped NavMeshes\\{result2}nav")) { return; } stopWatch.Start(); Logger.AddDebugText(rtbDebug, $@"Dumping NavMesh for {zoneFilename}"); NavBuilder.Dump_NavMesh(zoneFilename); stopWatch.Stop(); var ts = stopWatch.Elapsed; // Format and display the TimeSpan value. var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds / 10:00}"; Logger.AddDebugText(rtbDebug, $@"Finished dumping NavMesh for {zoneFilename}"); Logger.AddDebugText(rtbDebug, string.Format(@"Time Taken to dump NavMesh = " + elapsedTime)); } catch (Exception ex) { Logger.AddDebugText(rtbDebug, string.Format(ex.ToString())); } }
private void DumpMeshes_DoWork(object sender, DoWorkEventArgs e) { try { var stopWatch1 = new Stopwatch(); stopWatch1.Start(); while (!DumpMeshes.CancellationPending) { if (DumpMeshes.CancellationPending) { e.Cancel = true; break; } var path = $"{Application.StartupPath}\\Map Collision obj files\\"; var fileCount = Directory.GetFiles(path, "*.obj", SearchOption.AllDirectories).Length; Logger.AddDebugText(rtbDebug, $@"{fileCount.ToString()}.obj files fould in Map Collision obj folder"); foreach (var file in Directory.EnumerateFiles(string.Format(path, "*.obj"))) { if (DumpMeshes.CancellationPending) { button5.BeginInvoke(new MethodInvoker(() => { button5.Text = @"Start dumping all zone.obj file navmeshes"; })); e.Cancel = true; break; } var result = Path.GetFileName(file); var result2 = result.Substring(0, result.LastIndexOf(".", StringComparison.Ordinal) + 1); if (File.Exists($@"{Application.StartupPath}\\Dumped NavMeshes\\{result2}nav")) { var box = MessageBox.Show($@"Are you sure you want to overwrite {result2}.nav", @"Question", MessageBoxButtons.YesNoCancel); if (box == DialogResult.Yes) { if (!NavBuilder.DumpingMesh && !DumpMeshes.CancellationPending) { var stopWatch = new Stopwatch(); stopWatch.Start(); Logger.AddDebugText(rtbDebug, $@"Dumping NavMesh for {result2}"); if (NavBuilder.Dump_NavMesh(file) && !DumpMeshes.CancellationPending) { stopWatch.Stop(); NavBuilder.UnloadMeshBuilder(); var ts = stopWatch.Elapsed; // Format and display the TimeSpan value. var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds / 10:00}"; Logger.AddDebugText(rtbDebug, $@"Time Taken to dump mesh {result2} = {elapsedTime} "); } } } else if (box == DialogResult.Cancel) { button5.BeginInvoke(new MethodInvoker(() => { button5.Text = @"Start dumping all zone.obj file navmeshes"; })); DumpMeshes.CancelAsync(); break; } else if (box == DialogResult.No) { continue; } } if (!File.Exists($@"{Application.StartupPath}\\Dumped NavMeshes\\{result2}nav")) { if (!NavBuilder.DumpingMesh && !DumpMeshes.CancellationPending) { var stopWatch = new Stopwatch(); stopWatch.Start(); Logger.AddDebugText(rtbDebug, $@"Dumping NavMesh for {result2}"); if (NavBuilder.Dump_NavMesh(file) && !DumpMeshes.CancellationPending) { stopWatch.Stop(); NavBuilder.UnloadMeshBuilder(); var ts = stopWatch.Elapsed; // Format and display the TimeSpan value. var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds / 10:00}"; Logger.AddDebugText(rtbDebug, $@"Time Taken to dump mesh {result2} = {elapsedTime} "); } } } if (DumpMeshes.CancellationPending) { button5.BeginInvoke(new MethodInvoker(() => { button5.Text = @"Start dumping all zone.obj file navmeshes"; })); e.Cancel = true; break; } } stopWatch1.Stop(); var ts1 = stopWatch1.Elapsed; var elapsedTime1 = $"{ts1.Hours:00}:{ts1.Minutes:00}:{ts1.Seconds:00}.{ts1.Milliseconds / 10:00}"; Logger.AddDebugText(rtbDebug, @"Finished dumping NavMesh data"); Logger.AddDebugText(rtbDebug, string.Format(@"Time Taken to dump all zones NavMeshes = " + elapsedTime1)); var dInfo = new DirectoryInfo($@"{Application.StartupPath}\Dumped NavMeshes\"); var sizeOfDir = DirectorySize(dInfo, true); Logger.AddDebugText(rtbDebug, $@"NavMeshes data disk space used = {(double)sizeOfDir / (1024 * 1024):N2} MB"); button5.BeginInvoke(new MethodInvoker(() => { button5.Text = @"Start dumping all zone.obj file navmeshes"; })); progressBar1.Enabled = false; progressBar1.Visible = false; DumpMeshes.CancelAsync(); return; } } catch (Exception es) { Logger.AddDebugText(rtbDebug, es.ToString()); } }
/// <summary> /// Handles the DoWork event of the DumpMeshes control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e"> /// The <see cref="System.ComponentModel.DoWorkEventArgs"/> instance containing the event data. /// </param> private void DumpMeshes_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { try { { while (!DumpMeshes.CancellationPending) { string path = string.Format("{0}\\Map Collision obj\\", Application.StartupPath); int fileCount = Directory.GetFiles(path, "*.obj", SearchOption.AllDirectories).Length; Character.Logger.AddDebugText(rtbDebug, string.Format(@"{0}.obj files fould in Map Collision obj folder", fileCount.ToString())); foreach (var file in Directory.EnumerateFiles(string.Format(path, "*.obj"))) { string result; result = Path.GetFileName(file); string result2 = result.Substring(0, result.LastIndexOf(".") + 1); if (File.Exists(string.Format(@"{0}\\Dumped NavMeshes\\{1}nav", Application.StartupPath, result2))) { if (MessageBox.Show(string.Format(@"Are you sure you want to overwrite {0}.nav", result2.ToString()), "Alert", MessageBoxButtons.YesNo) == DialogResult.Yes) { Character.Logger.AddDebugText(rtbDebug, string.Format(@"Dumping NavMesh for {0}", result)); Thread.Sleep(100); if (!Character.FFxiNAV.DumpingMesh) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); Character.FFxiNAV.Dump_NavMesh(file); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Character.Logger.AddDebugText(rtbDebug, string.Format(@"Time Taken to dump mesh = " + elapsedTime)); } } } if (!File.Exists(string.Format(@"{0}\\Dumped NavMeshes\\{1}nav", Application.StartupPath, result2))) { Character.Logger.AddDebugText(rtbDebug, string.Format(@"Dumping NavMesh for {0}", result)); Thread.Sleep(100); if (!Character.FFxiNAV.DumpingMesh) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); Character.FFxiNAV.Dump_NavMesh(file); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Character.Logger.AddDebugText(rtbDebug, string.Format(@"Time Taken to dump mesh = " + elapsedTime)); } } } DumpMeshes.CancelAsync(); } } } catch (Exception es) { Character.Logger.AddDebugText(rtbDebug, es.ToString()); } }