// SPDX-License-Identifier: GPL-3.0-only // Included in the native UI implementation's anonymous namespace. void App::init_desktop() { if(!desktop_.contains("objects"))desktop_=default_desktop(); if(!working_desktop_initialized_){ working_desktop_initialized_=true; const auto file=user_dir()/"working-desktop.json"; if(config_.state.empty()&&fs::is_regular_file(file)){ try{auto next=Json::parse(editor::read_file(file));if(!migrate_desktop(next))throw editor::Error("Ungültige Desktopanordnung.");desktop_=std::move(next);} catch(const std::exception &){message("Die gespeicherte Desktopanordnung konnte nicht geladen werden. Die Standardansicht wird verwendet.");} } working_desktop_base_=desktop_;saved_desktop_=desktop_; } } std::string App::render_desktop() { init_desktop(); const auto s = snap(); widget_data_=demo_desktop_widgets(*world_,s.state); const bool national=s.state.at("career").value("role", "club")=="national"; const auto *c = club(s); std::string out = "
" + btn("desktop-context", (national?img("career.national-de",82,82,false,false,256):crest(c,82)) + "" + esc(national?"Deutschland":c ? world_->name(*c) : "") + "" + esc(manager(s).value("name", "")) + "", "identity", "id=\"desktop-identity\"") + "
" + std::string(widget_data_.at("matchday")==0?"Saisonvorbereitung":std::to_string(widget_data_.at("matchday").get())+". Spieltag") + "" + esc(widget_data_.at("season").get()) + "
"+std::string(national?"Aufgabenbereich":"Guthaben")+"" + (national?std::string("Nationalmannschaft"):cash(s.state.value("cash", int64_t(0)))) + "
"; if(desktop_.value("grid",true))for(int row=0;row<7;++row)for(int col=0;col<15;++col)out+=""; for (const auto &[id, o] : desktop_["objects"].items()) { if (!o.value("visible", false) || (o.value("widget",false)?!demo_career_widget_available(s.state,id):!demo_career_menu_available(s.state,id.substr(4)))) continue; const auto style = rect(o.value("x", 0), o.value("y", 0), o.value("w", 224), o.value("h", 224)) + "z-index:" + std::to_string(o.value("z", 1)) + ";"; if (o.value("widget", false)) { std::string size="s",route; for(const auto &d:widget_catalogue())if(d.at("id")==id){route=d.value("route","");for(const auto &[key,span]:d.at("spans").items())if(o.at("w")==span[0].get()*248-24&&o.at("h")==span[1].get()*248-24)size=key;} out += "
" + widget(id, o) + (o.value("pinned", true) ? "
" : "") + "
"; } else { const auto route = id.substr(4); const std::array colors = { "#3d789b", "#375a83", "#477c73", "#42846b", "#a58a49", "#586ba0", "#517d71", "#668a98", "#af6860", "#6b809c", "#657cb3", "#507b9c", "#559b76", "#a7474e", "#967d50", "#648f91", "#54856b", "#558f93", "#6379a3", "#788598", "#8d7856", "#a66d64", "#748474", "#6887a2", "#6b9270", "#7c8b9c", "#ac8b52", "#7783a4", "#648f83", "#927d9d", "#ac5e63", "#806c98"}; const auto i = std::find(routes.begin(), routes.end(), route); const auto color = colors[size_t(i - routes.begin())]; const auto top = theme_ == "matchday" ? mixed_color(color, "#27282e", .55) : mixed_color(color, "#c5ddf1", .1); const auto bottom = theme_ == "matchday" ? "#272a30" : mixed_color(color, "#07111e", .38); out += ""; } } return out + "
"; } std::string App::render_camp() { const auto index_file = Json::parse(editor::read_file(gui_.root() / "gui-assets.json")); const auto demo = index_file.at("demo"), camps = demo.at("training_camps"); const auto s = snap(); const auto id = s.state.at("camp").value("selected", std::string("resort:4")); const Json *chosen = nullptr; for (const auto &c : camps) if (c.value("id", "") == id) chosen = &c; if (!chosen) chosen = &camps.at(0); auto region = selections_["camp-region"]; if (region.empty()) region = chosen->value("map", "map:eu"); std::string body = "
"; for (const auto &m : demo.at("maps")) body += btn("camp-region", esc(m.value("name", "")), m.value("id", "") == region ? "primary" : "", "data-id=\"" + esc(m.value("id", "")) + "\""); body += "
" + img("map." + region.substr(4), 1440, 1603.2, false, false, 1600); for (const auto &c : camps) if (c.value("map", "") == region) { const double x = c.value("x", 0) * 1.2, y = c.value("y", 0) * 1.2; body += btn("camp-select", "", c.value("id", "") == id ? "primary" : "", "data-id=\"" + esc(c.value("id", "")) + "\" style=\"position:absolute;" + rect(x - 34, y - 34, 68, 68) + "padding:23dp;border-radius:34dp;\""); } body += "
<" "div style=\"height:570dp;overflow:hidden;border-radius:24dp;\">" + img(chosen->value("gui_image", ""), 1100, 570, false, true, 1400) + "

