From fb6edc997f611818ddca19f43aec52cd0df28ccd Mon Sep 17 00:00:00 2001 From: doitux Date: Sat, 29 Oct 2011 19:02:15 +0000 Subject: [PATCH] implement #79 - show cards chances also after fold --- src/gui/qt/gametable/gametableimpl.cpp | 9 ++++++-- src/gui/qt/gametable/mychancelabel.cpp | 30 +++++++++++++++----------- src/gui/qt/gametable/mychancelabel.h | 4 +++- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index acff3aa1..b950005d 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -3527,14 +3527,19 @@ void gameTableImpl::refreshCardsChance(GameState bero) if(myConfig->readConfigInt("ShowCardsChanceMonitor")) { boost::shared_ptr humanPlayer = myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front(); - if(humanPlayer->getMyActiveStatus() && humanPlayer->getMyAction() != PLAYER_ACTION_FOLD) { + if(humanPlayer->getMyActiveStatus()) { int boardCards[5]; int holeCards[2]; humanPlayer->getMyCards(holeCards); myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards); - label_chance->refreshChance(CardsValue::calcCardsChance(bero, holeCards, boardCards)); + if(humanPlayer->getMyAction() == PLAYER_ACTION_FOLD) { + label_chance->refreshChance(CardsValue::calcCardsChance(bero, holeCards, boardCards), true); + } + else { + label_chance->refreshChance(CardsValue::calcCardsChance(bero, holeCards, boardCards), false); + } } else { label_chance->resetChance(); } diff --git a/src/gui/qt/gametable/mychancelabel.cpp b/src/gui/qt/gametable/mychancelabel.cpp index c6959bbc..c19ed361 100644 --- a/src/gui/qt/gametable/mychancelabel.cpp +++ b/src/gui/qt/gametable/mychancelabel.cpp @@ -22,7 +22,7 @@ using namespace std; MyChanceLabel::MyChanceLabel(QWidget* parent) - : QLabel(parent), myW(0), myStyle(0) + : QLabel(parent), myW(0), myStyle(0), myFoldState(false) { RFChance[0] = 0; SFChance[0] = 0; @@ -51,7 +51,7 @@ MyChanceLabel::~MyChanceLabel() { } -void MyChanceLabel::refreshChance(vector< vector > chance) +void MyChanceLabel::refreshChance(vector< vector > chance, bool fold) { RFChance[0] = chance[0][9]; SFChance[0] = chance[0][8]; @@ -75,6 +75,8 @@ void MyChanceLabel::refreshChance(vector< vector > chance) OPChance[1] = chance[1][1]; HCChance[1] = chance[1][0]; + myFoldState = fold; + update(); } @@ -102,70 +104,70 @@ void MyChanceLabel::paintEvent(QPaintEvent * /*event*/) QColor possible("#"+myStyle->getChanceLabelPossibleColor()); QColor impossible("#"+myStyle->getChanceLabelImpossibleColor()); - if(RFChance[1] == 0) { + if(RFChance[1] == 0 || myFoldState) { painter.setPen(impossible); } else { painter.setPen(possible); } painter.drawText(QRectF(QPointF(2,0), QPointF(85,13)),Qt::AlignRight,"Royal Flush"); painter.drawText(QRectF(QPointF(196,0), QPointF(236,13)),Qt::AlignRight,QString("%1%").arg(RFChance[0])); - if(SFChance[1] == 0) { + if(SFChance[1] == 0 || myFoldState) { painter.setPen(impossible); } else { painter.setPen(possible); } painter.drawText(QRectF(QPointF(2,13), QPointF(85,26)),Qt::AlignRight,"Straight Flush"); painter.drawText(QRectF(QPointF(196,13), QPointF(236,26)),Qt::AlignRight,QString("%1%").arg(SFChance[0])); - if(FOAKChance[1] == 0) { + if(FOAKChance[1] == 0 || myFoldState) { painter.setPen(impossible); } else { painter.setPen(possible); } painter.drawText(QRectF(QPointF(2,26), QPointF(85,39)),Qt::AlignRight,"Four of a Kind"); painter.drawText(QRectF(QPointF(196,26), QPointF(236,39)),Qt::AlignRight,QString("%1%").arg(FOAKChance[0])); - if(FHChance[1] == 0) { + if(FHChance[1] == 0 || myFoldState) { painter.setPen(impossible); } else { painter.setPen(possible); } painter.drawText(QRectF(QPointF(2,39), QPointF(85,52)),Qt::AlignRight,"Full House"); painter.drawText(QRectF(QPointF(196,39), QPointF(236,52)),Qt::AlignRight,QString("%1%").arg(FHChance[0])); - if(FLChance[1] == 0) { + if(FLChance[1] == 0 || myFoldState) { painter.setPen(impossible); } else { painter.setPen(possible); } painter.drawText(QRectF(QPointF(2,52), QPointF(85,65)),Qt::AlignRight,"Flush"); painter.drawText(QRectF(QPointF(196,52), QPointF(236,65)),Qt::AlignRight,QString("%1%").arg(FLChance[0])); - if(STRChance[1] == 0) { + if(STRChance[1] == 0 || myFoldState) { painter.setPen(impossible); } else { painter.setPen(possible); } painter.drawText(QRectF(QPointF(2,65), QPointF(85,78)),Qt::AlignRight,"Straight"); painter.drawText(QRectF(QPointF(196,65), QPointF(236,78)),Qt::AlignRight,QString("%1%").arg(STRChance[0])); - if(TOAKChance[1] == 0) { + if(TOAKChance[1] == 0 || myFoldState) { painter.setPen(impossible); } else { painter.setPen(possible); } painter.drawText(QRectF(QPointF(2,78), QPointF(85,91)),Qt::AlignRight,"Three of a Kind"); painter.drawText(QRectF(QPointF(196,78), QPointF(236,91)),Qt::AlignRight,QString("%1%").arg(TOAKChance[0])); - if(TPChance[1] == 0) { + if(TPChance[1] == 0 || myFoldState) { painter.setPen(impossible); } else { painter.setPen(possible); } painter.drawText(QRectF(QPointF(2,91), QPointF(85,104)),Qt::AlignRight,"Two Pairs"); painter.drawText(QRectF(QPointF(196,91), QPointF(236,104)),Qt::AlignRight,QString("%1%").arg(TPChance[0])); - if(OPChance[1] == 0) { + if(OPChance[1] == 0 || myFoldState) { painter.setPen(impossible); } else { painter.setPen(possible); } painter.drawText(QRectF(QPointF(2,104), QPointF(85,117)),Qt::AlignRight,"One Pair"); painter.drawText(QRectF(QPointF(196,104), QPointF(236,117)),Qt::AlignRight,QString("%1%").arg(OPChance[0])); - if(HCChance[1] == 0) { + if(HCChance[1] == 0 || myFoldState) { painter.setPen(impossible); } else { painter.setPen(possible); @@ -182,6 +184,9 @@ void MyChanceLabel::paintEvent(QPaintEvent * /*event*/) linearGrad.setColorAt(1, Qt::red); painter.setBrush(linearGrad); + if(myFoldState) { painter.setOpacity(0.4); } + else { painter.setOpacity(1.0); } + if(RFChance[1] != 0) painter.drawRect(89,3,(108*RFChance[0])/100,7); if(SFChance[1] != 0) painter.drawRect(89,16,(108*SFChance[0])/100,7); if(FOAKChance[1] != 0) painter.drawRect(89,29,(108*FOAKChance[0])/100,7); @@ -219,5 +224,6 @@ void MyChanceLabel::resetChance() OPChance[1] = 0; HCChance[1] = 0; + myFoldState = false; update(); } diff --git a/src/gui/qt/gametable/mychancelabel.h b/src/gui/qt/gametable/mychancelabel.h index 4cd0af63..f200f9ea 100644 --- a/src/gui/qt/gametable/mychancelabel.h +++ b/src/gui/qt/gametable/mychancelabel.h @@ -41,7 +41,7 @@ public: myStyle = theValue; } void paintEvent(QPaintEvent * event); - void refreshChance(std::vector< std::vector >); + void refreshChance(std::vector< std::vector >, bool); void resetChance(); private: @@ -58,6 +58,8 @@ private: int TPChance[2]; int OPChance[2]; int HCChance[2]; + + bool myFoldState; }; #endif