From 1d879d303c0b775f8a0f6d4c1250af9d4651a792 Mon Sep 17 00:00:00 2001 From: ZeldaZach Date: Sat, 1 Feb 2025 21:33:44 -0500 Subject: [PATCH] Support more types of icons --- cockatrice/cockatrice.qrc | 4 + .../resources/usericons/pawn_vip_double.svg | 368 ++++++++++++++++++ .../resources/usericons/pawn_vip_single.svg | 363 +++++++++++++++++ .../resources/usericons/star_double.svg | 131 +++++++ .../resources/usericons/star_single.svg | 115 ++++++ .../src/client/ui/pixel_map_generator.cpp | 27 +- .../src/client/ui/pixel_map_generator.h | 11 +- 7 files changed, 1010 insertions(+), 9 deletions(-) create mode 100644 cockatrice/resources/usericons/pawn_vip_double.svg create mode 100644 cockatrice/resources/usericons/pawn_vip_single.svg create mode 100644 cockatrice/resources/usericons/star_double.svg create mode 100644 cockatrice/resources/usericons/star_single.svg diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 430f5dfcd..8f7010a64 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -331,6 +331,10 @@ 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 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/ui/pixel_map_generator.cpp b/cockatrice/src/client/ui/pixel_map_generator.cpp index 4f51b3fd8..a5d64f947 100644 --- a/cockatrice/src/client/ui/pixel_map_generator.cpp +++ b/cockatrice/src/client/ui/pixel_map_generator.cpp @@ -191,7 +191,7 @@ QIcon UserLevelPixmapGenerator::generateIcon(int height, // Has Color Override if (colorLeft.has_value()) { - return generateIconWithColorOverride(height, colorLeft, colorRight); + return generateIconWithColorOverride(height, isBuddy, privLevel, colorLeft, colorRight); } // Has No Color Override @@ -240,21 +240,38 @@ QIcon UserLevelPixmapGenerator::generateIconDefault(int height, } QIcon UserLevelPixmapGenerator::generateIconWithColorOverride(int height, + bool isBuddy, + const QString &privLevel, std::optional colorLeft, std::optional colorRight) { - QString key = QString::number(height * 10000) + ":" + colorLeft.value_or("") + ":" + colorRight.value_or(""); + QString key = QString::number(height * 10000) + ":" + (short)isBuddy + ":" + privLevel.toLower() + ":" + + colorLeft.value_or("") + ":" + colorRight.value_or(""); + if (iconCache.contains(key)) { return iconCache.value(key); } - QIcon icon; + QString iconPath; if (colorRight.has_value()) { - icon = changeSVGColor("theme:usericons/pawn_double.svg", colorLeft.value(), colorRight); + if (isBuddy) { + iconPath = "theme:usericons/star_double.svg"; + } else if (privLevel.toLower() == "vip") { + iconPath = "theme:usericons/pawn_vip_double.svg"; + } else { + iconPath = "theme:usericons/pawn_double.svg"; + } } else { - icon = changeSVGColor("theme:usericons/pawn_single.svg", colorLeft.value(), colorRight); + if (isBuddy) { + iconPath = "theme:usericons/star_single.svg"; + } else if (privLevel.toLower() == "vip") { + iconPath = "theme:usericons/pawn_vip_single.svg"; + } else { + iconPath = "theme:usericons/pawn_single.svg"; + } } + QIcon icon(changeSVGColor(iconPath, colorLeft.value(), colorRight)); iconCache.insert(key, icon); return icon; } diff --git a/cockatrice/src/client/ui/pixel_map_generator.h b/cockatrice/src/client/ui/pixel_map_generator.h index 4a385d372..7cd754d59 100644 --- a/cockatrice/src/client/ui/pixel_map_generator.h +++ b/cockatrice/src/client/ui/pixel_map_generator.h @@ -65,21 +65,24 @@ private: static QMap iconCache; static QIcon generateIconDefault(int height, UserLevelFlags userLevel, bool isBuddy, const QString &privLevel); - static QIcon - generateIconWithColorOverride(int height, std::optional colorLeft, std::optional colorRight); + static QIcon generateIconWithColorOverride(int height, + bool isBuddy, + const QString &privLevel, + std::optional colorLeft, + std::optional colorRight); public: static QPixmap generatePixmap(int height, UserLevelFlags userLevel, ServerInfo_User::PawnColorsOverride pawnColors, bool isBuddy, - const QString &privLevel = "NONE"); + const QString &privLevel); static QIcon generateIcon(int height, UserLevelFlags userLevel, ServerInfo_User::PawnColorsOverride pawnColors, bool isBuddy, - const QString &privLevel = "NONE"); + const QString &privLevel); static void clear() { iconCache.clear();