" +
@@ -198,7 +207,9 @@ bool App::report_picker_action(const std::string &action, Rml::Element *target)
? Json(std::stoi(value)) : Json(value);
close_report_picker(false);
// Commit even an unchanged country: the Gold resets its first league.
- if (kind == "year" && menu_ == "almanac") {
+ if (menu_ == "statistics") {
+ statistics_picker_select(kind, value);
+ } else if (kind == "year" && menu_ == "almanac") {
almanac_year_ = std::stoi(value);
almanac_day_.clear();
almanac_match_.clear();
diff --git a/src/modern/ui/screens.inc b/src/modern/ui/screens.inc
index 06b94c7..441febf 100644
--- a/src/modern/ui/screens.inc
+++ b/src/modern/ui/screens.inc
@@ -154,9 +154,7 @@ std::string App::widget(const std::string &id, const Json &o) {
"style=\"font-size:80dp;padding-top:85dp;\">" +
std::to_string(s.state.value("fans", 67)) + " %";
if (id == "news")
- return heading("Nachrichten") +
- "
Willkommen zur "
- "neuen Saison.
";
+ return render_news_widget(o);
if (id == "results")
return heading("Letzte sechs Spiele") +
"
";
}
std::string App::render_menu(const std::string &key) {
+ if (key == "news")
+ return "
" + render_news() + "
";
std::string body;
if (key == "tables" || key == "strengths" || key == "league" || key == "other")
body = render_reports(key);
@@ -897,6 +897,8 @@ std::string App::render_menu(const std::string &key) {
body = render_highscore();
else if (key == "stadium")
body = render_stadium();
+ else if (key == "statistics")
+ body = render_statistics();
else if (key == "environment")
body = render_environment();
else if (key == "advertising")
@@ -933,5 +935,6 @@ std::string App::render_menu(const std::string &key) {
if (labels.contains(bank_view_)) heading += " · " + labels.at(bank_view_);
}
return "
" +
- window(heading, body) + "
";
+ window(heading, body) +
+ (key == "statistics" ? render_statistics_trophy() : "") + "
";
}
diff --git a/src/modern/ui/statistics_controls.inc b/src/modern/ui/statistics_controls.inc
new file mode 100644
index 0000000..3105225
--- /dev/null
+++ b/src/modern/ui/statistics_controls.inc
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-3.0-only
+bool App::statistics_picker_select(const std::string &kind,const std::string &value) {
+ if(menu_!="statistics"||!source_||statistics_trophy_.contains("asset"))return false;
+ const auto items=statistics_picker_items(kind);
+ if(std::none_of(items.begin(),items.end(),[&](const auto &item){return item.first==value;}))return false;
+ statistics_remember_scroll();
+ if(kind=="winner-country")statistics_view_["winner_country"]=value;
+ else {
+ const auto field=kind=="stat-section"?"section":kind=="stat-category"?"category":"country";
+ statistics_view_[field]=std::stoi(value);
+ }
+ return true;
+}
+bool App::statistics_action(const std::string &action,Rml::Element *target) {
+ if(!action.starts_with("statistics-"))return false;
+ if(menu_!="statistics"||!source_)return true;
+ if(action=="statistics-trophy-close") {
+ if(statistics_trophy_.contains("asset")) {
+ focus_after_render_=statistics_trophy_.value("return_focus","");statistics_trophy_=Json::object();refresh();
+ }
+ return true;
+ }
+ if(!target||statistics_trophy_.contains("asset")||!report_detail_kind_.empty()||!report_picker_.empty())return true;
+ const auto data=source_->read_statistics(statistics_view_);
+ if(!data.value("ok",false))return true;
+ statistics_remember_scroll();
+ if(action=="statistics-absolute"&&data.at("section")==2)statistics_view_["absolute"]=!data.at("absolute").get
();
+ else if(action=="statistics-curve"&&data.at("section")==2) {
+ const int index=target->GetAttribute("data-index",-1);if(index<0||index>=6)return true;
+ auto curves=data.at("curves");curves[size_t(index)]=!curves[size_t(index)].get();statistics_view_["curves"]=curves;
+ } else if(action=="statistics-trophy") {
+ const int r=target->GetAttribute("data-row",-2),c=target->GetAttribute("data-column",-1);
+ if(c<0||c>=int(data.at("columns").size()))return true;
+ Json entry;
+ if(r==-1&&data.at("section")==7)entry=data.at("columns")[size_t(c)];
+ else if(r>=0&&r();
+ if(!world_||(!world_->find("clubs",winner)&&!world_->find("nations",winner)))return true;
+ const std::map captions{{"championship","Deutscher Meister"},{"dfb-cup","DFB-Pokalsieger"},{"supercup","Supercup-Sieger"},{"champions-league","Champions-League-Sieger"},{"cup-winners","Europapokalsieger"},{"uefa-cup","UEFA-Cup-Sieger"},{"world-cup","Weltmeister"},{"european-championship","Europameister"},{"indoor-masters","Hallenmasters-Sieger"},{"en-premier-league","Englischer Meister"},{"en-fa-cup","FA-Cup-Sieger"},{"fr-ligue-1","Französischer Meister"},{"fr-coupe-de-france","Coupe-de-France-Sieger"},{"it-serie-a","Italienischer Meister"},{"it-coppa-italia","Coppa-Italia-Sieger"},{"es-la-liga","Spanischer Meister"},{"es-copa-del-rey","Copa-del-Rey-Sieger"}};
+ const auto title=captions.contains(trophy)?captions.at(trophy):entry.value("text","Sieger");
+ statistics_trophy_={{"asset",asset},{"title",title},{"winner",winner},{"season",entry.value("season",data.value("previous_season",""))},{"return_focus",target->GetId()}};
+ focus_after_render_="statistics-trophy-close";
+ } else return true;
+ if(action!="statistics-trophy")focus_after_render_=target->GetId();
+ refresh();return true;
+}
+bool App::statistics_event(Rml::Event &event) {
+ if(menu_!="statistics")return false;
+ const auto type=event.GetType();const bool keyboard=type=="keydown";
+ const auto key=keyboard?Rml::Input::KeyIdentifier(event.GetParameter("key_identifier",0)):Rml::Input::KI_UNKNOWN;
+ if(statistics_trophy_.contains("asset")) {
+ if((keyboard&&key==Rml::Input::KI_ESCAPE)||(type=="mouseup"&&event.GetParameter("button",0)==1)) {
+ statistics_action("statistics-trophy-close",nullptr);event.StopImmediatePropagation();return true;
+ }
+ if(keyboard&&key==Rml::Input::KI_TAB) {
+ if(auto *close=element("statistics-trophy-close"))close->Focus(true);
+ event.StopImmediatePropagation();return true;
+ }
+ bool inside=false;
+ for(auto *node=event.GetTargetElement();node&&node!=doc_;node=node->GetParentNode())if(node->GetId()=="statistics-trophy-layer")inside=true;
+ if(!inside&&(type=="click"||type=="dblclick"||type=="mousedown"||type=="mouseup"||keyboard)) {event.StopImmediatePropagation();return true;}
+ return false;
+ }
+ if(!keyboard||key!=Rml::Input::KI_TAB||!report_detail_kind_.empty()||!report_picker_.empty())return false;
+ Rml::ElementList controls;
+ if(auto *canvas=element("canvas"))canvas->QuerySelectorAll(controls,".window button,.window input,.window select");
+ std::erase_if(controls,[](auto *node){return !node->IsVisible(true)||node->HasAttribute("disabled");});
+ if(!controls.empty()) {
+ const auto found=std::find(controls.begin(),controls.end(),context_->GetFocusElement());
+ const int old=found==controls.end()?-1:int(found-controls.begin()),count=int(controls.size());
+ const bool back=event.GetParameter("shift_key",0)!=0;
+ const int next=old<0?(back?count-1:0):(old+(back?-1:1)+count)%count;
+ controls[size_t(next)]->Focus(true);controls[size_t(next)]->ScrollIntoView({Rml::ScrollAlignment::Nearest});dirty_=true;
+ }
+ event.StopImmediatePropagation();return true;
+}
diff --git a/src/modern/ui/statistics_screens.inc b/src/modern/ui/statistics_screens.inc
new file mode 100644
index 0000000..4f9a150
--- /dev/null
+++ b/src/modern/ui/statistics_screens.inc
@@ -0,0 +1,186 @@
+// SPDX-License-Identifier: GPL-3.0-only
+namespace {
+std::string statistics_text(const std::string &text) {
+ return ""+esc(text)+" ";
+}
+std::string statistics_scroll_key(const Json &data) {
+ return std::to_string(data.value("section",7))+":"+std::to_string(data.value("category",0))+":"+std::to_string(data.value("country",0))+":"+data.value("winner_country","");
+}
+} // namespace
+
+std::vector> App::statistics_picker_items(const std::string &kind) const {
+ std::vector> result;
+ if(!source_)return result;
+ const auto data=source_->read_statistics(statistics_view_);
+ if(!data.value("ok",false))return result;
+ const int section=data.at("section").get();
+ if(kind=="stat-section") {
+ const auto &names=data.at("sections");
+ for(size_t i=0;i());
+ } else if(kind=="stat-category"&§ion==7)result={{"0","National"},{"1","International"},{"5","Hallenmasters"}};
+ else if(kind=="winner-country"&§ion==7&&data.at("category")==0) {
+ for(const auto &nation:data.at("countries"))result.emplace_back(nation.at("id").get(),nation.at("name").get());
+ } else if(kind=="stat-country"&§ion==3) {
+ for(const auto &nation:data.at("eternal_countries"))
+ result.emplace_back(std::to_string(nation.at("value").get()),nation.at("name").get());
+ } else if(kind=="stat-country"&§ion==4) {
+ const auto &names=data.at("world_views");
+ for(size_t i=0;i());
+ }
+ return result;
+}
+std::string App::statistics_picker_value(const std::string &kind) const {
+ if(!source_)return {};
+ const auto data=source_->read_statistics(statistics_view_);
+ if(!data.value("ok",false))return {};
+ if(kind=="winner-country")return data.value("winner_country","");
+ const auto key=kind=="stat-section"?"section":kind=="stat-category"?"category":"country";
+ return std::to_string(data.value(key,0));
+}
+void App::statistics_remember_scroll() {
+ if(auto *list=element("statistics-list")) {
+ const auto key=list->GetAttribute("data-scroll-key","");
+ if(!key.empty())statistics_scrolls_[key]=list->GetScrollTop();
+ }
+}
+void App::statistics_restore_scroll() {
+ if(menu_!="statistics"||!statistics_restore_pending_)return;
+ statistics_restore_pending_=false;
+ if(auto *list=element("statistics-list")) {
+ const auto key=list->GetAttribute("data-scroll-key","");
+ if(const auto i=statistics_scrolls_.find(key);i!=statistics_scrolls_.end()&&i->is_number())list->SetScrollTop(i->get());
+ }
+}
+std::string App::statistics_trophy_asset(const std::string &id) const {
+ if(id.empty())return {};
+ // Competition pictures belong to world content. The deterministic demo uses
+ // semantic trophy roles; an engine adapter can supply a logical asset key.
+ // Fixed prototype artwork is only a fallback, never an OBW requirement.
+ if (world_) {
+ if (id.starts_with("asset:")) {
+ if (world_->find("assets", id)) return id;
+ if (world_->find("assets", "asset:comp/generic/trophy"))
+ return "asset:comp/generic/trophy";
+ return {};
+ }
+ const auto key = "asset:comp/" + id + "/trophy";
+ if (world_->find("assets", key)) return key;
+ }
+ if(gui_.contains("trophy."+id))return "trophy."+id;
+ for(const auto &[key,item]:gui_.items().items()) {
+ if(!item.is_object())continue;
+ const auto file=item.value("file","");
+ const auto base=fs::path(file).filename().string();
+ if(base==id+"-v1.png"||base==id+"-v2.png")return key;
+ }
+ return {};
+}
+std::string App::render_statistics() {
+ statistics_remember_scroll();
+ if(!source_||!world_)return "Statistiken sind nicht verfügbar.
";
+ const auto data=source_->read_statistics(statistics_view_);
+ if(!data.value("ok",false))return "Statistiken sind nicht verfügbar.
";
+ const int section=data.at("section").get(),category=data.at("category").get();
+ const bool winners=section==7,minutes=section==8,finals=section==4&&data.at("country")==3;
+ std::string out=""+esc(data.at("title").get())+" ";
+ if(winners)out+="
"+statistics_text(data.value("note",""))+"
";
+ if(section==2) {
+ std::string svg="
";
+ const auto &series=data.at("series");
+ for(const auto &curve:series)if(curve.at("active")==true) {
+ svg+=" ";
+ }
+ svg+="";
+ out+="
"+picture(renderer_.diagram("statistics-analytics",svg,5100),2496,812)+"
";
+ for(size_t k=0;k();
+ out+=btn("statistics-curve","()+";\"> "+esc(curve.at("name").get())+" ","statistics-action statistics-series-button",
+ "id=\"statistics-curve-"+std::to_string(k)+"\" data-index=\""+std::to_string(k)+"\" aria-pressed=\""+(active?"true":"false")+"\" style=\""+rect(double(k%3)*854.666666667,double(k/3)*100,836.666666667,82)+"\"");
+ }
+ out+="
";
+ } else {
+ const auto &columns=data.at("columns"),&rows=data.at("rows");
+ const size_t count=columns.size();
+ const double table_width=2548;
+ const double first=minutes?table_width*.12:winners?190:table_width*.4;
+ const double rest=count>1?(table_width-first)/double(count-1):0;
+ const auto width=[&](size_t column){return finals?(column==1?160:1194):column?rest:first;};
+ const bool trophies=winners&&std::any_of(columns.begin(),columns.end(),[](const Json &column){return !column.value("trophy","").empty();});
+ const double head_height=trophies?200:winners?78:66;
+ out+="
";
+ for(size_t c=0;c
());
+ if(column.contains("round"))heading=""+esc(column.at("round").get())+" "+heading;
+ if(!trophy.empty()) {
+ const auto art=asset.empty()?std::string():""+img(asset,105,105,asset.starts_with("asset:"),false,320)+" ";
+ heading=btn("statistics-trophy",art+""+esc(column.at("text").get())+" ","statistics-trophy-heading",
+ "id=\"statistics-trophy-heading-"+std::to_string(c)+"\" data-column=\""+std::to_string(c)+"\" data-row=\"-1\" aria-label=\""+esc(column.at("text").get()+" · Siegerbild ansehen")+"\" "+(asset.empty()||!column.contains("winner")?"disabled":""));
+ }
+ out+=""+heading+"
";
+ }
+ out+=" ";
+ for(size_t r=0;r
";
+ for(size_t c=0;c"+esc(value.value("prefix",""))+""+btn("player-detail",statistics_text(title),"statistics-player-link","id=\"statistics-player-"+token+"\" data-id=\""+esc(value.at("player").get())+"\" data-club=\""+esc(value.value("club",""))+"\" title=\""+esc(title)+"\"");
+ } else if(value.contains("club")) {
+ const auto id=value.at("club").get();const auto *club=world_->find("clubs",id);const bool reverse=section==1&&c==1;
+ const auto name=""+esc(title)+" ",badge=crest(club,42);
+ content=btn("club-detail",reverse?name+badge:badge+name,"report-club-button statistics-club "+std::string(reverse?"name-first ":"")+(data.at("club")==id?"current":""),"id=\"statistics-club-"+token+"\" data-id=\""+esc(id)+"\" title=\""+esc(title)+"\"");
+ } else if(value.contains("trophy")) {
+ const auto asset=statistics_trophy_asset(value.at("trophy").get());
+ content=btn("statistics-trophy",(asset.empty()?std::string():""+img(asset,58,58,asset.starts_with("asset:"),false,192)+" ")+statistics_text(title),"statistics-world-trophy","id=\"statistics-trophy-row-"+token+"\" data-row=\""+std::to_string(r)+"\" data-column=\""+std::to_string(c)+"\" "+(asset.empty()?"disabled":""));
+ } else content=statistics_text(value.value("prefix","")+title);
+ if(value.contains("round"))content=""+esc(value.at("round").get())+" "+content;
+ out+=""+content+"
";
+ }
+ out+=" ";
+ }
+ if(rows.empty())out+="
"+statistics_text("Keine Statistikdaten für diese Auswahl vorhanden.")+"
";
+ out+="
";
+ }
+ out+=" "+render_report_detail();
+}
+
+std::string App::render_statistics_trophy() {
+ if(!statistics_trophy_.contains("asset"))return {};
+ const auto asset=statistics_trophy_.at("asset").get();
+ const bool world_image = asset.starts_with("asset:");
+ if(world_image ? (!world_ || !world_->find("assets", asset)) : !gui_.contains(asset))return {};
+ const auto winner=statistics_trophy_.value("winner","");
+ const auto *club=world_?world_->find("clubs",winner):nullptr;
+ const auto name=club?world_->name(*club):world_?world_->nation_name(winner):"—";
+ const auto viewport=context_->GetDimensions();
+ const double w=viewport.x/scale_,h=viewport.y/scale_,stage=std::min(w,h*16/9);
+ const double art=std::min({h*.61,1200/scale_,w*.82});
+ const double heading=std::clamp(h*.022,17/scale_,48/scale_),team=std::clamp(h*.035,25/scale_,76/scale_);
+ const double season_font=std::clamp(h*.0145,13/scale_,30/scale_),button_font=std::clamp(h*.0165,14/scale_,36/scale_);
+ const double heading_h=heading*1.25,team_h=team*1.5,season_h=season_font*1.25;
+ const double button_h=std::max(h*.046,button_font*1.25+h*.018+2/scale_);
+ const double gap=h*.018,copy_gap=h*.012;
+ const double total=art+heading_h+team_h+season_h+2*copy_gap+button_h+2*gap+h*.008;
+ const double top=(h-total)/2,heading_top=top+art+gap,team_top=heading_top+heading_h+copy_gap;
+ const double season_top=team_top+team_h+copy_gap,button_top=season_top+season_h+gap+h*.008;
+ return ""+img("background",w,h,false,true,2048)+"
"+img(asset,art,art,world_image,false,1600)+"
"+esc(statistics_trophy_.value("title","Sieger"))+" "+(club?crest(club,team_h):"")+""+esc(name)+"
"+statistics_text(statistics_trophy_.value("season",""))+"
"+btn("statistics-trophy-close","
Weiter ","statistics-trophy-close","id=\"statistics-trophy-close\" style=\""+rect((w-h*.17)/2,button_top,h*.17,button_h)+"font-size:"+scalar(button_font)+"dp;border-radius:"+scalar(h*.011)+"dp;\"")+"
";
+}
diff --git a/src/modern/ui/statistics_state.inc b/src/modern/ui/statistics_state.inc
new file mode 100644
index 0000000..1ede0f1
--- /dev/null
+++ b/src/modern/ui/statistics_state.inc
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-3.0-only
+ Json statistics_view_ = Json::object();
+ Json statistics_trophy_ = Json::object();
+ Json statistics_scrolls_ = Json::object();
+ bool statistics_restore_pending_ = false;
+ std::string render_statistics();
+ std::vector> statistics_picker_items(const std::string &) const;
+ std::string statistics_picker_value(const std::string &) const;
+ bool statistics_picker_select(const std::string &, const std::string &);
+ bool statistics_action(const std::string &, Rml::Element *);
+ bool statistics_event(Rml::Event &);
+ void statistics_remember_scroll();
+ void statistics_restore_scroll();
+ std::string statistics_trophy_asset(const std::string &) const;
+ std::string render_statistics_trophy();
diff --git a/src/modern/ui/view.cpp b/src/modern/ui/view.cpp
index 226e87f..71fcd66 100644
--- a/src/modern/ui/view.cpp
+++ b/src/modern/ui/view.cpp
@@ -17,6 +17,8 @@
#include "modern/ui/demo_career_reports.hpp"
#include "modern/ui/demo_rankings.hpp"
#include "modern/ui/demo_stadium.hpp"
+#include "modern/ui/demo_statistics.hpp"
+#include "modern/ui/demo_news.hpp"
#include "modern/ui/desktop.hpp"
#include "modern/ui/gui_assets.hpp"
#include "modern/ui/model.hpp"
@@ -374,6 +376,8 @@ class App final : public Rml::EventListener {
uint64_t stadium_revision_ = 0;
std::shared_ptr stadium_world_;
const DataSource *stadium_source_ = nullptr;
+#include "modern/ui/statistics_state.inc"
+#include "modern/ui/news_state.inc"
float device_ratio_ = 1.f;
Json desktop_ = Json::object(), saved_desktop_ = Json::object(),
options_ = Json::object();
@@ -593,6 +597,9 @@ class App final : public Rml::EventListener {
transfer_dialog_.clear(); transfer_picker_.clear(); transfer_notice_.clear(); transfer_return_focus_.clear();
transfer_poach_league_.clear(); transfer_poach_club_.clear(); transfer_world_.reset(); transfer_revision_ = 0;
career_view_ = Json::object(); rankings_view_ = Json::object();
+ statistics_view_ = Json::object(); statistics_trophy_ = Json::object();
+ statistics_scrolls_ = Json::object();
+ reset_news();
stadium_view_ = Json::object(); stadium_revision_ = 0;
stadium_world_.reset(); stadium_source_ = nullptr;
advertising_selected_ = -1; advertising_offer_ = 0; advertising_revision_ = 0; advertising_world_.reset();
@@ -836,13 +843,17 @@ class App final : public Rml::EventListener {
ticket_->resize(device_ratio_);
scale_chalk_shadow();
dirty_ = true;
+ if (statistics_trophy_.contains("asset"))
+ needs_render_ = true;
}
void render() {
+ news_before_render();
fixture_half_width_ = -1.f;
almanac_list_width_ = -1.f;
// A window-close save prompt can leave a menu while its local dialog is
// open. Never keep that menu's modal/input gate in the destination view.
if (menu_ != last_rendered_menu_) {
+ statistics_trophy_ = Json::object();
planning_dialog_.clear();
career_view_["dialog"] = ""; career_view_["return_focus"] = "";
stadium_view_["dialog"] = ""; stadium_view_["draft"] = Json();
@@ -901,7 +912,9 @@ class App final : public Rml::EventListener {
markup += render_menu(menu_);
setting_menu_markup_ = true;
element("canvas")->SetInnerRML(markup);
+ element("canvas")->SetProperty("overflow", statistics_trophy_.contains("asset") ? "visible" : "hidden");
setting_menu_markup_ = false;
+ news_after_render();
if (!report_detail_kind_.empty() || !planning_dialog_.empty() || !contracts_dialog_.empty() || !toto_dialog_.empty() || !transfer_dialog_.empty() || !career_view_.value("dialog", "").empty() || !stadium_view_.value("dialog", "").empty()) {
Rml::ElementList behind;
doc_->QuerySelectorAll(behind,
@@ -1058,6 +1071,7 @@ class App final : public Rml::EventListener {
}
if (menu_ == "transfer") transfer_restore_scroll();
if (menu_ == "scorers" || menu_ == "fairplay") rankings_restore_scroll();
+ if (menu_ == "statistics") statistics_restore_scroll();
if (!report_option_to_scroll_.empty()) {
if (auto *node = element(report_option_to_scroll_))
node->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
@@ -1079,7 +1093,7 @@ class App final : public Rml::EventListener {
editor::images::encode_png({w, h, std::move(bytes)}));
}
void load_fonts() {
- bool regular = false, bold = false;
+ bool regular = false, bold = false, italic = false, bold_italic = false;
#ifdef _WIN32
const char *base = std::getenv("WINDIR");
if (base) {
@@ -1090,6 +1104,12 @@ class App final : public Rml::EventListener {
bold = Rml::LoadFontFace(rml::asset_path(folder / "segoeuib.ttf"),
"Modern", Rml::Style::FontStyle::Normal,
Rml::Style::FontWeight::Bold);
+ italic = Rml::LoadFontFace(rml::asset_path(folder / "segoeuii.ttf"),
+ "Modern", Rml::Style::FontStyle::Italic,
+ Rml::Style::FontWeight::Normal);
+ bold_italic = Rml::LoadFontFace(rml::asset_path(folder / "segoeuiz.ttf"),
+ "Modern", Rml::Style::FontStyle::Italic,
+ Rml::Style::FontWeight::Bold);
}
#elif defined(__APPLE__)
const fs::path system = "/System/Library/Fonts/SFNS.ttf";
@@ -1100,6 +1120,15 @@ class App final : public Rml::EventListener {
bold = Rml::LoadFontFace(rml::asset_path(system), "Modern",
Rml::Style::FontStyle::Normal,
Rml::Style::FontWeight::Bold);
+ const fs::path slanted = "/System/Library/Fonts/SFNSItalic.ttf";
+ if (fs::exists(slanted)) {
+ italic = Rml::LoadFontFace(rml::asset_path(slanted), "Modern",
+ Rml::Style::FontStyle::Italic,
+ Rml::Style::FontWeight::Normal);
+ bold_italic = Rml::LoadFontFace(rml::asset_path(slanted), "Modern",
+ Rml::Style::FontStyle::Italic,
+ Rml::Style::FontWeight::Bold);
+ }
}
#else
const fs::path fonts = fs::exists("/usr/share/fonts/truetype/liberation2")
@@ -1112,6 +1141,12 @@ class App final : public Rml::EventListener {
bold = Rml::LoadFontFace(
rml::asset_path(fonts / "LiberationSans-Bold.ttf"), "Modern",
Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Bold);
+ italic = Rml::LoadFontFace(
+ rml::asset_path(fonts / "LiberationSans-Italic.ttf"), "Modern",
+ Rml::Style::FontStyle::Italic, Rml::Style::FontWeight::Normal);
+ bold_italic = Rml::LoadFontFace(
+ rml::asset_path(fonts / "LiberationSans-BoldItalic.ttf"), "Modern",
+ Rml::Style::FontStyle::Italic, Rml::Style::FontWeight::Bold);
}
#endif
if (!regular)
@@ -1122,6 +1157,14 @@ class App final : public Rml::EventListener {
bold = Rml::LoadFontFace(rml::asset_path(assets_ / "LatoLatin-Bold.ttf"),
"Modern", Rml::Style::FontStyle::Normal,
Rml::Style::FontWeight::Bold);
+ if (!italic)
+ italic = Rml::LoadFontFace(rml::asset_path(assets_ / "LatoLatin-Italic.ttf"),
+ "Modern", Rml::Style::FontStyle::Italic,
+ Rml::Style::FontWeight::Normal);
+ if (!bold_italic)
+ bold_italic = Rml::LoadFontFace(
+ rml::asset_path(assets_ / "LatoLatin-BoldItalic.ttf"), "Modern",
+ Rml::Style::FontStyle::Italic, Rml::Style::FontWeight::Bold);
std::vector chalk_fonts;
#ifdef _WIN32
if (const char *windir = std::getenv("WINDIR")) {
@@ -1143,7 +1186,7 @@ class App final : public Rml::EventListener {
Rml::Style::FontStyle::Normal,
Rml::Style::FontWeight::Normal))
break;
- if (!regular || !bold)
+ if (!regular || !bold || !italic || !bold_italic)
throw std::runtime_error(
"GUI-Schriften fehlen. Bitte das vollständige Paket entpacken.");
}
@@ -1334,6 +1377,10 @@ public:
#include "modern/ui/rankings_controls.inc"
#include "modern/ui/stadium_screens.inc"
#include "modern/ui/stadium_controls.inc"
+#include "modern/ui/statistics_screens.inc"
+#include "modern/ui/statistics_controls.inc"
+#include "modern/ui/news_screens.inc"
+#include "modern/ui/news_controls.inc"
} // namespace
bool is_modern_world(const fs::path &file) {
try {
diff --git a/tests/modern_control_layout_tests.cpp b/tests/modern_control_layout_tests.cpp
index fc86992..8c617d9 100644
--- a/tests/modern_control_layout_tests.cpp
+++ b/tests/modern_control_layout_tests.cpp
@@ -80,6 +80,15 @@ void centered_text(Rml::Element &text_root, Rml::Element &control,
text_centers(text_root, p.x + s.x / 2, p.y + s.y / 2, horizontal, lines);
require(lines == 1, "A control label disappeared or wrapped");
}
+size_t visible_text_lines(Rml::Element &node) {
+ size_t count = 0;
+ if (auto *text = dynamic_cast(&node))
+ for (const auto &line : text->GetLines())
+ if (!line.text.empty() && line.width > 0) ++count;
+ for (int i = 0; i < node.GetNumChildren(); ++i)
+ count += visible_text_lines(*node.GetChild(i));
+ return count;
+}
} // namespace
int main(int argc, char **argv) try {
require(argc == 2, "Pass the Modern asset directory");
@@ -97,10 +106,14 @@ int main(int argc, char **argv) try {
Rml::Style::FontStyle::Normal,
Rml::Style::FontWeight::Bold),
"Bold font missing");
+ require(Rml::LoadFontFace((root / "LatoLatin-BoldItalic.ttf").string(), "Modern",
+ Rml::Style::FontStyle::Italic,
+ Rml::Style::FontWeight::Bold),
+ "Bold italic font missing");
std::ostringstream css;
for (const auto *name : {"theme.rcss", "ticket.rcss", "sports.rcss",
"calendar.rcss", "reports.rcss", "report_details.rcss",
- "report_pickers.rcss", "indoor.rcss", "planning.rcss", "almanac.rcss", "finance.rcss", "bank.rcss", "contracts.rcss", "amount.rcss", "environment.rcss", "advertising.rcss", "toto.rcss", "lineup.rcss", "transfer.rcss", "career_reports.rcss", "rankings.rcss", "stadium.rcss"}) {
+ "report_pickers.rcss", "indoor.rcss", "planning.rcss", "almanac.rcss", "finance.rcss", "bank.rcss", "contracts.rcss", "amount.rcss", "environment.rcss", "advertising.rcss", "toto.rcss", "lineup.rcss", "transfer.rcss", "career_reports.rcss", "rankings.rcss", "stadium.rcss", "statistics.rcss", "news.rcss"}) {
std::ifstream input(root / name);
require(bool(input), "Production stylesheet missing");
css << input.rdbuf() << '\n';
@@ -138,6 +151,24 @@ int main(int argc, char **argv) try {
"id='rich' "
"style='position:absolute;left:700dp;top:40dp;width:250dp;height:"
"260dp;' ");
+ content +=
+ "" +
+ button_markup("statistics-absolute", "REL. ",
+ "statistics-action statistics-absolute", "style='left:0;top:0;width:100%;height:94dp;'") + "
" +
+ "" +
+ button_markup("player-detail", "Synthetic player ",
+ "statistics-player-link") + "
" +
+ "" +
+ button_markup("statistics-trophy", "WM 2098 ",
+ "statistics-world-trophy") + "
" +
+ "" +
+ button_markup("club-detail", "Synthetic source club ",
+ "report-club-button statistics-club name-first") + "
" +
+ "kicker " +
+ "" +
+ button_markup("statistics-curve", "Mannschaftsstärke ",
+ "statistics-action statistics-series-button", "style='left:2700dp;top:580dp;width:836dp;height:82dp;'");
content +=
"Render();
}
require(!center_selects(*doc), "Control centering does not settle");
+ for (const auto *id : {"stats-scale-label", "stats-legend-label", "stats-player-label", "stats-world-label", "stats-from-label", "stats-winner-label", "news-brand-test"}) {
+ auto *label = doc->GetElementById(id);
+ require(label && label->GetBox().GetSize(Rml::BoxArea::Content).x > 0 && visible_text_lines(*label) > 0,
+ "A production statistics/news label has collapsed or lost its font face");
+ }
for (const auto *id : {"step", "region", "footer"}) {
auto *button = doc->GetElementById(id);
require(button, "Button missing");
diff --git a/tests/modern_news_ui_tests.cpp b/tests/modern_news_ui_tests.cpp
new file mode 100644
index 0000000..e0cc72f
--- /dev/null
+++ b/tests/modern_news_ui_tests.cpp
@@ -0,0 +1,304 @@
+// SPDX-License-Identifier: GPL-3.0-only
+#include "modern/ui/demo_news.hpp"
+#include "modern/ui/desktop.hpp"
+#include "modern/ui/model.hpp"
+#include
+#include
+#include
+#include
+using namespace bmh::modern_ui;
+namespace {
+void require(bool yes, const char *why) {
+ if (!yes)
+ throw std::runtime_error(why);
+}
+struct Fixture {
+ fs::path root;
+ std::shared_ptr world;
+ Fixture() {
+ root = fs::temp_directory_path() /
+ ("openbmh-news-ui-" +
+ std::to_string(
+ std::chrono::steady_clock::now().time_since_epoch().count()));
+ fs::create_directories(root / "world");
+ const auto write = [&](const std::string &name, const Json &data) {
+ bmh::editor::write_atomic(root / name, data.dump());
+ };
+ write("manifest.json", {{"format", "openbmh-world"},
+ {"kind", "world"},
+ {"format_version", "1.1"},
+ {"id", "world:synthetic-news"},
+ {"start_date", "2032-07-01"},
+ {"requires", {"editor:world-v1"}},
+ {"x-editor", {{"profile", "editor-world-v1"}}}});
+ write("world/nations.json",
+ {{"items", {{{"id", "nation:de"}, {"name", "Synthetic nation"}}}}});
+ write("world/competitions.json", {{"items",
+ {{{"id", "competition:news-test"},
+ {"type", "league"},
+ {"nation", "nation:de"},
+ {"name", "Synthetic league"}}}}});
+ Json clubs = Json::array();
+ for (int i = 0; i < 2; ++i)
+ clubs.push_back({{"id", "club:news-" + std::to_string(i)},
+ {"name", "Synthetic Club " + std::to_string(i)},
+ {"nation", "nation:de"},
+ {"competition", "competition:news-test"}});
+ write("world/clubs.json", {{"items", clubs}});
+ write("world/players.json", {{"items", Json::array()}});
+ world = Catalog::open(root);
+ }
+ ~Fixture() {
+ std::error_code ec;
+ fs::remove_all(root, ec);
+ }
+};
+Json state() {
+ return {
+ {"date", "2032-03-01"},
+ {"managers", {{{"name", "Synthetic Manager"}, {"club", "club:news-0"}}}},
+ {"cash", 123456},
+ {"other", {{"kept", true}}}};
+}
+void reject(Json &s, const Json &a, const Catalog &w) {
+ const auto before = s;
+ require(!edit_demo_news(s, a, w).empty() && s == before,
+ "Rejected news action altered state");
+}
+void provider(Fixture &f) {
+ auto s = state();
+ const auto unrelated = s, clubs = f.world->rows("clubs");
+ require(migrate_demo_news(s, *f.world) && valid_demo_news(s),
+ "Old checkpoint migration failed");
+ const auto initial = s;
+ require(migrate_demo_news(s, *f.world) && s == initial,
+ "Existing mailbox was reinitialized");
+ auto rest = s;
+ rest.erase("news");
+ require(rest == unrelated, "News migration changed unrelated fields");
+ const auto view = demo_news_view(*f.world, s);
+ require(view.at("items").size() == 9 && view.at("counts").at("inbox") == 9 &&
+ view.at("counts").at("archive") == 3 && view.at("unread") == 5,
+ "Initial mailbox counts wrong");
+ require(view.at("date") == "01.03.2032" &&
+ s.at("news").at("items")[2].at("date") == "2032-02-29" &&
+ s.at("news").at("items")[11].at("date") == "2032-02-18",
+ "Relative fixture dates or leap day wrong");
+ require(view.at("items")[0].at("body").get().find(
+ "Synthetic Manager. Synthetic Club 0") != std::string::npos,
+ "Current manager and club not interpolated");
+ auto changed = s;
+ changed["managers"][0] = {{"name", "Other Manager"}, {"club", "club:news-1"}};
+ require(demo_news_view(*f.world, changed)
+ .at("items")[0]
+ .at("body")
+ .get()
+ .find("Other Manager. Synthetic Club 1") != std::string::npos,
+ "Manager change retained stale template identity");
+ require(demo_news_view(*f.world, s, "inbox", "FINANZEN").at("items").size() ==
+ 2 &&
+ demo_news_view(*f.world, s, "inbox", "VERTRAGSGESPRÄCHE")
+ .at("items")
+ .size() == 1,
+ "German case-insensitive category/title search failed");
+ require(demo_news_view(*f.world, s, "inbox", "unmatchable-search")
+ .at("items")
+ .empty() &&
+ demo_news_view(*f.world, s, "inbox", "01.03.2032")
+ .at("items")
+ .size() == 2,
+ "Search empty/date projection failed");
+ require(s == initial && f.world->rows("clubs") == clubs,
+ "Read-only projection mutated state or catalogue");
+ require(
+ edit_demo_news(s, {{"kind", "read-all"}, {"folder", "inbox"}}, *f.world)
+ .empty() &&
+ demo_news_unread(s) == 0,
+ "Read-all must mark the entire folder, including hidden results");
+ s = initial;
+ require(edit_demo_news(s, {{"kind", "read"}, {"id", "season"}}, *f.world)
+ .empty() &&
+ demo_news_unread(s) == 4,
+ "Open read action failed");
+ s = initial;
+ require(edit_demo_news(
+ s, {{"kind", "move"}, {"id", "season"}, {"folder", "archive"}},
+ *f.world)
+ .empty() &&
+ demo_news_unread(s) == 4,
+ "Archive must also mark read");
+ const Json patch =
+ Json::array({{{"id", "season"},
+ {"before", {{"read", false}, {"folder", "inbox"}}},
+ {"after", {{"read", true}, {"folder", "archive"}}}}});
+ const auto archived = s;
+ require(edit_demo_news(s, {{"kind", "undo"}, {"patch", patch}}, *f.world)
+ .empty() &&
+ s == initial,
+ "Undo failed to restore the small read/folder patch");
+ reject(s, {{"kind", "undo"}, {"patch", patch}}, *f.world);
+ s = archived;
+ require(edit_demo_news(
+ s, {{"kind", "move"}, {"id", "season"}, {"folder", "inbox"}},
+ *f.world)
+ .empty() &&
+ s.at("news").at("items")[0].at("read") == true,
+ "Restore must retain read state");
+ require(edit_demo_news(
+ s, {{"kind", "move"}, {"id", "season"}, {"folder", "trash"}},
+ *f.world)
+ .empty() &&
+ demo_news_view(*f.world, s).at("counts").at("inbox") == 8,
+ "Delete did not remove item from visible folders");
+ reject(s, {{"kind", "read"}, {"id", "season"}}, *f.world);
+ s = archived;
+ auto multi = patch;
+ multi.push_back({{"id", "missing"},
+ {"before", {{"read", false}, {"folder", "inbox"}}},
+ {"after", {{"read", true}, {"folder", "inbox"}}}});
+ reject(s, {{"kind", "undo"}, {"patch", multi}}, *f.world);
+ multi = patch;
+ multi.push_back(patch[0]);
+ reject(s, {{"kind", "undo"}, {"patch", multi}}, *f.world);
+ for (const auto &a : std::vector{
+ nullptr, Json::array(), Json{{"kind", 4}},
+ Json{{"kind", "move"}, {"id", "season"}, {"folder", "lost"}},
+ Json{{"kind", "read"}, {"id", 4}},
+ Json{{"kind", "read"}, {"id", "season"}, {"unexpected", true}},
+ Json{{"kind", "read-all"}, {"folder", "trash"}},
+ Json{{"kind", "undo"}, {"patch", Json::array()}},
+ Json{{"kind", "unknown"}}})
+ reject(s, a, *f.world);
+ std::vector bad;
+ auto invalid = initial;
+ invalid["news"]["items"].push_back(invalid["news"]["items"][0]);
+ bad.push_back(invalid);
+ for (const auto &[key, value] : std::vector>{
+ {"id", "BAD-ID"},
+ {"id", ""},
+ {"date", "2031-02-29"},
+ {"date", "2032-13-01"},
+ {"kind", 4},
+ {"kind", "unsupported"},
+ {"title", " "},
+ {"title", std::string(161, 'x')},
+ {"body", std::string(1201, 'x')},
+ {"read", 1},
+ {"folder", "removed"}}) {
+ invalid = initial;
+ invalid["news"]["items"][0][key] = value;
+ bad.push_back(invalid);
+ }
+ invalid = initial;
+ invalid["news"]["version"] = 1.0;
+ bad.push_back(invalid);
+ invalid = initial;
+ invalid["news"]["query"] = "must-be-local";
+ bad.push_back(invalid);
+ invalid = initial;
+ for (int i = 12; i < 101; ++i) {
+ auto m = invalid["news"]["items"][0];
+ m["id"] = "test-" + std::to_string(i);
+ invalid["news"]["items"].push_back(m);
+ }
+ bad.push_back(invalid);
+ for (auto invalid : bad) {
+ const auto before = invalid;
+ require(!valid_demo_news(invalid) &&
+ !migrate_demo_news(invalid, *f.world) && invalid == before,
+ "Malformed imported mailbox was repaired or accepted");
+ reject(invalid, {{"kind", "read-all"}, {"folder", "inbox"}}, *f.world);
+ }
+ auto empty = initial;
+ empty["news"]["items"] = Json::array();
+ require(valid_demo_news(empty) &&
+ demo_news_view(*f.world, empty).at("items").empty() &&
+ demo_news_unread(empty) == 0,
+ "Valid empty mailbox rejected");
+}
+void source(Fixture &f) {
+ DemoSource source(f.world);
+ auto initial = source.snapshot();
+ require(valid_demo_news(initial.state) && !source.dirty(),
+ "Default source mailbox missing or dirty");
+ const auto clean = initial.state;
+ demo_news_view(*f.world, initial.state, "archive", "search");
+ require(source.snapshot().revision == initial.revision && !source.dirty(),
+ "Navigation dirtied source");
+ require(
+ source
+ .apply(
+ {initial.revision, "news", {{"kind", "read"}, {"id", "season"}}})
+ .ok,
+ "Source rejected news action");
+ auto current = source.snapshot();
+ require(source.dirty() && current.revision == initial.revision + 1,
+ "News action did not advance source revision");
+ require(
+ !source.apply({initial.revision,
+ "news",
+ {{"kind", "move"}, {"id", "season"}, {"folder", "trash"}}})
+ .ok &&
+ source.snapshot().state == current.state,
+ "Stale news action changed source");
+ require(!source.apply({current.revision,
+ "news",
+ {{"kind", "move"}, {"id", "season"}, {"folder", 9}}})
+ .ok &&
+ source.snapshot().state == current.state &&
+ source.snapshot().revision == current.revision,
+ "Malformed source action was not atomic");
+ const auto save = f.root / "checkpoint.json";
+ source.save(save, default_desktop());
+ require(!source.dirty(), "Saving news did not clear dirty");
+ require(
+ source
+ .apply({source.snapshot().revision,
+ "news",
+ {{"kind", "move"}, {"id", "season"}, {"folder", "trash"}}})
+ .ok,
+ "Delete source action failed");
+ source.load(save);
+ require(source.snapshot().state.at("news") == current.state.at("news") &&
+ !source.dirty(),
+ "Saved mailbox did not reload");
+ auto data = Json::parse(bmh::editor::read_file(save));
+ data.erase("news");
+ bmh::editor::write_atomic(save, data.dump());
+ source.load(save);
+ require(valid_demo_news(source.snapshot().state) &&
+ demo_news_unread(source.snapshot().state) == 5 && !source.dirty(),
+ "Old checkpoint did not initialize clean news");
+ source.save(save, default_desktop());
+ data = Json::parse(bmh::editor::read_file(save));
+ data["news"]["items"][0]["kind"] = 44;
+ bmh::editor::write_atomic(save, data.dump());
+ const auto before = source.snapshot();
+ bool rejected = false;
+ try {
+ source.load(save);
+ } catch (const std::exception &) {
+ rejected = true;
+ }
+ require(rejected && source.snapshot().state == before.state &&
+ source.snapshot().revision == before.revision && !source.dirty(),
+ "Malformed checkpoint replaced state or advanced revision");
+ auto rest = before.state;
+ rest.erase("news");
+ auto base = clean;
+ base.erase("news");
+ require(rest == base, "Mailbox actions modified unrelated presentation data");
+}
+} // namespace
+int main() {
+ try {
+ Fixture f;
+ provider(f);
+ source(f);
+ std::cout << "modern news UI tests passed\n";
+ return 0;
+ } catch (const std::exception &e) {
+ std::cerr << e.what() << '\n';
+ return 1;
+ }
+}
diff --git a/tests/modern_statistics_ui_tests.cpp b/tests/modern_statistics_ui_tests.cpp
new file mode 100644
index 0000000..bfb834f
--- /dev/null
+++ b/tests/modern_statistics_ui_tests.cpp
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-3.0-only
+#include "modern/ui/demo_statistics.hpp"
+#include "modern/ui/model.hpp"
+#include
+#include
+#include
+#include
+#include
+
+using namespace bmh::modern_ui;
+namespace {
+void require(bool value,const char *message) {if(!value)throw std::runtime_error(message);}
+const std::array nations{"de","es","en","fr","it","nl","pt","be"};
+std::string club(const std::string &country,int index) {return "club:statistics-"+country+"-"+std::to_string(index);}
+struct Fixture {
+ fs::path root;std::shared_ptr world;
+ explicit Fixture(bool empty=false, bool english_subnation=false) {
+ root=fs::temp_directory_path()/("openbmh-statistics-ui-"+std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
+ fs::create_directories(root/"world");
+ const auto write=[&](const std::string &file,const Json &value){bmh::editor::write_atomic(root/file,value.dump());};
+ write("manifest.json",{{"format","openbmh-world"},{"kind","world"},{"format_version","1.1"},{"id","world:synthetic-statistics"},{"start_date","2026-07-01"},{"requires",{"editor:world-v1"}},{"x-editor",{{"profile","editor-world-v1"}}}});
+ Json ns=Json::array(),leagues=Json::array(),clubs=Json::array(),players=Json::array();
+ if(!empty)for(size_t n=0;n=5)continue;
+ const auto league="competition:statistics-"+code;
+ leagues.push_back({{"id",league},{"type","league"},{"nation",nation_id},{"tier",1},{"name","Synthetic league "+code}});
+ leagues.push_back({{"id",league+"-lower"},{"type","league"},{"nation",nation_id},{"tier",2},{"name","Synthetic lower league "+code}});
+ for(int i=0;i<20;++i) {
+ const auto id=club(code,i);
+ clubs.push_back({{"id",id},{"name","Synthetic club "+code+" "+std::to_string(i)},{"competition",league},{"nation",nation_id},{"crest","asset:synthetic-crest"}});
+ for(int p=0;p<12;++p)players.push_back({{"id","player:statistics-"+code+"-"+std::to_string(i)+"-"+std::to_string(p)},{"name","Synthetic player "+std::to_string(i*12+p)},{"team",id},{"nation",nation_id},{"positions",{p==0?"gk":"mid"}}});
+ }
+ clubs.push_back({{"id",club(code,20)},{"name","Synthetic lower club"},{"competition",league+"-lower"},{"nation",nation_id}});
+ }
+ write("world/nations.json",{{"items",ns}});write("world/competitions.json",{{"items",leagues}});write("world/clubs.json",{{"items",clubs}});write("world/players.json",{{"items",players}});
+ world=Catalog::open(root);
+ }
+ ~Fixture(){std::error_code ec;fs::remove_all(root,ec);}
+};
+Json state() {return {{"date","2027-07-07"},{"managers",{{{"name","Synthetic manager"},{"club",club("de",4)}}}},{"cash",123456},{"reports",{{"league","competition:statistics-es"},{"filter",4}}}};}
+void identities(const Catalog &world,const Json &data) {
+ for(const auto &r:data.at("rows"))for(const auto &c:r.at("cells")) {
+ if(c.contains("club"))require(world.find("clubs",c.at("club").get()),"Statistics contains an unknown club identity");
+ if(c.contains("player"))require(world.find("players",c.at("player").get()),"Statistics contains an unknown player identity");
+ if(c.contains("nation"))require(world.find("nations",c.at("nation").get()),"Statistics contains an unknown nation identity");
+ }
+}
+void projections() {
+ Fixture f;const auto s=state(),before=s,clubs=f.world->rows("clubs"),players=f.world->rows("players");
+ const auto initial=demo_statistics(*f.world,s);
+ require(initial.at("ok")==true&&initial.at("fictional")==true&&initial.at("section")==7&&initial.at("category")==0&&initial.at("winner_country")=="nation:de","Default must open national German winners");
+ require(initial.at("rows").size()==12&&initial.at("columns").size()==4,"National winners lost their three title columns or twelve seasons");
+ require(initial.at("rows")[0].at("cells")[0].at("text")=="2026/27"&&initial.at("rows")[11].at("cells")[0].at("text")=="2015/16","Winners must end with last completed season");
+ require(initial.at("manager")=="Synthetic manager"&&initial.at("club")==club("de",4),"Statistics has stale own-manager identity");
+ const std::array winner_order{"de","es","it","fr","en"};
+ for(size_t i=0;i order{"de","es","en","fr","it"};
+ require(data.at("rows").size()==20,"Eternal table silently lost twentieth team or mixed lower leagues");
+ require(data.at("rows")[0].at("cells")[0].at("club")==club(order[size_t(country)],0),"Eternal country selector uses wrong nation cohort");
+ require(data.at("rows")[19].at("cells")[0].at("club")==club(order[size_t(country)],19),"Eternal table truncated final actual club");
+ identities(*f.world,data);
+ }
+ require(demo_statistics(*f.world,s,{{"section",3},{"country",5}}).at("rows").size()==20,"Absolute eternal table lost own-league cohort");
+ for(const auto &nation:initial.at("countries")) {
+ const auto id=nation.at("id").get();const auto code=id.substr(7);
+ const auto data=demo_statistics(*f.world,s,{{"winner_country",id}});
+ require(data.at("rows")[0].at("cells")[1].at("club")==club(code,0)&&data.at("rows")[0].at("cells")[3].at("club")==club(code,1),"National winners must use selected country's actual clubs");
+ require(data.at("columns")[1].at("winner")==data.at("rows")[0].at("cells")[1].at("club"),"Trophy detail winner differs from latest visible winner");
+ identities(*f.world,data);
+ }
+ const auto international=demo_statistics(*f.world,s,{{"category",1}}),indoor=demo_statistics(*f.world,s,{{"category",5}});
+ require(international.at("columns").size()==4&&international.at("columns")[2].at("text")=="Pokalsieger"&&international.at("columns")[3].at("text")=="UEFA-Cup","International competition structure differs from BMH Gold");
+ require(indoor.at("columns").size()==3&&indoor.at("rows")[0].at("cells").size()==3&&indoor.at("columns")[1].at("text")=="Sieger"&&indoor.at("columns")[2].at("text")=="Finalist","Indoor winners need exactly two title columns");
+ identities(*f.world,international);identities(*f.world,indoor);
+ for(int view=0;view<6;++view) {
+ const auto data=demo_statistics(*f.world,s,{{"section",4},{"country",view}});identities(*f.world,data);
+ const size_t expected=view==0||view==5?6:view==3?4:8;
+ require(data.at("rows").size()==expected,"A world-statistics subview is missing");
+ if(view==3)require(data.at("columns")[0].at("round")=="Runde"&&data.at("rows")[0].at("cells")[0].at("round")=="Finale"&&!data.at("rows")[0].at("cells")[0].contains("prefix"),"World final-round metadata was flattened into the team label");
+ }
+ const auto relative=demo_statistics(*f.world,s,{{"section",2}}),absolute=demo_statistics(*f.world,s,{{"section",2},{"absolute",true},{"curves",{false,true,false,true,false,true}}});
+ require(relative.at("series").size()==6&&relative.at("series")[0].at("points").size()==24,"Analytics needs six 24-point curves");
+ require(relative.at("series")[0].at("points")!=absolute.at("series")[0].at("points")&&absolute.at("series")[0].at("active")==false&&absolute.at("series")[1].at("active")==true,"Curve toggles or relative/absolute data do not work");
+ const auto minutes=demo_statistics(*f.world,s,{{"section",8}});
+ require(minutes.at("columns").size()==19&&minutes.at("rows").size()==4&&minutes.at("rows")[0].at("cells")[1].at("tone")=="bad"&&minutes.at("rows")[0].at("cells")[4].at("tone")=="good","Minute grid must retain eighteen intervals and meaningful colors");
+ auto changed=s;changed["cash"]=0;changed["reports"]={{"league","elsewhere"}};
+ require(demo_statistics(*f.world,changed)==initial,"Statistics depends on unrelated wallet or report filters");
+ changed=s;changed["managers"][0]["name"]="Changed manager";changed["managers"][0]["club"]=club("de",7);
+ require(demo_statistics(*f.world,changed).at("manager")=="Changed manager"&&demo_statistics(*f.world,changed).at("club")==club("de",7),"Statistics retains stale manager after switch");
+ changed=s;changed["date"]="2027-06-30";
+ require(demo_statistics(*f.world,changed).at("rows")[0].at("cells")[0].at("text")=="2025/26","June date falsely completed current season");
+ require(s==before&&f.world->rows("clubs")==clubs&&f.world->rows("players")==players&&demo_statistics(*f.world,s)==initial,"Read projection changed input/catalogue or became nondeterministic");
+ // This boundary check also proves all UI filters remain outside saved state.
+ DemoSource source(f.world);const auto snapshot=source.snapshot();const bool dirty=source.dirty();
+ for(int section=0;section<9;++section)require(source.read_statistics({{"section",section}}).at("ok")==true,"Data-source read boundary does not expose statistics");
+ require(source.snapshot().revision==snapshot.revision&&source.snapshot().state==snapshot.state&&source.dirty()==dirty,"Statistics reads changed checkpoint state, revision or dirty flag");
+}
+void invalid_and_empty() {
+ Fixture f;
+ for(const auto &request:std::vector{nullptr,Json::array(),Json{{"section",-1}},Json{{"section",9}},Json{{"section","7"}},Json{{"category",2}},Json{{"country",6}},Json{{"winner_country","nation:missing"}},Json{{"winner_country",0}},Json{{"absolute",1}},Json{{"curves",{true,false}}},Json{{"curves",{true,true,true,true,true,1}}},Json{{"page",1}}})require(demo_statistics(*f.world,state(),request).at("ok")==false,"Malformed statistics filter was accepted");
+ Fixture empty(true);for(int section=0;section<9;++section) {
+ const auto data=demo_statistics(*empty.world,Json::object(),{{"section",section}});
+ require(data.at("ok")==true&&data.at("available")==false&&data.at("rows").empty()&&data.at("series").empty()&&data.at("club").is_null(),"Empty world fabricated statistics identities or rows");
+ }
+ for(const auto &s:std::vector{nullptr,Json::array(),Json::object(),Json{{"managers",Json::array()}},Json{{"managers",{{{"club","club:missing"}}}}}}) {
+ const auto data=demo_statistics(*f.world,s);require(data.at("ok")==true&&data.at("club").is_null(),"Malformed manager snapshot threw or invented own identity");
+ }
+}
+void english_subnation() {
+ Fixture f(false, true);
+ const auto initial = demo_statistics(*f.world, state());
+ require(initial.at("countries").size() == 5 && initial.at("countries")[4].at("id") == "nation:x-eng",
+ "Stable England identity disappeared from the country picker");
+ require(initial.at("eternal_countries").size() == 6 && initial.at("eternal_countries")[2].at("nation") == "nation:x-eng",
+ "Eternal table omitted England or changed its Gold index");
+ const auto eternal = demo_statistics(*f.world, state(), {{"section",3},{"country",2}});
+ require(eternal.at("rows").size() == 20 && eternal.at("rows")[19].at("cells")[0].at("club") == club("en",19),
+ "England's twentieth club is absent from its eternal table");
+ const auto winner = demo_statistics(*f.world, state(), {{"winner_country","nation:x-eng"}});
+ require(winner.at("columns")[1].at("text") == "Premier League" && winner.at("columns")[2].at("text") == "FA Cup" &&
+ winner.at("columns")[1].at("trophy") == "en-premier-league",
+ "England incorrectly uses German title or trophy names");
+ const auto world = demo_statistics(*f.world, state(), {{"section",4},{"country",1}});
+ require(world.at("rows")[4].at("cells")[1].at("nation") == "nation:x-eng",
+ "World statistics replaced England with an unrelated country");
+ require(!f.world->find("nations","nation:en"), "Projection changed stable nation IDs");
+}
+} // namespace
+int main()try{projections();invalid_and_empty();english_subnation();std::cout<<"Modern statistics UI checks passed\n";return 0;}catch(const std::exception &error){std::cerr<