mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 04:16:43 -07:00
[VDE] Deck Analytics Widgets overhaul
Took 2 minutes Took 3 minutes Took 3 minutes
This commit is contained in:
parent
36d8280765
commit
68ad18ad04
81 changed files with 4346 additions and 401 deletions
|
|
@ -32,4 +32,41 @@ inline color makeColor(int r, int g, int b)
|
|||
return result;
|
||||
}
|
||||
|
||||
namespace GameSpecificColors
|
||||
{
|
||||
namespace MTG
|
||||
{
|
||||
inline QColor colorHelper(const QString &name)
|
||||
{
|
||||
static const QMap<QString, QColor> colorMap = {
|
||||
{"W", QColor(245, 245, 220)},
|
||||
{"U", QColor(80, 140, 255)},
|
||||
{"B", QColor(60, 60, 60)},
|
||||
{"R", QColor(220, 60, 50)},
|
||||
{"G", QColor(70, 160, 70)},
|
||||
{"Creature", QColor(70, 130, 180)},
|
||||
{"Instant", QColor(138, 43, 226)},
|
||||
{"Sorcery", QColor(199, 21, 133)},
|
||||
{"Enchantment", QColor(218, 165, 32)},
|
||||
{"Artifact", QColor(169, 169, 169)},
|
||||
{"Planeswalker", QColor(210, 105, 30)},
|
||||
{"Land", QColor(110, 80, 50)},
|
||||
};
|
||||
|
||||
if (colorMap.contains(name))
|
||||
return colorMap[name];
|
||||
|
||||
if (name.length() == 1 && colorMap.contains(name.toUpper()))
|
||||
return colorMap[name.toUpper()];
|
||||
|
||||
uint h = qHash(name);
|
||||
int r = 100 + (h % 120);
|
||||
int g = 100 + ((h >> 8) % 120);
|
||||
int b = 100 + ((h >> 16) % 120);
|
||||
|
||||
return QColor(r, g, b);
|
||||
}
|
||||
} // namespace MTG
|
||||
} // namespace GameSpecificColors
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,6 +15,20 @@ template <typename T> T *findParentOfType(const QObject *obj)
|
|||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void clearLayoutRec(QLayout *l)
|
||||
{
|
||||
if (!l)
|
||||
return;
|
||||
QLayoutItem *it;
|
||||
while ((it = l->takeAt(0)) != nullptr) {
|
||||
if (QWidget *w = it->widget())
|
||||
w->deleteLater();
|
||||
if (QLayout *sub = it->layout())
|
||||
clearLayoutRec(sub);
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
} // namespace QtUtils
|
||||
|
||||
#endif // COCKATRICE_QT_UTILS_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue