Bind tactics and training drafts to confirmed engine commits (by Codex)
This commit is contained in:
1 parent
7d3b3f1101
commit
f75e0f8e49
18 files changed
+398
-43
No files matched your search
@@ -17,16 +17,15 @@ void App::engine_poll() {
|
||||
engine_link_ = std::move(result.connection); engine_data_ = std::move(result.bundle);
|
||||
engine_response_ = std::move(result.response);
|
||||
if (engine_response_.value("messageType", "") == "command_result") {
|
||||
engine_dirty_ = true;
|
||||
const auto changed = engine_response_.value("changedReadKinds", Json::array());
|
||||
const bool lineup_changed = std::find(changed.begin(), changed.end(), Json("lineup")) != changed.end();
|
||||
engine_notice_ = lineup_changed ? "Aufstellung übernommen · Änderungen noch nicht gespeichert." : "Trainingslager gebucht · Änderungen noch nicht gespeichert.";
|
||||
engine_dirty_ = engine_base_dirty_ || engine_response_.at("newRevision") != engine_response_.at("previousRevision");
|
||||
engine_notice_ = engine_text(engine_response_.at("feedback")) + (engine_dirty_ ? " · Änderungen noch nicht gespeichert." : "");
|
||||
} else if (engine_response_.value("messageType", "") == "error") {
|
||||
engine_dirty_ = engine_base_dirty_;
|
||||
engine_notice_ = "Änderung abgewiesen: " + engine_response_.value("code", "unknown_error");
|
||||
} else if (engine_response_.value("messageType", "") == "saved") {
|
||||
engine_dirty_ = false; engine_notice_ = "Spielstand als neue OBS-Datei gespeichert.";
|
||||
} else engine_notice_ = "Spielstand geladen · Weitere Menüs werden schrittweise angebunden.";
|
||||
engine_sports_reset();
|
||||
const auto &f = engine_data_.at("camps").at("data").at("focus");
|
||||
engine_focus_ = {{"condition", f.at("condition")}, {"technique", f.at("technique")}, {"play", f.at("play")}};
|
||||
if (engine_camp_.empty() && !engine_data_.at("camps").at("data").at("camps").empty())
|
||||
@@ -37,7 +36,9 @@ void App::engine_poll() {
|
||||
void App::engine_frame() {
|
||||
engine_poll();
|
||||
if (needs_render_) engine_render();
|
||||
engine_sports_update();
|
||||
render_popup(); context_->Update();
|
||||
if (center_selects(*doc_)) context_->Update();
|
||||
if (menu_ == "lineup" && lineup_roster_scroll_) {
|
||||
if (auto *roster = element("lineup-roster-scroll")) roster->SetScrollTop(*lineup_roster_scroll_);
|
||||
lineup_roster_scroll_.reset();
|
||||
@@ -71,6 +72,7 @@ void App::engine_event(Rml::Event &event) {
|
||||
const auto type = event.GetType(); auto *target = event.GetTargetElement();
|
||||
if (type == "keydown") keyboard_navigation_ = true;
|
||||
if (type == "mousedown") keyboard_navigation_ = false;
|
||||
if (engine_sports_event(event)) return;
|
||||
Rml::ElementFormControl *range = nullptr;
|
||||
for (auto *node = target; node && node != doc_; node = node->GetParentNode())
|
||||
if (node->GetId().starts_with("camp-focus-") && !node->HasAttribute("disabled")) {
|
||||
@@ -96,7 +98,7 @@ void App::engine_event(Rml::Event &event) {
|
||||
if (type == "keydown" && event.GetParameter<int>("key_identifier", 0) == Rml::Input::KI_ESCAPE) {
|
||||
if (!popup_.empty()) { popup_.clear(); confirm_ = {}; dirty_ = true; }
|
||||
else if (!engine_busy_ && !engine_player_.empty()) { focus_after_render_ = "lineup-detail-" + engine_player_ + "-0"; engine_player_.clear(); refresh(); }
|
||||
else if (!engine_busy_ && !menu_.empty()) { menu_.clear(); refresh(); }
|
||||
else if (!engine_busy_ && !menu_.empty()) { if (menu_ == "training" || menu_ == "tactics") engine_sports_reset(); menu_.clear(); refresh(); }
|
||||
else engine_quit();
|
||||
event.StopImmediatePropagation(); return;
|
||||
}
|
||||
@@ -132,9 +134,11 @@ void App::engine_event(Rml::Event &event) {
|
||||
if (action == "popup-confirm") { auto callback = std::move(confirm_); popup_.clear(); dirty_ = true; if (callback) callback(); }
|
||||
return;
|
||||
}
|
||||
if (engine_sports_action(action, id, node)) return;
|
||||
if (engine_lineup_action(action, id, node)) return;
|
||||
if (action == "close") { menu_.clear(); refresh(); }
|
||||
else if (action == "engine-open" && id == "save") engine_save();
|
||||
else if (action == "engine-open" && (id == "training" || id == "tactics")) { engine_sports_reset(); menu_ = id; refresh(); }
|
||||
else if (action == "engine-open" && id == "lineup") { menu_ = "lineup"; lineup_selected_.clear(); lineup_reset_scroll_ = true; refresh(); }
|
||||
else if (action == "engine-open" && id == "camp") { menu_ = "camp"; refresh(); }
|
||||
else if (action == "camp-region") { selections_["camp-region"] = id; refresh(); }
|
||||
@@ -153,5 +157,5 @@ void App::engine_event(Rml::Event &event) {
|
||||
}
|
||||
Json App::engine_snapshot() const {
|
||||
return {{"mode", engine_mode_}, {"busy", engine_busy_}, {"dirty", engine_dirty_}, {"fresh", engine_fresh_}, {"bundle", engine_data_},
|
||||
{"response", engine_response_}, {"player_profile", engine_player_}, {"lineup_selected", lineup_selected_}, {"focus", engine_focus_}, {"selected_camp", engine_camp_}, {"notice", engine_notice_}};
|
||||
{"response", engine_response_}, {"training_draft", engine_training_draft_}, {"tactics_draft", engine_tactics_draft_}, {"player_profile", engine_player_}, {"lineup_selected", lineup_selected_}, {"focus", engine_focus_}, {"selected_camp", engine_camp_}, {"notice", engine_notice_}};
|
||||
}
|
||||
Reference in new issue
Block a user