Port statistics and the news tablet to the Modern UI (by Codex)
This commit is contained in:
1 parent
349c416f3a
commit
a45217c362
32 files changed
+2493
-23
No files matched your search
+49
-2
@@ -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<const Catalog> 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<fs::path> 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 {
|
||||
|
||||
Reference in new issue
Block a user