SP: cleaned up code a bit
This commit is contained in:
parent
b1983c2bc3
commit
1ba2b7e823
3 changed files with 24 additions and 26 deletions
|
@ -14,6 +14,10 @@
|
|||
#include "game_initialization/singleplayer.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
#include "game_initialization/configure_engine.hpp"
|
||||
#include "game_initialization/connect_engine.hpp"
|
||||
#include "game_initialization/create_engine.hpp"
|
||||
#include "game_launcher.hpp"
|
||||
#include "gui/dialogs/campaign_selection.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#include "gui/dialogs/multiplayer/mp_staging.hpp"
|
||||
|
@ -26,13 +30,10 @@ static lg::log_domain log_engine("engine");
|
|||
|
||||
namespace sp
|
||||
{
|
||||
bool enter_create_mode(saved_game& state, jump_to_campaign_info jump_to_campaign)
|
||||
bool select_campaign(saved_game& state, jump_to_campaign_info jump_to_campaign)
|
||||
{
|
||||
bool configure_canceled = false;
|
||||
|
||||
do {
|
||||
while(true) {
|
||||
ng::create_engine create_eng(state);
|
||||
|
||||
create_eng.set_current_level_type(ng::level::TYPE::SP_CAMPAIGN);
|
||||
|
||||
const std::vector<ng::create_engine::level_ptr> campaigns =
|
||||
|
@ -92,7 +93,7 @@ bool enter_create_mode(saved_game& state, jump_to_campaign_info jump_to_campaign
|
|||
}
|
||||
|
||||
// Canceled difficulty dialog, relaunch the campaign selection dialog
|
||||
return enter_create_mode(state, jump_to_campaign);
|
||||
return select_campaign(state, jump_to_campaign);
|
||||
}
|
||||
|
||||
create_eng.prepare_for_era_and_mods();
|
||||
|
@ -109,14 +110,15 @@ bool enter_create_mode(saved_game& state, jump_to_campaign_info jump_to_campaign
|
|||
return false;
|
||||
}
|
||||
|
||||
configure_canceled = !enter_configure_mode(state, create_eng);
|
||||
|
||||
} while (configure_canceled);
|
||||
if(configure_campaign(state, create_eng)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool enter_configure_mode(saved_game& state, ng::create_engine& create_eng)
|
||||
bool configure_campaign(saved_game& state, ng::create_engine& create_eng)
|
||||
{
|
||||
// We create the config engine here in order to ensure values like use_map_settings are set correctly
|
||||
// TODO: should this be passed to this function instead of created here?
|
||||
|
@ -132,15 +134,10 @@ bool enter_configure_mode(saved_game& state, ng::create_engine& create_eng)
|
|||
create_eng.get_parameters();
|
||||
create_eng.prepare_for_new_level();
|
||||
|
||||
enter_connect_mode(state);
|
||||
ng::connect_engine connect_eng(state, true, nullptr);
|
||||
connect_eng.start_game();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void enter_connect_mode(saved_game& state)
|
||||
{
|
||||
ng::connect_engine connect_eng(state, true, nullptr);
|
||||
connect_eng.start_game();
|
||||
}
|
||||
|
||||
} // end namespace sp
|
||||
|
|
|
@ -14,17 +14,18 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "configure_engine.hpp"
|
||||
#include "connect_engine.hpp"
|
||||
#include "create_engine.hpp"
|
||||
#include "game_launcher.hpp"
|
||||
struct jump_to_campaign_info;
|
||||
class saved_game;
|
||||
|
||||
namespace ng
|
||||
{
|
||||
class create_engine;
|
||||
}
|
||||
|
||||
namespace sp
|
||||
{
|
||||
bool enter_create_mode(saved_game& state, jump_to_campaign_info jump_to);
|
||||
bool select_campaign(saved_game& state, jump_to_campaign_info jump_to);
|
||||
|
||||
bool enter_configure_mode(saved_game& state, ng::create_engine& create_eng);
|
||||
|
||||
void enter_connect_mode(saved_game& state);
|
||||
bool configure_campaign(saved_game& state, ng::create_engine& create_eng);
|
||||
|
||||
} // end namespace sp
|
||||
|
|
|
@ -762,7 +762,7 @@ bool game_launcher::new_campaign()
|
|||
state_.classification().campaign_type = game_classification::CAMPAIGN_TYPE::SCENARIO;
|
||||
play_replay_ = false;
|
||||
|
||||
return sp::enter_create_mode(state_, jump_to_campaign_);
|
||||
return sp::select_campaign(state_, jump_to_campaign_);
|
||||
}
|
||||
|
||||
std::string game_launcher::jump_to_campaign_id() const
|
||||
|
|
Loading…
Add table
Reference in a new issue