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 "mynamelabel.h"
|
2010-09-13 23:10:10 +00:00
|
|
|
#include "gametableimpl.h"
|
|
|
|
|
#include "session.h"
|
2011-11-15 21:20:34 +00:00
|
|
|
#include "game.h"
|
|
|
|
|
#include "playerinterface.h"
|
2010-09-13 23:10:10 +00:00
|
|
|
#include "gametablestylereader.h"
|
2009-04-22 22:32:45 +00:00
|
|
|
|
|
|
|
|
MyNameLabel::MyNameLabel(QGroupBox* parent)
|
2011-02-11 20:02:08 +00:00
|
|
|
: QLabel(parent), myW(0)
|
2009-04-22 22:32:45 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyNameLabel::~MyNameLabel()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
void MyNameLabel::setText ( const QString &t, bool trans, bool guest, bool computerplayer)
|
|
|
|
|
{
|
2009-04-22 22:32:45 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
QString text;
|
|
|
|
|
QColor transColor;
|
|
|
|
|
transColor.setNamedColor("#"+myW->getMyGameTableStyle()->getPlayerNickTextColor());
|
|
|
|
|
QString red = QString::number(transColor.red());
|
|
|
|
|
QString green = QString::number(transColor.green());
|
|
|
|
|
QString blue = QString::number(transColor.blue());
|
2010-09-13 23:10:10 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(trans) {
|
|
|
|
|
this->setStyleSheet("QLabel { "+ myW->getMyGameTableStyle()->getFont2String() +" font-size: "+myW->getMyGameTableStyle()->getPlayerNameLabelFontSize()+"px; font-weight: bold; color: rgba("+red+", "+green+", "+blue+", 80); }");
|
|
|
|
|
} else {
|
|
|
|
|
this->setStyleSheet("QLabel { "+ myW->getMyGameTableStyle()->getFont2String() +" font-size: "+myW->getMyGameTableStyle()->getPlayerNameLabelFontSize()+"px; font-weight: bold; color: #"+myW->getMyGameTableStyle()->getPlayerNickTextColor()+"; }");
|
|
|
|
|
}
|
2010-09-13 23:10:10 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(myW->getSession()) {
|
2010-09-13 23:10:10 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(myW->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !guest && !computerplayer ) {
|
2010-09-15 07:53:36 +00:00
|
|
|
// for internet game show players name with links to their profile included
|
2011-02-11 20:02:08 +00:00
|
|
|
this->setTextFormat(Qt::RichText);
|
2011-11-15 10:16:29 +00:00
|
|
|
QString linkString;
|
|
|
|
|
|
|
|
|
|
GameInfo info(myW->getSession()->getClientGameInfo(myW->getSession()->getClientCurrentGameId()));
|
|
|
|
|
if(info.data.gameType == GAME_TYPE_RANKING) {
|
2011-11-15 21:20:34 +00:00
|
|
|
|
|
|
|
|
QString nickList;
|
|
|
|
|
//build nick string list
|
|
|
|
|
if(myW->getSession()->getCurrentGame()) {
|
|
|
|
|
|
|
|
|
|
boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame();
|
|
|
|
|
PlayerListConstIterator it_c;
|
|
|
|
|
PlayerList seatsList = currentGame->getSeatsList();
|
|
|
|
|
int playerCounter = 0;
|
|
|
|
|
for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) {
|
|
|
|
|
if((*it_c)->getMyActiveStatus()) {
|
|
|
|
|
++playerCounter;
|
|
|
|
|
nickList += QString("&nick%1=").arg(playerCounter);
|
|
|
|
|
nickList += QUrl::toPercentEncoding(QString::fromUtf8((*it_c)->getMyName().c_str()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-16 15:12:46 +00:00
|
|
|
linkString = QString("http://pokerth.net/redirect_user_profile.php?tableview=1"+nickList+"&table="+QUrl::toPercentEncoding(QString::fromUtf8(info.name.c_str())));
|
2012-01-05 20:54:27 +00:00
|
|
|
} else {
|
2011-11-15 10:16:29 +00:00
|
|
|
linkString = QString("http://pokerth.net/redirect_user_profile.php?nick="+QUrl::toPercentEncoding(t));
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
if(trans) {
|
|
|
|
|
text = "<a style='color: rgba("+red+", "+green+", "+blue+", 80);' href='"+linkString+"'>"+t+"</a>";
|
|
|
|
|
} else {
|
|
|
|
|
text = "<a style='color: #"+myW->getMyGameTableStyle()->getPlayerNickTextColor()+";' href='"+linkString+"'>"+t+"</a>";
|
|
|
|
|
}
|
2010-09-13 23:10:10 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
} else {
|
|
|
|
|
this->setTextFormat(Qt::PlainText);
|
|
|
|
|
text = t;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
text = t;
|
|
|
|
|
}
|
2010-09-13 23:10:10 +00:00
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
QLabel::setText(text);
|
2009-04-22 22:32:45 +00:00
|
|
|
|
|
|
|
|
}
|