From a7fa1b03e702edf06ca34e17f896a84b49279d5b Mon Sep 17 00:00:00 2001 From: doitux Date: Sun, 4 Feb 2007 13:46:27 +0000 Subject: [PATCH] --- src/game.cpp | 5 ++- src/game.h | 8 +++- src/gui/guiinterface.h | 3 +- src/gui/qt/guiwrapper.cpp | 4 +- src/gui/qt/guiwrapper.h | 3 +- src/gui/qt/log.cpp | 51 ++++++++++++++++++------ src/gui/qt/log.h | 5 ++- src/gui/qt/mainwindow/mainwindow.ui | 4 +- src/gui/qt/mainwindow/mainwindowimpl.cpp | 22 +++++++--- src/session.cpp | 4 +- src/session.h | 6 +++ 11 files changed, 87 insertions(+), 28 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index e10bd534..35f543a1 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -31,7 +31,7 @@ using namespace std; -Game::Game(ConfigFile* c, GuiInterface* g, int qP, int sC, int sB) : myConfig(c), myGui(g), actualHand(0), actualBoard(0), startQuantityPlayers(qP), startCash(sC), startSmallBlind(sB), actualQuantityPlayers(qP), actualSmallBlind(sB), actualHandID(0), dealerPosition(0) +Game::Game(ConfigFile* c, GuiInterface* g, int qP, int sC, int sB, int gId) : myConfig(c), myGui(g), actualHand(0), actualBoard(0), startQuantityPlayers(qP), startCash(sC), startSmallBlind(sB), myGameID(gId), actualQuantityPlayers(qP), actualSmallBlind(sB), actualHandID(0), dealerPosition(0) { // cout << "Create Game Object" << "\n"; int i; @@ -142,5 +142,8 @@ void Game::startHand() } while(!(playerArray[dealerPosition]->getMyActiveStatus())); + myGui->logNewGameHandMsg(myGameID, actualHandID); + + // Abfrage Cash==0 -> player inactive -> actualQuantityPlayer-- } diff --git a/src/game.h b/src/game.h index 4b32ac3f..fe8e0add 100755 --- a/src/game.h +++ b/src/game.h @@ -35,7 +35,7 @@ class ConfigFile; class Game { public: - Game(ConfigFile*, GuiInterface*, int, int, int); + Game(ConfigFile*, GuiInterface*, int, int, int, int); ~Game(); @@ -52,6 +52,10 @@ public: void setDealerPosition(const int& theValue) { dealerPosition = theValue; } int getDealerPosition() const { return dealerPosition; } + void setMyGameID(const int& theValue) { myGameID = theValue;} + int getMyGameID() const { return myGameID; } + + //Zufgriff Laufvariablen void setActualQuantityPlayers(const int& theValue) { actualQuantityPlayers = theValue; } @@ -83,11 +87,11 @@ private: BoardInterface *actualBoard; PlayerInterface *playerArray[5]; - //Startvariablen int startQuantityPlayers; int startCash; int startSmallBlind; + int myGameID; //Laufvariablen int actualQuantityPlayers; diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index 10e8585e..c5759175 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -92,7 +92,8 @@ public: //log.cpp - virtual void logPlayerActionMsg(std::string playName, int action, int setValue) const=0; + virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0; + virtual void logNewGameHandMsg(int gameID, int HandID) =0; diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index 000c1f82..63151ef4 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -86,7 +86,7 @@ void GuiWrapper::nextRoundCleanGui() const { myW->nextRoundCleanGui(); } void GuiWrapper::meInAction() const { myW->meInAction(); } -void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) const { myLog->logPlayerActionMsg(playerName, action, setValue); } - +void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) { myLog->logPlayerActionMsg(playerName, action, setValue); } +void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myLog->logNewGameHandMsg(gameID, handID); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index c6fbbdf1..99b1ad6f 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -83,7 +83,8 @@ public: void meInAction() const; - void logPlayerActionMsg(std::string playerName, int action, int setValue) const; + void logPlayerActionMsg(std::string playerName, int action, int setValue) ; + void logNewGameHandMsg(int gameID, int handID) ; private: diff --git a/src/gui/qt/log.cpp b/src/gui/qt/log.cpp index 9b6bf696..b6e721d2 100644 --- a/src/gui/qt/log.cpp +++ b/src/gui/qt/log.cpp @@ -38,18 +38,16 @@ Log::Log(mainWindowImpl* w) : myW(w) myLogFile->open( QIODevice::WriteOnly ); QTextStream stream( myLogFile ); - stream << ""; - stream << ""; - stream << ""; - stream << "

Log-File for PokerTH Session started on "+QDate::currentDate().toString("yyyy-MM-dd")+" at "+QTime::currentTime().toString("hh:mm:ss")+"

"; - stream << ""; - stream << ""; + stream << "\n"; + stream << "\n"; + stream << "\n"; + stream << "

Log-File for PokerTH Session started on "+QDate::currentDate().toString("yyyy-MM-dd")+" at "+QTime::currentTime().toString("hh:mm:ss")+"

\n"; + stream << "\n"; + stream << "\n"; myLogFile->close(); + + linesInFile = 5; } - - - -; } @@ -57,8 +55,10 @@ Log::~Log() { } -void Log::logPlayerActionMsg(string playerName, int action, int setValue) const { - +void Log::logPlayerActionMsg(string playerName, int action, int setValue) { + + int i; + QString msg; msg = QString::fromStdString(playerName); @@ -83,7 +83,34 @@ void Log::logPlayerActionMsg(string playerName, int action, int setValue) const myW->textBrowser_Log->append(msg); + myLogFile->open( QIODevice::ReadWrite ); + QTextStream stream( myLogFile ); + for(i=0; i<=linesInFile-2; i++) { stream.readLine(); } + stream << msg+"
\n"; + stream << "\n"; + stream << "\n"; + myLogFile->close(); + + linesInFile++; + } +void Log::logNewGameHandMsg(int gameID, int handID) { + int i; + myW->textBrowser_Log->append("## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##"); + + myLogFile->open( QIODevice::ReadWrite ); + QTextStream stream( myLogFile ); + for(i=0; i<=linesInFile-2; i++) { stream.readLine(); } + + QString msg("

##### Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" #####

"); + stream << msg << "\n"; + stream << "\n"; + stream << "\n"; + myLogFile->close(); + + linesInFile++; + +} diff --git a/src/gui/qt/log.h b/src/gui/qt/log.h index d74cd785..019467db 100644 --- a/src/gui/qt/log.h +++ b/src/gui/qt/log.h @@ -40,11 +40,14 @@ public: ~Log(); - void logPlayerActionMsg(std::string playName, int action, int setValue) const; + void logPlayerActionMsg(std::string playName, int action, int setValue); + void logNewGameHandMsg(int gameID, int handID); private: + int linesInFile; + mainWindowImpl *myW; ConfigFile *myConfig; QFile *myLogFile; diff --git a/src/gui/qt/mainwindow/mainwindow.ui b/src/gui/qt/mainwindow/mainwindow.ui index 31a59170..8b1c13ea 100644 --- a/src/gui/qt/mainwindow/mainwindow.ui +++ b/src/gui/qt/mainwindow/mainwindow.ui @@ -578,7 +578,7 @@ - :/graphics/graphics/logo-140-100.png + @@ -4036,7 +4036,7 @@ pushButton_allin - + diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index c5b51bc5..1ff0da59 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -352,6 +352,9 @@ mainWindowImpl::mainWindowImpl(QMainWindow *parent) inactive.setRgb(83,141,107); highlight.setRgb(151,214,109); + //ShortCuts +// QShortcut *startNewGameKeys = new QShortcut(QKeySequence(Qt::Key_Control), Ui::mainWindow); + //Connects connect(dealFlopCards0Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards1() )); connect(dealFlopCards1Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards2() )); @@ -385,6 +388,9 @@ mainWindowImpl::mainWindowImpl(QMainWindow *parent) connect(postRiverRunAnimation5Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation6() )); connect(postRiverRunAnimation6Timer, SIGNAL(timeout()), this, SLOT( startNewHand() )); + + +// connect( startNewGameKeys, SIGNAL(activated() ), this, SLOT( callNewGameDialog() ) ); connect( actionNewGame, SIGNAL( triggered() ), this, SLOT( callNewGameDialog() ) ); connect( actionAboutPokerth, SIGNAL( triggered() ), this, SLOT( callAboutPokerthDialog() ) ); connect( actionSettings, SIGNAL( triggered() ), this, SLOT( callSettingsDialog() ) ); @@ -560,8 +566,8 @@ void mainWindowImpl::refreshSet() { void mainWindowImpl::refreshButton() { - QPixmap dealerButton(":/graphics/cards/dealerbutton.png"); - QPixmap onePix(":/graphics/cards/1px.png"); + QPixmap dealerButton(":/graphics/graphics/dealerbutton.png"); + QPixmap onePix(":/graphics/graphics/1px.png"); int i; for (i=0; igetPlayerArray()[i]->getMyAction()==1) { groupBoxArray[i]->setDisabled(TRUE); - QPixmap onePix(":/graphics/cards/1px.png"); + QPixmap onePix(":/graphics/graphics/1px.png"); if(i != 0) { holeCardsArray[i][0]->setPixmap(onePix, FALSE); holeCardsArray[i][1]->setPixmap(onePix, FALSE); @@ -1744,11 +1750,17 @@ void mainWindowImpl::paintStartSplash() { void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) { -// cout << event->key() << endl; + cout << event->key() << endl; + bool ctrlPressed = FALSE; + if (event->key() == 16777220) { if(spinBox_set->hasFocus()) pushButton_set->click(); } //ENTER if (event->key() == 16777265) { switchToolBox(); } //F2 - if (event->key() == 16777249) { pushButton_break->click(); } //CTRL + if (event->key() == 16777249) { + pushButton_break->click(); + ctrlPressed = TRUE; +// QTimer::SingleShot + } //CTRL // if (event->key() == 65) { paintStartSplash(); diff --git a/src/session.cpp b/src/session.cpp index 0429d5e6..95f0ee68 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -29,6 +29,7 @@ using namespace std; Session::Session(GuiInterface* g) : actualGame(0), myGui(g) { + actualGameID = 0; // Session an mainwindowimpl bergeben myGui->setSession(this); @@ -45,8 +46,9 @@ Session::~Session() void Session::startGame(int qP, int sC, int sB) { - actualGame = new Game(myConfig, myGui, qP, sC, sB); + actualGameID++; + actualGame = new Game(myConfig, myGui, qP, sC, sB, actualGameID); } void Session::deleteGame() { diff --git a/src/session.h b/src/session.h index cfdac6f1..7e760d62 100755 --- a/src/session.h +++ b/src/session.h @@ -38,9 +38,15 @@ public: void startGame(int, int, int); void deleteGame(); + void setActualGameID(const int& theValue) { actualGameID = theValue; } + int getActualGameID() const { return actualGameID; } + // void createConfig(); private: + + int actualGameID; + Game *actualGame; GuiInterface *myGui; ConfigFile *myConfig;