diff --git a/cockatrice/src/interface/essence_chart_colors.h b/cockatrice/src/interface/essence_chart_colors.h new file mode 100644 index 000000000..455574320 --- /dev/null +++ b/cockatrice/src/interface/essence_chart_colors.h @@ -0,0 +1,49 @@ +#ifndef CONTINUUMATRICE_ESSENCE_CHART_COLORS_H +#define CONTINUUMATRICE_ESSENCE_CHART_COLORS_H + +#include +#include +#include +#include +#include +#include +#include + +// CHART-ONLY presentation palette, NOT canon Essence colors or affiliations. +// Each type must remain distinguishable without inventing lore. N is colorless. +namespace EssenceCharts +{ +inline QColor colorFor(const QString &code) +{ + if (code == QStringLiteral("N")) { + return QColor(145, 149, 156); + } + const int index = Essence::symbols().indexOf(code); + if (index < 0) { + return QColor(145, 149, 156); + } + return QColor::fromHsv((index * 137) % 360, 125, 210); +} + +inline QList> ordered(const QMap &values) +{ + QList> result; + QSet used; + for (const QChar code : Essence::symbols()) { + const QString key(code); + auto it = values.constFind(key); + if (it != values.cend()) { + result.append(qMakePair(it.key(), it.value())); + used.insert(key); + } + } + for (auto it = values.cbegin(); it != values.cend(); ++it) { + if (!used.contains(it.key())) { + result.append(qMakePair(it.key(), it.value())); + } + } + return result; +} +} // namespace EssenceCharts + +#endif // CONTINUUMATRICE_ESSENCE_CHART_COLORS_H