From db54e45739bc4797617aaa7d540461be64047a46 Mon Sep 17 00:00:00 2001 From: doitux Date: Wed, 28 Mar 2007 17:44:22 +0000 Subject: [PATCH] --- src/config/configfile.cpp | 35 +- src/engine/local_engine/localplayer.cpp | 2 +- src/engine/local_engine/localplayer.h | 8 +- src/engine/local_engine/localriver.cpp | 16 +- src/engine/playerinterface.h | 3 + src/gui/qt/mainwindow.ui | 116 ++--- src/gui/qt/mainwindow/mainwindowimpl.cpp | 91 ++-- src/gui/qt/resources/data/flopValues | 1 + src/gui/qt/settingsdialog.ui | 464 +++++++++++++++--- .../qt/settingsdialog/settingsdialogimpl.cpp | 161 +++++- .../qt/settingsdialog/settingsdialogimpl.h | 8 +- 11 files changed, 708 insertions(+), 197 deletions(-) diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp index 09a1af4b..bb28684d 100644 --- a/src/config/configfile.cpp +++ b/src/config/configfile.cpp @@ -34,7 +34,7 @@ using namespace std; ConfigFile::ConfigFile() { // !!!! Revisionsnummer der Configdefaults !!!!! - configRev = 13; + configRev = 15; // Pfad und Dateinamen setzen #ifdef _WIN32 @@ -136,7 +136,7 @@ void ConfigFile::createDefaultConfig() { TiXmlElement * confElement1 = new TiXmlElement( "NumberOfPlayers" ); config->LinkEndChild( confElement1 ); - confElement1->SetAttribute("value", 5); + confElement1->SetAttribute("value", 7); TiXmlElement * confElement2 = new TiXmlElement( "StartCash" ); config->LinkEndChild( confElement2 ); confElement2->SetAttribute("value", 2000); @@ -161,7 +161,7 @@ void ConfigFile::createDefaultConfig() { TiXmlElement * confElement23 = new TiXmlElement( "NetNumberOfPlayers" ); config->LinkEndChild( confElement23 ); - confElement23->SetAttribute("value", 5); + confElement23->SetAttribute("value", 7); TiXmlElement * confElement24 = new TiXmlElement( "NetStartCash" ); config->LinkEndChild( confElement24 ); confElement24->SetAttribute("value", 2000); @@ -190,19 +190,46 @@ void ConfigFile::createDefaultConfig() { TiXmlElement * confElement6 = new TiXmlElement( "MyName" ); config->LinkEndChild( confElement6 ); confElement6->SetAttribute("value", "Human Player"); + TiXmlElement * confElement34 = new TiXmlElement( "MyAvatar" ); + config->LinkEndChild( confElement34 ); + confElement34->SetAttribute("value", ""); TiXmlElement * confElement7 = new TiXmlElement( "Opponent1Name" ); config->LinkEndChild( confElement7 ); confElement7->SetAttribute("value", "Player 1"); + TiXmlElement * confElement35 = new TiXmlElement( "Opponent1Avatar" ); + config->LinkEndChild( confElement35 ); + confElement35->SetAttribute("value", ""); TiXmlElement * confElement8 = new TiXmlElement( "Opponent2Name" ); config->LinkEndChild( confElement8 ); confElement8->SetAttribute("value", "Player 2"); + TiXmlElement * confElement36 = new TiXmlElement( "Opponent2Avatar" ); + config->LinkEndChild( confElement36 ); + confElement36->SetAttribute("value", ""); TiXmlElement * confElement9 = new TiXmlElement( "Opponent3Name" ); config->LinkEndChild( confElement9 ); confElement9->SetAttribute("value", "Player 3"); + TiXmlElement * confElement37 = new TiXmlElement( "Opponent3Avatar" ); + config->LinkEndChild( confElement37 ); + confElement37->SetAttribute("value", ""); TiXmlElement * confElement10 = new TiXmlElement( "Opponent4Name" ); config->LinkEndChild( confElement10 ); confElement10->SetAttribute("value", "Player 4"); - + TiXmlElement * confElement38 = new TiXmlElement( "Opponent4Avatar" ); + config->LinkEndChild( confElement38 ); + confElement38->SetAttribute("value", ""); + TiXmlElement * confElement39 = new TiXmlElement( "Opponent5Name" ); + config->LinkEndChild( confElement39 ); + confElement39->SetAttribute("value", "Player 5"); + TiXmlElement * confElement40 = new TiXmlElement( "Opponent5Avatar" ); + config->LinkEndChild( confElement40 ); + confElement40->SetAttribute("value", ""); + TiXmlElement * confElement41 = new TiXmlElement( "Opponent6Name" ); + config->LinkEndChild( confElement41 ); + confElement41->SetAttribute("value", "Player 6"); + TiXmlElement * confElement42 = new TiXmlElement( "Opponent6Avatar" ); + config->LinkEndChild( confElement42 ); + confElement42->SetAttribute("value", ""); + TiXmlElement * confElement20 = new TiXmlElement( "LogDir" ); config->LinkEndChild( confElement20 ); confElement20->SetAttribute("value", logDir); diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 2556b53a..db9fbc32 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -37,7 +37,7 @@ LocalPlayer::LocalPlayer(BoardInterface *b, int id, std::string name, int sC, bo } // myAggressive initialisieren - for(i=0; i<10; i++) { + for(i=0; i<7; i++) { myAggressive[i] = 0; } diff --git a/src/engine/local_engine/localplayer.h b/src/engine/local_engine/localplayer.h index c818d7bf..f17cdfbc 100755 --- a/src/engine/local_engine/localplayer.h +++ b/src/engine/local_engine/localplayer.h @@ -89,14 +89,14 @@ public: void setMyAggressive(const bool& theValue) { int i; - for(i=0; i<9; i++) { + for(i=0; i<6; i++) { myAggressive[i] = myAggressive[i+1]; } - myAggressive[9] = theValue; + myAggressive[6] = theValue; } int getMyAggressive() const { int i, sum = 0; - for(i=0; i<10; i++) { + for(i=0; i<7; i++) { sum += myAggressive[i]; } return sum; @@ -153,7 +153,7 @@ private: int myRoundStartCash; int myAverageSets[4]; - bool myAggressive[10]; + bool myAggressive[7]; }; diff --git a/src/engine/local_engine/localriver.cpp b/src/engine/local_engine/localriver.cpp index fd3103b6..0275d215 100755 --- a/src/engine/local_engine/localriver.cpp +++ b/src/engine/local_engine/localriver.cpp @@ -144,10 +144,24 @@ void LocalRiver::postRiverRun() { } } - // Aggresivität des human player ermitteln + // Durchschnittsets des human player ermitteln myHand->getPlayerArray()[0]->setMyAverageSets(((myHand->getPlayerArray()[0]->getMyRoundStartCash())-(myHand->getPlayerArray()[0]->getMyCash()))/(myHand->getBettingRoundsPlayed()+1)); // cout << myHand->getPlayerArray()[0]->getMyAverageSets() << endl; + // Aggressivität des human player ermitteln + // anzahl der player die möglichkeit haben am pot teilzuhaben + int potPlayers = 0; + for(i=0; igetGuiInterface()->getMaxQuantityPlayers(); i++) { + if(myHand->getPlayerArray()[i]->getMyActiveStatus() && myHand->getPlayerArray()[i]->getMyAction() != 1) { + potPlayers++; + } + } + + // prüfen ob nur noch der human player an der verteilung teilnimmt + myHand->getPlayerArray()[0]->setMyAggressive(potPlayers == 1 && myHand->getPlayerArray()[0]->getMyActiveStatus() && myHand->getPlayerArray()[0]->getMyAction() != 1); + + cout << "aggressive: " << myHand->getPlayerArray()[0]->getMyAggressive() << endl; + // Pot-Verteilung distributePot(); diff --git a/src/engine/playerinterface.h b/src/engine/playerinterface.h index df250e0f..b9fbae3a 100644 --- a/src/engine/playerinterface.h +++ b/src/engine/playerinterface.h @@ -73,6 +73,9 @@ public: virtual void setMyAverageSets(const int& theValue) =0; virtual int getMyAverageSets() const =0; + + virtual void setMyAggressive(const bool& theValue) =0; + virtual int getMyAggressive() const =0; virtual void action() =0; diff --git a/src/gui/qt/mainwindow.ui b/src/gui/qt/mainwindow.ui index c608799d..d746ab71 100644 --- a/src/gui/qt/mainwindow.ui +++ b/src/gui/qt/mainwindow.ui @@ -2665,19 +2665,6 @@ - - - - 80 - 17 - 118 - 23 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - @@ -2739,6 +2726,19 @@ + + + + 85 + 17 + 118 + 23 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + @@ -3608,38 +3608,6 @@ - - - - 85 - 40 - 118 - 111 - - - - - - 9 - 35 - 100 - 40 - - - - - 0 - 20 - - - - - - - Qt::AlignCenter - - - @@ -3810,19 +3778,6 @@ - - - - 85 - 17 - 118 - 23 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - @@ -3852,6 +3807,51 @@ + + + + 85 + 40 + 118 + 111 + + + + + + 9 + 35 + 100 + 40 + + + + + 0 + 20 + + + + + + + Qt::AlignCenter + + + + + + + 85 + 17 + 118 + 23 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index b9f3ee00..b79928d8 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -93,18 +93,6 @@ mainWindowImpl::mainWindowImpl(QMainWindow *parent) setupUi(this); - //Logos - label_logoleft = new QLabel; - label_logoleft->setPixmap(QPixmap(QString::fromUtf8(":/graphics/resources/graphics/logo-140-100.png"))); - label_logoleft->hide(); - vboxLayout->addWidget(label_logoleft); - - label_logoright = new QLabel; - label_logoright->setPixmap(QPixmap(QString::fromUtf8(":/graphics/resources/graphics/logo-140-100.png"))); - label_logoright->setAlignment(Qt::AlignRight); - label_logoright->hide(); - vboxLayout3->addWidget(label_logoright); - //pixmapCardsLabel erstellen und ins Layout einfügen! pixmapLabel_cardBoard0 = new MyCardsPixmapLabel(frame_Board); pixmapLabel_cardBoard0->setObjectName(QString::fromUtf8("pixmapLabel_BoardCard0")); @@ -555,7 +543,7 @@ void mainWindowImpl::callNewGameDialog() { newGameDialogImpl *v = new newGameDialogImpl(this); v->exec(); if (v->result() == QDialog::Accepted ) { startNewLocalGame(v); } - else { startNewLocalGame(); } +// else { startNewLocalGame(); } } // sonst mit gespeicherten Werten starten else { startNewLocalGame(); } @@ -685,27 +673,15 @@ void mainWindowImpl::callSettingsDialog() { settingsDialogImpl *v = new settingsDialogImpl(this); v->exec(); - - if (v->getSettingsCorrect()) { - - //Toolbox verstecken? - if (myConfig->readConfigInt("ShowLeftToolBox")) { - label_logoleft->hide(); - tabWidget_LeftToolBox->show(); - } - else { - tabWidget_LeftToolBox->hide(); - label_logoleft->show(); - } - if (myConfig->readConfigInt("ShowRightToolBox")) { - label_logoright->hide(); - frame_RightToolBox->show(); - } - else { - frame_RightToolBox->hide(); - label_logoright->show(); - } + + if (v->getSettingsCorrect()) { + //Toolbox verstecken? + if (myConfig->readConfigInt("ShowLeftToolBox")) { tabWidget_LeftToolBox->show(); } + else { tabWidget_LeftToolBox->hide(); } + + if (myConfig->readConfigInt("ShowRightToolBox")) { frame_RightToolBox->show(); } + else { frame_RightToolBox->hide(); } //Falls Spielernamen geändert wurden --> neu zeichnen --> erst beim nächsten Neustart neu ausgelesen if (v->getPlayerNickIsChanged() && actualGame) { @@ -715,11 +691,13 @@ void mainWindowImpl::callSettingsDialog() { actualHand->getPlayerArray()[2]->setMyName(v->lineEdit_Opponent2Name->text().toStdString()); actualHand->getPlayerArray()[3]->setMyName(v->lineEdit_Opponent3Name->text().toStdString()); actualHand->getPlayerArray()[4]->setMyName(v->lineEdit_Opponent4Name->text().toStdString()); + actualHand->getPlayerArray()[5]->setMyName(v->lineEdit_Opponent5Name->text().toStdString()); + actualHand->getPlayerArray()[6]->setMyName(v->lineEdit_Opponent6Name->text().toStdString()); v->setPlayerNickIsChanged(FALSE); refreshPlayerName(); } - + //Flipside refresh if (myConfig->readConfigInt("FlipsideOwn") && myConfig->readConfigString("FlipsideOwnFile") != "") { @@ -737,6 +715,9 @@ void mainWindowImpl::callSettingsDialog() { } } } + + //avatar refresh + refreshPlayerAvatar(); } } @@ -771,7 +752,7 @@ void mainWindowImpl::refreshButton() { if (actualHand->getPlayerArray()[k]->getMyActiveStatus() == 1) activePlayersCounter++; } - for (i=0; igetStartQuantityPlayers(); i++) { + for (i=0; igetPlayerArray()[i]->getMyActiveStatus()) { if(activePlayersCounter > 2) { if (actualHand->getPlayerArray()[i]->getMyButton()==1) { @@ -816,7 +797,25 @@ void mainWindowImpl::refreshPlayerAvatar() { for (i=0; igetPlayerArray()[i]->getMyActiveStatus()) { - playerAvatarLabelArray[i]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png")); + + if(!i) { + if(myConfig->readConfigString("MyAvatar") == "") { + playerAvatarLabelArray[0]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png")); + } + else { + playerAvatarLabelArray[0]->setPixmap(QPixmap(QString::fromStdString(myConfig->readConfigString("MyAvatar")))); + } + } + else { + QString tmp("Opponent"+QString::number(i,10)+"Avatar"); + + if(myConfig->readConfigString(tmp.toStdString()) == "") { + playerAvatarLabelArray[i]->setPixmap(QPixmap(":/guiv2/resources/guiv2/genereticAvatar.png")); + } + else { + playerAvatarLabelArray[i]->setPixmap(QPixmap(QString::fromStdString(myConfig->readConfigString(tmp.toStdString())))); + } + } } else { playerAvatarLabelArray[i]->setPixmap(onePix); @@ -2063,26 +2062,14 @@ void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) { void mainWindowImpl::switchLeftToolBox() { - if (tabWidget_LeftToolBox->isHidden()) { - label_logoleft->hide(); - tabWidget_LeftToolBox->show(); - } - else { - tabWidget_LeftToolBox->hide(); - label_logoleft->show(); - } + if (tabWidget_LeftToolBox->isHidden()) { tabWidget_LeftToolBox->show(); } + else { tabWidget_LeftToolBox->hide(); } } void mainWindowImpl::switchRightToolBox() { - if (frame_RightToolBox->isHidden()) { - label_logoright->hide(); - frame_RightToolBox->show(); - } - else { - frame_RightToolBox->hide(); - label_logoright->show(); - } + if (frame_RightToolBox->isHidden()) { frame_RightToolBox->show(); } + else { frame_RightToolBox->hide(); } } void mainWindowImpl::switchFullscreen() { diff --git a/src/gui/qt/resources/data/flopValues b/src/gui/qt/resources/data/flopValues index 1e8171f1..2b0cf151 100644 --- a/src/gui/qt/resources/data/flopValues +++ b/src/gui/qt/resources/data/flopValues @@ -520,6 +520,7 @@ 53010|0.816987|0.677700|0.570375|0.484100 53011|0.832275|0.707483|0.608725|0.527600 53012|0.879188|0.781317|0.704100|0.645950 +53102|0.646188|0.431000|0.297600|0.212250 53103|0.662075|0.451183|0.316450|0.226250 53104|0.679488|0.476467|0.338175|0.247350 53105|0.685588|0.486467|0.355675|0.262250 diff --git a/src/gui/qt/settingsdialog.ui b/src/gui/qt/settingsdialog.ui index 2d885fea..4bcc768f 100644 --- a/src/gui/qt/settingsdialog.ui +++ b/src/gui/qt/settingsdialog.ui @@ -164,7 +164,7 @@ p, li { white-space: pre-wrap; } - Default (Tux) + Default true @@ -601,23 +601,316 @@ p, li { white-space: pre-wrap; } 6 - - - - - - - - 75 - true - - - - Player Nicks + + + + Computer Engine + + + 5 + + + 5 + + + + + 0 + + + 0 + + + + + + + + + 27 + 23 + + + + + 27 + 23 + + + + :/graphics/resources/graphics/fileopen16.png + + + + + + + + + 0 + + + 0 + + + + + + + + + 27 + 23 + + + + + 27 + 23 + + + + :/graphics/resources/graphics/fileopen16.png + + + + + + + + + 0 + + + 0 + + + + + + + + + 27 + 23 + + + + + 27 + 23 + + + + :/graphics/resources/graphics/fileopen16.png + + + + + + + + + 0 + + + 0 + + + + + + + + + 27 + 23 + + + + + 27 + 23 + + + + :/graphics/resources/graphics/fileopen16.png + + + + + + + + + 0 + + + 0 + + + + + + + + + 27 + 23 + + + + + 27 + 23 + + + + :/graphics/resources/graphics/fileopen16.png + + + + + + + + + 0 + + + 0 + + + + + + + + + 27 + 23 + + + + + 27 + 23 + + + + :/graphics/resources/graphics/fileopen16.png + + + + + + + + + Avatar: + + + + + + + Avatar: + + + + + + + Avatar: + + + + + + + Avatar: + + + + + + + Avatar: + + + + + + + Avatar: + + + + + + + + + + + + + + + + + + + + + + + + + Opponent 2: + + + + + + + Opponent 3: + + + + + + + Opponent 4: + + + + + + + Opponent 1: + + + + + + + Opponent 5: + + + + + + + Opponent 6: + + + + - + Qt::Vertical @@ -630,57 +923,82 @@ p, li { white-space: pre-wrap; } - - - - Human Player: - - - - - - - Opponent 2: - - - - - - - + Qt::Horizontal - - - - - - - Opponent 3: + + + + 0 - - - - - - - - - - - - Opponent 4: + + 5 - + + + + Human Player: + + + + + + + + + + Avatar: + + + + + + + 0 + + + 0 + + + + + + + + + 27 + 23 + + + + + 27 + 23 + + + + :/graphics/resources/graphics/fileopen16.png + + + + + + - - + + + + + 75 + true + + - Opponent 1: + Player Nicks @@ -819,6 +1137,23 @@ p, li { white-space: pre-wrap; } + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + + Qt::Horizontal + + + @@ -860,23 +1195,6 @@ p, li { white-space: pre-wrap; } - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok - - - diff --git a/src/gui/qt/settingsdialog/settingsdialogimpl.cpp b/src/gui/qt/settingsdialog/settingsdialogimpl.cpp index cae5ac6d..e53fb2d6 100644 --- a/src/gui/qt/settingsdialog/settingsdialogimpl.cpp +++ b/src/gui/qt/settingsdialog/settingsdialogimpl.cpp @@ -35,10 +35,19 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent) //Player Nicks lineEdit_humanPlayerName->setText(QString::fromStdString(myConfig.readConfigString("MyName"))); + lineEdit_humanPlayerAvatar->setText(QString::fromStdString(myConfig.readConfigString("MyAvatar"))); lineEdit_Opponent1Name->setText(QString::fromStdString(myConfig.readConfigString("Opponent1Name"))); + lineEdit_Opponent1Avatar->setText(QString::fromStdString(myConfig.readConfigString("Opponent1Avatar"))); lineEdit_Opponent2Name->setText(QString::fromStdString(myConfig.readConfigString("Opponent2Name"))); + lineEdit_Opponent2Avatar->setText(QString::fromStdString(myConfig.readConfigString("Opponent2Avatar"))); lineEdit_Opponent3Name->setText(QString::fromStdString(myConfig.readConfigString("Opponent3Name"))); + lineEdit_Opponent3Avatar->setText(QString::fromStdString(myConfig.readConfigString("Opponent3Avatar"))); lineEdit_Opponent4Name->setText(QString::fromStdString(myConfig.readConfigString("Opponent4Name"))); + lineEdit_Opponent4Avatar->setText(QString::fromStdString(myConfig.readConfigString("Opponent4Avatar"))); + lineEdit_Opponent5Name->setText(QString::fromStdString(myConfig.readConfigString("Opponent5Name"))); + lineEdit_Opponent5Avatar->setText(QString::fromStdString(myConfig.readConfigString("Opponent5Avatar"))); + lineEdit_Opponent6Name->setText(QString::fromStdString(myConfig.readConfigString("Opponent6Name"))); + lineEdit_Opponent6Avatar->setText(QString::fromStdString(myConfig.readConfigString("Opponent6Avatar"))); //Local Game Settings spinBox_quantityPlayers->setValue(myConfig.readConfigInt("NumberOfPlayers")); @@ -88,7 +97,13 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent) connect( lineEdit_Opponent4Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); connect( pushButton_openFlipsidePicture, SIGNAL( clicked() ), this, SLOT( setFlipsidePicFileName()) ); connect( pushButton_openLogDir, SIGNAL( clicked() ), this, SLOT( setLogDir()) ); - + connect( pushButton_openAvatarFile0, SIGNAL( clicked() ), this, SLOT( setAvatarFile0()) ); + connect( pushButton_openAvatarFile1, SIGNAL( clicked() ), this, SLOT( setAvatarFile1()) ); + connect( pushButton_openAvatarFile2, SIGNAL( clicked() ), this, SLOT( setAvatarFile2()) ); + connect( pushButton_openAvatarFile3, SIGNAL( clicked() ), this, SLOT( setAvatarFile3()) ); + connect( pushButton_openAvatarFile4, SIGNAL( clicked() ), this, SLOT( setAvatarFile4()) ); + connect( pushButton_openAvatarFile5, SIGNAL( clicked() ), this, SLOT( setAvatarFile5()) ); + connect( pushButton_openAvatarFile6, SIGNAL( clicked() ), this, SLOT( setAvatarFile6()) ); } @@ -102,10 +117,81 @@ void settingsDialogImpl::isAccepted() { // Player Nicks myConfig.writeConfigString("MyName", lineEdit_humanPlayerName->text().toUtf8().constData()); + if(QFile::QFile(lineEdit_humanPlayerAvatar->text()).exists() || lineEdit_humanPlayerAvatar->text() == "") { + myConfig.writeConfigString("MyAvatar", lineEdit_humanPlayerAvatar->text().toUtf8().constData()); + } + else { QMessageBox::warning(this, tr("Settings Error"), + tr("The entered human player avatar picture doesn't exists.\n" + "Please enter an valid picture!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } + myConfig.writeConfigString("Opponent1Name", lineEdit_Opponent1Name->text().toUtf8().constData()); + if(QFile::QFile(lineEdit_Opponent1Avatar->text()).exists() || lineEdit_Opponent1Avatar->text() == "") { + myConfig.writeConfigString("Opponent1Avatar", lineEdit_Opponent1Avatar->text().toUtf8().constData()); + } + else { QMessageBox::warning(this, tr("Settings Error"), + tr("The entered \"opponent 1\" avatar picture doesn't exists.\n" + "Please enter an valid picture!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } + myConfig.writeConfigString("Opponent2Name", lineEdit_Opponent2Name->text().toUtf8().constData()); + if(QFile::QFile(lineEdit_Opponent2Avatar->text()).exists() || lineEdit_Opponent2Avatar->text() == "") { + myConfig.writeConfigString("Opponent2Avatar", lineEdit_Opponent2Avatar->text().toUtf8().constData()); + } + else { QMessageBox::warning(this, tr("Settings Error"), + tr("The entered \"opponent 2\" avatar picture doesn't exists.\n" + "Please enter an valid picture!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } + myConfig.writeConfigString("Opponent3Name", lineEdit_Opponent3Name->text().toUtf8().constData()); + if(QFile::QFile(lineEdit_Opponent3Avatar->text()).exists() || lineEdit_Opponent3Avatar->text() == "") { + myConfig.writeConfigString("Opponent3Avatar", lineEdit_Opponent3Avatar->text().toUtf8().constData()); + } + else { QMessageBox::warning(this, tr("Settings Error"), + tr("The entered \"opponent 3\" avatar picture doesn't exists.\n" + "Please enter an valid picture!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } + myConfig.writeConfigString("Opponent4Name", lineEdit_Opponent4Name->text().toUtf8().constData()); + if(QFile::QFile(lineEdit_Opponent4Avatar->text()).exists() || lineEdit_Opponent4Avatar->text() == "") { + myConfig.writeConfigString("Opponent4Avatar", lineEdit_Opponent4Avatar->text().toUtf8().constData()); + } + else { QMessageBox::warning(this, tr("Settings Error"), + tr("The entered \"opponent 4\" avatar picture doesn't exists.\n" + "Please enter an valid picture!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } + + myConfig.writeConfigString("Opponent5Name", lineEdit_Opponent5Name->text().toUtf8().constData()); + if(QFile::QFile(lineEdit_Opponent5Avatar->text()).exists() || lineEdit_Opponent5Avatar->text() == "") { + myConfig.writeConfigString("Opponent5Avatar", lineEdit_Opponent5Avatar->text().toUtf8().constData()); + } + else { QMessageBox::warning(this, tr("Settings Error"), + tr("The entered \"opponent 5\" avatar picture doesn't exists.\n" + "Please enter an valid picture!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } + + myConfig.writeConfigString("Opponent6Name", lineEdit_Opponent6Name->text().toUtf8().constData()); + if(QFile::QFile(lineEdit_Opponent6Avatar->text()).exists() || lineEdit_Opponent6Avatar->text() == "") { + myConfig.writeConfigString("Opponent6Avatar", lineEdit_Opponent6Avatar->text().toUtf8().constData()); + } + else { QMessageBox::warning(this, tr("Settings Error"), + tr("The entered \"opponent 6\" avatar picture doesn't exists.\n" + "Please enter an valid picture!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } // Local Game Settings myConfig.writeConfigInt("NumberOfPlayers", spinBox_quantityPlayers->value()); @@ -159,7 +245,6 @@ void settingsDialogImpl::isAccepted() { myConfig.writeConfigInt("LogStoreDuration", spinBox_logStoreDuration->value()); - //Wenn alles richtig eingegeben wurde --> Dialog schließen if(settingsCorrect) { this->hide(); } } @@ -168,12 +253,82 @@ void settingsDialogImpl::setFlipsidePicFileName() { QString fileName = QFileDialog::getOpenFileName(this, tr("Select your flipside picture"), QDir::homePath(), - tr("Images (*.bmp *.png *.xpm)")); + tr("Images (*.png)")); if (!fileName.isEmpty()) lineEdit_OwnFlipsideFilename->setText(fileName); } +void settingsDialogImpl::setAvatarFile0() { + + QString fileName = QFileDialog::getOpenFileName(this, tr("Select your avatar picture"), + QDir::homePath(), + tr("Images (*.png)")); + + if (!fileName.isEmpty()) + lineEdit_humanPlayerAvatar->setText(fileName); +} + +void settingsDialogImpl::setAvatarFile1() { + + QString fileName = QFileDialog::getOpenFileName(this, tr("Select computer opponents avatar picture"), + QDir::homePath(), + tr("Images (*.png)")); + + if (!fileName.isEmpty()) + lineEdit_Opponent1Avatar->setText(fileName); +} + +void settingsDialogImpl::setAvatarFile2() { + + QString fileName = QFileDialog::getOpenFileName(this, tr("Select computer opponents avatar picture"), + QDir::homePath(), + tr("Images (*.png)")); + + if (!fileName.isEmpty()) + lineEdit_Opponent2Avatar->setText(fileName); +} + +void settingsDialogImpl::setAvatarFile3() { + + QString fileName = QFileDialog::getOpenFileName(this, tr("Select computer opponents avatar picture"), + QDir::homePath(), + tr("Images (*.png)")); + + if (!fileName.isEmpty()) + lineEdit_Opponent3Avatar->setText(fileName); +} + +void settingsDialogImpl::setAvatarFile4() { + + QString fileName = QFileDialog::getOpenFileName(this, tr("Select computer opponents avatar picture"), + QDir::homePath(), + tr("Images (*.png)")); + + if (!fileName.isEmpty()) + lineEdit_Opponent4Avatar->setText(fileName); +} + +void settingsDialogImpl::setAvatarFile5() { + + QString fileName = QFileDialog::getOpenFileName(this, tr("Select computer opponents avatar picture"), + QDir::homePath(), + tr("Images (*.png)")); + + if (!fileName.isEmpty()) + lineEdit_Opponent5Avatar->setText(fileName); +} + +void settingsDialogImpl::setAvatarFile6() { + + QString fileName = QFileDialog::getOpenFileName(this, tr("Select computer opponents avatar picture"), + QDir::homePath(), + tr("Images (*.png)")); + + if (!fileName.isEmpty()) + lineEdit_Opponent6Avatar->setText(fileName); +} + void settingsDialogImpl::setLogDir() { QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), diff --git a/src/gui/qt/settingsdialog/settingsdialogimpl.h b/src/gui/qt/settingsdialog/settingsdialogimpl.h index 8e0d1006..1e1f1592 100644 --- a/src/gui/qt/settingsdialog/settingsdialogimpl.h +++ b/src/gui/qt/settingsdialog/settingsdialogimpl.h @@ -42,7 +42,13 @@ public slots: void playerNickChanged() { setPlayerNickIsChanged(TRUE); }; void setFlipsidePicFileName(); void setLogDir(); - + void setAvatarFile0(); + void setAvatarFile1(); + void setAvatarFile2(); + void setAvatarFile3(); + void setAvatarFile4(); + void setAvatarFile5(); + void setAvatarFile6(); private: bool playerNickIsChanged;