The Battle for Wesnoth  1.15.0-dev
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ng::create_engine Class Reference

#include <create_engine.hpp>

Classes

struct  extras_metadata
 
struct  type_list
 

Public Types

enum  MP_EXTRA { ERA, MOD }
 
typedef std::shared_ptr< extras_metadataextras_metadata_ptr
 
typedef std::shared_ptr< levellevel_ptr
 
typedef std::shared_ptr< scenarioscenario_ptr
 
typedef std::shared_ptr< user_mapuser_map_ptr
 
typedef std::shared_ptr< random_maprandom_map_ptr
 
typedef std::shared_ptr< campaigncampaign_ptr
 

Public Member Functions

 create_engine (saved_game &state)
 
void init_generated_level_data ()
 
void prepare_for_new_level ()
 
void prepare_for_era_and_mods ()
 
void prepare_for_scenario ()
 
void prepare_for_campaign (const std::string &difficulty="")
 
void prepare_for_saved_game ()
 
void prepare_for_other ()
 
std::string select_campaign_difficulty (int set_value=-1)
 select_campaign_difficulty More...
 
std::string get_selected_campaign_difficulty () const
 
void apply_level_filter (const std::string &name)
 
void apply_level_filter (int players)
 
void reset_level_filters ()
 
const std::string & level_name_filter () const
 
int player_num_filter () const
 
std::vector< level_ptrget_levels_by_type_unfiltered (level::TYPE type) const
 
std::vector< level_ptrget_levels_by_type (level::TYPE type) const
 
std::vector< std::size_t > get_filtered_level_indices (level::TYPE type) const
 
levelcurrent_level () const
 
const extras_metadatacurrent_era () const
 
void set_current_level_type (const level::TYPE type)
 
level::TYPE current_level_type () const
 
bool is_campaign () const
 Wrapper to simplify the is-type-campaign-or-sp-campaign check. More...
 
void set_current_level (const std::size_t index)
 
void set_current_era_index (const std::size_t index, bool force=false)
 
std::size_t current_era_index () const
 
const configcurent_era_cfg () const
 
const std::vector< extras_metadata_ptr > & get_const_extras_by_type (const MP_EXTRA extra_type) const
 
std::vector< extras_metadata_ptr > & get_extras_by_type (const MP_EXTRA extra_type)
 
bool toggle_mod (int index, bool force=false)
 
bool generator_assigned () const
 
bool generator_has_settings () const
 
void generator_user_config ()
 
std::pair< level::TYPE, int > find_level_by_id (const std::string &id) const
 
int find_extra_by_id (const MP_EXTRA extra_type, const std::string &id) const
 
const depcheck::manager & dependency_manager () const
 
void init_active_mods ()
 
std::vector< std::string > & active_mods ()
 
std::vector< extras_metadata_ptractive_mods_data ()
 
const mp_game_settingsget_parameters ()
 
saved_gameget_state ()
 
bool current_level_has_side_data ()
 Returns true if the current level has one or more [side] tags. More...
 

Private Member Functions

 create_engine (const create_engine &)=delete
 
void operator= (const create_engine &)=delete
 
void init_all_levels ()
 
void init_extras (const MP_EXTRA extra_type)
 
void apply_level_filters ()
 
std::size_t map_level_index (std::size_t index) const
 

Private Attributes

level::TYPE current_level_type_
 
std::size_t current_level_index_
 
std::size_t current_era_index_
 
std::string level_name_filter_
 
int player_count_filter_
 
std::map< level::TYPE, type_listtype_map_
 
std::vector< std::string > user_map_names_
 
std::vector< std::string > user_scenario_names_
 
std::vector< extras_metadata_ptreras_
 
std::vector< extras_metadata_ptrmods_
 
saved_gamestate_
 
std::unique_ptr< depcheck::manager > dependency_manager_
 
std::unique_ptr< map_generatorgenerator_
 
std::string selected_campaign_difficulty_
 
const configgame_config_
 Reference to the main game config. More...
 

Detailed Description

Definition at line 273 of file create_engine.hpp.

Member Typedef Documentation

◆ campaign_ptr

typedef std::shared_ptr<campaign> ng::create_engine::campaign_ptr

Definition at line 294 of file create_engine.hpp.

◆ extras_metadata_ptr

Definition at line 288 of file create_engine.hpp.

◆ level_ptr

typedef std::shared_ptr<level> ng::create_engine::level_ptr

Definition at line 290 of file create_engine.hpp.

◆ random_map_ptr

Definition at line 293 of file create_engine.hpp.

◆ scenario_ptr

typedef std::shared_ptr<scenario> ng::create_engine::scenario_ptr

Definition at line 291 of file create_engine.hpp.

◆ user_map_ptr

typedef std::shared_ptr<user_map> ng::create_engine::user_map_ptr

Definition at line 292 of file create_engine.hpp.

Member Enumeration Documentation

◆ MP_EXTRA

Enumerator
ERA 
MOD 

Definition at line 278 of file create_engine.hpp.

