Files
Dreierpack-Manager/src/modern/ui/environment_screens.inc
T
MichaelandClaude Fable 5.2 ff9ed94d1b The surroundings with the project's own pictures, kept in the repository
assets/modern/art holds pictures of the project's own with a catalogue; a key named
there is drawn from that folder, whatever a supplied picture pack says about it.
The six cards of the surroundings take theirs from it, framed on the faces.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-15 17:47:07 +01:00

47 lines
4.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// SPDX-License-Identifier: GPL-3.0-only
// The club's surroundings: three youth teams and three members of staff, six cards in two
// rows. Each card carries its monthly budget as a row of stars, its picture and its cost.
std::string App::render_environment() {
const auto snapshot = engine_mode_ ? Snapshot{input_revision(), world_, Json::object()} : snap();
const std::string unavailable = "<div class=\"pg-page\"><div class=\"pg-empty\">Die Umfeldvorschau ist derzeit nicht verfügbar.</div></div>";
if (!snapshot.world) return unavailable;
const auto view = engine_mode_ ? engine_environment_projection(engine_data_) : demo_environment_rows(snapshot.state, *snapshot.world);
if (!view.value("ok", false)) return unavailable;
const auto currency = engine_mode_ ? Json{{"code", "EUR"}, {"minor_units", 2}} : snapshot.world->manifest().value("currency", Json::object());
const auto star = [&](bool active) {
const std::string colour = active ? (theme_ == "silver" ? "#b2622d" : theme_ == "matchday" ? "#3f7a3a" : "#e0a25f") : (theme_ == "silver" ? "#c0b6a5" : theme_ == "matchday" ? "#afc09a" : "#525966");
const std::string svg = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"48\" height=\"48\" viewBox=\"0 0 48 48\">"
"<path fill=\"" + colour + "\" d=\"m24 3 6 13 15 2-11 11 3 15-13-7-13 7 3-15L3 18l15-2Z\"/></svg>";
return picture(renderer_.diagram("environment-star-" + theme_ + (active ? "-funded" : "-unfunded"), svg, 96), 46, 46);
};
const auto &rows = view.at("rows");
int64_t total = 0;
for (const auto &row : rows) total += row.at("cost").get<int64_t>();
page_title_ = "Umfeld – " + money(total, currency) + " pro Monat";
// a card is a third of the page wide; its picture takes the height that is left
const double card_width = (2799 - 2 * 31.5) / 3, picture_width = card_width - 2 * 36 - 4, picture_height = 500;
std::string out = "<div class=\"pg-page\" id=\"environment-ring\"><div class=\"env-grid\">";
for (size_t i = 0; i < rows.size(); ++i) {
const auto &row = rows[i];
const auto name = row.at("name").get<std::string>(), id = row.at("id").get<std::string>();
const auto level = row.at("level").get<int>();
out += "<section class=\"pg-panel pg-col env-card " + id + "\" style=\"width:" + scalar(card_width) + "dp;\" aria-labelledby=\"environment-title-" + std::to_string(i) +
"\"><div class=\"pg-row\" style=\"justify-content:space-between;\"><h2 class=\"pg-h\" id=\"environment-title-" + std::to_string(i) + "\">" + esc(name) + "</h2>" +
(i < 3 ? "<span class=\"pg-tag sage environment-standing\" title=\"Tabellenplatz der Jugendmannschaft\">Platz " + std::to_string(row.at("rank").get<int>()) + " · " + std::to_string(row.at("league").get<int>()) + ". Liga</span>" : std::string()) +
"</div><div class=\"env-stars\" role=\"group\" aria-label=\"" + esc(name + " Budget") + "\">";
for (int value = 0; value <= 6; ++value) {
const bool selected = value == level;
out += btn("environment-level", value ? star(value <= level) : std::string("<span class=\"env-zero\">×</span>"),
"env-level " + std::string(value == 0 ? "zero " : "") + (selected ? "selected" : ""),
"id=\"environment-level-" + std::to_string(i) + "-" + std::to_string(value) + "\" data-index=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(value) +
"\" aria-pressed=\"" + (selected ? "true" : "false") + "\" aria-label=\"" + esc(name + ": " + std::to_string(value) + (value == 1 ? " Stern" : " Sterne")) +
"\" " + std::string(engine_mode_ && value > row.at("max").get<int>() ? "disabled " : "") + "title=\"" + (value ? std::to_string(value) + (value == 1 ? " Stern" : " Sterne") : "Budget auf null setzen") + "\"");
}
out += "</div><div class=\"env-picture\" style=\"height:" + scalar(picture_height) + "dp;\">" +
img("environment." + row.at("image").get<std::string>() + "." + std::to_string(row.at("cell").get<int>()), picture_width, picture_height, false, true, 1024) +
"</div><div class=\"pg-row\" style=\"justify-content:space-between;\"><span class=\"pg-mut\">Monatskosten</span><strong class=\"pg-num environment-cost\" id=\"environment-cost-" + std::to_string(i) +
"\" aria-label=\"" + esc(name + " Monatskosten") + "\">" + esc(money(row.at("cost").get<int64_t>(), currency) + " / Monat") + "</strong></div></section>";
}
return out + "</div><nav class=\"pg-foot\">" + pg_status(engine_mode_ && engine_busy_ ? engine_operation_ : engine_mode_ && !engine_notice_.empty() ? engine_notice_ : std::string("Eine Stufe anklicken, um das Monatsbudget zu ändern.")) + "</nav></div>";
}