Create real careers from the native wizard and preserve manager presentation (by Codex)
This commit is contained in:
1 parent
738ecc7a09
commit
ce1535fe2d
38 files changed
+466
-75
No files matched your search
@@ -6,6 +6,38 @@ void App::engine_start(std::string label, std::function<EngineReply()> job, bool
|
||||
engine_operation_ = std::move(label); engine_busy_ = true;
|
||||
engine_job_ = std::async(std::launch::async, std::move(job)); refresh();
|
||||
}
|
||||
void App::engine_accept(EngineReply result) {
|
||||
engine_fresh_ = true;
|
||||
if (result.catalog) { world_ = std::move(result.catalog); bind_world(world_); }
|
||||
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_ = 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_;
|
||||
auto reason = engine_text(engine_response_.value("message", Json()));
|
||||
if (reason.empty() || reason == "—") reason = engine_response_.value("code", "unknown_error");
|
||||
engine_notice_ = "Änderung abgewiesen: " + reason;
|
||||
} else if (engine_response_.value("messageType", "") == "saved") {
|
||||
engine_dirty_ = false; engine_notice_ = "Spielstand als neue OBS-Datei gespeichert.";
|
||||
if(engine_exit_after_save_){engine_exit_after_save_=false;closed_=true;}
|
||||
} else if(engine_response_.value("messageType","")=="created"){engine_dirty_=true;engine_notice_="Neue Partie · Noch nicht gespeichert.";}
|
||||
else engine_notice_ = "Spielstand geladen · Weitere Menüs werden schrittweise angebunden.";
|
||||
if (engine_response_.value("messageType", "") == "command_result") { advertising_selected_ = -1; advertising_offer_ = 0; }
|
||||
engine_credit_ = engine_data_.value("credit", Json()); engine_credit_edits_ = Json::array();
|
||||
engine_reports_sync();
|
||||
engine_almanac_sync();
|
||||
engine_ticket_bind();
|
||||
engine_contracts_poll();
|
||||
engine_calendar_sync();
|
||||
engine_friendly_sync();
|
||||
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())
|
||||
engine_camp_ = engine_data_.at("camps").at("data").at("camps").front().at("id");
|
||||
}
|
||||
void App::engine_poll() {
|
||||
if (!engine_busy_ || engine_job_.wait_for(std::chrono::milliseconds(0)) != std::future_status::ready) return;
|
||||
engine_busy_ = false;
|
||||
@@ -37,35 +69,8 @@ void App::engine_poll() {
|
||||
}
|
||||
refresh(); return;
|
||||
}
|
||||
engine_fresh_ = true;
|
||||
if (result.catalog) { world_ = std::move(result.catalog); bind_world(world_); }
|
||||
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_ = 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_;
|
||||
auto reason = engine_text(engine_response_.value("message", Json()));
|
||||
if (reason.empty() || reason == "—") reason = engine_response_.value("code", "unknown_error");
|
||||
engine_notice_ = "Änderung abgewiesen: " + reason;
|
||||
} 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.";
|
||||
if (engine_response_.value("messageType", "") == "command_result") { advertising_selected_ = -1; advertising_offer_ = 0; }
|
||||
engine_credit_ = engine_data_.value("credit", Json()); engine_credit_edits_ = Json::array();
|
||||
engine_reports_sync();
|
||||
engine_almanac_sync();
|
||||
engine_ticket_bind();
|
||||
engine_contracts_poll();
|
||||
engine_calendar_sync();
|
||||
engine_friendly_sync();
|
||||
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())
|
||||
engine_camp_ = engine_data_.at("camps").at("data").at("camps").front().at("id");
|
||||
} catch (const std::exception &e) { engine_notice_ = e.what(); }
|
||||
engine_accept(std::move(result));
|
||||
} catch (const std::exception &e) { engine_notice_ = e.what(); if(engine_exit_after_save_){engine_exit_after_save_=false;message("Der Spielstand konnte nicht gespeichert werden: "+std::string(e.what()));} }
|
||||
refresh();
|
||||
}
|
||||
void App::engine_frame() {
|
||||
@@ -115,7 +120,7 @@ void App::engine_save() {
|
||||
NFD::Guard guard; NFD::UniquePath chosen;
|
||||
const nfdfilteritem_t filters[] = {{"OpenBMH-Spielstand", "obs"}};
|
||||
const auto result = NFD::SaveDialog(chosen, filters, 1, nullptr, "openbmh-career.obs");
|
||||
if (result == NFD_CANCEL) return;
|
||||
if (result == NFD_CANCEL) {engine_exit_after_save_=false;return;}
|
||||
if (result != NFD_OKAY) throw editor::Error("Die Dateiauswahl konnte nicht geöffnet werden.");
|
||||
output = editor::path(chosen.get());
|
||||
}
|
||||
@@ -124,7 +129,11 @@ void App::engine_save() {
|
||||
}
|
||||
void App::engine_quit() {
|
||||
if (engine_busy_) { engine_notice_ = "Bitte den laufenden Vorgang abwarten."; dirty_ = true; return; }
|
||||
if (engine_dirty_) confirmation("Ungespeicherte Änderungen verwerfen und beenden? Über die Diskette kannst du zuvor eine neue OBS-Datei speichern.", [this] { closed_ = true; });
|
||||
if (engine_dirty_) {
|
||||
confirmation("Die Partie enthält ungespeicherte Änderungen. Vor dem Beenden speichern?",[this]{closed_=true;});
|
||||
popup_accept_="Ohne Speichern beenden";
|
||||
popup_extra_=btn("engine-save-exit","Speichern und beenden","primary","id=\"engine-save-exit\"");
|
||||
}
|
||||
else closed_ = true;
|
||||
}
|
||||
void App::engine_event(Rml::Event &event) {
|
||||
@@ -138,6 +147,13 @@ void App::engine_event(Rml::Event &event) {
|
||||
if (!engine_busy_ && bank_event(event)) return;
|
||||
if (!engine_busy_ && advertising_event(event)) return;
|
||||
if (!engine_busy_ && popup_.empty() && contracts_event(event)) return;
|
||||
if(engine_opening_active()&&popup_.empty()) {
|
||||
if(type=="keydown") {const auto key=Rml::Input::KeyIdentifier(event.GetParameter<int>("key_identifier",0));
|
||||
if(key==Rml::Input::KI_TAB){Rml::ElementList nodes;doc_->QuerySelectorAll(nodes,".opening-actions button");std::erase_if(nodes,[](auto *n){return n->HasAttribute("disabled");});if(!nodes.empty()){const auto it=std::find(nodes.begin(),nodes.end(),context_->GetFocusElement());const int i=it==nodes.end()?-1:int(it-nodes.begin()),n=int(nodes.size());nodes[size_t((i+n+(event.GetParameter<int>("shift_key",0)?-1:1))%n)]->Focus(true);}event.StopImmediatePropagation();return;}
|
||||
if(key==Rml::Input::KI_RETURN||key==Rml::Input::KI_SPACE){for(auto *n=target;n&&n!=doc_;n=n->GetParentNode())if(n->GetTagName()=="button"&&!n->HasAttribute("disabled")){n->DispatchEvent("click",{});break;}}}
|
||||
if(type=="click")for(auto *n=target;n&&n!=doc_;n=n->GetParentNode())if(n->HasAttribute("data-action")){opening_action(n->GetAttribute<Rml::String>("data-action",""),n);break;}
|
||||
event.StopImmediatePropagation();return;
|
||||
}
|
||||
if (engine_reports_event(event)) return;
|
||||
if(!engine_busy_&&popup_.empty()&&rankings_event(event))return;
|
||||
if (!engine_busy_ && popup_.empty() && engine_friendly_event(event)) return;
|
||||
@@ -218,6 +234,7 @@ void App::engine_event(Rml::Event &event) {
|
||||
const auto action = node->GetAttribute<Rml::String>("data-action", ""), id = node->GetAttribute<Rml::String>("data-id", "");
|
||||
if (!popup_.empty()) {
|
||||
if (action == "popup-close") { popup_.clear(); confirm_ = {}; dirty_ = true; }
|
||||
if(action=="engine-save-exit"){reset_popup();popup_.clear();engine_exit_after_save_=true;try{engine_save();}catch(const std::exception &e){engine_exit_after_save_=false;message(e.what());}return;}
|
||||
if (action == "popup-confirm") { auto callback = std::move(confirm_); popup_.clear(); dirty_ = true; if (callback) callback(); }
|
||||
return;
|
||||
}
|
||||
@@ -268,6 +285,6 @@ 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_}, {"rankings_read",engine_rankings_read_},{"rankings_state",engine_rankings_state_},{"fairplay_read",engine_fairplay_read_},{"other_index",engine_other_index_},{"other_read",engine_other_read_},{"fixtures_read",engine_fixtures_read_},{"reports_state",engine_reports_state_},{"reports_index",engine_reports_index_},{"reports_read",engine_reports_read_},{"reports_roster",engine_reports_roster_},{"almanac_cache",engine_almanac_cache_}, {"almanac_context",engine_almanac_context_}, {"friendly_quote", engine_friendly_read_}, {"friendly_league", engine_friendly_league_}, {"friendly_opponent", engine_friendly_opponent_}, {"friendly_date", engine_friendly_date_}, {"friendly_home", engine_friendly_home_}, {"friendly_stage", engine_friendly_stage_}, {"friendly_month", engine_friendly_month_}, {"calendar_day", engine_calendar_day_}, {"move_id", engine_move_id_}, {"credit_preview", engine_credit_}, {"credit_edits", engine_credit_edits_}, {"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_}};
|
||||
return {{"mode", engine_mode_}, {"creation_busy",engine_creation_busy_}, {"busy", engine_busy_}, {"dirty", engine_dirty_}, {"fresh", engine_fresh_}, {"bundle", engine_data_},
|
||||
{"response", engine_response_}, {"opening_read",engine_opening_read_},{"opening_state",engine_opening_state_},{"rankings_read",engine_rankings_read_},{"rankings_state",engine_rankings_state_},{"fairplay_read",engine_fairplay_read_},{"other_index",engine_other_index_},{"other_read",engine_other_read_},{"fixtures_read",engine_fixtures_read_},{"reports_state",engine_reports_state_},{"reports_index",engine_reports_index_},{"reports_read",engine_reports_read_},{"reports_roster",engine_reports_roster_},{"almanac_cache",engine_almanac_cache_}, {"almanac_context",engine_almanac_context_}, {"friendly_quote", engine_friendly_read_}, {"friendly_league", engine_friendly_league_}, {"friendly_opponent", engine_friendly_opponent_}, {"friendly_date", engine_friendly_date_}, {"friendly_home", engine_friendly_home_}, {"friendly_stage", engine_friendly_stage_}, {"friendly_month", engine_friendly_month_}, {"calendar_day", engine_calendar_day_}, {"move_id", engine_move_id_}, {"credit_preview", engine_credit_}, {"credit_edits", engine_credit_edits_}, {"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