A player's card with figures and skills; shirts in the club's colour; table zones; reduced motion

The card shows age, strength, condition, technique and form as numerals, the seven
skills as marks and contract and status as a list. The line-up pitch draws shirts in
the club's colour with a condition dot instead of the data set's figures. League
tables carry the prediction's European places and the promotion and relegation
places. A display setting turns transitions off. The desk hangs from the top edge of
a taller screen.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 18:43:40 +01:00
1 parent 9b33e1f8c1
commit eec7f40a52
16 files changed
+160 -26

No files matched your search

+1 -1
View File
@@ -825,7 +825,7 @@ Json engine_report_squad(const Json &bundle,const Json &read,const std::string &
const auto id=r.at("player").at("id").get<std::string>();require(!id.empty()&&ids.insert(id).second&&r.at("squadTeamId")==team,"Doppelter oder fremder Kaderspieler.");
require(r.at("player").at("name").is_string()&&r.at("player").at("positions").is_array(),"Spieleridentität fehlt.");
}
auto result=data;for(auto &r:result["players"])r["live_strength"]=metric_value(r,"strength");return result;
auto result=data;for(auto &r:result["players"])for(const auto *key:{"strength","condition","technique","form"})r[std::string("live_")+key]=metric_value(r,key);return result;
}
Json engine_fixtures_projection(const Json &bundle,const Json &index,const Json &read,const std::string &league,int round) {
const auto data=engine_report_index(bundle,index);const Json *selected=nullptr;
+1 -1
View File
@@ -34,5 +34,5 @@ std::string App::engine_rankings_player_detail() {
std::string term="—";if(live&&live->at("contractRemaining").is_object())term=number(live->at("contractRemaining").at("value"))+" Monate";
const auto club=r.at("currentTeam").is_object()?engine_text(r.at("currentTeam").at("name")):r.at("club_name").get<std::string>();
const auto body="<div class=\"report-detail-portrait\">"+img(r.at("photo"),496,662.667,true,true,1024)+"</div><p class=\"report-detail-photo-caption\">"+std::string(r.at("currentTeam").is_null()?r.value("source_caption",std::string("Saisonaufzeichnung")):std::string("Porträt"))+"</p>"+report_detail_fields({{"Position",live?report_detail_position(live->at("player")):"—"},{"Alter",live?report_number(live->at("age"))+" Jahre":"—"},{"Stärke",live?report_number(live->at("live_strength")):"—"},{r.at("currentTeam").is_null()?r.value("archive_label",std::string("Archivverein")):std::string("Verein"),club},{"Vertrag",term}},73);
return "<div id=\"report-detail-layer\" class=\"report-detail-layer\"><section id=\"report-detail-dialog\" class=\"report-detail-card report-detail-player\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"report-detail-title\"><h2 id=\"report-detail-title\">"+esc(r.at("name").get<std::string>())+"</h2>"+body+"<nav class=\"report-detail-actions\">"+btn("report-detail-close","Schließen","report-detail-action","id=\"report-detail-close\"")+"</nav></section></div>";
return "<div id=\"report-detail-layer\" class=\"report-detail-layer\"><section id=\"report-detail-dialog\" class=\"report-detail-card report-detail-player listed\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"report-detail-title\"><h2 id=\"report-detail-title\">"+esc(r.at("name").get<std::string>())+"</h2>"+body+"<nav class=\"report-detail-actions\">"+btn("report-detail-close","Schließen","report-detail-action","id=\"report-detail-close\"")+"</nav></section></div>";
}
+7 -1
View File
@@ -198,7 +198,13 @@ std::string App::engine_reports_detail() {
const auto &p=row->at("player");title=engine_text(p.at("name"));auto photo=p.at("photoAssetId").is_string()?p.at("photoAssetId").get<std::string>():"asset:player/"+(report_detail_player_.starts_with("player:")?report_detail_player_.substr(7):report_detail_player_)+"/photo";
actions=btn("report-detail-close","Schließen","report-detail-action","id=\"report-detail-close\"");
std::string term="—";if(row->at("contractRemaining").is_object())term=number(row->at("contractRemaining").at("value"))+" Monate";
body="<div class=\"report-detail-portrait\">"+img(photo,496,662.667,true,true,1024)+"</div><p class=\"report-detail-photo-caption\">Porträt</p>"+report_detail_fields({{"Position",report_detail_position(p)},{"Alter",row->at("age").is_number_integer()?report_number(row->at("age"))+" Jahre":"—"},{"Stärke",report_number(row->at("live_strength"))},{"Verein",engine_text(team.at("name"))},{"Vertrag",term}},73);
body=report_player_card(img(photo,496,662.667,true,true,1024),crest(world_->find("clubs",report_detail_club_),56),engine_text(team.at("name")),report_detail_role(p),
{{"Alter",report_number(row->at("age"))},{"Stärke",report_number(row->at("live_strength"))},{"Kondition",report_number(row->at("live_condition"))},{"Technik",report_number(row->at("live_technique"))},{"Form",report_number(row->at("live_form"))}},
{{"Status",row->at("availability")=="injured"?"Verletzt, noch "+number(row->at("injuryRemaining").at("value"))+" Wo.":row->at("availability")=="suspended"?"Gesperrt, noch "+number(row->at("suspensionRemaining").at("value"))+" Wo.":std::string("Einsatzbereit")},
{"Kader",row->at("role")=="starter"?"Startelf":row->at("role")=="bench"?"Ersatzbank":"Tribüne"},
{"Nation",p.at("nationIds").empty()?std::string("—"):world_->nation_name(p.at("nationIds")[0].get<std::string>())},
{"Vertrag",term},{"Monatsgehalt",row->at("salaryMonthly").is_null()?std::string("—"):engine_price(row->at("salaryMonthly"))}},
row->at("skills"));
}
return "<div id=\"report-detail-layer\" class=\"report-detail-layer\"><section id=\"report-detail-dialog\" class=\"report-detail-card report-detail-"+esc(report_detail_kind_)+"\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"report-detail-title\"><h2 id=\"report-detail-title\">"+esc(title)+"</h2>"+body+"<nav class=\"report-detail-actions\">"+actions+"</nav></section></div>";
}
+1 -1
View File
@@ -49,7 +49,7 @@ void App::engine_render() {
if (auto *roster = element("lineup-roster-scroll")) lineup_roster_scroll_ = lineup_reset_scroll_ ? 0.f : roster->GetScrollTop();
lineup_reset_scroll_ = false;
}
doc_->SetClassNames(theme_);
doc_->SetClassNames(body_classes());
std::string out;
if (engine_data_.empty()) {
out = "<div class=\"fill center\"><div class=\"panel\" style=\"padding:70dp;\"><h1>Dreierpack Manager</h1><p>" +
+1 -1
View File
@@ -31,7 +31,7 @@ std::string App::files_details(bool layouts, bool save) {
for (const auto &[id, object] : payload.at("layout").at("objects").items())
if (object.value("visible", false)) { if (object.value("widget", false)) ++widgets; else ++apps; }
const auto look = payload.at("theme").get<std::string>();
const std::vector<std::pair<std::string, std::string>> meta = {{"Gestaltung", look == "silver" ? "Silver Glass" : look == "matchday" ? "Matchday" : "Midnight Glass"}, {"Widgets", std::to_string(widgets)}, {"Buttons", std::to_string(apps)}, {"Hintergrund", "Stadion bei Nacht"}};
const std::vector<std::pair<std::string, std::string>> meta = {{"Gestaltung", look == "silver" ? "Papier" : look == "matchday" ? "Spieltag" : "Mitternacht"}, {"Widgets", std::to_string(widgets)}, {"Buttons", std::to_string(apps)}, {"Hintergrund", "Stadion bei Nacht"}};
out += "<div class=\"files-metadata\">";
for (const auto &[label, value] : meta) out += "<div class=\"files-metadata-cell\"><span>" + esc(label) + "</span><strong>" + esc(value) + "</strong></div>";
return out + "</div>";
+30 -4
View File
@@ -98,6 +98,19 @@ std::string lineup_mini(const Json &points, const std::string &theme,
}
return lineup_svg(body);
}
// A shirt in the club's colour; the dot at its hem tells the player's condition.
std::string lineup_shirt(const std::string &colour, bool selected, const Json &condition) {
std::string body = "<path d=\"M13 5L4 10L7 18L11 16V35H29V16L33 18L36 10L27 5Q20 10 13 5Z\" fill=\"" + colour +
"\" stroke=\"" + (selected ? "#ffe27a" : "#ffffff") + "\" stroke-width=\"" + (selected ? "2.6" : "1.3") +
"\" stroke-linejoin=\"round\"/><path d=\"M13 5Q20 10 27 5\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"2.2\"/>"
"<path d=\"M11 16V35H29V16\" fill=\"#000000\" fill-opacity=\".12\" stroke=\"none\"/>";
if (condition.is_number_integer()) {
const int value = condition.get<int>();
body += std::string("<circle cx=\"32\" cy=\"32\" r=\"4.2\" fill=\"") + (value >= 85 ? "#3fae6a" : value >= 70 ? "#e0b23c" : "#d9534f") +
"\" stroke=\"#ffffff\" stroke-width=\"1.2\"/>";
}
return lineup_svg(body, "0 0 40 40");
}
std::string lineup_field(bool indoor = false) {
std::string body;
for (int x = 0; x < 196; x += 15)
@@ -339,6 +352,21 @@ std::string App::render_lineup() {
lineup_player_anchor_y_dp;
return std::pair<double, double>{x, y};
};
// the manager's club gives the shirts their colour
std::string shirt_colour;
{
const std::string own = engine_mode_ ? engine_data_.at("desktop").at("meta").at("scope").at("teamId").get<std::string>()
: manager(s).value("club", "");
if (const auto *club = world_->find("clubs", own); club && !club->value("crest", "").empty())
shirt_colour = renderer_.crest_colour(club->value("crest", ""));
if (shirt_colour.empty()) shirt_colour = "#3d5a73";
}
const auto shirt = [&](bool selected, const Json &condition) {
const std::string level = condition.is_number_integer() ? (condition.get<int>() >= 85 ? "a" : condition.get<int>() >= 70 ? "b" : "c") : "n";
return picture(renderer_.diagram("lineup-shirt-" + shirt_colour + (selected ? "-s-" : "-n-") + level,
lineup_shirt(shirt_colour, selected, condition), 160),
lineup_player_size_dp, lineup_player_size_dp);
};
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;
@@ -347,8 +375,7 @@ std::string App::render_lineup() {
const auto [x, y] = marker_position(i);
out +=
btn("lineup-player",
img(selected ? "lineup.player.selected" : "lineup.player.normal",
lineup_player_size_dp, lineup_player_size_dp) +
shirt(selected, row.value("condition", Json())) +
"<span class=\"lineup-jersey\">" + std::to_string(i + 1) +
"</span>",
paired ? "lineup-player lineup-paired" : "lineup-player",
@@ -365,8 +392,7 @@ std::string App::render_lineup() {
out += "<span class=\"lineup-pair-tag\" id=\"lineup-pair-group-" + std::to_string(pair.at("number").get<int>()) + "\" style=\"" + rect((ax + bx + lineup_player_size_dp) / 2 - 24, std::min(ay, by) - 24, 48, 22) + "\"><span>P" + std::to_string(pair.at("number").get<int>()) + "</span></span>";
}
out += "<div id=\"lineup-ghost\" class=\"lineup-ghost\">" +
img("lineup.player.ghost", lineup_player_size_dp,
lineup_player_size_dp) +
shirt(false, Json()) +
"</div></div><aside class=\"lineup-controls\"><nav "
"class=\"lineup-tabs\" aria-label=\"Aufstellungsansichten\">" +
data_btn() + view_btn();
+43 -8
View File
@@ -101,6 +101,39 @@ std::string report_detail_fields(
"</dd></div>";
return result + "</dl>";
}
std::string report_detail_role(const Json &player) {
const auto text = report_detail_position(player);
return text == "TW" ? "Torwart" : text == "ABW" ? "Abwehr" : text == "MIT" ? "Mittelfeld" : text == "STU" ? "Sturm" : text;
}
// The player's card: under the name the club and the role, then the figures a manager
// looks at first as large numerals, then the remaining facts as a list.
std::string report_player_card(const std::string &portrait, const std::string &crest, const std::string &club,
const std::string &role,
const std::vector<std::pair<std::string, std::string>> &figures,
const std::vector<std::pair<std::string, std::string>> &facts,
const Json &skills = Json()) {
std::string out = "<div class=\"report-detail-portrait\">" + portrait + "</div><div class=\"player-card-sub\">" + crest +
"<span>" + esc(club) + " · " + esc(role) + "</span></div><div class=\"player-card-figures\">";
for (const auto &[label, value] : figures)
out += "<div class=\"player-card-figure\"><strong>" + esc(value) + "</strong><span>" + esc(label) + "</span></div>";
out += "</div>";
// the seven skills, each on the engine's scale of none to three marks
out += "<div class=\"player-card-skills\"><h3>Fähigkeiten</h3>";
bool any = false;
for (const auto &[key, label] : std::array<std::pair<const char *, const char *>, 7>{
{{"teamplay", "Spielübersicht"}, {"speed", "Schnelligkeit"}, {"shooting", "Schuss"}, {"passing", "Passspiel"},
{"tackling", "Zweikampf"}, {"free_kick", "Freistöße"}, {"corner", "Ecken"}}}) {
if (!skills.is_object() || !skills.contains(key) || !skills.at(key).is_number_integer()) continue;
const int value = std::clamp(skills.at(key).get<int>(), 0, 3);
any = true;
out += std::string("<div class=\"player-card-skill\"><span>") + label + "</span><div class=\"pips\" title=\"" + std::to_string(value) + " von 3\">";
for (int pip = 0; pip < 3; ++pip) out += pip < value ? "<div class=\"pip on\"></div>" : "<div class=\"pip\"></div>";
out += "</div></div>";
}
if (!any) out += "<p class=\"player-card-none\">Für diesen Spieler liegen keine Einzelwerte vor.</p>";
out += "</div><div class=\"player-card-facts\"><h3>Vertrag und Status</h3>" + report_detail_fields(facts, 64) + "</div>";
return out;
}
} // namespace
std::string App::render_report_detail() {
@@ -234,14 +267,16 @@ std::string App::render_report_detail() {
photo = "asset:player/" + (id.starts_with("player:") ? id.substr(7) : id) +
"/photo";
}
body = "<div class=\"report-detail-portrait\">" +
img(photo, 496, 662.667, true, true, 1024) +
"</div><p class=\"report-detail-photo-caption\">Porträt</p>" +
report_detail_fields({{"Position", report_detail_position(*player)},
{"Alter", report_detail_age(*player, current_date, true)},
{"Stärke", report_detail_strength(*player)},
{"Verein", display_name(club)},
{"Vertrag", report_detail_term(*world_, *player, current_date)}}, 73);
const auto figure = [&](const char *key) {
const auto attributes = player->value("attributes", Json::object());
return attributes.is_object() && attributes.contains(key) && attributes[key].is_number_integer()
? number(attributes[key].get<int64_t>()) : std::string("—");
};
body = report_player_card(img(photo, 496, 662.667, true, true, 1024), crest(club, 56), display_name(club),
report_detail_role(*player),
{{"Alter", report_detail_age(*player, current_date, false)}, {"Stärke", figure("strength")},
{"Kondition", figure("condition")}, {"Technik", figure("technique")}, {"Form", figure("form")}},
{{"Vertrag", report_detail_term(*world_, *player, current_date)}});
actions = close("Schließen");
} else
return {};
+9 -1
View File
@@ -139,7 +139,7 @@ std::string App::render_reports(const std::string &mode) {
body += report_club_button(row.at(column == 0 ? "home" : "away").get<std::string>(), column == 0);
else if (!matches && column == 0) {
if (!strengths) {
const auto zone = engine_mode_?std::string():report_zone(row.value("rank", 0), int(rows.size()), tier);
const auto zone = engine_mode_?row.value("zone", std::string()):report_zone(row.value("rank", 0), int(rows.size()), tier);
body += "<span class=\"report-zone " + zone + "\"></span><span class=\"report-rank\"><span>" +
std::to_string(row.value("rank", 0)) + ".</span></span>";
}
@@ -179,6 +179,14 @@ std::string App::render_reports(const std::string &mode) {
body += "</div>";
if(real_other&&rows.empty())body+="<p class=\"report-detail-empty\">"+std::string(!fixture.at("available").get<bool>()?"Diese Runde ist noch nicht ausgelost oder die vorherige Phase ist noch nicht abgeschlossen.":"Keine Paarungen vorhanden.")+"</p>";
body+="</div>";
if (!matches && !strengths && engine_mode_) {
// only the zones this league has
std::string items;
for (const auto &[kind, label] : std::array<std::pair<const char *, const char *>, 3>{{{"europe", "Europapokal"}, {"promotion", "Aufstieg"}, {"relegation", "Abstieg"}}})
if (std::any_of(rows.begin(), rows.end(), [&](const Json &row) { return row.value("zone", "") == kind; }))
items += "<span class=\"report-legend-item\"><span class=\"report-zone " + std::string(kind) + "\"></span><span>" + label + "</span></span>";
if (!items.empty()) body += "<div class=\"report-legend\">" + items + "</div>";
}
if (!matches && !strengths && !engine_mode_) {
const auto legend = tier == 1
? std::vector<std::pair<std::string, std::string>>{
+5
View File
@@ -248,6 +248,11 @@ std::string App::render_settings() {
(p.at("theme") == type ? "true" : "false") + "\"");
}
pane += "</div></div>";
pane += "<div class=\"settings-group\"><h3>Bewegung</h3>" +
settings_row("preference-motion", "Übergänge und Einblendungen", "Reduziert: Fenster, Karten und Tor-Einblendungen erscheinen ohne Bewegung.",
settings_select("preference-motion", {{"full", "Voll"}, {"reduced", "Reduziert"}},
p.at("display").at("motion").get<std::string>(), "global", "display", "motion")) +
"</div>";
if (engine_mode_) {
int width=0,height=0; SDL_GetWindowSize(video_.window,&width,&height);
pane += "<div class=\"settings-group\"><h3>Fenster</h3><p>" + std::to_string(width) + " × " + std::to_string(height) + " · Automatische Anpassung</p></div>";
+10 -3
View File
@@ -26,7 +26,8 @@ Json default_ui_preferences() {
{{"mode", "window"},
{"resolution", "1920x1080"},
{"scale", "auto"},
{"language", "de"}}},
{"language", "de"},
{"motion", "full"}}},
{"sound", {{"volume", 80}, {"effects", true}, {"style", "classic"}}}};
}
bool valid_ui_preferences(const Json &v) {
@@ -35,7 +36,8 @@ bool valid_ui_preferences(const Json &v) {
!choice(v.at("theme"), {"midnight", "silver", "matchday"}))
return false;
const auto &d = v.at("display"), &s = v.at("sound");
return keys(d, {"mode", "resolution", "scale", "language"}) &&
return keys(d, {"mode", "resolution", "scale", "language", "motion"}) &&
choice(d.at("motion"), {"full", "reduced"}) &&
keys(s, {"volume", "effects", "style"}) &&
choice(d.at("mode"), {"window", "fullscreen"}) &&
choice(d.at("resolution"), {"1280x720", "1600x900", "1920x1080",
@@ -68,7 +70,12 @@ Json legacy_ui_preferences(const Json &legacy) {
Json load_ui_preferences(const fs::path &path) {
if (!fs::exists(path))
return default_ui_preferences();
const auto envelope = Json::parse(editor::read_file(path));
auto envelope = Json::parse(editor::read_file(path));
// a file written before the motion setting existed keeps full motion
if (envelope.is_object() && envelope.contains("preferences") && envelope["preferences"].is_object() &&
envelope["preferences"].contains("display") && envelope["preferences"]["display"].is_object() &&
!envelope["preferences"]["display"].contains("motion"))
envelope["preferences"]["display"]["motion"] = "full";
if (!keys(envelope, {"schema", "preferences"}) ||
envelope.at("schema") != "openbmh-ui-preferences@1" ||
!valid_ui_preferences(envelope.at("preferences")))
+13 -2
View File
@@ -412,6 +412,7 @@ class App final : public Rml::EventListener {
bool initialized_ = false, closed_ = false, dirty_ = true,
needs_render_ = true;
double scale_ = 1, canvas_left_ = 0, canvas_top_ = 0;
bool desk_top_ = false;
// A menu window (2720 x 2040 at the middle of the stage) is shown as large as the screen
// allows; the desk behind it is cropped. Without a window the whole stage is fitted.
bool window_zoom_ = false;
@@ -565,6 +566,11 @@ class App final : public Rml::EventListener {
bool world = false, bool cover = false, int pixels = 512) {
return picture(renderer_.image(key, world, pixels), w, h, cover);
}
// the theme, and "calm" when the player asked for reduced motion
std::string body_classes() const {
return theme_ + (ui_preferences_.is_object() && ui_preferences_.contains("display") &&
ui_preferences_.at("display").value("motion", "full") == "reduced" ? " calm" : "");
}
std::string picture(const Picture &p, double w, double h,
bool cover = false) {
if (p.token.empty())
@@ -922,8 +928,12 @@ class App final : public Rml::EventListener {
void sync_window_zoom() {
const bool wanted = doc_->QuerySelector(".window") != nullptr || doc_->QuerySelector(".live-stage") != nullptr;
if (!wanted) window_shown_ = "\x01";
if (wanted == window_zoom_) return;
// the career's desk hangs from the top edge of a taller screen, so its bar is the
// screen's bar and the spare height shows the stadium below
const bool desk = !wanted && (scene_ == "engine" || scene_ == "desktop");
if (wanted == window_zoom_ && desk == desk_top_) return;
window_zoom_ = wanted;
desk_top_ = desk;
resize();
}
void resize() {
@@ -936,6 +946,7 @@ class App final : public Rml::EventListener {
if (window_zoom_) scale_ = std::max(scale_, std::min(double(pw) / 2760, double(ph) / 2080));
canvas_left_ = (pw - 3840 * scale_) / 2;
canvas_top_ = (ph - 2160 * scale_) / 2;
if (desk_top_ && canvas_top_ > 0) canvas_top_ = 0;
device_ratio_ = float(pw) / w;
renderer_.SetViewport(pw, ph);
context_->SetDimensions({pw, ph});
@@ -1024,7 +1035,7 @@ class App final : public Rml::EventListener {
ticket_->close(false);
context_open_ = false;
context_dirty_ = true;
doc_->SetClassNames(theme_);
doc_->SetClassNames(body_classes());
std::string markup;
if (scene_ == "main")
markup = main_menu();