From 31302df43e4885c8cf0367b4dd5f8cdd352c6573 Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Sat, 24 Jan 2015 01:18:32 +0100 Subject: [PATCH] WIP --- cockatrice/cockatrice.qrc | 7 +- cockatrice/resources/buddy_icon.svg | 14 +- .../resources/userlevels/admin_buddy.svg | 125 +++++++++++++++ .../resources/userlevels/moderator_buddy.svg | 147 ++++++++++++++++++ .../resources/userlevels/registered_buddy.svg | 115 ++++++++++++++ cockatrice/src/chatview.cpp | 10 +- cockatrice/src/pixmapgenerator.cpp | 7 +- cockatrice/src/pixmapgenerator.h | 2 +- cockatrice/src/playerlistwidget.cpp | 4 +- 9 files changed, 410 insertions(+), 21 deletions(-) create mode 100644 cockatrice/resources/userlevels/admin_buddy.svg create mode 100644 cockatrice/resources/userlevels/moderator_buddy.svg create mode 100644 cockatrice/resources/userlevels/registered_buddy.svg diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 5fb8ed399..1aebae80e 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -54,9 +54,6 @@ resources/genders/male.svg resources/genders/female.svg resources/genders/unknown.svg - - resources/buddy_icon.svg - resources/empty_icon.svg resources/countries/ar.svg resources/countries/at.svg @@ -127,6 +124,10 @@ resources/userlevels/registered.svg resources/userlevels/moderator.svg resources/userlevels/admin.svg + + resources/userlevels/registered_buddy.svg + resources/userlevels/admin_buddy.svg + resources/userlevels/moderator_buddy.svg resources/news/exclamation_mark.svg resources/news/question_mark.svg diff --git a/cockatrice/resources/buddy_icon.svg b/cockatrice/resources/buddy_icon.svg index fa32b8c37..14fcd596c 100644 --- a/cockatrice/resources/buddy_icon.svg +++ b/cockatrice/resources/buddy_icon.svg @@ -34,11 +34,11 @@ + style="stop-color:#0fbb00;stop-opacity:1;" /> + style="stop-color:#064400;stop-opacity:1;" /> @@ -91,15 +91,15 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1920" - inkscape:window-height="1028" + inkscape:window-width="1600" + inkscape:window-height="1178" id="namedview8" showgrid="false" inkscape:zoom="7.375" - inkscape:cx="6.1659936" + inkscape:cx="-14.986549" inkscape:cy="23.31428" - inkscape:window-x="-8" - inkscape:window-y="-8" + inkscape:window-x="1912" + inkscape:window-y="227" inkscape:window-maximized="1" inkscape:current-layer="svg2" /> + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/resources/userlevels/moderator_buddy.svg b/cockatrice/resources/userlevels/moderator_buddy.svg new file mode 100644 index 000000000..677c6e13a --- /dev/null +++ b/cockatrice/resources/userlevels/moderator_buddy.svg @@ -0,0 +1,147 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/resources/userlevels/registered_buddy.svg b/cockatrice/resources/userlevels/registered_buddy.svg new file mode 100644 index 000000000..14fcd596c --- /dev/null +++ b/cockatrice/resources/userlevels/registered_buddy.svg @@ -0,0 +1,115 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/src/chatview.cpp b/cockatrice/src/chatview.cpp index e99df633f..e8bb69069 100644 --- a/cockatrice/src/chatview.cpp +++ b/cockatrice/src/chatview.cpp @@ -132,14 +132,8 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use if (!sameSender) { if (!sender.isEmpty()) { const int pixelSize = QFontInfo(cursor.charFormat().font()).pixelSize(); - cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel).toImage(), QString::number(pixelSize) + "_" + QString::number((int) userLevel)); - if (settingsCache->getShowBuddyIcon()) { - QMap buddyList = tabSupervisor->getUserListsTab()->getBuddyList()->getUsers(); - if (buddyList.contains(sender)) - cursor.insertImage(PixmapGenerator::generatePixmap(pixelSize, ":/resources/buddy_icon.svg").toImage()); - else - cursor.insertImage(PixmapGenerator::generatePixmap(pixelSize, ":/resources/empty_icon.svg").toImage()); - } + QMap buddyList = tabSupervisor->getUserListsTab()->getBuddyList()->getUsers(); + cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel, buddyList.contains(sender)).toImage(), QString::number(pixelSize) + "_" + QString::number((int) userLevel)); cursor.insertText(" "); } cursor.setCharFormat(senderFormat); diff --git a/cockatrice/src/pixmapgenerator.cpp b/cockatrice/src/pixmapgenerator.cpp index 1a50f23a5..45c9c5a6b 100644 --- a/cockatrice/src/pixmapgenerator.cpp +++ b/cockatrice/src/pixmapgenerator.cpp @@ -134,8 +134,9 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr QMap CountryPixmapGenerator::pmCache; -QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel) +QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy) { + int key = height * 10000 + (int) userLevel; if (pmCache.contains(key)) return pmCache.value(key); @@ -149,6 +150,10 @@ QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags user levelString = "registered"; else levelString = "normal"; + + if (isBuddy) + levelString.append("_buddy"); + QSvgRenderer svg(QString(":/resources/userlevels/" + levelString + ".svg")); int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height()); QPixmap pixmap(width, height); diff --git a/cockatrice/src/pixmapgenerator.h b/cockatrice/src/pixmapgenerator.h index a7ead3a26..023675b11 100644 --- a/cockatrice/src/pixmapgenerator.h +++ b/cockatrice/src/pixmapgenerator.h @@ -50,7 +50,7 @@ class UserLevelPixmapGenerator { private: static QMap pmCache; public: - static QPixmap generatePixmap(int height, UserLevelFlags userLevel); + static QPixmap generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy); static void clear() { pmCache.clear(); } }; diff --git a/cockatrice/src/playerlistwidget.cpp b/cockatrice/src/playerlistwidget.cpp index 4edf26edb..46673ce8f 100644 --- a/cockatrice/src/playerlistwidget.cpp +++ b/cockatrice/src/playerlistwidget.cpp @@ -118,7 +118,9 @@ 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())))); + QMap buddyList = tabSupervisor->getUserListsTab()->getBuddyList()->getUsers(); + QString userName = QString(prop.user_info().name().c_str()); + player->setIcon(3, QIcon(UserLevelPixmapGenerator::generatePixmap(12, UserLevelFlags(prop.user_info().user_level()), buddyList.contains(userName)))); player->setText(4, QString::fromStdString(prop.user_info().name())); const QString country = QString::fromStdString(prop.user_info().country()); if (!country.isEmpty())