SP Options Configure: only show dialog if there is at least one active mod with options
This commit is contained in:
parent
8b60904074
commit
4bacb417f2
4 changed files with 39 additions and 11 deletions
|
@ -424,7 +424,10 @@ bool manager::is_modification_active(int index) const
|
|||
return std::find(mods_.begin(), mods_.end(), id) != mods_.end();
|
||||
}
|
||||
|
||||
|
||||
bool manager::is_modification_active(const std::string id) const
|
||||
{
|
||||
return std::find(mods_.begin(), mods_.end(), id) != mods_.end();
|
||||
}
|
||||
|
||||
bool manager::enable_mods_dialog(const std::vector<std::string>& mods,
|
||||
const std::string& requester)
|
||||
|
|
|
@ -137,6 +137,15 @@ public:
|
|||
*/
|
||||
bool is_modification_active(int index) const;
|
||||
|
||||
/**
|
||||
* Tells whether a certain mod is activated.
|
||||
*
|
||||
* @param string the string id of the mod
|
||||
*
|
||||
* @return true if activated, false is not
|
||||
*/
|
||||
bool is_modification_active(const std::string id) const;
|
||||
|
||||
/**
|
||||
* Returns the selected era
|
||||
*
|
||||
|
|
|
@ -130,18 +130,16 @@ bool enter_create_mode(CVideo& video, const config& game_config, saved_game& sta
|
|||
|
||||
bool enter_configure_mode(CVideo& video, const config& game_config, saved_game& state, ng::create_engine& create_eng, bool local_players_only)
|
||||
{
|
||||
gui2::tsp_options_configure dlg(create_eng);
|
||||
|
||||
dlg.show(video);
|
||||
|
||||
if(dlg.get_retval() == gui2::twindow::OK) {
|
||||
create_eng.prepare_for_new_level();
|
||||
create_eng.get_parameters();
|
||||
|
||||
enter_connect_mode(video, game_config, state, local_players_only);
|
||||
if(!gui2::tsp_options_configure::execute(create_eng, video)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return dlg.get_retval() == gui2::twindow::OK;
|
||||
create_eng.prepare_for_new_level();
|
||||
create_eng.get_parameters();
|
||||
|
||||
enter_connect_mode(video, game_config, state, local_players_only);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool enter_connect_mode(CVideo& video, const config& game_config, saved_game& state, bool local_players_only)
|
||||
|
|
|
@ -29,6 +29,24 @@ class tsp_options_configure : public tdialog, private plugin_executor
|
|||
public:
|
||||
explicit tsp_options_configure(ng::create_engine& create_engine);
|
||||
|
||||
/**
|
||||
* Execute function. We only want to show the dialog if there are active mods and
|
||||
* those active mods all have custom options.
|
||||
*/
|
||||
static bool execute(ng::create_engine& create_engine, CVideo& video)
|
||||
{
|
||||
using mod_type = ng::create_engine::extras_metadata_ptr;
|
||||
|
||||
const std::vector<mod_type>& activemods = create_engine.active_mods_data();
|
||||
if(std::none_of(activemods.begin(), activemods.end(), [](mod_type mod) {
|
||||
return (*mod->cfg).has_child("options");
|
||||
})) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return tsp_options_configure(create_engine).show(video);
|
||||
}
|
||||
|
||||
private:
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue