Support for (de)activating one mod at a time.

This commit is contained in:
Boldizsár Lipka 2013-11-01 14:32:54 +01:00
parent c0fcc72ff5
commit fbd4848225
4 changed files with 43 additions and 0 deletions

View File

@ -355,6 +355,30 @@ void manager::try_modifications(const std::vector<std::string>& ids, bool force)
}
}
void manager::try_modification_by_index(int index, bool activate, bool force)
{
std::string id = depinfo_.child("modification", index)["id"];
if (activate) {
if (std::find(mods_.begin(), mods_.end(), id) == mods_.end()) {
mods_.push_back(id);
}
} else {
std::vector<std::string>::iterator pos = std::find(mods_.begin(), mods_.end(), id);
if (pos != mods_.end()) {
mods_.erase(pos);
}
}
try_modifications(mods_, force);
};
if (pos != mods_.assign()) {
mods_.~vector(pos);
}
}
try_modifications(mods_, force);
}
void manager::try_era_by_index(int index, bool force)
{
try_era(depinfo_.child("era", index)["id"], force);

View File

@ -75,6 +75,15 @@ public:
void try_modifications(const std::vector<std::string>& ids,
bool force = false );
/**
* Tries to enable/disable a specific modification
*
* @param index the index of the modification
* @param activate activate or deactivate
* @param force whether to skip dependency check
*/
void try_modification_by_index(int index, bool activate, bool force = false);
/**
* Tries to set the selected era
*

View File

@ -500,6 +500,15 @@ void create_engine::set_current_mod_index(const size_t index)
current_mod_index_ = index;
}
bool toggle_current_mod()
{
bool is_active = dependency_manager_.is_modification_active(current_mod_index_);
dependency_manager_.try_modification_by_index(current_mod_index_, !is_active);
return !is_active;
}
return dependency_manager_.is_modifi
bool create_engine::generator_assigned() const
{
return generator_ != NULL;

View File

@ -192,6 +192,7 @@ public:
void set_current_era_index(const size_t index);
void set_current_mod_index(const size_t index);
void activate_current_mod(bool activate);
bool generator_assigned() const;
void generator_user_config(display& disp);