Constructor & Destructor Documentation

◆ create_engine() [1/2]

ng::create_engine::create_engine ( saved_game state)
explicit

◆ create_engine() [2/2]

ng::create_engine::create_engine ( const create_engine )
privatedelete

Member Function Documentation

◆ active_mods()

std::vector< std::string > & ng::create_engine::active_mods ( )

◆ active_mods_data()

std::vector< create_engine::extras_metadata_ptr > ng::create_engine::active_mods_data ( )

◆ apply_level_filter() [1/2]

void ng::create_engine::apply_level_filter ( const std::string &  name)

◆ apply_level_filter() [2/2]

void ng::create_engine::apply_level_filter ( int  players)

Definition at line 489 of file create_engine.cpp.

References apply_level_filters(), and player_count_filter_.

◆ apply_level_filters()

void ng::create_engine::apply_level_filters ( )
private

Definition at line 784 of file create_engine.cpp.

References level_name_filter_, player_count_filter_, and type_map_.

Referenced by apply_level_filter().

◆ curent_era_cfg()

const config & ng::create_engine::curent_era_cfg ( ) const

◆ current_era()

const create_engine::extras_metadata & ng::create_engine::current_era ( ) const

◆ current_era_index()

std::size_t ng::create_engine::current_era_index ( ) const
inline

◆ current_level()

level & ng::create_engine::current_level ( ) const

◆ current_level_has_side_data()

bool ng::create_engine::current_level_has_side_data ( )

Returns true if the current level has one or more [side] tags.

Definition at line 348 of file create_engine.cpp.

References current_level(), ng::level::data(), config::has_child(), and is_campaign().

Referenced by gui2::dialogs::mp_create_game::dialog_exit_hook().

◆ current_level_type()

level::TYPE ng::create_engine::current_level_type ( ) const
inline

◆ dependency_manager()

const depcheck::manager& ng::create_engine::dependency_manager ( ) const
inline

◆ find_extra_by_id()

int ng::create_engine::find_extra_by_id ( const MP_EXTRA  extra_type,
const std::string &  id 
) const

Definition at line 589 of file create_engine.cpp.

References get_const_extras_by_type(), and i.

Referenced by gui2::dialogs::mp_create_game::pre_show().

◆ find_level_by_id()

std::pair< level::TYPE, int > ng::create_engine::find_level_by_id ( const std::string &  id) const

◆ generator_assigned()

bool ng::create_engine::generator_assigned ( ) const

Definition at line 557 of file create_engine.cpp.

References generator_.

Referenced by gui2::dialogs::mp_create_game::update_details().

◆ generator_has_settings()

bool ng::create_engine::generator_has_settings ( ) const

Definition at line 562 of file create_engine.cpp.

References generator_.

Referenced by gui2::dialogs::mp_create_game::update_details().

◆ generator_user_config()

void ng::create_engine::generator_user_config ( )

Definition at line 567 of file create_engine.cpp.

References generator_.

Referenced by gui2::dialogs::mp_create_game::show_generator_settings().

◆ get_const_extras_by_type()

const std::vector< create_engine::extras_metadata_ptr > & ng::create_engine::get_const_extras_by_type ( const MP_EXTRA  extra_type) const

◆ get_extras_by_type()

std::vector< create_engine::extras_metadata_ptr > & ng::create_engine::get_extras_by_type ( const MP_EXTRA  extra_type)

◆ get_filtered_level_indices()

std::vector< std::size_t > ng::create_engine::get_filtered_level_indices ( level::TYPE  type) const

◆ get_levels_by_type()

std::vector< create_engine::level_ptr > ng::create_engine::get_levels_by_type ( level::TYPE  type) const

Definition at line 801 of file create_engine.cpp.

References type_map_.

◆ get_levels_by_type_unfiltered()

std::vector< create_engine::level_ptr > ng::create_engine::get_levels_by_type_unfiltered ( level::TYPE  type) const

◆ get_parameters()

const mp_game_settings & ng::create_engine::get_parameters ( )

◆ get_selected_campaign_difficulty()

std::string ng::create_engine::get_selected_campaign_difficulty ( ) const
inline

Definition at line 320 of file create_engine.hpp.

References ng::level::name().

◆ get_state()

saved_game & ng::create_engine::get_state ( )

◆ init_active_mods()

void ng::create_engine::init_active_mods ( )

◆ init_all_levels()

void ng::create_engine::init_all_levels ( )
private

◆ init_extras()

void ng::create_engine::init_extras ( const MP_EXTRA  extra_type)
private

◆ init_generated_level_data()

void ng::create_engine::init_generated_level_data ( )

◆ is_campaign()

bool ng::create_engine::is_campaign ( ) const
inline

Wrapper to simplify the is-type-campaign-or-sp-campaign check.

Definition at line 358 of file create_engine.hpp.

References utf8::index().

Referenced by current_level_has_side_data(), gui2::dialogs::mp_create_game::dialog_exit_hook(), and gui2::dialogs::mp_options_helper::update_game_options().

