diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 9e0c11c0..5a98240c 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -327,9 +327,20 @@ resources/userlevels/normal.svg resources/userlevels/registered.svg resources/userlevels/registered_buddy.svg + resources/userlevels/registered_vip.svg + resources/userlevels/registered_vip_buddy.svg + resources/userlevels/registered_donator.svg + resources/userlevels/registered_donator_buddy.svg + resources/userlevels/moderator.svg resources/userlevels/moderator_buddy.svg + resources/userlevels/moderator_vip.svg + resources/userlevels/moderator_vip_buddy.svg + resources/userlevels/admin.svg resources/userlevels/admin_buddy.svg + resources/userlevels/admin_vip.svg + resources/userlevels/admin_vip_buddy.svg + diff --git a/cockatrice/resources/userlevels/admin_vip.svg b/cockatrice/resources/userlevels/admin_vip.svg new file mode 100644 index 00000000..7a3ad52f --- /dev/null +++ b/cockatrice/resources/userlevels/admin_vip.svg @@ -0,0 +1,363 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/cockatrice/resources/userlevels/admin_vip_buddy.svg b/cockatrice/resources/userlevels/admin_vip_buddy.svg new file mode 100644 index 00000000..5ff5c87a --- /dev/null +++ b/cockatrice/resources/userlevels/admin_vip_buddy.svg @@ -0,0 +1,136 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/resources/userlevels/moderator_vip.svg b/cockatrice/resources/userlevels/moderator_vip.svg new file mode 100644 index 00000000..6d93983e --- /dev/null +++ b/cockatrice/resources/userlevels/moderator_vip.svg @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/cockatrice/resources/userlevels/moderator_vip_buddy.svg b/cockatrice/resources/userlevels/moderator_vip_buddy.svg new file mode 100644 index 00000000..73a3efb0 --- /dev/null +++ b/cockatrice/resources/userlevels/moderator_vip_buddy.svg @@ -0,0 +1,131 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/resources/userlevels/registered_donator.svg b/cockatrice/resources/userlevels/registered_donator.svg new file mode 100644 index 00000000..1ec430e6 --- /dev/null +++ b/cockatrice/resources/userlevels/registered_donator.svg @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/cockatrice/resources/userlevels/registered_donator_buddy.svg b/cockatrice/resources/userlevels/registered_donator_buddy.svg new file mode 100644 index 00000000..476d5508 --- /dev/null +++ b/cockatrice/resources/userlevels/registered_donator_buddy.svg @@ -0,0 +1,137 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/resources/userlevels/registered_vip.svg b/cockatrice/resources/userlevels/registered_vip.svg new file mode 100644 index 00000000..be9a84c3 --- /dev/null +++ b/cockatrice/resources/userlevels/registered_vip.svg @@ -0,0 +1,373 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/cockatrice/resources/userlevels/registered_vip_buddy.svg b/cockatrice/resources/userlevels/registered_vip_buddy.svg new file mode 100644 index 00000000..2d2ca600 --- /dev/null +++ b/cockatrice/resources/userlevels/registered_vip_buddy.svg @@ -0,0 +1,115 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/src/chatview.cpp b/cockatrice/src/chatview.cpp index 218bde24..71bc651c 100644 --- a/cockatrice/src/chatview.cpp +++ b/cockatrice/src/chatview.cpp @@ -159,8 +159,9 @@ void ChatView::appendMessage(QString message, RoomMessageTypeFlags messageType, if (!sender.isEmpty() && tabSupervisor->getUserListsTab()) { const int pixelSize = QFontInfo(cursor.charFormat().font()).pixelSize(); QMap buddyList = tabSupervisor->getUserListsTab()->getBuddyList()->getUsers(); - cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel, - buddyList.contains(sender)).toImage()); + QMap userList = tabSupervisor->getUserListsTab()->getAllUsersList()->getUsers(); + UserListTWI *vlu = userList.value(sender); + cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel, buddyList.contains(sender), QString::fromStdString(vlu->getUserInfo().privlevel())).toImage()); cursor.insertText(" "); } cursor.setCharFormat(senderFormat); diff --git a/cockatrice/src/gamesmodel.cpp b/cockatrice/src/gamesmodel.cpp index 93ed99b5..c486ea6b 100644 --- a/cockatrice/src/gamesmodel.cpp +++ b/cockatrice/src/gamesmodel.cpp @@ -78,7 +78,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const case Qt::DisplayRole: return QString::fromStdString(g.creator_info().name()); case Qt::DecorationRole: { - QPixmap avatarPixmap = UserLevelPixmapGenerator::generatePixmap(13, (UserLevelFlags)g.creator_info().user_level(), false); + QPixmap avatarPixmap = UserLevelPixmapGenerator::generatePixmap(13, (UserLevelFlags)g.creator_info().user_level(), false, QString::fromStdString(g.creator_info().privlevel())); return QIcon(avatarPixmap); } default: diff --git a/cockatrice/src/pixmapgenerator.cpp b/cockatrice/src/pixmapgenerator.cpp index 687c63a7..720530fa 100644 --- a/cockatrice/src/pixmapgenerator.cpp +++ b/cockatrice/src/pixmapgenerator.cpp @@ -112,32 +112,38 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr QMap CountryPixmapGenerator::pmCache; -QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy) +QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy, QString privLevel) { - - int key = height * 10000 + (int) userLevel + (int) isBuddy; + + QString key = QString::number(height * 10000) + ":" + (int)userLevel + ":" + (int)isBuddy + ":" + privLevel; if (pmCache.contains(key)) return pmCache.value(key); QString levelString; - if (userLevel.testFlag(ServerInfo_User::IsAdmin)) + if (userLevel.testFlag(ServerInfo_User::IsAdmin)) { levelString = "admin"; - else if (userLevel.testFlag(ServerInfo_User::IsModerator)) + if (privLevel.toLower() == "vip") + levelString.append("_" + privLevel.toLower()); + } else if (userLevel.testFlag(ServerInfo_User::IsModerator)) { levelString = "moderator"; - else if (userLevel.testFlag(ServerInfo_User::IsRegistered)) + if (privLevel.toLower() == "vip") + levelString.append("_" + privLevel.toLower()); + } else if (userLevel.testFlag(ServerInfo_User::IsRegistered)) { levelString = "registered"; - else + if (privLevel.toLower() != "none") + levelString.append("_" + privLevel.toLower()); + } else levelString = "normal"; if (isBuddy) levelString.append("_buddy"); - + QPixmap pixmap = QPixmap("theme:userlevels/" + levelString).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); pmCache.insert(key, pixmap); return pixmap; } -QMap UserLevelPixmapGenerator::pmCache; +QMap UserLevelPixmapGenerator::pmCache; QPixmap LockPixmapGenerator::generatePixmap(int height) diff --git a/cockatrice/src/pixmapgenerator.h b/cockatrice/src/pixmapgenerator.h index 6b8f1eb2..131d1487 100644 --- a/cockatrice/src/pixmapgenerator.h +++ b/cockatrice/src/pixmapgenerator.h @@ -48,9 +48,9 @@ public: class UserLevelPixmapGenerator { private: - static QMap pmCache; + static QMap pmCache; public: - static QPixmap generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy); + static QPixmap generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy, QString privLevel = "NONE"); static void clear() { pmCache.clear(); } }; diff --git a/cockatrice/src/playerlistwidget.cpp b/cockatrice/src/playerlistwidget.cpp index 49b3b92c..64958af3 100644 --- a/cockatrice/src/playerlistwidget.cpp +++ b/cockatrice/src/playerlistwidget.cpp @@ -117,7 +117,7 @@ void PlayerListWidget::updatePlayerProperties(const ServerInfo_PlayerProperties player->setIcon(2, gameStarted ? (prop.conceded() ? concededIcon : QIcon()) : (prop.ready_start() ? readyIcon : notReadyIcon)); if (prop.has_user_info()) { player->setData(3, Qt::UserRole, prop.user_info().user_level()); - player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(prop.user_info().user_level()), false))); + player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(prop.user_info().user_level()), false, QString::fromStdString(prop.user_info().privlevel())))); player->setText(4, QString::fromStdString(prop.user_info().name())); const QString country = QString::fromStdString(prop.user_info().country()); if (!country.isEmpty()) diff --git a/cockatrice/src/playertarget.cpp b/cockatrice/src/playertarget.cpp index 22da4087..487bb68a 100644 --- a/cockatrice/src/playertarget.cpp +++ b/cockatrice/src/playertarget.cpp @@ -93,7 +93,7 @@ void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*o QPixmap tempPixmap; if (fullPixmap.isNull()) - tempPixmap = UserLevelPixmapGenerator::generatePixmap(translatedSize.height(), UserLevelFlags(info->user_level()), false); + tempPixmap = UserLevelPixmapGenerator::generatePixmap(translatedSize.height(), UserLevelFlags(info->user_level()), false, QString::fromStdString(info->privlevel())); else tempPixmap = fullPixmap.scaled(translatedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); diff --git a/cockatrice/src/userinfobox.cpp b/cockatrice/src/userinfobox.cpp index 4b12a7a9..255442a7 100644 --- a/cockatrice/src/userinfobox.cpp +++ b/cockatrice/src/userinfobox.cpp @@ -82,7 +82,7 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user) QPixmap avatarPixmap; const std::string bmp = user.avatar_bmp(); if (!avatarPixmap.loadFromData((const uchar *) bmp.data(), bmp.size())) - avatarPixmap = UserLevelPixmapGenerator::generatePixmap(64, userLevel, false); + avatarPixmap = UserLevelPixmapGenerator::generatePixmap(64, userLevel, false, QString::fromStdString(user.privlevel())); avatarLabel.setPixmap(avatarPixmap.scaled(avatarLabel.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); nameLabel.setText(QString::fromStdString(user.name())); @@ -100,7 +100,7 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user) countryLabel3.setText(""); } - userLevelLabel2.setPixmap(UserLevelPixmapGenerator::generatePixmap(15, userLevel, false)); + userLevelLabel2.setPixmap(UserLevelPixmapGenerator::generatePixmap(15, userLevel, false, QString::fromStdString(user.privlevel()))); QString userLevelText; if (userLevel.testFlag(ServerInfo_User::IsAdmin)) userLevelText = tr("Administrator"); diff --git a/cockatrice/src/userlist.cpp b/cockatrice/src/userlist.cpp index e7821ca7..57958a94 100644 --- a/cockatrice/src/userlist.cpp +++ b/cockatrice/src/userlist.cpp @@ -276,7 +276,7 @@ void UserListTWI::setUserInfo(const ServerInfo_User &_userInfo) userInfo = _userInfo; setData(0, Qt::UserRole, userInfo.user_level()); - setIcon(0, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(userInfo.user_level()), false))); + setIcon(0, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(userInfo.user_level()), false, QString::fromStdString(userInfo.privlevel())))); setIcon(1, QIcon(CountryPixmapGenerator::generatePixmap(12, QString::fromStdString(userInfo.country())))); setData(2, Qt::UserRole, QString::fromStdString(userInfo.name())); setData(2, Qt::DisplayRole, QString::fromStdString(userInfo.name())); diff --git a/servatrice/src/servatrice_database_interface.cpp b/servatrice/src/servatrice_database_interface.cpp index d2ac2c5f..8065e9a7 100644 --- a/servatrice/src/servatrice_database_interface.cpp +++ b/servatrice/src/servatrice_database_interface.cpp @@ -505,38 +505,38 @@ ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult(const QSqlQuer if (!country.isEmpty()) result.set_country(country.toStdString()); + const QString privlevel = query->value(4).toString(); + if (!privlevel.isEmpty()) + result.set_privlevel(privlevel.toStdString()); + if (complete) { - const QString genderStr = query->value(4).toString(); + const QString genderStr = query->value(5).toString(); if (genderStr == "m") result.set_gender(ServerInfo_User::Male); else if (genderStr == "f") result.set_gender(ServerInfo_User::Female); - const QString realName = query->value(5).toString(); + const QString realName = query->value(6).toString(); if (!realName.isEmpty()) result.set_real_name(realName.toStdString()); - const QByteArray avatarBmp = query->value(6).toByteArray(); + const QByteArray avatarBmp = query->value(7).toByteArray(); if (avatarBmp.size()) result.set_avatar_bmp(avatarBmp.data(), avatarBmp.size()); - const QDateTime regDate = query->value(7).toDateTime(); - if(!regDate.toString(Qt::ISODate).isEmpty()) { + const QDateTime regDate = query->value(8).toDateTime(); + if (!regDate.toString(Qt::ISODate).isEmpty()) { qint64 accountAgeInSeconds = regDate.secsTo(QDateTime::currentDateTime()); result.set_accountage_secs(accountAgeInSeconds); } - const QString email = query->value(8).toString(); + const QString email = query->value(9).toString(); if (!email.isEmpty()) result.set_email(email.toStdString()); - const QString clientid = query->value(9).toString(); + const QString clientid = query->value(10).toString(); if (!clientid.isEmpty()) result.set_clientid(clientid.toStdString()); - - const QString privlevel = query->value(10).toString(); - if (!privlevel.isEmpty()) - result.set_privlevel(privlevel.toStdString()); } return result; } @@ -551,7 +551,7 @@ ServerInfo_User Servatrice_DatabaseInterface::getUserData(const QString &name, b if (!checkSql()) return result; - QSqlQuery *query = prepareQuery("select id, name, admin, country, gender, realname, avatar_bmp, registrationDate, email, clientid, privlevel from {prefix}_users where name = :name and active = 1"); + QSqlQuery *query = prepareQuery("select id, name, admin, country, privlevel, gender, realname, avatar_bmp, registrationDate, email, clientid from {prefix}_users where name = :name and active = 1"); query->bindValue(":name", name); if (!execSqlQuery(query)) return result; @@ -560,7 +560,8 @@ ServerInfo_User Servatrice_DatabaseInterface::getUserData(const QString &name, b return evalUserQueryResult(query, true, withId); else return result; - } else + } + else return result; } @@ -641,7 +642,7 @@ QMap Servatrice_DatabaseInterface::getBuddyList(const if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) { checkSql(); - QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country from {prefix}_users a left join {prefix}_buddylist b on a.id = b.id_user2 left join {prefix}_users c on b.id_user1 = c.id where c.name = :name"); + QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel from {prefix}_users a left join {prefix}_buddylist b on a.id = b.id_user2 left join {prefix}_users c on b.id_user1 = c.id where c.name = :name"); query->bindValue(":name", name); if (!execSqlQuery(query)) return result; @@ -661,7 +662,7 @@ QMap Servatrice_DatabaseInterface::getIgnoreList(const if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) { checkSql(); - QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country from {prefix}_users a left join {prefix}_ignorelist b on a.id = b.id_user2 left join {prefix}_users c on b.id_user1 = c.id where c.name = :name"); + QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel from {prefix}_users a left join {prefix}_ignorelist b on a.id = b.id_user2 left join {prefix}_users c on b.id_user1 = c.id where c.name = :name"); query->bindValue(":name", name); if (!execSqlQuery(query)) return result;