// SPDX-License-Identifier: GPL-3.0-only namespace { // The three scenes of the manager's picture: which action each one is, its name, what it // does, and where it lies on the picture (left, top, width, height in percent). struct CareerScene { const char *action, *title, *text; double left, top, width, height; }; constexpr std::array career_scenes{{ {"career-resign", "Aufhören", "Dein Amt abgeben. Der Verein wird danach vom Computer geführt.", 0, 0, 49.3, 52.3}, {"career-search", "Vereinssuche", "Bei einem anderen Verein anheuern – noch nicht verfügbar.", 50.1, 0, 49.9, 52.3}, {"career-add", "Neuer Spieler", "Einen weiteren menschlichen Mitspieler einrichten: Name, Land, Liga und Verein.", 0, 53.2, 100, 46.8}}}; std::string career_hint_markup(const std::string &action) { for (const auto &scene : career_scenes) if (action == scene.action) return "" + esc(scene.title) + "· " + esc(scene.text) + ""; return {}; } } // namespace // Optionen > Manager: one picture with three scenes. The pointer lights the scene it is on and // darkens the others; under the picture stands what the scene does. std::string App::render_career() { const auto c = engine_mode_?engine_career_context():demo_career_context(snap().state,*snap().world); const bool ended = c.at("ended"); const Json m = engine_mode_?engine_manager_value_.at("active"):manager(snap()); page_title_ = ended ? "Karriere beendet" : "Manager"; page_hint_ = m.value("name", "") + " · " + c.at("current_team").value("name", "") + " · " + (c.at("role") == "national" ? "Nationalmannschaft" : "Vereinsmanager"); const auto off = [&](const std::string &action) { if (action == "career-search") return true; if (action == "career-resign") return ended || (engine_mode_ && engine_manager_value_.at("can_resign") != true); return ended || (engine_mode_ && engine_manager_value_.at("can_join") != true); }; // 1448 x 1086 on the page: as tall as the page allows constexpr double frame_h = 1485, frame_w = frame_h * 1448 / 1086; std::string body = "
" + img("manager.scenes", frame_w, frame_h, false, false, 2048) + "
"; for (const auto &scene : career_scenes) body += ""; const auto hint = career_hint_markup(career_hint_); body += "
"; // the demo lets one change who plays, as what, and on which ground the line-up is shown std::string people, tasks; if (!engine_mode_) { for (const auto &person : c.at("active_managers")) { const bool on = person.value("portrait", 0) == m.value("portrait", 0); people += pg_button("career-manager", esc(person.value("name", "")), on ? "on" : "", "id=\"career-manager-" + std::to_string(person.value("portrait", 0)) + "\" data-id=\"" + std::to_string(person.value("portrait", 0)) + "\" aria-pressed=\"" + (on ? "true" : "false") + "\""); } for (const auto &role : c.at("available_roles")) { const auto id = role.get(); tasks += pg_button("career-role", id == "club" ? "Verein" : "Nationalmannschaft", c.at("role") == role ? "on" : "", "id=\"career-role-" + id + "\" data-id=\"" + id + "\" aria-pressed=\"" + (c.at("role") == role ? "true" : "false") + "\" " + (ended ? "disabled=\"disabled\"" : "")); } for (const auto *surface : {"outdoor", "indoor"}) tasks += pg_button("career-surface", std::string(surface) == "indoor" ? "Halle" : "Rasen", c.at("surface") == surface ? "on" : "", "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=\"disabled\"" : "")); } body += "
" + people + "
" + hint + "
" + tasks + "
"; if (career_resign_open_ || career_game_end_) { body = "
" + body + "

" + std::string(career_game_end_ ? "Spiel beendet" : "Aufhören?") + "

"; if (career_game_end_) body += "

Es ist kein menschlicher Manager mehr im Amt.

"; else { std::vector> people_rows; for (const auto &person : c.at("active_managers")) { const auto *club = world_->find("clubs", person.value("club", "")); people_rows.emplace_back(std::to_string(person.value("portrait", 0)), person.value("name", "") + " · " + ((engine_mode_ ? c.at("role") != "national" : snap().state.at("edits").at("setup").value("league", true)) ? (club ? world_->name(*club) : "") : "Deutschland")); } body += "
" + select("career-resign-owner", people_rows, std::to_string(career_resign_portrait_), "career-resign-owner") + "
" + (people_rows.size() == 1 ? "Der Verein wird danach vom Computer geführt. Du bist der letzte menschliche Manager: Mit deiner Bestätigung ist das Spiel beendet." : "Der Verein wird danach vom Computer geführt. Die anderen spielen weiter.") + ""; } body += "
"; } return window("Manager", body); }