The Battle for Wesnoth  1.19.5+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 type) const
 
std::vector< level_ptrget_levels_by_type (level_type::type type) const
 
std::vector< std::size_t > get_filtered_level_indices (level_type::type type) const
 
levelcurrent_level () const
 
const extras_metadatacurrent_era () const
 
void set_current_level_type (const level_type::type type)
 
level_type::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 (const std::string &id, bool force=false)
 
bool generator_assigned () const
 
bool generator_has_settings () const
 
void generator_user_config ()
 
std::pair< level_type::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::managerdependency_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
 
create_engineoperator= (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::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, 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::managerdependency_manager_
 
std::unique_ptr< map_generatorgenerator_
 
std::string selected_campaign_difficulty_
 
const game_config_viewgame_config_
 Reference to the main game config. More...
 

Detailed Description

Definition at line 266 of file create_engine.hpp.

Member Typedef Documentation

◆ campaign_ptr

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

Definition at line 287 of file create_engine.hpp.

◆ extras_metadata_ptr

Definition at line 281 of file create_engine.hpp.

◆ level_ptr

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

Definition at line 283 of file create_engine.hpp.

◆ random_map_ptr

Definition at line 286 of file create_engine.hpp.

◆ scenario_ptr

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

Definition at line 284 of file create_engine.hpp.

◆ user_map_ptr

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

Definition at line 285 of file create_engine.hpp.

Member Enumeration Documentation

◆ MP_EXTRA

Enumerator
ERA 
MOD 

Definition at line 271 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 492 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 797 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

Definition at line 360 of file create_engine.hpp.

References current_era_index_.

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

◆ 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 349 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::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 592 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::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 560 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 565 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 570 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  type) const

◆ get_levels_by_type()

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

Definition at line 814 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  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 313 of file create_engine.hpp.

References selected_campaign_difficulty_.

◆ 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 351 of file create_engine.hpp.

References current_level_type_.

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 322 of file create_engine.hpp.

References level_name_filter_.

◆ map_level_index()

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

◆ operator=()

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

◆ player_num_filter()

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

Definition at line 327 of file create_engine.hpp.

References player_count_filter_.

◆ 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 498 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 421 of file create_engine.cpp.

References current_level(), d, data, PLAIN_LOG, 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().

◆ 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  type)
inline

◆ toggle_mod()

bool ng::create_engine::toggle_mod ( const std::string &  id,
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 407 of file create_engine.hpp.

Referenced by current_level(), and set_current_level().

◆ current_level_type_

level_type::type ng::create_engine::current_level_type_
private

◆ 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 game_config_view& ng::create_engine::game_config_
private

Reference to the main game config.

Definition at line 459 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

◆ mods_

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

Definition at line 447 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 412 of file create_engine.hpp.

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

◆ selected_campaign_difficulty_

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

◆ state_

saved_game& ng::create_engine::state_
private

◆ type_map_

std::map<level_type::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 443 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 444 of file create_engine.hpp.

Referenced by create_engine(), and init_all_levels().


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