@@ -66,8 +66,6 @@ wxBEGIN_EVENT_TABLE(Application, wxApp) EVT_TIMER(wxID_ANY, Application::OnSplas
6666
6767 bool Application::OnInit ()
6868{
69- wxApp::OnInit ();
70-
7169 const wxBitmap bitmap (gambitbig_xpm);
7270 m_splashTimer.Start ();
7371 m_splash = new wxSplashScreen (MakeScaledSplashBitmap (bitmap, 0.45 ),
@@ -84,26 +82,19 @@ wxBEGIN_EVENT_TABLE(Application, wxApp) EVT_TIMER(wxID_ANY, Application::OnSplas
8482 wxConfigBase::Get ()->Read (_T (" /General/CurrentDirectory" ), &m_currentDir, _T (" " ));
8583
8684 // Process command line arguments, if any.
87- for (int i = 1 ; i < wxApp:: argc; i++) {
88- const AppLoadResult result = LoadFile (wxApp:: argv[i]);
85+ for (int i = 1 ; i < argc; i++) {
86+ const AppLoadResult result = LoadFile (argv[i], nullptr );
8987 if (result == GBT_APP_OPEN_FAILED) {
90- wxMessageDialog dialog (
91- nullptr , wxT (" Gambit could not open file '" ) + wxApp::argv[i] + wxT (" ' for reading." ),
92- wxT (" Unable to open file" ), wxOK | wxICON_ERROR);
93- dialog.ShowModal ();
88+ wxMessageBox (wxString::Format (_ (" Gambit could not open file for reading:\n %s" ), argv[i]),
89+ _ (" Unable to open file" ), wxOK | wxICON_ERROR, nullptr );
9490 }
9591 else if (result == GBT_APP_PARSE_FAILED) {
96- wxMessageDialog dialog (
97- nullptr , wxT (" File '" ) + wxApp::argv[i] + wxT (" ' is not in a format Gambit recognizes." ),
98- wxT (" Unable to read file" ), wxOK | wxICON_ERROR);
99- dialog.ShowModal ();
92+ wxMessageBox (wxString::Format (_ (" File is not in a format Gambit recognizes:\n %s" ), argv[i]),
93+ _ (" Unable to read file" ), wxOK | wxICON_ERROR, nullptr );
10094 }
10195 }
10296
103- if (m_documents.size () == 0 ) {
104- // If we don't have any game files -- whether because none were
105- // specified on the command line, or because those specified couldn't
106- // be read -- create a default document.
97+ if (m_documents.empty ()) {
10798 const Game efg = NewTree ();
10899 efg->NewPlayer ()->SetLabel (" Player 1" );
109100 efg->NewPlayer ()->SetLabel (" Player 2" );
@@ -140,10 +131,12 @@ void Application::DismissSplash()
140131 m_splash = nullptr ;
141132}
142133
143- AppLoadResult Application::LoadFile (const wxString &p_filename)
134+ AppLoadResult Application::LoadFile (const wxString &p_filename, wxWindow *p_parent )
144135{
145- std::ifstream infile (( const char *) p_filename.mb_str ());
136+ std::ifstream infile (p_filename.mb_str ());
146137 if (!infile.good ()) {
138+ wxMessageBox (_ (" Gambit could not open file for reading:\n " ) + p_filename,
139+ _ (" Unable to open file" ), wxOK | wxICON_ERROR, p_parent);
147140 return GBT_APP_OPEN_FAILED;
148141 }
149142
@@ -155,21 +148,21 @@ AppLoadResult Application::LoadFile(const wxString &p_filename)
155148 (void )new GameFrame (nullptr , doc);
156149 return GBT_APP_FILE_OK;
157150 }
158- else {
159- delete doc;
160- }
151+ delete doc;
161152
162153 try {
163154 const Game nfg = ReadGame (infile);
164155
165156 m_fileHistory.AddFileToHistory (p_filename);
166157 m_fileHistory.Save (*wxConfigBase::Get ());
167158 doc = new GameDocument (nfg);
168- doc->SetFilename (wxT ( " " ) );
159+ doc->SetFilename (" " );
169160 (void )new GameFrame (nullptr , doc);
170161 return GBT_APP_FILE_OK;
171162 }
172163 catch (InvalidFileException &) {
164+ wxMessageBox (_ (" File is not in a format Gambit recognizes:\n " ) + p_filename,
165+ _ (" Unable to read file" ), wxOK | wxICON_ERROR, p_parent);
173166 return GBT_APP_PARSE_FAILED;
174167 }
175168}
0 commit comments