static void Main(string[] args) { String error = Global.Instance.Initialize(); #if DEBUG if (error != String.Empty) { MessageBox.Show(error); return; } #endif // Initialize Managers try { TileProperties.Initialize(); } catch (Exception ex) { MessageBox.Show("I failed Initilaizing TileProperties: " + ex.Message); } if (TestingFunction() == false) { return; } try { ResourceManager.Instance.Initialize(); } catch (Exception ex) { MessageBox.Show("I failed Initilaizing Resource Manager: " + ex.Message); } try { SettingsManager.Instance.Initialize(); } catch (Exception ex) { MessageBox.Show("I failed Initilaizing Settings Manager: " + ex.Message); } if (args.Length == 0) //started from windows { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormWorldView()); SettingsManager.Instance.Shutdown(); } else { //for (int i = 1; i < args.Length; i += 2) //{ // MessageBox.Show(args[i - 1] + args[i]); //} // See if we are running in Mono and if so do not do the Attach. // Ugly but at least it lets the code run. Type t = Type.GetType("Mono.Runtime"); if (t == null) { AttachConsole(ATTACH_PARENT_PROCESS); } bool show_help = false; string worldPath = string.Empty; string mapPath = string.Empty; string configName = string.Empty; var p = new OptionSet() { { "w|world=", "The path to the {WORLD} to map.", v => worldPath = v }, { "o|output=", "The path to the {OUTPUT} file where the map PNG will be written.", v => mapPath = v }, { "h|help", "Show this message and exit.", v => show_help = v != null }, { "c|config=", "The named UserSettings to use for this run.", v => configName = v } }; List <string> extra = new List <string>(); try { extra = p.Parse(args); } catch (OptionException e) { Console.WriteLine(e.Message); Console.WriteLine("Try '" + System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath) + " --help' for more information."); } if (show_help || args.Contains <string>("-?") || worldPath == string.Empty || mapPath == string.Empty) { Console.WriteLine("Generates a PNG from a Terraria World file (*.wld)."); Console.WriteLine(); Console.WriteLine("Usage:"); Console.WriteLine(" " + System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "NoGui.bat [option1] <path1> [option2] <path2>"); Console.WriteLine(); Console.WriteLine("Options:"); p.WriteOptionDescriptions(Console.Out); Console.WriteLine(); Console.WriteLine("Example:"); Console.WriteLine(); Console.WriteLine(" " + System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "NoGui.bat " + "-w \"C:\\Terraria Worlds\\world1.wld\" -o \"C:\\Terraria Maps\\World 1.png\""); } else if (worldPath == string.Empty || !File.Exists(worldPath)) { Console.WriteLine("The World file could not be found: " + worldPath); } else { if (!string.IsNullOrWhiteSpace(configName)) { SettingsManager.Instance.CurrentSettingsName = configName; } Console.WriteLine(Environment.NewLine + "Generating map from:" + Environment.NewLine + " " + worldPath); WorldMapper mapper = new WorldMapper(); Global.Instance.InConsole = true; #if !DEBUG try { #endif mapper.Initialize(); Console.WriteLine("Reading World file..."); mapper.OpenWorld(); mapper.ProcessWorld(worldPath, null); Console.WriteLine("World file closed. Generating PNG..."); mapper.CreatePreviewPNG(mapPath, null); Console.WriteLine("Done! Saved to: " + Environment.NewLine + " " + mapPath); #if !DEBUG } catch (Exception ex) { Console.WriteLine("Error: " + ex.ToString()); } #endif } } }
private void buttonLoadInformation_Click(object sender, EventArgs e) { if (checkValidPaths(false)) { treeViewChestInformation.ImageList = null; filterCount = SettingsManager.Instance.FilterItemStates.Count; buttonDrawWorld.Enabled = false; groupBoxSelectWorld.Enabled = false; groupBoxImageOutput.Enabled = false; (this.tabPageMarkers as Control).Enabled = false; (this.tabPageWorldInformation as Control).Enabled = false; Point pt = this.Location; pt.X += (this.Size.Width / 2); pt.Y += (this.Size.Height / 2); mapper = new WorldMapper(); mapper.Initialize(); mapperWorker = new BackgroundWorker(); progForm = new FormProgressDialog("Load World Information", false, mapperWorker); mapperWorker.WorkerReportsProgress = true; mapperWorker.WorkerSupportsCancellation = false; mapperWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(progForm.worker_Completed); mapperWorker.ProgressChanged += new ProgressChangedEventHandler(progForm.worker_ProgressChanged); mapperWorker.DoWork += new DoWorkEventHandler(worker_GenerateMap); mapperWorker.RunWorkerAsync(false); progForm.FormClosed += new FormClosedEventHandler(worker_Completed); progForm.Show(this); } }
private void buttonDrawWorld_Click(object sender, EventArgs e) { if (SettingsManager.Instance.FilterChests && !SettingsManager.Instance.DrawMarker("Chest")) { DialogResult markers = MessageBox.Show("You have enabled Chest Filtering but have disabled drawing Chest Markers. " + "No Chests will show up, even if they contain the items you are looking for.\r\n\r\n" + "Would you like to enable Markers for Chests before continuing?", "Chest Markers disabled", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (markers == System.Windows.Forms.DialogResult.Yes) { SettingsManager.Instance.MarkerVisible("Chest", true); markerNodes["Chest"].Checked = true; treeViewMarkerList_updateParentNode(markerNodes["Chest"]); } else if (markers == System.Windows.Forms.DialogResult.Cancel) { return; } } if (SettingsManager.Instance.FilterChests && lstFilteredItems.Items.Count == 0) { DialogResult markers = MessageBox.Show("You have enabled Chest Filtering but have not selected any items. " + "No Chests will show up, even if they are empty.\r\n\r\n" + "Would you like to disable Chest Filtering before continuing?", "Chest Finder list is empty", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (markers == System.Windows.Forms.DialogResult.Yes) { SettingsManager.Instance.FilterChests = false; checkBoxFilterChests.Checked = false; } else if (markers == System.Windows.Forms.DialogResult.Cancel) { return; } } if (checkValidPaths(true)) { if (SettingsManager.Instance.ShowChestTypes) treeViewChestInformation.ImageList = chestImageList; buttonDrawWorld.Enabled = false; filterCount = SettingsManager.Instance.FilterItemStates.Count(); groupBoxSelectWorld.Enabled = false; groupBoxImageOutput.Enabled = false; (this.tabPageMarkers as Control).Enabled = false; (this.tabPageWorldInformation as Control).Enabled = false; Point pt = this.Location; pt.X += (this.Size.Width / 2); pt.Y += (this.Size.Height / 2); mapper = new WorldMapper(); mapper.Initialize(); if (textBoxOutputFile.Text.Substring(textBoxOutputFile.Text.Length - 4).CompareTo(".png") != 0) { textBoxOutputFile.Text += ".png"; } mapperWorker = new BackgroundWorker(); progForm = new FormProgressDialog("Draw World", false, mapperWorker); mapperWorker.WorkerReportsProgress = true; mapperWorker.WorkerSupportsCancellation = true; mapperWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(progForm.worker_Completed); mapperWorker.ProgressChanged += new ProgressChangedEventHandler(progForm.worker_ProgressChanged); mapperWorker.DoWork += new DoWorkEventHandler(worker_GenerateMap); mapperWorker.RunWorkerAsync(true); progForm.FormClosed += new FormClosedEventHandler(worker_Completed); progForm.Show(this); } }
static void Main(string[] args) { String error = Global.Instance.Initialize(); #if DEBUG if (error != String.Empty) { MessageBox.Show(error); return; } #endif // Initialize Managers try { TileProperties.Initialize(); } catch (Exception ex) { MessageBox.Show("I failed Initilaizing TileProperties: " + ex.Message); } if (TestingFunction() == false) return; try { ResourceManager.Instance.Initialize(); } catch (Exception ex) { MessageBox.Show("I failed Initilaizing Resource Manager: " + ex.Message); } try { SettingsManager.Instance.Initialize(); } catch (Exception ex) { MessageBox.Show("I failed Initilaizing Settings Manager: " + ex.Message); } if (args.Length == 0) //started from windows { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormWorldView()); SettingsManager.Instance.Shutdown(); } else { //for (int i = 1; i < args.Length; i += 2) //{ // MessageBox.Show(args[i - 1] + args[i]); //} // See if we are running in Mono and if so do not do the Attach. // Ugly but at least it lets the code run. Type t = Type.GetType("Mono.Runtime"); if (t == null) AttachConsole(ATTACH_PARENT_PROCESS); bool show_help = false; string worldPath = string.Empty; string mapPath = string.Empty; string configName = string.Empty; var p = new OptionSet() { { "w|world=", "The path to the {WORLD} to map.", v => worldPath = v }, { "o|output=", "The path to the {OUTPUT} file where the map PNG will be written.", v => mapPath = v}, { "h|help", "Show this message and exit.", v => show_help = v != null }, { "c|config=", "The named UserSettings to use for this run.", v => configName = v } }; List<string> extra = new List<string>(); try { extra = p.Parse(args); } catch (OptionException e) { Console.WriteLine(e.Message); Console.WriteLine("Try '" + System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath) + " --help' for more information."); } if (show_help || args.Contains<string>("-?") || worldPath == string.Empty || mapPath == string.Empty) { Console.WriteLine("Generates a PNG from a Terraria World file (*.wld)."); Console.WriteLine(); Console.WriteLine("Usage:"); Console.WriteLine(" " + System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "NoGui.bat [option1] <path1> [option2] <path2>"); Console.WriteLine(); Console.WriteLine("Options:"); p.WriteOptionDescriptions(Console.Out); Console.WriteLine(); Console.WriteLine("Example:"); Console.WriteLine(); Console.WriteLine(" " + System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath) + "NoGui.bat " + "-w \"C:\\Terraria Worlds\\world1.wld\" -o \"C:\\Terraria Maps\\World 1.png\""); } else if (worldPath == string.Empty || !File.Exists(worldPath)) { Console.WriteLine("The World file could not be found: " + worldPath); } else { if (!string.IsNullOrWhiteSpace(configName)) { SettingsManager.Instance.CurrentSettingsName = configName; } Console.WriteLine(Environment.NewLine + "Generating map from:" + Environment.NewLine + " " + worldPath); WorldMapper mapper = new WorldMapper(); Global.Instance.InConsole = true; #if !DEBUG try { #endif mapper.Initialize(); Console.WriteLine("Reading World file..."); mapper.OpenWorld(); mapper.ProcessWorld(worldPath, null); Console.WriteLine("World file closed. Generating PNG..."); mapper.CreatePreviewPNG(mapPath, null); Console.WriteLine("Done! Saved to: " + Environment.NewLine + " " + mapPath); #if !DEBUG } catch (Exception ex) { Console.WriteLine("Error: " + ex.ToString()); } #endif } } }