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
+10
-1
@@ -13,6 +13,7 @@
|
||||
#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/desktop.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
@@ -103,6 +104,8 @@ DemoSource::DemoSource(std::shared_ptr<const Catalog> catalog)
|
||||
throw editor::Error("invalid_demo_stadium");
|
||||
if (!migrate_demo_news(state_, *catalog_))
|
||||
throw editor::Error("invalid_demo_news");
|
||||
if (!migrate_demo_settings(state_))
|
||||
throw editor::Error("invalid_demo_settings");
|
||||
saved_ = state_;
|
||||
}
|
||||
Snapshot DemoSource::snapshot() const { return {revision_, catalog_, state_}; }
|
||||
@@ -117,7 +120,10 @@ ActionResult DemoSource::apply(const Action &action) {
|
||||
return {false, revision_, "stale_revision"};
|
||||
auto next = state_;
|
||||
try {
|
||||
if (action.kind == "news") {
|
||||
if (action.kind == "settings") {
|
||||
const auto error = edit_demo_settings(next, action.value);
|
||||
if (!error.empty()) return {false, revision_, error};
|
||||
} else if (action.kind == "news") {
|
||||
const auto error = edit_demo_news(next, action.value, *catalog_);
|
||||
if (!error.empty())
|
||||
return {false, revision_, error};
|
||||
@@ -231,6 +237,7 @@ ActionResult DemoSource::apply(const Action &action) {
|
||||
} catch (const Json::exception &) {
|
||||
return {false, revision_, "invalid_action"};
|
||||
}
|
||||
sync_demo_settings_training(next);
|
||||
state_ = std::move(next);
|
||||
return {true, ++revision_, {}};
|
||||
}
|
||||
@@ -302,6 +309,8 @@ Json DemoSource::load(const fs::path &file) {
|
||||
throw editor::Error("invalid_demo_stadium");
|
||||
if (!migrate_demo_news(data, *catalog_))
|
||||
throw editor::Error("invalid_demo_news");
|
||||
if (!migrate_demo_settings(data))
|
||||
throw editor::Error("invalid_demo_settings");
|
||||
auto next = data;
|
||||
auto desktop = next.value("desktop", Json::object());
|
||||
if (!migrate_desktop(desktop))
|
||||
|
||||
Reference in new issue
Block a user