public static void Main(string[] args) { LispSerializer.SetupSerializers(typeof(Application).Assembly); Gtk.Application.Init(); Application app = new Application(args); #if !INSANEDEBUG try { #endif Gtk.Application.Run(); #if !INSANEDEBUG } catch (Exception e) { if (app.level != null) { string filename = System.IO.Path.GetTempPath() + "/supertux-editor-emergency." + ((app.level.isWorldmap)?"stwm":"stl"); LogManager.Log(LogLevel.Fatal, "Unexpected Exception... Emergency save to '" + filename + "'"); Console.Error.WriteLine(e.Message); app.serializer.Write(filename, app.level); } throw; } #endif Settings.Instance.Save(); }
public static void Main(string[] args) { // FIXME: 2018-10-12 // Temporary workaround to solve incompatibility of mono with ncurses6 // See: https://github.com/mono/mono/issues/6752 System.Environment.SetEnvironmentVariable("TERM", "xterm"); LispSerializer.SetupSerializers(typeof(Application).Assembly); Options opts = ParseArgs(args); if (opts.NoSort) { Sector.SortObjectTags = false; } if (opts.Help) { Console.WriteLine("Usage: supertux-editor.exe [--help|--resave|--no-sort] [FILENAME]..."); Console.WriteLine(); Console.WriteLine("A SuperTux level editor"); Console.WriteLine(); Console.WriteLine(" FILENAME A level or worldmap to load"); Console.WriteLine(" -h, --help Print this help"); Console.WriteLine(" --resave Load a level, save it and exit"); Console.WriteLine(" --no-sort Don't sort object tags"); } else if (opts.Resave) { var failedFiles = new List <string>(); foreach (var fileName in opts.FileNames) { try { ResaveLevel(fileName, fileName); } catch (Exception e) { LogManager.Log(LogLevel.Fatal, $"{fileName}: error while resaving the level:\n{e}"); failedFiles.Add(fileName); } } if (failedFiles.Count > 0) { Console.WriteLine("Files that failed to resave:"); foreach (var fileName in failedFiles) { Console.WriteLine($" {fileName}"); } } } else { Gtk.Application.Init(); Application app = new Application(opts); #if !INSANEDEBUG try { #endif Gtk.Application.Run(); #if !INSANEDEBUG } catch (Exception e) { if (app.level != null) { string filename = System.IO.Path.GetTempPath() + "/supertux-editor-emergency." + ((app.level.isWorldmap)?"stwm":"stl"); LogManager.Log(LogLevel.Fatal, "Unexpected Exception... Emergency save to '" + filename + "'"); Console.Error.WriteLine(e.Message); app.serializer.Write(filename, app.level); } throw; } #endif Settings.Instance.Save(); } }