From 6020fbc30a25068b5478b3e72720152811172c2b Mon Sep 17 00:00:00 2001 From: Weyoune Date: Sun, 15 Nov 2026 22:05:37 +0100 Subject: [PATCH] The training camps as a page: our camps as pins on the map, after the design The map fills its frame and shows the band the camps of a region lie in; the chosen camp stands beside it with its picture, price and ratings, the weights of the week and the booking. Co-Authored-By: Claude Fable 5.2 --- assets/modern/pages.rcss | 28 +++++++++ src/modern/ui/pages.inc | 2 +- src/modern/ui/screens.inc | 121 ++++++++++++++++++++------------------ 3 files changed, 94 insertions(+), 57 deletions(-) diff --git a/assets/modern/pages.rcss b/assets/modern/pages.rcss index 2cb95ce..45d47bc 100644 --- a/assets/modern/pages.rcss +++ b/assets/modern/pages.rcss @@ -662,3 +662,31 @@ body.midnight .sd-stage,body.matchday .sd-stage {background-color:var(--p-n2);} .tt-receipt-row.head {height:54dp;border-top-width:0dp;font-size:23dp;font-weight:bold;letter-spacing:1dp;color:var(--p-n7);} .tt-cell {display:block;flex:1;min-width:0;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;} .tt-cell.first {flex:3;text-align:left;} + +/* --- training camp: the map with its pins, the chosen camp, the weights of the week --- */ +.pg-root .camp-regions button {height:60dp;padding:0 29dp;border-radius:0dp;font-size:29dp;} +.cp-map {position:relative;display:block;flex:none;overflow:hidden;clip:always;border:2dp var(--p-n4);border-radius:54dp;background-color:#eaf3f4;} +body.midnight .cp-map,body.matchday .cp-map {background-color:var(--p-n2);} +.cp-map-art {position:absolute;display:block;pointer-events:none;} +.cp-map-name {position:absolute;left:45dp;top:32dp;display:block;font-family:Display;font-size:54dp;line-height:62dp;color:#2e2b25;font-effect:outline(4dp #f4ecdb);} +body.midnight .cp-map-name,body.matchday .cp-map-name {color:#f0ece2;font-effect:outline(4dp #23262d);} +.cp-pin,.cp-pin:hover,.cp-pin:focus {position:absolute;display:block;width:64dp;height:96dp;padding:0;border:0dp;background-color:transparent;decorator:none;} +.cp-pin:hover {transform:translateY(-5dp);} +.cp-pin-label {position:absolute;display:block;width:0dp;height:0dp;pointer-events:none;} +.cp-pin-label span {position:absolute;left:-250dp;top:0;display:block;width:500dp;height:34dp;line-height:34dp;text-align:center;font-size:26dp;font-weight:bold;white-space:nowrap;color:#2e2b25;font-effect:outline(4dp #f9f4ed);} +.cp-pin-label.chosen span {height:44dp;line-height:44dp;font-family:Display;font-size:34dp;font-weight:normal;} +.cp-compass {position:absolute;right:27dp;bottom:27dp;display:block;width:122dp;height:122dp;pointer-events:none;} +.cp-photo {display:block;width:918dp;height:400dp;overflow:hidden;border-radius:36dp;} +.cp-ratings {display:flex;flex-wrap:wrap;gap:4dp 54dp;} +.cp-rating {display:flex;align-items:center;justify-content:space-between;width:432dp;height:52dp;font-size:28dp;} +.cp-rating span {display:block;color:var(--p-n7);white-space:nowrap;} +.cp-focus {display:flex;align-items:center;gap:22dp;height:62dp;font-size:29dp;} +.cp-focus label {display:block;flex:none;width:202dp;font-weight:bold;} +.cp-focus.rest label {font-weight:normal;color:var(--p-n7);} +.cp-focus span {display:block;flex:none;width:135dp;text-align:right;font-family:Display;font-size:34dp;} +.pg-root .cp-range {display:block;flex:1;min-width:0;height:54dp;padding:0;border:0dp;background-color:transparent;} +.pg-root .cp-range slidertrack {height:9dp;margin:22dp 0;border-radius:5dp;background-color:var(--p-n3);} +.pg-root .cp-range sliderbar {width:40dp;height:40dp;margin-top:7dp;border:4dp var(--p-n1);border-radius:20dp;background-color:var(--p-accent);} +.pg-root .cp-range:disabled sliderbar {background-color:var(--p-s6);} +.pg-root .pg-btn.cp-book {width:100%;height:86dp;font-size:36dp;} +.cp-note {display:block;text-align:center;font-size:28dp;line-height:36dp;} diff --git a/src/modern/ui/pages.inc b/src/modern/ui/pages.inc index 34cf8f4..753d687 100644 --- a/src/modern/ui/pages.inc +++ b/src/modern/ui/pages.inc @@ -5,7 +5,7 @@ // The menus that are laid out as a page of the notebook. Every other career menu is still a // sheet of the old format, shown scaled inside the book. bool App::page_native() const { - static const std::set native{"toto", "settings", "save", "load", "stadium", "statistics", "news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"}; + static const std::set native{"camp", "toto", "settings", "save", "load", "stadium", "statistics", "news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"}; if (menu_ == "calendar" || menu_ == "postpone" || menu_ == "lineup") return notebook_page() && engine_mode_; // a national coach arranges friendlies on the older sheet if (menu_ == "friendlies") return notebook_page() && engine_mode_ && engine_data_.contains("desktop") && engine_data_.at("desktop").at("meta").at("scope").at("role") == "club"; diff --git a/src/modern/ui/screens.inc b/src/modern/ui/screens.inc index 2321af2..1440a14 100644 --- a/src/modern/ui/screens.inc +++ b/src/modern/ui/screens.inc @@ -74,6 +74,8 @@ std::string App::render_desktop() { {"manager", manager(s).value("name", "")}, {"duels", national ? Json(nullptr) : Json{{"won", 2}, {"drawn", 1}, {"lost", 3}}}}; return out + notebook_home(model); } +// Mannschaft > Trainingslager: the map of a region with a pin for every camp, and beside it +// the chosen camp with its picture, price and ratings, the weights of the week, and the booking. std::string App::render_camp() { const auto index_file = Json::parse(editor::read_file(gui_.root() / "gui-assets.json")); @@ -89,53 +91,64 @@ std::string App::render_camp() { auto region = selections_["camp-region"]; if (region.empty()) region = chosen->value("map", "map:eu"); - std::string body = "
"; - for (const auto &m : demo.at("maps")) - body += btn("camp-region", esc(m.value("name", "")), - m.value("id", "") == region ? "primary" : "", - "data-id=\"" + esc(m.value("id", "")) + "\""); - body += "
" + - img("map." + region.substr(4), 1440, 1603.2, false, false, 1600) + "
"; + std::string region_name, chosen_region; // the map that is shown, and the one the chosen camp lies on + std::string body = "
"; + bool first = true; + int shown_maps = 0; + for (const auto &m : demo.at("maps")) { + const bool on = m.value("id", "") == region; + if (on) region_name = m.value("name", ""); + if (m.value("id", "") == chosen->value("map", "")) chosen_region = m.value("name", ""); + body += btn("camp-region", "" + esc(m.value("name", "")) + "", std::string(first ? "first " : "") + (on ? "on" : ""), + "id=\"camp-region-" + std::to_string(shown_maps++) + "\" data-id=\"" + esc(m.value("id", "")) + "\" aria-pressed=\"" + (on ? "true" : "false") + "\""); + first = false; + } + body += "
Karte wählen, dann eine Stecknadel anklicken.
"; + // The map is 1200 x 1336 of its own units. It fills the width of its frame and shows the + // band the camps of the region lie in; only where they spread too far it is shown whole. + constexpr double frame_w = 1782, frame_h = 1529, map_w = 1200, map_h = 1336; + double lowest = map_h, highest = 0; + for (const auto &c : camps) + if (c.value("map", "") == region && c.value("positioned", true)) { lowest = std::min(lowest, c.value("y", 0.0)); highest = std::max(highest, c.value("y", 0.0)); } + double scale = frame_w / map_w, left = 0, top = 0; + const double shown = frame_h / scale; + if (highest >= lowest && highest - lowest < shown - 200) top = -std::clamp((lowest + highest) / 2 - shown / 2 + 20, 0.0, map_h - shown) * scale; + else { scale = frame_h / map_h; left = (frame_w - map_w * scale) / 2; } + const std::string pin_ink = "#3a332b"; + const auto pin = [&](bool on) { + return picture(renderer_.diagram(on ? "camp-pin-on" : "camp-pin", "", 160), 64, 96); + }; + body += "
" + + img("map." + region.substr(4), map_w * scale, map_h * scale, false, false, 1800) + "
" + esc(region_name) + ""; + std::string front; for (const auto &c : camps) if (c.value("map", "") == region && c.value("positioned", true)) { - const double x = c.value("x", 0) * 1.2, y = c.value("y", 0) * 1.2; + const double x = left + c.value("x", 0.0) * scale, y = top + c.value("y", 0.0) * scale; const bool here = c.value("id", "") == id; - body += btn("camp-select", "", here ? "camp-pin chosen" : "camp-pin", - "data-id=\"" + esc(c.value("id", "")) + "\" aria-label=\"" + esc(c.value("name", "")) + "\" style=\"position:absolute;" + rect(x - 40, y - 40, 80, 80) + "\""); - // every camp carries its place on the map; the chosen one its name - body += "" + - esc(here ? c.value("name", "") : c.value("place", "")) + ""; + // the tip of the pin stands on the place; under it the place, over the chosen one its name + std::string mark = btn("camp-select", pin(here), here ? "cp-pin chosen" : "cp-pin", + "data-id=\"" + esc(c.value("id", "")) + "\" aria-label=\"" + esc(c.value("name", "") + ", " + c.value("place", "")) + "\" aria-pressed=\"" + (here ? "true" : "false") + "\" style=\"left:" + scalar(x - 32) + "dp;top:" + scalar(y - 83) + "dp;\"") + + "" + esc(c.value("place", "")) + ""; + if (here) mark += "" + esc(c.value("name", "")) + ""; + (here ? front : body) += mark; } - body += "
<" - "div class=\"camp-photo\" style=\"height:520dp;overflow:hidden;border-radius:8dp;\">" + - img(chosen->value("gui_image", ""), 1060, 520, false, true, 1400) + - "

