309 { |
311 { |
310 MessageDialog::ShowFatalMessage(HWApplication::tr("Failed to open data directory:\n%1\n\nPlease check your installation!").arg(datadir->absolutePath()+"/Data")); |
312 MessageDialog::ShowFatalMessage(HWApplication::tr("Failed to open data directory:\n%1\n\nPlease check your installation!").arg(datadir->absolutePath()+"/Data")); |
311 return 1; |
313 return 1; |
312 } |
314 } |
313 |
315 |
|
316 bool isProbablyNewPlayer = false; |
|
317 |
314 // setup PhysFS |
318 // setup PhysFS |
315 engine = new FileEngineHandler(argv[0]); |
319 engine = new FileEngineHandler(argv[0]); |
316 engine->mount(datadir->absolutePath()); |
320 engine->mount(datadir->absolutePath()); |
317 engine->mount(cfgdir->absolutePath() + "/Data"); |
321 engine->mount(cfgdir->absolutePath() + "/Data"); |
318 engine->mount(cfgdir->absolutePath()); |
322 engine->mount(cfgdir->absolutePath()); |
322 QTranslator TranslatorHedgewars; |
326 QTranslator TranslatorHedgewars; |
323 QTranslator TranslatorQt; |
327 QTranslator TranslatorQt; |
324 { |
328 { |
325 QSettings settings(DataManager::instance().settingsFileName(), QSettings::IniFormat); |
329 QSettings settings(DataManager::instance().settingsFileName(), QSettings::IniFormat); |
326 settings.setIniCodec("UTF-8"); |
330 settings.setIniCodec("UTF-8"); |
|
331 |
|
332 // Heuristic to figure out if the user is (probably) a first-time player. |
|
333 // If nickname is not set, then probably yes. |
|
334 // The hidden setting firstLaunch is, if present, used to force HW to |
|
335 // treat iself as if it were launched the first time. |
|
336 QString nick = settings.value("net/nick", QString()).toString(); |
|
337 if (settings.contains("frontend/firstLaunch")) |
|
338 { |
|
339 isProbablyNewPlayer = settings.value("frontend/firstLaunch").toBool(); |
|
340 } |
|
341 else |
|
342 { |
|
343 isProbablyNewPlayer = nick.isNull(); |
|
344 } |
|
345 |
|
346 // Set firstLaunch to false to make sure we remember we have been launched before. |
|
347 settings.setValue("frontend/firstLaunch", false); |
327 |
348 |
328 QString cc = settings.value("misc/locale", QString()).toString(); |
349 QString cc = settings.value("misc/locale", QString()).toString(); |
329 if (cc.isEmpty()) |
350 if (cc.isEmpty()) |
330 { |
351 { |
331 cc = QLocale::system().name(); |
352 cc = QLocale::system().name(); |
396 #ifdef Q_OS_WIN |
417 #ifdef Q_OS_WIN |
397 splash.finish(app.form); |
418 splash.finish(app.form); |
398 #endif |
419 #endif |
399 app.form->show(); |
420 app.form->show(); |
400 |
421 |
|
422 // Show welcome message for (suspected) first-time player and |
|
423 // point towards the Training menu. |
|
424 if(isProbablyNewPlayer) { |
|
425 QMessageBox questionTutorialMsg(app.form); |
|
426 questionTutorialMsg.setIcon(QMessageBox::Question); |
|
427 questionTutorialMsg.setWindowTitle(QMessageBox::tr("Welcome to Hedgewars")); |
|
428 questionTutorialMsg.setText(QMessageBox::tr("Welcome to Hedgewars!\n\nYou seem to be new around here. Would you like to play some training missions first to learn the basics of Hedgewars?")); |
|
429 questionTutorialMsg.setWindowModality(Qt::WindowModal); |
|
430 questionTutorialMsg.addButton(QMessageBox::Yes); |
|
431 questionTutorialMsg.addButton(QMessageBox::No); |
|
432 |
|
433 int answer = questionTutorialMsg.exec(); |
|
434 if (answer == QMessageBox::Yes) { |
|
435 app.form->GoToTraining(); |
|
436 } |
|
437 } |
|
438 |
401 if (app.urlString) |
439 if (app.urlString) |
402 app.fakeEvent(); |
440 app.fakeEvent(); |
403 return app.exec(); |
441 return app.exec(); |
404 } |
442 } |