This commit is contained in:
@@ -40,7 +40,7 @@ using namespace std;
|
||||
ConfigFile::ConfigFile(bool configFirstStart)
|
||||
{
|
||||
// !!!! Revisionsnummer der Configdefaults !!!!!
|
||||
configRev = 17;
|
||||
configRev = 18;
|
||||
|
||||
// Pfad und Dateinamen setzen
|
||||
#ifdef _WIN32
|
||||
@@ -187,10 +187,11 @@ void ConfigFile::updateConfig(ConfigState myConfigState) {
|
||||
configList.push_back(ConfigInfo("Opponent5Avatar", CONFIG_TYPE_STRING, ""));
|
||||
configList.push_back(ConfigInfo("Opponent6Name", CONFIG_TYPE_STRING, "Player 6"));
|
||||
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("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("LogStoreDuration", CONFIG_TYPE_INT, "2"));
|
||||
|
||||
|
||||
if(myConfigState == NONEXISTING) {
|
||||
|
||||
+53
-16
@@ -31,6 +31,8 @@ Log::Log(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
|
||||
{
|
||||
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()) {
|
||||
|
||||
myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
|
||||
@@ -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"; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Log::~Log()
|
||||
@@ -124,6 +126,8 @@ void Log::logPlayerActionMsg(string playerName, int action, int setValue) {
|
||||
|
||||
myW->textBrowser_Log->append(msg);
|
||||
|
||||
if(myConfig->readConfigInt("LogOnOff")) {
|
||||
//if write logfiles is enabled
|
||||
myLogFile->open( QIODevice::ReadWrite );
|
||||
QTextStream stream( myLogFile );
|
||||
for(i=0; i<=linesInFile; i++) { stream.readLine(); }
|
||||
@@ -133,7 +137,7 @@ void Log::logPlayerActionMsg(string playerName, int action, int setValue) {
|
||||
myLogFile->close();
|
||||
|
||||
linesInFile++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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>");
|
||||
|
||||
if(myConfig->readConfigInt("LogOnOff")) {
|
||||
//if write logfiles is enabled
|
||||
|
||||
myLogFile->open( QIODevice::ReadWrite );
|
||||
QTextStream stream( myLogFile );
|
||||
for(i=0; i<=linesInFile; i++) { stream.readLine(); }
|
||||
@@ -223,7 +230,7 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
|
||||
myLogFile->close();
|
||||
|
||||
linesInFile = linesInFile++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Log::logPlayerWinsMsg(int playerID, int pot) {
|
||||
@@ -231,6 +238,10 @@ void Log::logPlayerWinsMsg(int playerID, int pot) {
|
||||
int i;
|
||||
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 );
|
||||
QTextStream stream( myLogFile );
|
||||
for(i=0; i<=linesInFile; i++) { stream.readLine(); }
|
||||
@@ -240,35 +251,50 @@ void Log::logPlayerWinsMsg(int playerID, int pot) {
|
||||
// stream << "</br><i>"+QString::fromUtf8(currentHand->getPlayerArray()[playerID]->getMyName())+" wins "+QString::number(pot,10)+"$!!!</i></p>\n";
|
||||
// }
|
||||
// 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";
|
||||
// }
|
||||
myLogFile->close();
|
||||
|
||||
linesInFile++;
|
||||
}
|
||||
}
|
||||
|
||||
void Log::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4, int card5) {
|
||||
|
||||
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 );
|
||||
QTextStream stream( myLogFile );
|
||||
for(i=0; i<=linesInFile; i++) { stream.readLine(); }
|
||||
|
||||
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)+"]");
|
||||
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;
|
||||
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";
|
||||
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)+"]");
|
||||
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;
|
||||
default: round = "ERROR";
|
||||
@@ -276,17 +302,13 @@ void Log::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int
|
||||
|
||||
myLogFile->close();
|
||||
linesInFile++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Log::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt, string showHas) {
|
||||
|
||||
int i;
|
||||
|
||||
myLogFile->open( QIODevice::ReadWrite );
|
||||
QTextStream stream( myLogFile );
|
||||
for(i=0; i<=linesInFile; i++) { stream.readLine(); }
|
||||
|
||||
if (cardsValueInt != -1) {
|
||||
|
||||
QString tempHandName;
|
||||
@@ -393,17 +415,32 @@ 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+"\"");
|
||||
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 {
|
||||
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();
|
||||
linesInFile++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QStringList Log::translateCardCode(int cardCode) {
|
||||
|
||||
|
||||
@@ -1030,7 +1030,7 @@ p, li { white-space: pre-wrap; }
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QGroupBox" name="groupBox_LogOnOff" >
|
||||
<widget class="QGroupBox" name="groupBox_logOnOff" >
|
||||
<property name="title" >
|
||||
<string>Enable/Disable Logging</string>
|
||||
</property>
|
||||
|
||||
@@ -111,8 +111,10 @@ void settingsDialogImpl::exec() {
|
||||
lineEdit_OwnFlipsideFilename->setText(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str()));
|
||||
|
||||
//Log
|
||||
groupBox_logOnOff->setChecked(myConfig->readConfigInt("LogOnOff"));
|
||||
lineEdit_logDir->setText(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
|
||||
spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration"));
|
||||
comboBox_logInterval->setCurrentIndex(myConfig->readConfigInt("LogInterval"));
|
||||
|
||||
QDialog::exec();
|
||||
|
||||
@@ -242,6 +244,7 @@ void settingsDialogImpl::isAccepted() {
|
||||
}
|
||||
|
||||
// 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()); }
|
||||
else {
|
||||
QMessageBox::warning(this, tr("Settings Error"),
|
||||
@@ -252,6 +255,7 @@ void settingsDialogImpl::isAccepted() {
|
||||
}
|
||||
|
||||
myConfig->writeConfigInt("LogStoreDuration", spinBox_logStoreDuration->value());
|
||||
myConfig->writeConfigInt("LogInterval", comboBox_logInterval->currentIndex());
|
||||
|
||||
//Wenn alles richtig eingegeben wurde --> Dialog schließen
|
||||
if(settingsCorrect) { this->hide(); }
|
||||
|
||||
Reference in New Issue
Block a user