Port statistics and the news tablet to the Modern UI (by Codex)
This commit is contained in:
1 parent
349c416f3a
commit
a45217c362
32 files changed
+2493
-23
No files matched your search
+14
-1
@@ -11,6 +11,8 @@
|
||||
#include "modern/ui/demo_lineup.hpp"
|
||||
#include "modern/ui/demo_transfer.hpp"
|
||||
#include "modern/ui/demo_stadium.hpp"
|
||||
#include "modern/ui/demo_statistics.hpp"
|
||||
#include "modern/ui/demo_news.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
@@ -99,18 +101,27 @@ DemoSource::DemoSource(std::shared_ptr<const Catalog> catalog)
|
||||
throw editor::Error("invalid_demo_squad");
|
||||
if (!migrate_demo_stadium(state_, *catalog_, club))
|
||||
throw editor::Error("invalid_demo_stadium");
|
||||
if (!migrate_demo_news(state_, *catalog_))
|
||||
throw editor::Error("invalid_demo_news");
|
||||
saved_ = state_;
|
||||
}
|
||||
Snapshot DemoSource::snapshot() const { return {revision_, catalog_, state_}; }
|
||||
Json DemoSource::read_almanac(const Json &request) const {
|
||||
return query_demo_almanac(almanac_, request, state_.at("date"));
|
||||
}
|
||||
Json DemoSource::read_statistics(const Json &request) const {
|
||||
return demo_statistics(*catalog_, state_, request);
|
||||
}
|
||||
ActionResult DemoSource::apply(const Action &action) {
|
||||
if (action.revision != revision_)
|
||||
return {false, revision_, "stale_revision"};
|
||||
auto next = state_;
|
||||
try {
|
||||
if (action.kind == "ticket") {
|
||||
if (action.kind == "news") {
|
||||
const auto error = edit_demo_news(next, action.value, *catalog_);
|
||||
if (!error.empty())
|
||||
return {false, revision_, error};
|
||||
} else if (action.kind == "ticket") {
|
||||
if (!action.value.is_number_integer() || action.value < 0 ||
|
||||
action.value > 25)
|
||||
return {false, revision_, "invalid_demo_ticket"};
|
||||
@@ -289,6 +300,8 @@ Json DemoSource::load(const fs::path &file) {
|
||||
throw editor::Error("invalid_demo_squad");
|
||||
if (!migrate_demo_stadium(data, *catalog_, club))
|
||||
throw editor::Error("invalid_demo_stadium");
|
||||
if (!migrate_demo_news(data, *catalog_))
|
||||
throw editor::Error("invalid_demo_news");
|
||||
auto next = data;
|
||||
auto desktop = next.value("desktop", Json::object());
|
||||
if (!migrate_desktop(desktop))
|
||||
|
||||
Reference in new issue
Block a user