Bind original settings and automation to atomic native drafts (by Codex)

This commit is contained in:
Codex committed 2026-10-29 18:52:41 +01:00
1 parent 2ce563a4b9
commit 98cff2185d
23 files changed
+959 -189

No files matched your search

+23 -13
View File
@@ -62,12 +62,10 @@ void App::settings_sync() {
else if (scope == "automation") {
const auto &a = settings_draft_["local"]["automation"];
if (key == "all") {
int n = 0;
for (const auto &[k, v] : a.items())
if (v == true)
++n;
on = n == 5;
mixed = n > 0 && n < 5;
int n=0,total=0;
for (const auto &[k,v]:a.items()) if(engine_settings_editable("automation",k)){++total;if(v==true)++n;}
on = total > 0 && n == total;
mixed = n > 0 && n < total;
} else
on = a.at(key).get<bool>();
}
@@ -82,6 +80,14 @@ void App::settings_sync() {
: "5") +
"dp");
}
if (engine_mode_) {
for (const auto &[key,cap]:engine_settings_value_.at("automation").items()) if(auto *node=element("automation-"+key)) {
if(cap.at("editable")==true)node->RemoveAttribute("disabled");else node->SetAttribute("disabled",true);
}
if(auto *node=element("automation-formation")) {
if(engine_settings_editable("automation","lineup")&&settings_draft_.at("local").at("automation").at("lineup")==true)node->RemoveAttribute("disabled");else node->SetAttribute("disabled",true);
}
}
for (const auto *theme : {"midnight", "silver", "matchday"})
if (auto *button = element(std::string("settings-theme-") + theme))
button->SetAttribute(
@@ -184,13 +190,16 @@ bool App::settings_change(Rml::Element *target) {
dirty_ = true;
return true;
}
if (scope == "global")
if (scope == "formation" && engine_mode_) {
for(const auto &slot:engine_settings_value_.at("formations")) if(std::to_string(slot.at("value").get<int>())==value)settings_draft_["local"]["formation"]=slot.at("value");
} else if (scope == "global")
settings_draft_["global"][section][key] = value;
else if (scope == "number" || scope == "cell") {
const int index = settings_index(key);
if (engine_mode_ && !engine_settings_editable("cell",key)) return true;
if (index < 0)
return true;
const bool digits = !value.empty() && value.size() <= 2 &&
const bool digits = !value.empty() && value.size() <= (engine_mode_?3u:2u) &&
std::all_of(value.begin(), value.end(), [](char c) {
return c >= '0' && c <= '9';
});
@@ -204,6 +213,7 @@ bool App::settings_change(Rml::Element *target) {
void App::settings_commit() {
if (!settings_dirty() || !settings_valid())
return;
if (engine_mode_) { engine_settings_apply(); return; }
const bool local = !settings_global_only();
if (local &&
(settings_source_ != source_.get() || settings_world_ != world_ ||
@@ -311,17 +321,17 @@ bool App::settings_action(const std::string &action, Rml::Element *target) {
!settings_draft_["global"]["sound"][key].get<bool>();
else if (!settings_global_only() && scope == "cell" &&
settings_index(key) >= 0) {
if (!engine_settings_editable("cell",key)) return true;
auto &value =
settings_draft_["local"]["cells"][size_t(settings_index(key))];
value = value == 1 ? 0 : 1;
} else if (!settings_global_only() && scope == "automation") {
auto &a = settings_draft_["local"]["automation"];
if (key == "all") {
const bool on = !std::all_of(a.begin(), a.end(),
[](const Json &v) { return v == true; });
for (auto &[k, v] : a.items())
v = on;
} else if (a.contains(key))
bool all=true;
for(const auto &[k,v]:a.items()) if(engine_settings_editable("automation",k))all=all&&v==true;
for(auto &[k,v]:a.items()) if(engine_settings_editable("automation",k))v=!all;
} else if (a.contains(key) && engine_settings_editable("automation",key))
a[key] = !a[key].get<bool>();
}
settings_notice_.clear();