2011-07-02 23:03:18 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* PokerTH - The open source texas holdem engine *
|
2012-12-25 15:06:23 +01:00
|
|
|
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
|
2011-07-02 23:03:18 +00:00
|
|
|
* *
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU Affero General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
2012-12-25 15:06:23 +01:00
|
|
|
* *
|
|
|
|
|
* *
|
|
|
|
|
* Additional permission under GNU AGPL version 3 section 7 *
|
|
|
|
|
* *
|
|
|
|
|
* If you modify this program, or any covered work, by linking or *
|
|
|
|
|
* combining it with the OpenSSL project's OpenSSL library (or a *
|
|
|
|
|
* modified version of that library), containing parts covered by the *
|
|
|
|
|
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
|
|
|
|
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
|
|
|
|
* permission to convey the resulting work. *
|
|
|
|
|
* Corresponding Source for a non-source form of such a combination *
|
|
|
|
|
* shall include the source code for the parts of OpenSSL used as well *
|
|
|
|
|
* as that of the covered work. *
|
2011-07-02 23:03:18 +00:00
|
|
|
*****************************************************************************/
|
2009-08-02 15:11:40 +00:00
|
|
|
#include <boost/asio.hpp>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <ctime>
|
2007-01-13 02:40:33 +00:00
|
|
|
#include <qapplication.h>
|
2009-08-02 15:11:40 +00:00
|
|
|
#include <QtGui>
|
|
|
|
|
#include <QtCore>
|
2007-04-30 23:18:31 +00:00
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2011-02-11 20:02:08 +00:00
|
|
|
#include <QMacStyle>
|
2007-04-30 23:18:31 +00:00
|
|
|
#endif
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2009-08-02 15:11:40 +00:00
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
#include "session.h"
|
2008-09-02 22:04:18 +00:00
|
|
|
#include "startwindowimpl.h"
|
2007-05-05 19:02:11 +00:00
|
|
|
#include "configfile.h"
|
2012-01-02 22:07:25 +00:00
|
|
|
#include "log.h"
|
2008-06-08 10:50:08 +00:00
|
|
|
#include "startsplash.h"
|
|
|
|
|
#include "game_defs.h"
|
2007-02-18 16:04:00 +00:00
|
|
|
#include <net/socket_startup.h>
|
2009-09-13 18:11:48 +00:00
|
|
|
#include <third_party/qtsingleapplication/qtsingleapplication.h>
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2007-02-19 00:39:44 +00:00
|
|
|
#ifdef _MSC_VER
|
2011-02-11 20:02:08 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
|
#define _CRTDBG_MAP_ALLOC
|
|
|
|
|
#include <crtdbg.h>
|
2007-02-19 00:39:44 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
#define ENABLE_LEAK_CHECK() \
|
2012-12-13 17:06:54 +01:00
|
|
|
{ \
|
|
|
|
|
int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \
|
|
|
|
|
tmpFlag |= _CRTDBG_LEAK_CHECK_DF; \
|
|
|
|
|
_CrtSetDbgFlag(tmpFlag); \
|
|
|
|
|
}
|
2011-02-11 20:02:08 +00:00
|
|
|
#endif
|
2007-02-19 00:39:44 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef ENABLE_LEAK_CHECK
|
2011-02-11 20:02:08 +00:00
|
|
|
#define ENABLE_LEAK_CHECK()
|
2007-02-19 00:39:44 +00:00
|
|
|
#endif
|
|
|
|
|
|
2007-01-19 23:25:42 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
2008-09-02 22:04:18 +00:00
|
|
|
class startWindowImpl;
|
2007-05-20 00:16:29 +00:00
|
|
|
class Game;
|
2007-01-13 02:40:33 +00:00
|
|
|
|
|
|
|
|
int main( int argc, char **argv )
|
|
|
|
|
{
|
2011-02-11 20:02:08 +00:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
//ENABLE_LEAK_CHECK();
|
2007-02-19 00:39:44 +00:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
//_CrtSetBreakAlloc(49937);
|
|
|
|
|
socket_startup();
|
|
|
|
|
curl_global_init(CURL_GLOBAL_NOTHING);
|
2008-04-24 22:11:43 +00:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
/////// can be removed for non-qt-guis ////////////
|
|
|
|
|
QtSingleApplication a( argc, argv );
|
2009-09-13 18:11:48 +00:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
if (a.sendMessage("Wake up!")) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-06-25 00:25:52 +00:00
|
|
|
|
2010-07-08 17:04:17 +00:00
|
|
|
#ifdef __APPLE__
|
2012-12-21 01:01:01 +01:00
|
|
|
// The following needs to be done directly after the application is created.
|
|
|
|
|
QDir dir(QApplication::applicationDirPath());
|
|
|
|
|
dir.cdUp();
|
|
|
|
|
dir.cd("plugins");
|
|
|
|
|
QApplication::setLibraryPaths(QStringList(dir.absolutePath()));
|
2010-07-08 17:04:17 +00:00
|
|
|
#endif
|
|
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
//create defaultconfig
|
|
|
|
|
ConfigFile *myConfig = new ConfigFile(argv[0], false);
|
|
|
|
|
Log *myLog = new Log(myConfig);
|
2012-05-22 00:48:35 +02:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
// set PlastiqueStyle even for mac-version to prevent artefacts on styled widgets
|
|
|
|
|
a.setStyle(new QPlastiqueStyle);
|
2012-05-22 00:48:35 +02:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
QString myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str());
|
|
|
|
|
//set QApplication default font
|
|
|
|
|
|
|
|
|
|
QFontDatabase::addApplicationFont (myAppDataPath +"fonts/n019003l.pfb");
|
|
|
|
|
QFontDatabase::addApplicationFont (myAppDataPath +"fonts/VeraBd.ttf");
|
|
|
|
|
QFontDatabase::addApplicationFont (myAppDataPath +"fonts/c059013l.pfb");
|
|
|
|
|
QFontDatabase::addApplicationFont (myAppDataPath +"fonts/DejaVuSans-Bold.ttf");
|
2007-12-05 00:39:51 +00:00
|
|
|
|
2007-09-04 22:54:07 +00:00
|
|
|
#ifdef _WIN32
|
2012-12-21 01:01:01 +01:00
|
|
|
QString font1String("QApplication, QWidget, QDialog { font-size: 12px; }");
|
2012-05-12 15:17:58 +02:00
|
|
|
#elif __APPLE__
|
2012-12-21 01:01:01 +01:00
|
|
|
// QString font1String("font-family: \"Lucida Grande\";");
|
|
|
|
|
QString font1String("QApplication, QWidget, QDialog { font-size: 11px; }");
|
2012-05-12 15:17:58 +02:00
|
|
|
#elif ANDROID
|
2012-12-21 01:01:01 +01:00
|
|
|
QString font1String("QApplication, QWidget, QDialog { font-family: \"Nimbus Sans L\"; font-size: 26px; }");
|
|
|
|
|
QPalette p = a.palette();
|
|
|
|
|
p.setColor(QPalette::Button, QColor::fromRgb(80,80,80));
|
|
|
|
|
p.setColor(QPalette::Base, QColor::fromRgb(80,80,80));
|
|
|
|
|
p.setColor(QPalette::Window, QColor::fromRgb(50,50,50));
|
|
|
|
|
p.setColor(QPalette::ButtonText, QColor::fromRgb(255,255,255));
|
|
|
|
|
p.setColor(QPalette::Disabled, QPalette::ButtonText, QColor::fromRgb(100,100,100));
|
|
|
|
|
p.setColor(QPalette::WindowText, QColor::fromRgb(255,255,255));
|
|
|
|
|
p.setColor(QPalette::Disabled, QPalette::WindowText, QColor::fromRgb(100,100,100));
|
|
|
|
|
p.setColor(QPalette::Text, QColor::fromRgb(255,255,255));
|
|
|
|
|
p.setColor(QPalette::Disabled, QPalette::Text, QColor::fromRgb(100,100,100));
|
|
|
|
|
p.setColor(QPalette::Link, QColor::fromRgb(192,192,255));
|
|
|
|
|
p.setColor(QPalette::LinkVisited, QColor::fromRgb(192,192,255));
|
|
|
|
|
a.setPalette(p);
|
2011-02-11 20:02:08 +00:00
|
|
|
#else
|
2012-12-21 01:01:01 +01:00
|
|
|
QString font1String("QApplication, QWidget, QDialog { font-family: \"Nimbus Sans L\"; font-size: 12px; }");
|
2011-02-11 20:02:08 +00:00
|
|
|
#endif
|
2012-12-21 01:01:01 +01:00
|
|
|
a.setStyleSheet(font1String + " QDialogButtonBox, QMessageBox { dialogbuttonbox-buttons-have-icons: 1; dialog-ok-icon: url(:/gfx/dialog_ok_apply.png); dialog-cancel-icon: url(:/gfx/dialog_close.png); dialog-close-icon: url(:/gfx/dialog_close.png); dialog-yes-icon: url(:/gfx/dialog_ok_apply.png); dialog-no-icon: url(:/gfx/dialog_close.png) }");
|
2008-06-08 10:50:08 +00:00
|
|
|
|
2012-05-06 20:57:04 +00:00
|
|
|
#ifdef ANDROID
|
2012-12-21 01:01:01 +01:00
|
|
|
QDesktopWidget dw;
|
2012-12-28 20:24:00 +01:00
|
|
|
QPixmap pixmap(myAppDataPath + "gfx/gui/misc/welcomepokerth_mobile.png");
|
|
|
|
|
pixmap = pixmap.scaled(dw.screenGeometry().width(), dw.screenGeometry().height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
|
|
|
#else
|
|
|
|
|
QPixmap pixmap(myAppDataPath + "gfx/gui/misc/welcomepokerth_desktop.png");
|
2012-05-06 20:57:04 +00:00
|
|
|
#endif
|
2012-12-21 01:01:01 +01:00
|
|
|
StartSplash splash(pixmap);
|
|
|
|
|
if(!myConfig->readConfigInt("DisableSplashScreenOnStartup")) {
|
|
|
|
|
splash.show();
|
|
|
|
|
splash.showMessage(QString("Version %1").arg(POKERTH_BETA_RELEASE_STRING), 0x0042, QColor(255,255,255));
|
|
|
|
|
}
|
2011-02-11 20:02:08 +00:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
//Set translations
|
|
|
|
|
QTranslator qtTranslator;
|
|
|
|
|
qtTranslator.load(QString(myAppDataPath +"translations/qt_") + QString::fromStdString(myConfig->readConfigString("Language")));
|
|
|
|
|
a.installTranslator(&qtTranslator);
|
2007-06-15 18:59:28 +00:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
QTranslator translator;
|
|
|
|
|
translator.load(QString(myAppDataPath +"translations/pokerth_") + QString::fromStdString(myConfig->readConfigString("Language")));
|
|
|
|
|
a.installTranslator(&translator);
|
2007-12-13 19:52:48 +00:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
qRegisterMetaType<unsigned>("unsigned");
|
|
|
|
|
qRegisterMetaType<boost::shared_ptr<Game> >("boost::shared_ptr<Game>");
|
|
|
|
|
qRegisterMetaType<ServerStats>("ServerStats");
|
|
|
|
|
qRegisterMetaType<DenyGameInvitationReason>("DenyGameInvitationReason");
|
|
|
|
|
///////////////////////////////////////////////////
|
2007-05-20 13:03:43 +00:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
startWindowImpl mainWin(myConfig,myLog);
|
|
|
|
|
a.setActivationWindow(&mainWin, true);
|
2009-09-13 18:11:48 +00:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
int retVal = a.exec();
|
2011-02-11 20:02:08 +00:00
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
curl_global_cleanup();
|
|
|
|
|
socket_cleanup();
|
2011-02-11 20:02:08 +00:00
|
|
|
|
|
|
|
|
|
2012-12-21 01:01:01 +01:00
|
|
|
return retVal;
|
2011-02-11 20:02:08 +00:00
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
}
|