Present fixed live ticker settings while preserving all stored options (by Codex)
This commit is contained in:
1 parent
e710937ca9
commit
9dd8731c66
6 files changed
+158
-8
No files matched your search
@@ -0,0 +1,65 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "modern/ui/demo_settings.hpp"
|
||||
#include <set>
|
||||
namespace bmh::modern_ui {
|
||||
// A read-only presentation copy. Stored cells and original validation remain
|
||||
// intact.
|
||||
inline const Json &live_settings_catalogue() {
|
||||
static const Json view = [] {
|
||||
auto out = settings_catalogue();
|
||||
Json groups = Json::array();
|
||||
const std::set<std::string> hidden = {"B5", "C5", "D5", "K5", "N7",
|
||||
"P7", "I5", "G6", "F9", "G9",
|
||||
"H9", "K9", "P9"};
|
||||
const auto options = [&](const Json &rows) {
|
||||
Json shown = Json::array();
|
||||
for (auto row : rows) {
|
||||
const auto code = row.value("code", "");
|
||||
if (hidden.contains(code) ||
|
||||
row.value("label", "").find("Sportschau") != std::string::npos)
|
||||
continue;
|
||||
if (code == "L5")
|
||||
row["label"] = "Gelbe Karten im Live-Ticker";
|
||||
if (code == "M5")
|
||||
row["label"] = "Rote Karten im Live-Ticker";
|
||||
if (code == "N5")
|
||||
row["label"] = "Chancen im Live-Ticker";
|
||||
shown.push_back(std::move(row));
|
||||
}
|
||||
return shown;
|
||||
};
|
||||
for (auto group : out.at("groups")) {
|
||||
const auto id = group.value("id", "");
|
||||
if (id == "sportschau" || id == "animations")
|
||||
continue;
|
||||
if (group.contains("options"))
|
||||
group["options"] = options(group.at("options"));
|
||||
else
|
||||
for (auto &competition : group["competitions"])
|
||||
competition["options"] = options(competition.at("options"));
|
||||
groups.push_back(std::move(group));
|
||||
}
|
||||
out["groups"] = std::move(groups);
|
||||
for (auto &row : out["sound"])
|
||||
if (row.value("code", "") == "A5")
|
||||
row["label"] = "Spielton";
|
||||
for (auto &row : out["automation"])
|
||||
if (row[0] == "marking")
|
||||
row[2] = "Die Zuordnung der Gegenspieler automatisch übernehmen.";
|
||||
return out;
|
||||
}();
|
||||
return view;
|
||||
}
|
||||
inline int live_settings_option_count() {
|
||||
int total = 0;
|
||||
for (const auto &group : live_settings_catalogue().at("groups")) {
|
||||
if (group.contains("options"))
|
||||
total += int(group.at("options").size());
|
||||
else
|
||||
for (const auto &competition : group.at("competitions"))
|
||||
total += int(competition.at("options").size());
|
||||
}
|
||||
return total;
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
Reference in new issue
Block a user