From fb7d7b7750324fb76abec59258dd04ad7711906b Mon Sep 17 00:00:00 2001 From: ZeldaZach Date: Sat, 1 Feb 2025 19:00:49 -0500 Subject: [PATCH] Support database changes --- cockatrice/cockatrice.qrc | 3 +++ .../src/client/ui/pixel_map_generator.cpp | 22 ++++--------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index c9bd6d2bb..430f5dfcd 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -329,6 +329,9 @@ resources/replay/fastforward.svg resources/replay/pause.svg + resources/usericons/pawn_single.svg + resources/usericons/pawn_double.svg + resources/userlevels/normal.svg resources/userlevels/registered.svg resources/userlevels/registered_buddy.svg diff --git a/cockatrice/src/client/ui/pixel_map_generator.cpp b/cockatrice/src/client/ui/pixel_map_generator.cpp index 304944290..5f83e03dd 100644 --- a/cockatrice/src/client/ui/pixel_map_generator.cpp +++ b/cockatrice/src/client/ui/pixel_map_generator.cpp @@ -125,6 +125,7 @@ QIcon changeSVGColor(const QString &iconPath, const QString &colorLeft, const st { QFile file(iconPath); if (!file.open(QIODevice::ReadOnly)) { + qWarning() << "Unable to open" << iconPath; return {}; } @@ -139,8 +140,6 @@ QIcon changeSVGColor(const QString &iconPath, const QString &colorLeft, const st SetAttrRecur(docElem, "path", "fill", "right", colorRight.value()); } - qDebug() << "ZACH" << doc.toString(); - QSvgRenderer svgRenderer(doc.toByteArray()); QPixmap pix(svgRenderer.defaultSize()); @@ -168,19 +167,6 @@ QIcon UserLevelPixmapGenerator::generateIcon(int height, bool isBuddy, QString privLevel) { - QString singlePawnPath = - "C:\\Users\\ZaHal\\Documents\\Development\\cockatrice\\cockatrice\\resources\\usericons\\pawn_single.svg"; - QString doublePawnPath = - "C:\\Users\\ZaHal\\Documents\\Development\\cockatrice\\cockatrice\\resources\\usericons\\pawn_double.svg"; - - const auto &r = rand() > (RAND_MAX / 2); - - pawnColorsOverride.set_left_side("#ff0000"); - - if (r == 0) { - pawnColorsOverride.set_right_side("#00ff00"); - } - std::optional colorLeft = std::nullopt; if (pawnColorsOverride.has_left_side()) { colorLeft = QString::fromStdString(pawnColorsOverride.left_side()); @@ -192,7 +178,7 @@ QIcon UserLevelPixmapGenerator::generateIcon(int height, } // Has Color Override - if (colorLeft.has_value() || colorRight.has_value()) { + if (colorLeft.has_value()) { QString key = QString::number(height * 10000) + ":" + colorLeft.value_or("") + ":" + colorRight.value_or(""); if (iconCache.contains(key)) { return iconCache.value(key); @@ -200,9 +186,9 @@ QIcon UserLevelPixmapGenerator::generateIcon(int height, QIcon icon; if (colorRight.has_value()) { - icon = changeSVGColor(doublePawnPath, colorLeft.value(), colorRight); + icon = changeSVGColor("theme:usericons/pawn_double.svg", colorLeft.value(), colorRight); } else { - icon = changeSVGColor(singlePawnPath, colorLeft.value(), std::nullopt); + icon = changeSVGColor("theme:usericons/pawn_single.svg", colorLeft.value(), colorRight); } iconCache.insert(key, icon);