557 lines
28 KiB
C++
557 lines
28 KiB
C++
// SPDX-License-Identifier: GPL-3.0-only
|
||
namespace {
|
||
// Shared with lineup_controls.inc: proportional outer pitch and its border-free
|
||
// art box.
|
||
constexpr double lineup_roster_height_dp = 1216.0;
|
||
constexpr double lineup_pitch_top_dp = 1256.0;
|
||
constexpr double lineup_pitch_height_dp = 608.0;
|
||
constexpr double lineup_pitch_width_dp = lineup_pitch_height_dp * 196.0 / 117.0;
|
||
constexpr double lineup_pitch_border_dp = 2.0;
|
||
constexpr double lineup_art_width_dp =
|
||
lineup_pitch_width_dp - 2.0 * lineup_pitch_border_dp;
|
||
constexpr double lineup_art_height_dp =
|
||
lineup_pitch_height_dp - 2.0 * lineup_pitch_border_dp;
|
||
constexpr double lineup_player_size_dp = 126.0 * lineup_pitch_width_dp / 1920.0;
|
||
constexpr double lineup_player_anchor_x_dp = lineup_player_size_dp * 0.5;
|
||
constexpr double lineup_player_anchor_y_dp = lineup_player_size_dp * 0.61;
|
||
constexpr double lineup_controls_width_dp =
|
||
2612.0 - lineup_pitch_width_dp - 40.0;
|
||
constexpr double lineup_formation_width_dp =
|
||
(lineup_controls_width_dp - 18.0) / 2.0;
|
||
constexpr double lineup_tools_width_dp = lineup_controls_width_dp - 16.0;
|
||
constexpr double lineup_order_width_dp = (lineup_tools_width_dp - 40.0) / 2.0;
|
||
constexpr double lineup_taker_width_dp = (lineup_tools_width_dp - 36.0) / 3.0;
|
||
constexpr int lineup_pitch_raster_px = 2048;
|
||
// Current demo follows the Classic German/Modern24-slot markers:11 start,6
|
||
// bench. This is not a universal match rule; a future session adapter supplies
|
||
// its DTO status. See game/lineup.cpp DispatchLiveOverview and
|
||
// ui/lineup_tests.cpp fixture markers.
|
||
constexpr size_t lineup_start_limit = 11;
|
||
constexpr size_t lineup_bench_limit = 6;
|
||
std::string lineup_status(size_t slot, bool indoor = false) {
|
||
if (indoor)
|
||
return slot < 6 ? "Hallen-Sechs" : slot < 11 ? "Wechselpaar" : "Reserve";
|
||
return slot < lineup_start_limit ? "Startelf"
|
||
: slot < lineup_start_limit + lineup_bench_limit ? "Ersatzbank"
|
||
: "—";
|
||
}
|
||
std::string lineup_managed(const Snapshot &s) {
|
||
return demo_career_manager(s.state).value("club", "");
|
||
}
|
||
std::string lineup_position(const Json &v) {
|
||
if (!v.is_string())
|
||
return "—";
|
||
const auto code = v.get<std::string>();
|
||
return code == "gk" ? "TW"
|
||
: code == "def" ? "ABW"
|
||
: code == "mid" ? "MIT"
|
||
: code == "fwd" ? "STU"
|
||
: code.empty() ? "—"
|
||
: code;
|
||
}
|
||
std::string lineup_value(const Json &v) {
|
||
if (!v.is_number())
|
||
return "—";
|
||
if (v.is_number_integer())
|
||
return number(v.get<int64_t>());
|
||
if (!std::isfinite(v.get<double>()))
|
||
return "—";
|
||
std::ostringstream out;
|
||
out << std::setprecision(5) << v.get<double>();
|
||
auto text = out.str();
|
||
std::replace(text.begin(), text.end(), '.', ',');
|
||
return text;
|
||
}
|
||
int lineup_slot(const Json &l, const std::string &id) {
|
||
if (!l.is_object() || !l.contains("order") || !l.at("order").is_array())
|
||
return -1;
|
||
const auto &a = l.at("order");
|
||
const auto p = std::find(a.begin(), a.end(), id);
|
||
return p == a.end() ? -1 : int(p - a.begin());
|
||
}
|
||
std::string lineup_svg(const std::string &body,
|
||
const std::string &box = "0 0 120 72") {
|
||
return "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"" + box + "\">" +
|
||
body + "</svg>";
|
||
}
|
||
std::string lineup_mini(const Json &points, const std::string &theme,
|
||
size_t limit = 11) {
|
||
const auto line = theme == "silver" ? "#536f66" : "#c3e8cb";
|
||
std::string body =
|
||
"<g stroke=\"" + std::string(line) +
|
||
"\" stroke-width=\"1\" fill=\"none\"><path d=\"M2 2H118V70H2Z M60 2V70 "
|
||
"M2 20H19V52H2 M118 20H101V52H118\"/><circle cx=\"60\" cy=\"36\" "
|
||
"r=\"9\"/></g>";
|
||
if (points.is_array())
|
||
for (size_t i = 0; i < std::min(limit, points.size()); ++i) {
|
||
const auto &p = points[i];
|
||
const int depth = p[0].get<int>(), lane = p[1].get<int>();
|
||
const auto color = theme == "silver" ? (depth < 7 ? "#85600c"
|
||
: depth < 13 ? "#a46914"
|
||
: "#b44931")
|
||
: (depth < 7 ? "#ffdc69"
|
||
: depth < 13 ? "#ecac4b"
|
||
: "#f07852");
|
||
body += "<circle cx=\"" + scalar(8 + depth / 18.0 * 104) + "\" cy=\"" +
|
||
scalar(8 + lane / 8.0 * 56) + "\" r=\"2.6\" fill=\"" + color +
|
||
"\"/>";
|
||
}
|
||
return lineup_svg(body);
|
||
}
|
||
std::string lineup_field(bool indoor = false) {
|
||
std::string body;
|
||
for (int x = 0; x < 196; x += 15)
|
||
body += "<rect x=\"" + std::to_string(x) +
|
||
"\" width=\"15\" height=\"117\" fill=\"" +
|
||
(indoor ? (x % 30 ? "#c89460" : "#bd854e")
|
||
: (x % 30 ? "#306b4c" : "#2d6447")) +
|
||
"\"/>";
|
||
body +=
|
||
"<svg viewBox=\"0 0 120 72\" width=\"196\" height=\"117\"><g "
|
||
"fill=\"none\" stroke=\"#cfdfd2\" stroke-width=\".45\">"
|
||
"<path d=\"M7 2H113V70H7Z M60 2V70 M7 15.84H23.5V56.16H7 M113 "
|
||
"15.84H96.5V56.16H113 M7 26.84H12.5V45.16H7 M113 26.84H107.5V45.16H113 "
|
||
"M7 32.34H5V39.66H7 M113 32.34H115V39.66H113 M23.5 28.8Q30 36 23.5 43.2 "
|
||
"M96.5 28.8Q90 36 96.5 43.2 M8 2A1 1 0 0 1 7 3 M112 2A1 1 0 0 0 113 3 M7 "
|
||
"69A1 1 0 0 1 8 70 M112 70A1 1 0 0 1 113 69\"/>"
|
||
"<circle cx=\"60\" cy=\"36\" r=\"9.15\"/></g><g fill=\"#cfdfd2\"><circle "
|
||
"cx=\"60\" cy=\"36\" r=\".4\"/><circle cx=\"18\" cy=\"36\" "
|
||
"r=\".3\"/><circle cx=\"102\" cy=\"36\" r=\".3\"/></g></svg>";
|
||
return lineup_svg(body, "0 0 196 117");
|
||
}
|
||
std::string lineup_zone(const Json &l, const std::string &id) {
|
||
const int row = lineup_slot(l, id);
|
||
if (row < 0 || row >= 11)
|
||
return "";
|
||
const auto &point = l.at("points")[size_t(row)],
|
||
&orders = l.at("orders").at(id);
|
||
const double forward = orders[0].get<int>(), width = orders[1].get<int>(),
|
||
coverage = orders[2].get<int>();
|
||
const double x = (8 + point[0].get<int>() / 18.0 * 84) * 1.96,
|
||
y = (10 + point[1].get<int>() / 8.0 * 80) * 1.17;
|
||
double x0 = x - (width / 2 + 46 - forward), x1 = x + width / 2 + forward + 8;
|
||
std::string body = "<g fill=\"#ed5b61\" fill-opacity=\".46\">";
|
||
for (int n = 0; n <= int(coverage / 2); ++n) {
|
||
if (n) {
|
||
const int bend = (n == 8 ? 3 : 0) + (n == 6 ? 2 : 0) + (n == 3 ? 1 : 0);
|
||
if (x0 < x1 - (1 + bend) * 2 - 20) {
|
||
x0 += 1 + bend;
|
||
x1 -= 1 + bend;
|
||
}
|
||
}
|
||
const double lo = std::max(3.0, x0), hi = std::min(192.0, x1);
|
||
if (hi > lo)
|
||
for (const auto yy :
|
||
{std::max(2.0, y - n - 1), std::min(114.0, y + n + 1)})
|
||
body += "<rect x=\"" + scalar(lo) + "\" y=\"" + scalar(yy) +
|
||
"\" width=\"" + scalar(hi - lo) + "\" height=\"1\"/>";
|
||
}
|
||
return lineup_svg(body + "</g>", "0 0 196 117");
|
||
}
|
||
} // namespace
|
||
|
||
std::string App::render_lineup() {
|
||
const auto s = engine_mode_ ? Snapshot{0, world_, Json()} : snap();
|
||
if (!s.world)
|
||
return "<p class=\"lineup-empty\">Die Aufstellung ist derzeit nicht "
|
||
"verfügbar.</p>";
|
||
const auto projection =
|
||
engine_mode_ ? engine_lineup_projection(engine_data_) : demo_lineup_rows(s.state, *s.world, lineup_managed(s));
|
||
if (!projection.value("ok", false))
|
||
return "<p class=\"lineup-empty\">Die Aufstellung ist derzeit nicht "
|
||
"verfügbar.</p>";
|
||
const auto &l = engine_mode_ ? projection.at("board") : demo_lineup_visible(s.state);
|
||
const auto &rows = projection.at("rows");
|
||
const int field_count = engine_mode_ ? projection.at("field_count").get<int>() : demo_career_field_count(s.state);
|
||
const bool indoor = !engine_mode_ && field_count == 6;
|
||
if (lineup_slot(l, lineup_selected_) < 0)
|
||
lineup_selected_.clear();
|
||
lineup_data_ = lineup_data_ == 1 ? 1 : 0;
|
||
lineup_page_ = lineup_page_ == 1 ? 1 : 0;
|
||
if (lineup_side_ != "orders" && lineup_side_ != "takers")
|
||
lineup_side_ = "formations";
|
||
const auto attr = [](const std::string &key, const std::string &value) {
|
||
return " " + key + "=\"" + esc(value) + "\"";
|
||
};
|
||
const auto player_attrs = [&](const Json &row, const std::string &prefix) {
|
||
const auto id = row.at("id").get<std::string>();
|
||
return attr("id", prefix + id) + attr("data-id", id) +
|
||
attr("data-squad-player", id) +
|
||
attr("data-slot", std::to_string(row.at("slot").get<size_t>())) +
|
||
attr("aria-pressed", lineup_selected_ == id ? "true" : "false") +
|
||
attr("aria-label", row.at("name").get<std::string>() + ", " +
|
||
lineup_position(row.at("position")));
|
||
};
|
||
std::string out = "<div id=\"lineup-underlay\" class=\"lineup-screen " +
|
||
std::string(lineup_pitch_ ? "pitch-view" : "team-view") +
|
||
(indoor ? " indoor-lineup" : "") +
|
||
"\"><div class=\"lineup-roster\"><div class=\"lineup-row "
|
||
"lineup-head\" role=\"row\">";
|
||
const std::array<std::array<const char *, 12>, 2> headings{
|
||
{{{"Nr.", "Name", "Pos.", "Ko", "Te", "Fo", "Stärke", "Status", "Land",
|
||
"Mot.", "Tore", "Ass."}},
|
||
{{"Nr.", "Name", "Alter", "Eck.", "Frei.", "Zwei.", "Pass", "Schuss",
|
||
"Schn.", "Team", "Spiele", "Note"}}}};
|
||
for (int c = 0; c < 12; ++c)
|
||
out += "<span class=\"lineup-cell lineup-col-" + std::to_string(c) +
|
||
"\"><span>" + headings[size_t(lineup_data_)][size_t(c)] +
|
||
"</span></span>";
|
||
out +=
|
||
"</div><div id=\"lineup-roster-scroll\" class=\"lineup-roster-scroll\" "
|
||
"tabindex=\"0\" aria-label=\"Kaderliste, scrollbar\" role=\"table\">";
|
||
for (const auto &row : rows) {
|
||
const auto slot = row.at("slot").get<int>();
|
||
const auto id = row.at("id").get<std::string>();
|
||
out += "<div class=\"lineup-row " + std::string(slot % 2 ? "even " : "") +
|
||
(slot == field_count ? "reserve-start " : "") +
|
||
(lineup_selected_ == id ? "selected" : "") + "\" role=\"row\">";
|
||
out += "<span class=\"lineup-cell lineup-col-0\"><span>" +
|
||
(slot < field_count ? std::to_string(slot + 1) : "–") +
|
||
"</span></span>";
|
||
out += btn("lineup-player", esc(row.at("name").get<std::string>()),
|
||
"lineup-cell lineup-col-1 lineup-name",
|
||
player_attrs(row, "lineup-name-"));
|
||
std::vector<std::string> fields;
|
||
if (!lineup_data_)
|
||
fields = {lineup_position(row.at("position")),
|
||
lineup_value(row.at("condition")),
|
||
lineup_value(row.at("technique")),
|
||
lineup_value(row.at("form")),
|
||
lineup_value(row.at("strength")),
|
||
engine_mode_ ? row.at("status").get<std::string>() : lineup_status(size_t(slot), indoor),
|
||
row.at("nation").is_string()
|
||
? row.at("nation").get<std::string>()
|
||
: "—",
|
||
lineup_value(row.at("motivation")),
|
||
lineup_value(row.at("goals")),
|
||
lineup_value(row.at("assists"))};
|
||
else
|
||
for (const auto *key :
|
||
{"age", "corner", "free_kick", "tackling", "passing", "shooting",
|
||
"speed", "teamplay", "games", "grade"})
|
||
fields.push_back(lineup_value(row.at(key)));
|
||
for (size_t f = 0; f < fields.size(); ++f) {
|
||
std::string value = esc(fields[f]);
|
||
if (!lineup_data_ && f == 6 && row.at("nation").is_string()) {
|
||
auto code = row.at("nation").get<std::string>();
|
||
if (code.starts_with("nation:"))
|
||
code = code.substr(7);
|
||
if (code == "de")
|
||
value = picture(
|
||
renderer_.diagram(
|
||
"lineup-flag-de",
|
||
lineup_svg("<path fill=\"#111111\" d=\"M0 0H40V8H0Z\"/><path "
|
||
"fill=\"#bc302e\" d=\"M0 8H40V16H0Z\"/><path "
|
||
"fill=\"#edc758\" d=\"M0 16H40V24H0Z\"/>",
|
||
"0 0 40 24"),
|
||
80),
|
||
40, 24);
|
||
else {
|
||
const auto flag = ui_nation_flag_svg(code);
|
||
if (!flag.empty())
|
||
value = picture(renderer_.diagram("lineup-flag-" + code, flag, 80),
|
||
40, 24);
|
||
else {
|
||
// Legacy placeholders are identifiers, not useful country labels.
|
||
const bool country_code =
|
||
code.size() == 2 &&
|
||
std::all_of(code.begin(), code.end(), [](unsigned char c) {
|
||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||
});
|
||
if (country_code) {
|
||
std::transform(
|
||
code.begin(), code.end(), code.begin(),
|
||
[](unsigned char c) { return char(std::toupper(c)); });
|
||
value = esc(code);
|
||
} else
|
||
value = "—";
|
||
}
|
||
}
|
||
}
|
||
if (!lineup_data_ && f == 5)
|
||
value = "<span class=\"lineup-status\">" + value + "</span>";
|
||
out += btn("player-detail", value,
|
||
"lineup-cell lineup-col-" + std::to_string(f + 2) +
|
||
" lineup-detail",
|
||
attr("id", "lineup-detail-" + id + "-" + std::to_string(f)) +
|
||
attr("data-id", id) +
|
||
attr("aria-label", row.at("name").get<std::string>() +
|
||
", Spielerinformationen"));
|
||
}
|
||
out += "</div>";
|
||
}
|
||
if (rows.empty())
|
||
out += "<p class=\"lineup-empty\">Für diesen Verein sind keine Spieler "
|
||
"überliefert.</p>";
|
||
out += "</div></div>";
|
||
const auto data_btn = [&]() {
|
||
return btn("lineup-data", lineup_data_ ? "Daten A" : "Daten B",
|
||
"lineup-tab", "id=\"lineup-data\"");
|
||
};
|
||
const auto view_btn = [&]() {
|
||
return btn("lineup-view", lineup_pitch_ ? "Team" : "Spielfeld",
|
||
"lineup-tab", "id=\"lineup-view\"");
|
||
};
|
||
out +=
|
||
"<nav class=\"lineup-surface-controls\" "
|
||
"aria-label=\"Spielfeldvariante\">" +
|
||
btn("lineup-surface", "Rasen · 11", indoor ? "" : "selected",
|
||
"id=\"lineup-surface-outdoor\" data-id=\"outdoor\" aria-pressed=\"" +
|
||
(indoor ? std::string("false") : "true") + "\" " + (engine_mode_ ? "disabled" : "")) +
|
||
btn("lineup-surface", "Halle · 6", indoor ? "selected" : "",
|
||
"id=\"lineup-surface-indoor\" data-id=\"indoor\" aria-pressed=\"" +
|
||
(indoor ? std::string("true") : "false") + "\" " +
|
||
(engine_mode_ || s.state.at("career").value("role", "club") == "national"
|
||
? "disabled"
|
||
: "")) +
|
||
"</nav>";
|
||
if (lineup_pitch_) {
|
||
out += "<div id=\"lineup-pitch\" class=\"lineup-pitch\" role=\"group\" "
|
||
"aria-label=\"" + std::string(engine_mode_ ? "Spielfeld, Spieler auswählen" : "Spielfeld, Spieler auswählen oder ziehen") + "\"><div "
|
||
"class=\"lineup-field-art\">" +
|
||
picture(renderer_.diagram("lineup-field", lineup_field(indoor),
|
||
lineup_pitch_raster_px),
|
||
lineup_art_width_dp, lineup_art_height_dp) +
|
||
"</div>";
|
||
if (!engine_mode_ && lineup_side_ == "orders" && !lineup_selected_.empty()) {
|
||
const auto zone = lineup_zone(l, lineup_selected_);
|
||
if (!zone.empty())
|
||
out += "<div id=\"lineup-zone\" class=\"lineup-order-zone\">" +
|
||
picture(renderer_.diagram("lineup-zone", zone,
|
||
lineup_pitch_raster_px),
|
||
lineup_art_width_dp, lineup_art_height_dp) +
|
||
"</div>";
|
||
}
|
||
for (size_t i = 0; i < std::min(size_t(field_count), rows.size()); ++i) {
|
||
const auto &row = rows[i], &point = l.at("points")[i];
|
||
if (point.is_null()) continue;
|
||
const bool selected = lineup_selected_ == row.at("id").get<std::string>();
|
||
const auto x =
|
||
(8 + point[0].get<int>() / double(l.value("depth_max", 18)) * 84) * lineup_art_width_dp / 100.0 -
|
||
lineup_player_anchor_x_dp;
|
||
const auto y =
|
||
(10 + point[1].get<int>() / double(l.value("lane_max", 8)) * 80) * lineup_art_height_dp / 100.0 -
|
||
lineup_player_anchor_y_dp;
|
||
out +=
|
||
btn("lineup-player",
|
||
img(selected ? "lineup.player.selected" : "lineup.player.normal",
|
||
lineup_player_size_dp, lineup_player_size_dp) +
|
||
"<span class=\"lineup-jersey\">" + std::to_string(i + 1) +
|
||
"</span>",
|
||
"lineup-player",
|
||
player_attrs(row, "lineup-player-") +
|
||
attr("style", rect(x, y, lineup_player_size_dp,
|
||
lineup_player_size_dp)));
|
||
}
|
||
out += "<div id=\"lineup-ghost\" class=\"lineup-ghost\">" +
|
||
img("lineup.player.ghost", lineup_player_size_dp,
|
||
lineup_player_size_dp) +
|
||
"</div></div><aside class=\"lineup-controls\"><nav "
|
||
"class=\"lineup-tabs\" aria-label=\"Aufstellungsansichten\">" +
|
||
data_btn() + view_btn();
|
||
for (const auto &[side, label] :
|
||
std::array<std::pair<const char *, const char *>, 3>{
|
||
{{"formations", "Aufst."},
|
||
{"orders", "Anweis."},
|
||
{"takers", "Schütze"}}})
|
||
out += btn(
|
||
"lineup-side", label, "lineup-tab",
|
||
attr("id", "lineup-side-" + std::string(side)) +
|
||
attr("data-id", side) +
|
||
attr("aria-pressed", lineup_side_ == side ? "true" : "false") + (engine_mode_ ? " disabled" : ""));
|
||
out += "</nav><div class=\"lineup-side\" id=\"lineup-side\">";
|
||
if (engine_mode_) out += engine_lineup_controls();
|
||
else if (lineup_side_ == "formations") {
|
||
for (int slot = 0; slot < 4; ++slot) {
|
||
const int i = slot + lineup_page_ * 4;
|
||
const auto point = i < 4 ? demo_lineup_formations(indoor)[size_t(i)]
|
||
: l.at("custom")[size_t(i - 4)];
|
||
const auto mini = lineup_mini(point, theme_, size_t(field_count));
|
||
const std::string label = i < 4 ? "Aufstellung " + std::to_string(i + 1)
|
||
: "Eigene " + std::to_string(i - 3);
|
||
// Rasterize thin SVG strokes at the actual output density, avoiding
|
||
// undersampling of a large texture in this small fixed-size preview.
|
||
const int mini_pixels=std::clamp(int(std::lround(200.0*scale_)),32,520);
|
||
const auto art = picture(
|
||
renderer_.diagram("lineup-mini-" + std::to_string(i) + "-" + theme_+"-"+std::to_string(mini_pixels),
|
||
mini, mini_pixels),
|
||
200, 120);
|
||
out += "<div class=\"lineup-formation-cell " +
|
||
std::string(i >= 4 ? "custom" : "") + "\" style=\"" +
|
||
rect((slot % 2) * (lineup_formation_width_dp + 18.0),
|
||
(slot / 2) * 172.0, lineup_formation_width_dp, 160) +
|
||
"\">";
|
||
out += btn("lineup-formation",
|
||
"<span class=\"lineup-mini\">" + art +
|
||
"</span><span class=\"lineup-formation-label\">" +
|
||
label + "</span>",
|
||
"lineup-formation",
|
||
attr("id", "lineup-formation-" + std::to_string(i)) +
|
||
attr("data-id", std::to_string(i)) +
|
||
attr("aria-pressed",
|
||
l.at("formation") == i ? "true" : "false") +
|
||
(point.is_null() ? " disabled=\"disabled\"" : ""));
|
||
if (i >= 4)
|
||
out += btn("lineup-save", "Merken", "lineup-save",
|
||
attr("id", "lineup-save-" + std::to_string(i - 4)) +
|
||
attr("data-id", std::to_string(i - 4)));
|
||
out += "</div>";
|
||
}
|
||
const auto arrow = [&](bool next) {
|
||
return picture(
|
||
renderer_.diagram(
|
||
next ? "lineup-next" : "lineup-prev",
|
||
lineup_svg("<path d=\"" +
|
||
std::string(next ? "M8 3L17 12L8 21"
|
||
: "M16 3L7 12L16 21") +
|
||
"\" fill=\"none\" stroke=\"" +
|
||
std::string(theme_ == "silver" ? "#233443"
|
||
: "#dce5ee") +
|
||
"\" stroke-width=\"2\"/>",
|
||
"0 0 24 24"),
|
||
48),
|
||
32, 32);
|
||
};
|
||
out += "<nav class=\"lineup-pages\" aria-label=\"Aufstellungsseiten\">" +
|
||
btn("lineup-page", arrow(false), "lineup-page",
|
||
"id=\"lineup-page-prev\" data-id=\"0\" "
|
||
"aria-label=\"Vorgegebene Aufstellungen\" " +
|
||
std::string(lineup_page_ == 0 ? "disabled=\"disabled\""
|
||
: "")) +
|
||
"<span>" +
|
||
(lineup_page_ ? "Eigene Aufstellungen"
|
||
: "Vorgegebene Aufstellungen") +
|
||
"</span>" +
|
||
btn("lineup-page", arrow(true), "lineup-page",
|
||
"id=\"lineup-page-next\" data-id=\"1\" aria-label=\"Eigene "
|
||
"Aufstellungen\" " +
|
||
std::string(lineup_page_ == 1 ? "disabled=\"disabled\""
|
||
: "")) +
|
||
"</nav><div class=\"lineup-weights\">";
|
||
const std::array<const char *, 3> names{"Position", "Seite / Rolle",
|
||
"Frische"};
|
||
for (int i = 0; i < 3; ++i) {
|
||
const int weight = l.at("weights")[size_t(i)].get<int>();
|
||
std::string bars = "<span class=\"lineup-weight-bars\">";
|
||
for (int n = 0; n < 3; ++n)
|
||
bars += "<span class=\"lineup-weight-bar " +
|
||
std::string(n < weight ? "active" : "") + "\"></span>";
|
||
out += btn("lineup-weight",
|
||
"<span class=\"lineup-weight-label\">" +
|
||
std::string(names[size_t(i)]) + "</span>" + bars +
|
||
"</span>",
|
||
"lineup-weight",
|
||
attr("id", "lineup-weight-" + std::to_string(i)) +
|
||
attr("data-id", std::to_string(i)) +
|
||
attr("aria-label",
|
||
std::string(names[size_t(i)]) + " Gewichtung " +
|
||
std::to_string(weight) + " von 3"));
|
||
}
|
||
out += "</div>";
|
||
} else if (lineup_side_ == "orders") {
|
||
const int slot = lineup_slot(l, lineup_selected_);
|
||
out += "<section class=\"lineup-orders\"><h2>Anweisungen</h2><p "
|
||
"class=\"lineup-order-name\">" +
|
||
esc(slot >= 0 ? rows[size_t(slot)].at("name").get<std::string>()
|
||
: "Einen Feldspieler auswählen.") +
|
||
"</p>";
|
||
if (slot >= 0 && slot < field_count) {
|
||
const std::array<const char *, 4> paths{
|
||
"M8 34L34 8M14 8H34V28", "M8 34L34 8M8 14V34H28",
|
||
"M4 22H40M13 13L4 22L13 31M31 13L40 22L31 31",
|
||
"M22 4V40M13 13L22 4L31 13M13 31L22 40L31 31"};
|
||
for (int i = 0; i < 4; ++i) {
|
||
const auto value =
|
||
l.at("orders").at(lineup_selected_)[size_t(i)].get<int>();
|
||
const auto icon =
|
||
lineup_svg("<path d=\"" + std::string(paths[size_t(i)]) +
|
||
"\" fill=\"none\" stroke=\"" +
|
||
std::string(theme_ == "silver" ? "#25617a"
|
||
: theme_ == "matchday" ? "#efb2aa"
|
||
: "#a9dccb") +
|
||
"\" stroke-width=\"3\"/>",
|
||
"0 0 44 44");
|
||
out += "<label class=\"lineup-order-row\" style=\"top:" +
|
||
scalar(135 + (i / 2) * 132.0) +
|
||
"dp;left:" + scalar((i % 2) * (lineup_order_width_dp + 40.0)) +
|
||
"dp;\"><span class=\"lineup-order-icon\">" +
|
||
picture(renderer_.diagram("lineup-order-icon-" +
|
||
std::to_string(i) + "-" + theme_,
|
||
icon, 88),
|
||
44, 44) +
|
||
"</span><input type=\"range\" min=\"2\" max=\"40\" step=\"1\" "
|
||
"value=\"" +
|
||
std::to_string(value) + "\" id=\"lineup-order-" +
|
||
std::to_string(i) + "\" data-lineup-order=\"" +
|
||
std::to_string(i) + "\" data-player=\"" +
|
||
esc(lineup_selected_) + "\" aria-label=\"Anweisung " +
|
||
std::to_string(i + 1) +
|
||
"\"/><span class=\"lineup-order-value\" "
|
||
"id=\"lineup-order-value-" +
|
||
std::to_string(i) + "\">" + std::to_string(value) +
|
||
"</span></label>";
|
||
}
|
||
} else
|
||
out += "<p class=\"lineup-hint\">Die vier Vorschauwerte gelten für "
|
||
"Spieler in der Startelf.</p>";
|
||
out += "</section>";
|
||
} else {
|
||
out += "<section class=\"lineup-takers\"><h2>Schützen</h2>";
|
||
const std::array<const char *, 3> labels{"Freistoß", "Elfmeter",
|
||
"Eckball"};
|
||
const auto option_text = [](const std::string &name) {
|
||
return "<span class=\"lineup-option-mark\" aria-hidden=\"true\"><span "
|
||
"class=\"lineup-option-check\"></span></span><span "
|
||
"class=\"lineup-option-text\">" +
|
||
esc(name) + "</span>";
|
||
};
|
||
for (int i = 0; i < 3; ++i) {
|
||
out += "<label class=\"lineup-taker-label\" style=\"left:" +
|
||
scalar(i * (lineup_taker_width_dp + 18.0)) + "dp;\"><span>" +
|
||
std::string(labels[size_t(i)]) +
|
||
"</span><select class=\"lineup-taker\" "
|
||
"data-select-max-height=\"280\" id=\"lineup-taker-" +
|
||
std::to_string(i) + "\" data-lineup-taker=\"" +
|
||
std::to_string(i) + "\" aria-label=\"" +
|
||
std::string(labels[size_t(i)]) +
|
||
"schütze\"><option value=\"\" " +
|
||
std::string(l.at("takers")[size_t(i)] == ""
|
||
? "selected=\"selected\""
|
||
: "") +
|
||
">" + option_text("AUTO") + "</option>";
|
||
for (size_t r = 0; r < std::min(size_t(field_count), rows.size());
|
||
++r) {
|
||
const auto id = rows[r].at("id").get<std::string>();
|
||
out += "<option value=\"" + esc(id) + "\" " +
|
||
std::string(l.at("takers")[size_t(i)] == id
|
||
? "selected=\"selected\""
|
||
: "") +
|
||
">" + option_text(rows[r].at("name").get<std::string>()) +
|
||
"</option>";
|
||
}
|
||
out += "</select></label>";
|
||
}
|
||
out += btn("lineup-auto", "Automatisch", "lineup-auto",
|
||
"id=\"lineup-auto\"") +
|
||
"</section>";
|
||
}
|
||
out += "</div></aside>";
|
||
} else {
|
||
const auto bench = engine_mode_ ? size_t(std::count_if(rows.begin(), rows.end(), [](const auto &r) { return r.at("role") == "bench"; })) : std::min(indoor ? size_t(5) : lineup_bench_limit,
|
||
rows.size() > size_t(field_count)
|
||
? rows.size() - size_t(field_count)
|
||
: 0);
|
||
const auto reserves = engine_mode_ ? size_t(std::count_if(rows.begin(), rows.end(), [](const auto &r) { return r.at("role") == "reserve"; })) : rows.size() > size_t(field_count) + bench
|
||
? rows.size() - size_t(field_count) - bench
|
||
: 0;
|
||
out += "<footer class=\"lineup-team-actions\">" + data_btn() + view_btn() +
|
||
"<span>" +
|
||
std::to_string(std::min(size_t(field_count), rows.size())) +
|
||
" Spieler auf dem Feld · " + std::to_string(bench) +
|
||
(indoor ? " Wechselspieler · " : " Ersatzbank · ") +
|
||
std::to_string(reserves) + " Reserve</span></footer>";
|
||
}
|
||
out += "</div>";
|
||
return out + (engine_mode_ ? engine_player_profile(projection) : render_report_detail());
|
||
}
|