2011-07-02 23:03:18 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* PokerTH - The open source texas holdem engine *
|
|
|
|
|
* Copyright (C) 2006-2011 Felix Hammer, Florian Thauer, Lothar May *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU Affero General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
2011-07-03 19:45:08 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
#include "mychancelabel.h"
|
2008-10-13 20:03:56 +00:00
|
|
|
#include "gametableimpl.h"
|
2009-04-01 12:27:31 +00:00
|
|
|
#include "gametablestylereader.h"
|
2008-10-13 20:03:56 +00:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
MyChanceLabel::MyChanceLabel(QWidget* parent)
|
2011-02-11 20:02:08 +00:00
|
|
|
: QLabel(parent), myW(0), myStyle(0)
|
2009-04-01 12:27:31 +00:00
|
|
|
{
|
2011-02-11 20:02:08 +00:00
|
|
|
RFChance[0] = 0;
|
|
|
|
|
SFChance[0] = 0;
|
|
|
|
|
FOAKChance[0] = 0;
|
|
|
|
|
FHChance[0] = 0;
|
|
|
|
|
FLChance[0] = 0;
|
|
|
|
|
STRChance[0] = 0;
|
|
|
|
|
TOAKChance[0] = 0;
|
|
|
|
|
TPChance[0] = 0;
|
|
|
|
|
OPChance[0] = 0;
|
|
|
|
|
HCChance[0] = 0;
|
2008-10-13 20:03:56 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
RFChance[1] = 0;
|
|
|
|
|
SFChance[1] = 0;
|
|
|
|
|
FOAKChance[1] = 0;
|
|
|
|
|
FHChance[1] = 0;
|
|
|
|
|
FLChance[1] = 0;
|
|
|
|
|
STRChance[1] = 0;
|
|
|
|
|
TOAKChance[1] = 0;
|
|
|
|
|
TPChance[1] = 0;
|
|
|
|
|
OPChance[1] = 0;
|
|
|
|
|
HCChance[1] = 0;
|
2008-10-13 20:03:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyChanceLabel::~MyChanceLabel()
|
|
|
|
|
{
|
|
|
|
|
}
|
2008-10-14 20:19:37 +00:00
|
|
|
|
2008-12-20 16:47:02 +00:00
|
|
|
void MyChanceLabel::refreshChance(vector< vector<int> > chance)
|
2008-10-14 20:19:37 +00:00
|
|
|
{
|
2008-12-20 16:47:02 +00:00
|
|
|
RFChance[0] = chance[0][9];
|
|
|
|
|
SFChance[0] = chance[0][8];
|
|
|
|
|
FOAKChance[0] = chance[0][7];
|
|
|
|
|
FHChance[0] = chance[0][6];
|
|
|
|
|
FLChance[0] = chance[0][5];
|
|
|
|
|
STRChance[0] = chance[0][4];
|
|
|
|
|
TOAKChance[0] = chance[0][3];
|
|
|
|
|
TPChance[0] = chance[0][2];
|
|
|
|
|
OPChance[0] = chance[0][1];
|
2008-10-17 11:53:09 +00:00
|
|
|
HCChance[0] = chance[0][0];
|
|
|
|
|
|
2008-12-20 16:47:02 +00:00
|
|
|
RFChance[1] = chance[1][9];
|
|
|
|
|
SFChance[1] = chance[1][8];
|
|
|
|
|
FOAKChance[1] = chance[1][7];
|
|
|
|
|
FHChance[1] = chance[1][6];
|
|
|
|
|
FLChance[1] = chance[1][5];
|
|
|
|
|
STRChance[1] = chance[1][4];
|
|
|
|
|
TOAKChance[1] = chance[1][3];
|
|
|
|
|
TPChance[1] = chance[1][2];
|
2008-10-17 11:53:09 +00:00
|
|
|
OPChance[1] = chance[1][1];
|
2008-12-20 16:47:02 +00:00
|
|
|
HCChance[1] = chance[1][0];
|
2008-10-14 20:19:37 +00:00
|
|
|
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void MyChanceLabel::paintEvent(QPaintEvent * /*event*/)
|
|
|
|
|
{
|
2008-10-14 20:19:37 +00:00
|
|
|
|
|
|
|
|
QPainter painter(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
QString font1String = "font-family: \"Arial\";";
|
2011-02-11 20:02:08 +00:00
|
|
|
#else
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
QString font1String = "font-family: \"Lucida Grande\";";
|
|
|
|
|
#else
|
|
|
|
|
QString font1String = "font-family: \"Nimbus Sans L\";";
|
|
|
|
|
#endif
|
2008-10-14 20:19:37 +00:00
|
|
|
#endif
|
|
|
|
|
QFont font;
|
|
|
|
|
font.setFamily(font1String);
|
|
|
|
|
font.setPixelSize(10);
|
|
|
|
|
painter.setFont(font);
|
|
|
|
|
|
|
|
|
|
//Draw Texts
|
2009-04-01 12:27:31 +00:00
|
|
|
QColor possible("#"+myStyle->getChanceLabelPossibleColor());
|
|
|
|
|
QColor impossible("#"+myStyle->getChanceLabelImpossibleColor());
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(RFChance[1] == 0) {
|
|
|
|
|
painter.setPen(impossible);
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(possible);
|
|
|
|
|
}
|
2008-12-12 07:34:51 +00:00
|
|
|
painter.drawText(QRectF(QPointF(2,0), QPointF(85,13)),Qt::AlignRight,"Royal Flush");
|
2008-10-17 11:53:09 +00:00
|
|
|
painter.drawText(QRectF(QPointF(196,0), QPointF(236,13)),Qt::AlignRight,QString("%1%").arg(RFChance[0]));
|
2011-02-11 20:02:08 +00:00
|
|
|
if(SFChance[1] == 0) {
|
|
|
|
|
painter.setPen(impossible);
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(possible);
|
|
|
|
|
}
|
2008-12-12 07:34:51 +00:00
|
|
|
painter.drawText(QRectF(QPointF(2,13), QPointF(85,26)),Qt::AlignRight,"Straight Flush");
|
2008-10-17 11:53:09 +00:00
|
|
|
painter.drawText(QRectF(QPointF(196,13), QPointF(236,26)),Qt::AlignRight,QString("%1%").arg(SFChance[0]));
|
2011-02-11 20:02:08 +00:00
|
|
|
if(FOAKChance[1] == 0) {
|
|
|
|
|
painter.setPen(impossible);
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(possible);
|
|
|
|
|
}
|
2008-12-12 07:34:51 +00:00
|
|
|
painter.drawText(QRectF(QPointF(2,26), QPointF(85,39)),Qt::AlignRight,"Four of a Kind");
|
2008-10-17 11:53:09 +00:00
|
|
|
painter.drawText(QRectF(QPointF(196,26), QPointF(236,39)),Qt::AlignRight,QString("%1%").arg(FOAKChance[0]));
|
2011-02-11 20:02:08 +00:00
|
|
|
if(FHChance[1] == 0) {
|
|
|
|
|
painter.setPen(impossible);
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(possible);
|
|
|
|
|
}
|
2008-12-12 07:34:51 +00:00
|
|
|
painter.drawText(QRectF(QPointF(2,39), QPointF(85,52)),Qt::AlignRight,"Full House");
|
2008-10-17 11:53:09 +00:00
|
|
|
painter.drawText(QRectF(QPointF(196,39), QPointF(236,52)),Qt::AlignRight,QString("%1%").arg(FHChance[0]));
|
2011-02-11 20:02:08 +00:00
|
|
|
if(FLChance[1] == 0) {
|
|
|
|
|
painter.setPen(impossible);
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(possible);
|
|
|
|
|
}
|
2008-12-12 07:34:51 +00:00
|
|
|
painter.drawText(QRectF(QPointF(2,52), QPointF(85,65)),Qt::AlignRight,"Flush");
|
2008-10-17 11:53:09 +00:00
|
|
|
painter.drawText(QRectF(QPointF(196,52), QPointF(236,65)),Qt::AlignRight,QString("%1%").arg(FLChance[0]));
|
2011-02-11 20:02:08 +00:00
|
|
|
if(STRChance[1] == 0) {
|
|
|
|
|
painter.setPen(impossible);
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(possible);
|
|
|
|
|
}
|
2008-12-12 07:34:51 +00:00
|
|
|
painter.drawText(QRectF(QPointF(2,65), QPointF(85,78)),Qt::AlignRight,"Straight");
|
2008-10-17 11:53:09 +00:00
|
|
|
painter.drawText(QRectF(QPointF(196,65), QPointF(236,78)),Qt::AlignRight,QString("%1%").arg(STRChance[0]));
|
2011-02-11 20:02:08 +00:00
|
|
|
if(TOAKChance[1] == 0) {
|
|
|
|
|
painter.setPen(impossible);
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(possible);
|
|
|
|
|
}
|
2008-12-12 07:34:51 +00:00
|
|
|
painter.drawText(QRectF(QPointF(2,78), QPointF(85,91)),Qt::AlignRight,"Three of a Kind");
|
2008-10-17 11:53:09 +00:00
|
|
|
painter.drawText(QRectF(QPointF(196,78), QPointF(236,91)),Qt::AlignRight,QString("%1%").arg(TOAKChance[0]));
|
2011-02-11 20:02:08 +00:00
|
|
|
if(TPChance[1] == 0) {
|
|
|
|
|
painter.setPen(impossible);
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(possible);
|
|
|
|
|
}
|
2008-12-12 07:34:51 +00:00
|
|
|
painter.drawText(QRectF(QPointF(2,91), QPointF(85,104)),Qt::AlignRight,"Two Pairs");
|
2008-10-17 11:53:09 +00:00
|
|
|
painter.drawText(QRectF(QPointF(196,91), QPointF(236,104)),Qt::AlignRight,QString("%1%").arg(TPChance[0]));
|
2011-02-11 20:02:08 +00:00
|
|
|
if(OPChance[1] == 0) {
|
|
|
|
|
painter.setPen(impossible);
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(possible);
|
|
|
|
|
}
|
2008-12-12 07:34:51 +00:00
|
|
|
painter.drawText(QRectF(QPointF(2,104), QPointF(85,117)),Qt::AlignRight,"One Pair");
|
2008-10-17 11:53:09 +00:00
|
|
|
painter.drawText(QRectF(QPointF(196,104), QPointF(236,117)),Qt::AlignRight,QString("%1%").arg(OPChance[0]));
|
2011-02-11 20:02:08 +00:00
|
|
|
if(HCChance[1] == 0) {
|
|
|
|
|
painter.setPen(impossible);
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(possible);
|
|
|
|
|
}
|
2008-12-12 07:34:51 +00:00
|
|
|
painter.drawText(QRectF(QPointF(2,117), QPointF(85,130)),Qt::AlignRight,"Highest Card");
|
2008-10-17 11:53:09 +00:00
|
|
|
painter.drawText(QRectF(QPointF(196,117), QPointF(236,130)),Qt::AlignRight,QString("%1%").arg(HCChance[0]));
|
2008-10-14 20:19:37 +00:00
|
|
|
|
|
|
|
|
//Draw gfx
|
|
|
|
|
painter.setPen(QColor(0,0,0));
|
2011-02-11 20:02:08 +00:00
|
|
|
|
2008-12-12 07:34:51 +00:00
|
|
|
QLinearGradient linearGrad(QPointF(89,3), QPointF(190,10));
|
2008-10-14 20:19:37 +00:00
|
|
|
linearGrad.setColorAt(0, Qt::blue);
|
|
|
|
|
linearGrad.setColorAt(0.5, Qt::yellow);
|
|
|
|
|
linearGrad.setColorAt(1, Qt::red);
|
|
|
|
|
painter.setBrush(linearGrad);
|
2011-02-11 20:02:08 +00:00
|
|
|
|
2008-12-12 07:34:51 +00:00
|
|
|
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);
|
|
|
|
|
if(FHChance[1] != 0) painter.drawRect(89,42,(108*FHChance[0])/100,7);
|
|
|
|
|
if(FLChance[1] != 0) painter.drawRect(89,55,(108*FLChance[0])/100,7);
|
|
|
|
|
if(STRChance[1] != 0) painter.drawRect(89,68,(108*STRChance[0])/100,7);
|
|
|
|
|
if(TOAKChance[1] != 0) painter.drawRect(89,81,(108*TOAKChance[0])/100,7);
|
|
|
|
|
if(TPChance[1] != 0) painter.drawRect(89,94,(108*TPChance[0])/100,7);
|
|
|
|
|
if(OPChance[1] != 0) painter.drawRect(89,107,(108*OPChance[0])/100,7);
|
|
|
|
|
if(HCChance[1] != 0) painter.drawRect(89,120,(108*HCChance[0])/100,7);
|
2008-10-14 20:19:37 +00:00
|
|
|
}
|
2008-10-16 09:55:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void MyChanceLabel::resetChance()
|
|
|
|
|
{
|
2008-10-17 11:53:09 +00:00
|
|
|
RFChance[0] = 0;
|
|
|
|
|
SFChance[0] = 0;
|
|
|
|
|
FOAKChance[0] = 0;
|
|
|
|
|
FHChance[0] = 0;
|
|
|
|
|
FLChance[0] = 0;
|
|
|
|
|
STRChance[0] = 0;
|
|
|
|
|
TOAKChance[0] = 0;
|
|
|
|
|
TPChance[0] = 0;
|
|
|
|
|
OPChance[0] = 0;
|
|
|
|
|
HCChance[0] = 0;
|
|
|
|
|
|
|
|
|
|
RFChance[1] = 0;
|
|
|
|
|
SFChance[1] = 0;
|
|
|
|
|
FOAKChance[1] = 0;
|
|
|
|
|
FHChance[1] = 0;
|
|
|
|
|
FLChance[1] = 0;
|
|
|
|
|
STRChance[1] = 0;
|
|
|
|
|
TOAKChance[1] = 0;
|
|
|
|
|
TPChance[1] = 0;
|
|
|
|
|
OPChance[1] = 0;
|
|
|
|
|
HCChance[1] = 0;
|
2008-10-16 09:55:48 +00:00
|
|
|
|
|
|
|
|
update();
|
2010-10-28 08:19:52 +00:00
|
|
|
}
|