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 "createinternetgamedialogimpl.h"
|
2007-08-21 23:31:09 +00:00
|
|
|
#include "session.h"
|
|
|
|
|
#include "configfile.h"
|
2010-03-26 23:08:12 +00:00
|
|
|
#include "gamedata.h"
|
2007-09-27 00:35:30 +00:00
|
|
|
#include "changecompleteblindsdialogimpl.h"
|
|
|
|
|
|
2007-08-21 23:31:09 +00:00
|
|
|
|
|
|
|
|
createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, ConfigFile *c)
|
2011-02-11 20:02:08 +00:00
|
|
|
: QDialog(parent), myConfig(c), currentGuestMode(false), currentPlayerName("")
|
2007-08-21 23:31:09 +00:00
|
|
|
{
|
2007-12-04 01:37:43 +00:00
|
|
|
#ifdef __APPLE__
|
2007-11-28 22:00:42 +00:00
|
|
|
setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
|
2011-02-11 20:02:08 +00:00
|
|
|
#endif
|
|
|
|
|
setupUi(this);
|
2012-12-21 00:36:01 +01:00
|
|
|
this->installEventFilter(this);
|
2007-08-21 23:31:09 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
comboBox_gameType->setItemData(0, GAME_TYPE_NORMAL, Qt::UserRole);
|
|
|
|
|
comboBox_gameType->setItemData(1, GAME_TYPE_REGISTERED_ONLY, Qt::UserRole);
|
|
|
|
|
comboBox_gameType->setItemData(2, GAME_TYPE_INVITE_ONLY, Qt::UserRole);
|
|
|
|
|
comboBox_gameType->setItemData(3, GAME_TYPE_RANKING, Qt::UserRole);
|
2010-03-26 23:08:12 +00:00
|
|
|
|
2007-09-27 00:35:30 +00:00
|
|
|
myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl;
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
startBlind = new QLabel(tr("<i>First small blind: $%1</i>").arg(RANKING_GAME_START_SBLIND));
|
|
|
|
|
raiseMode = new QLabel(tr("<i>Double blinds every %1'th hand</i>").arg(RANKING_GAME_RAISE_EVERY_HAND));
|
|
|
|
|
startBlind->hide();
|
|
|
|
|
raiseMode->hide();
|
|
|
|
|
gridLayout1->addWidget(startBlind, 0, 0, 1, 1);
|
|
|
|
|
gridLayout1->addWidget(raiseMode, 1, 0, 1, 1);
|
2010-04-02 18:01:08 +00:00
|
|
|
|
2007-09-27 00:35:30 +00:00
|
|
|
connect( radioButton_changeBlindsSettings, SIGNAL( clicked(bool) ), this, SLOT( callChangeBlindsDialog(bool) ) );
|
2012-01-30 20:54:05 +00:00
|
|
|
#ifndef GUI_800x480
|
2007-08-21 23:31:09 +00:00
|
|
|
connect( pushButton_cancel, SIGNAL( clicked() ), this, SLOT( cancel() ) );
|
2012-01-30 20:54:05 +00:00
|
|
|
#endif
|
2007-08-21 23:31:09 +00:00
|
|
|
connect( pushButton_createGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
|
2011-02-11 20:02:08 +00:00
|
|
|
connect( checkBox_Password, SIGNAL( toggled(bool) ), this, SLOT( clearGamePassword(bool)) );
|
|
|
|
|
connect( comboBox_gameType, SIGNAL(currentIndexChanged(int)), this, SLOT( gameTypeChanged() ) );
|
2007-08-21 23:31:09 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void createInternetGameDialogImpl::exec(bool guestMode, QString playerName)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
currentGuestMode = guestMode;
|
|
|
|
|
currentPlayerName = playerName;
|
|
|
|
|
fillFormular(guestMode, playerName);
|
2007-08-21 23:31:09 +00:00
|
|
|
QDialog::exec();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void createInternetGameDialogImpl::createGame()
|
|
|
|
|
{
|
|
|
|
|
|
2007-08-21 23:31:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void createInternetGameDialogImpl::cancel()
|
|
|
|
|
{
|
|
|
|
|
|
2007-08-21 23:31:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerName)
|
|
|
|
|
{
|
|
|
|
|
|
2007-08-21 23:31:09 +00:00
|
|
|
//Network Game Settings
|
2009-10-23 23:12:33 +00:00
|
|
|
spinBox_netDelayBetweenHands->setValue(myConfig->readConfigInt("NetDelayBetweenHands"));
|
2007-08-21 23:31:09 +00:00
|
|
|
spinBox_netTimeOutPlayerAction->setValue(myConfig->readConfigInt("NetTimeOutPlayerAction"));
|
2007-08-26 08:02:07 +00:00
|
|
|
checkBox_Password->setChecked(myConfig->readConfigInt("UseInternetGamePassword"));
|
|
|
|
|
if(myConfig->readConfigInt("UseInternetGamePassword")) {
|
|
|
|
|
lineEdit_Password->setText(QString::fromUtf8(myConfig->readConfigString("InternetGamePassword").c_str()));
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-23 19:58:19 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(guestMode) {
|
|
|
|
|
comboBox_gameType->setCurrentIndex(0);
|
|
|
|
|
comboBox_gameType->setDisabled(true);
|
|
|
|
|
lineEdit_gameName->setText(tr("%1's game").arg(playerName));
|
|
|
|
|
lineEdit_gameName->setDisabled(true);
|
2007-08-21 23:31:09 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
} else {
|
|
|
|
|
comboBox_gameType->setDisabled(false);
|
|
|
|
|
comboBox_gameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType"));
|
|
|
|
|
lineEdit_gameName->setDisabled(false);
|
|
|
|
|
lineEdit_gameName->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str()));
|
|
|
|
|
}
|
2010-03-25 10:36:51 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
gameTypeChanged();
|
2007-08-21 23:31:09 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void createInternetGameDialogImpl::keyPressEvent ( QKeyEvent * event )
|
|
|
|
|
{
|
2007-08-21 23:31:09 +00:00
|
|
|
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if (event->key() == 16777220) {
|
|
|
|
|
pushButton_createGame->click(); //ENTER
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-21 23:31:09 +00:00
|
|
|
}
|
2007-08-26 12:45:37 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void createInternetGameDialogImpl::clearGamePassword(bool clear)
|
|
|
|
|
{
|
2007-08-26 12:45:37 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(!clear) {
|
|
|
|
|
lineEdit_Password->clear();
|
|
|
|
|
}
|
2007-09-04 23:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void createInternetGameDialogImpl::callChangeBlindsDialog(bool show)
|
|
|
|
|
{
|
2007-09-27 00:35:30 +00:00
|
|
|
|
|
|
|
|
if(show) {
|
|
|
|
|
myChangeCompleteBlindsDialog->exec();
|
|
|
|
|
if(myChangeCompleteBlindsDialog->result() == QDialog::Accepted ) {}
|
|
|
|
|
else {
|
|
|
|
|
radioButton_useSavedBlindsSettings->setChecked(TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-25 10:36:51 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void createInternetGameDialogImpl::gameTypeChanged()
|
|
|
|
|
{
|
2010-03-25 10:36:51 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
switch (comboBox_gameType->currentIndex()) {
|
2010-03-25 10:36:51 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
case GAME_TYPE_NORMAL-1: {
|
|
|
|
|
checkBox_Password->setDisabled(FALSE);
|
|
|
|
|
spinBox_startCash->setDisabled(FALSE);
|
|
|
|
|
spinBox_quantityPlayers->setDisabled(FALSE);
|
|
|
|
|
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers"));
|
|
|
|
|
spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash"));
|
|
|
|
|
radioButton_useSavedBlindsSettings->show();
|
|
|
|
|
radioButton_changeBlindsSettings->show();
|
|
|
|
|
startBlind->hide();
|
|
|
|
|
raiseMode->hide();
|
|
|
|
|
}
|
2010-04-02 18:01:08 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
break;
|
|
|
|
|
case GAME_TYPE_REGISTERED_ONLY-1: {
|
|
|
|
|
checkBox_Password->setDisabled(FALSE);
|
|
|
|
|
spinBox_startCash->setDisabled(FALSE);
|
|
|
|
|
spinBox_quantityPlayers->setDisabled(FALSE);
|
|
|
|
|
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers"));
|
|
|
|
|
spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash"));
|
|
|
|
|
radioButton_useSavedBlindsSettings->show();
|
|
|
|
|
radioButton_changeBlindsSettings->show();
|
|
|
|
|
startBlind->hide();
|
|
|
|
|
raiseMode->hide();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case GAME_TYPE_INVITE_ONLY-1: {
|
|
|
|
|
checkBox_Password->setChecked(FALSE);
|
|
|
|
|
checkBox_Password->setDisabled(TRUE);
|
|
|
|
|
spinBox_startCash->setDisabled(FALSE);
|
|
|
|
|
spinBox_quantityPlayers->setDisabled(FALSE);
|
|
|
|
|
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers"));
|
|
|
|
|
spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash"));
|
|
|
|
|
radioButton_useSavedBlindsSettings->show();
|
|
|
|
|
radioButton_changeBlindsSettings->show();
|
|
|
|
|
startBlind->hide();
|
|
|
|
|
raiseMode->hide();
|
2010-04-02 18:01:08 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case GAME_TYPE_RANKING-1: {
|
|
|
|
|
checkBox_Password->setChecked(FALSE);
|
|
|
|
|
checkBox_Password->setDisabled(TRUE);
|
2010-04-02 18:01:08 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
spinBox_startCash->setValue(RANKING_GAME_START_CASH);
|
|
|
|
|
spinBox_startCash->setDisabled(TRUE);
|
|
|
|
|
spinBox_quantityPlayers->setValue(RANKING_GAME_NUMBER_OF_PLAYERS);
|
|
|
|
|
spinBox_quantityPlayers->setDisabled(TRUE);
|
|
|
|
|
radioButton_useSavedBlindsSettings->hide();
|
|
|
|
|
radioButton_changeBlindsSettings->hide();
|
|
|
|
|
startBlind->show();
|
|
|
|
|
raiseMode->show();
|
2010-04-02 18:01:08 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-03-25 10:36:51 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(comboBox_gameType->currentIndex() == GAME_TYPE_RANKING-1) {
|
|
|
|
|
//set static values
|
|
|
|
|
myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->setValue(RANKING_GAME_START_SBLIND);
|
|
|
|
|
myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtHands->setChecked(TRUE);
|
|
|
|
|
myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtMinutes->setChecked(FALSE);
|
|
|
|
|
myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryHands->setValue(11);
|
|
|
|
|
myChangeCompleteBlindsDialog->radioButton_alwaysDoubleBlinds->setChecked(TRUE);
|
|
|
|
|
myChangeCompleteBlindsDialog->radioButton_manualBlindsOrder->setChecked(FALSE);
|
|
|
|
|
myChangeCompleteBlindsDialog->listWidget_blinds->clear();
|
|
|
|
|
} else {
|
|
|
|
|
//read config values
|
|
|
|
|
myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->setValue(myConfig->readConfigInt("NetFirstSmallBlind"));
|
|
|
|
|
myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtHands->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtHands"));
|
|
|
|
|
myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtMinutes->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtMinutes"));
|
|
|
|
|
myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryHands->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryHands"));
|
|
|
|
|
myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryMinutes->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryMinutes"));
|
|
|
|
|
myChangeCompleteBlindsDialog->radioButton_alwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAlwaysDoubleBlinds"));
|
|
|
|
|
myChangeCompleteBlindsDialog->radioButton_manualBlindsOrder->setChecked(myConfig->readConfigInt("NetManualBlindsOrder"));
|
2010-07-15 09:52:24 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
myChangeCompleteBlindsDialog->listWidget_blinds->clear();
|
|
|
|
|
myChangeCompleteBlindsDialog->spinBox_input->setMinimum(myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->value()+1);
|
2010-07-15 09:52:24 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
std::list<int> myBlindsList = myConfig->readConfigIntList("NetManualBlindsList");
|
|
|
|
|
std::list<int>::iterator it1;
|
2010-07-15 09:52:24 +00:00
|
|
|
|
2011-02-09 15:01:07 +00:00
|
|
|
for(it1= myBlindsList.begin(); it1 != myBlindsList.end(); ++it1) {
|
2011-02-11 20:02:08 +00:00
|
|
|
myChangeCompleteBlindsDialog->listWidget_blinds->addItem(QString::number(*it1,10));
|
|
|
|
|
}
|
|
|
|
|
myChangeCompleteBlindsDialog->sortBlindsList();
|
2010-07-15 09:52:24 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAfterMBAlwaysDoubleBlinds"));
|
|
|
|
|
myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysRaiseAbout->setChecked(myConfig->readConfigInt("NetAfterMBAlwaysRaiseAbout"));
|
|
|
|
|
myChangeCompleteBlindsDialog->spinBox_afterThisAlwaysRaiseValue->setValue(myConfig->readConfigInt("NetAfterMBAlwaysRaiseValue"));
|
|
|
|
|
myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind"));
|
|
|
|
|
}
|
2010-03-25 10:36:51 +00:00
|
|
|
}
|
2012-12-21 00:36:01 +01:00
|
|
|
|
|
|
|
|
bool createInternetGameDialogImpl::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
|
{
|
2012-12-22 17:57:00 +01:00
|
|
|
#ifdef ANDROID
|
2012-12-21 00:36:01 +01:00
|
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
|
|
|
|
|
|
|
|
|
//androi changes for return key behavior (hopefully useless from necessitas beta2)
|
|
|
|
|
if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) {
|
|
|
|
|
if(spinBox_startCash->hasFocus()) {
|
|
|
|
|
spinBox_startCash->clearFocus();
|
|
|
|
|
}
|
|
|
|
|
if(spinBox_quantityPlayers->hasFocus()) {
|
|
|
|
|
spinBox_quantityPlayers->clearFocus();
|
|
|
|
|
}
|
|
|
|
|
if(spinBox_netTimeOutPlayerAction->hasFocus()) {
|
|
|
|
|
spinBox_netTimeOutPlayerAction->clearFocus();
|
|
|
|
|
}
|
|
|
|
|
if(spinBox_netDelayBetweenHands->hasFocus()) {
|
|
|
|
|
spinBox_netDelayBetweenHands->clearFocus();
|
|
|
|
|
}
|
|
|
|
|
if(lineEdit_gameName->hasFocus()) {
|
|
|
|
|
lineEdit_gameName->clearFocus();
|
|
|
|
|
}
|
|
|
|
|
if(lineEdit_Password->hasFocus()) {
|
|
|
|
|
lineEdit_Password->clearFocus();
|
|
|
|
|
}
|
|
|
|
|
event->ignore();
|
|
|
|
|
return false;
|
2012-12-21 01:01:01 +01:00
|
|
|
} else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Back) {
|
2012-12-21 00:36:01 +01:00
|
|
|
this->reject();
|
|
|
|
|
return true;
|
2012-12-21 01:01:01 +01:00
|
|
|
} else {
|
2012-12-21 00:36:01 +01:00
|
|
|
// pass the event on to the parent class
|
|
|
|
|
return QDialog::eventFilter(obj, event);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
return QDialog::eventFilter(obj, event);
|
|
|
|
|
#endif
|
|
|
|
|
}
|