// Scripting main static void Main(string[] args) { SetCulture(); // Default options Program.Scale = 1.0f; Program.TexelBias = DefaultTexelBias; Program.Verbose = false; Program.Help = false; Program.TmxPath = ""; Program.ExportUnityProjectDir = ""; bool success = ParseOptions(args); if (success && !Program.Help) { if (String.IsNullOrEmpty(Program.ExportUnityProjectDir)) { Console.Error.WriteLine("UNITYDIR is missing!"); PrintHelp(); return; } // We should have everyting we need to export a TMX file to a Unity project TmxMap tmxMap = TmxMap.LoadFromFile(Program.TmxPath); TiledMapExporter tiledMapExporter = new TiledMapExporter(tmxMap); tiledMapExporter.Export(Program.ExportUnityProjectDir); } }
private void OpenTmxFile(string tmxPath) { this.warnings.Clear(); this.errors.Clear(); this.buttonFolderBrowser.Enabled = false; this.buttonViewer.Enabled = false; this.buttonExport.Enabled = false; try { this.tmxMap = TmxMap.LoadFromFile(tmxPath); this.tmxExporter = new TiledMapExporter(this.tmxMap); CheckExportButton(); ReportSummary(); } catch (TmxException tmx) { Program.WriteError(tmx.Message); } }
private void OpenTmxFile(string tmxPath) { this.warnings.Clear(); this.errors.Clear(); this.buttonFolderBrowser.Enabled = false; this.buttonViewer.Enabled = false; this.buttonExport.Enabled = false; try { // Load the TMX file and its dependencies, including the Object Type Xml file used. this.tmxMap = TmxMap.LoadFromFile(tmxPath); this.tmxMap.LoadObjectTypeXml(Program.ObjectTypeXml); this.tmxExporter = new TiledMapExporter(this.tmxMap); CheckExportButton(); ReportSummary("Compilation complete"); } catch (TmxException tmx) { Program.WriteError(tmx.Message); } }
// Scripting main static void Main(string[] args) { SetCulture(); // Listen to any success, warning, and error messages. Give a report when finished. List <string> errors = new List <string>(); Action <string> funcError = delegate(string line) { errors.Add(line); }; List <string> warnings = new List <string>(); Action <string> funcWaring = delegate(string line) { warnings.Add(line); }; List <string> successes = new List <string>(); Action <string> funcSuccess = delegate(string line) { successes.Add(line); }; // Temporarily capture output while exporting Program.OnWriteError += new Program.WriteErrorDelegate(funcError); Program.OnWriteWarning += new Program.WriteWarningDelegate(funcWaring); Program.OnWriteSuccess += new Program.WriteSuccessDelegate(funcSuccess); // Default options Program.Scale = 1.0f; Program.PreferConvexPolygons = false; Program.TexelBias = DefaultTexelBias; Program.Verbose = false; Program.Help = false; Program.TmxPath = ""; Program.ExportUnityProjectDir = ""; bool success = ParseOptions(args); if (success && !Program.Help) { if (String.IsNullOrEmpty(Program.ExportUnityProjectDir)) { Console.Error.WriteLine("UNITYDIR is missing!"); PrintHelp(); return; } // We should have everyting we need to export a TMX file to a Unity project TmxMap tmxMap = TmxMap.LoadFromFile(Program.TmxPath); tmxMap.LoadObjectTypeXml(Program.ObjectTypeXml); TiledMapExporter tiledMapExporter = new TiledMapExporter(tmxMap); tiledMapExporter.Export(Program.ExportUnityProjectDir); // Write a summary that repeats warnings and errors Console.WriteLine("----------------------------------------"); Console.WriteLine("Export completed"); foreach (string msg in successes) { Console.WriteLine(msg); } Console.WriteLine("Warnings: {0}", warnings.Count); foreach (string warning in warnings) { Console.WriteLine(warning); } Console.Error.WriteLine("Errors: {0}\n", errors.Count); foreach (string error in errors) { Console.WriteLine(error); } Console.WriteLine("----------------------------------------"); } }