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
@@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
bool App::engine_opening_active() const {
|
||||
return engine_mode_&&engine_opening_state_.is_object()&&engine_opening_state_.at("opening_flow").at("phase")!="done";
|
||||
}
|
||||
void App::engine_create(const std::shared_ptr<const Catalog> &catalog,const Json &managers) {
|
||||
if(engine_creation_busy_||engine_mode_)return;
|
||||
const auto file=catalog->source();const auto setup=start_options_;
|
||||
const uint32_t seed=config_.creation_seed.value_or(uint32_t(SDL_GetPerformanceCounter()));
|
||||
engine_creation_busy_=true;manager_confirm_=false;focus_after_render_.clear();
|
||||
engine_creation_job_=std::async(std::launch::async,[file,setup,managers,seed] {
|
||||
auto link=EngineBridge::create(file,setup,managers,seed);auto loaded=Catalog::open(file);auto bundle=link->snapshot();auto opening=link->read({{"kind","opening"}});const auto state=engine_opening_projection(bundle,opening);
|
||||
if(loaded->manifest().at("id")!=bundle.at("desktop").at("meta").at("worldId"))throw editor::Error("Bildkatalog und Partie gehören nicht zur selben Welt.");
|
||||
for(const auto &id:state.at("opening_flow").at("order"))if(!loaded->find("clubs",id))throw editor::Error("Ein ausgeloster Verein fehlt im Bildkatalog.");
|
||||
for(const auto &ids:state.at("opening_flow").at("entrants"))for(const auto &id:ids)if(!loaded->find("clubs",id))throw editor::Error("Ein Europapokalteilnehmer fehlt im Bildkatalog.");
|
||||
return EngineReply{link,bundle,{{"messageType","created"},{"opening",opening}},loaded};
|
||||
});refresh();
|
||||
}
|
||||
void App::engine_create_poll() {
|
||||
if(!engine_creation_busy_||engine_creation_job_.wait_for(std::chrono::milliseconds(0))!=std::future_status::ready)return;
|
||||
engine_creation_busy_=false;const auto previous=world_;
|
||||
try {
|
||||
auto result=engine_creation_job_.get();validate_engine_desk(result.bundle);auto opening=engine_opening_projection(result.bundle,result.response.at("opening"));
|
||||
engine_mode_=true;engine_accept(std::move(result));engine_opening_read_=engine_response_.at("opening");engine_opening_state_=std::move(opening);source_.reset();entry_catalog_.reset();managers_draft_=Json::array();scene_="engine";menu_.clear();manager_confirm_=manager_success_=false;opening_due_=0;opening_io_blocked_=false;focus_after_render_=engine_opening_active()?(engine_opening_state_.at("opening_flow").at("phase")=="draw"?"opening-play":"opening-next"):"";engine_creation_busy_=false;
|
||||
}catch(const std::exception &e){engine_mode_=false;engine_link_.reset();engine_data_=Json();engine_fresh_=false;world_=previous;if(entry_catalog_)bind_world(entry_catalog_);else bind_world(world_);manager_confirm_=true;message("Die Partie konnte nicht gestartet werden: "+std::string(e.what()));}
|
||||
refresh();
|
||||
}
|
||||
Reference in new issue
Block a user