The settings as a page of the notebook, after the design
The categories as tabs at the top, the skins as cards with a sketch, the options as rows with the page's switches, and status with the two buttons in the foot. From the main menu the older sheet stays. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
724f717421
commit
66905ef04f
3 files changed
+84
-6
No files matched your search
@@ -5,7 +5,7 @@
|
||||
// The menus that are laid out as a page of the notebook. Every other career menu is still a
|
||||
// sheet of the old format, shown scaled inside the book.
|
||||
bool App::page_native() const {
|
||||
static const std::set<std::string> native{"save", "load", "stadium", "statistics", "news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"};
|
||||
static const std::set<std::string> native{"settings", "save", "load", "stadium", "statistics", "news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"};
|
||||
if (menu_ == "calendar" || menu_ == "postpone" || menu_ == "lineup") return notebook_page() && engine_mode_;
|
||||
// a national coach arranges friendlies on the older sheet
|
||||
if (menu_ == "friendlies") return notebook_page() && engine_mode_ && engine_data_.contains("desktop") && engine_data_.at("desktop").at("meta").at("scope").at("role") == "club";
|
||||
|
||||
@@ -185,8 +185,21 @@ std::string App::render_settings_groups(int *count) const {
|
||||
"Suchbegriff.</small></p>";
|
||||
return out;
|
||||
}
|
||||
namespace {
|
||||
// A sketch of a skin for its card: paper, ink, a panel and the accent.
|
||||
std::string settings_theme_svg(const std::string &theme) {
|
||||
const std::array<const char *, 4> c = theme == "midnight" ? std::array<const char *, 4>{"#23262d", "#f0ece2", "#e0a25f", "#30343d"}
|
||||
: theme == "matchday" ? std::array<const char *, 4>{"#e4eed6", "#1d2a16", "#3f7a3a", "#cfe0b8"}
|
||||
: std::array<const char *, 4>{"#f5ead8", "#201e1d", "#c67139", "#ebddc5"};
|
||||
return std::string("<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 110\"><rect width=\"200\" height=\"110\" rx=\"12\" fill=\"") + c[0] + "\"/><rect x=\"14\" y=\"14\" width=\"80\" height=\"9\" rx=\"4\" fill=\"" + c[1] +
|
||||
"\"/><rect x=\"14\" y=\"32\" width=\"110\" height=\"5\" rx=\"2\" fill=\"" + c[1] + "\" opacity=\".5\"/><rect x=\"14\" y=\"44\" width=\"76\" height=\"52\" rx=\"8\" fill=\"" + c[3] + "\"/><rect x=\"100\" y=\"44\" width=\"86\" height=\"24\" rx=\"8\" fill=\"" + c[3] +
|
||||
"\"/><rect x=\"100\" y=\"76\" width=\"50\" height=\"20\" rx=\"10\" fill=\"" + c[2] + "\"/></svg>";
|
||||
}
|
||||
} // namespace
|
||||
std::string App::render_settings() {
|
||||
begin_settings();
|
||||
// in a career the settings are a page of the notebook; from the main menu the older sheet
|
||||
const bool page = page_native();
|
||||
settings_remember_scroll();
|
||||
const auto &p = settings_draft_.at("global");
|
||||
std::string nav, pane;
|
||||
@@ -200,13 +213,13 @@ std::string App::render_settings() {
|
||||
std::string(id) == "sound") &&
|
||||
!(engine_mode_ && std::string(id) == "sound")) // a career has no sound options yet
|
||||
nav += btn("settings-category", "<span>" + std::string(label) + "</span>",
|
||||
settings_category_ == id ? "active" : "",
|
||||
settings_category_ == id ? "active on" : "",
|
||||
"id=\"settings-tab-" + std::string(id) +
|
||||
"\" role=\"tab\" aria-selected=\"" +
|
||||
(settings_category_ == id ? "true" : "false") +
|
||||
"\" data-id=\"" + id + "\"");
|
||||
const std::map<std::string, std::pair<std::string, std::string>> captions = {
|
||||
{"display", {"Anzeige", "Bildschirm und Sprache"}},
|
||||
{"display", {"Anzeige", page && engine_mode_ ? "Gestaltung, Bewegung und Fenster" : "Bildschirm und Sprache"}},
|
||||
{"sound", {"Sound", "Lautstärke, Effekte und Spielton"}},
|
||||
{"game", {"Spiel", engine_mode_ ? "Spielablauf und Nachrichten" : "Spielablauf und Live-Ticker"}},
|
||||
{"automation",
|
||||
@@ -226,6 +239,12 @@ std::string App::render_settings() {
|
||||
{{"matchday", "Spieltag", "Graphit, rote Akzente"}}}};
|
||||
for (const auto &t : themes) {
|
||||
const std::string type = t[0];
|
||||
if (page) {
|
||||
const bool chosen = p.at("theme") == type;
|
||||
pane += btn("settings-theme", "<span class=\"set-theme-art\">" + picture(renderer_.diagram("settings-theme-" + type, settings_theme_svg(type), 640), 590, 324.5) + "</span><strong class=\"pg-h\" style=\"font-size:" + pg(16) + ";\">" + t[1] + "</strong>",
|
||||
std::string("pg-card set-theme") + (chosen ? " sel" : ""), "id=\"settings-theme-" + type + "\" data-id=\"" + type + "\" aria-pressed=\"" + (chosen ? "true" : "false") + "\"");
|
||||
continue;
|
||||
}
|
||||
const auto mini =
|
||||
"<div class=\"settings-theme-preview preview-" + type +
|
||||
"\"><div class=\"preview-background\">" +
|
||||
@@ -248,14 +267,16 @@ std::string App::render_settings() {
|
||||
(p.at("theme") == type ? "true" : "false") + "\"");
|
||||
}
|
||||
pane += "</div></div>";
|
||||
pane += "<div class=\"settings-group\"><h3>Bewegung</h3>" +
|
||||
pane += "<div class=\"settings-group\"><h3>" + std::string(page ? "Darstellung" : "Bewegung") + "</h3>" +
|
||||
settings_row("preference-motion", "Übergänge und Einblendungen", "Reduziert: Fenster, Karten und Tor-Einblendungen erscheinen ohne Bewegung.",
|
||||
settings_select("preference-motion", {{"full", "Voll"}, {"reduced", "Reduziert"}},
|
||||
p.at("display").at("motion").get<std::string>(), "global", "display", "motion")) +
|
||||
"</div>";
|
||||
(page && engine_mode_ ? "" : "</div>");
|
||||
if (engine_mode_) {
|
||||
int width=0,height=0; SDL_GetWindowSize(video_.window,&width,&height);
|
||||
pane += "<div class=\"settings-group\"><h3>Fenster</h3><p>" + std::to_string(width) + " × " + std::to_string(height) + " · Automatische Anpassung</p></div>";
|
||||
const auto size = std::to_string(width) + " × " + std::to_string(height);
|
||||
if (page) pane += settings_row("settings-window", "Fenster", "Größe, nur Anzeige · passt sich dem Fenster an", "<span class=\"settings-readonly\">" + size + "</span>") + "</div>";
|
||||
else pane += "<div class=\"settings-group\"><h3>Fenster</h3><p>" + size + " · Automatische Anpassung</p></div>";
|
||||
} else {
|
||||
pane += "<div class=\"settings-group\"><h3>Bildschirm</h3>";
|
||||
const auto pref =
|
||||
@@ -370,6 +391,25 @@ std::string App::render_settings() {
|
||||
"</div><span id=\"settings-search-count\"></span></div>"
|
||||
: "";
|
||||
settings_restore_scroll_ = true;
|
||||
if (page) {
|
||||
// the headings of the panels in capitals, as on the other pages
|
||||
for (size_t at = pane.find("<h3>"); at != std::string::npos; at = pane.find("<h3>", at + 4)) {
|
||||
const auto end = pane.find("</h3>", at);
|
||||
if (end == std::string::npos) break;
|
||||
const auto text = pane.substr(at + 4, end - at - 4);
|
||||
if (text.find('&') == std::string::npos && text.find('<') == std::string::npos) pane.replace(at + 4, end - at - 4, pg_upper(text));
|
||||
}
|
||||
const bool game = settings_category_ == "game";
|
||||
std::string jump;
|
||||
if (const auto at = head.find("<div class=\"settings-jump-label\">"); at != std::string::npos) jump = head.substr(at);
|
||||
std::string out = "<section class=\"pg-page set-page\"><div class=\"pg-row\" style=\"align-items:flex-end;\"><div class=\"pg-grow\"><h2 class=\"pg-h\" style=\"font-size:" + pg(22) + ";line-height:" + pg(28) + ";\">" + captions.at(settings_category_).first +
|
||||
"</h2><span class=\"pg-mut\" style=\"display:block;\">" + captions.at(settings_category_).second + "</span></div><nav class=\"pg-tabs\" role=\"tablist\">" + nav + "</nav></div>";
|
||||
if (game)
|
||||
out += "<div class=\"pg-row set-search\"><input type=\"text\" id=\"settings-search\" maxlength=\"120\" value=\"" + esc(settings_query_) + "\" placeholder=\"Spieloption suchen …\" aria-label=\"Spieloption suchen\"/>" +
|
||||
pg_button("settings-search-clear", "×", "round", "id=\"settings-search-clear\" aria-label=\"Suche leeren\"") + "<span id=\"settings-search-count\" class=\"pg-mut\"></span>" + jump + "</div>";
|
||||
return out + "<div id=\"settings-options\" class=\"settings-scroll\" tabindex=\"0\">" + pane + "</div><nav class=\"pg-foot\"><span class=\"pg-status\" id=\"settings-draft-status\" role=\"status\"></span><span class=\"pg-sp\"></span>" +
|
||||
pg_button("settings-cancel", "Abbrechen", "", "id=\"settings-cancel\"") + pg_button("settings-apply", "Anwenden", "primary", "id=\"settings-apply\"") + "</nav></section>";
|
||||
}
|
||||
return "<section class=\"settings-layout\"><nav "
|
||||
"class=\"settings-categories\" role=\"tablist\" "
|
||||
"aria-orientation=\"vertical\">" +
|
||||
|
||||
Reference in new issue
Block a user