Bind native statistics to recorded careers and correct cup winners (by Codex)
This commit is contained in:
1 parent
e3ea03a05d
commit
eb140cdb1c
24 files changed
+296
-33
No files matched your search
@@ -10,8 +10,8 @@ std::string statistics_scroll_key(const Json &data) {
|
||||
|
||||
std::vector<std::pair<std::string,std::string>> App::statistics_picker_items(const std::string &kind) const {
|
||||
std::vector<std::pair<std::string,std::string>> result;
|
||||
if(!source_)return result;
|
||||
const auto data=source_->read_statistics(statistics_view_);
|
||||
if(!source_&&!engine_mode_)return result;
|
||||
const auto data=statistics_data();
|
||||
if(!data.value("ok",false))return result;
|
||||
const int section=data.at("section").get<int>();
|
||||
if(kind=="stat-section") {
|
||||
@@ -30,8 +30,8 @@ std::vector<std::pair<std::string,std::string>> App::statistics_picker_items(con
|
||||
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(!source_&&!engine_mode_)return {};
|
||||
const auto data=statistics_data();
|
||||
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";
|
||||
@@ -77,14 +77,15 @@ std::string App::statistics_trophy_asset(const std::string &id) const {
|
||||
}
|
||||
std::string App::render_statistics() {
|
||||
statistics_remember_scroll();
|
||||
if(!source_||!world_)return "<p>Statistiken sind nicht verfügbar.</p>";
|
||||
const auto data=source_->read_statistics(statistics_view_);
|
||||
if((!source_&&!engine_mode_)||!world_)return "<p>Statistiken sind nicht verfügbar.</p>";
|
||||
const auto data=statistics_data();
|
||||
if(!data.value("ok",false))return "<p>Statistiken sind nicht verfügbar.</p>";
|
||||
const int section=data.at("section").get<int>(),category=data.at("category").get<int>();
|
||||
const bool winners=section==7,minutes=section==8,finals=section==4&&data.at("country")==3;
|
||||
std::string out="<section class=\"statistics-native statistics-section-"+std::to_string(section)+(finals?" statistics-finals":"")+"\"><div class=\"statistics-panel\"><h2 class=\"statistics-heading\">"+esc(data.at("title").get<std::string>())+"</h2>";
|
||||
if(winners)out+="<p class=\"statistics-winner-note\">"+statistics_text(data.value("note",""))+"</p>";
|
||||
if(section==2) {
|
||||
if(engine_mode_&&!data.value("available",false)){out+="<p class=\"statistics-empty\">"+statistics_text(data.value("reason","")=="not_recorded"?"Diese Auswertung wurde in der Karriere noch nicht aufgezeichnet.":"Keine Statistikdaten für diese Auswahl vorhanden.")+"</p>";}
|
||||
else if(section==2) {
|
||||
std::string svg="<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3400 780' width='2496' height='812' preserveAspectRatio='none'><path d='M30 10V730H3380' fill='none' stroke='"+std::string(theme_=="silver"?"#627c8f":"#7d9aae")+"' stroke-width='3'/>";
|
||||
const auto &series=data.at("series");
|
||||
for(const auto &curve:series)if(curve.at("active")==true) {
|
||||
@@ -93,7 +94,7 @@ std::string App::render_statistics() {
|
||||
svg+="' fill='none' stroke='"+curve.at("color").get<std::string>()+"' stroke-width='7'/>";
|
||||
}
|
||||
svg+="</svg>";
|
||||
out+="<div class=\"statistics-graph\" role=\"img\" aria-label=\"Sechs fiktive Verlaufsreihen · "+std::string(data.at("absolute")==true?"absolut":"relativ")+"\">"+picture(renderer_.diagram("statistics-analytics",svg,5100),2496,812)+"</div><div class=\"statistics-series\">";
|
||||
out+="<div class=\"statistics-graph\" role=\"img\" aria-label=\""+std::string(engine_mode_?"Aufgezeichnete Verlaufsreihen · ":"Sechs fiktive Verlaufsreihen · ")+std::string(data.at("absolute")==true?"absolut":"relativ")+"\">"+picture(renderer_.diagram("statistics-analytics",svg,5100),2496,812)+"</div><div class=\"statistics-series\">";
|
||||
for(size_t k=0;k<series.size();++k) {
|
||||
const auto &curve=series[k];const bool active=curve.at("active").get<bool>();
|
||||
out+=btn("statistics-curve","<span class=\"statistics-series-dot\" style=\"background-color:"+curve.at("color").get<std::string>()+";\"></span><span class=\"statistics-series-label\">"+esc(curve.at("name").get<std::string>())+"</span>","statistics-action statistics-series-button",
|
||||
|
||||
Reference in new issue
Block a user