From 14c1b2064c97d6cc3f2104ddfdefeeeeeb149fa1 Mon Sep 17 00:00:00 2001 From: doitux Date: Wed, 31 Jan 2007 01:17:13 +0000 Subject: [PATCH] flipcards animation complete (with config-entry) --- src/config/configfile.cpp | 5 +- src/gui/qt/cards/mycardspixmaplabel.cpp | 16 +- src/gui/qt/cards/mycardspixmaplabel.h | 7 +- src/gui/qt/mainwindow.ui | 22 +- src/gui/qt/mainwindowimpl.cpp | 258 +++++++++++++++++------- src/gui/qt/mainwindowimpl.h | 5 + src/gui/qt/settingsdialog.ui | 87 ++++---- src/gui/qt/settingsdialogimpl.cpp | 2 + 8 files changed, 266 insertions(+), 136 deletions(-) diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp index afae8efe..4c17f152 100644 --- a/src/config/configfile.cpp +++ b/src/config/configfile.cpp @@ -31,7 +31,7 @@ using namespace std; ConfigFile::ConfigFile() { // !!!! Revisionsnummer der Configdefaults !!!!! - configRev = 2; + configRev = 3; // Pfad und Dateinamen setzen #ifdef _WIN32 @@ -131,6 +131,9 @@ void ConfigFile::createDefaultConfig() { TiXmlElement * confElement15 = new TiXmlElement( "ShowFadeOutCardsAnimation" ); config->LinkEndChild( confElement15 ); confElement15->SetAttribute("value", 1); + TiXmlElement * confElement19 = new TiXmlElement( "ShowFlipCardsAnimation" ); + config->LinkEndChild( confElement19 ); + confElement19->SetAttribute("value", 1); TiXmlElement * confElement16 = new TiXmlElement( "FlipsideTux" ); config->LinkEndChild( confElement16 ); confElement16->SetAttribute("value", 1); diff --git a/src/gui/qt/cards/mycardspixmaplabel.cpp b/src/gui/qt/cards/mycardspixmaplabel.cpp index 0e3af8a7..1d09a478 100644 --- a/src/gui/qt/cards/mycardspixmaplabel.cpp +++ b/src/gui/qt/cards/mycardspixmaplabel.cpp @@ -73,20 +73,22 @@ void MyCardsPixmapLabel::nextFadeOutFrame() { void MyCardsPixmapLabel::startFlipCards(int speed, QPixmap frontPix, QPixmap *flipsidePix) { + QLabel::setPixmap(frontPix); + frameFlipCardsAction1Size = 1.0; frameFlipCardsAction2Size = 0.0; *front = frontPix; flipside = flipsidePix; -// if(speed <= 4) { opacityRaiseIntervall = 0.01; } -// if(speed > 4 && speed <= 7) { opacityRaiseIntervall = 0.02; } -// if(speed > 7 && speed <= 10) { opacityRaiseIntervall = 0.04; } -// - flipCardsScaleIntervall = 0.1; + if(speed <= 4) { flipCardsScaleIntervall = 0.1; } + if(speed > 4 && speed <= 6) { flipCardsScaleIntervall = 0.20; } + if(speed > 6 && speed <= 8) { flipCardsScaleIntervall = 0.25; } + if(speed > 8 && speed <= 10) { flipCardsScaleIntervall = 0.5; } +// + if(speed != 11) { flipCardsAction1 = TRUE; -// frameOpacity = 0.0; flipCardsTimer->start(40); } @@ -105,7 +107,7 @@ void MyCardsPixmapLabel::nextFlipCardsFrame() { flipCardsAction2 = TRUE; } else { - //dann front aufdecken + //dann front vergrößern if (frameFlipCardsAction2Size < 0.9 ) { frameFlipCardsAction2Size += flipCardsScaleIntervall; diff --git a/src/gui/qt/cards/mycardspixmaplabel.h b/src/gui/qt/cards/mycardspixmaplabel.h index 9639854d..e80df509 100644 --- a/src/gui/qt/cards/mycardspixmaplabel.h +++ b/src/gui/qt/cards/mycardspixmaplabel.h @@ -27,7 +27,10 @@ public: void setIsFlipside(bool theValue){ isFlipside = theValue;} bool getIsFlipside() const{ return isFlipside;} - + + void setFadeOutAction(bool theValue) { fadeOutAction = theValue; } + bool getFadeOutAction() const { return fadeOutAction;} + void startFadeOut(int); void startFlipCards(int, QPixmap, QPixmap*); @@ -40,6 +43,8 @@ public slots: void nextFadeOutFrame(); void nextFlipCardsFrame(); + + private: qreal frameOpacity; diff --git a/src/gui/qt/mainwindow.ui b/src/gui/qt/mainwindow.ui index 3ef5d3ab..5da807d1 100644 --- a/src/gui/qt/mainwindow.ui +++ b/src/gui/qt/mainwindow.ui @@ -3992,7 +3992,7 @@ 0 0 874 - 29 + 30 @@ -4061,24 +4061,8 @@ 616 - 716 - 627 - - - - - spinBox_set - editingFinished() - pushButton_set - click() - - - 572 - 498 - - - 533 - 501 + 721 + 626 diff --git a/src/gui/qt/mainwindowimpl.cpp b/src/gui/qt/mainwindowimpl.cpp index b5788f07..9e2135f3 100755 --- a/src/gui/qt/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindowimpl.cpp @@ -171,6 +171,9 @@ mainWindowImpl::mainWindowImpl(QMainWindow *parent, const char *name) } else { flipside->load(":/othercards/cards/othercards/flipside.png"); } + //Flipside Animation noch nicht erledigt + flipHolecardsAllInAlreadyDone = FALSE; + //Toolbox verstecken? if (!myConfig->readConfigInt("ShowToolBox", 1)) { groupBox_tools->hide(); } @@ -759,7 +762,7 @@ void mainWindowImpl::dealHoleCards() { refreshGroupbox(); } -void mainWindowImpl::dealFlopCards0() { dealFlopCards0Timer->start(dealCardsSpeed*2); } +void mainWindowImpl::dealFlopCards0() { dealFlopCards0Timer->start(preDealCardsSpeed); } void mainWindowImpl::dealFlopCards1() { @@ -792,8 +795,16 @@ void mainWindowImpl::dealFlopCards4() { actualHand->getBoard()->getMyCards(tempBoardCardsArray); tempCardsPixmap.load(":/othercards/cards/othercards/"+QString::number(tempBoardCardsArray[0], 10)+".png"); QPixmap card(tempCardsPixmap); - boardCardsArray[0]->setPixmap(card, FALSE); + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation", 1)) { + //mit Eye-Candy + boardCardsArray[0]->startFlipCards(guiGameSpeed, card, flipside); + } + else { + //ohne Eye-Candy + boardCardsArray[0]->setPixmap(card, FALSE); + } dealFlopCards4Timer->start(dealCardsSpeed); } @@ -804,8 +815,16 @@ void mainWindowImpl::dealFlopCards5() { actualHand->getBoard()->getMyCards(tempBoardCardsArray); tempCardsPixmap.load(":/othercards/cards/othercards/"+QString::number(tempBoardCardsArray[1], 10)+".png"); QPixmap card(tempCardsPixmap); - boardCardsArray[1]->setPixmap(card, FALSE); - + + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation", 1)) { + //mit Eye-Candy + boardCardsArray[1]->startFlipCards(guiGameSpeed, card, flipside); + } + else { + //ohne Eye-Candy + boardCardsArray[1]->setPixmap(card, FALSE); + } dealFlopCards5Timer->start(dealCardsSpeed); } @@ -817,17 +836,26 @@ void mainWindowImpl::dealFlopCards6() { actualHand->getBoard()->getMyCards(tempBoardCardsArray); tempCardsPixmap.load(":/othercards/cards/othercards/"+QString::number(tempBoardCardsArray[2], 10)+".png"); QPixmap card(tempCardsPixmap); - boardCardsArray[2]->setPixmap(card, FALSE); + + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation", 1)) { + //mit Eye-Candy + boardCardsArray[2]->startFlipCards(guiGameSpeed, card, flipside); + } + else { + //ohne Eye-Candy + boardCardsArray[2]->setPixmap(card, FALSE); + } // stable // wenn alle All In - if(actualHand->getAllInCondition()) { dealFlopCards6Timer->start(dealCardsSpeed*4); } + if(actualHand->getAllInCondition()) { dealFlopCards6Timer->start(AllInDealCardsSpeed); } // sonst normale Variante - else { dealFlopCards6Timer->start(dealCardsSpeed);} + else { dealFlopCards6Timer->start(postDealCardsSpeed);} } -void mainWindowImpl::dealTurnCards0() { dealTurnCards0Timer->start(dealCardsSpeed*2); } +void mainWindowImpl::dealTurnCards0() { dealTurnCards0Timer->start(preDealCardsSpeed); } void mainWindowImpl::dealTurnCards1() { @@ -843,17 +871,26 @@ void mainWindowImpl::dealTurnCards2() { actualHand->getBoard()->getMyCards(tempBoardCardsArray); tempCardsPixmap.load(":/othercards/cards/othercards/"+QString::number(tempBoardCardsArray[3], 10)+".png"); QPixmap card(tempCardsPixmap); - boardCardsArray[3]->setPixmap(card, FALSE); + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation", 1)) { + //mit Eye-Candy + boardCardsArray[3]->startFlipCards(guiGameSpeed, card, flipside); + } + else { + //ohne Eye-Candy + boardCardsArray[3]->setPixmap(card, FALSE); + } + // stable // wenn alle All In - if(actualHand->getAllInCondition()) { dealTurnCards2Timer->start(dealCardsSpeed*4); + if(actualHand->getAllInCondition()) { dealTurnCards2Timer->start(AllInDealCardsSpeed); } // sonst normale Variante - else { dealTurnCards2Timer->start(dealCardsSpeed); } + else { dealTurnCards2Timer->start(postDealCardsSpeed); } } -void mainWindowImpl::dealRiverCards0() { dealRiverCards0Timer->start(dealCardsSpeed*2); } +void mainWindowImpl::dealRiverCards0() { dealRiverCards0Timer->start(preDealCardsSpeed); } void mainWindowImpl::dealRiverCards1() { @@ -870,19 +907,23 @@ void mainWindowImpl::dealRiverCards2() { actualHand->getBoard()->getMyCards(tempBoardCardsArray); tempCardsPixmap.load(":/othercards/cards/othercards/"+QString::number(tempBoardCardsArray[4], 10)+".png"); QPixmap card(tempCardsPixmap); - boardCardsArray[4]->setPixmap(card, FALSE); + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation", 1)) { + //mit Eye-Candy + boardCardsArray[4]->startFlipCards(guiGameSpeed, card, flipside); + } + else { + //ohne Eye-Candy + boardCardsArray[4]->setPixmap(card, FALSE); + } // stable // wenn alle All In - if(actualHand->getAllInCondition()) { -// QTimer::singleShot(dealCardsSpeed*4, this, SLOT( handSwitchRounds() )); - dealRiverCards2Timer->start(dealCardsSpeed*4); - } + if(actualHand->getAllInCondition()) { dealRiverCards2Timer->start(AllInDealCardsSpeed); } // sonst normale Variante else { -// QTimer::singleShot(dealCardsSpeed, this, SLOT( handSwitchRounds() )); - dealRiverCards2Timer->start(dealCardsSpeed); + dealRiverCards2Timer->start(postDealCardsSpeed); } @@ -1243,7 +1284,7 @@ void mainWindowImpl::postRiverRunAnimation1() { void mainWindowImpl::postRiverRunAnimation2() { int i; - + //Aktive Spieler zählen --> wenn nur noch einer nicht-folded dann keine Karten umdrehen int activePlayersCounter = 0; for (i=0; igetPlayerArray()[i]->getMyCards(tempCardsIntArray); - for(j=0; j<2; j++) { - if(actualHand->getPlayerArray()[i]->getMyActiveStatus() && actualHand->getPlayerArray()[i]->getMyAction() != 1) { + if(!flipHolecardsAllInAlreadyDone) { + + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation", 1)) { + // mit Eye-Candy + + //TempArrays + int tempCardsIntArray[2]; + + int i, j; + + for(i=1; igetPlayerArray()[i]->getMyCards(tempCardsIntArray); + for(j=0; j<2; j++) { + if(actualHand->getPlayerArray()[i]->getMyActiveStatus() && actualHand->getPlayerArray()[i]->getMyAction() != 1) { - tempCardsPixmapArray[j].load(":/othercards/cards/othercards/"+QString::number(tempCardsIntArray[j], 10)+".png"); - holeCardsArray[i][j]->setPixmap(tempCardsPixmapArray[j], FALSE); - - } + holeCardsArray[i][j]->startFlipCards(guiGameSpeed, QPixmap(":/othercards/cards/othercards/"+QString::number(tempCardsIntArray[j], 10)+".png"), flipside); + + } + } + } } + else { + //Ohne Eye-Candy + + //Karten der aktiven Spieler umdrehen + QPixmap onePix(":/graphics/cards/1px.png"); + + //TempArrays + QPixmap tempCardsPixmapArray[2]; + int tempCardsIntArray[2]; + + int i, j; + for(i=1; igetPlayerArray()[i]->getMyCards(tempCardsIntArray); + for(j=0; j<2; j++) { + if(actualHand->getPlayerArray()[i]->getMyActiveStatus() && actualHand->getPlayerArray()[i]->getMyAction() != 1) { + + tempCardsPixmapArray[j].load(":/othercards/cards/othercards/"+QString::number(tempCardsIntArray[j], 10)+".png"); + holeCardsArray[i][j]->setPixmap(tempCardsPixmapArray[j], FALSE); + + } + } + } + } + //Wenn einmal umgedreht dann fertig!! + flipHolecardsAllInAlreadyDone = TRUE; } postRiverRunAnimation2Timer->start(postRiverRunAnimationSpeed); } else { postRiverRunAnimation3(); } + } void mainWindowImpl::postRiverRunAnimation3() { @@ -1431,37 +1502,65 @@ void mainWindowImpl::postRiverRunAnimation6() { void mainWindowImpl::flipHolecardsAllIn() { - int i; - - //Aktive Spieler zählen --> wenn nur noch einer nicht-folded dann keine Karten umdrehen - int activePlayersCounter = 0; - for (i=0; igetPlayerArray()[i]->getMyAction() != 1 && actualHand->getPlayerArray()[i]->getMyActiveStatus() == 1) activePlayersCounter++; - } - - if(activePlayersCounter!=1) { - - //Karten der aktiven Spieler umdrehen - QPixmap onePix(":/graphics/cards/1px.png"); - - //TempArrays - QPixmap tempCardsPixmapArray[2]; - int tempCardsIntArray[2]; - - int i, j; - for(i=1; igetPlayerArray()[i]->getMyCards(tempCardsIntArray); - for(j=0; j<2; j++) { - if(actualHand->getPlayerArray()[i]->getMyActiveStatus() && actualHand->getPlayerArray()[i]->getMyAction() != 1) { - - tempCardsPixmapArray[j].load(":/othercards/cards/othercards/"+QString::number(tempCardsIntArray[j], 10)+".png"); - holeCardsArray[i][j]->setPixmap(tempCardsPixmapArray[j], FALSE); - - } - } - } - } + int i; + + if(!flipHolecardsAllInAlreadyDone) { + //Aktive Spieler zählen --> wenn nur noch einer nicht-folded dann keine Karten umdrehen + int activePlayersCounter = 0; + for (i=0; igetPlayerArray()[i]->getMyAction() != 1 && actualHand->getPlayerArray()[i]->getMyActiveStatus() == 1) activePlayersCounter++; + } + + if(activePlayersCounter!=1) { + + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation", 1)) { + // mit Eye-Candy + + //TempArrays + int tempCardsIntArray[2]; + + int i, j; + + for(i=1; igetPlayerArray()[i]->getMyCards(tempCardsIntArray); + for(j=0; j<2; j++) { + if(actualHand->getPlayerArray()[i]->getMyActiveStatus() && actualHand->getPlayerArray()[i]->getMyAction() != 1) { + + holeCardsArray[i][j]->startFlipCards(guiGameSpeed, QPixmap(":/othercards/cards/othercards/"+QString::number(tempCardsIntArray[j], 10)+".png"), flipside); + + } + } + } + } + else { + //Ohne Eye-Candy + + //Karten der aktiven Spieler umdrehen + QPixmap onePix(":/graphics/cards/1px.png"); + + //TempArrays + QPixmap tempCardsPixmapArray[2]; + int temp2CardsIntArray[2]; + + int i, j; + for(i=1; igetPlayerArray()[i]->getMyCards(temp2CardsIntArray); + for(j=0; j<2; j++) { + if(actualHand->getPlayerArray()[i]->getMyActiveStatus() && actualHand->getPlayerArray()[i]->getMyAction() != 1) { + + tempCardsPixmapArray[j].load(":/othercards/cards/othercards/"+QString::number(temp2CardsIntArray[j], 10)+".png"); + holeCardsArray[i][j]->setPixmap(tempCardsPixmapArray[j], FALSE); + + } + } + } + } + } + } + //Wenn einmal umgedreht dann fertig!! + flipHolecardsAllInAlreadyDone = TRUE; } void mainWindowImpl::startNewHand() { @@ -1481,11 +1580,20 @@ void mainWindowImpl::handSwitchRounds() { actualHand->switchRounds(); } void mainWindowImpl::nextRoundCleanGui() { - int i; + int i,j; - // GUI bereinigen + // GUI bereinigen - Bilder löschen, Animationen unterbrechen QPixmap onePix(":/graphics/cards/1px.png"); - for (i=0; i<5; i++ ) { boardCardsArray[i]->setPixmap(onePix, FALSE); } + for (i=0; i<5; i++ ) { + boardCardsArray[i]->setPixmap(onePix, FALSE); + boardCardsArray[i]->setFadeOutAction(FALSE); + + } + for (i=1; i<=4; i++ ) { + for ( j=0; j<=1; j++ ) { holeCardsArray[i][j]->setFadeOutAction(FALSE);} + } + + QColor c(0,0,0); for(i=0; ireadConfigInt("PauseBetweenHands", 0)) { pushButton_break->click(); } @@ -1579,6 +1689,9 @@ void mainWindowImpl::setSpeeds() { gameSpeed = (11-guiGameSpeed)*10; dealCardsSpeed = (gameSpeed/2)*10; //milliseconds + preDealCardsSpeed = dealCardsSpeed*2; //Zeit for Karten aufdecken auf dem Board (Flop, Turn, River) + postDealCardsSpeed = dealCardsSpeed*2; //Zeit nach Karten aufdecken auf dem Board (Flop, Turn, River) + AllInDealCardsSpeed = dealCardsSpeed*4; //Zeit nach Karten aufdecken auf dem Board (Flop, Turn, River) bei AllIn postRiverRunAnimationSpeed = gameSpeed*18; winnerBlinkSpeed = gameSpeed*3; //milliseconds newRoundSpeed = gameSpeed*35; @@ -1612,12 +1725,11 @@ void mainWindowImpl::paintStartSplash() { void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) { -// cout << event->key() << endl; + cout << event->key() << endl; - - if (event->key() == 16777265) { switchToolBox(); } + if (event->key() == 16777220) { if(spinBox_set->hasFocus()) pushButton_set->click(); } //ENTER + if (event->key() == 16777265) { switchToolBox(); } //F2 if (event->key() == 65) { - pixmapLabel_card1a->startFlipCards(4, QPixmap(":/othercards/cards/othercards/44.png"), flipside); } if (event->key() == 66) { diff --git a/src/gui/qt/mainwindowimpl.h b/src/gui/qt/mainwindowimpl.h index 436487ad..365b5432 100755 --- a/src/gui/qt/mainwindowimpl.h +++ b/src/gui/qt/mainwindowimpl.h @@ -234,6 +234,9 @@ private: int guiGameSpeed; int gameSpeed; int dealCardsSpeed; + int preDealCardsSpeed; + int postDealCardsSpeed; + int AllInDealCardsSpeed; int postRiverRunAnimationSpeed; int winnerBlinkSpeed; int newRoundSpeed; @@ -246,6 +249,8 @@ private: bool debugMode; bool breakAfterActualHand; + + bool flipHolecardsAllInAlreadyDone; QColor active; QColor inactive; diff --git a/src/gui/qt/settingsdialog.ui b/src/gui/qt/settingsdialog.ui index 392f30af..8a3d420b 100644 --- a/src/gui/qt/settingsdialog.ui +++ b/src/gui/qt/settingsdialog.ui @@ -177,6 +177,26 @@ 6 + + + + Show Toolbox (F2 to switch on/off) + + + + + + + + 75 + true + + + + Interface + + + @@ -184,20 +204,14 @@ - - - - Qt::Vertical + + + + Show Fade-Out Animation for Non-Winning Cards - - - 20 - 40 - - - + - + Flipside of Cards @@ -291,20 +305,6 @@ p, li { white-space: pre-wrap; } - - - - Show Fade-Out Animation for Non-Winning Cards - - - - - - - Show Toolbox (F2 to switch on/off) - - - @@ -312,16 +312,23 @@ p, li { white-space: pre-wrap; } - - - - - 75 - true - + + + + Qt::Vertical + + + 20 + 40 + + + + + + - Interface + Show Flip-Card Animation @@ -519,14 +526,24 @@ p, li { white-space: pre-wrap; } spinBox_quantityPlayers spinBox_startCash spinBox_smallBlind + spinBox_handsBeforeRaiseSmallBlind spinBox_gameSpeed + checkBox_pauseBetweenHands checkBox_showGameSettingsDialogOnNewGame - buttonBox + checkBox_showIntro + checkBox_showToolbox + checkBox_showFadeOutCardsAnimation + checkBox_showFlipCardsAnimation + radioButton_flipsideTux + radioButton_flipsideOwn + lineEdit_OwnFlipsideFilename + pushButton_openFlipsidePicture lineEdit_humanPlayerName lineEdit_Opponent1Name lineEdit_Opponent2Name lineEdit_Opponent3Name lineEdit_Opponent4Name + buttonBox diff --git a/src/gui/qt/settingsdialogimpl.cpp b/src/gui/qt/settingsdialogimpl.cpp index 2a367e3f..757427a3 100644 --- a/src/gui/qt/settingsdialogimpl.cpp +++ b/src/gui/qt/settingsdialogimpl.cpp @@ -53,6 +53,7 @@ settingsDialogImpl::settingsDialogImpl(QWidget *parent, const char *name) checkBox_showToolbox->setChecked(myConfig.readConfigInt("ShowToolBox", 1)); checkBox_showIntro->setChecked(myConfig.readConfigInt("ShowIntro", 1)); checkBox_showFadeOutCardsAnimation->setChecked(myConfig.readConfigInt("ShowFadeOutCardsAnimation", 1)); + checkBox_showFlipCardsAnimation->setChecked(myConfig.readConfigInt("ShowFlipCardsAnimation", 1)); radioButton_flipsideTux->setChecked(myConfig.readConfigInt("FlipsideTux", 1)); radioButton_flipsideOwn->setChecked(myConfig.readConfigInt("FlipsideOwn", 0)); if(radioButton_flipsideOwn->isChecked()) { @@ -98,6 +99,7 @@ void settingsDialogImpl::isAccepted() { myConfig.writeConfigInt("ShowToolBox", checkBox_showToolbox->isChecked()); myConfig.writeConfigInt("ShowIntro", checkBox_showIntro->isChecked()); myConfig.writeConfigInt("ShowFadeOutCardsAnimation", checkBox_showFadeOutCardsAnimation->isChecked()); + myConfig.writeConfigInt("ShowFlipCardsAnimation", checkBox_showFlipCardsAnimation->isChecked()); myConfig.writeConfigInt("FlipsideTux", radioButton_flipsideTux->isChecked()); myConfig.writeConfigInt("FlipsideOwn", radioButton_flipsideOwn->isChecked()); myConfig.writeConfigString("FlipsideOwnFile", lineEdit_OwnFlipsideFilename->text().toStdString());