" + esc(chosen->value("name", "")) + "

" + esc(chosen->value("place", "")) + "

"; const std::array qualities = { "Platzqualität", "Fitnessgeräte", "Verpflegung", "Unterkunft"}; for (size_t i = 0; i < 4; ++i) { const int q = chosen->at("quality")[i].get(); std::string stars; for (int j = 0; j < q; ++j) stars += glyph("star", 32); body += "
" + std::string(qualities[i]) + "" + stars + "
"; } body += "
Preis" + cash(chosen->value("price", int64_t(0))) + "
"; const std::array focus = {"Kondition", "Technik", "Spiel", "Erholung"}; const auto values = s.state.at("camp").at("focus"); int sum = 0; for (const auto &v : values) sum += v.get(); for (int i = 0; i < 4; ++i) { const int value = i == 3 ? 15 - sum / 3 : values[size_t(i)].get(); body += "
" + std::to_string(value) + " / 15
"; } body += "
" + btn("camp-remember", "Vormerken", "primary") + "
"; return body; } std::string App::render_menu(const std::string &key) { if(key=="view-save"||key=="view-load")return render_files(true,key=="view-save"); if (key == "widgets" || key == "background" || key == "warning" || key == "quit") return render_widget_dialog(key); if (key == "news") return "
" + render_news() + "
"; std::string body; if(source_ && snap().state.at("career").value("role","club")=="national" && std::set{"achievements","friendlies","scorers"}.contains(key)) body=render_national(key); else if (key == "tables" || key == "strengths" || key == "league" || key == "other") body = render_reports(key); else if (key == "almanac") body = render_almanac(); else if (key == "postpone") body = render_postpone(); else if (key == "friendlies") body = render_friendlies(); else if (key == "indoor") body = render_indoor(); else if (key == "lineup") body = render_lineup(); else if (key == "transfer") body = render_transfer(); else if (key == "achievements") body = render_achievements(); else if (key == "scorers") body = render_scorers(); else if (key == "fairplay") body = render_fairplay(); else if (key == "highscore") 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") body = render_advertising(); else if (key == "toto") body = render_toto(); else if (key == "bank") body = render_bank(); else if (key == "balance") body = render_balance(); else if (key == "contracts") body = render_contracts(); else if (key == "training") body = render_training(); else if (key == "tactics") body = render_tactics(); else if (key == "calendar") body = render_calendar(); else if (key == "camp") body = render_camp(); else if (key == "settings") body = render_settings(); else if (key == "save" || key == "load") body = render_files(false,key == "save"); else throw editor::Error("Diese native Ansicht ist noch nicht verfügbar."); std::string heading = key == "postpone" ? "Spiel verlegen" : title(key); if (key == "bank" && bank_view_ != "entrance") { const std::map labels = {{"savings", "Sparbuch"}, {"properties", "Immobilien"}, {"stocks", "Aktien"}, {"credit", "Kredit"}, {"overview", "Finanzübersicht"}}; if (labels.contains(bank_view_)) heading += " · " + labels.at(bank_view_); } return "
" + window(heading, body) + (key == "statistics" ? render_statistics_trophy() : "") + "
"; }