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 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-15 22:05:37 +01:00
1 parent 2b0d528ec7
commit 6020fbc30a
3 files changed
+94 -57

No files matched your search

+28
View File
@@ -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;}
+1 -1
View File
@@ -5,7 +5,7 @@
// The menus that are laid out as a page of the notebook. Every other career menu is still a
// sheet of the old format, shown scaled inside the book.
bool App::page_native() const {
static const std::set<std::string> native{"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<std::string> 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";
+65 -56
View File
@@ -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 = "<div class=\"camp-left\" "
"style=\"position:absolute;left:0;top:0;width:1440dp;"
"bottom:0;\"><div class=\"toolbar camp-regions\">";
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 += "</div><div class=\"camp-map\" "
"style=\"position:absolute;left:0;top:120dp;width:1440dp;height:1603."
"2dp;overflow:hidden;border-radius:10dp;\"><div class=\"camp-map-art\">" +
img("map." + region.substr(4), 1440, 1603.2, false, false, 1600) + "</div>";
std::string region_name, chosen_region; // the map that is shown, and the one the chosen camp lies on
std::string body = "<section class=\"pg-page\"><div class=\"pg-row\"><div class=\"pg-seg camp-regions\">";
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", "<span>" + esc(m.value("name", "")) + "</span>", 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 += "</div><span class=\"pg-mut\">Karte wählen, dann eine Stecknadel anklicken.</span></div><div class=\"pg-row pg-grow\" style=\"align-items:stretch;\">";
// 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", "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-12 -31 24 36\"><ellipse cy=\"1.5\" rx=\"6\" ry=\"2.2\" fill=\"#2e2b25\" opacity=\".25\"/><path d=\"M0 0C-8 -10 -9 -15 -9 -19a9 9 0 0 1 18 0c0 4 -1 9 -9 19z\" fill=\"" +
std::string(on ? "#c8733c" : "#f9f4ed") + "\" stroke=\"" + pin_ink + "\" stroke-width=\"1.5\"/><circle cy=\"-19\" r=\"3.2\" fill=\"" + (on ? "#ffffff" : "#c8733c") + "\"/></svg>", 160), 64, 96);
};
body += "<div class=\"cp-map camp-map\" style=\"width:" + scalar(frame_w) + "dp;\"><div class=\"cp-map-art camp-map-art\" style=\"left:" + scalar(left) + "dp;top:" + scalar(top) + "dp;\">" +
img("map." + region.substr(4), map_w * scale, map_h * scale, false, false, 1800) + "</div><span class=\"cp-map-name\">" + esc(region_name) + "</span>";
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", "<span class=\"camp-pin-dot\"></span>", 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 += "<span class=\"camp-pin-label" + std::string(here ? " chosen" : "") + "\" style=\"left:" + scalar(x) + "dp;top:" + scalar(y + 44) + "dp;\"><span>" +
esc(here ? c.value("name", "") : c.value("place", "")) + "</span></span>";
// 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;\"") +
"<span class=\"cp-pin-label\" style=\"left:" + scalar(x) + "dp;top:" + scalar(y + 12) + "dp;\"><span>" + esc(c.value("place", "")) + "</span></span>";
if (here) mark += "<span class=\"cp-pin-label chosen\" style=\"left:" + scalar(std::clamp(x, 300.0, frame_w - 300)) + "dp;top:" + scalar(y - 134) + "dp;\"><span>" + esc(c.value("name", "")) + "</span></span>";
(here ? front : body) += mark;
}
body += "</div></div><div class=\"camp-card\" "
"style=\"position:absolute;left:1480dp;right:0;top:0;bottom:0;\"><"
"div class=\"camp-photo\" style=\"height:520dp;overflow:hidden;border-radius:8dp;\">" +
img(chosen->value("gui_image", ""), 1060, 520, false, true, 1400) +
"</div><h2 style=\"margin-top:22dp;\">" +
esc(chosen->value("name", "")) +
"</h2><p class=\"small\" style=\"margin-top:14dp;\">" +
esc(chosen->value("place", "")) + "</p>";
const std::array<const char *, 4> qualities = {
"Platzqualität", "Fitnessgeräte", "Verpflegung", "Unterkunft"};
for (size_t i = 0; i < 4; ++i) {
const int q = chosen->at("quality")[i].get<int>();
std::string stars;
for (int j = 0; j < q; ++j)
stars += glyph("star", 44);
body += "<div class=\"field-row\" style=\"min-height:84dp;padding:10dp "
"0;\"><span>" +
std::string(qualities[i]) +
"</span><span class=\"row\" style=\"gap:5dp;color:#d9b96f;\">" +
stars + "</span></div>";
}
body += "<div class=\"field-row camp-price\"><strong>Preis</strong><strong "
"class=\"money-amount\">" +
(chosen->at("price").is_null() ? std::string("—") : (engine_mode_ ? money(chosen->at("price").get<int64_t>(), {{"code", "EUR"}, {"minor_units", 2}}) : cash(chosen->at("price").get<int64_t>()))) + "</strong></div>";
const std::array<const char *, 4> focus = {"Kondition", "Technik", "Spiel",
"Erholung"};
body += front + "<span class=\"cp-compass\">" + picture(renderer_.diagram("camp-compass", "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-27 -27 54 54\"><g stroke=\"#3a332b\" fill=\"none\" stroke-width=\"1.5\" opacity=\".7\"><circle r=\"18\" fill=\"#f4ecdb\"/><path d=\"M0 -25L4.5 0 0 25 -4.5 0Z\" fill=\"#f9f4ed\"/><path d=\"M0 -25L4.5 0H-4.5Z\" fill=\"#c8733c\"/></g></svg>", 160), 122, 122) + "</span></div>";
// the chosen camp
const auto stars = [&](int count) {
std::string svg = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 120 24\">";
for (int i = 0; i < 5; ++i) svg += "<path transform=\"translate(" + std::to_string(i * 24) + " 0) scale(.5)\" d=\"m24 3 6 13 15 2-11 11 3 15-13-7-13 7 3-15L3 18l15-2Z\" fill=\"" + std::string(i < count ? "#c67139" : theme_ == "silver" ? "#d9cfbb" : "#59606b") + "\"/>";
return picture(renderer_.diagram("camp-stars-" + std::to_string(count) + "-" + theme_, svg + "</svg>", 360), 180, 36);
};
const auto price = chosen->at("price").is_null() ? std::string("—") : (engine_mode_ ? money(chosen->at("price").get<int64_t>(), {{"code", "EUR"}, {"minor_units", 2}}) : cash(chosen->at("price").get<int64_t>()));
body += "<div class=\"pg-col pg-grow\" style=\"" + pg_css("gap:10px;") + "\"><div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:8px;padding:12px 14px;") + "\"><div class=\"cp-photo camp-photo\">" +
img(chosen->value("gui_image", ""), 918, 400, false, true, 1400) + "</div><div class=\"pg-row\" style=\"justify-content:space-between;align-items:flex-end;\"><div class=\"pg-grow\"><h3 class=\"pg-h\" style=\"font-size:" + pg(22) + ";line-height:" + pg(27) + ";\">" +
esc(chosen->value("name", "")) + "</h3><span class=\"pg-mut\" style=\"display:block;\">" + esc(chosen->value("place", "") + (chosen_region.empty() ? "" : " · " + chosen_region)) + "</span></div><div style=\"text-align:right;\">" + pg_kicker("Preis") +
"<strong class=\"pg-h\" style=\"font-size:" + pg(22) + ";line-height:" + pg(27) + ";\">" + esc(price) + "</strong></div></div><div class=\"cp-ratings\">";
const std::array<const char *, 4> qualities = {"Platzqualität", "Fitnessgeräte", "Verpflegung", "Unterkunft"};
for (size_t i = 0; i < 4; ++i) body += "<div class=\"cp-rating\"><span>" + std::string(qualities[i]) + "</span>" + stars(chosen->at("quality")[i].get<int>()) + "</div>";
body += "</div></div><div class=\"pg-panel pg-col\" style=\"" + pg_css("gap:7px;padding:12px 14px;") + "\">" + pg_kicker("Schwerpunkte");
const std::array<const char *, 4> 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<int>();
body += "<div class=\"field-row\" style=\"min-height:100dp;padding:8dp "
"0;\"><label>" +
std::string(focus[size_t(i)]) +
"</label><input type=\"range\" id=\"camp-focus-" +
std::to_string(i) + "\" data-input=\"camp-focus\" data-id=\"" +
std::to_string(i) + "\" min=\"0\" max=\"15\" step=\"1\" value=\"" +
std::to_string(value) + "\" style=\"width:400dp;" + std::string(i == 3 && focus_changed ? "visibility:hidden;" : "") + "\" " +
(i == 3 ? "disabled" : "") + "/><span id=\"camp-value-" +
std::to_string(i) +
"\" style=\"width:145dp;flex-shrink:0;text-align:right;\">" +
body += "<div class=\"cp-focus" + std::string(i == 3 ? " rest" : "") + "\"><label>" + std::string(focus[size_t(i)]) + "</label><input type=\"range\" class=\"cp-range\" id=\"camp-focus-" + std::to_string(i) +
"\" data-input=\"camp-focus\" data-id=\"" + std::to_string(i) + "\" min=\"0\" max=\"15\" step=\"1\" value=\"" + std::to_string(value) + "\" aria-label=\"" + focus[size_t(i)] + "\" style=\"" +
std::string(i == 3 && focus_changed ? "visibility:hidden;" : "") + "\" " + (i == 3 ? "disabled" : "") + "/><span id=\"camp-value-" + std::to_string(i) + "\">" +
(i == 3 && focus_changed ? std::string("—") : std::to_string(value) + " / 15") + "</span></div>";
}
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 &quote = 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 += "<div class=\"row camp-book-row\" "
"style=\"margin-top:26dp;justify-content:flex-end;\">" +
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" : "")) + "</div>" + (engine_mode_ ? "<p class=\"camp-note\" style=\"margin-top:22dp;\">" + esc(engine_busy_ ? engine_operation_ : (booking_note.empty() ? engine_notice_ : booking_note)) + "</p>" : "") + "</div>";
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 += "</div><span class=\"pg-sp\"></span><div class=\"pg-col\" style=\"" + pg_css("gap:6px;") + "\">" +
pg_button("camp-remember", engine_mode_ ? "Verbindlich buchen" : "Vormerken", "primary cp-book", "id=\"camp-book\" " + std::string(allowed ? "" : "disabled=\"disabled\"")) +
"<span class=\"pg-mut cp-note camp-note\">" + esc(note) + "</span></div></div></div></section>";
return body;
}
std::string App::render_menu(const std::string &key) {