Port career setup, manager hub and context-aware native UI (by Codex)
This commit is contained in:
1 parent
d88bf2872a
commit
d085697bb9
37 files changed
+1447
-421
No files matched your search
@@ -19,3 +19,6 @@
|
||||
.career-dialog label {display:block;font-size:32dp;margin-bottom:20dp;}
|
||||
.career-dialog select {width:100%;height:100dp;font-size:32dp;}
|
||||
.career-dialog p {font-size:32dp;line-height:1.5;margin:28dp 0;}
|
||||
|
||||
.career-hub h2,.career-caption strong {font-weight:bold;}
|
||||
.career-hub header nav {max-width:64%;flex-wrap:wrap;}
|
||||
@@ -156,3 +156,26 @@ body.matchday {--entry-focus:#efb2aa;--entry-selected:#d48c7b26;--entry-accent-b
|
||||
.entry-confirm-dialog>h2 {text-align:center;}
|
||||
|
||||
.entry-choice-status>span,.entry-manager-portrait-caption>span {display:block;}
|
||||
|
||||
/* Club and international cards mirror the approved HTML career setup. */
|
||||
.entry-career-setup .entry-setup-option {padding:26dp 22dp;gap:12dp;}
|
||||
.entry-career-setup .entry-setup-option>h2 {font-size:34dp;}
|
||||
.entry-career-setup .entry-setup-stepper button {width:90dp;height:112dp;font-size:60dp;}
|
||||
.entry-career-setup .entry-setup-value>strong {height:140dp;font-size:138dp;}
|
||||
.entry-career-setup .entry-setup-value>.entry-setup-duration {font-size:160dp;}
|
||||
.entry-career-setup .entry-setup-value>span {font-size:28dp;white-space:nowrap;}
|
||||
.entry-career-setup .entry-setup-balls,.entry-career-setup .entry-setup-people {height:140dp;}
|
||||
.entry-career-setup .entry-setup-people {gap:8dp;}
|
||||
.entry-career-setup .entry-setup-competitions {left:786dp;right:0;top:104dp;bottom:124dp;height:auto;}
|
||||
.entry-career-setup .entry-setup-competition {top:0;width:904dp;height:1580dp;display:block;padding:0;overflow:hidden;border:4dp var(--border);border-radius:22dp;background-color:#0b1724;}
|
||||
.entry-career-setup .entry-setup-competition>.image-frame {position:absolute;left:0;right:0;top:0;bottom:0;}
|
||||
.entry-career-setup .entry-setup-competition.selected {border-color:var(--accent);}
|
||||
.entry-career-setup .entry-setup-competition:disabled {opacity:1;}
|
||||
.entry-career-setup .entry-career-caption {position:absolute;left:0;right:0;bottom:0;display:flex;flex-direction:column;align-items:flex-start;gap:10dp;padding:70dp 26dp 26dp;background-color:#091522ef;color:#f3f7fb;}
|
||||
.entry-career-caption strong {font-size:34dp;}.entry-career-caption small {font-size:28dp;color:#d4ede7;}
|
||||
.entry-career-setup .entry-career-check {position:absolute;right:24dp;top:22dp;width:56dp;height:56dp;display:flex;align-items:center;justify-content:center;background-color:#10282be8;border:2dp #a4dfce;border-radius:28dp;}
|
||||
.entry-career-setup .entry-setup-competitions>p {top:1598dp;}
|
||||
.entry-manager-fields.is-national .entry-manager-options {display:none;}
|
||||
.entry-manager-fields.is-national .entry-manager-choices {top:358dp;}
|
||||
|
||||
.entry-career-setup .entry-career-caption strong {font-weight:bold;}
|
||||
@@ -97,3 +97,10 @@ body.matchday .lineup-row.even {background-color:#f9f4ed05;}
|
||||
|
||||
body.silver .lineup-taker selectbox {background-color:#f3f7fcfc;}
|
||||
body.matchday .lineup-taker selectbox {background-color:#303037fc;}
|
||||
|
||||
.lineup-surface-controls {position:absolute;right:0;top:1156dp;width:650dp;height:70dp;display:flex;gap:12dp;}
|
||||
.lineup-surface-controls button {flex:1;min-width:0;height:70dp;font-size:25dp;padding:8dp 14dp;}
|
||||
.lineup-surface-controls .selected {background-color:var(--selected);border-color:var(--accent);color:var(--accent);}
|
||||
|
||||
.pitch-view .lineup-roster-scroll {height:1068dp;}
|
||||
.team-view .lineup-surface-controls {display:none;}
|
||||
@@ -1,6 +1,6 @@
|
||||
<rml>
|
||||
<head><title>OpenBMH</title><link type="text/rcss" href="theme.rcss"/><link type="text/rcss" href="ticket.rcss"/><link type="text/rcss" href="sports.rcss"/><link type="text/rcss" href="calendar.rcss"/><link type="text/rcss" href="reports.rcss"/><link type="text/rcss" href="report_details.rcss"/><link type="text/rcss" href="report_pickers.rcss"/><link type="text/rcss" href="indoor.rcss"/><link type="text/rcss" href="planning.rcss"/><link type="text/rcss" href="almanac.rcss"/><link type="text/rcss" href="finance.rcss"/>
|
||||
<link type="text/rcss" href="bank.rcss"/><link type="text/rcss" href="contracts.rcss"/><link type="text/rcss" href="amount.rcss"/><link type="text/rcss" href="environment.rcss"/><link type="text/rcss" href="advertising.rcss"/><link type="text/rcss" href="toto.rcss"/><link type="text/rcss" href="lineup.rcss"/><link type="text/rcss" href="transfer.rcss"/><link type="text/rcss" href="career_reports.rcss"/><link type="text/rcss" href="rankings.rcss"/><link type="text/rcss" href="stadium.rcss"/><link type="text/rcss" href="statistics.rcss"/><link type="text/rcss" href="news.rcss"/><link type="text/rcss" href="settings.rcss"/><link type="text/rcss" href="widgets.rcss"/><link type="text/rcss" href="files.rcss"/><link type="text/rcss" href="front.rcss"/><link type="text/rcss" href="entry.rcss"/><link type="text/rcss" href="opening.rcss"/><link type="text/rcss" href="select_menu.rcss"/></head>
|
||||
<link type="text/rcss" href="bank.rcss"/><link type="text/rcss" href="contracts.rcss"/><link type="text/rcss" href="amount.rcss"/><link type="text/rcss" href="environment.rcss"/><link type="text/rcss" href="advertising.rcss"/><link type="text/rcss" href="toto.rcss"/><link type="text/rcss" href="lineup.rcss"/><link type="text/rcss" href="transfer.rcss"/><link type="text/rcss" href="career_reports.rcss"/><link type="text/rcss" href="rankings.rcss"/><link type="text/rcss" href="stadium.rcss"/><link type="text/rcss" href="statistics.rcss"/><link type="text/rcss" href="news.rcss"/><link type="text/rcss" href="settings.rcss"/><link type="text/rcss" href="widgets.rcss"/><link type="text/rcss" href="files.rcss"/><link type="text/rcss" href="front.rcss"/><link type="text/rcss" href="entry.rcss"/><link type="text/rcss" href="career.rcss"/><link type="text/rcss" href="opening.rcss"/><link type="text/rcss" href="select_menu.rcss"/></head>
|
||||
<body class="midnight">
|
||||
<div id="background"></div>
|
||||
<div id="canvas"></div>
|
||||
|
||||
@@ -89,3 +89,19 @@ dieselbe Grafik unter `assets/modern/icons/almanac.svg` mit und kann sie auch
|
||||
bei einem älteren externen GUI-Paket anzeigen. Ein OBW muss dieses Motiv
|
||||
nicht enthalten. Bestehende Desktopansichten erhalten nur das zusätzliche
|
||||
Icon an einer freien Stelle; vorhandene Objekte werden dabei nicht verschoben.
|
||||
|
||||
## Karrierebilder und Büro-Unterlagen
|
||||
|
||||
Die optionale private GUI-Vorbereitung übernimmt die unveränderten Nutzerbilder
|
||||
unter `assets/studies/career/` als `career.club`, `career.international` und drei
|
||||
normierte Ausschnitte `manager.resign`, `manager.search`, `manager.add` desselben
|
||||
Sheets. Die beiden Hochformatmotive besitzen1086×1448Pixel, das Sheet1448×1086.
|
||||
Contain-Darstellung und gemessene Ausschnitte erhalten Proportionen und Köpfe;
|
||||
es wird keine native4K-Auflösung behauptet. `career.national-de/fr` sind eigene
|
||||
GUI-Flaggensymbole und keine Vereine im Weltkatalog.
|
||||
|
||||
`menu.club-office` und `menu.trophy-office` werden bei vorhandenen freigegebenen
|
||||
Study-Dateien ebenfalls übernommen; ältere GUI-Bestände behalten ihren bisherigen
|
||||
Hintergrundfallback. Das Manifest zeichnet Dateiquelle, SHA256 und Ausschnitt auf
|
||||
und bleibt als `private-reference-assets` gekennzeichnet. Diese Quelländerung
|
||||
verteilt keine privaten PNGs und ändert weder OBW noch dessen Asset-Index.
|
||||
@@ -21,3 +21,21 @@ Synthetische Providerprüfungen decken leere, kurze und vollständige Kader, die
|
||||
Der unabhängige Vergleich der vorigen Geometrie bestätigt sechs erfolgreiche Rendererfälle und 48 Status-/Readonly-Prüfungen. Alle sechs Grundansichten und die schmalen eigenen Formationen, Anweisungen und Schützenpicker wurden angesehen. In 24 vermessenen Controlzuständen gibt es keinen unerwarteten horizontalen Textüberlauf; die Seitentitel entsprechen den aktuellen HTML-Maßen (Schrift 34, Boxhöhe 39). Der reine Reglernachtest auf der abschließenden Runtime bleibt in den Metadaten von den vorherigen Geometrieaufnahmen getrennt.
|
||||
|
||||
Die aktuelle Aufteilung mit breiten Namen und ungefähr zwei Dritteln Tabelle ist getrennt unter `docs/qa/lineup-table-focus-2026-10-25/` geprüft. Der gemeinsame Build und alle 26 Regressionstests bestehen. Der unabhängige Vergleich umfasst sechs Theme-/Größenfälle, 96 Status-/Readonly-/Layoutprüfungen und 18 direkte Popup-Bildgrenzen; beide Datenseiten und alle 20 tatsächlichen Namen passen ohne Textüberlauf. Die drei Schützenlisten bleiben selbst bei 720p mit mindestens zwölf physischen Pixeln Reserve innerhalb des Inhalts. Zwei gezielte Bedienläufe mit 20 und 24 Spielern bestätigen vollständigen Kaderzugriff, Profile, Tauschen durch Anklicken und Ziehen, korrekt skalierte Ziehgeister, eigene Formationen, Gewichtungen, Schützenabbruch, Regler und tatsächlich geänderte rote Fläche sowie saubere Checkpoints. Die bisherigen Nachweise bleiben als vorangegangene Geometrien unverändert.
|
||||
|
||||
## Getrennte Hallenvorschau
|
||||
|
||||
Die native Demo kann über die Managerzentrale oder den Umschalter im Spielfeld
|
||||
zwischen Rasen und Halle wechseln. Rasen erhält elf gleichzeitige Positionen,
|
||||
die Halle sechs. Die ersten elf bilden den Rotationsplan (ein Torwart und fünf
|
||||
Paare); weitere tatsächlich vorhandene Weltspieler bleiben als Reserve sichtbar.
|
||||
Die Kennzeichnung von fünf Partnern ist keine zusätzliche allgemeine
|
||||
Kader-/Einsatzsperre. Ein beliebiger vorhandener Spieler darf per Tausch einen
|
||||
Feldplatz übernehmen. Nur die Positionsbearbeitung selbst gilt für die aktuell
|
||||
sichtbaren sechs beziehungsweise elf Plätze.
|
||||
|
||||
Rasen und Halle behalten getrennte Positionen, Formationen, Aufträge und Schützen.
|
||||
Das gemeinsame interne Positionsformat bleibt elfgeteilt, während der lesende
|
||||
Starterzugriff nur die sechs Hallenpositionen projiziert. Eine passende braune
|
||||
Hallenfläche ersetzt die grüne Rasenfläche. Der Kader bleibt vollständig;
|
||||
fehlende Spieler werden weder ergänzt noch als Nationalberufung erfunden.
|
||||
Es werden keine Rotation, Auswechslung oder Spielminute von einer Engine bewegt.
|
||||
@@ -60,3 +60,23 @@ aktiveIdentität, Rollen-/Menüsperren, verworfene/stale Aktionen, getrennte
|
||||
Hallenanker, kein siebter Feldspieler, erhaltene Vereinsansichten sowie
|
||||
Checkpoint-/Game-End-Fortsetzung. Native Bild- und Eingabeprüfung folgt nach dem
|
||||
UI-App-Link; dieser Modellmeilenstein behauptet noch keine grafische Abnahme.
|
||||
|
||||
## Nativer UI-Meilenstein
|
||||
|
||||
Manager-Hub mit Nutzerillustrationen, Besitzerwahl und Bestätigung der Abgabe,
|
||||
deaktivierter Vereinssuche („Später“) und dem bisherigen Neuen-Spieler-Dialog
|
||||
sind nativ angebunden. Rollen- und Managerauswahl verwenden denselben Kontext
|
||||
wie Header, Wappen, Aufstellung, Verträge, Stadion, Transferansichten, Statistik
|
||||
und Save-Metadaten. Personenreihenfolge und gewählte Identität bleiben erhalten.
|
||||
Eine geöffnete Abgabebestätigung bindet Sourceidentität und Revision; eine
|
||||
inzwischen gewechselte Partie wird abgewiesen. Nach Game End führen weder
|
||||
Desktop-Rückkehr noch alte Opening-Fortsetzung in die beendete Partie.
|
||||
|
||||
Die ersten echten Linux-RmlUI-Eingabeläufe bestehen33/33 Prüfungen in zwei normal
|
||||
beendeten Prozessen: National-only mit gesperrtem zweiten Menschen und komplette
|
||||
Vier-Personen-Partie einschließlich Rollenwechsel, Hallen-/Rasenankern,
|
||||
Save/Export, verworfener Abgabe, anderem Besitzer, KI-Vermerk und letztem
|
||||
Game End mit erneut erreichbarem Neuen Spiel. Zehn betroffene CTest-Gruppen sind
|
||||
grün. Die gemessenen Binär-/Welt-Hashes liegen in privater QA; das OBW bleibt
|
||||
unverändert. Drei-Theme-Bildvergleich, Resize-Gegenprobe und Neustarts werden als
|
||||
separater Folgeschritt dokumentiert; keine Mac-/Windows-Abnahme wird behauptet.
|
||||
@@ -54,3 +54,18 @@ UI-Checkpoints werden im privaten QA-Verzeichnis
|
||||
`docs/qa/entry-flow-batch-2026-10-26` geführt. Tatsächliche Laufresultate und
|
||||
verbleibende Abweichungen stehen im dortigen Bericht; Quellvergleich allein
|
||||
wird nicht als Laufabnahme ausgewiesen.
|
||||
|
||||
## Nachtpaket: fester Modus und Wettbewerbskarten
|
||||
|
||||
Der native UI-Entwurf entfernt die Moduswahl; gültige ältere UI-JSON-Spielstände
|
||||
mit Modus1/2 normalisieren auf3. Dauer, Schwierigkeit und1–4 Menschen bleiben.
|
||||
Vereinsfußball und International sind zwei getrennte Bildkarten mit gedrücktem
|
||||
Zustand; mindestens eine bleibt aktiv. International allein erlaubt weiterhin
|
||||
nur einen Menschen und zeigt eine gesperrte Deutschlandkarte, keine wählbare
|
||||
Vereinskarte. Die Liga-/Stärkeeinstellungen werden dort ausgeblendet.
|
||||
|
||||
Das Büro bleibt hinter frischem Setup, Managerwizard und Saisonvorbereitung;
|
||||
beim Hinzufügen bleibt der vorhandene Desktop sichtbar und gesperrt. Die neue
|
||||
Managerzentrale, aktiver Mensch und Rollen stehen im
|
||||
[Managervertrag](../../desktop/manager/README.md). Die Motive gehören zum
|
||||
externen GUI-Paket, nicht zum OBW und nicht zum öffentlichen Quellpaket.
|
||||
@@ -0,0 +1,141 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
bool App::career_action(const std::string &action, Rml::Element *target) {
|
||||
if (scene_ != "managerhub" || !source_ || !popup_.empty())
|
||||
return false;
|
||||
const auto id =
|
||||
target ? target->GetAttribute<Rml::String>("data-id", "") : "";
|
||||
if (action == "career-resign-cancel") {
|
||||
career_resign_open_ = false;
|
||||
focus_after_render_ = "career-resign";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "career-game-end") {
|
||||
career_game_end_ = false;
|
||||
career_resign_open_ = false;
|
||||
scene_ = "main";
|
||||
menu_.clear();
|
||||
focus_after_render_ = "front-new";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (career_game_end_)
|
||||
return true;
|
||||
if (career_resign_open_) {
|
||||
if (action == "career-resign-confirm") {
|
||||
const auto value = field("career-resign-owner");
|
||||
if (value.empty() || value.size() > 2 ||
|
||||
!std::all_of(value.begin(), value.end(),
|
||||
[](char c) { return c >= '0' && c <= '9'; }))
|
||||
return true;
|
||||
const auto result =
|
||||
source_.get() == career_resign_source_
|
||||
? source_->apply(
|
||||
{career_resign_revision_,
|
||||
"career",
|
||||
{{"kind", "resign"}, {"portrait", std::stoi(value)}}})
|
||||
: ActionResult{false, 0, "changed_session"};
|
||||
if (!result.ok) {
|
||||
career_resign_open_ = false;
|
||||
refresh();
|
||||
message("Die Partie hat sich geändert. Bitte die Managerabgabe erneut "
|
||||
"öffnen.");
|
||||
return true;
|
||||
}
|
||||
{
|
||||
career_resign_open_ = false;
|
||||
career_game_end_ = snap().state.at("career").value("ended", false);
|
||||
focus_after_render_ =
|
||||
career_game_end_ ? "career-game-end" : "career-resign";
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (action == "close") {
|
||||
scene_ =
|
||||
snap().state.at("career").value("ended", false) ? "main" : "desktop";
|
||||
focus_after_render_ = "object-app-newplayer";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "career-add") {
|
||||
entry_add();
|
||||
return true;
|
||||
}
|
||||
if (action == "career-resign") {
|
||||
career_resign_open_ = true;
|
||||
career_resign_portrait_ = manager(snap()).value("portrait", 0);
|
||||
career_resign_revision_ = snap().revision;
|
||||
career_resign_source_ = source_.get();
|
||||
focus_after_render_ = "career-resign-owner";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "career-manager" && !id.empty()) {
|
||||
if (apply("career",
|
||||
{{"kind", "select_manager"}, {"portrait", std::stoi(id)}})) {
|
||||
focus_after_render_ = "career-manager-" + id;
|
||||
refresh();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (action == "career-role" || action == "career-surface") {
|
||||
if (apply("career", {{"kind", action == "career-role" ? "role" : "surface"},
|
||||
{"value", id}})) {
|
||||
focus_after_render_ = action + "-" + id;
|
||||
refresh();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool App::career_event(Rml::Event &event) {
|
||||
if (scene_ != "managerhub" || !source_ || !popup_.empty())
|
||||
return false;
|
||||
const auto type = event.GetType();
|
||||
const bool keyboard = type == "keydown";
|
||||
const auto key = keyboard ? Rml::Input::KeyIdentifier(
|
||||
event.GetParameter<int>("key_identifier", 0))
|
||||
: Rml::Input::KI_UNKNOWN;
|
||||
if (key == Rml::Input::KI_ESCAPE) {
|
||||
career_action(career_game_end_ ? "career-game-end"
|
||||
: career_resign_open_ ? "career-resign-cancel"
|
||||
: "close",
|
||||
nullptr);
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (!career_resign_open_ && !career_game_end_)
|
||||
return false;
|
||||
auto *target = event.GetTargetElement();
|
||||
bool inside = false;
|
||||
for (auto *n = target; n && n != doc_; n = n->GetParentNode())
|
||||
if (n->GetId() == "career-dialog-layer")
|
||||
inside = true;
|
||||
if (!inside && (type == "click" || type == "mousedown" || type == "mouseup" ||
|
||||
type == "dblclick")) {
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (key == Rml::Input::KI_TAB) {
|
||||
Rml::ElementList nodes;
|
||||
if (auto *layer = element("career-dialog-layer"))
|
||||
layer->QuerySelectorAll(nodes, "button,select");
|
||||
nodes.erase(
|
||||
std::remove_if(nodes.begin(), nodes.end(),
|
||||
[](auto *n) { return n->HasAttribute("disabled"); }),
|
||||
nodes.end());
|
||||
if (!nodes.empty()) {
|
||||
auto i =
|
||||
std::find(nodes.begin(), nodes.end(), context_->GetFocusElement());
|
||||
const int old = i == nodes.end() ? -1 : int(i - nodes.begin()),
|
||||
step = event.GetParameter<int>("shift_key", 0) ? -1 : 1;
|
||||
nodes[size_t((old + step + int(nodes.size())) % int(nodes.size()))]
|
||||
->Focus(true);
|
||||
}
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
std::string App::render_career() {
|
||||
const auto s = snap();
|
||||
const auto c = demo_career_context(s.state, *s.world);
|
||||
const bool ended = c.at("ended");
|
||||
const auto &m = manager(s);
|
||||
std::string body =
|
||||
"<section class=\"career-hub\"><header><div><h2>" +
|
||||
esc(ended ? "Karriere beendet" : m.value("name", "")) + "</h2><p>" +
|
||||
esc(c.at("current_team").value("name", "")) + " · " +
|
||||
(c.at("role") == "national" ? "Nationalmannschaft" : "Vereinsmanager") +
|
||||
"</p></div><nav aria-label=\"Aktiver Manager\">";
|
||||
for (const auto &person : c.at("active_managers"))
|
||||
body += btn(
|
||||
"career-manager", esc(person.value("name", "")),
|
||||
person.value("portrait", 0) == m.value("portrait", 0) ? "selected" : "",
|
||||
"id=\"career-manager-" + std::to_string(person.value("portrait", 0)) +
|
||||
"\" data-id=\"" + std::to_string(person.value("portrait", 0)) +
|
||||
"\" aria-pressed=\"" +
|
||||
(person.value("portrait", 0) == m.value("portrait", 0) ? "true"
|
||||
: "false") +
|
||||
"\"");
|
||||
body += "</nav></header><div class=\"career-cards\">";
|
||||
const auto card = [&](const std::string &action, const std::string &key,
|
||||
const std::string &title, const std::string ¬e,
|
||||
const std::string &css, bool disabled) {
|
||||
return btn(
|
||||
action,
|
||||
img(key, css == "career-add" ? 2612 : 1292, 724, false, false, 1600) +
|
||||
"<span class=\"career-caption\"><strong>" + title +
|
||||
"</strong><small>" + note + "</small></span>",
|
||||
"career-card " + css,
|
||||
"id=\"" + action + "\" " + (disabled ? "disabled" : ""));
|
||||
};
|
||||
body += card("career-resign", "manager.resign", "Aufgeben",
|
||||
"Dein Amt abgeben", "career-resign", ended) +
|
||||
card("career-search", "manager.search", "Vereinssuche", "Später",
|
||||
"career-search", true) +
|
||||
card("career-add", "manager.add", "Neuer Spieler",
|
||||
"Weiteren Menschen einrichten", "career-add", ended) +
|
||||
"</div><footer><section><span>Dein Aufgabenbereich</span><div>";
|
||||
for (const auto &role : c.at("available_roles")) {
|
||||
const auto id = role.get<std::string>();
|
||||
body += btn("career-role", id == "club" ? "Verein" : "Nationalmannschaft",
|
||||
c.at("role") == role ? "selected" : "",
|
||||
"id=\"career-role-" + id + "\" data-id=\"" + id +
|
||||
"\" aria-pressed=\"" +
|
||||
(c.at("role") == role ? "true" : "false") + "\" " +
|
||||
(ended ? "disabled" : ""));
|
||||
}
|
||||
body += "</div></section><section><span>Aufstellung · Vorschau</span><div>";
|
||||
for (const auto *surface : {"outdoor", "indoor"})
|
||||
body += btn("career-surface",
|
||||
std::string(surface) == "indoor" ? "Halle · 6 Spieler"
|
||||
: "Rasen · 11 Spieler",
|
||||
c.at("surface") == surface ? "selected" : "",
|
||||
"id=\"career-surface-" + std::string(surface) +
|
||||
"\" data-id=\"" + surface + "\" aria-pressed=\"" +
|
||||
(c.at("surface") == surface ? "true" : "false") + "\" " +
|
||||
(ended || (std::string(surface) == "indoor" &&
|
||||
c.at("role") == "national")
|
||||
? "disabled"
|
||||
: ""));
|
||||
body += "</div></section></footer></section>";
|
||||
if (career_resign_open_ || career_game_end_) {
|
||||
body = "<div id=\"career-underlay\" aria-hidden=\"true\">" + body +
|
||||
"</div><div id=\"career-dialog-layer\" "
|
||||
"class=\"entry-dialog-layer\"><section class=\"entry-dialog "
|
||||
"career-dialog\" role=\"dialog\" aria-modal=\"true\"><h2>" +
|
||||
std::string(career_game_end_ ? "Spiel beendet"
|
||||
: "Manageramt aufgeben?") +
|
||||
"</h2>";
|
||||
if (career_game_end_)
|
||||
body += "<p>Der letzte menschliche Mitspieler hat sein Amt abgegeben. "
|
||||
"Zurück zum Hauptmenü.</p><footer>" +
|
||||
btn("career-game-end", "Zum Hauptmenü", {},
|
||||
"id=\"career-game-end\"") +
|
||||
"</footer>";
|
||||
else {
|
||||
std::vector<std::pair<std::string, std::string>> people;
|
||||
for (const auto &person : c.at("active_managers")) {
|
||||
const auto *club = s.world->find("clubs", person.value("club", ""));
|
||||
people.emplace_back(
|
||||
std::to_string(person.value("portrait", 0)),
|
||||
person.value("name", "") + " · " +
|
||||
(s.state.at("edits").at("setup").value("league", true)
|
||||
? (club ? s.world->name(*club) : "")
|
||||
: "Deutschland"));
|
||||
}
|
||||
body +=
|
||||
"<label for=\"career-resign-owner\">Wer gibt sein Amt ab?</label>" +
|
||||
select("career-resign-owner", people,
|
||||
std::to_string(career_resign_portrait_),
|
||||
"career-resign-owner") +
|
||||
"<p>" +
|
||||
(people.size() == 1
|
||||
? "Du bist der letzte menschliche Mitspieler. Mit deiner "
|
||||
"Bestätigung endet diese Partie."
|
||||
: "Die anderen Menschen spielen weiter. Die KI übernimmt den "
|
||||
"abgegebenen Verein in dieser Karrierevorschau.") +
|
||||
"</p><footer>" +
|
||||
btn("career-resign-cancel", "Abbrechen", {},
|
||||
"id=\"career-resign-cancel\"") +
|
||||
btn("career-resign-confirm", "Amt aufgeben", {},
|
||||
"id=\"career-resign-confirm\"") +
|
||||
"</footer>";
|
||||
}
|
||||
body += "</section></div>";
|
||||
}
|
||||
return window("Manager", body);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ std::string contracts_text(const Json &value, const std::string &fallback = "—
|
||||
std::string contracts_managed(const Snapshot &snapshot) {
|
||||
const auto &managers = contracts_field(snapshot.state, "managers");
|
||||
return managers.is_array() && !managers.empty()
|
||||
? contracts_text(contracts_field(managers[0], "club"), "") : "";
|
||||
? contracts_text(contracts_field(demo_career_manager(snapshot.state), "club"), "") : "";
|
||||
}
|
||||
Json contracts_projection(const Snapshot &snapshot) {
|
||||
if (!snapshot.world) return {{"ok", false}};
|
||||
|
||||
@@ -148,6 +148,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
if (n->GetId() == "native-ticket-layer")
|
||||
return;
|
||||
if(front_event(event))return;
|
||||
if (career_event(event)) return;
|
||||
if (entry_event(event)) return;
|
||||
if (opening_event(event)) return;
|
||||
if (amount_event(event)) return;
|
||||
@@ -464,6 +465,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
const auto id =
|
||||
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
|
||||
if(front_action(action,target))return;
|
||||
if (career_action(action,target)) return;
|
||||
if (entry_action(action, target)) return;
|
||||
if (opening_action(action, target)) return;
|
||||
if (settings_action(action,target)) return;
|
||||
@@ -682,10 +684,11 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
}
|
||||
if (action.starts_with("open:")) {
|
||||
const auto route = action.substr(5);
|
||||
if(source_&&!demo_career_menu_available(snap().state,route)){message(snap().state.at("career").value("ended",false)?"Diese Partie ist beendet. Bitte ein neues Spiel beginnen oder einen Spielstand laden.":"Dieses Vereinsmenü ist für die Nationalmannschaft nicht verfügbar.");return;}
|
||||
if (route == "kickoff")
|
||||
return;
|
||||
if (route == "newplayer") {
|
||||
entry_add();
|
||||
scene_="managerhub";menu_.clear();career_resign_open_=career_game_end_=false;focus_after_render_="career-resign";refresh();
|
||||
return;
|
||||
}
|
||||
static const std::set<std::string> available = {
|
||||
@@ -890,7 +893,14 @@ void App::script() {
|
||||
try {
|
||||
const auto command = Json::parse(line);
|
||||
const auto type = command.value("type", std::string());
|
||||
if(type=="front-wait"){
|
||||
if(type=="window-resize-probe"){
|
||||
// QA-only synthetic event: no OS window or mouse coordinate is changed.
|
||||
int w,h,pw,ph;SDL_GetWindowSize(video_.window,&w,&h);video_.drawable_size(pw,ph);
|
||||
const auto before=context_->GetDimensions();SDL_Event probe{};probe.type=SDL_WINDOWEVENT;probe.window.windowID=SDL_GetWindowID(video_.window);probe.window.event=SDL_WINDOWEVENT_SIZE_CHANGED;probe.window.data1=std::max(1,w/2);probe.window.data2=std::max(1,h/2);handle_event(probe);
|
||||
const auto after=context_->GetDimensions();const bool ok=after.x==pw&&after.y==ph;
|
||||
editor::write_atomic(editor::path(command.at("path").get<std::string>()),Json{{"qa_only",true},{"logical",{w,h}},{"drawable",{pw,ph}},{"context_before",{before.x,before.y}},{"synthetic_event",{probe.window.data1,probe.window.data2}},{"context_after",{after.x,after.y}},{"passed",ok}}.dump(2));
|
||||
if(!ok)throw editor::Error("QA resize probe: context dimensions were overwritten by logical event data.");
|
||||
}else if(type=="front-wait"){
|
||||
const auto end=SDL_GetTicks64()+command.value("timeout_ms",uint64_t(300000));
|
||||
while(front_busy_&&SDL_GetTicks64()<end){front_poll();if(needs_render_||dirty_)frame();SDL_Delay(10);}
|
||||
if(front_busy_)throw editor::Error("Modvorgang hat das QA-Zeitlimit überschritten.");
|
||||
@@ -969,7 +979,7 @@ void App::script() {
|
||||
{"transfer_view", transfer_view_}, {"transfer_dialog", transfer_dialog_}, {"transfer_draft", transfer_draft_},
|
||||
{"career_view", career_view_}, {"rankings_view", rankings_view_},
|
||||
{"stadium_view", stadium_view_},
|
||||
{"select_menu", select_menu_ ? select_menu_->snapshot() : Json()}, {"entry_view", entry_snapshot()}, {"front_view",front_snapshot_view()}, {"files_view",{{"mode",files_mode_},{"selected",files_selected_},{"name",files_name_},{"feedback",files_feedback_}}}, {"widget_view",{{"query",widget_query_},{"notice",widget_notice_}}}, {"ui_preferences",ui_preferences_}, {"settings_draft",settings_draft_}, {"settings_category",settings_category_}, {"settings_query",settings_query_}, {"settings_notice",settings_notice_},
|
||||
{"select_menu", select_menu_ ? select_menu_->snapshot() : Json()}, {"career_context",source_?demo_career_context(snap().state,*world_):Json()}, {"manager_hub",{{"resign_open",career_resign_open_},{"game_end",career_game_end_},{"owner",field("career-resign-owner")}}}, {"entry_view", entry_snapshot()}, {"front_view",front_snapshot_view()}, {"files_view",{{"mode",files_mode_},{"selected",files_selected_},{"name",files_name_},{"feedback",files_feedback_}}}, {"widget_view",{{"query",widget_query_},{"notice",widget_notice_}}}, {"ui_preferences",ui_preferences_}, {"settings_draft",settings_draft_}, {"settings_category",settings_category_}, {"settings_query",settings_query_}, {"settings_notice",settings_notice_},
|
||||
{"statistics_view", statistics_view_}, {"statistics_trophy", statistics_trophy_},
|
||||
{"statistics_scrolls", statistics_scrolls_},
|
||||
{"news_view", news_view_}, {"news_dialog", news_dialog_},
|
||||
@@ -977,6 +987,7 @@ void App::script() {
|
||||
{"focus", context_->GetFocusElement() ? context_->GetFocusElement()->GetId() : ""},
|
||||
{"contracts_view", {{"dialog", contracts_dialog_}, {"player", contracts_player_}, {"tab", contracts_tab_}, {"draft", contract_draft_}}},
|
||||
{"amount_editor", amount_ ? Json{{"title", amount_->request.title}, {"raw", amount_->raw}, {"review", amount_->review}, {"error", amount_error()}} : Json()},
|
||||
{"display_metrics",[&](){int w,h,pw,ph;SDL_GetWindowSize(video_.window,&w,&h);video_.drawable_size(pw,ph);const auto d=context_->GetDimensions();return Json{{"logical",{w,h}},{"drawable",{pw,ph}},{"context",{d.x,d.y}}};}()},
|
||||
{"source_revision", source_ ? Json(snap().revision) : Json()},
|
||||
{"game_dirty", source_ && source_->dirty()},
|
||||
{"desktop_dirty", desktop_ != saved_desktop_},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_career_reports.hpp"
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
@@ -35,9 +36,9 @@ Context context(const Catalog &world,const Json &state) {
|
||||
Context c;
|
||||
const auto &managers=field(state,"managers");
|
||||
if(managers.is_array()&&!managers.empty()&&managers[0].is_object()) {
|
||||
c.manager=text(field(managers[0],"name"));
|
||||
const auto id=text(field(managers[0],"club"),"");
|
||||
if(!id.empty())if(const auto *club=world.find("clubs",id);club&&club->value("type",std::string("club"))=="club")c.club=id;
|
||||
c.manager=text(field(demo_career_manager(state),"name"));
|
||||
const auto id=text(field(demo_career_manager(state),"club"),"");
|
||||
if(state.value("career",Json::object()).value("role","club")!="national"&&!id.empty())if(const auto *club=world.find("clubs",id);club&&club->value("type",std::string("club"))=="club")c.club=id;
|
||||
}
|
||||
auto reference=field(state,"date");
|
||||
if(!date(reference))reference=world.manifest().value("start_date",Json());
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
// Read-only, deterministic presentation fixtures. FULL demo state supplies only
|
||||
// the first manager/club and date. No engine, RNG, wallet or catalogue mutation.
|
||||
// the active manager/club and date. No engine, RNG, wallet or catalogue mutation.
|
||||
// page0..4 moves the eight-season window backwards by one season per page.
|
||||
// {ok,available,fictional,page,club,manager,first_year,last_year,range,charts,
|
||||
// history:[12 newest completed seasons]}; clubs are existing IDs or null.
|
||||
Json demo_achievements(const Catalog &, const Json &full_state, int page = 0);
|
||||
// At most8 distinct existing clubs, managed club first. Fictional manager names
|
||||
// and totals match the Gold; the first manager name is taken from the snapshot.
|
||||
// and totals match the Gold; the active manager name is taken from the snapshot.
|
||||
// {ok,available,fictional,club,manager,rows:[{rank,manager,club,points,...}]}.
|
||||
Json demo_highscores(const Catalog &, const Json &full_state);
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_files.hpp"
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "editor/images.hpp"
|
||||
#include "content/digest.hpp"
|
||||
@@ -343,6 +344,6 @@ Json DemoFiles::career_metadata(const Json &data) {
|
||||
if (data.contains("game_info")) matchday = data.at("game_info").value("matchday", 0);
|
||||
return {{"season", std::to_string(season) + "/" + std::to_string(season + 1).substr(2)},
|
||||
{"matchday", matchday > 0 ? std::to_string(matchday) + ". Spieltag" : "Vorbereitung"},
|
||||
{"date", date}, {"managers", data.at("managers")}};
|
||||
{"date", date}, {"managers", data.at("managers")}, {"current_manager",demo_career_manager(data)}, {"role",data.value("career",Json::object()).value("role","club")}, {"ended",data.value("career",Json::object()).value("ended",false)}, {"human_count",data.value("career",Json::object()).value("ended",false)?0:data.at("managers").size()}};
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_finance.hpp"
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
@@ -52,9 +53,9 @@ std::string own(const Catalog &world, const std::string &managed, const Json *st
|
||||
if (!managers.is_array() || managers.empty() || !managers[0].is_object() ||
|
||||
!managers[0].contains("club") || !managers[0]["club"].is_string())
|
||||
throw editor::Error("invalid_finance_manager");
|
||||
if (managers[0]["club"].get<std::string>().empty())
|
||||
if (demo_career_manager(*state).value("club", "").empty())
|
||||
throw editor::Error("invalid_finance_manager");
|
||||
return own(world, managers[0]["club"].get<std::string>());
|
||||
return own(world, demo_career_manager(*state).value("club", ""));
|
||||
}
|
||||
for (const auto *club : world.clubs())
|
||||
if (world.manageable(club->value("id", ""))) return club->value("id", "");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_news.hpp"
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
@@ -310,7 +311,7 @@ Json demo_news_view(const Catalog &world, const Json &state,
|
||||
std::string manager, club_id, club_name;
|
||||
if (state.contains("managers") && state.at("managers").is_array() &&
|
||||
!state.at("managers").empty()) {
|
||||
const auto &m = state.at("managers")[0];
|
||||
const auto &m = demo_career_manager(state);
|
||||
manager = m.value("name", "");
|
||||
club_id = m.value("club", "");
|
||||
if (const auto *c = world.find("clubs", club_id))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_stadium.hpp"
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include "modern/ui/demo_finance.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -48,8 +49,9 @@ std::string owner(const Catalog &world, const Json *state, std::string requested
|
||||
if (requested.empty() && state && state->is_object()) {
|
||||
const auto managers = state->find("managers");
|
||||
if (managers != state->end() && managers->is_array() && !managers->empty() && (*managers)[0].is_object()) {
|
||||
const auto club = (*managers)[0].find("club");
|
||||
if (club != (*managers)[0].end() && club->is_string()) requested = club->get<std::string>();
|
||||
const auto &active=demo_career_manager(*state);
|
||||
const auto club = active.find("club");
|
||||
if (club != active.end() && club->is_string()) requested = club->get<std::string>();
|
||||
}
|
||||
}
|
||||
if (!requested.empty()) {
|
||||
|
||||
@@ -25,7 +25,7 @@ std::string edit_demo_stadium(Json &state, const Json &action, const Catalog &,
|
||||
// placesCost,seatsCost,roofCost}. All monetary values are raw minor units.
|
||||
// Invalid input/downgrades => ok=false; no-op, pending target or insufficient
|
||||
// budget => ok=true,can_build=false with a precise error and usable quote.
|
||||
// Explicit club wins; otherwise full state.managers[0].club, then legacy first
|
||||
// Explicit club wins; otherwise the active full-state manager club, then legacy first
|
||||
// manageable club, or "" for a catalogue without manageable clubs.
|
||||
Json demo_stadium_quote(const Json &state, const Json &request, const Catalog &,
|
||||
const std::string &club = {});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_statistics.hpp"
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
@@ -120,9 +121,9 @@ Json demo_statistics(const Catalog &world,const Json &state,const Json &request)
|
||||
const Json *own=nullptr;std::string manager_name="—";
|
||||
const auto &managers=field(state,"managers");
|
||||
if(managers.is_array()&&!managers.empty()) {
|
||||
own=world.find("clubs",string(field(managers.front(),"club")));
|
||||
if(own&&own->value("type","club")!="club")own=nullptr;
|
||||
const auto name=string(field(managers.front(),"name"));if(!name.empty())manager_name=name;
|
||||
own=world.find("clubs",string(field(demo_career_manager(state),"club")));
|
||||
if(own&&(own->value("type","club")!="club"||state.value("career",Json::object()).value("role","club")=="national"))own=nullptr;
|
||||
const auto name=string(field(demo_career_manager(state),"name"));if(!name.empty())manager_name=name;
|
||||
}
|
||||
int year=season_year(field(state,"date")).value_or(season_year(world.manifest().value("start_date",Json())).value_or(2027));
|
||||
const bool absolute=request.value("absolute",false);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_widgets.hpp"
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
@@ -27,7 +28,7 @@ const Json &widget_catalogue() {
|
||||
return catalogue;
|
||||
}
|
||||
Json demo_desktop_widgets(const Catalog &world, const Json &state) {
|
||||
const auto own = state.at("managers")[0].at("club").get<std::string>();
|
||||
const auto own = demo_career_manager(state).value("club", "");
|
||||
const auto *club = world.find("clubs", own);
|
||||
const auto clubs = world.clubs(club ? club->value("competition", "") : "");
|
||||
std::string opponent = own;
|
||||
|
||||
@@ -84,6 +84,8 @@ void App::entry_begin() {
|
||||
bind_world(entry_catalog_);
|
||||
start_options_ = {{"duration", 5}, {"difficulty", 3}, {"players", 1},
|
||||
{"mode", 3}, {"league", true}, {"world", true}};
|
||||
if(source_ && world_ && entry_catalog_->manifest().at("id")==world_->manifest().at("id"))start_options_=snap().state.at("edits").at("setup");
|
||||
start_options_["mode"]=3;
|
||||
adding_manager_ = false;
|
||||
managers_draft_ = Json::array();
|
||||
manager_index_ = 0;
|
||||
@@ -240,14 +242,15 @@ bool App::entry_action(const std::string &action, Rml::Element *target) {
|
||||
return true;
|
||||
}
|
||||
if (action == "setup-step") {
|
||||
start_options_["mode"]=3;
|
||||
if(id=="mode")return true;
|
||||
const auto step = target->GetAttribute<int>("data-step", 0);
|
||||
const int limit = id == "duration" ? 5
|
||||
: id == "difficulty" ? 10
|
||||
: id == "players"
|
||||
? (start_options_.value("league", true) ? 4 : 1)
|
||||
: 3;
|
||||
if (id == "duration" || id == "difficulty" || id == "players" ||
|
||||
id == "mode")
|
||||
if (id == "duration" || id == "difficulty" || id == "players")
|
||||
start_options_[id] =
|
||||
std::clamp(start_options_.value(id, 1) + step, 1, limit);
|
||||
const int current = start_options_.value(id, 1);
|
||||
@@ -291,6 +294,7 @@ bool App::entry_action(const std::string &action, Rml::Element *target) {
|
||||
}
|
||||
return true;
|
||||
} else if (action == "manager-clubs") {
|
||||
if(career_national_entry()||entry_full())return true;
|
||||
selections_["manager-name"] = field("manager-name");
|
||||
entry_picker_country_ = country_;
|
||||
entry_picker_league_ = league_;
|
||||
|
||||
@@ -27,6 +27,7 @@ bool App::opening_pending() const {
|
||||
if (!source_)
|
||||
return false;
|
||||
const auto state = snap().state;
|
||||
if(state.value("career",Json::object()).value("ended",false))return false;
|
||||
const auto &flow = state.at("opening_flow");
|
||||
return flow.at("created").get<bool>() && flow.at("phase") != "done";
|
||||
}
|
||||
@@ -70,6 +71,7 @@ void App::opening_restore_startup() {
|
||||
auto checkpoint = data.at("state");
|
||||
checkpoint["desktop"] = data.at("desktop");
|
||||
const auto layout = demo->load_data(std::move(checkpoint), false);
|
||||
if(demo->snapshot().state.value("career",Json::object()).value("ended",false))return;
|
||||
const auto flow = demo->snapshot().state.at("opening_flow");
|
||||
if (!flow.at("created").get<bool>() || flow.at("phase") == "done")
|
||||
return;
|
||||
@@ -211,6 +213,11 @@ void App::handle_event(SDL_Event &event) {
|
||||
opening_change("pause");
|
||||
}
|
||||
resize();
|
||||
if(event.window.event==SDL_WINDOWEVENT_SIZE_CHANGED || event.window.event==SDL_WINDOWEVENT_RESIZED || event.window.event==SDL_WINDOWEVENT_DISPLAY_CHANGED){
|
||||
// resize() already uses the drawable size. The SDL2 Rml backend would
|
||||
// replace it with logical event dimensions on SIZE_CHANGED.
|
||||
dirty_=true;return;
|
||||
}
|
||||
}
|
||||
int w, h, pw, ph;
|
||||
SDL_GetWindowSize(video_.window, &w, &h);
|
||||
|
||||
@@ -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>" +
|
||||
|
||||
@@ -56,7 +56,7 @@ std::string App::render_environment() {
|
||||
out += "<div class=\"environment-emblem\"><div class=\"environment-ball\">" +
|
||||
img("art.environment-ball-v1.png", 400, 400, false, false, 640) + "</div>";
|
||||
const auto &managers = snapshot.state.at("managers");
|
||||
const auto managed = managers.is_array() && !managers.empty() ? managers[0].value("club", "") : "";
|
||||
const auto managed = managers.is_array() && !managers.empty() ? demo_career_manager(snapshot.state).value("club", "") : "";
|
||||
const auto *club = snapshot.world->find("clubs", managed);
|
||||
out += "<div class=\"environment-crest\" aria-label=\"" + esc(club ? snapshot.world->name(*club) : "Vereinswappen nicht verfügbar") + "\">" +
|
||||
(club ? img(club->value("crest", ""), 162, 162, true) : "<span>—</span>") + "</div></div></div>";
|
||||
|
||||
@@ -38,13 +38,13 @@ std::string App::files_details(bool layouts, bool save) {
|
||||
const auto data = fresh ? snap().state : files_entry_->data;
|
||||
const auto meta = DemoFiles::career_metadata(data);
|
||||
const auto &managers = meta.at("managers");
|
||||
const Json *own = managers.empty() ? nullptr : world_->find("clubs", managers.at(0).value("club", ""));
|
||||
out = "<div class=\"files-detail-heading\"><div class=\"files-crest\">" + crest(own, 108) + "</div><div><p>" + std::string(fresh ? "Aktuelles Spiel" : "Gespeicherter Spielstand") + "</p><h2>" + esc(fresh ? "Neuer Speicherstand" : files_entry_->name) + "</h2><span>" + esc(own ? world_->name(*own) : "") + "</span></div></div>";
|
||||
const Json *own = managers.empty() ? nullptr : world_->find("clubs", meta.at("current_manager").value("club", ""));
|
||||
out = "<div class=\"files-detail-heading\"><div class=\"files-crest\">" + (meta.at("role")=="national"?img("career.national-de",108,108,false,false,256):crest(own,108)) + "</div><div><p>" + std::string(fresh ? "Aktuelles Spiel" : "Gespeicherter Spielstand") + "</p><h2>" + esc(fresh ? "Neuer Speicherstand" : files_entry_->name) + "</h2><span>" + esc(meta.at("role")=="national"?"Deutschland":own ? world_->name(*own) : "") + "</span></div></div>";
|
||||
if (fresh) out += input();
|
||||
out += "<div class=\"files-metadata\">";
|
||||
const auto iso_date = meta.at("date").get<std::string>();
|
||||
const auto display_date = iso_date.substr(8, 2) + "." + iso_date.substr(5, 2) + "." + iso_date.substr(0, 4);
|
||||
const std::vector<std::pair<std::string, std::string>> cells = {{"Saison", meta.at("season")}, {"Spieltag", meta.at("matchday")}, {"Spieldatum", display_date}, {"Spieler", std::to_string(managers.size())}};
|
||||
const std::vector<std::pair<std::string, std::string>> cells = {{"Saison", meta.at("season")}, {"Spieltag", meta.at("matchday")}, {"Spieldatum", display_date}, {"Spieler", std::to_string(meta.at("human_count").get<size_t>())}};
|
||||
for (const auto &[label, value] : cells) out += "<div class=\"files-metadata-cell\"><span>" + esc(label) + "</span><strong>" + esc(value) + "</strong></div>";
|
||||
out += "</div><section class=\"files-managers\"><h3>Mitspieler</h3>";
|
||||
for (const auto &manager : managers) {
|
||||
|
||||
@@ -35,7 +35,7 @@ std::string App::main_menu() {
|
||||
{"exit", "Beenden"}}};
|
||||
for (const auto &[key, title] : actions) {
|
||||
const bool network = std::string(key) == "network",
|
||||
disabled = scene_ != "main" || network ||
|
||||
disabled = scene_ != "main" || !menu_.empty() || network ||
|
||||
(std::string(key) == "new" && !available &&
|
||||
!(front_external_override_ && world_));
|
||||
out += btn(key,
|
||||
|
||||
+392
-161
@@ -1,198 +1,429 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
void App::cancel_lineup_drag(bool refresh_view) {
|
||||
lineup_drag_=Json(); lineup_drag_world_.reset(); lineup_drag_revision_=0;
|
||||
if (auto *ghost=element("lineup-ghost")) ghost->SetProperty("display","none");
|
||||
if (refresh_view) refresh();
|
||||
lineup_drag_ = Json();
|
||||
lineup_drag_world_.reset();
|
||||
lineup_drag_revision_ = 0;
|
||||
if (auto *ghost = element("lineup-ghost"))
|
||||
ghost->SetProperty("display", "none");
|
||||
if (refresh_view)
|
||||
refresh();
|
||||
}
|
||||
bool App::lineup_action(const std::string &action,Rml::Element *target) {
|
||||
if (!action.starts_with("lineup-") || menu_!="lineup") return false;
|
||||
if (!source_ || !target || !popup_.empty() || amount_ || !report_detail_kind_.empty()) return true;
|
||||
if (lineup_ignore_click_ && action=="lineup-player") {lineup_ignore_click_=false;return true;}
|
||||
const auto id=target->GetAttribute<Rml::String>("data-id","");
|
||||
const auto s=snap();
|
||||
if (!s.world || !valid_demo_lineup(s.state,*s.world,lineup_managed(s))) return true;
|
||||
const auto &l=s.state.at("lineup");
|
||||
const auto parse_index=[&](int maximum)->int {return id.size()==1 && id[0]>='0' && id[0]<='0'+maximum ? id[0]-'0':-1;};
|
||||
const auto commit=[&](const Json &payload,const std::string &focus) {
|
||||
const auto result=source_->apply({s.revision,"lineup",payload});
|
||||
if (!result.ok) {message("Die Aufstellung konnte nicht übernommen werden. Bitte die Ansicht erneut öffnen.");return false;}
|
||||
focus_after_render_=focus; refresh(); return true;
|
||||
};
|
||||
const auto player_focus=[&](const std::string &p) {
|
||||
const int slot=lineup_slot(l,p);
|
||||
return std::string(lineup_pitch_ && slot<11?"lineup-player-":"lineup-name-")+p;
|
||||
};
|
||||
if (action=="lineup-player") {
|
||||
if (lineup_slot(l,id)<0) return true;
|
||||
if (lineup_selected_==id) lineup_selected_.clear();
|
||||
else if (!lineup_selected_.empty()) {
|
||||
const auto selected=lineup_selected_; lineup_selected_.clear();
|
||||
const int destination=lineup_slot(l,selected);
|
||||
const auto focus=std::string(lineup_pitch_ && destination<11?"lineup-player-":"lineup-name-")+id;
|
||||
commit({{"kind","swap"},{"a",selected},{"b",id}},focus); return true;
|
||||
} else lineup_selected_=id;
|
||||
focus_after_render_=player_focus(id); refresh(); return true;
|
||||
}
|
||||
if (action=="lineup-data") {lineup_data_=1-lineup_data_;focus_after_render_="lineup-data";refresh();return true;}
|
||||
if (action=="lineup-view") {cancel_lineup_drag(false);lineup_pitch_=!lineup_pitch_;lineup_reset_scroll_=true;focus_after_render_="lineup-view";refresh();return true;}
|
||||
if (action=="lineup-side") {
|
||||
if (id=="formations" || id=="orders" || id=="takers") {lineup_side_=id;focus_after_render_="lineup-side-"+id;refresh();}
|
||||
bool App::lineup_action(const std::string &action, Rml::Element *target) {
|
||||
if (!action.starts_with("lineup-") || menu_ != "lineup")
|
||||
return false;
|
||||
if (!source_ || !target || !popup_.empty() || amount_ ||
|
||||
!report_detail_kind_.empty())
|
||||
return true;
|
||||
if (action == "lineup-surface") {
|
||||
const auto surface =
|
||||
target ? target->GetAttribute<Rml::String>("data-id", "") : "";
|
||||
if (apply("career", {{"kind", "surface"}, {"value", surface}})) {
|
||||
lineup_selected_.clear();
|
||||
focus_after_render_ = "lineup-surface-" + surface;
|
||||
refresh();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (lineup_ignore_click_ && action == "lineup-player") {
|
||||
lineup_ignore_click_ = false;
|
||||
return true;
|
||||
}
|
||||
const auto id = target->GetAttribute<Rml::String>("data-id", "");
|
||||
const auto s = snap();
|
||||
if (!s.world || !valid_demo_lineup(s.state, *s.world, lineup_managed(s)))
|
||||
return true;
|
||||
const auto &l = demo_lineup_visible(s.state);
|
||||
const int field_count = demo_career_field_count(s.state);
|
||||
const auto parse_index = [&](int maximum) -> int {
|
||||
return id.size() == 1 && id[0] >= '0' && id[0] <= '0' + maximum
|
||||
? id[0] - '0'
|
||||
: -1;
|
||||
};
|
||||
const auto commit = [&](const Json &payload, const std::string &focus) {
|
||||
const auto result = source_->apply({s.revision, "lineup", payload});
|
||||
if (!result.ok) {
|
||||
message("Die Aufstellung konnte nicht übernommen werden. Bitte die "
|
||||
"Ansicht erneut öffnen.");
|
||||
return false;
|
||||
}
|
||||
focus_after_render_ = focus;
|
||||
refresh();
|
||||
return true;
|
||||
};
|
||||
const auto player_focus = [&](const std::string &p) {
|
||||
const int slot = lineup_slot(l, p);
|
||||
return std::string(lineup_pitch_ && slot < field_count ? "lineup-player-"
|
||||
: "lineup-name-") +
|
||||
p;
|
||||
};
|
||||
if (action == "lineup-player") {
|
||||
if (lineup_slot(l, id) < 0)
|
||||
return true;
|
||||
if (lineup_selected_ == id)
|
||||
lineup_selected_.clear();
|
||||
else if (!lineup_selected_.empty()) {
|
||||
const auto selected = lineup_selected_;
|
||||
lineup_selected_.clear();
|
||||
const int destination = lineup_slot(l, selected);
|
||||
const auto focus = std::string(lineup_pitch_ && destination < field_count
|
||||
? "lineup-player-"
|
||||
: "lineup-name-") +
|
||||
id;
|
||||
commit({{"kind", "swap"}, {"a", selected}, {"b", id}}, focus);
|
||||
return true;
|
||||
} else
|
||||
lineup_selected_ = id;
|
||||
focus_after_render_ = player_focus(id);
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "lineup-data") {
|
||||
lineup_data_ = 1 - lineup_data_;
|
||||
focus_after_render_ = "lineup-data";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "lineup-view") {
|
||||
cancel_lineup_drag(false);
|
||||
lineup_pitch_ = !lineup_pitch_;
|
||||
lineup_reset_scroll_ = true;
|
||||
focus_after_render_ = "lineup-view";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "lineup-side") {
|
||||
if (id == "formations" || id == "orders" || id == "takers") {
|
||||
lineup_side_ = id;
|
||||
focus_after_render_ = "lineup-side-" + id;
|
||||
refresh();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (action == "lineup-page") {
|
||||
const int n = parse_index(1);
|
||||
if (n >= 0) {
|
||||
lineup_page_ = n;
|
||||
focus_after_render_ = n ? "lineup-page-prev" : "lineup-page-next";
|
||||
refresh();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (action == "lineup-formation") {
|
||||
const int n = parse_index(7);
|
||||
if (n >= 0) {
|
||||
lineup_selected_.clear();
|
||||
commit({{"kind", "formation"}, {"value", n}}, "lineup-formation-" + id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (action == "lineup-save") {
|
||||
const int n = parse_index(3);
|
||||
if (n >= 0)
|
||||
commit({{"kind", "custom-save"}, {"index", n}}, "lineup-save-" + id);
|
||||
return true;
|
||||
}
|
||||
if (action == "lineup-weight") {
|
||||
const int n = parse_index(2);
|
||||
if (n >= 0)
|
||||
commit({{"kind", "weight"}, {"index", n}}, "lineup-weight-" + id);
|
||||
return true;
|
||||
}
|
||||
if (action == "lineup-auto") {
|
||||
commit({{"kind", "takers-auto"}}, "lineup-auto");
|
||||
return true;
|
||||
}
|
||||
if (action=="lineup-page") {const int n=parse_index(1);if(n>=0) {lineup_page_=n;focus_after_render_=n?"lineup-page-prev":"lineup-page-next";refresh();}return true;}
|
||||
if (action=="lineup-formation") {const int n=parse_index(7);if(n>=0) {lineup_selected_.clear();commit({{"kind","formation"},{"value",n}},"lineup-formation-"+id);}return true;}
|
||||
if (action=="lineup-save") {const int n=parse_index(3);if(n>=0)commit({{"kind","custom-save"},{"index",n}},"lineup-save-"+id);return true;}
|
||||
if (action=="lineup-weight") {const int n=parse_index(2);if(n>=0)commit({{"kind","weight"},{"index",n}},"lineup-weight-"+id);return true;}
|
||||
if (action=="lineup-auto") {commit({{"kind","takers-auto"}},"lineup-auto");return true;}
|
||||
return true;
|
||||
}
|
||||
bool App::lineup_event(Rml::Event &event) {
|
||||
if (menu_!="lineup" || !source_ || !popup_.empty() || amount_ || !report_detail_kind_.empty()) return false;
|
||||
const auto type=event.GetType();
|
||||
auto *target=event.GetTargetElement();
|
||||
const auto ancestor=[&](const std::string &attribute)->Rml::Element* {
|
||||
for(auto *n=target;n && n!=doc_;n=n->GetParentNode()) if(n->HasAttribute(attribute))return n;
|
||||
if (menu_ != "lineup" || !source_ || !popup_.empty() || amount_ ||
|
||||
!report_detail_kind_.empty())
|
||||
return false;
|
||||
const auto type = event.GetType();
|
||||
auto *target = event.GetTargetElement();
|
||||
const auto ancestor = [&](const std::string &attribute) -> Rml::Element * {
|
||||
for (auto *n = target; n && n != doc_; n = n->GetParentNode())
|
||||
if (n->HasAttribute(attribute))
|
||||
return n;
|
||||
return nullptr;
|
||||
};
|
||||
auto *player_node=ancestor("data-squad-player");
|
||||
auto *pitch=element("lineup-pitch");
|
||||
const auto s=snap();
|
||||
if (!s.world || !valid_demo_lineup(s.state,*s.world,lineup_managed(s))) {cancel_lineup_drag(false);return false;}
|
||||
const auto &l=s.state.at("lineup");
|
||||
const auto stop=[&]() {event.StopImmediatePropagation();};
|
||||
const auto commit=[&](const Json &payload,uint64_t revision) {
|
||||
const auto result=source_->apply({revision,"lineup",payload});
|
||||
if(!result.ok)message("Die Aufstellung hat sich geändert. Bitte den Spieler erneut auswählen.");
|
||||
auto *player_node = ancestor("data-squad-player");
|
||||
auto *pitch = element("lineup-pitch");
|
||||
const auto s = snap();
|
||||
if (!s.world || !valid_demo_lineup(s.state, *s.world, lineup_managed(s))) {
|
||||
cancel_lineup_drag(false);
|
||||
return false;
|
||||
}
|
||||
const auto &l = demo_lineup_visible(s.state);
|
||||
const int field_count = demo_career_field_count(s.state);
|
||||
const auto stop = [&]() { event.StopImmediatePropagation(); };
|
||||
const auto commit = [&](const Json &payload, uint64_t revision) {
|
||||
const auto result = source_->apply({revision, "lineup", payload});
|
||||
if (!result.ok)
|
||||
message("Die Aufstellung hat sich geändert. Bitte den Spieler erneut "
|
||||
"auswählen.");
|
||||
return result.ok;
|
||||
};
|
||||
const auto point=[&](float x,float y)->Json {
|
||||
if(!pitch)return Json();
|
||||
const auto origin=pitch->GetAbsoluteOffset(Rml::BoxArea::Border), size=pitch->GetBox().GetSize(Rml::BoxArea::Border);
|
||||
if(size.x<=0 || size.y<=0)return Json();
|
||||
return Json::array({std::clamp(int(std::round(((x-origin.x)/size.x*100-8)/84*18)),0,18),std::clamp(int(std::round(((y-origin.y)/size.y*100-10)/80*8)),0,8)});
|
||||
const auto point = [&](float x, float y) -> Json {
|
||||
if (!pitch)
|
||||
return Json();
|
||||
const auto origin = pitch->GetAbsoluteOffset(Rml::BoxArea::Border),
|
||||
size = pitch->GetBox().GetSize(Rml::BoxArea::Border);
|
||||
if (size.x <= 0 || size.y <= 0)
|
||||
return Json();
|
||||
return Json::array(
|
||||
{std::clamp(
|
||||
int(std::round(((x - origin.x) / size.x * 100 - 8) / 84 * 18)), 0,
|
||||
18),
|
||||
std::clamp(
|
||||
int(std::round(((y - origin.y) / size.y * 100 - 10) / 80 * 8)), 0,
|
||||
8)});
|
||||
};
|
||||
const auto in_pitch=[&](float x,float y) {
|
||||
if(!pitch)return false;
|
||||
const auto origin=pitch->GetAbsoluteOffset(Rml::BoxArea::Border), size=pitch->GetBox().GetSize(Rml::BoxArea::Border);
|
||||
return x>=origin.x && y>=origin.y && x<=origin.x+size.x && y<=origin.y+size.y;
|
||||
const auto in_pitch = [&](float x, float y) {
|
||||
if (!pitch)
|
||||
return false;
|
||||
const auto origin = pitch->GetAbsoluteOffset(Rml::BoxArea::Border),
|
||||
size = pitch->GetBox().GetSize(Rml::BoxArea::Border);
|
||||
return x >= origin.x && y >= origin.y && x <= origin.x + size.x &&
|
||||
y <= origin.y + size.y;
|
||||
};
|
||||
const float mx=event.GetParameter<float>("mouse_x",0),my=event.GetParameter<float>("mouse_y",0);
|
||||
if(type=="keydown") {
|
||||
lineup_ignore_click_=false;
|
||||
const auto key=Rml::Input::KeyIdentifier(event.GetParameter<int>("key_identifier",0));
|
||||
if(key==Rml::Input::KI_ESCAPE) {
|
||||
for(auto *n=target;n && n!=doc_;n=n->GetParentNode())
|
||||
if(auto *select=dynamic_cast<Rml::ElementFormControlSelect*>(n);select && select->IsSelectBoxVisible())return false;
|
||||
if(!lineup_drag_.is_null()) {cancel_lineup_drag(true);stop();return true;}
|
||||
if(!lineup_selected_.empty()) {lineup_selected_.clear();refresh();stop();return true;}
|
||||
const float mx = event.GetParameter<float>("mouse_x", 0),
|
||||
my = event.GetParameter<float>("mouse_y", 0);
|
||||
if (type == "keydown") {
|
||||
lineup_ignore_click_ = false;
|
||||
const auto key =
|
||||
Rml::Input::KeyIdentifier(event.GetParameter<int>("key_identifier", 0));
|
||||
if (key == Rml::Input::KI_ESCAPE) {
|
||||
for (auto *n = target; n && n != doc_; n = n->GetParentNode())
|
||||
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(n);
|
||||
select && select->IsSelectBoxVisible())
|
||||
return false;
|
||||
if (!lineup_drag_.is_null()) {
|
||||
cancel_lineup_drag(true);
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
if (!lineup_selected_.empty()) {
|
||||
lineup_selected_.clear();
|
||||
refresh();
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(pitch && player_node && player_node->IsClassSet("lineup-player") && (key==Rml::Input::KI_LEFT || key==Rml::Input::KI_RIGHT || key==Rml::Input::KI_UP || key==Rml::Input::KI_DOWN)) {
|
||||
const auto id=player_node->GetAttribute<Rml::String>("data-squad-player","");
|
||||
const int slot=lineup_slot(l,id);
|
||||
if(slot>=0 && slot<11) {
|
||||
auto p=l.at("points")[size_t(slot)];
|
||||
p[0]=std::clamp(p[0].get<int>()+(key==Rml::Input::KI_RIGHT?1:key==Rml::Input::KI_LEFT?-1:0),0,18);
|
||||
p[1]=std::clamp(p[1].get<int>()+(key==Rml::Input::KI_DOWN?1:key==Rml::Input::KI_UP?-1:0),0,8);
|
||||
lineup_selected_=id;commit({{"kind","move"},{"player",id},{"point",p}},s.revision);
|
||||
focus_after_render_="lineup-player-"+id;refresh();stop();return true;
|
||||
if (pitch && player_node && player_node->IsClassSet("lineup-player") &&
|
||||
(key == Rml::Input::KI_LEFT || key == Rml::Input::KI_RIGHT ||
|
||||
key == Rml::Input::KI_UP || key == Rml::Input::KI_DOWN)) {
|
||||
const auto id =
|
||||
player_node->GetAttribute<Rml::String>("data-squad-player", "");
|
||||
const int slot = lineup_slot(l, id);
|
||||
if (slot >= 0 && slot < field_count) {
|
||||
auto p = l.at("points")[size_t(slot)];
|
||||
p[0] = std::clamp(p[0].get<int>() + (key == Rml::Input::KI_RIGHT ? 1
|
||||
: key == Rml::Input::KI_LEFT ? -1
|
||||
: 0),
|
||||
0, 18);
|
||||
p[1] = std::clamp(p[1].get<int>() + (key == Rml::Input::KI_DOWN ? 1
|
||||
: key == Rml::Input::KI_UP ? -1
|
||||
: 0),
|
||||
0, 8);
|
||||
lineup_selected_ = id;
|
||||
commit({{"kind", "move"}, {"player", id}, {"point", p}}, s.revision);
|
||||
focus_after_render_ = "lineup-player-" + id;
|
||||
refresh();
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if((type=="change" || type=="input") && target) {
|
||||
if(auto *control=dynamic_cast<Rml::ElementFormControl*>(target)) {
|
||||
if(target->HasAttribute("data-lineup-taker")) {
|
||||
const auto index=target->GetAttribute<Rml::String>("data-lineup-taker","");
|
||||
if(index.size()!=1 || index[0]<'0' || index[0]>'2')return true;
|
||||
const auto value=control->GetValue(); const int i=index[0]-'0';
|
||||
if(l.at("takers")[size_t(i)]!=value) {commit({{"kind","taker"},{"index",i},{"player",value}},s.revision);focus_after_render_=target->GetId();refresh();}
|
||||
stop();return true;
|
||||
}
|
||||
if(target->HasAttribute("data-lineup-order")) {
|
||||
const auto index=target->GetAttribute<Rml::String>("data-lineup-order","");
|
||||
const auto id=target->GetAttribute<Rml::String>("data-player","");
|
||||
const auto text=control->GetValue();
|
||||
// RmlUI ranges format whole steps as "%f" (for example "22.000000").
|
||||
// Accept that complete representation without rounding fractional input.
|
||||
const auto dot=text.find('.');
|
||||
const auto whole=text.substr(0,dot);
|
||||
const bool whole_fraction=dot==std::string::npos ||
|
||||
(dot+1<text.size() && std::all_of(text.begin()+dot+1,text.end(),[](char c){return c=='0';}));
|
||||
if(index.size()!=1 || index[0]<'0' || index[0]>'3' || whole.empty() || whole.size()>2 || !whole_fraction || std::any_of(whole.begin(),whole.end(),[](char c){return c<'0'||c>'9';}))return true;
|
||||
const int value=std::stoi(whole),i=index[0]-'0';
|
||||
if(value<2 || value>40 || lineup_slot(l,id)<0 || lineup_slot(l,id)>=11)return true;
|
||||
if(l.at("orders").at(id)[size_t(i)]!=value && commit({{"kind","order"},{"player",id},{"index",i},{"value",value}},s.revision)) {
|
||||
if(auto *output=element("lineup-order-value-"+index))output->SetInnerRML(std::to_string(value));
|
||||
if(auto *zone=element("lineup-zone")) {
|
||||
const auto now=snap();
|
||||
zone->SetInnerRML(picture(renderer_.diagram("lineup-zone",lineup_zone(now.state.at("lineup"),id),lineup_pitch_raster_px),lineup_art_width_dp,lineup_art_height_dp));
|
||||
}
|
||||
dirty_=true;
|
||||
if ((type == "change" || type == "input") && target) {
|
||||
if (auto *control = dynamic_cast<Rml::ElementFormControl *>(target)) {
|
||||
if (target->HasAttribute("data-lineup-taker")) {
|
||||
const auto index =
|
||||
target->GetAttribute<Rml::String>("data-lineup-taker", "");
|
||||
if (index.size() != 1 || index[0] < '0' || index[0] > '2')
|
||||
return true;
|
||||
const auto value = control->GetValue();
|
||||
const int i = index[0] - '0';
|
||||
if (l.at("takers")[size_t(i)] != value) {
|
||||
commit({{"kind", "taker"}, {"index", i}, {"player", value}},
|
||||
s.revision);
|
||||
focus_after_render_ = target->GetId();
|
||||
refresh();
|
||||
}
|
||||
stop();return true;
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
if (target->HasAttribute("data-lineup-order")) {
|
||||
const auto index =
|
||||
target->GetAttribute<Rml::String>("data-lineup-order", "");
|
||||
const auto id = target->GetAttribute<Rml::String>("data-player", "");
|
||||
const auto text = control->GetValue();
|
||||
// RmlUI ranges format whole steps as "%f" (for example "22.000000").
|
||||
// Accept that complete representation without rounding fractional
|
||||
// input.
|
||||
const auto dot = text.find('.');
|
||||
const auto whole = text.substr(0, dot);
|
||||
const bool whole_fraction =
|
||||
dot == std::string::npos ||
|
||||
(dot + 1 < text.size() &&
|
||||
std::all_of(text.begin() + dot + 1, text.end(),
|
||||
[](char c) { return c == '0'; }));
|
||||
if (index.size() != 1 || index[0] < '0' || index[0] > '3' ||
|
||||
whole.empty() || whole.size() > 2 || !whole_fraction ||
|
||||
std::any_of(whole.begin(), whole.end(),
|
||||
[](char c) { return c < '0' || c > '9'; }))
|
||||
return true;
|
||||
const int value = std::stoi(whole), i = index[0] - '0';
|
||||
if (value < 2 || value > 40 || lineup_slot(l, id) < 0 ||
|
||||
lineup_slot(l, id) >= field_count)
|
||||
return true;
|
||||
if (l.at("orders").at(id)[size_t(i)] != value &&
|
||||
commit({{"kind", "order"},
|
||||
{"player", id},
|
||||
{"index", i},
|
||||
{"value", value}},
|
||||
s.revision)) {
|
||||
if (auto *output = element("lineup-order-value-" + index))
|
||||
output->SetInnerRML(std::to_string(value));
|
||||
if (auto *zone = element("lineup-zone")) {
|
||||
const auto now = snap();
|
||||
zone->SetInnerRML(
|
||||
picture(renderer_.diagram(
|
||||
"lineup-zone",
|
||||
lineup_zone(demo_lineup_visible(now.state), id),
|
||||
lineup_pitch_raster_px),
|
||||
lineup_art_width_dp, lineup_art_height_dp));
|
||||
}
|
||||
dirty_ = true;
|
||||
}
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(type=="mousedown" && event.GetParameter<int>("button",0)==0) {
|
||||
lineup_ignore_click_=false;
|
||||
if(pitch && player_node) {
|
||||
const auto id=player_node->GetAttribute<Rml::String>("data-squad-player","");const int slot=lineup_slot(l,id);
|
||||
if(slot>=0) {lineup_drag_={{"player",id},{"club",lineup_managed(s)},{"source_slot",slot},{"start_x",mx},{"start_y",my},{"ghost",point(mx,my)},{"moved",false}};lineup_drag_revision_=s.revision;lineup_drag_world_=s.world;}
|
||||
if (type == "mousedown" && event.GetParameter<int>("button", 0) == 0) {
|
||||
lineup_ignore_click_ = false;
|
||||
if (pitch && player_node) {
|
||||
const auto id =
|
||||
player_node->GetAttribute<Rml::String>("data-squad-player", "");
|
||||
const int slot = lineup_slot(l, id);
|
||||
if (slot >= 0) {
|
||||
lineup_drag_ = {{"player", id}, {"club", lineup_managed(s)},
|
||||
{"source_slot", slot}, {"start_x", mx},
|
||||
{"start_y", my}, {"ghost", point(mx, my)},
|
||||
{"moved", false}};
|
||||
lineup_drag_revision_ = s.revision;
|
||||
lineup_drag_world_ = s.world;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(type=="mousemove" && lineup_drag_.is_object()) {
|
||||
if(!lineup_drag_.value("moved",false) && std::hypot(mx-lineup_drag_.at("start_x").get<float>(),my-lineup_drag_.at("start_y").get<float>())<5)return false;
|
||||
lineup_drag_["moved"]=true;
|
||||
const auto p=point(mx,my);lineup_drag_["ghost"]=p;
|
||||
if(p.is_array())if(auto *ghost=element("lineup-ghost")) {
|
||||
ghost->SetProperty("display","block");
|
||||
ghost->SetProperty("left",scalar((8+p[0].get<int>()/18.0*84)*lineup_art_width_dp/100-lineup_player_anchor_x_dp)+"dp");
|
||||
ghost->SetProperty("top",scalar((10+p[1].get<int>()/8.0*80)*lineup_art_height_dp/100-lineup_player_anchor_y_dp)+"dp");
|
||||
dirty_=true;
|
||||
}
|
||||
stop();return true;
|
||||
if (type == "mousemove" && lineup_drag_.is_object()) {
|
||||
if (!lineup_drag_.value("moved", false) &&
|
||||
std::hypot(mx - lineup_drag_.at("start_x").get<float>(),
|
||||
my - lineup_drag_.at("start_y").get<float>()) < 5)
|
||||
return false;
|
||||
lineup_drag_["moved"] = true;
|
||||
const auto p = point(mx, my);
|
||||
lineup_drag_["ghost"] = p;
|
||||
if (p.is_array())
|
||||
if (auto *ghost = element("lineup-ghost")) {
|
||||
ghost->SetProperty("display", "block");
|
||||
ghost->SetProperty("left", scalar((8 + p[0].get<int>() / 18.0 * 84) *
|
||||
lineup_art_width_dp / 100 -
|
||||
lineup_player_anchor_x_dp) +
|
||||
"dp");
|
||||
ghost->SetProperty("top", scalar((10 + p[1].get<int>() / 8.0 * 80) *
|
||||
lineup_art_height_dp / 100 -
|
||||
lineup_player_anchor_y_dp) +
|
||||
"dp");
|
||||
dirty_ = true;
|
||||
}
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
if(type=="mouseup" && lineup_drag_.is_object()) {
|
||||
const auto drag=lineup_drag_; const auto revision=lineup_drag_revision_;const auto world=lineup_drag_world_;
|
||||
const bool moved=drag.value("moved",false);cancel_lineup_drag(false);
|
||||
if(!moved)return false;
|
||||
lineup_ignore_click_=true;
|
||||
const auto id=drag.at("player").get<std::string>();
|
||||
if(s.world!=world || s.revision!=revision || lineup_managed(s)!=drag.at("club").get<std::string>() || lineup_slot(l,id)!=drag.at("source_slot").get<int>()) {
|
||||
message("Die Aufstellung hat sich geändert. Bitte den Spieler erneut auswählen.");stop();return true;
|
||||
if (type == "mouseup" && lineup_drag_.is_object()) {
|
||||
const auto drag = lineup_drag_;
|
||||
const auto revision = lineup_drag_revision_;
|
||||
const auto world = lineup_drag_world_;
|
||||
const bool moved = drag.value("moved", false);
|
||||
cancel_lineup_drag(false);
|
||||
if (!moved)
|
||||
return false;
|
||||
lineup_ignore_click_ = true;
|
||||
const auto id = drag.at("player").get<std::string>();
|
||||
if (s.world != world || s.revision != revision ||
|
||||
lineup_managed(s) != drag.at("club").get<std::string>() ||
|
||||
lineup_slot(l, id) != drag.at("source_slot").get<int>()) {
|
||||
message("Die Aufstellung hat sich geändert. Bitte den Spieler erneut "
|
||||
"auswählen.");
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
// Resolve the physical drop target independently of the active mouse
|
||||
// element: Rml may continue dispatching mouseup to the drag origin.
|
||||
std::string drop;
|
||||
for(auto *n=context_->GetElementAtPoint({mx,my});n && n!=doc_;n=n->GetParentNode()) {
|
||||
if(n->HasAttribute("data-squad-player")) {drop=n->GetAttribute<Rml::String>("data-squad-player","");break;}
|
||||
}
|
||||
const int drop_slot=lineup_slot(l,drop);
|
||||
if(drop_slot>=0 && drop!=id) {
|
||||
commit({{"kind","swap"},{"a",id},{"b",drop}},revision);
|
||||
lineup_selected_.clear();
|
||||
focus_after_render_=std::string(drop_slot<11?"lineup-player-":"lineup-name-")+id;
|
||||
} else if(drop_slot<0 && in_pitch(mx,my)) {
|
||||
const int slot=lineup_slot(l,id); const auto p=point(mx,my);
|
||||
if(slot<11) {lineup_selected_=id;commit({{"kind","move"},{"player",id},{"point",p}},revision);}
|
||||
else {
|
||||
const auto &points=l.at("points");const auto hit=std::find(points.begin(),points.end(),p);const int n=int(hit-points.begin());
|
||||
if(n<int(std::min(size_t(11),l.at("order").size()))) {commit({{"kind","swap"},{"a",id},{"b",l.at("order")[size_t(n)]}},revision);lineup_selected_.clear();}
|
||||
else lineup_selected_=id;
|
||||
for (auto *n = context_->GetElementAtPoint({mx, my}); n && n != doc_;
|
||||
n = n->GetParentNode()) {
|
||||
if (n->HasAttribute("data-squad-player")) {
|
||||
drop = n->GetAttribute<Rml::String>("data-squad-player", "");
|
||||
break;
|
||||
}
|
||||
focus_after_render_="lineup-player-"+id;
|
||||
}
|
||||
refresh();stop();return true;
|
||||
const int drop_slot = lineup_slot(l, drop);
|
||||
if (drop_slot >= 0 && drop != id) {
|
||||
commit({{"kind", "swap"}, {"a", id}, {"b", drop}}, revision);
|
||||
lineup_selected_.clear();
|
||||
focus_after_render_ =
|
||||
std::string(drop_slot < field_count ? "lineup-player-"
|
||||
: "lineup-name-") +
|
||||
id;
|
||||
} else if (drop_slot < 0 && in_pitch(mx, my)) {
|
||||
const int slot = lineup_slot(l, id);
|
||||
const auto p = point(mx, my);
|
||||
if (slot < field_count) {
|
||||
lineup_selected_ = id;
|
||||
commit({{"kind", "move"}, {"player", id}, {"point", p}}, revision);
|
||||
} else {
|
||||
const auto &points = l.at("points");
|
||||
const auto hit = std::find(points.begin(), points.end(), p);
|
||||
const int n = int(hit - points.begin());
|
||||
if (n < int(std::min(size_t(field_count), l.at("order").size()))) {
|
||||
commit({{"kind", "swap"}, {"a", id}, {"b", l.at("order")[size_t(n)]}},
|
||||
revision);
|
||||
lineup_selected_.clear();
|
||||
} else
|
||||
lineup_selected_ = id;
|
||||
}
|
||||
focus_after_render_ = "lineup-player-" + id;
|
||||
}
|
||||
refresh();
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
if(type=="click" && lineup_ignore_click_) {lineup_ignore_click_=false;stop();return true;}
|
||||
if(type=="click" && pitch && !player_node && !lineup_selected_.empty()) {
|
||||
bool inside=false;for(auto *n=target;n && n!=doc_;n=n->GetParentNode())if(n==pitch)inside=true;
|
||||
if(inside) {
|
||||
const int slot=lineup_slot(l,lineup_selected_);
|
||||
if(slot>=0 && slot<11) {const auto id=lineup_selected_;commit({{"kind","move"},{"player",id},{"point",point(mx,my)}},s.revision);focus_after_render_="lineup-player-"+id;refresh();}
|
||||
else message("Einen Ersatzspieler auf einen Spieler der Startelf ziehen oder beide nacheinander anklicken.");
|
||||
stop();return true;
|
||||
if (type == "click" && lineup_ignore_click_) {
|
||||
lineup_ignore_click_ = false;
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
if (type == "click" && pitch && !player_node && !lineup_selected_.empty()) {
|
||||
bool inside = false;
|
||||
for (auto *n = target; n && n != doc_; n = n->GetParentNode())
|
||||
if (n == pitch)
|
||||
inside = true;
|
||||
if (inside) {
|
||||
const int slot = lineup_slot(l, lineup_selected_);
|
||||
if (slot >= 0 && slot < field_count) {
|
||||
const auto id = lineup_selected_;
|
||||
commit({{"kind", "move"}, {"player", id}, {"point", point(mx, my)}},
|
||||
s.revision);
|
||||
focus_after_render_ = "lineup-player-" + id;
|
||||
refresh();
|
||||
} else
|
||||
message("Einen Ersatzspieler auf einen Spieler der Startelf ziehen "
|
||||
"oder beide nacheinander anklicken.");
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
+491
-163
@@ -1,222 +1,550 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
namespace {
|
||||
// Shared with lineup_controls.inc: proportional outer pitch and its border-free art box.
|
||||
// Shared with lineup_controls.inc: proportional outer pitch and its border-free
|
||||
// art box.
|
||||
constexpr double lineup_roster_height_dp = 1216.0;
|
||||
constexpr double lineup_pitch_top_dp = 1256.0;
|
||||
constexpr double lineup_pitch_height_dp = 608.0;
|
||||
constexpr double lineup_pitch_width_dp = lineup_pitch_height_dp * 196.0 / 117.0;
|
||||
constexpr double lineup_pitch_border_dp = 2.0;
|
||||
constexpr double lineup_art_width_dp = lineup_pitch_width_dp - 2.0 * lineup_pitch_border_dp;
|
||||
constexpr double lineup_art_height_dp = lineup_pitch_height_dp - 2.0 * lineup_pitch_border_dp;
|
||||
constexpr double lineup_art_width_dp =
|
||||
lineup_pitch_width_dp - 2.0 * lineup_pitch_border_dp;
|
||||
constexpr double lineup_art_height_dp =
|
||||
lineup_pitch_height_dp - 2.0 * lineup_pitch_border_dp;
|
||||
constexpr double lineup_player_size_dp = 126.0 * lineup_pitch_width_dp / 1920.0;
|
||||
constexpr double lineup_player_anchor_x_dp = lineup_player_size_dp * 0.5;
|
||||
constexpr double lineup_player_anchor_y_dp = lineup_player_size_dp * 0.61;
|
||||
constexpr double lineup_controls_width_dp = 2612.0 - lineup_pitch_width_dp - 40.0;
|
||||
constexpr double lineup_formation_width_dp = (lineup_controls_width_dp - 18.0) / 2.0;
|
||||
constexpr double lineup_controls_width_dp =
|
||||
2612.0 - lineup_pitch_width_dp - 40.0;
|
||||
constexpr double lineup_formation_width_dp =
|
||||
(lineup_controls_width_dp - 18.0) / 2.0;
|
||||
constexpr double lineup_tools_width_dp = lineup_controls_width_dp - 16.0;
|
||||
constexpr double lineup_order_width_dp = (lineup_tools_width_dp - 40.0) / 2.0;
|
||||
constexpr double lineup_taker_width_dp = (lineup_tools_width_dp - 36.0) / 3.0;
|
||||
constexpr int lineup_pitch_raster_px = 2048;
|
||||
// Current demo follows the Classic German/Modern24-slot markers:11 start,6 bench.
|
||||
// This is not a universal match rule; a future session adapter supplies its DTO status.
|
||||
// See game/lineup.cpp DispatchLiveOverview and ui/lineup_tests.cpp fixture markers.
|
||||
// Current demo follows the Classic German/Modern24-slot markers:11 start,6
|
||||
// bench. This is not a universal match rule; a future session adapter supplies
|
||||
// its DTO status. See game/lineup.cpp DispatchLiveOverview and
|
||||
// ui/lineup_tests.cpp fixture markers.
|
||||
constexpr size_t lineup_start_limit = 11;
|
||||
constexpr size_t lineup_bench_limit = 6;
|
||||
std::string lineup_status(size_t slot) {
|
||||
return slot < lineup_start_limit ? "Startelf" :
|
||||
slot < lineup_start_limit + lineup_bench_limit ? "Ersatzbank" : "—";
|
||||
std::string lineup_status(size_t slot, bool indoor = false) {
|
||||
if (indoor)
|
||||
return slot < 6 ? "Hallen-Sechs" : slot < 11 ? "Wechselpaar" : "Reserve";
|
||||
return slot < lineup_start_limit ? "Startelf"
|
||||
: slot < lineup_start_limit + lineup_bench_limit ? "Ersatzbank"
|
||||
: "—";
|
||||
}
|
||||
std::string lineup_managed(const Snapshot &s) {
|
||||
const auto m = s.state.value("managers",Json::array());
|
||||
return m.is_array() && !m.empty() && m[0].is_object() ? m[0].value("club","") : "";
|
||||
return demo_career_manager(s.state).value("club", "");
|
||||
}
|
||||
std::string lineup_position(const Json &v) {
|
||||
if (!v.is_string()) return "—";
|
||||
if (!v.is_string())
|
||||
return "—";
|
||||
const auto code = v.get<std::string>();
|
||||
return code == "gk" ? "TW" : code == "def" ? "ABW" : code == "mid" ? "MIT" : code == "fwd" ? "STU" : code.empty() ? "—" : code;
|
||||
return code == "gk" ? "TW"
|
||||
: code == "def" ? "ABW"
|
||||
: code == "mid" ? "MIT"
|
||||
: code == "fwd" ? "STU"
|
||||
: code.empty() ? "—"
|
||||
: code;
|
||||
}
|
||||
std::string lineup_value(const Json &v) {
|
||||
if (!v.is_number()) return "—";
|
||||
if (v.is_number_integer()) return number(v.get<int64_t>());
|
||||
if (!std::isfinite(v.get<double>())) return "—";
|
||||
std::ostringstream out; out << std::setprecision(5) << v.get<double>();
|
||||
auto text = out.str(); std::replace(text.begin(),text.end(),'.',','); return text;
|
||||
if (!v.is_number())
|
||||
return "—";
|
||||
if (v.is_number_integer())
|
||||
return number(v.get<int64_t>());
|
||||
if (!std::isfinite(v.get<double>()))
|
||||
return "—";
|
||||
std::ostringstream out;
|
||||
out << std::setprecision(5) << v.get<double>();
|
||||
auto text = out.str();
|
||||
std::replace(text.begin(), text.end(), '.', ',');
|
||||
return text;
|
||||
}
|
||||
int lineup_slot(const Json &l, const std::string &id) {
|
||||
if (!l.is_object() || !l.contains("order") || !l.at("order").is_array()) return -1;
|
||||
const auto &a = l.at("order"); const auto p = std::find(a.begin(),a.end(),id);
|
||||
return p == a.end() ? -1 : int(p-a.begin());
|
||||
if (!l.is_object() || !l.contains("order") || !l.at("order").is_array())
|
||||
return -1;
|
||||
const auto &a = l.at("order");
|
||||
const auto p = std::find(a.begin(), a.end(), id);
|
||||
return p == a.end() ? -1 : int(p - a.begin());
|
||||
}
|
||||
std::string lineup_svg(const std::string &body, const std::string &box="0 0 120 72") {
|
||||
return "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\""+box+"\">"+body+"</svg>";
|
||||
std::string lineup_svg(const std::string &body,
|
||||
const std::string &box = "0 0 120 72") {
|
||||
return "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"" + box + "\">" +
|
||||
body + "</svg>";
|
||||
}
|
||||
std::string lineup_mini(const Json &points, const std::string &theme) {
|
||||
std::string lineup_mini(const Json &points, const std::string &theme,
|
||||
size_t limit = 11) {
|
||||
const auto line = theme == "silver" ? "#536f66" : "#c3e8cb";
|
||||
std::string body = "<g stroke=\""+std::string(line)+"\" stroke-width=\"1\" fill=\"none\"><path d=\"M2 2H118V70H2Z M60 2V70 M2 20H19V52H2 M118 20H101V52H118\"/><circle cx=\"60\" cy=\"36\" r=\"9\"/></g>";
|
||||
if (points.is_array()) for (const auto &p : points) {
|
||||
const int depth=p[0].get<int>(), lane=p[1].get<int>();
|
||||
const auto color = theme == "silver" ? (depth<7?"#85600c":depth<13?"#a46914":"#b44931") : (depth<7?"#ffdc69":depth<13?"#ecac4b":"#f07852");
|
||||
body += "<circle cx=\""+scalar(8+depth/18.0*104)+"\" cy=\""+scalar(8+lane/8.0*56)+"\" r=\"2.6\" fill=\""+color+"\"/>";
|
||||
}
|
||||
std::string body =
|
||||
"<g stroke=\"" + std::string(line) +
|
||||
"\" stroke-width=\"1\" fill=\"none\"><path d=\"M2 2H118V70H2Z M60 2V70 "
|
||||
"M2 20H19V52H2 M118 20H101V52H118\"/><circle cx=\"60\" cy=\"36\" "
|
||||
"r=\"9\"/></g>";
|
||||
if (points.is_array())
|
||||
for (size_t i = 0; i < std::min(limit, points.size()); ++i) {
|
||||
const auto &p = points[i];
|
||||
const int depth = p[0].get<int>(), lane = p[1].get<int>();
|
||||
const auto color = theme == "silver" ? (depth < 7 ? "#85600c"
|
||||
: depth < 13 ? "#a46914"
|
||||
: "#b44931")
|
||||
: (depth < 7 ? "#ffdc69"
|
||||
: depth < 13 ? "#ecac4b"
|
||||
: "#f07852");
|
||||
body += "<circle cx=\"" + scalar(8 + depth / 18.0 * 104) + "\" cy=\"" +
|
||||
scalar(8 + lane / 8.0 * 56) + "\" r=\"2.6\" fill=\"" + color +
|
||||
"\"/>";
|
||||
}
|
||||
return lineup_svg(body);
|
||||
}
|
||||
std::string lineup_field() {
|
||||
std::string lineup_field(bool indoor = false) {
|
||||
std::string body;
|
||||
for (int x=0;x<196;x+=15) body += "<rect x=\""+std::to_string(x)+"\" width=\"15\" height=\"117\" fill=\""+(x%30?"#306b4c":"#2d6447")+"\"/>";
|
||||
body += "<svg viewBox=\"0 0 120 72\" width=\"196\" height=\"117\"><g fill=\"none\" stroke=\"#cfdfd2\" stroke-width=\".45\">"
|
||||
"<path d=\"M7 2H113V70H7Z M60 2V70 M7 15.84H23.5V56.16H7 M113 15.84H96.5V56.16H113 M7 26.84H12.5V45.16H7 M113 26.84H107.5V45.16H113 M7 32.34H5V39.66H7 M113 32.34H115V39.66H113 M23.5 28.8Q30 36 23.5 43.2 M96.5 28.8Q90 36 96.5 43.2 M8 2A1 1 0 0 1 7 3 M112 2A1 1 0 0 0 113 3 M7 69A1 1 0 0 1 8 70 M112 70A1 1 0 0 1 113 69\"/>"
|
||||
"<circle cx=\"60\" cy=\"36\" r=\"9.15\"/></g><g fill=\"#cfdfd2\"><circle cx=\"60\" cy=\"36\" r=\".4\"/><circle cx=\"18\" cy=\"36\" r=\".3\"/><circle cx=\"102\" cy=\"36\" r=\".3\"/></g></svg>";
|
||||
return lineup_svg(body,"0 0 196 117");
|
||||
for (int x = 0; x < 196; x += 15)
|
||||
body += "<rect x=\"" + std::to_string(x) +
|
||||
"\" width=\"15\" height=\"117\" fill=\"" +
|
||||
(indoor ? (x % 30 ? "#c89460" : "#bd854e")
|
||||
: (x % 30 ? "#306b4c" : "#2d6447")) +
|
||||
"\"/>";
|
||||
body +=
|
||||
"<svg viewBox=\"0 0 120 72\" width=\"196\" height=\"117\"><g "
|
||||
"fill=\"none\" stroke=\"#cfdfd2\" stroke-width=\".45\">"
|
||||
"<path d=\"M7 2H113V70H7Z M60 2V70 M7 15.84H23.5V56.16H7 M113 "
|
||||
"15.84H96.5V56.16H113 M7 26.84H12.5V45.16H7 M113 26.84H107.5V45.16H113 "
|
||||
"M7 32.34H5V39.66H7 M113 32.34H115V39.66H113 M23.5 28.8Q30 36 23.5 43.2 "
|
||||
"M96.5 28.8Q90 36 96.5 43.2 M8 2A1 1 0 0 1 7 3 M112 2A1 1 0 0 0 113 3 M7 "
|
||||
"69A1 1 0 0 1 8 70 M112 70A1 1 0 0 1 113 69\"/>"
|
||||
"<circle cx=\"60\" cy=\"36\" r=\"9.15\"/></g><g fill=\"#cfdfd2\"><circle "
|
||||
"cx=\"60\" cy=\"36\" r=\".4\"/><circle cx=\"18\" cy=\"36\" "
|
||||
"r=\".3\"/><circle cx=\"102\" cy=\"36\" r=\".3\"/></g></svg>";
|
||||
return lineup_svg(body, "0 0 196 117");
|
||||
}
|
||||
std::string lineup_zone(const Json &l, const std::string &id) {
|
||||
const int row = lineup_slot(l,id);
|
||||
if (row<0 || row>=11) return "";
|
||||
const auto &point = l.at("points")[size_t(row)], &orders = l.at("orders").at(id);
|
||||
const double forward=orders[0].get<int>(), width=orders[1].get<int>(), coverage=orders[2].get<int>();
|
||||
const double x=(8+point[0].get<int>()/18.0*84)*1.96, y=(10+point[1].get<int>()/8.0*80)*1.17;
|
||||
double x0=x-(width/2+46-forward), x1=x+width/2+forward+8;
|
||||
std::string body="<g fill=\"#ed5b61\" fill-opacity=\".46\">";
|
||||
for (int n=0;n<=int(coverage/2);++n) {
|
||||
if (n) { const int bend=(n==8?3:0)+(n==6?2:0)+(n==3?1:0); if (x0<x1-(1+bend)*2-20) {x0+=1+bend;x1-=1+bend;} }
|
||||
const double lo=std::max(3.0,x0),hi=std::min(192.0,x1);
|
||||
if (hi>lo) for (const auto yy : {std::max(2.0,y-n-1),std::min(114.0,y+n+1)})
|
||||
body += "<rect x=\""+scalar(lo)+"\" y=\""+scalar(yy)+"\" width=\""+scalar(hi-lo)+"\" height=\"1\"/>";
|
||||
const int row = lineup_slot(l, id);
|
||||
if (row < 0 || row >= 11)
|
||||
return "";
|
||||
const auto &point = l.at("points")[size_t(row)],
|
||||
&orders = l.at("orders").at(id);
|
||||
const double forward = orders[0].get<int>(), width = orders[1].get<int>(),
|
||||
coverage = orders[2].get<int>();
|
||||
const double x = (8 + point[0].get<int>() / 18.0 * 84) * 1.96,
|
||||
y = (10 + point[1].get<int>() / 8.0 * 80) * 1.17;
|
||||
double x0 = x - (width / 2 + 46 - forward), x1 = x + width / 2 + forward + 8;
|
||||
std::string body = "<g fill=\"#ed5b61\" fill-opacity=\".46\">";
|
||||
for (int n = 0; n <= int(coverage / 2); ++n) {
|
||||
if (n) {
|
||||
const int bend = (n == 8 ? 3 : 0) + (n == 6 ? 2 : 0) + (n == 3 ? 1 : 0);
|
||||
if (x0 < x1 - (1 + bend) * 2 - 20) {
|
||||
x0 += 1 + bend;
|
||||
x1 -= 1 + bend;
|
||||
}
|
||||
}
|
||||
const double lo = std::max(3.0, x0), hi = std::min(192.0, x1);
|
||||
if (hi > lo)
|
||||
for (const auto yy :
|
||||
{std::max(2.0, y - n - 1), std::min(114.0, y + n + 1)})
|
||||
body += "<rect x=\"" + scalar(lo) + "\" y=\"" + scalar(yy) +
|
||||
"\" width=\"" + scalar(hi - lo) + "\" height=\"1\"/>";
|
||||
}
|
||||
return lineup_svg(body+"</g>","0 0 196 117");
|
||||
return lineup_svg(body + "</g>", "0 0 196 117");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string App::render_lineup() {
|
||||
const auto s=snap();
|
||||
if (!s.world) return "<p class=\"lineup-empty\">Die Aufstellung ist derzeit nicht verfügbar.</p>";
|
||||
const auto projection=demo_lineup_rows(s.state,*s.world,lineup_managed(s));
|
||||
if (!projection.value("ok",false)) return "<p class=\"lineup-empty\">Die Aufstellung ist derzeit nicht verfügbar.</p>";
|
||||
const auto &l=s.state.at("lineup"), &rows=projection.at("rows");
|
||||
if (lineup_slot(l,lineup_selected_)<0) lineup_selected_.clear();
|
||||
lineup_data_=lineup_data_==1?1:0; lineup_page_=lineup_page_==1?1:0;
|
||||
if (lineup_side_!="orders" && lineup_side_!="takers") lineup_side_="formations";
|
||||
const auto attr=[](const std::string &key,const std::string &value) {return " "+key+"=\""+esc(value)+"\"";};
|
||||
const auto player_attrs=[&](const Json &row,const std::string &prefix) {
|
||||
const auto id=row.at("id").get<std::string>();
|
||||
return attr("id",prefix+id)+attr("data-id",id)+attr("data-squad-player",id)+
|
||||
attr("data-slot",std::to_string(row.at("slot").get<size_t>()))+attr("aria-pressed",lineup_selected_==id?"true":"false")+
|
||||
attr("aria-label",row.at("name").get<std::string>()+", "+lineup_position(row.at("position")));
|
||||
const auto s = snap();
|
||||
if (!s.world)
|
||||
return "<p class=\"lineup-empty\">Die Aufstellung ist derzeit nicht "
|
||||
"verfügbar.</p>";
|
||||
const auto projection =
|
||||
demo_lineup_rows(s.state, *s.world, lineup_managed(s));
|
||||
if (!projection.value("ok", false))
|
||||
return "<p class=\"lineup-empty\">Die Aufstellung ist derzeit nicht "
|
||||
"verfügbar.</p>";
|
||||
const auto &l = demo_lineup_visible(s.state), &rows = projection.at("rows");
|
||||
const int field_count = demo_career_field_count(s.state);
|
||||
const bool indoor = field_count == 6;
|
||||
if (lineup_slot(l, lineup_selected_) < 0)
|
||||
lineup_selected_.clear();
|
||||
lineup_data_ = lineup_data_ == 1 ? 1 : 0;
|
||||
lineup_page_ = lineup_page_ == 1 ? 1 : 0;
|
||||
if (lineup_side_ != "orders" && lineup_side_ != "takers")
|
||||
lineup_side_ = "formations";
|
||||
const auto attr = [](const std::string &key, const std::string &value) {
|
||||
return " " + key + "=\"" + esc(value) + "\"";
|
||||
};
|
||||
std::string out="<div id=\"lineup-underlay\" class=\"lineup-screen "+std::string(lineup_pitch_?"pitch-view":"team-view")+"\"><div class=\"lineup-roster\"><div class=\"lineup-row lineup-head\" role=\"row\">";
|
||||
const std::array<std::array<const char*,12>,2> headings{{
|
||||
{{"Nr.","Name","Pos.","Ko","Te","Fo","Stärke","Status","Land","Mot.","Tore","Ass."}},
|
||||
{{"Nr.","Name","Alter","Eck.","Frei.","Zwei.","Pass","Schuss","Schn.","Team","Spiele","Note"}}}};
|
||||
for (int c=0;c<12;++c) out+="<span class=\"lineup-cell lineup-col-"+std::to_string(c)+"\"><span>"+headings[size_t(lineup_data_)][size_t(c)]+"</span></span>";
|
||||
out+="</div><div id=\"lineup-roster-scroll\" class=\"lineup-roster-scroll\" tabindex=\"0\" aria-label=\"Kaderliste, scrollbar\" role=\"table\">";
|
||||
for (const auto &row:rows) {
|
||||
const auto slot=row.at("slot").get<int>(); const auto id=row.at("id").get<std::string>();
|
||||
out+="<div class=\"lineup-row "+std::string(slot%2?"even ":"")+(slot==11?"reserve-start ":"")+(lineup_selected_==id?"selected":"")+"\" role=\"row\">";
|
||||
out+="<span class=\"lineup-cell lineup-col-0\"><span>"+(slot<11?std::to_string(slot+1):"–")+"</span></span>";
|
||||
out+=btn("lineup-player",esc(row.at("name").get<std::string>()),"lineup-cell lineup-col-1 lineup-name",player_attrs(row,"lineup-name-"));
|
||||
const auto player_attrs = [&](const Json &row, const std::string &prefix) {
|
||||
const auto id = row.at("id").get<std::string>();
|
||||
return attr("id", prefix + id) + attr("data-id", id) +
|
||||
attr("data-squad-player", id) +
|
||||
attr("data-slot", std::to_string(row.at("slot").get<size_t>())) +
|
||||
attr("aria-pressed", lineup_selected_ == id ? "true" : "false") +
|
||||
attr("aria-label", row.at("name").get<std::string>() + ", " +
|
||||
lineup_position(row.at("position")));
|
||||
};
|
||||
std::string out = "<div id=\"lineup-underlay\" class=\"lineup-screen " +
|
||||
std::string(lineup_pitch_ ? "pitch-view" : "team-view") +
|
||||
(indoor ? " indoor-lineup" : "") +
|
||||
"\"><div class=\"lineup-roster\"><div class=\"lineup-row "
|
||||
"lineup-head\" role=\"row\">";
|
||||
const std::array<std::array<const char *, 12>, 2> headings{
|
||||
{{{"Nr.", "Name", "Pos.", "Ko", "Te", "Fo", "Stärke", "Status", "Land",
|
||||
"Mot.", "Tore", "Ass."}},
|
||||
{{"Nr.", "Name", "Alter", "Eck.", "Frei.", "Zwei.", "Pass", "Schuss",
|
||||
"Schn.", "Team", "Spiele", "Note"}}}};
|
||||
for (int c = 0; c < 12; ++c)
|
||||
out += "<span class=\"lineup-cell lineup-col-" + std::to_string(c) +
|
||||
"\"><span>" + headings[size_t(lineup_data_)][size_t(c)] +
|
||||
"</span></span>";
|
||||
out +=
|
||||
"</div><div id=\"lineup-roster-scroll\" class=\"lineup-roster-scroll\" "
|
||||
"tabindex=\"0\" aria-label=\"Kaderliste, scrollbar\" role=\"table\">";
|
||||
for (const auto &row : rows) {
|
||||
const auto slot = row.at("slot").get<int>();
|
||||
const auto id = row.at("id").get<std::string>();
|
||||
out += "<div class=\"lineup-row " + std::string(slot % 2 ? "even " : "") +
|
||||
(slot == field_count ? "reserve-start " : "") +
|
||||
(lineup_selected_ == id ? "selected" : "") + "\" role=\"row\">";
|
||||
out += "<span class=\"lineup-cell lineup-col-0\"><span>" +
|
||||
(slot < field_count ? std::to_string(slot + 1) : "–") +
|
||||
"</span></span>";
|
||||
out += btn("lineup-player", esc(row.at("name").get<std::string>()),
|
||||
"lineup-cell lineup-col-1 lineup-name",
|
||||
player_attrs(row, "lineup-name-"));
|
||||
std::vector<std::string> fields;
|
||||
if (!lineup_data_) fields={lineup_position(row.at("position")),lineup_value(row.at("condition")),lineup_value(row.at("technique")),lineup_value(row.at("form")),lineup_value(row.at("strength")),lineup_status(size_t(slot)),row.at("nation").is_string()?row.at("nation").get<std::string>():"—",lineup_value(row.at("motivation")),lineup_value(row.at("goals")),lineup_value(row.at("assists"))};
|
||||
else for (const auto *key:{"age","corner","free_kick","tackling","passing","shooting","speed","teamplay","games","grade"}) fields.push_back(lineup_value(row.at(key)));
|
||||
for (size_t f=0;f<fields.size();++f) {
|
||||
std::string value=esc(fields[f]);
|
||||
if (!lineup_data_ && f==6 && row.at("nation").is_string()) {
|
||||
auto code=row.at("nation").get<std::string>();
|
||||
if (code.starts_with("nation:")) code=code.substr(7);
|
||||
if (code=="de") value=picture(renderer_.diagram("lineup-flag-de",lineup_svg("<path fill=\"#111111\" d=\"M0 0H40V8H0Z\"/><path fill=\"#bc302e\" d=\"M0 8H40V16H0Z\"/><path fill=\"#edc758\" d=\"M0 16H40V24H0Z\"/>","0 0 40 24"),80),40,24);
|
||||
if (!lineup_data_)
|
||||
fields = {lineup_position(row.at("position")),
|
||||
lineup_value(row.at("condition")),
|
||||
lineup_value(row.at("technique")),
|
||||
lineup_value(row.at("form")),
|
||||
lineup_value(row.at("strength")),
|
||||
lineup_status(size_t(slot), indoor),
|
||||
row.at("nation").is_string()
|
||||
? row.at("nation").get<std::string>()
|
||||
: "—",
|
||||
lineup_value(row.at("motivation")),
|
||||
lineup_value(row.at("goals")),
|
||||
lineup_value(row.at("assists"))};
|
||||
else
|
||||
for (const auto *key :
|
||||
{"age", "corner", "free_kick", "tackling", "passing", "shooting",
|
||||
"speed", "teamplay", "games", "grade"})
|
||||
fields.push_back(lineup_value(row.at(key)));
|
||||
for (size_t f = 0; f < fields.size(); ++f) {
|
||||
std::string value = esc(fields[f]);
|
||||
if (!lineup_data_ && f == 6 && row.at("nation").is_string()) {
|
||||
auto code = row.at("nation").get<std::string>();
|
||||
if (code.starts_with("nation:"))
|
||||
code = code.substr(7);
|
||||
if (code == "de")
|
||||
value = picture(
|
||||
renderer_.diagram(
|
||||
"lineup-flag-de",
|
||||
lineup_svg("<path fill=\"#111111\" d=\"M0 0H40V8H0Z\"/><path "
|
||||
"fill=\"#bc302e\" d=\"M0 8H40V16H0Z\"/><path "
|
||||
"fill=\"#edc758\" d=\"M0 16H40V24H0Z\"/>",
|
||||
"0 0 40 24"),
|
||||
80),
|
||||
40, 24);
|
||||
else {
|
||||
const auto flag=ui_nation_flag_svg(code);
|
||||
if (!flag.empty()) value=picture(renderer_.diagram("lineup-flag-"+code,flag,80),40,24);
|
||||
const auto flag = ui_nation_flag_svg(code);
|
||||
if (!flag.empty())
|
||||
value = picture(renderer_.diagram("lineup-flag-" + code, flag, 80),
|
||||
40, 24);
|
||||
else {
|
||||
// Legacy placeholders are identifiers, not useful country labels.
|
||||
const bool country_code=code.size()==2 && std::all_of(code.begin(),code.end(),[](unsigned char c){return (c>='a'&&c<='z')||(c>='A'&&c<='Z');});
|
||||
const bool country_code =
|
||||
code.size() == 2 &&
|
||||
std::all_of(code.begin(), code.end(), [](unsigned char c) {
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
});
|
||||
if (country_code) {
|
||||
std::transform(code.begin(),code.end(),code.begin(),[](unsigned char c){return char(std::toupper(c));});
|
||||
value=esc(code);
|
||||
} else value="—";
|
||||
std::transform(
|
||||
code.begin(), code.end(), code.begin(),
|
||||
[](unsigned char c) { return char(std::toupper(c)); });
|
||||
value = esc(code);
|
||||
} else
|
||||
value = "—";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!lineup_data_ && f==5) value="<span class=\"lineup-status\">"+value+"</span>";
|
||||
out+=btn("player-detail",value,"lineup-cell lineup-col-"+std::to_string(f+2)+" lineup-detail",
|
||||
attr("id","lineup-detail-"+id+"-"+std::to_string(f))+attr("data-id",id)+attr("aria-label",row.at("name").get<std::string>()+", Spielerinformationen"));
|
||||
if (!lineup_data_ && f == 5)
|
||||
value = "<span class=\"lineup-status\">" + value + "</span>";
|
||||
out += btn("player-detail", value,
|
||||
"lineup-cell lineup-col-" + std::to_string(f + 2) +
|
||||
" lineup-detail",
|
||||
attr("id", "lineup-detail-" + id + "-" + std::to_string(f)) +
|
||||
attr("data-id", id) +
|
||||
attr("aria-label", row.at("name").get<std::string>() +
|
||||
", Spielerinformationen"));
|
||||
}
|
||||
out+="</div>";
|
||||
out += "</div>";
|
||||
}
|
||||
if (rows.empty()) out+="<p class=\"lineup-empty\">Für diesen Verein sind keine Spieler überliefert.</p>";
|
||||
out+="</div></div>";
|
||||
const auto data_btn=[&]() {return btn("lineup-data",lineup_data_?"Daten A":"Daten B","lineup-tab","id=\"lineup-data\"");};
|
||||
const auto view_btn=[&]() {return btn("lineup-view",lineup_pitch_?"Team":"Spielfeld","lineup-tab","id=\"lineup-view\"");};
|
||||
if (rows.empty())
|
||||
out += "<p class=\"lineup-empty\">Für diesen Verein sind keine Spieler "
|
||||
"überliefert.</p>";
|
||||
out += "</div></div>";
|
||||
const auto data_btn = [&]() {
|
||||
return btn("lineup-data", lineup_data_ ? "Daten A" : "Daten B",
|
||||
"lineup-tab", "id=\"lineup-data\"");
|
||||
};
|
||||
const auto view_btn = [&]() {
|
||||
return btn("lineup-view", lineup_pitch_ ? "Team" : "Spielfeld",
|
||||
"lineup-tab", "id=\"lineup-view\"");
|
||||
};
|
||||
out +=
|
||||
"<nav class=\"lineup-surface-controls\" "
|
||||
"aria-label=\"Spielfeldvariante\">" +
|
||||
btn("lineup-surface", "Rasen · 11", indoor ? "" : "selected",
|
||||
"id=\"lineup-surface-outdoor\" data-id=\"outdoor\" aria-pressed=\"" +
|
||||
(indoor ? std::string("false") : "true") + "\"") +
|
||||
btn("lineup-surface", "Halle · 6", indoor ? "selected" : "",
|
||||
"id=\"lineup-surface-indoor\" data-id=\"indoor\" aria-pressed=\"" +
|
||||
(indoor ? std::string("true") : "false") + "\" " +
|
||||
(s.state.at("career").value("role", "club") == "national"
|
||||
? "disabled"
|
||||
: "")) +
|
||||
"</nav>";
|
||||
if (lineup_pitch_) {
|
||||
out+="<div id=\"lineup-pitch\" class=\"lineup-pitch\" role=\"group\" aria-label=\"Spielfeld, Spieler auswählen oder ziehen\"><div class=\"lineup-field-art\">"+picture(renderer_.diagram("lineup-field",lineup_field(),lineup_pitch_raster_px),lineup_art_width_dp,lineup_art_height_dp)+"</div>";
|
||||
if (lineup_side_=="orders" && !lineup_selected_.empty()) {
|
||||
const auto zone=lineup_zone(l,lineup_selected_);
|
||||
if (!zone.empty()) out+="<div id=\"lineup-zone\" class=\"lineup-order-zone\">"+picture(renderer_.diagram("lineup-zone",zone,lineup_pitch_raster_px),lineup_art_width_dp,lineup_art_height_dp)+"</div>";
|
||||
out += "<div id=\"lineup-pitch\" class=\"lineup-pitch\" role=\"group\" "
|
||||
"aria-label=\"Spielfeld, Spieler auswählen oder ziehen\"><div "
|
||||
"class=\"lineup-field-art\">" +
|
||||
picture(renderer_.diagram("lineup-field", lineup_field(indoor),
|
||||
lineup_pitch_raster_px),
|
||||
lineup_art_width_dp, lineup_art_height_dp) +
|
||||
"</div>";
|
||||
if (lineup_side_ == "orders" && !lineup_selected_.empty()) {
|
||||
const auto zone = lineup_zone(l, lineup_selected_);
|
||||
if (!zone.empty())
|
||||
out += "<div id=\"lineup-zone\" class=\"lineup-order-zone\">" +
|
||||
picture(renderer_.diagram("lineup-zone", zone,
|
||||
lineup_pitch_raster_px),
|
||||
lineup_art_width_dp, lineup_art_height_dp) +
|
||||
"</div>";
|
||||
}
|
||||
for (size_t i=0;i<std::min(size_t(11),rows.size());++i) {
|
||||
const auto &row=rows[i], &point=l.at("points")[i];
|
||||
const bool selected=lineup_selected_==row.at("id").get<std::string>();
|
||||
const auto x=(8+point[0].get<int>()/18.0*84)*lineup_art_width_dp/100.0-lineup_player_anchor_x_dp;
|
||||
const auto y=(10+point[1].get<int>()/8.0*80)*lineup_art_height_dp/100.0-lineup_player_anchor_y_dp;
|
||||
out+=btn("lineup-player",img(selected?"lineup.player.selected":"lineup.player.normal",lineup_player_size_dp,lineup_player_size_dp)+"<span class=\"lineup-jersey\">"+std::to_string(i+1)+"</span>","lineup-player",player_attrs(row,"lineup-player-")+attr("style",rect(x,y,lineup_player_size_dp,lineup_player_size_dp)));
|
||||
for (size_t i = 0; i < std::min(size_t(field_count), rows.size()); ++i) {
|
||||
const auto &row = rows[i], &point = l.at("points")[i];
|
||||
const bool selected = lineup_selected_ == row.at("id").get<std::string>();
|
||||
const auto x =
|
||||
(8 + point[0].get<int>() / 18.0 * 84) * lineup_art_width_dp / 100.0 -
|
||||
lineup_player_anchor_x_dp;
|
||||
const auto y =
|
||||
(10 + point[1].get<int>() / 8.0 * 80) * lineup_art_height_dp / 100.0 -
|
||||
lineup_player_anchor_y_dp;
|
||||
out +=
|
||||
btn("lineup-player",
|
||||
img(selected ? "lineup.player.selected" : "lineup.player.normal",
|
||||
lineup_player_size_dp, lineup_player_size_dp) +
|
||||
"<span class=\"lineup-jersey\">" + std::to_string(i + 1) +
|
||||
"</span>",
|
||||
"lineup-player",
|
||||
player_attrs(row, "lineup-player-") +
|
||||
attr("style", rect(x, y, lineup_player_size_dp,
|
||||
lineup_player_size_dp)));
|
||||
}
|
||||
out+="<div id=\"lineup-ghost\" class=\"lineup-ghost\">"+img("lineup.player.ghost",lineup_player_size_dp,lineup_player_size_dp)+"</div></div><aside class=\"lineup-controls\"><nav class=\"lineup-tabs\" aria-label=\"Aufstellungsansichten\">"+data_btn()+view_btn();
|
||||
for (const auto &[side,label]:std::array<std::pair<const char*,const char*>,3>{{{"formations","Aufst."},{"orders","Anweis."},{"takers","Schütze"}}})
|
||||
out+=btn("lineup-side",label,"lineup-tab",attr("id","lineup-side-"+std::string(side))+attr("data-id",side)+attr("aria-pressed",lineup_side_==side?"true":"false"));
|
||||
out+="</nav><div class=\"lineup-side\" id=\"lineup-side\">";
|
||||
if (lineup_side_=="formations") {
|
||||
for (int slot=0;slot<4;++slot) {
|
||||
const int i=slot+lineup_page_*4;
|
||||
const auto point=i<4?demo_lineup_formations()[size_t(i)]:l.at("custom")[size_t(i-4)];
|
||||
const auto mini=lineup_mini(point,theme_);
|
||||
const std::string label=i<4?"Aufstellung "+std::to_string(i+1):"Eigene "+std::to_string(i-3);
|
||||
const auto art=picture(renderer_.diagram("lineup-mini-"+std::to_string(i)+"-"+theme_,mini,520),200,120);
|
||||
out+="<div class=\"lineup-formation-cell "+std::string(i>=4?"custom":"")+"\" style=\""+rect((slot%2)*(lineup_formation_width_dp+18.0),(slot/2)*172.0,lineup_formation_width_dp,160)+"\">";
|
||||
out+=btn("lineup-formation","<span class=\"lineup-mini\">"+art+"</span><span class=\"lineup-formation-label\">"+label+"</span>","lineup-formation",
|
||||
attr("id","lineup-formation-"+std::to_string(i))+attr("data-id",std::to_string(i))+attr("aria-pressed",l.at("formation")==i?"true":"false")+(point.is_null()?" disabled=\"disabled\"":""));
|
||||
if (i>=4) out+=btn("lineup-save","Merken","lineup-save",attr("id","lineup-save-"+std::to_string(i-4))+attr("data-id",std::to_string(i-4)));
|
||||
out+="</div>";
|
||||
out += "<div id=\"lineup-ghost\" class=\"lineup-ghost\">" +
|
||||
img("lineup.player.ghost", lineup_player_size_dp,
|
||||
lineup_player_size_dp) +
|
||||
"</div></div><aside class=\"lineup-controls\"><nav "
|
||||
"class=\"lineup-tabs\" aria-label=\"Aufstellungsansichten\">" +
|
||||
data_btn() + view_btn();
|
||||
for (const auto &[side, label] :
|
||||
std::array<std::pair<const char *, const char *>, 3>{
|
||||
{{"formations", "Aufst."},
|
||||
{"orders", "Anweis."},
|
||||
{"takers", "Schütze"}}})
|
||||
out += btn(
|
||||
"lineup-side", label, "lineup-tab",
|
||||
attr("id", "lineup-side-" + std::string(side)) +
|
||||
attr("data-id", side) +
|
||||
attr("aria-pressed", lineup_side_ == side ? "true" : "false"));
|
||||
out += "</nav><div class=\"lineup-side\" id=\"lineup-side\">";
|
||||
if (lineup_side_ == "formations") {
|
||||
for (int slot = 0; slot < 4; ++slot) {
|
||||
const int i = slot + lineup_page_ * 4;
|
||||
const auto point = i < 4 ? demo_lineup_formations(indoor)[size_t(i)]
|
||||
: l.at("custom")[size_t(i - 4)];
|
||||
const auto mini = lineup_mini(point, theme_, size_t(field_count));
|
||||
const std::string label = i < 4 ? "Aufstellung " + std::to_string(i + 1)
|
||||
: "Eigene " + std::to_string(i - 3);
|
||||
const auto art = picture(
|
||||
renderer_.diagram("lineup-mini-" + std::to_string(i) + "-" + theme_,
|
||||
mini, 520),
|
||||
200, 120);
|
||||
out += "<div class=\"lineup-formation-cell " +
|
||||
std::string(i >= 4 ? "custom" : "") + "\" style=\"" +
|
||||
rect((slot % 2) * (lineup_formation_width_dp + 18.0),
|
||||
(slot / 2) * 172.0, lineup_formation_width_dp, 160) +
|
||||
"\">";
|
||||
out += btn("lineup-formation",
|
||||
"<span class=\"lineup-mini\">" + art +
|
||||
"</span><span class=\"lineup-formation-label\">" +
|
||||
label + "</span>",
|
||||
"lineup-formation",
|
||||
attr("id", "lineup-formation-" + std::to_string(i)) +
|
||||
attr("data-id", std::to_string(i)) +
|
||||
attr("aria-pressed",
|
||||
l.at("formation") == i ? "true" : "false") +
|
||||
(point.is_null() ? " disabled=\"disabled\"" : ""));
|
||||
if (i >= 4)
|
||||
out += btn("lineup-save", "Merken", "lineup-save",
|
||||
attr("id", "lineup-save-" + std::to_string(i - 4)) +
|
||||
attr("data-id", std::to_string(i - 4)));
|
||||
out += "</div>";
|
||||
}
|
||||
const auto arrow=[&](bool next) {return picture(renderer_.diagram(next?"lineup-next":"lineup-prev",lineup_svg("<path d=\""+std::string(next?"M8 3L17 12L8 21":"M16 3L7 12L16 21")+"\" fill=\"none\" stroke=\""+std::string(theme_=="silver"?"#233443":"#dce5ee")+"\" stroke-width=\"2\"/>","0 0 24 24"),48),32,32);};
|
||||
out+="<nav class=\"lineup-pages\" aria-label=\"Aufstellungsseiten\">"+btn("lineup-page",arrow(false),"lineup-page","id=\"lineup-page-prev\" data-id=\"0\" aria-label=\"Vorgegebene Aufstellungen\" "+std::string(lineup_page_==0?"disabled=\"disabled\"":""))+"<span>"+(lineup_page_?"Eigene Aufstellungen":"Vorgegebene Aufstellungen")+"</span>"+btn("lineup-page",arrow(true),"lineup-page","id=\"lineup-page-next\" data-id=\"1\" aria-label=\"Eigene Aufstellungen\" "+std::string(lineup_page_==1?"disabled=\"disabled\"":""))+"</nav><div class=\"lineup-weights\">";
|
||||
const std::array<const char*,3> names{"Position","Seite / Rolle","Frische"};
|
||||
for (int i=0;i<3;++i) {
|
||||
const int weight=l.at("weights")[size_t(i)].get<int>();
|
||||
std::string bars="<span class=\"lineup-weight-bars\">";
|
||||
for (int n=0;n<3;++n) bars+="<span class=\"lineup-weight-bar "+std::string(n<weight?"active":"")+"\"></span>";
|
||||
out+=btn("lineup-weight","<span class=\"lineup-weight-label\">"+std::string(names[size_t(i)])+"</span>"+bars+"</span>","lineup-weight",attr("id","lineup-weight-"+std::to_string(i))+attr("data-id",std::to_string(i))+attr("aria-label",std::string(names[size_t(i)])+" Gewichtung "+std::to_string(weight)+" von 3"));
|
||||
}
|
||||
out+="</div>";
|
||||
} else if (lineup_side_=="orders") {
|
||||
const int slot=lineup_slot(l,lineup_selected_);
|
||||
out+="<section class=\"lineup-orders\"><h2>Anweisungen</h2><p class=\"lineup-order-name\">"+esc(slot>=0?rows[size_t(slot)].at("name").get<std::string>():"Einen Feldspieler auswählen.")+"</p>";
|
||||
if (slot>=0 && slot<11) {
|
||||
const std::array<const char*,4> paths{"M8 34L34 8M14 8H34V28","M8 34L34 8M8 14V34H28","M4 22H40M13 13L4 22L13 31M31 13L40 22L31 31","M22 4V40M13 13L22 4L31 13M13 31L22 40L31 31"};
|
||||
for (int i=0;i<4;++i) {
|
||||
const auto value=l.at("orders").at(lineup_selected_)[size_t(i)].get<int>();
|
||||
const auto icon=lineup_svg("<path d=\""+std::string(paths[size_t(i)])+"\" fill=\"none\" stroke=\""+std::string(theme_=="silver"?"#25617a":theme_=="matchday"?"#efb2aa":"#a9dccb")+"\" stroke-width=\"3\"/>","0 0 44 44");
|
||||
out+="<label class=\"lineup-order-row\" style=\"top:"+scalar(135+(i/2)*132.0)+"dp;left:"+scalar((i%2)*(lineup_order_width_dp+40.0))+"dp;\"><span class=\"lineup-order-icon\">"+picture(renderer_.diagram("lineup-order-icon-"+std::to_string(i)+"-"+theme_,icon,88),44,44)+"</span><input type=\"range\" min=\"2\" max=\"40\" step=\"1\" value=\""+std::to_string(value)+"\" id=\"lineup-order-"+std::to_string(i)+"\" data-lineup-order=\""+std::to_string(i)+"\" data-player=\""+esc(lineup_selected_)+"\" aria-label=\"Anweisung "+std::to_string(i+1)+"\"/><span class=\"lineup-order-value\" id=\"lineup-order-value-"+std::to_string(i)+"\">"+std::to_string(value)+"</span></label>";
|
||||
}
|
||||
} else out+="<p class=\"lineup-hint\">Die vier Vorschauwerte gelten für Spieler in der Startelf.</p>";
|
||||
out+="</section>";
|
||||
} else {
|
||||
out+="<section class=\"lineup-takers\"><h2>Schützen</h2>";
|
||||
const std::array<const char*,3> labels{"Freistoß","Elfmeter","Eckball"};
|
||||
const auto option_text=[](const std::string &name) {
|
||||
return "<span class=\"lineup-option-mark\" aria-hidden=\"true\"><span class=\"lineup-option-check\"></span></span><span class=\"lineup-option-text\">"+esc(name)+"</span>";
|
||||
const auto arrow = [&](bool next) {
|
||||
return picture(
|
||||
renderer_.diagram(
|
||||
next ? "lineup-next" : "lineup-prev",
|
||||
lineup_svg("<path d=\"" +
|
||||
std::string(next ? "M8 3L17 12L8 21"
|
||||
: "M16 3L7 12L16 21") +
|
||||
"\" fill=\"none\" stroke=\"" +
|
||||
std::string(theme_ == "silver" ? "#233443"
|
||||
: "#dce5ee") +
|
||||
"\" stroke-width=\"2\"/>",
|
||||
"0 0 24 24"),
|
||||
48),
|
||||
32, 32);
|
||||
};
|
||||
for (int i=0;i<3;++i) {
|
||||
out+="<label class=\"lineup-taker-label\" style=\"left:"+scalar(i*(lineup_taker_width_dp+18.0))+"dp;\"><span>"+std::string(labels[size_t(i)])+"</span><select class=\"lineup-taker\" data-select-max-height=\"280\" id=\"lineup-taker-"+std::to_string(i)+"\" data-lineup-taker=\""+std::to_string(i)+"\" aria-label=\""+std::string(labels[size_t(i)])+"schütze\"><option value=\"\" "+std::string(l.at("takers")[size_t(i)]==""?"selected=\"selected\"":"")+">"+option_text("AUTO")+"</option>";
|
||||
for (size_t r=0;r<std::min(size_t(11),rows.size());++r) {
|
||||
const auto id=rows[r].at("id").get<std::string>();
|
||||
out+="<option value=\""+esc(id)+"\" "+std::string(l.at("takers")[size_t(i)]==id?"selected=\"selected\"":"")+">"+option_text(rows[r].at("name").get<std::string>())+"</option>";
|
||||
}
|
||||
out+="</select></label>";
|
||||
out += "<nav class=\"lineup-pages\" aria-label=\"Aufstellungsseiten\">" +
|
||||
btn("lineup-page", arrow(false), "lineup-page",
|
||||
"id=\"lineup-page-prev\" data-id=\"0\" "
|
||||
"aria-label=\"Vorgegebene Aufstellungen\" " +
|
||||
std::string(lineup_page_ == 0 ? "disabled=\"disabled\""
|
||||
: "")) +
|
||||
"<span>" +
|
||||
(lineup_page_ ? "Eigene Aufstellungen"
|
||||
: "Vorgegebene Aufstellungen") +
|
||||
"</span>" +
|
||||
btn("lineup-page", arrow(true), "lineup-page",
|
||||
"id=\"lineup-page-next\" data-id=\"1\" aria-label=\"Eigene "
|
||||
"Aufstellungen\" " +
|
||||
std::string(lineup_page_ == 1 ? "disabled=\"disabled\""
|
||||
: "")) +
|
||||
"</nav><div class=\"lineup-weights\">";
|
||||
const std::array<const char *, 3> names{"Position", "Seite / Rolle",
|
||||
"Frische"};
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
const int weight = l.at("weights")[size_t(i)].get<int>();
|
||||
std::string bars = "<span class=\"lineup-weight-bars\">";
|
||||
for (int n = 0; n < 3; ++n)
|
||||
bars += "<span class=\"lineup-weight-bar " +
|
||||
std::string(n < weight ? "active" : "") + "\"></span>";
|
||||
out += btn("lineup-weight",
|
||||
"<span class=\"lineup-weight-label\">" +
|
||||
std::string(names[size_t(i)]) + "</span>" + bars +
|
||||
"</span>",
|
||||
"lineup-weight",
|
||||
attr("id", "lineup-weight-" + std::to_string(i)) +
|
||||
attr("data-id", std::to_string(i)) +
|
||||
attr("aria-label",
|
||||
std::string(names[size_t(i)]) + " Gewichtung " +
|
||||
std::to_string(weight) + " von 3"));
|
||||
}
|
||||
out+=btn("lineup-auto","Automatisch","lineup-auto","id=\"lineup-auto\"")+"</section>";
|
||||
out += "</div>";
|
||||
} else if (lineup_side_ == "orders") {
|
||||
const int slot = lineup_slot(l, lineup_selected_);
|
||||
out += "<section class=\"lineup-orders\"><h2>Anweisungen</h2><p "
|
||||
"class=\"lineup-order-name\">" +
|
||||
esc(slot >= 0 ? rows[size_t(slot)].at("name").get<std::string>()
|
||||
: "Einen Feldspieler auswählen.") +
|
||||
"</p>";
|
||||
if (slot >= 0 && slot < field_count) {
|
||||
const std::array<const char *, 4> paths{
|
||||
"M8 34L34 8M14 8H34V28", "M8 34L34 8M8 14V34H28",
|
||||
"M4 22H40M13 13L4 22L13 31M31 13L40 22L31 31",
|
||||
"M22 4V40M13 13L22 4L31 13M13 31L22 40L31 31"};
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const auto value =
|
||||
l.at("orders").at(lineup_selected_)[size_t(i)].get<int>();
|
||||
const auto icon =
|
||||
lineup_svg("<path d=\"" + std::string(paths[size_t(i)]) +
|
||||
"\" fill=\"none\" stroke=\"" +
|
||||
std::string(theme_ == "silver" ? "#25617a"
|
||||
: theme_ == "matchday" ? "#efb2aa"
|
||||
: "#a9dccb") +
|
||||
"\" stroke-width=\"3\"/>",
|
||||
"0 0 44 44");
|
||||
out += "<label class=\"lineup-order-row\" style=\"top:" +
|
||||
scalar(135 + (i / 2) * 132.0) +
|
||||
"dp;left:" + scalar((i % 2) * (lineup_order_width_dp + 40.0)) +
|
||||
"dp;\"><span class=\"lineup-order-icon\">" +
|
||||
picture(renderer_.diagram("lineup-order-icon-" +
|
||||
std::to_string(i) + "-" + theme_,
|
||||
icon, 88),
|
||||
44, 44) +
|
||||
"</span><input type=\"range\" min=\"2\" max=\"40\" step=\"1\" "
|
||||
"value=\"" +
|
||||
std::to_string(value) + "\" id=\"lineup-order-" +
|
||||
std::to_string(i) + "\" data-lineup-order=\"" +
|
||||
std::to_string(i) + "\" data-player=\"" +
|
||||
esc(lineup_selected_) + "\" aria-label=\"Anweisung " +
|
||||
std::to_string(i + 1) +
|
||||
"\"/><span class=\"lineup-order-value\" "
|
||||
"id=\"lineup-order-value-" +
|
||||
std::to_string(i) + "\">" + std::to_string(value) +
|
||||
"</span></label>";
|
||||
}
|
||||
} else
|
||||
out += "<p class=\"lineup-hint\">Die vier Vorschauwerte gelten für "
|
||||
"Spieler in der Startelf.</p>";
|
||||
out += "</section>";
|
||||
} else {
|
||||
out += "<section class=\"lineup-takers\"><h2>Schützen</h2>";
|
||||
const std::array<const char *, 3> labels{"Freistoß", "Elfmeter",
|
||||
"Eckball"};
|
||||
const auto option_text = [](const std::string &name) {
|
||||
return "<span class=\"lineup-option-mark\" aria-hidden=\"true\"><span "
|
||||
"class=\"lineup-option-check\"></span></span><span "
|
||||
"class=\"lineup-option-text\">" +
|
||||
esc(name) + "</span>";
|
||||
};
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
out += "<label class=\"lineup-taker-label\" style=\"left:" +
|
||||
scalar(i * (lineup_taker_width_dp + 18.0)) + "dp;\"><span>" +
|
||||
std::string(labels[size_t(i)]) +
|
||||
"</span><select class=\"lineup-taker\" "
|
||||
"data-select-max-height=\"280\" id=\"lineup-taker-" +
|
||||
std::to_string(i) + "\" data-lineup-taker=\"" +
|
||||
std::to_string(i) + "\" aria-label=\"" +
|
||||
std::string(labels[size_t(i)]) +
|
||||
"schütze\"><option value=\"\" " +
|
||||
std::string(l.at("takers")[size_t(i)] == ""
|
||||
? "selected=\"selected\""
|
||||
: "") +
|
||||
">" + option_text("AUTO") + "</option>";
|
||||
for (size_t r = 0; r < std::min(size_t(field_count), rows.size());
|
||||
++r) {
|
||||
const auto id = rows[r].at("id").get<std::string>();
|
||||
out += "<option value=\"" + esc(id) + "\" " +
|
||||
std::string(l.at("takers")[size_t(i)] == id
|
||||
? "selected=\"selected\""
|
||||
: "") +
|
||||
">" + option_text(rows[r].at("name").get<std::string>()) +
|
||||
"</option>";
|
||||
}
|
||||
out += "</select></label>";
|
||||
}
|
||||
out += btn("lineup-auto", "Automatisch", "lineup-auto",
|
||||
"id=\"lineup-auto\"") +
|
||||
"</section>";
|
||||
}
|
||||
out+="</div></aside>";
|
||||
out += "</div></aside>";
|
||||
} else {
|
||||
out+="<footer class=\"lineup-team-actions\">"+data_btn()+view_btn()+"<span>"+std::to_string(std::min(size_t(11),rows.size()))+" Spieler auf dem Feld · "+std::to_string(std::min(lineup_bench_limit,rows.size()>lineup_start_limit?rows.size()-lineup_start_limit:0))+" Ersatzbank · "+std::to_string(rows.size()>lineup_start_limit+lineup_bench_limit?rows.size()-lineup_start_limit-lineup_bench_limit:0)+" weitere Spieler</span></footer>";
|
||||
const auto bench = std::min(indoor ? size_t(5) : lineup_bench_limit,
|
||||
rows.size() > size_t(field_count)
|
||||
? rows.size() - size_t(field_count)
|
||||
: 0);
|
||||
const auto reserves = rows.size() > size_t(field_count) + bench
|
||||
? rows.size() - size_t(field_count) - bench
|
||||
: 0;
|
||||
out += "<footer class=\"lineup-team-actions\">" + data_btn() + view_btn() +
|
||||
"<span>" +
|
||||
std::to_string(std::min(size_t(field_count), rows.size())) +
|
||||
" Spieler auf dem Feld · " + std::to_string(bench) +
|
||||
(indoor ? " Wechselspieler · " : " Ersatzbank · ") +
|
||||
std::to_string(reserves) + " Reserve</span></footer>";
|
||||
}
|
||||
out+="</div>";
|
||||
return out+render_report_detail();
|
||||
out += "</div>";
|
||||
return out + render_report_detail();
|
||||
}
|
||||
@@ -244,6 +244,7 @@ Json DemoSource::read_statistics(const Json &request) const {
|
||||
ActionResult DemoSource::apply(const Action &action) {
|
||||
if (action.revision != revision_)
|
||||
return {false, revision_, "stale_revision"};
|
||||
if(state_.value("career",Json::object()).value("ended",false)&&action.kind!="start")return {false,revision_,"career_ended"};
|
||||
auto next = state_;
|
||||
try {
|
||||
if (action.kind == "career") {
|
||||
|
||||
@@ -27,7 +27,7 @@ std::string App::report_club_button(const std::string &id, bool name_first) {
|
||||
"\">" + name + "</span>";
|
||||
return btn("club-detail", name_first ? text + crest(c, 42) : crest(c, 42) + text,
|
||||
std::string("report-club-button ") + (name_first ? "name-first " : "") +
|
||||
(manager(snap()).value("club", "") == id ? "current" : ""),
|
||||
(snap().state.at("career").value("role","club")=="club"&&manager(snap()).value("club", "") == id ? "current" : ""),
|
||||
"id=\"report-club-" + esc(id) + "\" data-id=\"" + esc(id) + "\"");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,22 +16,23 @@ void App::init_desktop() {
|
||||
std::string App::render_desktop() {
|
||||
init_desktop();
|
||||
const auto s = snap();
|
||||
widget_data_ = demo_desktop_widgets(*world_, s.state);
|
||||
widget_data_=demo_desktop_widgets(*world_,s.state);
|
||||
const bool national=s.state.at("career").value("role", "club")=="national";
|
||||
const auto *c = club(s);
|
||||
std::string out =
|
||||
"<div class=\"desktop-layer\"><div class=\"info-bar\">" +
|
||||
btn("desktop-context",
|
||||
crest(c, 82) + "<span><strong>" + esc(c ? world_->name(*c) : "") +
|
||||
(national?img("career.national-de",82,82,false,false,256):crest(c,82)) + "<span><strong>" + esc(national?"Deutschland":c ? world_->name(*c) : "") +
|
||||
"</strong><small>" + esc(manager(s).value("name", "")) +
|
||||
"</small></span>",
|
||||
"identity", "id=\"desktop-identity\"") +
|
||||
"<div class=\"info-date\">" + std::string(widget_data_.at("matchday")==0?"Saisonvorbereitung":std::to_string(widget_data_.at("matchday").get<int>())+". Spieltag") + "<small>" +
|
||||
esc(widget_data_.at("season").get<std::string>()) +
|
||||
"</small></div><div class=\"info-cash\"><small>Guthaben</small><strong>" +
|
||||
cash(s.state.value("cash", int64_t(0))) + "</strong></div></div>";
|
||||
"</small></div><div class=\"info-cash\"><small>"+std::string(national?"Aufgabenbereich":"Guthaben")+"</small><strong>" +
|
||||
(national?std::string("Nationalmannschaft"):cash(s.state.value("cash", int64_t(0)))) + "</strong></div></div>";
|
||||
if(desktop_.value("grid",true))for(int row=0;row<7;++row)for(int col=0;col<15;++col)out+="<span class=\"desktop-grid-dot\" style=\"left:"+std::to_string(64+col*248)+"dp;top:"+std::to_string(224+row*248)+"dp;\"></span>";
|
||||
for (const auto &[id, o] : desktop_["objects"].items()) {
|
||||
if (!o.value("visible", false))
|
||||
if (!o.value("visible", false) || (o.value("widget",false)?!demo_career_widget_available(s.state,id):!demo_career_menu_available(s.state,id.substr(4))))
|
||||
continue;
|
||||
const auto style = rect(o.value("x", 0), o.value("y", 0), o.value("w", 224),
|
||||
o.value("h", 224)) + "z-index:" + std::to_string(o.value("z", 1)) + ";";
|
||||
@@ -65,7 +66,7 @@ std::string App::render_desktop() {
|
||||
"style=\"decorator:linear-gradient(140deg," +
|
||||
top + "," + bottom + ");\">" +
|
||||
img("button." + route, 146, 146, false, false, 256) +
|
||||
"</div><span class=\"app-name\">" + esc(route=="transfer"?"Transfer":title(route)) + "</span>" +
|
||||
"</div><span class=\"app-name\">" + esc(route=="newplayer"?"Manager":route=="transfer"?"Transfer":title(route)) + "</span>" +
|
||||
(o.value("pinned", true) ? "<div class=\"pin-dot\"></div>" : "") +
|
||||
"</button>";
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ void stadium_view_defaults(Json &v) {
|
||||
}
|
||||
std::string stadium_managed(const Snapshot &s) {
|
||||
const auto &m=stadium_field(s.state,"managers");
|
||||
return m.is_array()&&!m.empty()&&stadium_field(m[0],"club").is_string()?m[0].at("club").get<std::string>():"";
|
||||
return m.is_array()&&!m.empty()&&stadium_field(m[0],"club").is_string()?demo_career_manager(s.state).value("club",""):"";
|
||||
}
|
||||
std::string stadium_money(const Json &value,const Catalog &world) {
|
||||
return value.is_number_integer()?money(value.get<int64_t>(),world.manifest().value("currency",Json::object())):"—";
|
||||
|
||||
@@ -35,7 +35,7 @@ std::string transfer_ui_role(const Json &v) {
|
||||
: "—";
|
||||
}
|
||||
std::string transfer_ui_club(const Snapshot &s) {
|
||||
return s.state.at("managers")[0].at("club").get<std::string>();
|
||||
return demo_career_manager(s.state).value("club", "");
|
||||
}
|
||||
Json transfer_ui_find(const Json &rows, const std::string &id) {
|
||||
if (rows.is_array())
|
||||
|
||||
+24
-6
@@ -15,6 +15,7 @@
|
||||
#include "modern/ui/demo_opening.hpp"
|
||||
#include "modern/ui/demo_sports.hpp"
|
||||
#include "modern/ui/demo_lineup.hpp"
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include "modern/ui/demo_transfer.hpp"
|
||||
#include "modern/ui/demo_career_reports.hpp"
|
||||
#include "modern/ui/demo_rankings.hpp"
|
||||
@@ -458,7 +459,7 @@ class App final : public Rml::EventListener {
|
||||
}
|
||||
Snapshot snap() const { return source_->snapshot(); }
|
||||
const Json &manager(const Snapshot &s) const {
|
||||
return s.state.at("managers").at(0);
|
||||
return demo_career_manager(s.state);
|
||||
}
|
||||
const Json *club(const Snapshot &s) const {
|
||||
return s.world->find("clubs", manager(s).value("club", ""));
|
||||
@@ -761,7 +762,7 @@ class App final : public Rml::EventListener {
|
||||
bool entry_name_valid() const;
|
||||
bool entry_used_club(const std::string &) const;
|
||||
bool entry_used_portrait(int) const;
|
||||
bool entry_full() const { return adding_manager_ && managers_draft_.size() >= 4; }
|
||||
bool entry_full() const { return adding_manager_ && managers_draft_.size() >= size_t(career_national_entry()?1:4); }
|
||||
void entry_begin();
|
||||
void entry_add();
|
||||
void entry_cancel();
|
||||
@@ -773,6 +774,14 @@ class App final : public Rml::EventListener {
|
||||
bool entry_input(Rml::Element *);
|
||||
bool entry_event(Rml::Event &);
|
||||
Json entry_snapshot() const;
|
||||
bool career_resign_open_=false,career_game_end_=false;
|
||||
int career_resign_portrait_=0;
|
||||
uint64_t career_resign_revision_=0;
|
||||
const DataSource *career_resign_source_=nullptr;
|
||||
bool career_national_entry() const {return adding_manager_?source_&&!snap().state.at("edits").at("setup").value("league",true):!start_options_.value("league",true);}
|
||||
std::string render_career();
|
||||
bool career_action(const std::string &,Rml::Element *);
|
||||
bool career_event(Rml::Event &);
|
||||
std::string render_newgame();
|
||||
std::string render_manager();
|
||||
std::string render_opening();
|
||||
@@ -856,6 +865,7 @@ class App final : public Rml::EventListener {
|
||||
}
|
||||
void render() {
|
||||
if (select_menu_) select_menu_->before_render();
|
||||
if (source_ && scene_=="desktop" && snap().state.value("career",Json::object()).value("ended",false)){scene_="main";menu_.clear();}
|
||||
if (scene_ == "desktop" && !files_capturing_ && opening_pending()) {
|
||||
scene_ = "opening";
|
||||
menu_.clear();
|
||||
@@ -919,11 +929,13 @@ class App final : public Rml::EventListener {
|
||||
else if (scene_ == "mods")
|
||||
markup = mods_page();
|
||||
else if (scene_ == "newgame")
|
||||
markup = render_newgame();
|
||||
markup = main_menu()+"<div class=\"fill\" style=\"z-index:100;\">"+render_newgame()+"</div>";
|
||||
else if (scene_ == "manager")
|
||||
markup = render_manager();
|
||||
markup = (adding_manager_?render_desktop():main_menu())+"<div class=\"fill\" style=\"z-index:100;\">"+render_manager()+"</div>";
|
||||
else if (scene_ == "managerhub")
|
||||
markup = render_desktop()+"<div class=\"fill\" style=\"z-index:100;\">"+render_career()+"</div>";
|
||||
else if (scene_ == "opening")
|
||||
markup = render_opening();
|
||||
markup = main_menu()+"<div class=\"fill\" style=\"z-index:100;\">"+render_opening()+"</div>";
|
||||
else if (source_)
|
||||
markup = render_desktop();
|
||||
if (!menu_.empty())
|
||||
@@ -937,6 +949,10 @@ class App final : public Rml::EventListener {
|
||||
doc_->QuerySelectorAll(behind, "#entry-manager-underlay button,#entry-manager-underlay input,#entry-manager-underlay select,.window>.titlebar button");
|
||||
for (auto *node : behind) node->SetProperty("pointer-events", "none");
|
||||
}
|
||||
if(scene_=="managerhub" || (scene_=="manager"&&adding_manager_)){
|
||||
Rml::ElementList background;doc_->QuerySelectorAll(background,".desktop-layer button,.desktop-layer [data-action]");
|
||||
for(auto *node:background){node->SetProperty("pointer-events","none");node->SetAttribute("tabindex",-1);}
|
||||
}
|
||||
news_after_render();
|
||||
if (!report_detail_kind_.empty() || !planning_dialog_.empty() || !contracts_dialog_.empty() || !toto_dialog_.empty() || !transfer_dialog_.empty() || !career_view_.value("dialog", "").empty() || !stadium_view_.value("dialog", "").empty()) {
|
||||
Rml::ElementList behind;
|
||||
@@ -1303,7 +1319,7 @@ public:
|
||||
active_mod_.clear();
|
||||
load_world(config_.world);
|
||||
scene_ = config_.scene;
|
||||
if (scene_ != "main" && scene_ != "mods" && scene_ != "newgame" && scene_ != "manager" &&
|
||||
if (scene_ != "main" && scene_ != "mods" && scene_ != "newgame" && scene_ != "manager" && scene_ != "managerhub" &&
|
||||
scene_ != "opening" && scene_ != "desktop") {
|
||||
menu_ = scene_;
|
||||
scene_ = "desktop";
|
||||
@@ -1386,6 +1402,8 @@ public:
|
||||
}
|
||||
};
|
||||
#include "modern/ui/entry_controls.inc"
|
||||
#include "modern/ui/career_screens.inc"
|
||||
#include "modern/ui/career_controls.inc"
|
||||
#include "modern/ui/entry_screens.inc"
|
||||
#include "modern/ui/entry_opening_controls.inc"
|
||||
#include "modern/ui/entry_opening_screens.inc"
|
||||
|
||||
@@ -75,6 +75,10 @@ std::string App::widget(const std::string &id, const Json &o) {
|
||||
const auto heading = [&](const std::string &name, bool link = true) {
|
||||
return widget_heading(name, link);
|
||||
};
|
||||
if(s.state.at("career").value("role","club")=="national"){
|
||||
if(id=="crest"||id=="opponent-crest")return "<div class=\"desk-logo-surface\">"+img(id=="crest"?"career.national-de":"career.national-fr",std::min(w-48,h-138),std::min(w-48,h-138),false,false,768)+"</div><div class=\"desk-logo-caption\"><small>"+(id=="crest"?std::string("Dein Nationalteam"):"Nächster Gegner")+"</small><strong>"+(id=="crest"?std::string("Deutschland"):"Frankreich")+"</strong></div>";
|
||||
if(id=="competition")return heading("Nächste Begegnung")+"<div class=\"desk-fixture\"><div>"+img("career.national-de",80,80,false,false,256)+"<span>Deutschland</span></div><div class=\"desk-fixture-centre\"><small>Fiktives Länderspiel</small><strong>19:00</strong><span>Heim · Samstag</span></div><div>"+img("career.national-fr",80,80,false,false,256)+"<span>Frankreich</span></div></div>";
|
||||
}
|
||||
if (id == "calendar")
|
||||
return "<div class=\"desk-calendar-month\"><span>" +
|
||||
esc(widget_data_.at("month").get<std::string>()) +
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_career.hpp"
|
||||
#include "modern/ui/demo_career_reports.hpp"
|
||||
#include "modern/ui/demo_files.hpp"
|
||||
#include "modern/ui/demo_finance.hpp"
|
||||
#include "modern/ui/demo_lineup.hpp"
|
||||
#include "modern/ui/demo_opening.hpp"
|
||||
#include "modern/ui/demo_stadium.hpp"
|
||||
#include "modern/ui/demo_statistics.hpp"
|
||||
#include "modern/ui/demo_widgets.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/model.hpp"
|
||||
#include <iostream>
|
||||
@@ -110,6 +116,27 @@ int main() {
|
||||
"manager select");
|
||||
require(demo_career_manager(source.snapshot().state).at("portrait") == 2,
|
||||
"requested active identity");
|
||||
const auto selected_state = source.snapshot().state;
|
||||
const auto selected_club =
|
||||
demo_career_manager(selected_state).value("club", "");
|
||||
require(demo_desktop_widgets(*f.world, selected_state).at("own") ==
|
||||
selected_club,
|
||||
"widget projection follows active manager");
|
||||
require(demo_contract_rows(selected_state, *f.world).at("ok") == true,
|
||||
"contracts query accepts active club snapshot");
|
||||
require(demo_stadium_view(selected_state, *f.world).at("club") ==
|
||||
selected_club,
|
||||
"stadium query follows active manager");
|
||||
require(demo_statistics(*f.world, selected_state).at("club") ==
|
||||
selected_club,
|
||||
"statistics own club follows active manager");
|
||||
require(demo_highscores(*f.world, selected_state).at("manager") ==
|
||||
demo_career_manager(selected_state).at("name"),
|
||||
"highscore identity follows active manager");
|
||||
require(DemoFiles::career_metadata(selected_state)
|
||||
.at("current_manager")
|
||||
.at("portrait") == 2,
|
||||
"save metadata follows selected snapshot manager");
|
||||
auto context = demo_career_context(source.snapshot().state, *f.world);
|
||||
require(context.at("active_managers").size() == 4, "four active humans");
|
||||
require(act({{"kind", "role"}, {"value", "national"}}).ok, "national role");
|
||||
|
||||
Reference in new issue
Block a user