This commit is contained in:
doitux
2007-05-15 21:22:16 +00:00
parent c160a09811
commit 151a45de33
4 changed files with 215 additions and 173 deletions
+3 -2
View File
@@ -40,7 +40,7 @@ using namespace std;
ConfigFile::ConfigFile(bool configFirstStart) ConfigFile::ConfigFile(bool configFirstStart)
{ {
// !!!! Revisionsnummer der Configdefaults !!!!! // !!!! Revisionsnummer der Configdefaults !!!!!
configRev = 17; configRev = 18;
// Pfad und Dateinamen setzen // Pfad und Dateinamen setzen
#ifdef _WIN32 #ifdef _WIN32
@@ -187,10 +187,11 @@ void ConfigFile::updateConfig(ConfigState myConfigState) {
configList.push_back(ConfigInfo("Opponent5Avatar", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("Opponent5Avatar", CONFIG_TYPE_STRING, ""));
configList.push_back(ConfigInfo("Opponent6Name", CONFIG_TYPE_STRING, "Player 6")); configList.push_back(ConfigInfo("Opponent6Name", CONFIG_TYPE_STRING, "Player 6"));
configList.push_back(ConfigInfo("Opponent6Avatar", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("Opponent6Avatar", CONFIG_TYPE_STRING, ""));
configList.push_back(ConfigInfo("LogOnOff", CONFIG_TYPE_INT, "1"));
configList.push_back(ConfigInfo("LogDir", CONFIG_TYPE_STRING, logDir)); configList.push_back(ConfigInfo("LogDir", CONFIG_TYPE_STRING, logDir));
configList.push_back(ConfigInfo("LogStoreDuration", CONFIG_TYPE_INT, "2")); configList.push_back(ConfigInfo("LogStoreDuration", CONFIG_TYPE_INT, "2"));
configList.push_back(ConfigInfo("LogInterval", CONFIG_TYPE_INT, "0"));
configList.push_back(ConfigInfo("DataDir", CONFIG_TYPE_STRING, dataDir)); configList.push_back(ConfigInfo("DataDir", CONFIG_TYPE_STRING, dataDir));
configList.push_back(ConfigInfo("LogStoreDuration", CONFIG_TYPE_INT, "2"));
if(myConfigState == NONEXISTING) { if(myConfigState == NONEXISTING) {
+66 -29
View File
@@ -31,6 +31,8 @@ Log::Log(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
{ {
myW->setLog(this); myW->setLog(this);
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
if(myConfig->readConfigString("LogDir") != "" && QDir::QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())).exists()) { if(myConfig->readConfigString("LogDir") != "" && QDir::QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())).exists()) {
myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
@@ -39,7 +41,7 @@ Log::Log(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
//Logo-Pixmap extrahieren //Logo-Pixmap extrahieren
QPixmap::QPixmap(":graphics/resources/graphics/logoChip3D.png").save(myLogDir->absolutePath()+"/logo.png"); QPixmap::QPixmap(":graphics/resources/graphics/logoChip3D.png").save(myLogDir->absolutePath()+"/logo.png");
// myW->textBrowser_Log->append(myLogFile->fileName()); // myW->textBrowser_Log->append(myLogFile->fileName());
myLogFile->open( QIODevice::WriteOnly ); myLogFile->open( QIODevice::WriteOnly );
QTextStream stream( myLogFile ); QTextStream stream( myLogFile );
@@ -50,8 +52,8 @@ Log::Log(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
stream << "<body>\n"; stream << "<body>\n";
stream << "<img src='logo.png'>\n"; stream << "<img src='logo.png'>\n";
stream << "<h3><b>Log-File for PokerTH 0.4 Session started on "+QDate::currentDate().toString("yyyy-MM-dd")+" at "+QTime::currentTime().toString("hh:mm:ss")+"</b></h3>\n"; stream << "<h3><b>Log-File for PokerTH 0.4 Session started on "+QDate::currentDate().toString("yyyy-MM-dd")+" at "+QTime::currentTime().toString("hh:mm:ss")+"</b></h3>\n";
// stream << "</body>\n"; // stream << "</body>\n";
// stream << "</html>\n"; // stream << "</html>\n";
myLogFile->close(); myLogFile->close();
linesInFile = 3; linesInFile = 3;
@@ -87,7 +89,7 @@ Log::Log(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
} }
else { cout << "Log directory doesn't exists. Cannot create log files"; } else { cout << "Log directory doesn't exists. Cannot create log files"; }
}
} }
Log::~Log() Log::~Log()
@@ -124,16 +126,18 @@ void Log::logPlayerActionMsg(string playerName, int action, int setValue) {
myW->textBrowser_Log->append(msg); myW->textBrowser_Log->append(msg);
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
myLogFile->open( QIODevice::ReadWrite ); myLogFile->open( QIODevice::ReadWrite );
QTextStream stream( myLogFile ); QTextStream stream( myLogFile );
for(i=0; i<=linesInFile; i++) { stream.readLine(); } for(i=0; i<=linesInFile; i++) { stream.readLine(); }
stream << msg+"</br>\n"; stream << msg+"</br>\n";
// stream << "</body>\n"; // stream << "</body>\n";
// stream << "</html>\n"; // stream << "</html>\n";
myLogFile->close(); myLogFile->close();
linesInFile++; linesInFile++;
}
} }
void Log::logNewGameHandMsg(int gameID, int handID) { void Log::logNewGameHandMsg(int gameID, int handID) {
@@ -142,6 +146,9 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
myW->textBrowser_Log->append("<b>## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##</b>"); myW->textBrowser_Log->append("<b>## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##</b>");
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
myLogFile->open( QIODevice::ReadWrite ); myLogFile->open( QIODevice::ReadWrite );
QTextStream stream( myLogFile ); QTextStream stream( myLogFile );
for(i=0; i<=linesInFile; i++) { stream.readLine(); } for(i=0; i<=linesInFile; i++) { stream.readLine(); }
@@ -205,8 +212,8 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
} }
if(activePlayersCounter < 3) { j=1; } if(activePlayersCounter < 3) { j=1; }
// cout << activePlayersCounter << endl; // cout << activePlayersCounter << endl;
// cout << (i+currentHand->getDealerPosition()+j)%5 << endl; // cout << (i+currentHand->getDealerPosition()+j)%5 << endl;
switch (currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMyButton()) { switch (currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMyButton()) {
case 2 : stream << QString::fromUtf8(currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMyName().c_str())+" ("+QString::number(currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMySet(),10)+"$), "; case 2 : stream << QString::fromUtf8(currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMyName().c_str())+" ("+QString::number(currentHand->getPlayerArray()[(i+currentHand->getDealerPosition()+j)%MAX_NUMBER_OF_PLAYERS]->getMySet(),10)+"$), ";
@@ -223,7 +230,7 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
myLogFile->close(); myLogFile->close();
linesInFile = linesInFile++; linesInFile = linesInFile++;
}
} }
void Log::logPlayerWinsMsg(int playerID, int pot) { void Log::logPlayerWinsMsg(int playerID, int pot) {
@@ -231,44 +238,63 @@ void Log::logPlayerWinsMsg(int playerID, int pot) {
int i; int i;
HandInterface *currentHand = myW->getSession().getCurrentGame()->getCurrentHand(); HandInterface *currentHand = myW->getSession().getCurrentGame()->getCurrentHand();
myW->textBrowser_Log->append(QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName().c_str())+" wins "+QString::number(pot,10)+"$!!! ");
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
myLogFile->open( QIODevice::ReadWrite ); myLogFile->open( QIODevice::ReadWrite );
QTextStream stream( myLogFile ); QTextStream stream( myLogFile );
for(i=0; i<=linesInFile; i++) { stream.readLine(); } for(i=0; i<=linesInFile; i++) { stream.readLine(); }
// if (cardsValueInt != -1) { // if (cardsValueInt != -1) {
// myW->textBrowser_Log->append(QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName())+" wins "+QString::number(pot,10)+"$ with "+translateCardsValueCode(cardsValueInt).at(0)+"!!! "); // myW->textBrowser_Log->append(QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName())+" wins "+QString::number(pot,10)+"$ with "+translateCardsValueCode(cardsValueInt).at(0)+"!!! ");
// stream << "</br><i>"+QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName())+" wins "+QString::number(pot,10)+"$!!!</i></p>\n"; // stream << "</br><i>"+QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName())+" wins "+QString::number(pot,10)+"$!!!</i></p>\n";
// } // }
// else { // else {
myW->textBrowser_Log->append(QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName().c_str())+" wins "+QString::number(pot,10)+"$!!! ");
stream << "</br><i>"+QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName().c_str())+" wins "+QString::number(pot,10)+"$!!!</i></p>\n"; stream << "</br><i>"+QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName().c_str())+" wins "+QString::number(pot,10)+"$!!!</i></p>\n";
// } // }
myLogFile->close(); myLogFile->close();
linesInFile++; linesInFile++;
}
} }
void Log::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4, int card5) { void Log::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4, int card5) {
int i; int i;
QString round;
switch (roundID) {
case 1: round = "Flop";
myW->textBrowser_Log->append("--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+"]");
break;
case 2: round = "Turn";
myW->textBrowser_Log->append("--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+translateCardCode(card4).at(1)+"]");
break;
case 3: round = "River";
myW->textBrowser_Log->append("--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+translateCardCode(card4).at(1)+","+translateCardCode(card5).at(0)+translateCardCode(card5).at(1)+"]");
break;
default: round = "ERROR";
}
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
myLogFile->open( QIODevice::ReadWrite ); myLogFile->open( QIODevice::ReadWrite );
QTextStream stream( myLogFile ); QTextStream stream( myLogFile );
for(i=0; i<=linesInFile; i++) { stream.readLine(); } for(i=0; i<=linesInFile; i++) { stream.readLine(); }
QString round;
switch (roundID) { switch (roundID) {
case 1: round = "Flop"; case 1: round = "Flop";
myW->textBrowser_Log->append("--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+"]");
stream << "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+"]"+"</br>\n"; stream << "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+"]"+"</br>\n";
break; break;
case 2: round = "Turn"; case 2: round = "Turn";
myW->textBrowser_Log->append("--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+translateCardCode(card4).at(1)+"]");
stream << "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+",<b>"+translateCardCode(card4).at(0)+"</b>"+translateCardCode(card4).at(1)+"]"+"</br>\n"; stream << "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+",<b>"+translateCardCode(card4).at(0)+"</b>"+translateCardCode(card4).at(1)+"]"+"</br>\n";
break; break;
case 3: round = "River"; case 3: round = "River";
myW->textBrowser_Log->append("--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+translateCardCode(card4).at(1)+","+translateCardCode(card5).at(0)+translateCardCode(card5).at(1)+"]");
stream << "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+",<b>"+translateCardCode(card4).at(0)+"</b>"+translateCardCode(card4).at(1)+",<b>"+translateCardCode(card5).at(0)+"</b>"+translateCardCode(card5).at(1)+"]"+"</br>\n"; stream << "</br><b>"+round.toUpper()+"</b> [board cards <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+",<b>"+translateCardCode(card3).at(0)+"</b>"+translateCardCode(card3).at(1)+",<b>"+translateCardCode(card4).at(0)+"</b>"+translateCardCode(card4).at(1)+",<b>"+translateCardCode(card5).at(0)+"</b>"+translateCardCode(card5).at(1)+"]"+"</br>\n";
break; break;
default: round = "ERROR"; default: round = "ERROR";
@@ -276,17 +302,13 @@ void Log::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int
myLogFile->close(); myLogFile->close();
linesInFile++; linesInFile++;
}
} }
void Log::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt, string showHas) { void Log::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt, string showHas) {
int i; int i;
myLogFile->open( QIODevice::ReadWrite );
QTextStream stream( myLogFile );
for(i=0; i<=linesInFile; i++) { stream.readLine(); }
if (cardsValueInt != -1) { if (cardsValueInt != -1) {
QString tempHandName; QString tempHandName;
@@ -393,16 +415,31 @@ void Log::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int
} }
myW->textBrowser_Log->append(QString::fromUtf8(playerName.c_str())+" "+QString::fromUtf8(showHas.c_str())+" \""+tempHandName+"\""); myW->textBrowser_Log->append(QString::fromUtf8(playerName.c_str())+" "+QString::fromUtf8(showHas.c_str())+" \""+tempHandName+"\"");
stream << QString::fromUtf8(playerName.c_str())+" "+QString::fromUtf8(showHas.c_str())+" [ <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+"] - "+tempHandName+"</br>\n";
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
myLogFile->open( QIODevice::ReadWrite );
QTextStream stream( myLogFile );
for(i=0; i<=linesInFile; i++) { stream.readLine(); }
stream << QString::fromUtf8(playerName.c_str())+" "+QString::fromUtf8(showHas.c_str())+" [ <b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+"] - "+tempHandName+"</br>\n";
myLogFile->close();
linesInFile++;
}
} }
else { else {
myW->textBrowser_Log->append(QString::fromUtf8(playerName.c_str())+" "+QString::fromUtf8(showHas.c_str())+" ["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+"]"); myW->textBrowser_Log->append(QString::fromUtf8(playerName.c_str())+" "+QString::fromUtf8(showHas.c_str())+" ["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+"]");
stream << QString::fromUtf8(playerName.c_str())+" "+QString::fromUtf8(showHas.c_str())+" [<b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+"]"+"</br>\n";
} if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
myLogFile->open( QIODevice::ReadWrite );
QTextStream stream( myLogFile );
for(i=0; i<=linesInFile; i++) { stream.readLine(); }
stream << QString::fromUtf8(playerName.c_str())+" "+QString::fromUtf8(showHas.c_str())+" [<b>"+translateCardCode(card1).at(0)+"</b>"+translateCardCode(card1).at(1)+",<b>"+translateCardCode(card2).at(0)+"</b>"+translateCardCode(card2).at(1)+"]"+"</br>\n";
myLogFile->close(); myLogFile->close();
linesInFile++; linesInFile++;
}
}
} }
QStringList Log::translateCardCode(int cardCode) { QStringList Log::translateCardCode(int cardCode) {
+1 -1
View File
@@ -1030,7 +1030,7 @@ p, li { white-space: pre-wrap; }
<number>6</number> <number>6</number>
</property> </property>
<item row="2" column="0" > <item row="2" column="0" >
<widget class="QGroupBox" name="groupBox_LogOnOff" > <widget class="QGroupBox" name="groupBox_logOnOff" >
<property name="title" > <property name="title" >
<string>Enable/Disable Logging</string> <string>Enable/Disable Logging</string>
</property> </property>
@@ -111,8 +111,10 @@ void settingsDialogImpl::exec() {
lineEdit_OwnFlipsideFilename->setText(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str())); lineEdit_OwnFlipsideFilename->setText(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str()));
//Log //Log
groupBox_logOnOff->setChecked(myConfig->readConfigInt("LogOnOff"));
lineEdit_logDir->setText(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); lineEdit_logDir->setText(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration")); spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration"));
comboBox_logInterval->setCurrentIndex(myConfig->readConfigInt("LogInterval"));
QDialog::exec(); QDialog::exec();
@@ -242,6 +244,7 @@ void settingsDialogImpl::isAccepted() {
} }
// Log // Log
myConfig->writeConfigInt("LogOnOff", groupBox_logOnOff->isChecked());
if(QDir::QDir(lineEdit_logDir->text()).exists() && lineEdit_logDir->text() != "") { myConfig->writeConfigString("LogDir", lineEdit_logDir->text().toUtf8().constData()); } if(QDir::QDir(lineEdit_logDir->text()).exists() && lineEdit_logDir->text() != "") { myConfig->writeConfigString("LogDir", lineEdit_logDir->text().toUtf8().constData()); }
else { else {
QMessageBox::warning(this, tr("Settings Error"), QMessageBox::warning(this, tr("Settings Error"),
@@ -252,6 +255,7 @@ void settingsDialogImpl::isAccepted() {
} }
myConfig->writeConfigInt("LogStoreDuration", spinBox_logStoreDuration->value()); myConfig->writeConfigInt("LogStoreDuration", spinBox_logStoreDuration->value());
myConfig->writeConfigInt("LogInterval", comboBox_logInterval->currentIndex());
//Wenn alles richtig eingegeben wurde --> Dialog schließen //Wenn alles richtig eingegeben wurde --> Dialog schließen
if(settingsCorrect) { this->hide(); } if(settingsCorrect) { this->hide(); }