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-03 19:45:08 +00:00
*****************************************************************************/
#include "startwindowimpl.h"
2008-09-17 21:50:51 +00:00
#include "playerinterface.h"
2008-06-08 21:18:29 +00:00
#include <gamedata.h>
#include <generic/serverguiwrapper.h>
#include <net/socket_msg.h>
2008-09-13 20:40:08 +00:00
#include "tools.h"
2008-06-08 21:18:29 +00:00
#include "session.h"
#include "game.h"
2008-09-02 22:04:18 +00:00
#include "guiwrapper.h"
2008-06-07 21:11:57 +00:00
#include "configfile.h"
#include "gametableimpl.h"
2008-06-08 21:18:29 +00:00
#include "newgamedialogimpl.h"
#include "aboutpokerthimpl.h"
#include "mymessagedialogimpl.h"
2012-05-17 01:35:59 +02:00
#include "mymessagebox.h"
2008-06-08 21:18:29 +00:00
#include "settingsdialogimpl.h"
#include "selectavatardialogimpl.h"
#include "joinnetworkgamedialogimpl.h"
#include "connecttoserverdialogimpl.h"
#include "createnetworkgamedialogimpl.h"
#include "startnetworkgamedialogimpl.h"
2010-07-14 08:43:51 +00:00
#include "changecontentdialogimpl.h"
2008-06-08 21:18:29 +00:00
#include "changecompleteblindsdialogimpl.h"
#include "gamelobbydialogimpl.h"
#include "timeoutmsgboximpl.h"
2009-08-17 23:20:58 +00:00
#include "chattools.h"
2009-04-05 12:32:16 +00:00
#include "serverlistdialogimpl.h"
2009-08-27 10:19:11 +00:00
#include "internetgamelogindialogimpl.h"
2012-09-17 23:44:33 +02:00
#include "logfiledialog.h"
2011-11-26 21:07:22 +00:00
#include "guilog.h"
2008-09-13 20:40:08 +00:00
2012-12-22 01:22:28 +01:00
#ifdef ANDROID
2013-10-06 16:30:09 +02:00
#ifndef ANDROID_TEST
2017-02-05 00:44:48 +01:00
#include "QtGui/5.7.1/QtGui/qpa/qplatformnativeinterface.h"
2013-10-06 16:30:09 +02:00
#include <jni.h>
#endif
2012-12-22 01:22:28 +01:00
#endif
2008-09-13 20:40:08 +00:00
using namespace std ;
2008-06-08 21:18:29 +00:00
2012-01-02 22:07:25 +00:00
startWindowImpl :: startWindowImpl ( ConfigFile * c , Log * l )
: myConfig ( c ), myLog ( l ), msgBoxOutdatedVersionActive ( false )
2008-06-07 21:11:57 +00:00
{
2008-09-02 22:04:18 +00:00
2011-02-11 20:02:08 +00:00
myGuiInterface . reset ( new GuiWrapper ( myConfig , this ));
{
2012-01-02 22:07:25 +00:00
mySession . reset ( new Session ( myGuiInterface . get (), myConfig , myLog ));
2011-02-11 20:02:08 +00:00
mySession -> init (); // TODO handle error
2012-01-02 22:07:25 +00:00
myLog -> init ();
2011-02-11 20:02:08 +00:00
// myGuiInterface->setSession(session);
}
2012-02-09 17:47:51 +00:00
myGuiInterface -> getMyGuiLog () -> setMySqliteLogFileName ( myLog -> getMySqliteLogFileName ());
2008-09-02 22:04:18 +00:00
2011-02-11 20:02:08 +00:00
// #ifdef __APPLE__
// setWindowModality(Qt::ApplicationModal);
// setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
// #endif
setupUi ( this );
this -> setWindowTitle ( QString ( tr ( "PokerTH %1" ). arg ( POKERTH_BETA_RELEASE_STRING )));
this -> installEventFilter ( this );
2008-06-07 21:11:57 +00:00
2011-02-11 20:02:08 +00:00
//Widgets Grafiken per Stylesheets setzen
2012-12-21 01:01:01 +01:00
QString myAppDataPath = QString :: fromUtf8 ( myConfig -> readConfigString ( "AppDataDir" ). c_str ());
2011-02-11 20:02:08 +00:00
this -> setWindowIcon ( QIcon ( myAppDataPath + "gfx/gui/misc/windowicon.png" ));
2009-03-26 09:47:14 +00:00
2011-02-11 20:02:08 +00:00
this -> setStatusBar ( 0 );
2012-01-30 17:50:36 +00:00
#ifdef GUI_800x480
2013-10-06 16:30:09 +02:00
#ifdef ANDROID
2013-12-22 11:23:59 +01:00
this -> setMenuBar ( 0 );
// this->menubar->clear();
// this->menubar->hide();
2012-12-15 09:19:00 +01:00
2013-10-06 16:30:09 +02:00
//check if custom background picture for the resolution is there. Otherwise create it!
QString UserDataDir = QString :: fromUtf8 ( myConfig -> readConfigString ( "UserDataDir" ). c_str ());
QDesktopWidget dw ;
int screenWidth = dw . screenGeometry (). width ();
int screenHeight = dw . screenGeometry (). height ();
QString customStartWindowBgFileString ( UserDataDir + "/startwindowbg10_" + QString :: number ( screenWidth ) + "x" + QString :: number ( screenHeight ) + ".png" );
QFile customStartWindowBgFile ( customStartWindowBgFileString );
if ( customStartWindowBgFile . exists ()) {
centralwidget -> setStyleSheet ( ".QWidget { background-image: url(" + QFileInfo ( customStartWindowBgFile ). absoluteFilePath () + "); background-position: top center; background-origin: content; background-repeat: no-repeat;}" );
} else {
//if custom bg file could not be found load the big origin file
centralwidget -> setStyleSheet ( ".QWidget { background-image: url(:/android/android-data/gfx/gui/misc/startwindowbg10_mobile.png); background-position: top center; background-origin: content; background-repeat: no-repeat;}" );
}
this -> showFullScreen ();
2012-12-24 11:28:00 +01:00
2013-10-06 16:30:09 +02:00
//TODO HACK Missing QSystemScreenSaver::setScreenSaverInhibited(true)
2012-12-29 21:56:12 +01:00
// #ifndef ANDROID_TEST
// JavaVM *currVM = (JavaVM *)QApplication::platformNativeInterface()->nativeResourceForWidget("JavaVM", 0);
// JNIEnv* env;
// if (currVM->AttachCurrentThread(&env, NULL)<0) {
// qCritical()<<"AttachCurrentThread failed";
// } else {
// // jclass jclassApplicationClass = env->FindClass("android/view/View");
// // if (jclassApplicationClass) {
// // env->SetStaticIntField(jclassApplicationClass, env->GetStaticFieldID(jclassApplicationClass,"KEEP_SCREEN_ON", "I"), 1);
// // }
// currVM->DetachCurrentThread();
// }
// #endif
2013-10-06 16:30:09 +02:00
#else
2012-12-24 11:28:00 +01:00
// Maemo
2013-10-06 16:30:09 +02:00
this -> menubar -> hide ();
centralwidget -> setStyleSheet ( ".QWidget { background-image: url( \" " + myAppDataPath + "gfx/gui/misc/startwindowbg10_desktop.png \" ); background-position: bottom center; background-origin: content; background-repeat: no-repeat;}" );
#endif
2012-12-24 11:28:00 +01:00
// All mobile GUI's
2012-12-29 21:56:12 +01:00
pushButtonStart_Local_Game -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 3px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:22px; border-width: 0px;}" );
pushButtonInternet_Game -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 3px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:22px; border-width: 0px;}" );
pushButton_Create_Network_Game -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 3px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:22px; border-width: 0px;}" );
pushButton_Join_Network_Game -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 3px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:22px; border-width: 0px;}" );
pushButton_about -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 3px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:22px; border-width: 0px;}" );
pushButton_configure -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 3px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:22px; border-width: 0px;}" );
pushButton_Logs -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 3px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:22px; border-width: 0px;}" );
2012-05-09 23:13:41 +00:00
2012-12-21 01:01:01 +01:00
connect ( pushButton_about , SIGNAL ( clicked () ), this , SLOT ( callAboutPokerthDialog () ) );
connect ( pushButton_configure , SIGNAL ( clicked () ), this , SLOT ( callSettingsDialogFromStartwindow () ) );
2012-01-30 17:50:36 +00:00
#else
2012-12-24 11:28:00 +01:00
//Desktop
2013-09-22 00:06:33 +02:00
this -> menubar -> setStyleSheet ( "QMenuBar { background-color: #505050; font-size:12px; border-width: 0px;} QMenuBar::item { background: transparent; color: #FDC942; } QMenuBar::item:selected { background: #787878; color: #FDC942; } QMenuBar::item:pressed { background: #FDC942; color: #505050; }" );
2012-12-29 23:05:30 +01:00
centralwidget -> setStyleSheet ( ".QWidget { background-image: url( \" " + myAppDataPath + "gfx/gui/misc/startwindowbg10_desktop.png \" ); background-position: bottom center; background-origin: content; background-repeat: no-repeat;}" );
2008-06-08 21:18:29 +00:00
2012-12-29 21:56:12 +01:00
pushButtonStart_Local_Game -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 1px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:12px; border-width: 0px;}" );
pushButtonInternet_Game -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 1px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:12px; border-width: 0px;}" );
pushButton_Create_Network_Game -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 1px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:12px; border-width: 0px;}" );
pushButton_Join_Network_Game -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 1px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:12px; border-width: 0px;}" );
pushButton_Logs -> setStyleSheet ( "QPushButton { text-align:left; font-weight:bold; padding-left: 1px; padding-bottom: 3px; padding-top: 3px; padding-right: 3px; background-color: #505050; color: #FDC942; font-size:12px; border-width: 0px;}" );
2012-05-09 23:13:41 +00:00
2012-12-21 01:01:01 +01:00
connect ( actionAbout_PokerTH , SIGNAL ( triggered () ), this , SLOT ( callAboutPokerthDialog () ) );
connect ( actionConfigure_PokerTH , SIGNAL ( triggered () ), this , SLOT ( callSettingsDialogFromStartwindow () ) );
2012-05-09 23:13:41 +00:00
2012-01-30 17:50:36 +00:00
#endif
2011-12-29 11:30:44 +00:00
2011-02-11 20:02:08 +00:00
// Dialogs
myNewGameDialog = new newGameDialogImpl ( this , myConfig );
mySelectAvatarDialog = new selectAvatarDialogImpl ( this , myConfig );
mySettingsDialog = new settingsDialogImpl ( this , myConfig , mySelectAvatarDialog );
myJoinNetworkGameDialog = new joinNetworkGameDialogImpl ( this , myConfig );
myConnectToServerDialog = new connectToServerDialogImpl ( this );
myStartNetworkGameDialog = new startNetworkGameDialogImpl ( this , myConfig );
myCreateNetworkGameDialog = new createNetworkGameDialogImpl ( this , myConfig );
myAboutPokerthDialog = new aboutPokerthImpl ( this , myConfig );
myGameLobbyDialog = new gameLobbyDialogImpl ( this , myConfig );
2012-09-17 23:44:33 +02:00
myLogFileDialog = new LogFileDialog ( this , myConfig );
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
myStartNetworkGameDialog -> setMyW ( myGuiInterface -> getMyW ());
myGameLobbyDialog -> setMyW ( myGuiInterface -> getMyW ());
2011-11-26 21:07:22 +00:00
mySettingsDialog -> setGuiLog ( myGuiLog );
2012-09-17 23:44:33 +02:00
myLogFileDialog -> setGuiLog ( myGuiLog );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
myTimeoutDialog = new timeoutMsgBoxImpl ( this );
myServerListDialog = new serverListDialogImpl ( this , this , myConfig );
myInternetGameLoginDialog = new internetGameLoginDialogImpl ( this , myConfig );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
connect ( actionStart_Local_Game , SIGNAL ( triggered () ), this , SLOT ( callNewGameDialog () ) );
connect ( pushButtonStart_Local_Game , SIGNAL ( clicked () ), this , SLOT ( callNewGameDialog () ) );
connect ( actionInternet_Game , SIGNAL ( triggered () ), this , SLOT ( joinGameLobby () ) );
connect ( pushButtonInternet_Game , SIGNAL ( clicked () ), this , SLOT ( joinGameLobby () ) );
connect ( actionCreate_Network_Game , SIGNAL ( triggered () ), this , SLOT ( callCreateNetworkGameDialog () ) );
connect ( pushButton_Create_Network_Game , SIGNAL ( clicked () ), this , SLOT ( callCreateNetworkGameDialog () ) );
connect ( actionJoin_Network_Game , SIGNAL ( triggered () ), this , SLOT ( callJoinNetworkGameDialog () ) );
2012-09-17 23:44:33 +02:00
connect ( pushButton_Join_Network_Game , SIGNAL ( clicked () ), this , SLOT ( callJoinNetworkGameDialog () ) );
2012-12-24 11:28:00 +01:00
connect ( pushButton_Logs , SIGNAL ( clicked () ), this , SLOT ( callLogFileDialog () ) );
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalShowClientDialog ()), this , SLOT ( showClientDialog ()));
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalNetClientConnect ( int )), myConnectToServerDialog , SLOT ( refresh ( int )));
connect ( this , SIGNAL ( signalNetClientGameInfo ( int )), myStartNetworkGameDialog , SLOT ( refresh ( int )));
connect ( this , SIGNAL ( signalNetClientGameInfo ( int )), myGameLobbyDialog , SLOT ( refresh ( int )));
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalNetClientServerListShow ()), myServerListDialog , SLOT ( exec ()));
connect ( this , SIGNAL ( signalNetClientServerListClear ()), myServerListDialog , SLOT ( clearList ()));
connect ( this , SIGNAL ( signalNetClientServerListAdd ( unsigned )), myServerListDialog , SLOT ( addServerItem ( unsigned )));
2009-04-05 12:32:16 +00:00
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalNetClientLoginShow ()), this , SLOT ( callInternetGameLoginDialog ()));
2011-08-08 19:50:28 +00:00
connect ( this , SIGNAL ( signalNetClientRejoinPossible ( unsigned )), this , SLOT ( callRejoinPossibleDialog ( unsigned )));
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalNetClientSelfJoined ( unsigned , QString , bool )), myStartNetworkGameDialog , SLOT ( joinedNetworkGame ( unsigned , QString , bool )));
connect ( this , SIGNAL ( signalNetClientPlayerJoined ( unsigned , QString , bool )), myStartNetworkGameDialog , SLOT ( addConnectedPlayer ( unsigned , QString , bool )));
connect ( this , SIGNAL ( signalNetClientPlayerChanged ( unsigned , QString )), myStartNetworkGameDialog , SLOT ( updatePlayer ( unsigned , QString )));
connect ( this , SIGNAL ( signalNetClientPlayerLeft ( unsigned , QString )), myStartNetworkGameDialog , SLOT ( removePlayer ( unsigned , QString )));
connect ( this , SIGNAL ( signalNetClientNewGameAdmin ( unsigned , QString )), myStartNetworkGameDialog , SLOT ( newGameAdmin ( unsigned , QString )));
connect ( this , SIGNAL ( signalNetClientGameListNew ( unsigned )), myStartNetworkGameDialog , SLOT ( gameCreated ( unsigned )));
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalNetClientSelfJoined ( unsigned , QString , bool )), myGameLobbyDialog , SLOT ( joinedNetworkGame ( unsigned , QString , bool )));
connect ( this , SIGNAL ( signalNetClientPlayerJoined ( unsigned , QString , bool )), myGameLobbyDialog , SLOT ( addConnectedPlayer ( unsigned , QString , bool )));
connect ( this , SIGNAL ( signalNetClientPlayerChanged ( unsigned , QString )), myGameLobbyDialog , SLOT ( updatePlayer ( unsigned , QString )));
connect ( this , SIGNAL ( signalNetClientPlayerLeft ( unsigned , QString )), myGameLobbyDialog , SLOT ( removePlayer ( unsigned , QString )));
2013-08-28 10:49:03 +02:00
connect ( this , SIGNAL ( signalNetClientSpectatorJoined ( unsigned , QString )), myGameLobbyDialog , SLOT ( addConnectedSpectator ( unsigned , QString )));
connect ( this , SIGNAL ( signalNetClientSpectatorLeft ( unsigned , QString )), myGameLobbyDialog , SLOT ( removeSpectator ( unsigned , QString )));
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalNetClientNewGameAdmin ( unsigned , QString )), myGameLobbyDialog , SLOT ( newGameAdmin ( unsigned , QString )));
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalNetClientGameListNew ( unsigned )), myGameLobbyDialog , SLOT ( addGame ( unsigned )));
connect ( this , SIGNAL ( signalNetClientGameListRemove ( unsigned )), myGameLobbyDialog , SLOT ( removeGame ( unsigned )));
connect ( this , SIGNAL ( signalNetClientGameListUpdateMode ( unsigned , int )), myGameLobbyDialog , SLOT ( updateGameMode ( unsigned , int )));
connect ( this , SIGNAL ( signalNetClientGameListUpdateAdmin ( unsigned , unsigned )), myGameLobbyDialog , SLOT ( updateGameAdmin ( unsigned , unsigned )));
connect ( this , SIGNAL ( signalNetClientGameListPlayerJoined ( unsigned , unsigned )), myGameLobbyDialog , SLOT ( gameAddPlayer ( unsigned , unsigned )));
connect ( this , SIGNAL ( signalNetClientGameListPlayerLeft ( unsigned , unsigned )), myGameLobbyDialog , SLOT ( gameRemovePlayer ( unsigned , unsigned )));
2013-08-28 10:49:03 +02:00
connect ( this , SIGNAL ( signalNetClientGameListSpectatorJoined ( unsigned , unsigned )), myGameLobbyDialog , SLOT ( gameAddSpectator ( unsigned , unsigned )));
connect ( this , SIGNAL ( signalNetClientGameListSpectatorLeft ( unsigned , unsigned )), myGameLobbyDialog , SLOT ( gameRemoveSpectator ( unsigned , unsigned )));
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalNetClientRemovedFromGame ( int )), myGameLobbyDialog , SLOT ( removedFromGame ( int )));
connect ( this , SIGNAL ( signalNetClientStatsUpdate ( ServerStats )), myGameLobbyDialog , SLOT ( updateStats ( ServerStats )));
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalNetClientGameChatMsg ( QString , QString )), myGuiInterface -> getMyW () -> getMyChat (), SLOT ( receiveMessage ( QString , QString )));
connect ( this , SIGNAL ( signalNetClientLobbyChatMsg ( QString , QString )), myStartNetworkGameDialog -> getMyChat (), SLOT ( receiveMessage ( QString , QString )));
connect ( this , SIGNAL ( signalNetClientLobbyChatMsg ( QString , QString )), myGameLobbyDialog -> getMyChat (), SLOT ( receiveMessage ( QString , QString )));
2011-02-11 23:02:29 +00:00
connect ( this , SIGNAL ( signalNetClientPrivateChatMsg ( QString , QString )), myStartNetworkGameDialog -> getMyChat (), SLOT ( privateMessage ( QString , QString )));
connect ( this , SIGNAL ( signalNetClientPrivateChatMsg ( QString , QString )), myGameLobbyDialog -> getMyChat (), SLOT ( privateMessage ( QString , QString )));
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalNetClientMsgBox ( QString )), this , SLOT ( networkMessage ( QString )));
connect ( this , SIGNAL ( signalNetClientMsgBox ( unsigned )), this , SLOT ( networkMessage ( unsigned )));
connect ( this , SIGNAL ( signalNetClientShowTimeoutDialog ( int , unsigned )), this , SLOT ( showTimeoutDialog ( int , unsigned )));
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalLobbyPlayerJoined ( unsigned , QString )), myGameLobbyDialog , SLOT ( playerJoinedLobby ( unsigned , QString )));
connect ( this , SIGNAL ( signalLobbyPlayerLeft ( unsigned )), myGameLobbyDialog , SLOT ( playerLeftLobby ( unsigned )));
2009-08-17 23:20:58 +00:00
2008-09-17 21:50:51 +00:00
2011-02-11 20:02:08 +00:00
// Errors are handled globally, not within one dialog.
connect ( this , SIGNAL ( signalNetClientError ( int , int )), this , SLOT ( networkError ( int , int )));
connect ( this , SIGNAL ( signalNetClientNotification ( int )), this , SLOT ( networkNotification ( int )));
connect ( this , SIGNAL ( signalNetServerError ( int , int )), this , SLOT ( networkError ( int , int )));
connect ( this , SIGNAL ( signalNetClientRemovedFromGame ( int )), this , SLOT ( networkNotification ( int )));
connect ( this , SIGNAL ( signalNetClientGameStart ( boost :: shared_ptr < Game > )), this , SLOT ( networkStart ( boost :: shared_ptr < Game > )));
2010-03-29 13:08:59 +00:00
2011-02-11 20:02:08 +00:00
connect ( this , SIGNAL ( signalSelfGameInvitation ( unsigned , unsigned )), myGameLobbyDialog , SLOT ( showInvitationDialog ( unsigned , unsigned )));
connect ( this , SIGNAL ( signalPlayerGameInvitation ( unsigned , unsigned , unsigned )), myGameLobbyDialog , SLOT ( chatInfoPlayerInvitation ( unsigned , unsigned , unsigned )));
connect ( this , SIGNAL ( signalRejectedGameInvitation ( unsigned , unsigned , DenyGameInvitationReason )), myGameLobbyDialog , SLOT ( chatInfoPlayerRejectedInvitation ( unsigned , unsigned , DenyGameInvitationReason )));
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
this -> show ();
2008-06-07 21:11:57 +00:00
2011-02-11 20:02:08 +00:00
//update HACKS
if ( ! checkForFirstStartAfterUpdated (). isEmpty ()) {
qDebug () << checkForFirstStartAfterUpdated ();
}
2010-09-05 12:26:36 +00:00
2010-07-11 20:36:50 +00:00
}
startWindowImpl ::~ startWindowImpl ()
{
2008-06-07 21:11:57 +00:00
}
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
void startWindowImpl :: callNewGameDialog ()
{
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
//wenn Dialogfenster gezeigt werden soll
if ( myConfig -> readConfigInt ( "ShowGameSettingsDialogOnNewGame" )) {
2008-06-08 21:18:29 +00:00
2012-12-16 00:36:19 +01:00
#ifdef ANDROID
2012-12-21 01:01:01 +01:00
myGuiInterface -> getMyW () -> hide ();
2012-12-16 00:36:19 +01:00
#endif
2011-02-11 20:02:08 +00:00
myNewGameDialog -> exec ();
if ( myNewGameDialog -> result () == QDialog :: Accepted ) {
startNewLocalGame ( myNewGameDialog );
}
}
// sonst mit gespeicherten Werten starten
else {
startNewLocalGame ();
}
2008-09-13 20:40:08 +00:00
}
2011-02-11 20:02:08 +00:00
void startWindowImpl :: startNewLocalGame ( newGameDialogImpl * v )
{
2008-09-13 20:40:08 +00:00
2011-02-11 20:02:08 +00:00
this -> hide ();
myGuiInterface -> getMyW () -> show ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
// Start new local game - terminate existing network game.
mySession -> terminateNetworkClient ();
if ( myServerGuiInterface . get ())
myServerGuiInterface -> getSession () -> terminateNetworkServer ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
//get values from local game dialog
GameData gameData ;
if ( v ) {
// Set Game Data
gameData . maxNumberOfPlayers = v -> spinBox_quantityPlayers -> value ();
gameData . startMoney = v -> spinBox_startCash -> value ();
gameData . firstSmallBlind = v -> getChangeCompleteBlindsDialog () -> spinBox_firstSmallBlind -> value ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
if ( v -> getChangeCompleteBlindsDialog () -> radioButton_raiseBlindsAtHands -> isChecked ()) {
gameData . raiseIntervalMode = RAISE_ON_HANDNUMBER ;
gameData . raiseSmallBlindEveryHandsValue = v -> getChangeCompleteBlindsDialog () -> spinBox_raiseSmallBlindEveryHands -> value ();
} else {
gameData . raiseIntervalMode = RAISE_ON_MINUTES ;
gameData . raiseSmallBlindEveryMinutesValue = v -> getChangeCompleteBlindsDialog () -> spinBox_raiseSmallBlindEveryMinutes -> value ();
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
if ( v -> getChangeCompleteBlindsDialog () -> radioButton_alwaysDoubleBlinds -> isChecked ()) {
gameData . raiseMode = DOUBLE_BLINDS ;
} else {
gameData . raiseMode = MANUAL_BLINDS_ORDER ;
list < int > tempBlindList ;
int i ;
2013-08-28 10:49:03 +02:00
bool ok = true ;
2011-02-11 20:02:08 +00:00
for ( i = 0 ; i < v -> getChangeCompleteBlindsDialog () -> listWidget_blinds -> count (); i ++ ) {
tempBlindList . push_back ( v -> getChangeCompleteBlindsDialog () -> listWidget_blinds -> item ( i ) -> text (). toInt ( & ok , 10 ));
}
gameData . manualBlindsList = tempBlindList ;
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
if ( v -> getChangeCompleteBlindsDialog () -> radioButton_afterThisAlwaysDoubleBlinds -> isChecked ()) {
gameData . afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS ;
} else {
if ( v -> getChangeCompleteBlindsDialog () -> radioButton_afterThisAlwaysRaiseAbout -> isChecked ()) {
gameData . afterManualBlindsMode = AFTERMB_RAISE_ABOUT ;
gameData . afterMBAlwaysRaiseValue = v -> getChangeCompleteBlindsDialog () -> spinBox_afterThisAlwaysRaiseValue -> value ();
} else {
gameData . afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND ;
}
}
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
//Speeds
gameData . guiSpeed = v -> spinBox_gameSpeed -> value ();
}
// start with default values
else {
// Set Game Data
gameData . maxNumberOfPlayers = myConfig -> readConfigInt ( "NumberOfPlayers" );
gameData . startMoney = myConfig -> readConfigInt ( "StartCash" );
gameData . firstSmallBlind = myConfig -> readConfigInt ( "FirstSmallBlind" );
2008-09-13 20:40:08 +00:00
2011-02-11 20:02:08 +00:00
if ( myConfig -> readConfigInt ( "RaiseBlindsAtHands" )) {
gameData . raiseIntervalMode = RAISE_ON_HANDNUMBER ;
gameData . raiseSmallBlindEveryHandsValue = myConfig -> readConfigInt ( "RaiseSmallBlindEveryHands" );
} else {
gameData . raiseIntervalMode = RAISE_ON_MINUTES ;
gameData . raiseSmallBlindEveryMinutesValue = myConfig -> readConfigInt ( "RaiseSmallBlindEveryMinutes" );
}
2008-09-13 20:40:08 +00:00
2011-02-11 20:02:08 +00:00
if ( myConfig -> readConfigInt ( "AlwaysDoubleBlinds" )) {
gameData . raiseMode = DOUBLE_BLINDS ;
} else {
gameData . raiseMode = MANUAL_BLINDS_ORDER ;
gameData . manualBlindsList = myConfig -> readConfigIntList ( "ManualBlindsList" );
2008-09-13 20:40:08 +00:00
2011-02-11 20:02:08 +00:00
if ( myConfig -> readConfigInt ( "AfterMBAlwaysDoubleBlinds" )) {
gameData . afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS ;
} else {
if ( myConfig -> readConfigInt ( "AfterMBAlwaysRaiseAbout" )) {
gameData . afterManualBlindsMode = AFTERMB_RAISE_ABOUT ;
gameData . afterMBAlwaysRaiseValue = myConfig -> readConfigInt ( "AfterMBAlwaysRaiseValue" );
} else {
gameData . afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND ;
}
}
}
//Speeds
gameData . guiSpeed = myConfig -> readConfigInt ( "GameSpeed" );
}
// Set dealer pos.
StartData startData ;
int tmpDealerPos = 0 ;
startData . numberOfPlayers = gameData . maxNumberOfPlayers ;
2011-10-11 15:15:22 +00:00
Tools :: GetRand ( 0 , startData . numberOfPlayers - 1 , 1 , & tmpDealerPos );
2011-02-11 20:02:08 +00:00
//if(DEBUG_MODE) {
// tmpDealerPos = 4;
//}
startData . startDealerPlayerId = static_cast < unsigned > ( tmpDealerPos );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
//some gui modifications
myGuiInterface -> getMyW () -> localGameModification ();
//Start Game!!!
mySession -> startLocalGame ( gameData , startData );
2008-06-08 21:18:29 +00:00
}
2011-02-11 20:02:08 +00:00
void startWindowImpl :: callGameLobbyDialog ()
{
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
//Avoid join Lobby with "Human Player" nick
if ( QString :: fromUtf8 ( myConfig -> readConfigString ( "MyName" ). c_str ()) == QString ( "Human Player" )) {
changeContentDialogImpl dialog ( this , myConfig , CHANGE_HUMAN_PLAYER_NAME );
dialog . exec ();
if ( dialog . result () == QDialog :: Accepted ) {
joinGameLobby ();
}
} else {
joinGameLobby ();
}
2008-06-08 21:18:29 +00:00
}
2011-02-11 20:02:08 +00:00
void startWindowImpl :: joinGameLobby ()
{
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
// Stop local game.
myGuiInterface -> getMyW () -> stopTimer ();
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
mySession -> terminateNetworkClient ();
if ( myServerGuiInterface )
myServerGuiInterface -> getSession () -> terminateNetworkServer ();
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
myGameLobbyDialog -> setSession ( getSession ());
myStartNetworkGameDialog -> setSession ( getSession ());
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
// Clear Lobby dialog.
myGameLobbyDialog -> clearDialog ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
//start internet client with config values for user and pw TODO
mySession -> startInternetClient ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
//Dialog mit Statusbalken
myConnectToServerDialog -> exec ();
if ( myConnectToServerDialog -> result () == QDialog :: Accepted ) {
showLobbyDialog ();
} else {
mySession -> terminateNetworkClient ();
}
2009-11-08 21:18:25 +00:00
}
2011-02-11 20:02:08 +00:00
void startWindowImpl :: callInternetGameLoginDialog ()
{
2009-11-08 21:18:25 +00:00
2011-02-11 20:02:08 +00:00
//login
2010-08-15 20:11:31 +00:00
2011-02-11 20:02:08 +00:00
//HACK if Outdated Version info is available show it here!
if ( msgBoxOutdatedVersionActive ) {
msgBoxOutdatedVersionActive = false ;
msgBoxOutdatedVersion . exec ();
msgBoxOutdatedVersion . raise ();
msgBoxOutdatedVersion . activateWindow ();
}
2010-08-15 20:11:31 +00:00
2011-02-11 20:02:08 +00:00
myInternetGameLoginDialog -> exec ();
2010-08-15 20:11:31 +00:00
2011-02-11 20:02:08 +00:00
if ( myInternetGameLoginDialog -> result () == QDialog :: Accepted ) {
//send login infos
mySession -> setLogin (
2011-10-03 08:03:58 +00:00
myConfig -> readConfigString ( "MyName" ),
myInternetGameLoginDialog -> lineEdit_password -> text (). toUtf8 (). constData (),
myInternetGameLoginDialog -> checkBox_guest -> isChecked ());
2011-02-11 20:02:08 +00:00
} else {
myConnectToServerDialog -> reject ();
mySession -> terminateNetworkClient ();
}
2008-06-08 21:18:29 +00:00
}
2011-08-07 20:16:03 +00:00
2011-08-08 19:50:28 +00:00
void startWindowImpl :: callRejoinPossibleDialog ( unsigned gameId )
2011-10-29 14:41:17 +00:00
{
/*
2011-10-27 09:04:19 +00:00
assert(mySession);
GameInfo info(mySession->getClientGameInfo(gameId));*/
2011-08-08 19:50:28 +00:00
2012-12-21 01:01:01 +01:00
MyMessageBox msgBox ;
2011-08-07 20:16:03 +00:00
msgBox . setIcon ( QMessageBox :: Question );
2012-12-25 16:30:18 +01:00
msgBox . setWindowTitle ( tr ( "Rejoin possible!" ));
msgBox . setText ( tr ( "There is an existing session with a previous game." ));
msgBox . setInformativeText ( tr ( "Do you want to rejoin this game?" ));
2011-08-07 20:16:03 +00:00
msgBox . setStandardButtons ( QMessageBox :: Yes | QMessageBox :: No );
msgBox . setDefaultButton ( QMessageBox :: Yes );
int ret = msgBox . exec ();
switch ( ret ) {
2011-10-03 08:03:58 +00:00
case QMessageBox :: Yes :
2011-09-11 17:41:56 +00:00
mySession -> clientRejoinGame ( gameId );
2011-08-07 20:16:03 +00:00
break ;
2012-01-02 22:07:25 +00:00
case QMessageBox :: No :
;
2011-08-07 20:16:03 +00:00
break ;
}
}
2011-02-11 20:02:08 +00:00
void startWindowImpl :: callCreateNetworkGameDialog ()
{
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
myCreateNetworkGameDialog -> exec ();
//
if ( myCreateNetworkGameDialog -> result () == QDialog :: Accepted ) {
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
// Stop local game.
myGuiInterface -> getMyW () -> stopTimer ();
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
if ( ! myServerGuiInterface ) {
// Create pseudo Gui Wrapper for the server.
myServerGuiInterface . reset ( new ServerGuiWrapper ( myConfig , mySession -> getGui (), mySession -> getGui (), mySession -> getGui ()));
{
2012-01-02 22:07:25 +00:00
boost :: shared_ptr < Session > session ( new Session ( myServerGuiInterface . get (), myConfig , 0 ));
2011-02-11 20:02:08 +00:00
session -> init ( mySession -> getAvatarManager ());
myServerGuiInterface -> setSession ( session );
}
}
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
// Terminate existing network games.
mySession -> terminateNetworkClient ();
myServerGuiInterface -> getSession () -> terminateNetworkServer ();
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
GameData gameData ;
gameData . maxNumberOfPlayers = myCreateNetworkGameDialog -> spinBox_quantityPlayers -> value ();
gameData . startMoney = myCreateNetworkGameDialog -> spinBox_startCash -> value ();
gameData . firstSmallBlind = myCreateNetworkGameDialog -> getChangeCompleteBlindsDialog () -> spinBox_firstSmallBlind -> value ();
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
if ( myCreateNetworkGameDialog -> getChangeCompleteBlindsDialog () -> radioButton_raiseBlindsAtHands -> isChecked ()) {
gameData . raiseIntervalMode = RAISE_ON_HANDNUMBER ;
gameData . raiseSmallBlindEveryHandsValue = myCreateNetworkGameDialog -> getChangeCompleteBlindsDialog () -> spinBox_raiseSmallBlindEveryHands -> value ();
} else {
gameData . raiseIntervalMode = RAISE_ON_MINUTES ;
gameData . raiseSmallBlindEveryMinutesValue = myCreateNetworkGameDialog -> getChangeCompleteBlindsDialog () -> spinBox_raiseSmallBlindEveryMinutes -> value ();
}
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
if ( myCreateNetworkGameDialog -> getChangeCompleteBlindsDialog () -> radioButton_alwaysDoubleBlinds -> isChecked ()) {
gameData . raiseMode = DOUBLE_BLINDS ;
} else {
gameData . raiseMode = MANUAL_BLINDS_ORDER ;
std :: list < int > tempBlindList ;
int i ;
2013-08-28 10:49:03 +02:00
bool ok = true ;
2011-02-11 20:02:08 +00:00
for ( i = 0 ; i < myCreateNetworkGameDialog -> getChangeCompleteBlindsDialog () -> listWidget_blinds -> count (); i ++ ) {
tempBlindList . push_back ( myCreateNetworkGameDialog -> getChangeCompleteBlindsDialog () -> listWidget_blinds -> item ( i ) -> text (). toInt ( & ok , 10 ));
}
gameData . manualBlindsList = tempBlindList ;
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
if ( myCreateNetworkGameDialog -> getChangeCompleteBlindsDialog () -> radioButton_afterThisAlwaysDoubleBlinds -> isChecked ()) {
gameData . afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS ;
} else {
if ( myCreateNetworkGameDialog -> getChangeCompleteBlindsDialog () -> radioButton_afterThisAlwaysRaiseAbout -> isChecked ()) {
gameData . afterManualBlindsMode = AFTERMB_RAISE_ABOUT ;
gameData . afterMBAlwaysRaiseValue = myCreateNetworkGameDialog -> getChangeCompleteBlindsDialog () -> spinBox_afterThisAlwaysRaiseValue -> value ();
} else {
gameData . afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND ;
}
}
}
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
gameData . guiSpeed = myConfig -> readConfigInt ( "GameSpeed" );
gameData . delayBetweenHandsSec = myCreateNetworkGameDialog -> spinBox_netDelayBetweenHands -> value ();
gameData . playerActionTimeoutSec = myCreateNetworkGameDialog -> spinBox_netTimeOutPlayerAction -> value ();
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
myGameLobbyDialog -> setSession ( getSession ());
myStartNetworkGameDialog -> setSession ( getSession ());
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
// Clear network game dialog.
myStartNetworkGameDialog -> clearDialog ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
myServerGuiInterface -> getSession () -> startNetworkServer ( false );
mySession -> startNetworkClientForLocalServer ( gameData );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
myStartNetworkGameDialog -> setMaxPlayerNumber ( gameData . maxNumberOfPlayers );
2010-03-30 12:25:30 +00:00
2012-12-25 16:30:18 +01:00
myStartNetworkGameDialog -> setWindowTitle ( tr ( "Start Network Game" ));
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
showNetworkStartDialog ();
}
2008-08-31 21:21:52 +00:00
}
2011-02-11 20:02:08 +00:00
void startWindowImpl :: callJoinNetworkGameDialog ()
{
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
myJoinNetworkGameDialog -> exec ();
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
if ( myJoinNetworkGameDialog -> result () == QDialog :: Accepted ) {
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
// Stop local game.
myGuiInterface -> getMyW () -> stopTimer ();
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
mySession -> terminateNetworkClient ();
if ( myServerGuiInterface )
myServerGuiInterface -> getSession () -> terminateNetworkServer ();
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
myGameLobbyDialog -> setSession ( getSession ());
myStartNetworkGameDialog -> setSession ( getSession ());
// Clear network game dialog
myStartNetworkGameDialog -> clearDialog ();
// Maybe use QUrl::toPunycode.
mySession -> startNetworkClient (
2011-10-03 08:03:58 +00:00
myJoinNetworkGameDialog -> lineEdit_ipAddress -> text (). toUtf8 (). constData (),
myJoinNetworkGameDialog -> spinBox_port -> value (),
myJoinNetworkGameDialog -> checkBox_ipv6 -> isChecked (),
myJoinNetworkGameDialog -> checkBox_sctp -> isChecked ());
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
//Dialog mit Statusbalken
myConnectToServerDialog -> exec ();
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
if ( myConnectToServerDialog -> result () == QDialog :: Rejected ) {
mySession -> terminateNetworkClient ();
actionJoin_Network_Game -> trigger (); // re-trigger
} else {
//needed for join and ready sounds - TODO
//myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers);
2012-12-25 16:30:18 +01:00
myStartNetworkGameDialog -> setWindowTitle ( tr ( "Start Network Game" ));
2008-08-31 21:21:52 +00:00
2011-02-11 20:02:08 +00:00
showNetworkStartDialog ();
}
}
2008-08-31 21:21:52 +00:00
}
2008-06-08 21:18:29 +00:00
void startWindowImpl :: showClientDialog ()
{
2011-02-11 20:02:08 +00:00
if ( mySession -> getGameType () == Session :: GAME_TYPE_NETWORK ) {
if ( myGuiInterface -> getMyW () -> isVisible ())
myGuiInterface -> getMyW () -> hide ();
if ( ! this -> isVisible ())
this -> show ();
if ( ! myStartNetworkGameDialog -> isVisible ())
showNetworkStartDialog ();
} else if ( mySession -> getGameType () == Session :: GAME_TYPE_INTERNET ) {
if ( myGuiInterface -> getMyW () -> isVisible ())
myGuiInterface -> getMyW () -> closeMessageBoxes ();
myGuiInterface -> getMyW () -> hide ();
if ( ! this -> isVisible ())
this -> show ();
if ( ! myGameLobbyDialog -> isVisible ())
showLobbyDialog ();
}
2008-06-08 21:18:29 +00:00
}
void startWindowImpl :: showLobbyDialog ()
{
2011-02-11 20:02:08 +00:00
myGameLobbyDialog -> exec ();
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
if ( myGameLobbyDialog -> result () == QDialog :: Accepted ) {
this -> hide ();
//some gui modifications
myGuiInterface -> getMyW () -> networkGameModification ();
} else {
myGameLobbyDialog -> clearDialog ();
mySession -> terminateNetworkClient ();
}
2008-06-08 21:18:29 +00:00
}
void startWindowImpl :: showNetworkStartDialog ()
{
2011-02-11 20:02:08 +00:00
myStartNetworkGameDialog -> exec ();
2008-06-08 21:18:29 +00:00
2011-02-11 20:02:08 +00:00
if ( myStartNetworkGameDialog -> result () == QDialog :: Accepted ) {
this -> hide ();
//some gui modifications
myGuiInterface -> getMyW () -> networkGameModification ();
} else {
mySession -> terminateNetworkClient ();
if ( myServerGuiInterface )
myServerGuiInterface -> getSession () -> terminateNetworkServer ();
}
2008-06-08 21:18:29 +00:00
}
2008-09-11 15:03:46 +00:00
2011-02-11 20:02:08 +00:00
void startWindowImpl :: callAboutPokerthDialog ()
{
myAboutPokerthDialog -> exec ();
2008-09-11 15:03:46 +00:00
}
2008-09-17 21:50:51 +00:00
2012-01-06 09:34:26 +00:00
void startWindowImpl :: callSettingsDialogFromStartwindow ()
2011-02-11 20:02:08 +00:00
{
2012-01-06 09:34:26 +00:00
callSettingsDialog ( false );
}
2008-09-17 21:50:51 +00:00
2012-01-06 09:34:26 +00:00
void startWindowImpl :: callSettingsDialog ( bool ingame )
{
mySettingsDialog -> exec ( ingame );
2011-02-11 20:02:08 +00:00
if ( mySettingsDialog -> result () == QDialog :: Accepted && mySettingsDialog -> getSettingsCorrect ()) {
myGuiInterface -> getMyW () -> applySettings ( mySettingsDialog );
}
2008-09-17 21:50:51 +00:00
}
2012-09-17 23:44:33 +02:00
void startWindowImpl :: callLogFileDialog ()
{
myLogFileDialog -> exec ();
}
2011-02-11 20:02:08 +00:00
void startWindowImpl :: showTimeoutDialog ( int msgID , unsigned duration )
{
if ( myTimeoutDialog -> isHidden ()) {
myTimeoutDialog -> setMySession ( mySession );
myTimeoutDialog -> setMsgID (( NetTimeoutReason ) msgID );
myTimeoutDialog -> setTimeoutDuration ( duration );
myTimeoutDialog -> show ();
myTimeoutDialog -> raise ();
myTimeoutDialog -> activateWindow ();
myTimeoutDialog -> startTimeout ();
}
}
2008-09-17 21:50:51 +00:00
2011-02-11 20:02:08 +00:00
void startWindowImpl :: hideTimeoutDialog ()
{
myTimeoutDialog -> hide ();
}
void startWindowImpl :: networkError ( int errorID , int /*osErrorID*/ )
{
hideTimeoutDialog ();
switch ( errorID ) {
case ERR_SOCK_SERVERADDR_NOT_SET : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Server address was not set." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_INVALID_PORT : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "An invalid port was set (ports 0-1023 are not allowed)." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_CREATION_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Could not create a socket for TCP communication." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_SET_ADDR_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Could not set the IP address." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_SET_PORT_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Could not set the port for this type of address." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_RESOLVE_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The server name could not be resolved." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_BIND_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Bind failed - please choose a different port." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_LISTEN_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Internal network error: \" listen \" failed." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_ACCEPT_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Server execution was terminated." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_CONNECT_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Could not connect to the server." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
2014-05-10 21:06:50 +02:00
case ERR_SOCK_CONNECT_IPV6_FAILED : {
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Could not connect to the server. \n\n Please note: IPv6 is enabled in the settings. The connection fails if your provider does not support IPv6. \n This may be fixed by unchecking the \" Use IPv6 \" checkbox in the settings." ),
QMessageBox :: Close );
}
break ;
2011-02-11 20:02:08 +00:00
case ERR_SOCK_CONNECT_TIMEOUT : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Connection timed out. \n Please check the server address. \n\n If the server is behind a NAT-Router, make sure port forwarding has been set up on server side." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
2014-05-10 21:06:50 +02:00
case ERR_SOCK_CONNECT_IPV6_TIMEOUT : {
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Connection timed out. \n Please check the server address. \n\n Please note: IPv6 is enabled in the settings. The connection fails if your provider does not support IPv6. \n This may be fixed by unchecking the \" Use IPv6 \" checkbox in the settings." ),
QMessageBox :: Close );
}
break ;
2011-02-11 20:02:08 +00:00
case ERR_SOCK_SELECT_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Internal network error: \" select \" failed." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_SEND_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Internal network error: \" send \" failed." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_RECV_FAILED : // Sometimes windows reports recv failed on close.
case ERR_SOCK_CONN_RESET : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The connection to the server was lost." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_CONN_EXISTS : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Internal network error: Duplicate TCP connection." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_INVALID_PACKET : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "An invalid network packet was received. \n Please make sure that all players use the same version of PokerTH." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_INVALID_STATE : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Internal state error. \n Please make sure that all players use the same version of PokerTH." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_INVALID_SERVERLIST_URL :
case ERR_SOCK_TRANSFER_INVALID_URL : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Invalid server list URL. \n Please correct the address in the settings." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_INVALID_SERVERLIST_XML : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The PokerTH internet server list contains invalid data. \n If you use a custom server list, please make sure its format is correct." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_UNZIP_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Could not unzip the PokerTH internet server list." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_TRANSFER_INIT_FAILED :
case ERR_SOCK_TRANSFER_SELECT_FAILED :
case ERR_SOCK_TRANSFER_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Could not download the PokerTH internet server list. \n Please make sure you are directly connected to the internet." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_SOCK_TRANSFER_OPEN_FAILED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Could not open the target file when downloading the server list." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_VERSION_NOT_SUPPORTED : {
2012-12-21 01:01:01 +01:00
MyMessageBox msgBox ( QMessageBox :: Warning , tr ( "Network Error" ),
tr ( "The PokerTH server does not support this version of the game.<br>Please go to <a href= \" http://www.pokerth.net/ \" target= \" _blank \" >http://www.pokerth.net</a> and download the latest version." ),
QMessageBox :: Close , this );
2011-02-11 20:02:08 +00:00
msgBox . setTextFormat ( Qt :: RichText );
msgBox . exec ();
}
break ;
case ERR_NET_SERVER_FULL : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Sorry, this server is already full." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_INVALID_PASSWORD : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Invalid login. \n Please check your username and password." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_INVALID_PASSWORD_STR : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The password is too long. Please choose another one." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_PLAYER_NAME_IN_USE : {
changeContentDialogImpl dialog ( this , myConfig , CHANGE_NICK_ALREADY_IN_USE );
dialog . exec ();
}
break ;
case ERR_NET_INVALID_PLAYER_NAME : {
changeContentDialogImpl dialog ( this , myConfig , CHANGE_NICK_INVALID );
dialog . exec ();
}
break ;
case ERR_NET_INVALID_GAME_NAME : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The game name is either too short or too long. Please choose another one." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_UNKNOWN_GAME : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The game could not be found." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_INVALID_CHAT_TEXT : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The chat text is invalid." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_UNKNOWN_PLAYER_ID : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The server referred to an unknown player. Aborting." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_NO_CURRENT_PLAYER : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Internal error: The current player could not be found." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_PLAYER_NOT_ACTIVE : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Internal error: The current player is not active." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_PLAYER_KICKED : {
mySession -> terminateNetworkClient ();
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "You were kicked from the server." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_PLAYER_BANNED : {
mySession -> terminateNetworkClient ();
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "You were temporarily banned from the server." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_PLAYER_BLOCKED : {
mySession -> terminateNetworkClient ();
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Your account is blocked indefinitely." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_SESSION_TIMED_OUT : {
mySession -> terminateNetworkClient ();
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Your server connection timed out due to inactivity. You are very welcome to reconnect!" ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_INVALID_PLAYER_COUNT : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The client player count is invalid." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_TOO_MANY_MANUAL_BLINDS : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Too many manual blinds were set. Please reconfigure the manual blinds." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_INVALID_AVATAR_FILE :
case ERR_NET_WRONG_AVATAR_SIZE : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "An invalid avatar file was configured. Please choose a different avatar." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_AVATAR_TOO_LARGE : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The selected avatar file is too large. Please choose a different avatar." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_INIT_BLOCKED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "You cannot login at this time. Please try again in a few seconds." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_INVALID_REQUEST_ID : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "An internal avatar error occured. Please report this to an admin in the lobby chat." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_START_TIMEOUT : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "Could not start game: Synchronization failed." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case ERR_NET_SERVER_MAINTENANCE : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "The server is down for maintenance. Please try again later." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
default : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Error" ),
tr ( "An internal error occured." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
}
// close dialogs
myGameLobbyDialog -> reject ();
myConnectToServerDialog -> reject ();
myStartNetworkGameDialog -> reject ();
2011-10-20 14:13:25 +00:00
myGuiInterface -> getMyW () -> close ();
2011-11-19 11:01:54 +00:00
myInternetGameLoginDialog -> reject ();
2008-09-17 21:50:51 +00:00
}
void startWindowImpl :: networkNotification ( int notificationId )
{
2011-02-11 20:02:08 +00:00
hideTimeoutDialog ();
switch ( notificationId ) {
case NTF_NET_JOIN_IP_BLOCKED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Notification" ),
tr ( "You cannot join this game, because another player in that game has your network address." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case NTF_NET_REMOVED_START_FAILED : {
2011-08-21 18:15:42 +00:00
myGameLobbyDialog -> stopWaitStartGameMsgBoxTimer ();
2012-12-21 01:01:01 +01:00
if ( MyMessageBox :: warning ( this , tr ( "Network Notification" ),
tr ( "Your connection to the server is very slow, the game had to start without you." ),
QMessageBox :: Close ) == QMessageBox :: Close ) {
2011-08-21 18:15:42 +00:00
myGameLobbyDialog -> hideWaitStartGameMsgBox ();
}
2011-02-11 20:02:08 +00:00
}
break ;
case NTF_NET_REMOVED_KICKED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Notification" ),
tr ( "You were kicked from the game." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case NTF_NET_REMOVED_GAME_FULL :
case NTF_NET_JOIN_GAME_FULL : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Notification" ),
tr ( "Sorry, this game is already full." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case NTF_NET_REMOVED_ALREADY_RUNNING :
case NTF_NET_JOIN_ALREADY_RUNNING : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Notification" ),
tr ( "Unable to join - the server has already started the game." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case NTF_NET_JOIN_NOT_INVITED : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Notification" ),
tr ( "This game is of type invite-only. You cannot join this game without being invited." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case NTF_NET_JOIN_GAME_NAME_IN_USE : {
changeContentDialogImpl dialog ( this , myConfig , CHANGE_INET_GAME_NAME_IN_USE );
dialog . exec ();
if ( dialog . result () == QDialog :: Accepted ) {
myGameLobbyDialog -> pushButton_CreateGame -> click ();
}
}
break ;
case NTF_NET_JOIN_GAME_BAD_NAME : {
changeContentDialogImpl dialog ( this , myConfig , CHANGE_INET_BAD_GAME_NAME );
dialog . exec ();
if ( dialog . result () == QDialog :: Accepted ) {
myGameLobbyDialog -> pushButton_CreateGame -> click ();
}
}
break ;
case NTF_NET_REMOVED_TIMEOUT : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Notification" ),
tr ( "Your admin state timed out due to inactivity. Feel free to create a new game!" ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case NTF_NET_JOIN_INVALID_PASSWORD : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Notification" ),
tr ( "Invalid password when joining the game. \n Please reenter the password and try again." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case NTF_NET_JOIN_GUEST_FORBIDDEN : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Notification" ),
tr ( "You cannot join this type of game as guest." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case NTF_NET_JOIN_INVALID_SETTINGS : {
2012-12-21 01:01:01 +01:00
MyMessageBox :: warning ( this , tr ( "Network Notification" ),
tr ( "The settings are invalid for this type of game." ),
QMessageBox :: Close );
2011-02-11 20:02:08 +00:00
}
break ;
case NTF_NET_NEW_RELEASE_AVAILABLE : {
msgBoxOutdatedVersion . setIcon ( QMessageBox :: Information );
msgBoxOutdatedVersion . setWindowTitle ( tr ( "Network Notification" ));
msgBoxOutdatedVersion . setText ( tr ( "A new release of PokerTH is available.<br>Please go to <a href= \" http://www.pokerth.net/ \" target= \" _blank \" >http://www.pokerth.net</a> and download the latest version." ));
msgBoxOutdatedVersion . setTextFormat ( Qt :: RichText );
msgBoxOutdatedVersion . setStandardButtons ( QMessageBox :: Ok );
msgBoxOutdatedVersion . setDefaultButton ( QMessageBox :: Ok );
2010-08-15 20:11:31 +00:00
2011-02-11 20:02:08 +00:00
msgBoxOutdatedVersionActive = true ;
}
break ;
case NTF_NET_OUTDATED_BETA : {
msgBoxOutdatedVersion . setIcon ( QMessageBox :: Information );
msgBoxOutdatedVersion . setWindowTitle ( tr ( "Network Notification" ));
msgBoxOutdatedVersion . setText ( tr ( "This beta release of PokerTH is outdated.<br>Please go to <a href= \" http://www.pokerth.net/ \" target= \" _blank \" >http://www.pokerth.net</a> and download the latest version." ));
msgBoxOutdatedVersion . setTextFormat ( Qt :: RichText );
msgBoxOutdatedVersion . setStandardButtons ( QMessageBox :: Ok );
msgBoxOutdatedVersion . setDefaultButton ( QMessageBox :: Ok );
2010-08-15 20:11:31 +00:00
2011-02-11 20:02:08 +00:00
msgBoxOutdatedVersionActive = true ;
}
break ;
}
2008-09-17 21:50:51 +00:00
}
2008-12-26 16:47:14 +00:00
void startWindowImpl :: networkMessage ( QString msg )
{
2012-12-21 01:01:01 +01:00
MyMessageBox msgBox ( QMessageBox :: Information , tr ( "Server Message" ),
msg , QMessageBox :: Close , this );
2011-02-11 20:02:08 +00:00
msgBox . setTextFormat ( Qt :: RichText );
msgBox . exec ();
2008-12-26 16:47:14 +00:00
}
2011-01-10 21:40:48 +00:00
void startWindowImpl :: networkMessage ( unsigned msgId )
{
2011-02-11 20:02:08 +00:00
QString msgText ;
2013-02-26 23:32:47 +01:00
bool showMsgBox = true ;
2011-01-10 21:40:48 +00:00
2011-02-11 20:02:08 +00:00
switch ( msgId ) {
2011-01-10 21:40:48 +00:00
2011-02-11 20:02:08 +00:00
case MSG_NET_AVATAR_REPORT_ACCEPTED : {
msgText = tr ( "The avatar report was accepted by the server. Thank you." );
}
break ;
case MSG_NET_AVATAR_REPORT_DUP : {
msgText = tr ( "This avatar was already reported by another player." );
}
break ;
case MSG_NET_AVATAR_REPORT_REJECTED : {
msgText = tr ( "An error occurred while reporting the avatar." );
}
break ;
2012-03-29 14:28:53 +00:00
case MSG_NET_GAMENAME_REPORT_ACCEPTED : {
msgText = tr ( "The game name report was accepted by the server. Thank you." );
}
break ;
case MSG_NET_GAMENAME_REPORT_DUP : {
msgText = tr ( "This game name was already reported by another player." );
}
break ;
case MSG_NET_GAMENAME_REPORT_REJECTED : {
msgText = tr ( "An error occurred while reporting the game name." );
}
break ;
2013-02-26 23:25:33 +01:00
case MSG_NET_ADMIN_REMOVE_GAME_ACCEPTED : {
2013-02-26 23:45:57 +01:00
msgText = tr ( "The game was closed." );
2013-02-26 23:25:33 +01:00
}
break ;
case MSG_NET_ADMIN_REMOVE_GAME_REJECTED : {
msgText = tr ( "The game could not be closed." );
}
break ;
case MSG_NET_ADMIN_BAN_PLAYER_ACCEPTED : {
2013-02-26 23:45:57 +01:00
msgText = tr ( "The player was kicked and banned permanently." );
2013-02-26 23:25:33 +01:00
}
break ;
case MSG_NET_ADMIN_BAN_PLAYER_NODB : {
2013-02-26 23:45:57 +01:00
msgText = tr ( "The player was kicked, but could not be banned because it was a guest player." );
2013-02-26 23:25:33 +01:00
}
break ;
case MSG_NET_ADMIN_BAN_PLAYER_DBERROR : {
2013-02-26 23:45:57 +01:00
msgText = tr ( "The player was kicked, but could not be banned, \n because the nick could not be found in the database" );
2013-02-26 23:25:33 +01:00
}
break ;
case MSG_NET_ADMIN_BAN_PLAYER_REJECTED : {
2013-02-26 23:45:57 +01:00
msgText = tr ( "The player could not be found." );
2013-02-26 23:25:33 +01:00
}
break ;
2013-10-06 16:30:09 +02:00
default :
showMsgBox = false ;
break ;
2013-02-26 23:32:47 +01:00
}
if ( showMsgBox ) {
MyMessageBox msgBox ( QMessageBox :: Information , tr ( "Server Message" ),
msgText , QMessageBox :: Close , this );
// msgBox.setTextFormat(Qt::RichText);
msgBox . exec ();
2011-02-11 20:02:08 +00:00
}
2011-01-10 21:40:48 +00:00
}
2008-09-17 21:50:51 +00:00
void startWindowImpl :: networkStart ( boost :: shared_ptr < Game > game )
{
2011-02-11 20:02:08 +00:00
mySession -> startClientGame ( game );
2008-09-17 21:50:51 +00:00
2011-02-11 20:02:08 +00:00
//send playerNicksList to chat for nick-autocompletition
myGuiInterface -> getMyW () -> getMyChat () -> setPlayerNicksList ( getPlayerNicksList ());
2008-09-17 21:50:51 +00:00
}
2011-02-11 20:02:08 +00:00
QStringList startWindowImpl :: getPlayerNicksList ()
{
2008-09-17 21:50:51 +00:00
2011-02-11 20:02:08 +00:00
QStringList list ;
PlayerListConstIterator it_c ;
PlayerList seatList = mySession -> getCurrentGame () -> getSeatsList ();
2011-02-09 14:33:39 +00:00
for ( it_c = seatList -> begin (); it_c != seatList -> end (); ++ it_c ) {
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
list << QString :: fromUtf8 (( * it_c ) -> getMyName (). c_str ());
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
return list ;
2008-09-19 19:37:12 +00:00
}
2010-07-11 20:36:50 +00:00
QString startWindowImpl :: checkForFirstStartAfterUpdated ()
{
2011-02-11 20:02:08 +00:00
if ( myConfig -> getConfigState () == OLD ) {
2010-07-11 20:36:50 +00:00
2011-02-11 20:02:08 +00:00
if ( POKERTH_VERSION_MAJOR == 0 && POKERTH_VERSION_MINOR == 80 ) {
//version 0.8 HACK
//to avoid old PokerTH distributed styles pathes in settings which leads to error message like "outdated" prepare settings dialog (fallback will correct this issue) and save settings
mySettingsDialog -> prepareDialog ();
mySettingsDialog -> isAccepted ();
myGuiInterface -> getMyW () -> applySettings ( mySettingsDialog );
}
return QString ( "Update old config to version %1" ). arg ( QString :: number ( POKERTH_VERSION_MAJOR ) + "." + QString :: number ( POKERTH_VERSION_MINOR ));
}
2010-07-11 20:36:50 +00:00
2011-02-11 20:02:08 +00:00
return QString ();
2010-07-11 20:36:50 +00:00
}
2010-07-13 19:13:38 +00:00
bool startWindowImpl :: eventFilter ( QObject * obj , QEvent * event )
{
2011-02-11 20:02:08 +00:00
if ( event -> type () == QEvent :: Close ) {
event -> ignore ();
2011-08-07 20:16:03 +00:00
// mySession->getMyLog()->closeLogDbAtExit();
2011-02-11 20:02:08 +00:00
return QMainWindow :: eventFilter ( obj , event );
} else {
// pass the event on to the parent class
return QMainWindow :: eventFilter ( obj , event );
}
2010-07-13 19:13:38 +00:00
}