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
@@ -18,7 +18,7 @@ void App::settings_after_render() {
|
||||
if (auto *label = element("settings-search-count"))
|
||||
label->SetInnerRML(std::to_string(count) + (settings_query_.empty()
|
||||
? " Optionen"
|
||||
: " von 142 Optionen"));
|
||||
: " von "+std::to_string(live_settings_option_count())+" Optionen"));
|
||||
}
|
||||
if (settings_restore_scroll_) {
|
||||
context_->Update();
|
||||
@@ -107,12 +107,12 @@ void App::settings_filter() {
|
||||
if (auto *label = element("settings-search-count"))
|
||||
label->SetInnerRML(std::to_string(count) + (settings_query_.empty()
|
||||
? " Optionen"
|
||||
: " von 142 Optionen"));
|
||||
: " von "+std::to_string(live_settings_option_count())+" Optionen"));
|
||||
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(
|
||||
element("settings-jump"))) {
|
||||
std::string choices;
|
||||
std::string first;
|
||||
for (const auto &g : settings_catalogue().at("groups")) {
|
||||
for (const auto &g : live_settings_catalogue().at("groups")) {
|
||||
const auto id = g.at("id").get<std::string>();
|
||||
const bool shown = element("settings-group-" + id) != nullptr;
|
||||
if (shown && first.empty())
|
||||
|
||||
@@ -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
|
||||
@@ -124,7 +124,7 @@ std::string App::render_settings_groups(int *count) const {
|
||||
terms.push_back(word);
|
||||
int found = 0;
|
||||
std::string out;
|
||||
for (const auto &group : settings_catalogue().at("groups")) {
|
||||
for (const auto &group : live_settings_catalogue().at("groups")) {
|
||||
std::string rows;
|
||||
const auto matches = [&](const Json &o, const std::string &competition) {
|
||||
const auto text = settings_search_key(
|
||||
@@ -193,13 +193,14 @@ std::string App::render_settings() {
|
||||
const std::map<std::string, std::pair<std::string, std::string>> captions = {
|
||||
{"display", {"Anzeige", "Bildschirm und Sprache"}},
|
||||
{"sound", {"Sound", "Lautstärke, Effekte und Spielton"}},
|
||||
{"game", {"Spiel", "Spielablauf und Darstellung nach dem Handbuch"}},
|
||||
{"game", {"Spiel", "Spielablauf und Live-Ticker"}},
|
||||
{"automation",
|
||||
{"Automatik",
|
||||
"Aufstellung, Wechsel, Taktik, Manndeckung und Training"}}};
|
||||
std::string head = "<div><h2>" + captions.at(settings_category_).first +
|
||||
"</h2><p>" + captions.at(settings_category_).second +
|
||||
"</p></div>";
|
||||
if(settings_category_=="display")head+="<span id=\"settings-transmission-style\" style=\"font-size:28dp;color:var(--muted);\">Live-Ticker · feste Darstellungsart</span>";
|
||||
if (settings_category_ == "display") {
|
||||
pane =
|
||||
"<div class=\"settings-group\"><h3>Gestaltung</h3><p "
|
||||
@@ -283,7 +284,7 @@ std::string App::render_settings() {
|
||||
"</div>";
|
||||
if (!settings_global_only()) {
|
||||
pane += "<div class=\"settings-group\"><h3>Ton im Spiel</h3>";
|
||||
for (const auto &o : settings_catalogue().at("sound"))
|
||||
for (const auto &o : live_settings_catalogue().at("sound"))
|
||||
pane += settings_option(o);
|
||||
pane += "</div>";
|
||||
}
|
||||
@@ -302,7 +303,7 @@ std::string App::render_settings() {
|
||||
"abgeben</h3><p class=\"settings-group-help\">Die fünf "
|
||||
"Automatikfunktionen des Originals. Änderungen werden erst mit "
|
||||
"„Anwenden“ übernommen.</p>";
|
||||
for (const auto &o : settings_catalogue().at("automation")) {
|
||||
for (const auto &o : live_settings_catalogue().at("automation")) {
|
||||
const auto key = o[0].get<std::string>();
|
||||
pane += settings_row("automation-" + key, o[1].get<std::string>(),
|
||||
o[2].get<std::string>(),
|
||||
@@ -312,7 +313,7 @@ std::string App::render_settings() {
|
||||
pane += "</div>";
|
||||
} else {
|
||||
std::vector<std::pair<std::string, std::string>> groups;
|
||||
for (const auto &g : settings_catalogue().at("groups"))
|
||||
for (const auto &g : live_settings_catalogue().at("groups"))
|
||||
groups.emplace_back(g.at("id").get<std::string>(),
|
||||
g.at("title").get<std::string>());
|
||||
head += "<div class=\"settings-jump-label\"><span>Zum Abschnitt</span>" +
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "modern/ui/demo_statistics.hpp"
|
||||
#include "modern/ui/demo_news.hpp"
|
||||
#include "modern/ui/demo_settings.hpp"
|
||||
#include "modern/ui/settings_presentation.hpp"
|
||||
#include "modern/ui/ui_preferences.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/demo_widgets.hpp"
|
||||
|
||||
Reference in new issue
Block a user