2007-01-13 02:40:33 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2006 by FThauer FHammer *
|
|
|
|
|
* f.thauer@web.de *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 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 General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
2007-01-16 22:42:02 +00:00
|
|
|
|
2007-01-17 00:39:20 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
2007-01-16 22:42:02 +00:00
|
|
|
/////// can be removed for non-qt-guis ////////////
|
2007-01-13 02:40:33 +00:00
|
|
|
#include <qapplication.h>
|
2007-04-30 23:18:31 +00:00
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
#include <QMacStyle>
|
|
|
|
|
#endif
|
2007-01-16 22:42:02 +00:00
|
|
|
///////////////////////////////////////////////////
|
2007-01-13 02:40:33 +00:00
|
|
|
|
|
|
|
|
#include "session.h"
|
|
|
|
|
#include "guiwrapper.h"
|
2007-05-05 19:02:11 +00:00
|
|
|
#include "configfile.h"
|
2007-02-18 16:04:00 +00:00
|
|
|
#include <net/socket_startup.h>
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2007-05-13 17:50:48 +00:00
|
|
|
#include <QtGui>
|
|
|
|
|
#include <QtCore>
|
|
|
|
|
|
2007-01-19 23:25:42 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <ctime>
|
|
|
|
|
|
2007-02-19 00:39:44 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
#define _CRTDBG_MAP_ALLOC
|
|
|
|
|
#include <crtdbg.h>
|
|
|
|
|
|
|
|
|
|
#define ENABLE_LEAK_CHECK() \
|
|
|
|
|
{ \
|
|
|
|
|
int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \
|
|
|
|
|
tmpFlag |= _CRTDBG_LEAK_CHECK_DF; \
|
|
|
|
|
_CrtSetDbgFlag(tmpFlag); \
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef ENABLE_LEAK_CHECK
|
|
|
|
|
#define ENABLE_LEAK_CHECK()
|
|
|
|
|
#endif
|
|
|
|
|
|
2007-09-24 10:32:08 +00:00
|
|
|
//Uncomment this for RELEASE
|
|
|
|
|
// #include <QtPlugin>
|
|
|
|
|
// Q_IMPORT_PLUGIN(qjpeg)
|
|
|
|
|
// Q_IMPORT_PLUGIN(qgif)
|
2007-09-15 22:35:35 +00:00
|
|
|
|
|
|
|
|
|
2007-01-19 23:25:42 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
2007-01-13 02:40:33 +00:00
|
|
|
class GuiWrapper;
|
2007-05-20 00:16:29 +00:00
|
|
|
class Game;
|
2007-01-13 02:40:33 +00:00
|
|
|
|
|
|
|
|
int main( int argc, char **argv )
|
|
|
|
|
{
|
2007-10-01 07:17:05 +00:00
|
|
|
|
2007-02-25 23:16:26 +00:00
|
|
|
//ENABLE_LEAK_CHECK();
|
2007-02-19 00:39:44 +00:00
|
|
|
|
|
|
|
|
//_CrtSetBreakAlloc(49937);
|
2007-02-18 16:04:00 +00:00
|
|
|
socket_startup();
|
2007-01-16 23:08:39 +00:00
|
|
|
|
2007-01-16 22:42:02 +00:00
|
|
|
/////// can be removed for non-qt-guis ////////////
|
2007-01-13 02:40:33 +00:00
|
|
|
QApplication a( argc, argv );
|
2007-06-25 00:25:52 +00:00
|
|
|
|
2007-10-01 07:17:05 +00:00
|
|
|
//create defaultconfig
|
|
|
|
|
ConfigFile *myConfig = new ConfigFile(argc, argv);
|
|
|
|
|
|
2007-06-25 00:25:52 +00:00
|
|
|
// set PlastiqueStyle even for mac-version to prevent artefacts on styled widgets
|
2007-04-30 23:14:30 +00:00
|
|
|
a.setStyle(new QPlastiqueStyle);
|
2007-09-03 00:26:38 +00:00
|
|
|
|
2007-09-08 22:01:30 +00:00
|
|
|
QString myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str());
|
2007-09-04 22:54:07 +00:00
|
|
|
//set QApplication default font
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
QString font1String("font-family: \"Arial\";");
|
|
|
|
|
|
|
|
|
|
#else
|
2007-09-08 22:01:30 +00:00
|
|
|
QFontDatabase::addApplicationFont (myAppDataPath +"fonts/n019003l.pfb");
|
|
|
|
|
QFontDatabase::addApplicationFont (myAppDataPath +"fonts/VeraBd.ttf");
|
2007-09-04 22:54:07 +00:00
|
|
|
|
|
|
|
|
QString font1String("font-family: \"Nimbus Sans L\";");
|
|
|
|
|
#endif
|
|
|
|
|
a.setStyleSheet("QApplication, QWidget, QDialog { " + font1String + " font-size: 12px; }");
|
|
|
|
|
|
|
|
|
|
//Set translations
|
2007-06-15 18:59:28 +00:00
|
|
|
QTranslator qtTranslator;
|
2007-09-08 22:01:30 +00:00
|
|
|
qtTranslator.load(QString(myAppDataPath +"translations/qt_") + QString::fromStdString(myConfig->readConfigString("Language")));
|
2007-06-15 18:59:28 +00:00
|
|
|
a.installTranslator(&qtTranslator);
|
|
|
|
|
|
2007-05-20 00:16:29 +00:00
|
|
|
QTranslator translator;
|
2007-09-08 22:01:30 +00:00
|
|
|
translator.load(QString(myAppDataPath +"translations/pokerth_") + QString::fromStdString(myConfig->readConfigString("Language")));
|
2007-06-15 18:59:28 +00:00
|
|
|
a.installTranslator(&translator);
|
2007-05-20 13:03:43 +00:00
|
|
|
|
2007-01-16 22:42:02 +00:00
|
|
|
|
2007-09-02 16:36:52 +00:00
|
|
|
qRegisterMetaType<unsigned>("unsigned");
|
2007-05-20 00:16:29 +00:00
|
|
|
qRegisterMetaType<boost::shared_ptr<Game> >("boost::shared_ptr<Game>");
|
2007-05-20 13:03:43 +00:00
|
|
|
///////////////////////////////////////////////////
|
|
|
|
|
|
2007-05-20 00:16:29 +00:00
|
|
|
|
2007-05-14 12:40:42 +00:00
|
|
|
boost::shared_ptr<GuiInterface> myGuiInterface(new GuiWrapper(myConfig));
|
2007-05-11 12:01:13 +00:00
|
|
|
{
|
2007-05-14 12:40:42 +00:00
|
|
|
boost::shared_ptr<Session> session(new Session(myGuiInterface.get(), myConfig));
|
2007-09-08 21:43:15 +00:00
|
|
|
session->init(); // TODO handle error
|
2007-05-11 12:01:13 +00:00
|
|
|
myGuiInterface->setSession(session);
|
|
|
|
|
}
|
2007-01-13 02:40:33 +00:00
|
|
|
|
2007-02-18 16:04:00 +00:00
|
|
|
int retVal = a.exec();
|
|
|
|
|
|
|
|
|
|
socket_cleanup();
|
|
|
|
|
return retVal;
|
2007-01-13 02:40:33 +00:00
|
|
|
}
|