optional add country flag to avatar feature (thx to drull)

This commit is contained in:
doitux
2010-10-26 17:31:41 +00:00
parent fbc623a704
commit 74a96a4354
6 changed files with 45 additions and 17 deletions
+9 -6
View File
@@ -817,17 +817,20 @@ void gameTableImpl::refreshPlayerAvatar() {
QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png"));
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
int seatPlace;
PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
for (it_c=currentHand->getSeatsList()->begin(), seatPlace=0; it_c!=currentHand->getSeatsList()->end(); it_c++, seatPlace++) {
QString countryString(QString(myStartWindow->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).countryCode.c_str()).toLower());
countryString = QString(":/cflags/cflags/%1.png").arg(countryString);
if((*it_c)->getMyActiveStatus()) {
QFile myAvatarFile(QString::fromUtf8((*it_c)->getMyAvatar().c_str()));
if((*it_c)->getMyAvatar() == "" || !myAvatarFile.exists()) {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())));
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())),countryString,seatPlace);
}
else {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))));
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))),countryString,seatPlace);
}
}
else {
@@ -835,10 +838,10 @@ void gameTableImpl::refreshPlayerAvatar() {
if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER) {
QFile myAvatarFile(QString::fromUtf8((*it_c)->getMyAvatar().c_str()));
if((*it_c)->getMyAvatar() == "" || !myAvatarFile.exists()) {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())), TRUE);
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())), countryString, seatPlace, TRUE);
}
else {
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))), TRUE);
playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))),countryString,seatPlace, TRUE);
}
}
else {
+23
View File
@@ -112,6 +112,29 @@ void MyAvatarLabel::setPixmap ( const QPixmap &pix, const bool trans) {
}
void MyAvatarLabel::setPixmapAndCountry ( const QPixmap &pix,QString countryString, int seatPlace, const bool trans) {
QPixmap resultAvatar(pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
QPainter painter(&resultAvatar);
int showCountryFlags = myW->getMyConfig()->readConfigInt("ShowCountryFlagInAvatar");
if(showCountryFlags && !countryString.isEmpty())
{
if(seatPlace<=2||seatPlace>=8)
{
painter.drawPixmap(resultAvatar.width()-(QPixmap(countryString)).width(),resultAvatar.height()-(QPixmap(countryString)).height(),QPixmap(countryString));
}
else
{
painter.drawPixmap(resultAvatar.width()-(QPixmap(countryString)).width(),0,QPixmap(countryString));
}
}
painter.end();
myPixmap = resultAvatar;
transparent = trans;
update();
}
void MyAvatarLabel::paintEvent(QPaintEvent*) {
QPainter painter(this);
+1
View File
@@ -38,6 +38,7 @@ public slots:
void setVoteOnKickContextMenuEnabled(bool);
void setVoteRunning ( bool theValue ) { voteRunning = theValue; }
void setPixmap ( const QPixmap &, const bool = FALSE);
void setPixmapAndCountry ( const QPixmap &, QString country, int seatPlace, const bool = FALSE);
void paintEvent(QPaintEvent*);
void putPlayerOnIgnoreList();
bool playerIsOnIgnoreList(QString playerName);