mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-12 13:34:34 +00:00
Support for (de)activating one mod at a time.
This commit is contained in:
parent
c0fcc72ff5
commit
fbd4848225
@ -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);
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user