The game page of a Dreierpack career offers five options (winter postponements and their cap, indoor tournaments, the two transfer-news switches). The cells of the original's presentation, the multi-player and autosave cells and the switches that take leagues out of a running game are no longer shown, and settings.commit refuses them. The sound page and the marking automation are hidden in a career. A mailbox text cut inside a multi-byte character no longer breaks the news read. modern_live_dump can commit options and reports their effect. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
109 lines
4.5 KiB
C++
109 lines
4.5 KiB
C++
// 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;
|
|
}
|
|
// The game options of a Dreierpack career: only switches that change how the season is
|
|
// played or what the manager is told. The stored cells of the original's presentation
|
|
// (broadcast panels, animation timings, result boards per competition) have no effect in
|
|
// this interface and are not offered; neither is switching leagues off in a running game.
|
|
inline const Json &career_settings_catalogue() {
|
|
static const Json view = [] {
|
|
const auto &all = settings_catalogue();
|
|
const auto find = [&](const std::string &code) -> Json {
|
|
for (const auto &group : all.at("groups"))
|
|
if (group.contains("options"))
|
|
for (const auto &row : group.at("options"))
|
|
if (row.value("code", "") == code) return row;
|
|
throw editor::Error("Unbekannte Spieloption.");
|
|
};
|
|
const auto option = [&](const char *code, const char *label, const char *help) {
|
|
Json row = find(code);
|
|
row["label"] = label; row["help"] = help;
|
|
return row;
|
|
};
|
|
Json out = Json::object();
|
|
out["groups"] = Json::array(
|
|
{{{"id", "rules"}, {"title", "Spielablauf"},
|
|
{"options", Json::array({option("P5", "Spielausfälle im Winter", "Bei schlechtem Wetter fallen Spiele aus und werden nachgeholt."),
|
|
option("J8", "Höchstens ausgefallene Spiele je Liga und Spieltag", "0 bis 9."),
|
|
option("Q5", "Hallenturniere in der Winterpause", "Kann während der Hallensaison nicht umgestellt werden.")})}},
|
|
{{"id", "transfers"}, {"title", "Nachrichten"},
|
|
{"options", Json::array({option("H6", "Alle Transfers melden", "Jeder Vereinswechsel erscheint in den Nachrichten."),
|
|
option("I6", "Nur Transfers der Tabellennachbarn melden", "")})}}});
|
|
out["sound"] = Json::array();
|
|
Json automation = Json::array();
|
|
for (const auto &row : all.at("automation"))
|
|
if (row[0] != "marking") automation.push_back(row);
|
|
out["automation"] = std::move(automation);
|
|
return out;
|
|
}();
|
|
return view;
|
|
}
|
|
inline int career_settings_option_count() {
|
|
int total = 0;
|
|
for (const auto &group : career_settings_catalogue().at("groups")) total += int(group.at("options").size());
|
|
return total;
|
|
}
|
|
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
|