mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Buddy stars
Buddies will now be seen as stars in the chat
This commit is contained in:
parent
6d4716b38f
commit
d57a6111aa
12 changed files with 409 additions and 12 deletions
|
|
@ -134,12 +134,13 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr
|
|||
|
||||
QMap<QString, QPixmap> CountryPixmapGenerator::pmCache;
|
||||
|
||||
QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel)
|
||||
QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags userLevel, bool isBuddy)
|
||||
{
|
||||
int key = height * 10000 + (int) userLevel;
|
||||
|
||||
int key = height * 10000 + (int) userLevel + (int) isBuddy;
|
||||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
|
||||
QString levelString;
|
||||
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
||||
levelString = "admin";
|
||||
|
|
@ -149,13 +150,17 @@ 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);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter painter(&pixmap);
|
||||
svg.render(&painter, QRectF(0, 0, width, height));
|
||||
|
||||
|
||||
pmCache.insert(key, pixmap);
|
||||
return pixmap;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue