// SPDX-License-Identifier: GPL-3.0-only std::string App::render_advertising() { const auto snapshot = snap(); const auto view = demo_advertising_view(snapshot.state, *world_); if (!view.value("ok", false)) return {}; const auto brand = [&](const Json &c) { if (c.at("sponsor") == -1) return std::string(); return "() % 5) + "\">" + esc(c.at("name").get()) + ""; }; std::string out = "
"; for (int i = 0; i < 14; ++i) { const auto &c = view.at("slots")[size_t(i)]; out += btn("ad-contract", (c.at("active") == true ? brand(c) : "Platz frei") + "Bande " + std::to_string(i + 1) + "", "advertising-board " + std::string(advertising_selected_ == i ? "selected" : ""), "id=\"ad-contract-" + std::to_string(i) + "\" data-ad-contract=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) + "\" aria-pressed=\"" + (advertising_selected_ == i ? "true" : "false") + "\" aria-label=\"Bande " + std::to_string(i + 1) + ", " + esc(c.at("name").get()) + "\" style=\"" + rect(16 + (i % 7) * (354.285714 + 16), 16 + (i / 7) * 145, 354.285714, 129) + "\""); } out += "
"; const std::array headings{"Trikotwerbung", "Fanartikel", "Öffentlichkeitsarbeit", "Fanbetreuung"}; for (int i = 0; i < 4; ++i) { std::string body = "" + std::string(headings[size_t(i)]) + "
" + img("advertising.panel." + std::to_string(i), 510, 510, false, false, 1000) + "
"; if (i == 0) body += brand(view.at("slots")[14]); else body += "" + esc(cash(view.at("spending")[size_t(i - 1)].at("amount").get())) + ""; out += btn(i == 0 ? "ad-contract" : "ad-spending", body, "advertising-card advertising-panel " + std::string(i == 0 ? "advertising-shirt " : "") + (i == 0 && advertising_selected_ == 14 ? "selected" : ""), "id=\"" + std::string(i == 0 ? "ad-contract-14" : "ad-spending-" + std::to_string(i - 1)) + "\" data-id=\"" + std::to_string(i == 0 ? 14 : i - 1) + "\" " + (i == 0 ? "data-ad-contract=\"14\" aria-pressed=\"" + std::string(advertising_selected_ == 14 ? "true" : "false") + "\" " : "data-ad-spending=\"" + std::to_string(i - 1) + "\" ") + "style=\"" + rect(i * 658.5, 346, 636.5, 650) + "\""); } out += btn("ad-contract", "TV-Rechte
" + img("art.advertising-tv-v1.png", 540, 540, false, false, 1000) + "
" + brand(view.at("slots")[15]), "advertising-card advertising-tv " + std::string(advertising_selected_ == 15 ? "selected" : ""), "id=\"ad-contract-15\" data-ad-contract=\"15\" data-id=\"15\" aria-pressed=\"" + std::string(advertising_selected_ == 15 ? "true" : "false") + "\""); out += "
"; if (advertising_selected_ < 0 || advertising_selected_ > 15) { out += "

Werbung und Vereinsausgaben

" "

Bande, Trikot oder TV-Rechte auswählen.

Die drei Ausgabenbilder öffnen die Zahleneingabe.

"; } else { const auto quote = demo_advertising_quote(snapshot.state, advertising_selected_, advertising_offer_, *world_); const bool active = quote.at("active"); out += "
" + brand(quote) + "
" + btn("ad-offer", "‹", "ad-offer-arrow", "id=\"ad-offer-previous\" data-step=\"-1\" aria-label=\"Vorheriges Angebot\" " + std::string(active ? "disabled" : "")) + btn("ad-offer", "›", "ad-offer-arrow", "id=\"ad-offer-next\" data-step=\"1\" aria-label=\"Nächstes Angebot\" " + std::string(active ? "disabled" : "")) + "
" + esc(quote.at("label").get()) + "" + esc(quote.at("name").get()) + "
Dauer" + std::to_string(quote.at("months").get()) + " Monate
" + (active ? "Vertrag" : "Angebot") + "" + esc(cash(quote.at("amount").get())) + " / Monat
"; } out += "
"; for (const auto &[label, key] : std::array, 3>{{{"Einnahmen", "income"}, {"Ausgaben", "expenses"}, {"Saldo", "balance"}}}) out += "
" + std::string(label) + "" + esc(cash(view.at(key).get())) + "
"; return out + "
"; }