mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 00:24:47 -07:00
make client gender neutral
This commit is contained in:
parent
2e3966afce
commit
c01d526161
12 changed files with 185 additions and 515 deletions
|
|
@ -14,7 +14,7 @@ QPixmap PhasePixmapGenerator::generatePixmap(int height, QString name)
|
|||
QString key = name + QString::number(height);
|
||||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
|
||||
QPixmap pixmap = QPixmap("theme:phases/" + name).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
pmCache.insert(key, pixmap);
|
||||
|
|
@ -30,7 +30,7 @@ QPixmap CounterPixmapGenerator::generatePixmap(int height, QString name, bool hi
|
|||
QString key = name + QString::number(height);
|
||||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
|
||||
QPixmap pixmap = QPixmap("theme:counters/" + name).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
if(pixmap.isNull())
|
||||
{
|
||||
|
|
@ -38,7 +38,7 @@ QPixmap CounterPixmapGenerator::generatePixmap(int height, QString name, bool hi
|
|||
if (highlight)
|
||||
name.append("_highlight");
|
||||
pixmap = QPixmap("theme:counters/" + name).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
|
||||
}
|
||||
|
||||
pmCache.insert(key, pixmap);
|
||||
|
|
@ -50,7 +50,7 @@ QPixmap PingPixmapGenerator::generatePixmap(int size, int value, int max)
|
|||
int key = size * 1000000 + max * 1000 + value;
|
||||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
|
||||
QPixmap pixmap(size, size);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter painter(&pixmap);
|
||||
|
|
@ -59,12 +59,12 @@ QPixmap PingPixmapGenerator::generatePixmap(int size, int value, int max)
|
|||
color = Qt::black;
|
||||
else
|
||||
color.setHsv(120 * (1.0 - ((double) value / max)), 255, 255);
|
||||
|
||||
|
||||
QRadialGradient g(QPointF((double) pixmap.width() / 2, (double) pixmap.height() / 2), qMin(pixmap.width(), pixmap.height()) / 2.0);
|
||||
g.setColorAt(0, color);
|
||||
g.setColorAt(1, Qt::transparent);
|
||||
painter.fillRect(0, 0, pixmap.width(), pixmap.height(), QBrush(g));
|
||||
|
||||
|
||||
pmCache.insert(key, pixmap);
|
||||
|
||||
return pixmap;
|
||||
|
|
@ -72,22 +72,17 @@ QPixmap PingPixmapGenerator::generatePixmap(int size, int value, int max)
|
|||
|
||||
QMap<int, QPixmap> PingPixmapGenerator::pmCache;
|
||||
|
||||
QPixmap GenderPixmapGenerator::generatePixmap(int height, int _gender)
|
||||
QPixmap GenderPixmapGenerator::generatePixmap(int height)
|
||||
{
|
||||
ServerInfo_User::Gender gender = static_cast<ServerInfo_User::Gender>(_gender);
|
||||
if ((gender != ServerInfo_User::Male) && (gender != ServerInfo_User::Female))
|
||||
gender = ServerInfo_User::GenderUnknown;
|
||||
|
||||
ServerInfo_User::Gender gender = ServerInfo_User::GenderUnknown;
|
||||
|
||||
int key = gender * 100000 + height;
|
||||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
|
||||
QString genderStr;
|
||||
switch (gender) {
|
||||
case ServerInfo_User::Male: genderStr = "male"; break;
|
||||
case ServerInfo_User::Female: genderStr = "female"; break;
|
||||
default: genderStr = "unknown";
|
||||
};
|
||||
genderStr = "unknown";
|
||||
|
||||
|
||||
QPixmap pixmap = QPixmap("theme:genders/" + genderStr).scaled(height, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
pmCache.insert(key, pixmap);
|
||||
|
|
@ -103,14 +98,14 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr
|
|||
QString key = countryCode + QString::number(height);
|
||||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
|
||||
int width = height * 2;
|
||||
QPixmap pixmap = QPixmap("theme:countries/" + countryCode.toLower()).scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
QPainter painter(&pixmap);
|
||||
painter.setPen(Qt::black);
|
||||
painter.drawRect(0, 0, pixmap.width() - 1, pixmap.height() - 1);
|
||||
|
||||
|
||||
pmCache.insert(key, pixmap);
|
||||
return pixmap;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue