Bind squad and lineup views to confirmed engine player swaps (by Codex)

This commit is contained in:
Codex committed 2026-10-28 09:01:14 +01:00
1 parent 94dc5ecbc4
commit 7d3b3f1101
15 files changed
+340 -36

No files matched your search

+14 -4
View File
@@ -17,10 +17,13 @@ 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; engine_notice_ = "Trainingslager gebucht · Änderungen noch nicht gespeichert.";
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.";
} else if (engine_response_.value("messageType", "") == "error") {
engine_dirty_ = engine_base_dirty_;
engine_notice_ = "Buchung abgewiesen: " + engine_response_.value("code", "unknown_error");
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.";
@@ -35,6 +38,10 @@ void App::engine_frame() {
engine_poll();
if (needs_render_) engine_render();
render_popup(); context_->Update();
if (menu_ == "lineup" && lineup_roster_scroll_) {
if (auto *roster = element("lineup-roster-scroll")) roster->SetScrollTop(*lineup_roster_scroll_);
lineup_roster_scroll_.reset();
}
if (popup_.empty() && !focus_after_render_.empty()) {
if (auto *node = element(focus_after_render_)) node->Focus(keyboard_navigation_);
focus_after_render_.clear();
@@ -88,12 +95,13 @@ 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 engine_quit();
event.StopImmediatePropagation(); return;
}
if (type == "keydown" && event.GetParameter<int>("key_identifier", 0) == Rml::Input::KI_TAB) {
auto *root = !popup_.empty() ? element("popup") : !menu_.empty() ? doc_->QuerySelector(".window") : element("canvas"); Rml::ElementList controls;
auto *root = !popup_.empty() ? element("popup") : !engine_player_.empty() ? element("engine-player-dialog") : !menu_.empty() ? doc_->QuerySelector(".window") : element("canvas"); Rml::ElementList controls;
if (!root) return;
root->QuerySelectorAll(controls, "button,input");
controls.erase(std::remove_if(controls.begin(), controls.end(), [](auto *node) { return !node->IsVisible(true) || node->HasAttribute("disabled"); }), controls.end());
@@ -124,8 +132,10 @@ 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_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 == "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(); }
else if (action == "camp-select") { engine_camp_ = id; refresh(); }
@@ -143,5 +153,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_}, {"focus", engine_focus_}, {"selected_camp", engine_camp_}, {"notice", engine_notice_}};
{"response", engine_response_}, {"player_profile", engine_player_}, {"lineup_selected", lineup_selected_}, {"focus", engine_focus_}, {"selected_camp", engine_camp_}, {"notice", engine_notice_}};
}