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
+13
-44
@@ -133,7 +133,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
const auto type = event.GetType();
|
||||
// Native widgets can emit intermediate selected values while their options
|
||||
// are being constructed. Opening a squad menu must stay read-only.
|
||||
if (setting_menu_markup_ && (menu_ == "lineup" || menu_ == "transfer" || menu_ == "news") &&
|
||||
if (setting_menu_markup_ && (menu_ == "lineup" || menu_ == "transfer" || menu_ == "news" || menu_ == "settings") &&
|
||||
(type == "change" || type == "input")) return;
|
||||
if (type == "keydown")
|
||||
keyboard_navigation_ = true;
|
||||
@@ -154,6 +154,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
if (n->GetId() == "native-ticket-layer")
|
||||
return;
|
||||
if (amount_event(event)) return;
|
||||
if (popup_.empty() && settings_event(event)) return;
|
||||
if ((menu_ == "lineup" || menu_ == "transfer") && (type == "change" || type == "input")) {
|
||||
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(event.GetTargetElement());
|
||||
select && select->IsSelectBoxVisible()) {
|
||||
@@ -246,7 +247,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
if (type == "mouseup" && event.GetParameter<int>("button", 0) == 1) {
|
||||
if (scene_ == "desktop" && !menu_.empty() && popup_.empty()) {
|
||||
menu_.clear();
|
||||
draft_preferences_ = nullptr;
|
||||
reset_settings();
|
||||
refresh();
|
||||
} else if (scene_ == "desktop" && menu_.empty() && popup_.empty()) {
|
||||
std::string id;
|
||||
@@ -363,7 +364,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
dirty_ = true;
|
||||
} else if (!menu_.empty()) {
|
||||
menu_.clear();
|
||||
draft_preferences_ = nullptr;
|
||||
reset_settings();
|
||||
refresh();
|
||||
} else if (scene_ == "manager") {
|
||||
scene_ = "newgame";
|
||||
@@ -459,6 +460,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
const auto id =
|
||||
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
|
||||
if (settings_action(action,target)) return;
|
||||
if (lineup_action(action, target) || transfer_action(action, target)) return;
|
||||
if (career_report_action(action, target) || rankings_action(action, target)) return;
|
||||
if (statistics_action(action, target) || dispatch_news(action, target)) return;
|
||||
@@ -678,7 +680,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
}
|
||||
if (action == "close") {
|
||||
menu_.clear();
|
||||
draft_preferences_ = nullptr;
|
||||
reset_settings();
|
||||
if (scene_ != "desktop")
|
||||
scene_ = "main";
|
||||
refresh();
|
||||
@@ -692,7 +694,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
}
|
||||
if (action == "settings") {
|
||||
settings_category_ = "display";
|
||||
draft_preferences_ = nullptr;
|
||||
reset_settings();
|
||||
menu_ = "settings";
|
||||
refresh();
|
||||
return;
|
||||
@@ -1088,7 +1090,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
planning_dialog_.clear();
|
||||
if (route == "settings") {
|
||||
settings_category_ = "display";
|
||||
draft_preferences_ = nullptr;
|
||||
reset_settings();
|
||||
}
|
||||
refresh();
|
||||
return;
|
||||
@@ -1155,37 +1157,6 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
message("Trainingslager für die Demo vorgemerkt.");
|
||||
return;
|
||||
}
|
||||
if (action == "settings-category") {
|
||||
settings_category_ = id;
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "settings-theme") {
|
||||
draft_preferences_["theme"] = id;
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "settings-apply") {
|
||||
if (settings_category_ == "display") {
|
||||
for (const auto *key : {"mode", "resolution", "scale"}) {
|
||||
const auto value = field(std::string("display-") + key);
|
||||
if (!value.empty())
|
||||
draft_preferences_[key] = value;
|
||||
}
|
||||
}
|
||||
if (settings_category_ == "sound") {
|
||||
draft_preferences_["effects"] =
|
||||
element("sound-effects")->HasAttribute("checked");
|
||||
draft_preferences_["sound-style"] = field("sound-style");
|
||||
}
|
||||
if (source_ && !apply("preferences", draft_preferences_))
|
||||
return;
|
||||
theme_ = draft_preferences_.value("theme", theme_);
|
||||
draft_preferences_ = nullptr;
|
||||
menu_.clear();
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "save-select") {
|
||||
selections_["save"] = id;
|
||||
refresh();
|
||||
@@ -1230,7 +1201,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
desktop_ =
|
||||
source_->load(user_dir() / "saves" / editor::path(name + ".json"));
|
||||
saved_desktop_ = desktop_;
|
||||
theme_ = snap().state.at("preferences").value("theme", theme_);
|
||||
if(!ui_preferences_loaded_){ui_preferences_=legacy_ui_preferences(snap().state.at("preferences"));theme_=ui_preferences_.at("theme").get<std::string>();}
|
||||
menu_.clear();
|
||||
scene_ = "desktop";
|
||||
refresh();
|
||||
@@ -1279,6 +1250,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
}
|
||||
}
|
||||
void App::change(Rml::Element *target) {
|
||||
if(settings_change(target))return;
|
||||
const auto kind = target->GetAttribute<Rml::String>("data-change", "");
|
||||
auto *control = dynamic_cast<Rml::ElementFormControl *>(target);
|
||||
if (!control)
|
||||
@@ -1342,6 +1314,7 @@ void App::change(Rml::Element *target) {
|
||||
}
|
||||
}
|
||||
void App::input(Rml::Element *target) {
|
||||
if(settings_change(target))return;
|
||||
const auto kind = target->GetAttribute<Rml::String>("data-input", "");
|
||||
auto *control = dynamic_cast<Rml::ElementFormControl *>(target);
|
||||
if (!control)
|
||||
@@ -1359,12 +1332,7 @@ void App::input(Rml::Element *target) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (kind == "sound-volume") {
|
||||
const int n = std::stoi(value);
|
||||
draft_preferences_["volume"] = n;
|
||||
element("volume-value")->SetInnerRML(std::to_string(n) + " %");
|
||||
dirty_ = true;
|
||||
}
|
||||
|
||||
if (kind == "camp-focus") {
|
||||
const auto i = std::stoi(target->GetAttribute<Rml::String>("data-id", "0"));
|
||||
if (i < 0 || i > 2)
|
||||
@@ -1469,6 +1437,7 @@ void App::script() {
|
||||
{"transfer_view", transfer_view_}, {"transfer_dialog", transfer_dialog_}, {"transfer_draft", transfer_draft_},
|
||||
{"career_view", career_view_}, {"rankings_view", rankings_view_},
|
||||
{"stadium_view", stadium_view_},
|
||||
{"ui_preferences",ui_preferences_}, {"settings_draft",settings_draft_}, {"settings_category",settings_category_}, {"settings_query",settings_query_}, {"settings_notice",settings_notice_},
|
||||
{"statistics_view", statistics_view_}, {"statistics_trophy", statistics_trophy_},
|
||||
{"statistics_scrolls", statistics_scrolls_},
|
||||
{"news_view", news_view_}, {"news_dialog", news_dialog_},
|
||||
|
||||
Reference in new issue
Block a user