diff --git a/src/gui/symbol/window.cpp b/src/gui/symbol/window.cpp index 7054e303..79abb4ab 100644 --- a/src/gui/symbol/window.cpp +++ b/src/gui/symbol/window.cpp @@ -26,8 +26,11 @@ SymbolWindow::SymbolWindow(Window* parent) { } SymbolWindow::SymbolWindow(Window* parent, const String& filename) { - // TODO : open file - init(parent, default_symbol()); + // open file + Reader reader(filename); + SymbolP symbol; + reader.handle(symbol); + init(parent, symbol); } SymbolWindow::SymbolWindow(Window* parent, const SymbolValueP& value, const SetP& set) diff --git a/src/gui/symbol/window.hpp b/src/gui/symbol/window.hpp index 7f274d14..74ea6f39 100644 --- a/src/gui/symbol/window.hpp +++ b/src/gui/symbol/window.hpp @@ -27,7 +27,7 @@ class SymbolWindow : public Frame { SymbolWindow(Window* parent); /// Construct a SymbolWindow showing a symbol from a file SymbolWindow(Window* parent, const String& filename); -// /// Construct a SymbolWindow showing a symbol value in a set + /// Construct a SymbolWindow showing a symbol value in a set SymbolWindow(Window* parent, const SymbolValueP& value, const SetP& set); private: diff --git a/src/main.cpp b/src/main.cpp index b55b0501..ab8d7450 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,17 +48,35 @@ bool MSE::OnInit() { packages.init(); settings.read(); the_locale = Locale::byName(settings.locale); - // check for updates check_updates(); - //Window* wnd = new SymbolWindow(nullptr); - //GameP g = Game::byName(_("magic")) - SetP s = new_shared(); - s->open(_("test.mse-set")); - Window* wnd = new SetWindow(nullptr, s); - //Window* wnd = new WelcomeWindow(); - wnd->Show(); + + // interpret command line + if (argc > 1) { + try { + // Command line argument, find its extension + wxFileName f(argv[1]); + if (f.GetExt() == _("mse-symbol")) { + // Show the symbol editor + Window* wnd = new SymbolWindow(nullptr, argv[1]); + wnd->Show(); + return true; + } else if (f.GetExt() == _("mse-set") || f.GetExt() == _("mse") || f.GetExt() == _("set")) { + // Show the set window + Window* wnd = new SetWindow(nullptr, import_set(argv[1])); + wnd->Show(); + return true; + } else { + handle_error(_("Invalid command line argument:\n") + String(argv[1])); + } + } catch (const Error& e) { + handle_error(e); + } + } + + // no command line arguments, or error, show welcome window + (new WelcomeWindow())->Show(); return true; - + } catch (Error e) { handle_error(e, false); } catch (std::exception e) { @@ -67,7 +85,7 @@ bool MSE::OnInit() { } catch (...) { handle_error(InternalError(_("An unexpected exception occurred!")), false); } - packages.destroy(); + OnExit(); return false; }