◆ level_name_filter()

const std::string& ng::create_engine::level_name_filter ( ) const
inline

Definition at line 329 of file create_engine.hpp.

◆ map_level_index()

std::size_t ng::create_engine::map_level_index ( std::size_t  index) const
private

◆ operator=()

void ng::create_engine::operator= ( const create_engine )
privatedelete

◆ player_num_filter()

int ng::create_engine::player_num_filter ( ) const
inline

Definition at line 334 of file create_engine.hpp.

◆ prepare_for_campaign()

void ng::create_engine::prepare_for_campaign ( const std::string &  difficulty = "")

◆ prepare_for_era_and_mods()

void ng::create_engine::prepare_for_era_and_mods ( )

◆ prepare_for_new_level()

void ng::create_engine::prepare_for_new_level ( )

◆ prepare_for_other()

void ng::create_engine::prepare_for_other ( )

◆ prepare_for_saved_game()

void ng::create_engine::prepare_for_saved_game ( )

◆ prepare_for_scenario()

void ng::create_engine::prepare_for_scenario ( )

◆ reset_level_filters()

void ng::create_engine::reset_level_filters ( )

Definition at line 495 of file create_engine.cpp.

References level_name_filter_, and type_map_.

Referenced by create_engine().

◆ select_campaign_difficulty()

std::string ng::create_engine::select_campaign_difficulty ( int  set_value = -1)

select_campaign_difficulty

Launches difficulty selection gui and returns selected difficulty name.

The gui can be bypassed by supplying a number from 1 to the number of difficulties available, corresponding to a choice of difficulty. This is useful for specifying difficulty via command line.

Parameters
set_valuePreselected difficulty number. The default -1 launches the gui.
Returns
Selected difficulty. Returns "FAIL" if set_value is invalid, and "CANCEL" if the gui is canceled.

Definition at line 418 of file create_engine.cpp.

References current_level(), d, selected_campaign_difficulty_, gui2::dialogs::campaign_difficulty::selected_difficulty(), and gui2::dialogs::modal_dialog::show().

Referenced by gui2::dialogs::mp_create_game::dialog_exit_hook(), and sp::enter_create_mode().

◆ set_current_era_index()

void ng::create_engine::set_current_era_index ( const std::size_t  index,
bool  force = false 
)

◆ set_current_level()

void ng::create_engine::set_current_level ( const std::size_t  index)

◆ set_current_level_type()

void ng::create_engine::set_current_level_type ( const level::TYPE  type)
inline

◆ toggle_mod()

bool ng::create_engine::toggle_mod ( int  index,
bool  force = false 
)

Member Data Documentation

◆ current_era_index_

std::size_t ng::create_engine::current_era_index_
private

◆ current_level_index_

std::size_t ng::create_engine::current_level_index_
private

Definition at line 414 of file create_engine.hpp.

Referenced by current_level(), and set_current_level().

◆ current_level_type_

level::TYPE ng::create_engine::current_level_type_
private

Definition at line 413 of file create_engine.hpp.

Referenced by current_level(), and set_current_level().

◆ dependency_manager_

std::unique_ptr<depcheck::manager> ng::create_engine::dependency_manager_
private

◆ eras_

std::vector<extras_metadata_ptr> ng::create_engine::eras_
private

◆ game_config_

const config& ng::create_engine::game_config_
private

Reference to the main game config.

Definition at line 466 of file create_engine.hpp.

Referenced by create_engine(), init_all_levels(), init_extras(), and prepare_for_era_and_mods().

◆ generator_

std::unique_ptr<map_generator> ng::create_engine::generator_
private

◆ level_name_filter_

std::string ng::create_engine::level_name_filter_
private

Definition at line 418 of file create_engine.hpp.

Referenced by apply_level_filter(), apply_level_filters(), and reset_level_filters().

◆ mods_

std::vector<extras_metadata_ptr> ng::create_engine::mods_
private

Definition at line 454 of file create_engine.hpp.

Referenced by get_const_extras_by_type(), and get_extras_by_type().

◆ player_count_filter_

int ng::create_engine::player_count_filter_
private

Definition at line 419 of file create_engine.hpp.

Referenced by apply_level_filter(), and apply_level_filters().

◆ selected_campaign_difficulty_

std::string ng::create_engine::selected_campaign_difficulty_
private

Definition at line 463 of file create_engine.hpp.

Referenced by prepare_for_campaign(), and select_campaign_difficulty().

◆ state_

saved_game& ng::create_engine::state_
private

◆ type_map_

std::map<level::TYPE, type_list> ng::create_engine::type_map_
private

◆ user_map_names_

std::vector<std::string> ng::create_engine::user_map_names_
private

Definition at line 450 of file create_engine.hpp.

Referenced by create_engine(), and init_all_levels().

◆ user_scenario_names_

std::vector<std::string> ng::create_engine::user_scenario_names_
private

Definition at line 451 of file create_engine.hpp.

Referenced by create_engine(), and init_all_levels().


The documentation for this class was generated from the following files: