Port career setup, manager hub and context-aware native UI (by Codex)

This commit is contained in:
Codex authored and Codex committed 2026-10-27 01:57:58 +01:00
1 parent d88bf2872a
commit d085697bb9
37 files changed
+1447 -421

No files matched your search

+86 -54
View File
@@ -7,16 +7,17 @@
// country_, league_, selected_club_, manager_index_, manager_picker_,
// adding_manager_ remain the draft contract.
std::string App::render_newgame() {
const std::array<const char *, 4> keys = {"duration", "difficulty", "players",
"mode"};
const std::array<const char *, 4> names = {"Spieldauer", "Schwierigkeit",
"Mitspieler", "Modus"};
const std::array<int, 4> limits = {
5, 10, start_options_.value("league", true) ? 4 : 1, 3};
start_options_["mode"] = 3;
const std::array<const char *, 3> keys = {"duration", "difficulty",
"players"},
names = {"Spieldauer", "Schwierigkeit",
"Mitspieler"};
const std::array<int, 3> limits = {
5, 10, start_options_.value("league", true) ? 4 : 1};
std::string body =
"<section class=\"entry-setup\"><header class=\"entry-setup-heading\">"
"<h2>Grundeinstellungen</h2><p>Zuerst die Partie, dann die Manager.</p>"
"</header><div class=\"entry-setup-options\">";
"<section class=\"entry-setup entry-career-setup\"><header "
"class=\"entry-setup-heading\"><h2>Grundeinstellungen</h2><p>Deine "
"Karriere · alle Funktionen</p></header>";
for (size_t i = 0; i < keys.size(); ++i) {
const std::string key = keys[i];
const int value = start_options_.value(key, 1);
@@ -27,35 +28,48 @@ std::string App::render_newgame() {
"</strong>";
caption = value == 5 ? "Unbegrenzt" : value == 1 ? "Saison" : "Saisons";
} else if (i == 1) {
const int columns = std::min(value, 5), rows = value > 5 ? 2 : 1;
const int columns = std::min(5, value);
visual = "<div class=\"entry-setup-balls\" style=\"width:" +
std::to_string(columns * 102 - 10) + "dp;\">";
for (int n = 0; n < value; ++n)
visual += "<div style=\"position:absolute;" +
rect((n % columns) * 102,
(n / columns) * 102 + (rows == 1 ? 51 : 0), 92, 92) +
"\">" + glyph("ball", 92) + "</div>";
std::to_string(columns * 68 - 6) + "dp;\">";
for (int j = 0; j < value; ++j)
visual +=
"<div style=\"position:absolute;" +
rect((j % columns) * 68, (j / columns) * 68 + (value <= 5 ? 35 : 0),
62, 62) +
"\">" +
picture(renderer_.diagram(
"setup-ball",
"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 "
"0 48 48\"><circle cx=\"24\" cy=\"24\" r=\"21\" "
"fill=\"#e0e8e6\" stroke=\"#526771\" "
"stroke-width=\"2.6\"/><path d=\"m24 14 10 7-4 "
"12H18l-4-12ZM24 3v11M4 18l10 3M11 41l7-8M37 "
"41l-7-8M44 18l-10 3\" fill=\"#445966\" "
"stroke=\"#526771\" stroke-width=\"2.6\"/></svg>",
128),
62, 62) +
"</div>";
visual += "</div>";
caption = "Spielstärke " + std::to_string(value) + " von 10";
} else if (i == 2) {
} else {
visual = "<div class=\"entry-setup-people\">";
for (int n = 0; n < value; ++n)
visual += glyph("person", 84);
for (int j = 0; j < value; ++j)
visual += picture(
renderer_.diagram(
"setup-person",
"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 48 "
"64\"><circle cx=\"24\" cy=\"12\" r=\"9\" fill=\"#9fcbbf\" "
"stroke=\"#a9d8ca\" stroke-width=\"4\"/><path d=\"M8 "
"58V39c0-10 6-15 16-15s16 5 16 15v19M16 58V39M32 58V39\" "
"fill=\"none\" stroke=\"#a9d8ca\" stroke-width=\"4\" "
"stroke-linecap=\"round\"/></svg>",
192),
60, 112);
visual += "</div>";
caption = std::to_string(value) + " Mitspieler";
} else {
visual = "<strong class=\"entry-setup-mode\">" +
std::string(value == 1 ? "I"
: value == 2 ? "II"
: "III") +
"</strong>";
caption = value == 1 ? "Grundfunktionen"
: value == 2 ? "Erweiterte Funktionen"
: "Alle Funktionen";
}
body += "<section class=\"entry-setup-option\" style=\"" +
rect((i % 2) * 1320, (i / 2) * 719, 1292, 691) +
"\" aria-labelledby=\"setup-label-" + key +
rect(0, 104 + i * (530.6667 + 22), 760, 530.6667) +
"\"><h2 id=\"setup-label-" + key + "\">" + names[i] +
"</h2><div class=\"entry-setup-stepper\">";
body += btn("setup-step", "−", "entry-setup-minus",
@@ -71,8 +85,8 @@ std::string App::render_newgame() {
" erhöhen\" " + (value == limits[i] ? "disabled" : "")) +
"</div></section>";
}
body += "</div><section class=\"entry-setup-competitions\" "
"aria-label=\"Wettbewerbe\">";
body +=
"<section class=\"entry-setup-competitions\" aria-label=\"Wettbewerbe\">";
for (const auto *key : {"league", "world"}) {
const bool league = std::string(key) == "league",
active = start_options_.value(key, true),
@@ -82,23 +96,28 @@ std::string App::render_newgame() {
: !start_options_.value("league", true);
body += btn(
"setup-competition",
glyph(league ? "pitch" : "world", 70) + "<span><strong>" +
std::string(league ? "Ligaspiel" : "WM / EM") + "</strong><small>" +
(active ? "Aktiv" : "Aus") + "</small></span>",
"entry-setup-competition " + std::string(active ? "selected" : ""),
img(league ? "career.club" : "career.international", 904, 1580, false,
false, 1600) +
"<span class=\"entry-career-caption\"><strong>" +
std::string(league ? "Vereinsfußball" : "International · WM / EM") +
"</strong><small>" + (active ? "Aktiv" : "Auswählen") +
"</small></span><span class=\"entry-career-check\">" +
(active ? glyph("check", 38) : "<span>○</span>") + "</span>",
std::string("entry-setup-competition ") + (active ? "selected" : ""),
"id=\"setup-competition-" + std::string(key) + "\" data-id=\"" + key +
"\" aria-pressed=\"" + (active ? "true" : "false") + "\" " +
(locked ? "disabled" : ""));
}
const std::string hint =
start_options_.value("players", 1) > 1
? "Bei mehreren Mitspielern bleibt das Ligaspiel aktiv."
: !start_options_.value("league", true)
? "WM / EM allein ist mit einem Mitspieler möglich."
: "Mindestens ein Wettbewerb bleibt aktiv.";
body += "<p role=\"status\">" + hint +
"</p></section><footer class=\"entry-setup-actions\"><p>Deine "
"Auswahl wird beim Spielstart übernommen.</p><div>" +
body += "<p role=\"status\">" +
std::string(
start_options_.value("players", 1) > 1
? "Bei mehreren Mitspielern bleibt der Vereinsfußball aktiv."
: !start_options_.value("league", true)
? "Nationalmannschaft · ein Mitspieler · Deutschland"
: "Mindestens ein Wettbewerb bleibt aktiv.") +
"</p></section><footer class=\"entry-setup-actions\"><p>Dauer, "
"Schwierigkeit und Mitspielerzahl gelten für deine neue "
"Partie.</p><div>" +
btn("close", "Abbrechen") +
btn("setup-next", "Weiter", "primary", "id=\"setup-next\"") +
"</div></footer></section>";
@@ -110,8 +129,10 @@ std::string App::render_manager() {
if (!catalog)
return window("Neuer Spieler",
"<p>Bitte zuerst eine Modern-Mod aktivieren.</p>");
const bool national = career_national_entry();
const bool full = entry_full(), modal = manager_confirm_ || manager_success_;
const int limit = adding_manager_ ? 4 : start_options_.value("players", 1);
const int limit =
adding_manager_ ? (national ? 1 : 4) : start_options_.value("players", 1);
const int portrait =
selections_["portrait"].empty() ? 0 : std::stoi(selections_["portrait"]);
const std::string style =
@@ -136,9 +157,13 @@ std::string App::render_manager() {
"</div>";
};
const auto club_name = [&](const Json *c) {
return c ? catalog->name(*c) : std::string("Kein spielbarer Verein");
return national ? std::string("Deutschland")
: c ? catalog->name(*c)
: std::string("Kein spielbarer Verein");
};
const auto league_name = [&](const Json *c) {
if (national)
return std::string("Nationalmannschaft");
const auto *l =
c ? catalog->find("competitions", c->value("competition", ""))
: nullptr;
@@ -166,7 +191,7 @@ std::string App::render_manager() {
};
const auto *selected = catalog->find("clubs", selected_club_);
std::string content;
if (manager_picker_) {
if (manager_picker_ && !national) {
const auto query = settings_search_key(club_search_);
std::vector<const Json *> clubs;
for (const auto *c : catalog->clubs(league_))
@@ -230,7 +255,8 @@ std::string App::render_manager() {
"<section class=\"entry-manager-layout " +
std::string(adding_manager_ ? "is-add" : "") +
"\"><header class=\"entry-manager-step\"><span>" +
(full ? std::string("Vier Mitspieler im Spiel")
(full ? std::string(national ? "Nationaltrainer im Spiel"
: "Vier Mitspieler im Spiel")
: "Mitspieler " + std::to_string(manager_index_ + 1) + " von " +
std::to_string(limit)) +
"</span><p>Dein Name. Dein Verein. Dein Porträt.</p>" +
@@ -238,7 +264,7 @@ std::string App::render_manager() {
"id=\"manager-newgame\"")
: "") +
"</header><div class=\"entry-manager-fields " +
std::string(full ? "is-full" : "") +
std::string(full ? "is-full " : "") + (national ? "is-national" : "") +
"\"><div class=\"entry-manager-identity\"><section "
"class=\"entry-manager-person-card\"><div "
"class=\"entry-manager-person-copy\"><label "
@@ -251,9 +277,13 @@ std::string App::render_manager() {
"angesprochen.</p><span class=\"entry-manager-profile-tag\">Porträt " +
std::to_string(portrait + 1) + "</span></div>" +
face(portrait, style, 174) +
"</section><section class=\"entry-manager-club-card\"><h2>Verein</h2>" +
"</section><section class=\"entry-manager-club-card\"><h2>" +
std::string(national ? "Nationalmannschaft" : "Verein") + "</h2>" +
btn("manager-clubs",
"<div class=\"entry-manager-club-crest\">" + crest(selected, 176) +
"<div class=\"entry-manager-club-crest\">" +
(national
? img("career.national-de", 176, 176, false, false, 512)
: crest(selected, 176)) +
"</div><span><strong>" + esc(club_name(selected)) +
"</strong><small>" +
esc(selected
@@ -263,7 +293,8 @@ std::string App::render_manager() {
"</small><em>Verein wählen <span>›</span></em></span>",
"entry-manager-club-button",
"id=\"manager-clubs\" aria-label=\"Verein wählen: " +
esc(club_name(selected)) + "\" " + (full ? "disabled" : "")) +
esc(club_name(selected)) + "\" " +
(full || national ? "disabled" : "")) +
"</section></div><div "
"class=\"entry-manager-options\"><section><h2>Startliga</h2><div>" +
choose("manager-country", countries, country_) +
@@ -371,7 +402,8 @@ std::string App::render_manager() {
"aria-modal=\"true\" aria-labelledby=\"entry-confirm-title\"><h2 "
"id=\"entry-confirm-title\">Sind alle Angaben richtig?</h2><div "
"class=\"entry-confirm-identity\"><div class=\"entry-confirm-crest\">" +
crest(selected, 200) +
(national ? img("career.national-de", 200, 200, false, false, 512)
: crest(selected, 200)) +
"</div><div class=\"entry-confirm-copy\"><strong>" +
esc(selections_["manager-name"]) + "</strong><span>" +
esc(club_name(selected)) + "</span><small>" +