From f1241ae726373b0b0456d5e1c4a3b44461c3cd37 Mon Sep 17 00:00:00 2001 From: Christian Daniel Jensen Date: Mon, 2 Nov 2026 05:52:49 -0700 Subject: [PATCH] Provide non-canonical display palette and ordering for Essence analytics --- .../src/interface/essence_chart_colors.h | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 cockatrice/src/interface/essence_chart_colors.h 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