Complete Modern season preparation with persistent draw progress (by Codex)
This commit is contained in:
1 parent
967520190d
commit
e81ecf95f2
27 files changed
+1432
-208
No files matched your search
+25
-6
@@ -7,6 +7,7 @@
|
||||
#include "modern/ui/demo_finance.hpp"
|
||||
#include "modern/ui/demo_lineup.hpp"
|
||||
#include "modern/ui/demo_news.hpp"
|
||||
#include "modern/ui/demo_opening.hpp"
|
||||
#include "modern/ui/demo_reports.hpp"
|
||||
#include "modern/ui/demo_settings.hpp"
|
||||
#include "modern/ui/demo_sports.hpp"
|
||||
@@ -226,6 +227,8 @@ DemoSource::DemoSource(std::shared_ptr<const Catalog> catalog)
|
||||
throw editor::Error("invalid_demo_news");
|
||||
if (!migrate_demo_settings(state_))
|
||||
throw editor::Error("invalid_demo_settings");
|
||||
if (!migrate_demo_opening(state_, *catalog_))
|
||||
throw editor::Error("Ungültige Saisonvorbereitung.");
|
||||
saved_ = state_;
|
||||
}
|
||||
Snapshot DemoSource::snapshot() const { return {revision_, catalog_, state_}; }
|
||||
@@ -294,6 +297,7 @@ ActionResult DemoSource::apply(const Action &action) {
|
||||
? "pending"
|
||||
: "complete";
|
||||
next["opening_created"] = false;
|
||||
next["opening_flow"] = make_demo_opening(*catalog_, next, action.value.at("setup").at("league").get<bool>());
|
||||
}
|
||||
} else if (action.kind == "environment" || action.kind == "advertising" ||
|
||||
action.kind == "toto") {
|
||||
@@ -364,12 +368,25 @@ ActionResult DemoSource::apply(const Action &action) {
|
||||
next["camp"]["focus"] = action.value;
|
||||
} else if (action.kind == "camp.remember")
|
||||
next["camp"]["confirmed"] = next["camp"]["selected"];
|
||||
else if (action.kind == "opening") {
|
||||
if (!action.value.is_string())
|
||||
else if (action.kind == "opening.flow") {
|
||||
const auto error = edit_demo_opening(next, action.value, *catalog_);
|
||||
if (!error.empty()) return {false, revision_, error};
|
||||
} else if (action.kind == "opening") {
|
||||
if (!action.value.is_string() ||
|
||||
(action.value.get<std::string>() != "complete" && action.value.get<std::string>() != "pending"))
|
||||
return {false, revision_, "invalid_opening_state"};
|
||||
next["opening"] = action.value;
|
||||
if (action.value == "complete")
|
||||
if (!migrate_demo_opening(next, *catalog_)) return {false, revision_, "Ungültige gespeicherte Saisonvorbereitung."};
|
||||
if (action.value.get<std::string>() == "complete") {
|
||||
// Old callers may finish directly, without stepping the new UI flow.
|
||||
auto &flow = next.at("opening_flow");
|
||||
flow["created"] = true; flow["phase"] = "done";
|
||||
flow["revealed"] = flow.at("order").size(); flow["playing"] = false;
|
||||
next["opening"] = "complete";
|
||||
next["opening_created"] = true;
|
||||
} else {
|
||||
next["opening"] = "pending"; next["opening_created"] = false;
|
||||
next["opening_flow"] = make_demo_opening(*catalog_, next, true);
|
||||
}
|
||||
} else if (action.kind == "preferences") {
|
||||
if (!preferences(action.value))
|
||||
return {false, revision_, "invalid_preferences"};
|
||||
@@ -405,7 +422,7 @@ bool DemoSource::mark_saved(uint64_t expected_revision) {
|
||||
saved_ = state_;
|
||||
return true;
|
||||
}
|
||||
Json DemoSource::load_data(Json data) {
|
||||
Json DemoSource::load_data(Json data, bool saved) {
|
||||
if (data.value("schema", "") != "openbmh-ui-demo@1" ||
|
||||
data.value("world", "") != catalog_->manifest().value("id", ""))
|
||||
throw editor::Error("wrong_demo_world");
|
||||
@@ -471,13 +488,15 @@ Json DemoSource::load_data(Json data) {
|
||||
throw editor::Error("invalid_demo_news");
|
||||
if (!migrate_demo_settings(data))
|
||||
throw editor::Error("invalid_demo_settings");
|
||||
if (!migrate_demo_opening(data, *catalog_))
|
||||
throw editor::Error("Ungültige oder inkonsistente Saisonvorbereitung.");
|
||||
auto next = data;
|
||||
auto desktop = next.value("desktop", Json::object());
|
||||
if (!migrate_desktop(desktop))
|
||||
throw editor::Error("invalid_demo_desktop");
|
||||
next.erase("desktop");
|
||||
state_ = std::move(next);
|
||||
saved_ = state_;
|
||||
if (saved) saved_ = state_;
|
||||
++revision_;
|
||||
return desktop;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user