QTfrontend/main.cpp
changeset 13086 8d569c7b36a2
parent 12661 1dc160048a0c
child 13188 16b375b21af1
equal deleted inserted replaced
13085:26173dd0c606 13086:8d569c7b36a2
    48 #endif
    48 #endif
    49 
    49 
    50 #ifdef Q_OS_WIN
    50 #ifdef Q_OS_WIN
    51 #include <QSplashScreen>
    51 #include <QSplashScreen>
    52 #endif
    52 #endif
       
    53 
       
    54 #include <QMessageBox>
    53 
    55 
    54 // Program resources
    56 // Program resources
    55 #ifdef __APPLE__
    57 #ifdef __APPLE__
    56 static CocoaInitializer * cocoaInit = NULL;
    58 static CocoaInitializer * cocoaInit = NULL;
    57 #endif
    59 #endif
   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 }