diff --git a/cmake/FindQtRuntime.cmake b/cmake/FindQtRuntime.cmake index 6db821dd7..3025934f4 100644 --- a/cmake/FindQtRuntime.cmake +++ b/cmake/FindQtRuntime.cmake @@ -23,6 +23,7 @@ if(WITH_CLIENT) Svg WebSockets Widgets + Xml ) endif() if(WITH_ORACLE) diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index c9bd6d2bb..8f7010a64 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -329,6 +329,13 @@ resources/replay/fastforward.svg resources/replay/pause.svg + resources/usericons/pawn_single.svg + resources/usericons/pawn_double.svg + resources/usericons/pawn_vip_single.svg + resources/usericons/pawn_vip_double.svg + resources/usericons/star_single.svg + resources/usericons/star_double.svg + resources/userlevels/normal.svg resources/userlevels/registered.svg resources/userlevels/registered_buddy.svg diff --git a/cockatrice/resources/config/qtlogging.ini b/cockatrice/resources/config/qtlogging.ini index ddfbec51b..ca68708fd 100644 --- a/cockatrice/resources/config/qtlogging.ini +++ b/cockatrice/resources/config/qtlogging.ini @@ -44,4 +44,6 @@ # cockatrice_xml.xml_4_parser = false # card_list = false +# pixel_map_generator = false + # filter_string = false \ No newline at end of file diff --git a/cockatrice/resources/usericons/pawn_double.svg b/cockatrice/resources/usericons/pawn_double.svg new file mode 100644 index 000000000..b9f72d385 --- /dev/null +++ b/cockatrice/resources/usericons/pawn_double.svg @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/cockatrice/resources/usericons/pawn_single.svg b/cockatrice/resources/usericons/pawn_single.svg new file mode 100644 index 000000000..2f0c94ae8 --- /dev/null +++ b/cockatrice/resources/usericons/pawn_single.svg @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/cockatrice/resources/usericons/pawn_vip_double.svg b/cockatrice/resources/usericons/pawn_vip_double.svg new file mode 100644 index 000000000..0d002a791 --- /dev/null +++ b/cockatrice/resources/usericons/pawn_vip_double.svg @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/cockatrice/resources/usericons/pawn_vip_single.svg b/cockatrice/resources/usericons/pawn_vip_single.svg new file mode 100644 index 000000000..efa02b51e --- /dev/null +++ b/cockatrice/resources/usericons/pawn_vip_single.svg @@ -0,0 +1,363 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/cockatrice/resources/usericons/star_double.svg b/cockatrice/resources/usericons/star_double.svg new file mode 100644 index 000000000..aff2ad0c6 --- /dev/null +++ b/cockatrice/resources/usericons/star_double.svg @@ -0,0 +1,131 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/resources/usericons/star_single.svg b/cockatrice/resources/usericons/star_single.svg new file mode 100644 index 000000000..acc5e4da6 --- /dev/null +++ b/cockatrice/resources/usericons/star_single.svg @@ -0,0 +1,115 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/src/client/tabs/tab_supervisor.cpp b/cockatrice/src/client/tabs/tab_supervisor.cpp index a665d8df2..49090d1fc 100644 --- a/cockatrice/src/client/tabs/tab_supervisor.cpp +++ b/cockatrice/src/client/tabs/tab_supervisor.cpp @@ -809,9 +809,9 @@ void TabSupervisor::processUserJoined(const ServerInfo_User &userInfoJoined) if (auto *tab = getTabAccount()) { if (tab != currentWidget()) { tab->setContentsChanged(true); - QPixmap avatarPixmap = - UserLevelPixmapGenerator::generatePixmap(13, (UserLevelFlags)userInfoJoined.user_level(), true, - QString::fromStdString(userInfoJoined.privlevel())); + QPixmap avatarPixmap = UserLevelPixmapGenerator::generatePixmap( + 13, (UserLevelFlags)userInfoJoined.user_level(), userInfoJoined.pawn_colors(), true, + QString::fromStdString(userInfoJoined.privlevel())); setTabIcon(indexOf(tab), QPixmap(avatarPixmap)); } } diff --git a/cockatrice/src/client/ui/pixel_map_generator.cpp b/cockatrice/src/client/ui/pixel_map_generator.cpp index 09dc2d1ae..501fa3c95 100644 --- a/cockatrice/src/client/ui/pixel_map_generator.cpp +++ b/cockatrice/src/client/ui/pixel_map_generator.cpp @@ -3,9 +3,11 @@ #include "pb/serverinfo_user.pb.h" #include -#include +#include +#include #include #include +#include QMap PhasePixmapGenerator::pmCache; @@ -96,40 +98,177 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr QMap CountryPixmapGenerator::pmCache; -QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy, QString privLevel) +/** + * Updates tags in the svg + * + * @param elem The svg + * @param tagName tag with attribute to update + * @param attrName attribute to be updated + * @param idName id that the tag has to match + * @param attrValue the value to update the attribute to + */ +void setAttrRecur(QDomElement &elem, + const QString &tagName, + const QString &attrName, + const QString &idName, + const QString &attrValue) { + if (elem.tagName().compare(tagName) == 0) { + if (elem.attribute("id").compare(idName) == 0) { + elem.setAttribute(attrName, attrValue); + } + } + for (int i = 0; i < elem.childNodes().count(); i++) { + if (!elem.childNodes().at(i).isElement()) { + continue; + } + auto docElem = elem.childNodes().at(i).toElement(); + setAttrRecur(docElem, tagName, attrName, idName, attrValue); + } +} + +/** + * Returns an icon of the svg that has its color filled in + */ +QIcon changeSVGColor(const QString &iconPath, const QString &colorLeft, const std::optional &colorRight) +{ + QFile file(iconPath); + if (!file.open(QIODevice::ReadOnly)) { + qCWarning(PixelMapGeneratorLog) << "Unable to open" << iconPath; + return {}; + } + + const auto &baData = file.readAll(); + QDomDocument doc; + doc.setContent(baData); + + auto docElem = doc.documentElement(); + + setAttrRecur(docElem, "path", "fill", "left", colorLeft); + if (colorRight.has_value()) { + setAttrRecur(docElem, "path", "fill", "right", colorRight.value()); + } + + QSvgRenderer svgRenderer(doc.toByteArray()); + + QPixmap pix(svgRenderer.defaultSize()); + pix.fill(Qt::transparent); + + QPainter pixPainter(&pix); + svgRenderer.render(&pixPainter); + QIcon myicon(pix); + + return myicon; +} + +QPixmap UserLevelPixmapGenerator::generatePixmap(int height, + UserLevelFlags userLevel, + ServerInfo_User::PawnColorsOverride pawnColorsOverride, + bool isBuddy, + const QString &privLevel) +{ + return generateIcon(height, userLevel, pawnColorsOverride, isBuddy, privLevel).pixmap(height, height); +} + +QIcon UserLevelPixmapGenerator::generateIcon(int height, + UserLevelFlags userLevel, + ServerInfo_User::PawnColorsOverride pawnColorsOverride, + bool isBuddy, + const QString &privLevel) +{ + std::optional colorLeft = std::nullopt; + if (pawnColorsOverride.has_left_side()) { + colorLeft = QString::fromStdString(pawnColorsOverride.left_side()); + } + + std::optional colorRight = std::nullopt; + if (pawnColorsOverride.has_right_side()) { + colorRight = QString::fromStdString(pawnColorsOverride.right_side()); + } + + // Has Color Override + if (colorLeft.has_value()) { + return generateIconWithColorOverride(height, isBuddy, privLevel, colorLeft, colorRight); + } + + // Has No Color Override + return generateIconDefault(height, userLevel, isBuddy, privLevel); +} + +QIcon UserLevelPixmapGenerator::generateIconDefault(int height, + UserLevelFlags userLevel, + bool isBuddy, + const QString &privLevel) +{ QString key = QString::number(height * 10000) + ":" + (short)userLevel + ":" + (short)isBuddy + ":" + privLevel; - if (pmCache.contains(key)) - return pmCache.value(key); + if (iconCache.contains(key)) { + return iconCache.value(key); + } QString levelString; if (userLevel.testFlag(ServerInfo_User::IsAdmin)) { levelString = "admin"; - if (privLevel.toLower() == "vip") + if (privLevel.toLower() == "vip") { levelString.append("_" + privLevel.toLower()); + } } else if (userLevel.testFlag(ServerInfo_User::IsModerator)) { levelString = "moderator"; - if (privLevel.toLower() == "vip") + if (privLevel.toLower() == "vip") { levelString.append("_" + privLevel.toLower()); + } } else if (userLevel.testFlag(ServerInfo_User::IsRegistered)) { levelString = "registered"; - if (privLevel.toLower() != "none") + if (privLevel.toLower() != "none") { levelString.append("_" + privLevel.toLower()); - } else + } + } else { levelString = "normal"; + } - if (isBuddy) + if (isBuddy) { levelString.append("_buddy"); + } - QPixmap pixmap = QPixmap("theme:userlevels/" + levelString) - .scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); - - pmCache.insert(key, pixmap); - return pixmap; + auto pixmap = QPixmap("theme:userlevels/" + levelString) + .scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); + QIcon icon(pixmap); + iconCache.insert(key, icon); + return icon; } -QMap UserLevelPixmapGenerator::pmCache; +QIcon UserLevelPixmapGenerator::generateIconWithColorOverride(int height, + bool isBuddy, + const QString &privLevel, + std::optional colorLeft, + std::optional colorRight) +{ + QString key = QString::number(height * 10000) + ":" + (short)isBuddy + ":" + privLevel.toLower() + ":" + + colorLeft.value_or("") + ":" + colorRight.value_or(""); + + if (iconCache.contains(key)) { + return iconCache.value(key); + } + + QString iconType; + if (isBuddy) { + iconType = "star"; + } else if (privLevel.toLower() == "vip") { + iconType = "pawn_vip"; + } else { + iconType = "pawn"; + } + + QString arity = colorRight.has_value() ? "double" : "single"; + + QString iconPath = QString("theme:usericons/%1_%2.svg").arg(iconType).arg(arity); + + QIcon icon(changeSVGColor(iconPath, colorLeft.value(), colorRight)); + iconCache.insert(key, icon); + return icon; +} + +QMap UserLevelPixmapGenerator::iconCache; QPixmap LockPixmapGenerator::generatePixmap(int height) { diff --git a/cockatrice/src/client/ui/pixel_map_generator.h b/cockatrice/src/client/ui/pixel_map_generator.h index 65f9a96fc..b206ee0ea 100644 --- a/cockatrice/src/client/ui/pixel_map_generator.h +++ b/cockatrice/src/client/ui/pixel_map_generator.h @@ -3,9 +3,13 @@ #include "user_level.h" +#include +#include #include #include +inline Q_LOGGING_CATEGORY(PixelMapGeneratorLog, "pixel_map_generator"); + class PhasePixmapGenerator { private: @@ -61,13 +65,30 @@ public: class UserLevelPixmapGenerator { private: - static QMap pmCache; + static QMap iconCache; + + static QIcon generateIconDefault(int height, UserLevelFlags userLevel, bool isBuddy, const QString &privLevel); + static QIcon generateIconWithColorOverride(int height, + bool isBuddy, + const QString &privLevel, + std::optional colorLeft, + std::optional colorRight); public: - static QPixmap generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy, QString privLevel = "NONE"); + static QPixmap generatePixmap(int height, + UserLevelFlags userLevel, + ServerInfo_User::PawnColorsOverride pawnColors, + bool isBuddy, + const QString &privLevel); + + static QIcon generateIcon(int height, + UserLevelFlags userLevel, + ServerInfo_User::PawnColorsOverride pawnColors, + bool isBuddy, + const QString &privLevel); static void clear() { - pmCache.clear(); + iconCache.clear(); } }; diff --git a/cockatrice/src/game/games_model.cpp b/cockatrice/src/game/games_model.cpp index a0cf15fbc..319aa2c57 100644 --- a/cockatrice/src/game/games_model.cpp +++ b/cockatrice/src/game/games_model.cpp @@ -119,7 +119,8 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const return QString::fromStdString(gameentry.creator_info().name()); case Qt::DecorationRole: { QPixmap avatarPixmap = UserLevelPixmapGenerator::generatePixmap( - 13, (UserLevelFlags)gameentry.creator_info().user_level(), false, + 13, (UserLevelFlags)gameentry.creator_info().user_level(), + gameentry.creator_info().pawn_colors(), false, QString::fromStdString(gameentry.creator_info().privlevel())); return QIcon(avatarPixmap); } diff --git a/cockatrice/src/game/player/player_list_widget.cpp b/cockatrice/src/game/player/player_list_widget.cpp index 930b36d69..c8771968d 100644 --- a/cockatrice/src/game/player/player_list_widget.cpp +++ b/cockatrice/src/game/player/player_list_widget.cpp @@ -140,9 +140,9 @@ void PlayerListWidget::updatePlayerProperties(const ServerInfo_PlayerProperties } 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, - QString::fromStdString(prop.user_info().privlevel())))); + player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap( + 12, UserLevelFlags(prop.user_info().user_level()), prop.user_info().pawn_colors(), 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/game/player/player_target.cpp b/cockatrice/src/game/player/player_target.cpp index a4542225b..ba1c3d52d 100644 --- a/cockatrice/src/game/player/player_target.cpp +++ b/cockatrice/src/game/player/player_target.cpp @@ -103,9 +103,9 @@ void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*o QPixmap tempPixmap; if (fullPixmap.isNull()) - tempPixmap = - UserLevelPixmapGenerator::generatePixmap(translatedSize.height(), UserLevelFlags(info->user_level()), - false, QString::fromStdString(info->privlevel())); + tempPixmap = UserLevelPixmapGenerator::generatePixmap( + translatedSize.height(), UserLevelFlags(info->user_level()), info->pawn_colors(), false, + QString::fromStdString(info->privlevel())); else tempPixmap = fullPixmap.scaled(translatedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); diff --git a/cockatrice/src/server/chat_view/chat_view.cpp b/cockatrice/src/server/chat_view/chat_view.cpp index 29a4a7dfc..33249829d 100644 --- a/cockatrice/src/server/chat_view/chat_view.cpp +++ b/cockatrice/src/server/chat_view/chat_view.cpp @@ -191,8 +191,9 @@ void ChatView::appendMessage(QString message, const int pixelSize = QFontInfo(cursor.charFormat().font()).pixelSize(); bool isBuddy = userListProxy->isUserBuddy(userName); const QString privLevel = userInfo.has_privlevel() ? QString::fromStdString(userInfo.privlevel()) : "NONE"; - cursor.insertImage( - UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel, isBuddy, privLevel).toImage()); + cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel, userInfo.pawn_colors(), + isBuddy, privLevel) + .toImage()); cursor.insertText(" "); cursor.setCharFormat(senderFormat); cursor.insertText(userName); diff --git a/cockatrice/src/server/user/user_info_box.cpp b/cockatrice/src/server/user/user_info_box.cpp index 53c1881ad..53e1d3379 100644 --- a/cockatrice/src/server/user/user_info_box.cpp +++ b/cockatrice/src/server/user/user_info_box.cpp @@ -90,8 +90,8 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user) const std::string &bmp = user.avatar_bmp(); if (!avatarPixmap.loadFromData((const uchar *)bmp.data(), static_cast(bmp.size()))) { - avatarPixmap = - UserLevelPixmapGenerator::generatePixmap(64, userLevel, false, QString::fromStdString(user.privlevel())); + avatarPixmap = UserLevelPixmapGenerator::generatePixmap(64, userLevel, user.pawn_colors(), false, + QString::fromStdString(user.privlevel())); } nameLabel.setText(QString::fromStdString(user.name())); @@ -106,8 +106,8 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user) countryLabel3.setText(""); } - userLevelIcon.setPixmap( - UserLevelPixmapGenerator::generatePixmap(15, userLevel, false, QString::fromStdString(user.privlevel()))); + userLevelIcon.setPixmap(UserLevelPixmapGenerator::generatePixmap(15, userLevel, user.pawn_colors(), false, + QString::fromStdString(user.privlevel()))); QString userLevelText; if (userLevel.testFlag(ServerInfo_User::IsAdmin)) userLevelText = tr("Administrator"); diff --git a/cockatrice/src/server/user/user_list_widget.cpp b/cockatrice/src/server/user/user_list_widget.cpp index 8077f4cab..71b5888a7 100644 --- a/cockatrice/src/server/user/user_list_widget.cpp +++ b/cockatrice/src/server/user/user_list_widget.cpp @@ -344,8 +344,8 @@ 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, - QString::fromStdString(userInfo.privlevel())))); + setIcon(0, UserLevelPixmapGenerator::generateIcon(12, UserLevelFlags(userInfo.user_level()), userInfo.pawn_colors(), + 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/common/pb/serverinfo_user.proto b/common/pb/serverinfo_user.proto index c74ed8ee6..10add611f 100644 --- a/common/pb/serverinfo_user.proto +++ b/common/pb/serverinfo_user.proto @@ -8,6 +8,11 @@ message ServerInfo_User { IsAdmin = 8; IsJudge = 16; }; + message PawnColorsOverride { + optional string left_side = 1; + optional string right_side = 2; + }; + optional string name = 1; optional uint32 user_level = 2; optional string address = 3; @@ -22,4 +27,5 @@ message ServerInfo_User { optional string email = 12; optional string clientid = 13; optional string privlevel = 14; + optional PawnColorsOverride pawn_colors = 15; } diff --git a/servatrice/migrations/servatrice_0033_to_0034.sql b/servatrice/migrations/servatrice_0033_to_0034.sql new file mode 100644 index 000000000..19c33c2dc --- /dev/null +++ b/servatrice/migrations/servatrice_0033_to_0034.sql @@ -0,0 +1,8 @@ +-- Servatrice db migration from version 33 to version 34 + +ALTER TABLE cockatrice_users ADD COLUMN leftPawnColorOverride varchar(255); +ALTER TABLE cockatrice_users ADD COLUMN rightPawnColorOverride varchar(255); + +ALTER TABLE cockatrice_users ADD INDEX `idx_pawnColorOverrides` (`leftPawnColorOverride`, `rightPawnColorOverride`); + +UPDATE cockatrice_schema_version SET version=34 WHERE version=33; diff --git a/servatrice/servatrice.sql b/servatrice/servatrice.sql index f38fa67d0..fa644dbc0 100644 --- a/servatrice/servatrice.sql +++ b/servatrice/servatrice.sql @@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_schema_version` ( PRIMARY KEY (`version`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci; -INSERT INTO cockatrice_schema_version VALUES(33); +INSERT INTO cockatrice_schema_version VALUES(34); -- users and user data tables CREATE TABLE IF NOT EXISTS `cockatrice_users` ( @@ -41,6 +41,8 @@ CREATE TABLE IF NOT EXISTS `cockatrice_users` ( `privlevelStartDate` datetime NOT NULL, `privlevelEndDate` datetime NOT NULL, `passwordLastChangedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `leftPawnColorOverride` varchar(255), + `rightPawnColorOverride` varchar(255), PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), KEY `token` (`token`), @@ -48,7 +50,8 @@ CREATE TABLE IF NOT EXISTS `cockatrice_users` ( INDEX `idx_admin` (`admin`), INDEX `idx_active` (`active`), INDEX `idx_privlevel` (`privlevel`), - INDEX `idx_clientid` (`clientid`) + INDEX `idx_clientid` (`clientid`), + INDEX `idx_pawnColorOverrides` (`leftPawnColorOverride`, `rightPawnColorOverride`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci; CREATE TABLE IF NOT EXISTS `cockatrice_decklist_files` ( diff --git a/servatrice/src/servatrice_database_interface.cpp b/servatrice/src/servatrice_database_interface.cpp index 4ad61c6e4..884495ad2 100644 --- a/servatrice/src/servatrice_database_interface.cpp +++ b/servatrice/src/servatrice_database_interface.cpp @@ -615,27 +615,36 @@ ServerInfo_User Servatrice_DatabaseInterface::evalUserQueryResult(const QSqlQuer if (!privlevel.isEmpty()) result.set_privlevel(privlevel.toStdString()); + const auto &pawn_left_override = query->value(5).toString(); + const auto &pawn_right_override = query->value(6).toString(); + if (!pawn_left_override.isEmpty()) { + result.mutable_pawn_colors()->set_left_side(pawn_left_override.toStdString()); + } + if (!pawn_right_override.isEmpty()) { + result.mutable_pawn_colors()->set_right_side(pawn_right_override.toStdString()); + } + if (complete) { - const QString realName = query->value(5).toString(); + const QString realName = query->value(7).toString(); if (!realName.isEmpty()) result.set_real_name(realName.toStdString()); - const QByteArray avatarBmp = query->value(6).toByteArray(); + const QByteArray avatarBmp = query->value(8).toByteArray(); if (avatarBmp.size()) result.set_avatar_bmp(avatarBmp.data(), avatarBmp.size()); - const QDateTime regDate = query->value(7).toDateTime(); + const QDateTime regDate = query->value(9).toDateTime(); if (!regDate.toString(Qt::ISODate).isEmpty()) { // the registration date is in utc qint64 accountAgeInSeconds = regDate.secsTo(QDateTime::currentDateTimeUtc()); result.set_accountage_secs(accountAgeInSeconds); } - const QString email = query->value(8).toString(); + const QString email = query->value(10).toString(); if (!email.isEmpty()) result.set_email(email.toStdString()); - const QString clientid = query->value(9).toString(); + const QString clientid = query->value(11).toString(); if (!clientid.isEmpty()) result.set_clientid(clientid.toStdString()); } @@ -652,9 +661,10 @@ ServerInfo_User Servatrice_DatabaseInterface::getUserData(const QString &name, b if (!checkSql()) return result; - QSqlQuery *query = - prepareQuery("select id, name, admin, country, privlevel, realname, avatar_bmp, registrationDate, " - "email, clientid from {prefix}_users where name = :name and active = 1"); + QSqlQuery *query = prepareQuery("select id, name, admin, country, privlevel, leftPawnColorOverride, " + "rightPawnColorOverride, realname, avatar_bmp, registrationDate, " + "email, clientid from {prefix}_users where " + "name = :name and active = 1"); query->bindValue(":name", name); if (!execSqlQuery(query)) return result; @@ -751,7 +761,8 @@ QMap Servatrice_DatabaseInterface::getBuddyList(const if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) { checkSql(); - QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel from {prefix}_users a " + QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel, " + "a.leftPawnColorOverride, a.rightPawnColorOverride 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); @@ -773,7 +784,8 @@ QMap Servatrice_DatabaseInterface::getIgnoreList(const if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) { checkSql(); - QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel from {prefix}_users a " + QSqlQuery *query = prepareQuery("select a.id, a.name, a.admin, a.country, a.privlevel, " + "a.leftPawnColorOverride, a.rightPawnColorOverride 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); diff --git a/servatrice/src/servatrice_database_interface.h b/servatrice/src/servatrice_database_interface.h index 22994f298..e3846cdd4 100644 --- a/servatrice/src/servatrice_database_interface.h +++ b/servatrice/src/servatrice_database_interface.h @@ -9,7 +9,7 @@ #include #include -#define DATABASE_SCHEMA_VERSION 33 +#define DATABASE_SCHEMA_VERSION 34 class Servatrice;