From 2d63007542a18050471a007b833ba1343f939cd0 Mon Sep 17 00:00:00 2001 From: Laureline David Date: Thu, 13 Aug 2015 21:15:18 +0200 Subject: [PATCH] Batch Processing Added a menu item to process multiple files with the same parameters --- .../src/Tiled2UnityForm.Designer.cs | 14 +++++++++++-- tool/Tiled2Unity/src/Tiled2UnityForm.cs | 20 ++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/tool/Tiled2Unity/src/Tiled2UnityForm.Designer.cs b/tool/Tiled2Unity/src/Tiled2UnityForm.Designer.cs index 3bad132..95e7e42 100644 --- a/tool/Tiled2Unity/src/Tiled2UnityForm.Designer.cs +++ b/tool/Tiled2Unity/src/Tiled2UnityForm.Designer.cs @@ -50,6 +50,7 @@ private void InitializeComponent() this.labelScale = new System.Windows.Forms.Label(); this.textBoxScale = new System.Windows.Forms.TextBox(); this.textBoxExportFolder = new System.Windows.Forms.TextBox(); + this.batchProcessToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip.SuspendLayout(); this.SuspendLayout(); // @@ -134,6 +135,7 @@ private void InitializeComponent() // this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.openTiledFileToolStripMenuItem, + this.batchProcessToolStripMenuItem, this.exitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); @@ -142,14 +144,14 @@ private void InitializeComponent() // openTiledFileToolStripMenuItem // this.openTiledFileToolStripMenuItem.Name = "openTiledFileToolStripMenuItem"; - this.openTiledFileToolStripMenuItem.Size = new System.Drawing.Size(165, 22); + this.openTiledFileToolStripMenuItem.Size = new System.Drawing.Size(199, 22); this.openTiledFileToolStripMenuItem.Text = "&Open Tiled File ..."; this.openTiledFileToolStripMenuItem.Click += new System.EventHandler(this.openTiledFileToolStripMenuItem_Click); // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(165, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(199, 22); this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -255,6 +257,13 @@ private void InitializeComponent() this.textBoxExportFolder.Text = global::Tiled2Unity.Properties.Settings.Default.LastExportDirectory; this.textBoxExportFolder.TextChanged += new System.EventHandler(this.textBoxExportFolder_TextChanged); // + // batchProcessToolStripMenuItem + // + this.batchProcessToolStripMenuItem.Name = "batchProcessToolStripMenuItem"; + this.batchProcessToolStripMenuItem.Size = new System.Drawing.Size(199, 22); + this.batchProcessToolStripMenuItem.Text = "Process Multiple Files ..."; + this.batchProcessToolStripMenuItem.Click += new System.EventHandler(this.batchProcessToolStripMenuItem_Click); + // // Tiled2UnityForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -305,6 +314,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripMenuItem supportTiledMapEditorToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripMenuItem batchProcessToolStripMenuItem; } } diff --git a/tool/Tiled2Unity/src/Tiled2UnityForm.cs b/tool/Tiled2Unity/src/Tiled2UnityForm.cs index c165a3b..a14ccae 100644 --- a/tool/Tiled2Unity/src/Tiled2UnityForm.cs +++ b/tool/Tiled2Unity/src/Tiled2UnityForm.cs @@ -19,7 +19,7 @@ public partial class Tiled2UnityForm : Form private string[] args = null; private TmxMap tmxMap = null; private TiledMapExporter tmxExporter = null; - + private List warnings = new List(); private List errors = new List(); @@ -348,6 +348,24 @@ private void richTextBoxOutput_LinkClicked(object sender, LinkClickedEventArgs e System.Diagnostics.Process.Start(e.LinkText); } + private void batchProcessToolStripMenuItem_Click(object sender, EventArgs e) + { + OpenFileDialog dialog = new OpenFileDialog(); + dialog.InitialDirectory = Properties.Settings.Default.LastOpenDirectory; + dialog.Title = "Open Tiled (*.tmx) File"; + dialog.Filter = "TMX files (*.tmx)|*.tmx"; + dialog.RestoreDirectory = true; + dialog.Multiselect = true; + + if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { + string path = this.textBoxExportFolder.Text; + + foreach (var fileName in dialog.FileNames) { + OpenTmxFile(fileName); + this.tmxExporter.Export(path); + } + } + } } }