Port settings and automation to the Modern UI (by Codex)
This commit is contained in:
1 parent
8222926d9c
commit
adb4166a80
26 files changed
+2734
-179
No files matched your search
+26
-11
@@ -19,6 +19,8 @@
|
||||
#include "modern/ui/demo_stadium.hpp"
|
||||
#include "modern/ui/demo_statistics.hpp"
|
||||
#include "modern/ui/demo_news.hpp"
|
||||
#include "modern/ui/demo_settings.hpp"
|
||||
#include "modern/ui/ui_preferences.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/gui_assets.hpp"
|
||||
#include "modern/ui/model.hpp"
|
||||
@@ -408,8 +410,7 @@ class App final : public Rml::EventListener {
|
||||
int last_tactic_ = 0;
|
||||
bool draw_playing_ = true;
|
||||
uint64_t draw_at_ = 0;
|
||||
std::string settings_category_ = "display";
|
||||
Json draft_preferences_;
|
||||
#include "modern/ui/settings_state.inc"
|
||||
std::map<std::string, std::string> selections_;
|
||||
Rml::Element *element(const std::string &id) const {
|
||||
return doc_->GetElementById(id);
|
||||
@@ -585,6 +586,7 @@ class App final : public Rml::EventListener {
|
||||
return nullptr;
|
||||
}
|
||||
void load_world(const fs::path &file) {
|
||||
reset_settings();
|
||||
auto next = Catalog::open(file);
|
||||
auto demo = std::make_unique<DemoSource>(next);
|
||||
ticket_.reset();
|
||||
@@ -807,7 +809,7 @@ class App final : public Rml::EventListener {
|
||||
pending_selects_.erase(id);
|
||||
if (auto *select = element(id)) {
|
||||
// Menu-local select handlers receive only a committed/cancelled value.
|
||||
if ((menu_ == "lineup" && id.starts_with("lineup-")) ||
|
||||
if (menu_ == "settings" || (menu_ == "lineup" && id.starts_with("lineup-")) ||
|
||||
(menu_ == "transfer" && id.starts_with("transfer-")))
|
||||
select->DispatchEvent("change", {});
|
||||
else change(select);
|
||||
@@ -853,6 +855,7 @@ class App final : public Rml::EventListener {
|
||||
// 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_) {
|
||||
if(last_rendered_menu_=="settings")reset_settings();
|
||||
statistics_trophy_ = Json::object();
|
||||
planning_dialog_.clear();
|
||||
career_view_["dialog"] = ""; career_view_["return_focus"] = "";
|
||||
@@ -1072,6 +1075,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 (menu_ == "settings") settings_after_render();
|
||||
if (!report_option_to_scroll_.empty()) {
|
||||
if (auto *node = element(report_option_to_scroll_))
|
||||
node->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
|
||||
@@ -1223,8 +1227,15 @@ public:
|
||||
"mouseup", "mousemove", "contextmenu", "focus"})
|
||||
doc_->AddEventListener(event, this, Rml::String(event) == "keydown" ||
|
||||
Rml::String(event) == "blur" || Rml::String(event) == "focus");
|
||||
if (!config_.theme.empty())
|
||||
theme_ = config_.theme;
|
||||
try {
|
||||
ui_preferences_loaded_=fs::exists(ui_preferences_file());
|
||||
ui_preferences_=load_ui_preferences(ui_preferences_file());
|
||||
} catch(const std::exception &) {
|
||||
ui_preferences_error_="Die gespeicherten UI-Einstellungen konnten nicht geladen werden. Die Standardwerte werden verwendet.";
|
||||
ui_preferences_=default_ui_preferences();ui_preferences_loaded_=false;
|
||||
}
|
||||
theme_=ui_preferences_.at("theme").get<std::string>();
|
||||
if (!config_.theme.empty()) theme_ = config_.theme;
|
||||
if (theme_ != "midnight" && theme_ != "silver" && theme_ != "matchday")
|
||||
throw editor::Error("Unbekanntes Modern-Theme.");
|
||||
collect_mods();
|
||||
@@ -1243,19 +1254,21 @@ public:
|
||||
if (!config_.state.empty() && source_) {
|
||||
desktop_ = source_->load(config_.state);
|
||||
saved_desktop_ = desktop_;
|
||||
if (config_.theme.empty())
|
||||
theme_ = snap().state.at("preferences").value("theme", theme_);
|
||||
if (config_.theme.empty() && !ui_preferences_loaded_) {
|
||||
ui_preferences_=legacy_ui_preferences(snap().state.at("preferences"));
|
||||
theme_=ui_preferences_.at("theme").get<std::string>();
|
||||
}
|
||||
}
|
||||
if (source_ && !config_.theme.empty()) {
|
||||
auto preferences = snap().state.at("preferences");
|
||||
preferences["theme"] = theme_;
|
||||
apply("preferences", preferences);
|
||||
if (!config_.theme.empty()) {
|
||||
// A capture/CLI override is visual only and never edits a career.
|
||||
ui_preferences_["theme"]=theme_;
|
||||
}
|
||||
if (scene_ == "manager" && selections_["manager-name"].empty())
|
||||
selections_["manager-name"] = "Alex Berger";
|
||||
doc_->Show();
|
||||
resize();
|
||||
render();
|
||||
if (!ui_preferences_error_.empty()) message(ui_preferences_error_);
|
||||
SDL_ShowWindow(video_.window);
|
||||
frame();
|
||||
} catch (...) {
|
||||
@@ -1381,6 +1394,8 @@ public:
|
||||
#include "modern/ui/statistics_controls.inc"
|
||||
#include "modern/ui/news_screens.inc"
|
||||
#include "modern/ui/news_controls.inc"
|
||||
#include "modern/ui/settings_screens.inc"
|
||||
#include "modern/ui/settings_controls.inc"
|
||||
} // namespace
|
||||
bool is_modern_world(const fs::path &file) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user