QTfrontend/main.cpp
changeset 2428 6800f8aa0184
parent 2418 538a777f90c4
child 2517 6ed1fba6da18
equal deleted inserted replaced
2427:241e3bb6a146 2428:6800f8aa0184
    73             qWarning() << "WARNING: Cannot open DATA_PATH=" << f.absoluteFilePath();
    73             qWarning() << "WARNING: Cannot open DATA_PATH=" << f.absoluteFilePath();
    74         }
    74         }
    75         *cDataDir = f.absoluteFilePath();
    75         *cDataDir = f.absoluteFilePath();
    76     }
    76     }
    77 
    77 
       
    78     if(parsedArgs.contains("config-dir")) {
       
    79         QFileInfo f(parsedArgs["config-dir"]);
       
    80         *cConfigDir = f.absoluteFilePath();
       
    81     }
       
    82 
    78 	app.setStyle(new QPlastiqueStyle);
    83 	app.setStyle(new QPlastiqueStyle);
    79 
    84 
    80 	QDateTime now = QDateTime::currentDateTime();
    85 	QDateTime now = QDateTime::currentDateTime();
    81 	QDateTime zero;
    86 	srand(now.toTime_t());
    82 	srand(now.secsTo(zero));
       
    83 	rand();
    87 	rand();
    84 
    88 
    85 	Q_INIT_RESOURCE(hedgewars);
    89 	Q_INIT_RESOURCE(hedgewars);
    86 
    90 
    87 	qApp->setStyleSheet
    91 	qApp->setStyleSheet
   286 			)
   290 			)
   287 		);
   291 		);
   288 
   292 
   289 	bindir->cd("bin"); // workaround over NSIS installer
   293 	bindir->cd("bin"); // workaround over NSIS installer
   290 
   294 
   291 	cfgdir->setPath(cfgdir->homePath());
   295 	if(cConfigDir->length() == 0)
   292         
   296 		cfgdir->setPath(cfgdir->homePath());
       
   297 	else
       
   298 		cfgdir->setPath(*cConfigDir);
       
   299 
       
   300 	if(cConfigDir->length() == 0)
       
   301 	{
   293 #ifdef __APPLE__
   302 #ifdef __APPLE__
   294 	if (checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars"))
   303 		if (checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars"))
       
   304 		{
       
   305 			checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Demos");
       
   306 			checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Saves");
       
   307 		}
       
   308 		cfgdir->cd("Library/Application Support/Hedgewars");
       
   309 #else
       
   310 		if (checkForDir(cfgdir->absolutePath() + "/.hedgewars"))
       
   311 		{
       
   312 			checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos");
       
   313 			checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves");
       
   314 		}
       
   315 		cfgdir->cd(".hedgewars");
       
   316 #endif
       
   317 	}
       
   318 	else
   295 	{
   319 	{
   296 		checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Demos");
   320 		if (checkForDir(cfgdir->absolutePath()))
   297 		checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Saves");
   321 		{
       
   322 			checkForDir(cfgdir->absolutePath() + "/Demos");
       
   323 			checkForDir(cfgdir->absolutePath() + "/Saves");
       
   324 		}
   298 	}
   325 	}
   299 	cfgdir->cd("Library/Application Support/Hedgewars");
       
   300 #else
       
   301 	if (checkForDir(cfgdir->absolutePath() + "/.hedgewars"))
       
   302 	{
       
   303 		checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos");
       
   304 		checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves");
       
   305 	}
       
   306 	cfgdir->cd(".hedgewars");
       
   307 #endif
       
   308 
   326 
   309 	datadir->cd(bindir->absolutePath());
   327 	datadir->cd(bindir->absolutePath());
   310 	datadir->cd(*cDataDir);
   328 	datadir->cd(*cDataDir);
   311 	if(!datadir->cd("hedgewars/Data")) {
   329 	if(!datadir->cd("hedgewars/Data")) {
   312 		QMessageBox::critical(0, QMessageBox::tr("Error"),
   330 		QMessageBox::critical(0, QMessageBox::tr("Error"),