" + - esc(chosen->value("name", "")) + - "

" + - esc(chosen->value("place", "")) + "

"; - const std::array qualities = { - "Platzqualität", "Fitnessgeräte", "Verpflegung", "Unterkunft"}; - for (size_t i = 0; i < 4; ++i) { - const int q = chosen->at("quality")[i].get(); - std::string stars; - for (int j = 0; j < q; ++j) - stars += glyph("star", 44); - body += "
" + - std::string(qualities[i]) + - "" + - stars + "
"; - } - body += "
Preis" + - (chosen->at("price").is_null() ? std::string("—") : (engine_mode_ ? money(chosen->at("price").get(), {{"code", "EUR"}, {"minor_units", 2}}) : cash(chosen->at("price").get()))) + "
"; - const std::array focus = {"Kondition", "Technik", "Spiel", - "Erholung"}; + body += front + "" + picture(renderer_.diagram("camp-compass", "", 160), 122, 122) + "
"; + // the chosen camp + const auto stars = [&](int count) { + std::string svg = ""; + for (int i = 0; i < 5; ++i) svg += ""; + return picture(renderer_.diagram("camp-stars-" + std::to_string(count) + "-" + theme_, svg + "", 360), 180, 36); + }; + const auto price = chosen->at("price").is_null() ? std::string("—") : (engine_mode_ ? money(chosen->at("price").get(), {{"code", "EUR"}, {"minor_units", 2}}) : cash(chosen->at("price").get())); + body += "
" + + img(chosen->value("gui_image", ""), 918, 400, false, true, 1400) + "

