All gui calls through guiwrapper are now thread safe.

This commit is contained in:
lotodore
2007-05-18 23:16:54 +00:00
parent bb8a235b22
commit e7b31f2d44
5 changed files with 172 additions and 96 deletions
+9 -9
View File
@@ -31,6 +31,9 @@ Log::Log(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), m
{
myW->setLog(this);
connect(this, SIGNAL(signalLogPlayerActionMsg(QString, int, int)), this, SLOT(logPlayerActionMsg(QString, int, int)));
connect(this, SIGNAL(signalLogNewGameHandMsg(int, int)), this, SLOT(logNewGameHandMsg(int, int)));
logFileStreamString = "";
lastGameID = 0;
@@ -99,11 +102,8 @@ Log::~Log()
myConfig = 0;
}
void Log::logPlayerActionMsg(string playerName, int action, int setValue) {
void Log::logPlayerActionMsg(QString msg, int action, int setValue) {
QString msg;
msg = QString::fromUtf8(playerName.c_str());
switch (action) {
case 1: msg += " folds.";
@@ -300,7 +300,7 @@ void Log::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int
}
}
void Log::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt, string showHas) {
void Log::logFlipHoleCardsMsg(QString playerName, int card1, int card2, int cardsValueInt, string showHas) {
if (cardsValueInt != -1) {
@@ -407,12 +407,12 @@ void Log::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int
default: {}
}
myW->textBrowser_Log->append(QString::fromUtf8(playerName.c_str())+" "+QString::fromUtf8(showHas.c_str())+" \""+tempHandName+"\"");
myW->textBrowser_Log->append(playerName+" "+QString::fromUtf8(showHas.c_str())+" \""+tempHandName+"\"");
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
logFileStreamString += 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";
logFileStreamString += playerName+" "+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("LogInterval") == 0) {
writeLogFileStream(logFileStreamString);
@@ -422,12 +422,12 @@ void Log::logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int
}
}
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(playerName+" "+QString::fromUtf8(showHas.c_str())+" ["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+"]");
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
logFileStreamString += 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";
logFileStreamString += playerName+" "+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("LogInterval") == 0) {
writeLogFileStream(logFileStreamString);
logFileStreamString = "";
+15 -6
View File
@@ -31,24 +31,32 @@
class mainWindowImpl;
class Log{
class Log : public QObject
{
Q_OBJECT
public:
Log(mainWindowImpl*, ConfigFile *c);
Log(mainWindowImpl*, ConfigFile *c);
~Log();
~Log();
void logPlayerActionMsg(std::string playerName, int action, int setValue);
public slots:
void logPlayerActionMsg(QString playerName, int action, int setValue);
void logNewGameHandMsg(int gameID, int handID);
void logPlayerWinsMsg(int playerID, int pot);
void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1);
void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows");
void logFlipHoleCardsMsg(QString playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows");
public:
QStringList translateCardsValueCode(int cardsValueCode);
QStringList translateCardCode(int cardCode);
void writeLogFileStream(QString string);
signals:
void signalLogPlayerActionMsg(QString playerName, int action, int setValue);
void signalLogNewGameHandMsg(int gameID, int handID);
private:
int lastGameID;
@@ -59,6 +67,7 @@ private:
QFile *myLogFile;
QString logFileStreamString;
friend class GuiWrapper;
};
#endif