Bind league fixtures and round navigation to live engine data (by Codex)
This commit is contained in:
1 parent
1c35698dbe
commit
545e16f153
21 files changed
+207
-31
No files matched your search
@@ -54,6 +54,7 @@ Json engine_almanac_projection(const Json &bundle, const Json &read, const Json
|
||||
Json engine_report_index(const Json &bundle,const Json &read);
|
||||
Json engine_report_projection(const Json &bundle,const Json &index,const Json &read,const std::string &league,int filter);
|
||||
Json engine_report_squad(const Json &bundle,const Json &read,const std::string &team);
|
||||
Json engine_fixtures_projection(const Json &bundle,const Json &index,const Json &read,const std::string &league,int round);
|
||||
|
||||
// Single-session facade. Its owner serializes all calls on a background worker.
|
||||
// No RmlUI objects or callbacks cross this boundary.
|
||||
|
||||
@@ -75,7 +75,7 @@ void App::engine_frame() {
|
||||
engine_sports_update();
|
||||
if (ticket_) ticket_->update();
|
||||
render_popup(); context_->Update();
|
||||
if(almanac_layout_update())context_->Update();
|
||||
if(center_fixture_columns())context_->Update();
|
||||
if (rendered && menu_ == "friendlies") if (auto *list = element("friendly-opponents")) list->SetScrollTop(engine_friendly_scroll_);
|
||||
if (menu_ == "contracts" && engine_contract_scroll_) {
|
||||
if (auto *roster = element("contracts-roster-scroll")) roster->SetScrollTop(*engine_contract_scroll_);
|
||||
@@ -138,7 +138,7 @@ void App::engine_event(Rml::Event &event) {
|
||||
if (!engine_busy_ && popup_.empty() && contracts_event(event)) return;
|
||||
if (engine_reports_event(event)) return;
|
||||
if (!engine_busy_ && popup_.empty() && engine_friendly_event(event)) return;
|
||||
if (!engine_busy_ && planning_dialog_.empty() && popup_.empty() && (menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths") && report_picker_event(event)) return;
|
||||
if (!engine_busy_ && planning_dialog_.empty() && popup_.empty() && (menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths" || menu_=="league") && report_picker_event(event)) return;
|
||||
if (engine_sports_event(event)) return;
|
||||
Rml::ElementFormControl *range = nullptr;
|
||||
for (auto *node = target; node && node != doc_; node = node->GetParentNode())
|
||||
@@ -211,7 +211,7 @@ void App::engine_event(Rml::Event &event) {
|
||||
if (engine_reports_action(action,node)) return;
|
||||
if (almanac_action(action,node)) return;
|
||||
if (engine_friendly_action(action, node)) return;
|
||||
if ((menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths") && report_picker_action(action,node)) return;
|
||||
if ((menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths" || menu_=="league") && report_picker_action(action,node)) return;
|
||||
if (engine_calendar_action(action, node)) return;
|
||||
if (contracts_action(action, node)) return;
|
||||
if (environment_action(action, node)) return;
|
||||
@@ -225,6 +225,7 @@ void App::engine_event(Rml::Event &event) {
|
||||
ticket_->open(node, device_ratio_, price.at("min"), price.at("max")); dirty_ = true;
|
||||
}
|
||||
else if (action == "engine-open" && (id == "environment" || id == "advertising")) { menu_ = id; advertising_selected_ = -1; advertising_offer_ = 0; refresh(); }
|
||||
else if(action=="engine-open"&&id=="league"){menu_=id;engine_reports_sync();const auto league=engine_reports_state_.at("league").get<std::string>();engine_fixtures_load(league,engine_fixtures_value_.is_object()&&engine_fixtures_value_.at("leagueId")==league?engine_fixtures_value_.at("round").get<int>():0);}
|
||||
else if(action=="engine-open"&&(id=="tables"||id=="strengths")){menu_=id;engine_reports_sync();engine_reports_load(engine_reports_state_.at("league"),engine_reports_state_.at("filter"));}
|
||||
else if (action == "engine-open" && id == "almanac") { menu_=id;engine_almanac_sync();engine_almanac_load({{"kind","index"}}); }
|
||||
else if (action == "engine-open" && id == "friendlies") { menu_ = id; planning_dialog_.clear(); engine_friendly_sync(); refresh(); }
|
||||
@@ -251,5 +252,5 @@ void App::engine_event(Rml::Event &event) {
|
||||
}
|
||||
Json App::engine_snapshot() const {
|
||||
return {{"mode", engine_mode_}, {"busy", engine_busy_}, {"dirty", engine_dirty_}, {"fresh", engine_fresh_}, {"bundle", engine_data_},
|
||||
{"response", engine_response_}, {"reports_state",engine_reports_state_},{"reports_index",engine_reports_index_},{"reports_read",engine_reports_read_},{"reports_roster",engine_reports_roster_},{"almanac_cache",engine_almanac_cache_}, {"almanac_context",engine_almanac_context_}, {"friendly_quote", engine_friendly_read_}, {"friendly_league", engine_friendly_league_}, {"friendly_opponent", engine_friendly_opponent_}, {"friendly_date", engine_friendly_date_}, {"friendly_home", engine_friendly_home_}, {"friendly_stage", engine_friendly_stage_}, {"friendly_month", engine_friendly_month_}, {"calendar_day", engine_calendar_day_}, {"move_id", engine_move_id_}, {"credit_preview", engine_credit_}, {"credit_edits", engine_credit_edits_}, {"training_draft", engine_training_draft_}, {"tactics_draft", engine_tactics_draft_}, {"player_profile", engine_player_}, {"lineup_selected", lineup_selected_}, {"focus", engine_focus_}, {"selected_camp", engine_camp_}, {"notice", engine_notice_}};
|
||||
{"response", engine_response_}, {"fixtures_read",engine_fixtures_read_},{"reports_state",engine_reports_state_},{"reports_index",engine_reports_index_},{"reports_read",engine_reports_read_},{"reports_roster",engine_reports_roster_},{"almanac_cache",engine_almanac_cache_}, {"almanac_context",engine_almanac_context_}, {"friendly_quote", engine_friendly_read_}, {"friendly_league", engine_friendly_league_}, {"friendly_opponent", engine_friendly_opponent_}, {"friendly_date", engine_friendly_date_}, {"friendly_home", engine_friendly_home_}, {"friendly_stage", engine_friendly_stage_}, {"friendly_month", engine_friendly_month_}, {"calendar_day", engine_calendar_day_}, {"move_id", engine_move_id_}, {"credit_preview", engine_credit_}, {"credit_edits", engine_credit_edits_}, {"training_draft", engine_training_draft_}, {"tactics_draft", engine_tactics_draft_}, {"player_profile", engine_player_}, {"lineup_selected", lineup_selected_}, {"focus", engine_focus_}, {"selected_camp", engine_camp_}, {"notice", engine_notice_}};
|
||||
}
|
||||
@@ -819,4 +819,25 @@ Json engine_report_squad(const Json &bundle,const Json &read,const std::string &
|
||||
}
|
||||
auto result=data;for(auto &r:result["players"])r["live_strength"]=metric_value(r,"strength");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;
|
||||
for(const auto &l:data.at("leagues"))if(l.at("id")==league)selected=&l;
|
||||
require(selected,"Paarungen gehören keiner aktiven Liga.");
|
||||
auto context=bundle;context["league-fixtures"]=read;const auto &value=lineup_read(context,"league-fixtures");
|
||||
require(value.at("leagueId")==league&&value.at("league").at("id")==league&&value.at("round")==round&&value.at("rounds")==selected->at("matchdays"),"Paarungen gehören einer anderen Liga oder Runde.");
|
||||
(void)whole_in_range(value.at("round"),1,selected->at("matchdays"));
|
||||
require(value.at("matches").is_array()&&value.at("matches").size()*2==selected->at("members").size(),"Unvollständiger Ligaspieltag.");
|
||||
std::set<std::string> members,teams,ids;for(const auto &id:selected->at("members"))members.insert(id.get<std::string>());
|
||||
Json out=value;out["league"]=*selected;
|
||||
for(auto &m:out["matches"]) {
|
||||
const auto id=m.at("id").get<std::string>();require(!id.empty()&&ids.insert(id).second,"Doppelte oder fehlende Paarungs-ID.");
|
||||
for(const auto *side:{"home","away"}){const auto team=m.at(side).at("id").get<std::string>();require(members.contains(team)&&teams.insert(team).second&&m.at(side).at("name").is_string(),"Fremder oder doppelter Teilnehmer.");}
|
||||
const auto status=m.at("status").get<std::string>();require(status=="played"||status=="open"||status=="postponed"||status=="rescheduled"||status=="unavailable","Unbekannter Paarungsstatus.");
|
||||
if(status=="played"){require(m.at("result").is_array()&&m.at("result").size()==2,"Gespieltes Ergebnis fehlt.");for(const auto &n:m.at("result"))(void)whole_in_range(n,0,15);}
|
||||
else require(m.at("result").is_null(),"Ungespielte Partie enthält ein erfundenes Ergebnis.");
|
||||
m["home_team"]=m.at("home");m["away_team"]=m.at("away");m["home"]=m.at("home_team").at("id");m["away"]=m.at("away_team").at("id");
|
||||
m["home_goals"]=status=="played"?m.at("result")[0]:Json();m["away_goals"]=status=="played"?m.at("result")[1]:Json();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -4,6 +4,7 @@ void App::engine_reports_sync() {
|
||||
if(meta==engine_reports_context_)return;
|
||||
if(engine_reports_context_.is_null()||meta.at("careerId")!=engine_reports_context_.at("careerId")||meta.at("scope").at("managerId")!=engine_reports_context_.at("scope").at("managerId"))engine_reports_state_["league"]="";
|
||||
engine_reports_context_=meta;engine_reports_index_=Json();engine_reports_read_=Json();engine_reports_roster_=Json();engine_reports_value_=Json();engine_reports_roster_value_=Json();
|
||||
engine_fixtures_read_=Json();engine_fixtures_value_=Json();
|
||||
report_detail_kind_.clear();report_detail_club_.clear();report_detail_player_.clear();
|
||||
}
|
||||
void App::engine_reports_load(const std::string &preferred,int filter) {
|
||||
@@ -20,14 +21,31 @@ void App::engine_reports_load(const std::string &preferred,int filter) {
|
||||
return EngineReply{link,bundle,{{"messageType","reports_preview"},{"kind","league"},{"index",index},{"read",read},{"league",league},{"filter",filter}},nullptr};
|
||||
});
|
||||
}
|
||||
void App::engine_fixtures_load(const std::string &preferred,int round) {
|
||||
if(engine_busy_||!engine_fresh_)return;
|
||||
if(engine_fixtures_value_.is_object()&&engine_fixtures_value_.at("leagueId")==preferred&&engine_fixtures_value_.at("round")==round){refresh();return;}
|
||||
const int filter=engine_reports_state_.at("filter");auto link=engine_link_;
|
||||
engine_start("Ligaspiele werden geladen …",[link,preferred,round,filter] {
|
||||
const auto bundle=link->snapshot(),index=link->read({{"kind","report-index"}});const auto data=engine_report_index(bundle,index);
|
||||
const Json *league=nullptr;for(const auto &l:data.at("leagues"))if(l.at("id")==preferred)league=&l;
|
||||
if(!league)for(const auto &l:data.at("leagues"))if(l.at("own")==true){league=&l;break;}
|
||||
if(!league)league=&data.at("leagues")[0];
|
||||
const int total=league->at("matchdays");const int selected=round>0?std::clamp(round,1,total):std::min(league->at("played").get<int>()+1,total);
|
||||
const auto id=league->at("id").get<std::string>();
|
||||
const auto report=link->read({{"kind","league-report"},{"leagueId",id},{"filter",filter}}),fixtures=link->read({{"kind","league-fixtures"},{"leagueId",id},{"round",selected}});
|
||||
return EngineReply{link,bundle,{{"messageType","reports_preview"},{"kind","fixtures"},{"index",index},{"read",report},{"league",id},{"filter",filter},{"fixtures",fixtures},{"round",selected}},nullptr};
|
||||
});
|
||||
}
|
||||
void App::engine_reports_poll(const EngineReply &reply) {
|
||||
if(reply.bundle.at("desktop").at("meta")!=engine_reports_context_)throw editor::Error("Der Berichtskontext hat sich geändert. Bitte neu öffnen.");
|
||||
const auto &r=reply.response,&read=r.at("read");
|
||||
if(read.value("messageType","")=="error"){engine_notice_=engine_text(read.value("message",Json()));return;}
|
||||
if(r.at("kind")=="league") {
|
||||
if(r.at("kind")=="league"||r.at("kind")=="fixtures") {
|
||||
auto value=engine_report_projection(reply.bundle,r.at("index"),read,r.at("league"),r.at("filter"));
|
||||
Json fixtures;if(r.at("kind")=="fixtures")fixtures=engine_fixtures_projection(reply.bundle,r.at("index"),r.at("fixtures"),r.at("league"),r.at("round"));
|
||||
engine_reports_value_=std::move(value);engine_reports_index_=r.at("index");engine_reports_read_=read;
|
||||
engine_reports_state_["league"]=r.at("league");engine_reports_state_["filter"]=r.at("filter");
|
||||
if(r.at("kind")=="fixtures"){engine_fixtures_read_=r.at("fixtures");engine_fixtures_value_=std::move(fixtures);engine_reports_state_["round"]=r.at("round").get<int>()-1;}
|
||||
} else {
|
||||
engine_reports_roster_value_=engine_report_squad(reply.bundle,read,r.at("team"));engine_reports_roster_=read;
|
||||
if(report_detail_kind_=="roster"&&report_detail_club_==r.at("team").get<std::string>())focus_after_render_=engine_reports_roster_value_.at("players").empty()?"report-detail-close":"report-detail-player-0";
|
||||
@@ -35,6 +53,7 @@ void App::engine_reports_poll(const EngineReply &reply) {
|
||||
engine_notice_="Ligabericht geladen.";
|
||||
}
|
||||
Json App::engine_reports_rows(const std::string &mode) const {
|
||||
if(mode=="league")return engine_fixtures_value_.at("matches");
|
||||
std::vector<Json> rows;
|
||||
for(const auto &r:engine_reports_value_.at(mode=="tables"?"table":"strengths"))rows.push_back(r);
|
||||
return sort_report_rows(std::move(rows),engine_reports_state_.at("sorts").at(mode));
|
||||
@@ -60,10 +79,11 @@ std::vector<std::pair<std::string,std::string>> App::engine_reports_picker_items
|
||||
return out;
|
||||
}
|
||||
bool App::engine_reports_action(const std::string &action,Rml::Element *target) {
|
||||
if(menu_!="tables"&&menu_!="strengths")return false;
|
||||
if(menu_!="tables"&&menu_!="strengths"&&menu_!="league")return false;
|
||||
const auto id=target?target->GetAttribute<Rml::String>("data-id",""):std::string();
|
||||
if(action=="report-detail-close") {focus_after_render_=report_detail_return_focus_;report_detail_kind_.clear();report_detail_club_.clear();report_detail_player_.clear();refresh();return true;}
|
||||
if(engine_busy_||!engine_fresh_)return action.starts_with("report-")||action=="club-detail"||action=="player-detail";
|
||||
if(action=="report-round"&&menu_=="league") {if(id!="1"&&id!="-1")return true;const int current=engine_fixtures_value_.at("round"),total=engine_fixtures_value_.at("rounds");const int next=std::clamp(current+std::stoi(id),1,total);focus_after_render_=target->GetId();engine_fixtures_load(engine_reports_state_.at("league"),next);return true;}
|
||||
if(action=="report-sort") {
|
||||
const std::set<std::string> table{"rank","played","wins","draw","loss","form","points","gf","diff"},strength{"club","keeper","defence","midfield","attack","strength"};
|
||||
if(!(menu_=="tables"?table:strength).contains(id))return true;
|
||||
@@ -87,7 +107,7 @@ bool App::engine_reports_action(const std::string &action,Rml::Element *target)
|
||||
return false;
|
||||
}
|
||||
bool App::engine_reports_event(Rml::Event &event) {
|
||||
if((menu_!="tables"&&menu_!="strengths")||report_detail_kind_.empty())return false;
|
||||
if((menu_!="tables"&&menu_!="strengths"&&menu_!="league")||report_detail_kind_.empty())return false;
|
||||
const auto type=event.GetType();
|
||||
if(type=="keydown"&&event.GetParameter<int>("key_identifier",0)==Rml::Input::KI_ESCAPE){engine_reports_action("report-detail-close",nullptr);event.StopImmediatePropagation();return true;}
|
||||
if(type=="keydown"&&event.GetParameter<int>("key_identifier",0)==Rml::Input::KI_TAB){Rml::ElementList nodes;if(auto *root=element("report-detail-dialog"))root->QuerySelectorAll(nodes,"button");std::erase_if(nodes,[](auto *n){return n->HasAttribute("disabled");});if(!nodes.empty()){const auto it=std::find(nodes.begin(),nodes.end(),context_->GetFocusElement());int i=it==nodes.end()?-1:int(it-nodes.begin()),n=int(nodes.size());auto *next=nodes[size_t((i+n+(event.GetParameter<int>("shift_key",0)?-1:1))%n)];next->Focus(true);next->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));}event.StopImmediatePropagation();return true;}
|
||||
|
||||
@@ -37,6 +37,7 @@ Json App::engine_camp_view() const {
|
||||
}
|
||||
void App::engine_render() {
|
||||
if (ticket_) ticket_->close(false);
|
||||
fixture_half_width_=-1.f;
|
||||
almanac_list_width_=-1.f;
|
||||
if (menu_ == "friendlies") if (auto *list = element("friendly-opponents")) engine_friendly_scroll_ = list->GetScrollTop();
|
||||
if (menu_ == "contracts") if (auto *roster = element("contracts-roster-scroll")) engine_contract_scroll_ = roster->GetScrollTop();
|
||||
@@ -113,11 +114,12 @@ void App::engine_render() {
|
||||
const auto route = id.substr(4);
|
||||
const bool camp_allowed = desk.at("menuAvailability").at("camps").value("status", "") == "available";
|
||||
const auto commands = meta.at("scope").value("allowedCommands", Json::array());
|
||||
const bool supported = ((route=="tables"||route=="strengths")&&engine_fresh_&&meta.at("scope").at("role")=="club") || (route == "almanac" && engine_fresh_) || (route == "friendlies" && friendlies_available && engine_fresh_) || (route == "calendar" && calendar_available && engine_fresh_) || (route == "postpone" && scheduling_available && engine_fresh_) || (route == "contracts" && contracts_available && engine_fresh_) || (route == "environment" && environment_available && engine_fresh_) || (route == "advertising" && advertising_available && engine_fresh_) || (route == "bank" && bank_available && engine_fresh_) || (route == "training" && training_available && engine_fresh_) || (route == "tactics" && tactics_available && engine_fresh_) || (route == "lineup" && lineup_available && engine_fresh_) || route == "save" || (route == "camp" && engine_fresh_ && camp_allowed && std::find(commands.begin(), commands.end(), Json("camp.book")) != commands.end());
|
||||
const bool supported = ((route=="tables"||route=="strengths"||route=="league")&&engine_fresh_&&meta.at("scope").at("role")=="club") || (route == "almanac" && engine_fresh_) || (route == "friendlies" && friendlies_available && engine_fresh_) || (route == "calendar" && calendar_available && engine_fresh_) || (route == "postpone" && scheduling_available && engine_fresh_) || (route == "contracts" && contracts_available && engine_fresh_) || (route == "environment" && environment_available && engine_fresh_) || (route == "advertising" && advertising_available && engine_fresh_) || (route == "bank" && bank_available && engine_fresh_) || (route == "training" && training_available && engine_fresh_) || (route == "tactics" && tactics_available && engine_fresh_) || (route == "lineup" && lineup_available && engine_fresh_) || route == "save" || (route == "camp" && engine_fresh_ && camp_allowed && std::find(commands.begin(), commands.end(), Json("camp.book")) != commands.end());
|
||||
out += desktop_button(id, o, "engine-open", supported && !engine_busy_);
|
||||
}
|
||||
}
|
||||
out += "</div>";
|
||||
if(menu_=="league")out+="<div class=\"fill\" style=\"z-index:100;\">"+window("Ligaspiele",engine_fixtures_value_.is_object()?render_reports("league"):"<div class=\"fill center\">"+esc(engine_busy_?"Ligaspiele werden geladen …":engine_notice_)+"</div>")+"</div>";
|
||||
if(menu_=="tables"||menu_=="strengths")out+="<div class=\"fill\" style=\"z-index:100;\">"+window(menu_=="tables"?"Tabelle":"Stärken",engine_reports_read_.is_object()?render_reports(menu_):"<div class=\"fill center\">"+esc(engine_busy_?"Ligabericht wird geladen …":engine_notice_)+"</div>")+"</div>";
|
||||
if(menu_=="almanac") out+="<div class=\"fill\" style=\"z-index:100;\">"+window("Almanach",engine_almanac_cache_.contains("index")?render_almanac():"<div class=\"fill center\">"+esc(engine_busy_?"Spielarchiv wird geladen …":engine_notice_)+"</div>")+"</div>";
|
||||
if (menu_ == "friendlies") out += "<div class=\"fill\" style=\"z-index:100;\">" + window("Freundschaftsspiel", friendlies_available ? render_friendlies() : "<div class=\"fill center\">Freundschaftsplanung ist derzeit nicht verfügbar.</div>") + "</div>";
|
||||
@@ -132,7 +134,7 @@ void App::engine_render() {
|
||||
if (menu_ == "lineup") out += "<div class=\"fill\" style=\"z-index:100;\">" + window("Aufstellung", render_lineup()) + "</div>";
|
||||
if (menu_ == "camp") out += "<div class=\"fill\" style=\"z-index:100;\">" + window("Trainingslager", render_camp()) + "</div>";
|
||||
}
|
||||
if ((menu_ == "bank" || menu_ == "environment" || menu_ == "advertising" || menu_ == "contracts" || menu_ == "calendar" || menu_ == "postpone" || menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths") && !amount_ && contracts_dialog_.empty() && planning_dialog_.empty()) out += "<div class=\"panel\" style=\"position:absolute;bottom:12dp;left:700dp;right:700dp;padding:9dp;font-size:25dp;z-index:110;\" id=\"engine-status\">" + esc(engine_busy_ ? engine_operation_ : engine_notice_) + "</div>";
|
||||
if ((menu_ == "bank" || menu_ == "environment" || menu_ == "advertising" || menu_ == "contracts" || menu_ == "calendar" || menu_ == "postpone" || menu_ == "friendlies" || menu_ == "almanac" || menu_=="tables" || menu_=="strengths" || menu_=="league") && !amount_ && contracts_dialog_.empty() && planning_dialog_.empty()) out += "<div class=\"panel\" style=\"position:absolute;bottom:12dp;left:700dp;right:700dp;padding:9dp;font-size:25dp;z-index:110;\" id=\"engine-status\">" + esc(engine_busy_ ? engine_operation_ : engine_notice_) + "</div>";
|
||||
if (menu_.empty() || engine_data_.empty()) out += "<div class=\"panel\" style=\"position:absolute;left:850dp;bottom:24dp;right:100dp;padding:18dp;font-size:27dp;\" id=\"engine-status\">" + esc(engine_busy_ ? engine_operation_ : engine_notice_) + "</div>";
|
||||
element("canvas")->SetInnerRML(out); ++document_generation_;
|
||||
scale_chalk_shadow();
|
||||
@@ -155,7 +157,7 @@ void App::engine_render() {
|
||||
Rml::ElementList underlay; doc_->QuerySelectorAll(underlay, ".window>.content,.window>.titlebar");
|
||||
for (auto *node : underlay) { node->SetProperty("pointer-events", "none"); node->SetProperty("filter", "blur(10dp)"); }
|
||||
}
|
||||
if(!report_detail_kind_.empty()&&(menu_=="tables"||menu_=="strengths")){Rml::ElementList nodes;doc_->QuerySelectorAll(nodes,"#report-underlay button,#window-close");for(auto *n:nodes){n->SetAttribute("disabled",true);n->SetProperty("pointer-events","none");}}
|
||||
if(!report_detail_kind_.empty()&&(menu_=="tables"||menu_=="strengths"||menu_=="league")){Rml::ElementList nodes;doc_->QuerySelectorAll(nodes,"#report-underlay button,#window-close");for(auto *n:nodes){n->SetAttribute("disabled",true);n->SetProperty("pointer-events","none");}}
|
||||
if (engine_busy_) {
|
||||
Rml::ElementList controls; doc_->QuerySelectorAll(controls, "#canvas button,#canvas input");
|
||||
for (auto *node : controls) node->SetAttribute("disabled", true);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
void engine_contracts_close(bool focus = true);
|
||||
Json engine_reports_context_, engine_reports_index_, engine_reports_read_, engine_reports_roster_, engine_reports_value_, engine_reports_roster_value_;
|
||||
Json engine_reports_state_={{"league",""},{"filter",0},{"sorts",{{"tables",{{"key","rank"},{"desc",false}}},{"strengths",{{"key","strength"},{"desc",true}}}}}};
|
||||
Json engine_fixtures_read_, engine_fixtures_value_;
|
||||
void engine_fixtures_load(const std::string &,int);
|
||||
void engine_reports_sync();
|
||||
void engine_reports_load(const std::string &,int);
|
||||
void engine_reports_poll(const EngineReply &);
|
||||
|
||||
@@ -16,7 +16,7 @@ App::report_picker_items(const std::string &kind) const {
|
||||
std::vector<std::pair<std::string, std::string>> items;
|
||||
if (!world_ || !report_picker_kind(kind))
|
||||
return items;
|
||||
if (engine_mode_ && (menu_=="tables"||menu_=="strengths")) return engine_reports_picker_items(kind);
|
||||
if (engine_mode_ && (menu_=="tables"||menu_=="strengths"||menu_=="league")) return engine_reports_picker_items(kind);
|
||||
if (engine_mode_ && menu_ == "friendlies") return engine_friendly_picker_items(kind);
|
||||
if (menu_ == "statistics")
|
||||
return statistics_picker_items(kind);
|
||||
@@ -75,7 +75,7 @@ App::report_picker_items(const std::string &kind) const {
|
||||
std::string App::report_picker_value(const std::string &kind) const {
|
||||
if (!world_ || !report_picker_kind(kind))
|
||||
return {};
|
||||
if(engine_mode_&&(menu_=="tables"||menu_=="strengths")){if(kind=="filter")return std::to_string(engine_reports_state_.at("filter").get<int>());if(kind=="league")return engine_reports_state_.at("league");const auto live_index=engine_report_index(engine_data_,engine_reports_index_);for(const auto &l:live_index.at("leagues"))if(l.at("id")==engine_reports_state_.at("league"))return l.at("nationId").is_string()?l.at("nationId").get<std::string>():"__other__";return {}; }
|
||||
if(engine_mode_&&(menu_=="tables"||menu_=="strengths"||menu_=="league")){if(kind=="filter")return std::to_string(engine_reports_state_.at("filter").get<int>());if(kind=="league")return engine_reports_state_.at("league");const auto live_index=engine_report_index(engine_data_,engine_reports_index_);for(const auto &l:live_index.at("leagues"))if(l.at("id")==engine_reports_state_.at("league"))return l.at("nationId").is_string()?l.at("nationId").get<std::string>():"__other__";return {}; }
|
||||
if (menu_ == "statistics")
|
||||
return statistics_picker_value(kind);
|
||||
if (kind == "year") return std::to_string(almanac_year_);
|
||||
@@ -216,12 +216,12 @@ 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(engine_mode_&&(menu_=="tables"||menu_=="strengths")){
|
||||
if(engine_mode_&&(menu_=="tables"||menu_=="strengths"||menu_=="league")){
|
||||
std::string league=engine_reports_state_.at("league");int filter=engine_reports_state_.at("filter");
|
||||
if(kind=="league")league=value;
|
||||
else if(kind=="filter")filter=std::stoi(value);
|
||||
else if(kind=="country"){const auto index=engine_report_index(engine_data_,engine_reports_index_);for(const auto &l:index.at("leagues"))if((l.at("nationId").is_string()?l.at("nationId").get<std::string>():"__other__")==value){league=l.at("id");break;}}
|
||||
engine_reports_load(league,filter);
|
||||
if(menu_=="league")engine_fixtures_load(league,engine_fixtures_value_.at("round"));else engine_reports_load(league,filter);
|
||||
} else if (engine_mode_ && menu_ == "friendlies") {
|
||||
engine_friendly_filter(kind, value);
|
||||
} else if (menu_ == "statistics") {
|
||||
|
||||
@@ -70,10 +70,11 @@ std::string App::render_reports(const std::string &mode) {
|
||||
: rows.size() >= 20 ? (1682 - heading_height) / rows.size() : 80;
|
||||
std::string body = "<div id=\"report-underlay\" class=\"report-underlay\">";
|
||||
if (matches) {
|
||||
const int round = std::clamp(state.value("round", 0), 0,
|
||||
const int round = engine_mode_?engine_fixtures_value_.at("round").get<int>()-1:std::clamp(state.value("round", 0), 0,
|
||||
report_round_count(*world_, state, mode == "other") - 1);
|
||||
std::string subtitle;
|
||||
if (mode == "league" || state.value("competition", 0) == 0)
|
||||
if(engine_mode_){const auto &l=engine_fixtures_value_.at("league");subtitle=(l.at("nationId").is_string()?world_->nation_name(l.at("nationId")):std::string())+" · "+l.at("name").get<std::string>();}
|
||||
else if (mode == "league" || state.value("competition", 0) == 0)
|
||||
subtitle = (league ? world_->nation_name(league->value("nation", "")) : "") +
|
||||
" · " + (league ? world_->name(*league) : "");
|
||||
else {
|
||||
@@ -136,7 +137,7 @@ std::string App::render_reports(const std::string &mode) {
|
||||
std::string value;
|
||||
if (matches)
|
||||
value = row.at("home_goals").is_null() || row.at("away_goals").is_null()
|
||||
? "–" : report_number(row["home_goals"]) + " : " + report_number(row["away_goals"]);
|
||||
? (engine_mode_&&(row.value("status","")=="rescheduled"||row.value("status","")=="postponed")?"verlegt":"–") : report_number(row["home_goals"]) + " : " + report_number(row["away_goals"]);
|
||||
else if (!strengths && column == 5)
|
||||
value = row.value("form_text", "");
|
||||
else if (!strengths && column == 7)
|
||||
@@ -171,7 +172,7 @@ std::string App::render_reports(const std::string &mode) {
|
||||
body += btn("report-round", i ? "›" : "‹", "report-round",
|
||||
"id=\"report-round-" + std::string(i ? "next" : "previous") +
|
||||
"\" data-id=\"" + (i ? "1" : "-1") + "\" style=\"" +
|
||||
rect(i * 130, 0, 110, 94) + "\" " + (opening ? "disabled" : ""));
|
||||
rect(i * 130, 0, 110, 94) + "\" " + ((opening||(engine_mode_&&(i?engine_fixtures_value_.at("round")==engine_fixtures_value_.at("rounds"):engine_fixtures_value_.at("round")==1))) ? "disabled" : ""));
|
||||
body += mode == "league" ? report_picker("country", 260, 1060) + report_picker("league", 1340, 1272)
|
||||
: report_picker("competition", 260, 2352);
|
||||
} else if (strengths)
|
||||
|
||||
Reference in new issue
Block a user