" + + esc(chosen->value("name", "")) + "

" + esc(chosen->value("place", "") + (chosen_region.empty() ? "" : " · " + chosen_region)) + "
" + pg_kicker("Preis") + + "" + esc(price) + "
"; + const std::array qualities = {"Platzqualität", "Fitnessgeräte", "Verpflegung", "Unterkunft"}; + for (size_t i = 0; i < 4; ++i) body += "
" + std::string(qualities[i]) + "" + stars(chosen->at("quality")[i].get()) + "
"; + body += "
" + pg_kicker("Schwerpunkte"); + const std::array focus = {"Kondition", "Technik", "Spiel", "Erholung"}; const auto values = state.at("camp").at("focus"); int sum = 0; for (const auto &v : values) @@ -144,29 +157,25 @@ std::string App::render_camp() { for (int i = 0; i < 4; ++i) { const int recovery = engine_mode_ ? engine_data_.at("camps").at("data").at("focus").value("recovery", 0) : 15 - sum / 3; const int value = i == 3 ? recovery : values[size_t(i)].get(); - body += "
" + + body += "
" + (i == 3 && focus_changed ? std::string("—") : std::to_string(value) + " / 15") + "
"; } std::string booking_note; + bool allowed = !engine_mode_; if (engine_mode_) for (const auto &camp : engine_data_.at("camps").at("data").at("camps")) if (camp.at("id") == id && camp.at("quote").is_object()) { const auto "e = camp.at("quote"); const auto reason = quote.at("reasonCode"); + allowed = engine_fresh_ && quote.value("allowed", false); if (reason == "booked_this_week") booking_note = "Diese Woche wurde bereits ein Trainingslager gebucht."; else if (reason == "visit_limit") booking_note = "Das Trainingslagerlimit dieser Saison ist erreicht."; else if (quote.value("exceedsCash", false)) booking_note = "Der Preis übersteigt das aktuelle Guthaben."; } - body += "
" + - btn("camp-remember", engine_mode_ ? "Verbindlich buchen" : "Vormerken", "primary", "id=\"camp-book\" " + std::string(engine_mode_ && ![&]() { for (const auto &camp : engine_data_.at("camps").at("data").at("camps")) if (camp.at("id") == id) return engine_fresh_ && camp.at("quote").is_object() && camp.at("quote").value("allowed", false); return false; }() ? "disabled" : "")) + "
" + (engine_mode_ ? "

" + esc(engine_busy_ ? engine_operation_ : (booking_note.empty() ? engine_notice_ : booking_note)) + "

" : "") + "
"; + const auto note = engine_mode_ ? (engine_busy_ ? engine_operation_ : booking_note.empty() ? std::string("Die Buchung gilt für die laufende Woche.") : booking_note) : std::string("Das Lager wird für die Woche vorgemerkt."); + body += "
" + + pg_button("camp-remember", engine_mode_ ? "Verbindlich buchen" : "Vormerken", "primary cp-book", "id=\"camp-book\" " + std::string(allowed ? "" : "disabled=\"disabled\"")) + + "" + esc(note) + "
"; return body; } std::string App::render_menu(const std::string &key) {