Port lineup and transfer market to the native Modern UI (by Codex)

This commit is contained in:
Codex committed 2026-10-25 10:23:53 +01:00
1 parent ec1d804d08
commit bf3f910437
33 files changed
+3339 -29

No files matched your search

+72 -6
View File
@@ -12,6 +12,8 @@
#include "modern/ui/demo_toto.hpp"
#include "modern/ui/demo_reports.hpp"
#include "modern/ui/demo_sports.hpp"
#include "modern/ui/demo_lineup.hpp"
#include "modern/ui/demo_transfer.hpp"
#include "modern/ui/desktop.hpp"
#include "modern/ui/gui_assets.hpp"
#include "modern/ui/model.hpp"
@@ -324,7 +326,7 @@ class App final : public Rml::EventListener {
bool focus_ticket_ = false;
std::set<std::string> pending_selects_;
std::string focus_after_render_;
bool keyboard_navigation_ = false;
bool keyboard_navigation_ = false, setting_menu_markup_ = false;
std::string last_rendered_menu_;
std::optional<float> training_scroll_;
std::optional<float> report_scroll_;
@@ -352,6 +354,18 @@ class App final : public Rml::EventListener {
int toto_column_ = 0;
std::array<std::pair<int, int>, 6> toto_focus_{{{0,1},{0,1},{0,1},{0,1},{0,1},{0,1}}};
std::string toto_dialog_, toto_return_focus_;
bool lineup_pitch_ = true;
int lineup_data_ = 0, lineup_page_ = 0;
std::string lineup_side_ = "formations", lineup_selected_;
Json lineup_drag_;
uint64_t lineup_drag_revision_ = 0;
std::shared_ptr<const Catalog> lineup_drag_world_;
bool lineup_ignore_click_ = false, lineup_reset_scroll_ = false;
std::optional<float> lineup_roster_scroll_, lineup_bench_scroll_;
Json transfer_view_ = Json::object(), transfer_draft_, transfer_search_draft_;
std::string transfer_dialog_, transfer_return_focus_, transfer_notice_, transfer_poach_league_, transfer_poach_club_, transfer_picker_;
uint64_t transfer_revision_ = 0;
std::shared_ptr<const Catalog> transfer_world_;
float device_ratio_ = 1.f;
Json desktop_ = Json::object(), saved_desktop_ = Json::object(),
options_ = Json::object();
@@ -565,6 +579,11 @@ class App final : public Rml::EventListener {
renderer_.world(next);
world_ = std::move(next);
source_ = std::move(demo);
lineup_drag_ = Json(); lineup_drag_world_.reset(); lineup_selected_.clear(); lineup_ignore_click_ = false;
lineup_pitch_ = true; lineup_data_ = lineup_page_ = 0; lineup_side_ = "formations";
transfer_view_ = Json::object(); transfer_draft_ = transfer_search_draft_ = Json();
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;
advertising_selected_ = -1; advertising_offer_ = 0; advertising_revision_ = 0; advertising_world_.reset();
toto_column_ = 0; toto_dialog_.clear();
for (auto &focus : toto_focus_) focus = {0, 1};
@@ -714,6 +733,17 @@ class App final : public Rml::EventListener {
std::string render_toto();
bool toto_action(const std::string &, Rml::Element *);
bool toto_event(Rml::Event &);
std::string render_lineup();
bool lineup_action(const std::string &, Rml::Element *);
bool lineup_event(Rml::Event &);
void cancel_lineup_drag(bool refresh_view = true);
std::string render_transfer();
std::string render_transfer_dialog();
bool transfer_action(const std::string &, Rml::Element *);
bool transfer_event(Rml::Event &);
void close_transfer(bool restore = true);
void transfer_remember_scroll();
void transfer_restore_scroll();
std::string render_almanac();
bool almanac_action(const std::string &, Rml::Element *);
std::string render_indoor();
@@ -742,8 +772,13 @@ class App final : public Rml::EventListener {
}
for (const auto &id : ready) {
pending_selects_.erase(id);
if (auto *select = element(id))
change(select);
if (auto *select = element(id)) {
// Menu-local select handlers receive only a committed/cancelled value.
if ((menu_ == "lineup" && id.starts_with("lineup-")) ||
(menu_ == "transfer" && id.starts_with("transfer-")))
select->DispatchEvent("change", {});
else change(select);
}
}
}
void input(Rml::Element *);
@@ -783,6 +818,9 @@ class App final : public Rml::EventListener {
// open. Never keep that menu's modal/input gate in the destination view.
if (menu_ != last_rendered_menu_) {
planning_dialog_.clear();
lineup_drag_ = Json(); lineup_drag_world_.reset(); lineup_ignore_click_ = false;
transfer_dialog_.clear(); transfer_draft_ = transfer_search_draft_ = Json(); transfer_picker_.clear();
transfer_world_.reset(); transfer_revision_ = 0; transfer_return_focus_.clear();
toto_dialog_.clear();
if (menu_ == "toto" && source_)
for (size_t c = 0; c < toto_focus_.size(); ++c) {
@@ -795,6 +833,15 @@ class App final : public Rml::EventListener {
report_detail_kind_.clear();
report_picker_.clear();
}
lineup_roster_scroll_.reset();
lineup_bench_scroll_.reset();
if (menu_ == "lineup" && last_rendered_menu_ == "lineup") {
if (auto *roster = element("lineup-roster-scroll"))
lineup_roster_scroll_ = lineup_reset_scroll_ ? 0.f : roster->GetScrollTop();
if (auto *bench = element("lineup-bench-scroll"))
lineup_bench_scroll_ = bench->GetScrollTop();
}
lineup_reset_scroll_ = false;
training_scroll_.reset();
if (menu_ == "training" && last_rendered_menu_ == "training")
if (auto *roster = element("training-roster"))
@@ -824,11 +871,13 @@ class App final : public Rml::EventListener {
markup = render_desktop();
if (!menu_.empty())
markup += render_menu(menu_);
setting_menu_markup_ = true;
element("canvas")->SetInnerRML(markup);
if (!report_detail_kind_.empty() || !planning_dialog_.empty() || !contracts_dialog_.empty() || !toto_dialog_.empty()) {
setting_menu_markup_ = false;
if (!report_detail_kind_.empty() || !planning_dialog_.empty() || !contracts_dialog_.empty() || !toto_dialog_.empty() || !transfer_dialog_.empty()) {
Rml::ElementList behind;
doc_->QuerySelectorAll(behind,
"#report-underlay button,#report-underlay input,#report-underlay select,#contracts-underlay button,#toto-underlay button,.window .titlebar button");
"#report-underlay button,#report-underlay input,#report-underlay select,#contracts-underlay button,#toto-underlay button,#lineup-underlay button,#lineup-underlay select,#lineup-underlay input,#transfer-underlay button,#transfer-underlay select,#transfer-underlay input,.window .titlebar button");
for (auto *node : behind)
node->SetProperty("pointer-events", "none");
}
@@ -867,7 +916,10 @@ class App final : public Rml::EventListener {
if (focus_after_render_.starts_with("report-option-") ||
focus_after_render_.starts_with("friendly-opponent-") ||
focus_after_render_.starts_with("alm-match-") ||
focus_after_render_.starts_with("contract-player-"))
focus_after_render_.starts_with("contract-player-") ||
focus_after_render_.starts_with("lineup-name-") ||
focus_after_render_.starts_with("lineup-detail-") ||
focus_after_render_.starts_with("lineup-bench-"))
report_option_to_scroll_ = focus_after_render_;
focus_after_render_.clear();
}
@@ -973,6 +1025,15 @@ class App final : public Rml::EventListener {
list->SetScrollTop(*report_scroll_);
report_scroll_.reset();
}
if (lineup_roster_scroll_) {
if (auto *roster = element("lineup-roster-scroll")) roster->SetScrollTop(*lineup_roster_scroll_);
lineup_roster_scroll_.reset();
}
if (lineup_bench_scroll_) {
if (auto *bench = element("lineup-bench-scroll")) bench->SetScrollTop(*lineup_bench_scroll_);
lineup_bench_scroll_.reset();
}
if (menu_ == "transfer") transfer_restore_scroll();
if (!report_option_to_scroll_.empty()) {
if (auto *node = element(report_option_to_scroll_))
node->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
@@ -1238,6 +1299,11 @@ public:
#include "modern/ui/advertising_controls.inc"
#include "modern/ui/toto_screens.inc"
#include "modern/ui/toto_controls.inc"
#include "modern/ui/nation_flags.inc"
#include "modern/ui/lineup_screens.inc"
#include "modern/ui/lineup_controls.inc"
#include "modern/ui/transfer_screens.inc"
#include "modern/ui/transfer_controls.inc"
} // namespace
bool is_modern_world(const fs::path &file) {
try {