Cleaned up usage of MP Create Game and MP Staging

This commit is contained in:
Charles Dang 2020-12-12 01:54:23 +11:00
parent 63b16ad6e1
commit c67e55efed
3 changed files with 10 additions and 20 deletions

View File

@ -516,8 +516,7 @@ void mp_manager::enter_wait_mode(int game_id, bool observe)
return;
}
dlg.show();
dlg_ok = dlg.get_retval() == gui2::retval::OK;
dlg_ok = dlg.show();
}
if(dlg_ok) {
@ -545,11 +544,8 @@ void mp_manager::enter_staging_mode()
bool dlg_ok = false;
{
ng::connect_engine connect_engine(state, true, campaign_info.get());
gui2::dialogs::mp_staging dlg(connect_engine, connection.get());
dlg.show();
dlg_ok = dlg.get_retval() == gui2::retval::OK;
} // end connect_engine, dlg scope
dlg_ok = gui2::dialogs::mp_staging::execute(connect_engine, connection.get());
} // end connect_engine
if(dlg_ok) {
campaign_controller controller(state, game_config_manager::get()->terrain_types());
@ -566,19 +562,7 @@ void mp_manager::enter_create_mode()
{
DBG_MP << "entering create mode" << std::endl;
bool dlg_ok = false;
{
bool local_mode = connection == nullptr;
gui2::dialogs::mp_create_game dlg(*game_config, state, local_mode);
dlg.show();
// The Create Game dialog also has a LOAD_GAME retval besides OK.
// Do a did-not-cancel check here to catch that
dlg_ok = dlg.get_retval() != gui2::retval::CANCEL;
}
if(dlg_ok) {
if(gui2::dialogs::mp_create_game::execute(*game_config, state, connection == nullptr)) {
enter_staging_mode();
} else if(connection) {
connection->send_data(config("refresh_lobby"));

View File

@ -854,6 +854,9 @@ void mp_create_game::post_show(window& window)
if(get_retval() == LOAD_GAME) {
create_engine_.prepare_for_saved_game();
// We don't need the LOAD_GAME retval past this point. For convenience, reset it to OK so we can use the execute wrapper, then exit.
set_retval(retval::OK);
return;
}

View File

@ -41,6 +41,9 @@ class mp_create_game : public modal_dialog, private plugin_executor
public:
mp_create_game(const game_config_view& cfg, saved_game& state, bool local_mode);
/** The execute function. See @ref modal_dialog for more information. */
DEFINE_SIMPLE_EXECUTE_WRAPPER(mp_create_game);
private:
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const override;