diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 8f7010a64..b59092ce2 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -336,24 +336,6 @@ resources/usericons/star_single.svg resources/usericons/star_double.svg - 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 - resources/tips/images/accounts_tab.png resources/tips/images/arrows.png diff --git a/cockatrice/resources/userlevels/admin.svg b/cockatrice/resources/userlevels/admin.svg deleted file mode 100644 index 5675cc0f8..000000000 --- a/cockatrice/resources/userlevels/admin.svg +++ /dev/null @@ -1,301 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/cockatrice/resources/userlevels/admin_buddy.svg b/cockatrice/resources/userlevels/admin_buddy.svg deleted file mode 100644 index 5ff5c87aa..000000000 --- a/cockatrice/resources/userlevels/admin_buddy.svg +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cockatrice/resources/userlevels/admin_vip.svg b/cockatrice/resources/userlevels/admin_vip.svg deleted file mode 100644 index 7a3ad52f6..000000000 --- a/cockatrice/resources/userlevels/admin_vip.svg +++ /dev/null @@ -1,363 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - diff --git a/cockatrice/resources/userlevels/admin_vip_buddy.svg b/cockatrice/resources/userlevels/admin_vip_buddy.svg deleted file mode 100644 index 5ff5c87aa..000000000 --- a/cockatrice/resources/userlevels/admin_vip_buddy.svg +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cockatrice/resources/userlevels/moderator.svg b/cockatrice/resources/userlevels/moderator.svg deleted file mode 100644 index 37ac156b9..000000000 --- a/cockatrice/resources/userlevels/moderator.svg +++ /dev/null @@ -1,294 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - diff --git a/cockatrice/resources/userlevels/moderator_buddy.svg b/cockatrice/resources/userlevels/moderator_buddy.svg deleted file mode 100644 index 73a3efb04..000000000 --- a/cockatrice/resources/userlevels/moderator_buddy.svg +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cockatrice/resources/userlevels/moderator_vip.svg b/cockatrice/resources/userlevels/moderator_vip.svg deleted file mode 100644 index 6d93983e3..000000000 --- a/cockatrice/resources/userlevels/moderator_vip.svg +++ /dev/null @@ -1,368 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/cockatrice/resources/userlevels/moderator_vip_buddy.svg b/cockatrice/resources/userlevels/moderator_vip_buddy.svg deleted file mode 100644 index 73a3efb04..000000000 --- a/cockatrice/resources/userlevels/moderator_vip_buddy.svg +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cockatrice/resources/userlevels/normal.svg b/cockatrice/resources/userlevels/normal.svg deleted file mode 100644 index 172d8620c..000000000 --- a/cockatrice/resources/userlevels/normal.svg +++ /dev/null @@ -1,300 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/cockatrice/resources/userlevels/registered.svg b/cockatrice/resources/userlevels/registered.svg deleted file mode 100644 index a7f8a72cf..000000000 --- a/cockatrice/resources/userlevels/registered.svg +++ /dev/null @@ -1,333 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/cockatrice/resources/userlevels/registered_buddy.svg b/cockatrice/resources/userlevels/registered_buddy.svg deleted file mode 100644 index 2d2ca600b..000000000 --- a/cockatrice/resources/userlevels/registered_buddy.svg +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cockatrice/resources/userlevels/registered_donator.svg b/cockatrice/resources/userlevels/registered_donator.svg deleted file mode 100644 index 1ec430e68..000000000 --- a/cockatrice/resources/userlevels/registered_donator.svg +++ /dev/null @@ -1,291 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/cockatrice/resources/userlevels/registered_donator_buddy.svg b/cockatrice/resources/userlevels/registered_donator_buddy.svg deleted file mode 100644 index 476d55088..000000000 --- a/cockatrice/resources/userlevels/registered_donator_buddy.svg +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cockatrice/resources/userlevels/registered_vip.svg b/cockatrice/resources/userlevels/registered_vip.svg deleted file mode 100644 index 48982fa2f..000000000 --- a/cockatrice/resources/userlevels/registered_vip.svg +++ /dev/null @@ -1,344 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/cockatrice/resources/userlevels/registered_vip_buddy.svg b/cockatrice/resources/userlevels/registered_vip_buddy.svg deleted file mode 100644 index 27757b934..000000000 --- a/cockatrice/resources/userlevels/registered_vip_buddy.svg +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cockatrice/src/client/ui/pixel_map_generator.cpp b/cockatrice/src/client/ui/pixel_map_generator.cpp index 350bdb5d1..2fc1d0cd3 100644 --- a/cockatrice/src/client/ui/pixel_map_generator.cpp +++ b/cockatrice/src/client/ui/pixel_map_generator.cpp @@ -9,6 +9,13 @@ #include #include +#define DEFAULT_COLOR_UNREGISTERED "#32c8ec"; +#define DEFAULT_COLOR_REGISTERED "#5ed900"; +#define DEFAULT_COLOR_DONATOR "#8c5fd3"; +#define DEFAULT_COLOR_MODERATOR_LEFT "#ffffff"; +#define DEFAULT_COLOR_MODERATOR_RIGHT "#000000"; +#define DEFAULT_COLOR_ADMIN "#ff2701"; + /** * Loads in an svg from file and scales it without affecting image quality. * @@ -204,9 +211,8 @@ static QIcon loadAndColorSvg(const QString &iconPath, QPainter pixPainter(&pix); svgRenderer.render(&pixPainter); - QIcon myicon(pix); - return myicon; + return QIcon(pix); } QPixmap UserLevelPixmapGenerator::generatePixmap(int height, @@ -234,13 +240,20 @@ QIcon UserLevelPixmapGenerator::generateIcon(int minHeight, colorRight = QString::fromStdString(pawnColorsOverride.right_side()); } - // Has Color Override - if (colorLeft.has_value()) { - return generateIconWithColorOverride(minHeight, isBuddy, privLevel, colorLeft, colorRight); + QString key = QString::number(minHeight * 10000) + ":" + static_cast(userLevel) + ":" + + static_cast(isBuddy) + ":" + privLevel.toLower() + ":" + colorLeft.value_or("") + ":" + + colorRight.value_or(""); + + if (iconCache.contains(key)) { + return iconCache.value(key); } - // Has No Color Override - return generateIconDefault(minHeight, userLevel, isBuddy, privLevel); + QIcon icon = colorLeft.has_value() + ? generateIconWithColorOverride(minHeight, isBuddy, privLevel, colorLeft, colorRight) + : generateIconDefault(minHeight, userLevel, isBuddy, privLevel); + + iconCache.insert(key, icon); + return icon; } QIcon UserLevelPixmapGenerator::generateIconDefault(int height, @@ -248,39 +261,36 @@ QIcon UserLevelPixmapGenerator::generateIconDefault(int height, bool isBuddy, const QString &privLevel) { - QString key = QString::number(height * 10000) + ":" + (short)userLevel + ":" + (short)isBuddy + ":" + privLevel; - if (iconCache.contains(key)) { - return iconCache.value(key); - } - - QString levelString; - if (userLevel.testFlag(ServerInfo_User::IsAdmin)) { - levelString = "admin"; - if (privLevel.toLower() == "vip") { - levelString.append("_" + privLevel.toLower()); - } - } else if (userLevel.testFlag(ServerInfo_User::IsModerator)) { - levelString = "moderator"; - if (privLevel.toLower() == "vip") { - levelString.append("_" + privLevel.toLower()); - } - } else if (userLevel.testFlag(ServerInfo_User::IsRegistered)) { - levelString = "registered"; - if (privLevel.toLower() != "none") { - levelString.append("_" + privLevel.toLower()); - } - } else { - levelString = "normal"; - } - + QString iconType; if (isBuddy) { - levelString.append("_buddy"); + iconType = "star"; + } else if (privLevel.toLower() == "vip") { + iconType = "pawn_vip"; + } else { + iconType = "pawn"; } - auto pixmap = loadSvg("theme:userlevels/" + levelString, QSize(height, height)); - QIcon icon(pixmap); - iconCache.insert(key, icon); - return icon; + QString arity = "single"; + QString colorLeft; + std::optional colorRight = std::nullopt; + + if (userLevel.testFlag(ServerInfo_User::IsAdmin)) { + colorLeft = DEFAULT_COLOR_ADMIN; + } else if (userLevel.testFlag(ServerInfo_User::IsModerator)) { + colorLeft = DEFAULT_COLOR_MODERATOR_LEFT; + colorRight = DEFAULT_COLOR_MODERATOR_RIGHT; + arity = "double"; + } else if (privLevel.toLower() == "donator") { + colorLeft = DEFAULT_COLOR_DONATOR; + } else if (userLevel.testFlag(ServerInfo_User::IsRegistered)) { + colorLeft = DEFAULT_COLOR_REGISTERED; + } else { + colorLeft = DEFAULT_COLOR_UNREGISTERED; + } + + QString iconPath = QString("theme:usericons/%1_%2.svg").arg(iconType, arity); + + return loadAndColorSvg(iconPath, colorLeft, colorRight, height); } QIcon UserLevelPixmapGenerator::generateIconWithColorOverride(int height, @@ -289,13 +299,6 @@ QIcon UserLevelPixmapGenerator::generateIconWithColorOverride(int height, 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"; @@ -307,11 +310,9 @@ QIcon UserLevelPixmapGenerator::generateIconWithColorOverride(int height, QString arity = colorRight.has_value() ? "double" : "single"; - QString iconPath = QString("theme:usericons/%1_%2.svg").arg(iconType).arg(arity); + QString iconPath = QString("theme:usericons/%1_%2.svg").arg(iconType, arity); - QIcon icon = loadAndColorSvg(iconPath, colorLeft.value(), colorRight, height); - iconCache.insert(key, icon); - return icon; + return loadAndColorSvg(iconPath, colorLeft.value(), colorRight, height); } QMap UserLevelPixmapGenerator::iconCache;