// SPDX-License-Identifier: GPL-3.0-only // Presentation and selection only. The existing session validates each swap. std::string App::engine_lineup_controls() { return "

Aufstellung

" "

Zwei Spieler zum Tauschen anklicken.

" "

Der Tausch wird erst nach Bestätigung übernommen. " "Formationen, Anweisungen und Schützen sind hier noch nicht angebunden.

" "

" + esc(engine_busy_ ? engine_operation_ : engine_notice_) + "

"; } std::string App::engine_player_profile(const Json &projection) { if (engine_player_.empty()) return {}; const Json *row = nullptr; for (const auto &member : engine_data_.at("squad").at("data").at("players")) if (member.at("player").at("id") == engine_player_) row = &member; if (!row) return {}; Json strength; for (const auto &entry : projection.at("rows")) if (entry.at("id") == engine_player_) strength = entry.at("strength"); const auto &person = row->at("player"); const auto photo = person.at("photoAssetId").is_string() ? person.at("photoAssetId").get() : "asset:player/" + engine_player_ + "/photo"; const auto position = person.at("positions").empty() ? Json() : person.at("positions")[0]; const auto salary = row->at("salaryMonthly").is_null() ? std::string("—") : engine_price(row->at("salaryMonthly")); const auto availability = row->value("availability", ""); const auto status = availability == "fit" ? "Einsatzbereit" : availability == "injured" ? "Verletzt" : availability == "suspended" ? "Gesperrt" : "—"; const auto fields = report_detail_fields({ {"Position", lineup_position(position)}, {"Alter", lineup_value(row->at("age"))}, {"Stärke", lineup_value(strength)}, {"Status", status}, {"Verein", engine_text(engine_data_.at("desktop").at("data").at("team").at("name"))}, {"Monatsgehalt", salary}}, 73); return "
" "

" + esc(person.at("name").get()) + "

" "
" + img(photo, 496, 662.667, true, true, 1024) + "
" + fields + "
"; } bool App::engine_lineup_action(const std::string &action, const std::string &id, Rml::Element *target) { if (!engine_player_.empty()) { if (action == "engine-player-close") { focus_after_render_ = "lineup-detail-" + engine_player_ + "-0"; engine_player_.clear(); refresh(); } return true; } if (menu_ != "lineup") return false; if (action == "lineup-data" || action == "lineup-view") { if (action == "lineup-data") lineup_data_ = 1 - lineup_data_; else { lineup_pitch_ = !lineup_pitch_; lineup_reset_scroll_ = true; } focus_after_render_ = target->GetId(); refresh(); return true; } if (action != "lineup-player" && action != "player-detail") return action.starts_with("lineup-"); const auto projection = engine_lineup_projection(engine_data_); auto order = projection.at("board").at("order"); auto chosen = std::find(order.begin(), order.end(), Json(id)); if (chosen == order.end()) return true; if (action == "player-detail") { engine_player_ = id; focus_after_render_ = "engine-player-close"; refresh(); return true; } if (lineup_selected_.empty() || lineup_selected_ == id) { lineup_selected_ = lineup_selected_ == id ? "" : id; focus_after_render_ = target->GetId(); refresh(); return true; } const auto first = std::find(order.begin(), order.end(), Json(lineup_selected_)); if (first == order.end() || !engine_fresh_) return true; std::iter_swap(first, chosen); const auto command = engine_lineup_command(engine_data_, order, editor::new_id("request:ui-")); std::string first_name, second_name; for (const auto &row : projection.at("rows")) { if (row.at("id") == lineup_selected_) first_name = row.at("name"); if (row.at("id") == id) second_name = row.at("name"); } confirmation(first_name + " und " + second_name + " in der Aufstellung tauschen?", [this, command, id] { lineup_selected_.clear(); focus_after_render_ = "lineup-name-" + id; auto link = engine_link_; engine_start("Aufstellung wird übernommen …", [link, command] { auto response = link->command(command); return EngineReply{link, link->snapshot(), response, nullptr}; }, true); }); return true; }