mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-27 03:36:06 +00:00
small create_engine simplification
This commit is contained in:
parent
2f1c1e3836
commit
fe253d5779
@ -230,7 +230,6 @@ create_engine::create_engine(CVideo& v, saved_game& state)
|
||||
: current_level_type_()
|
||||
, current_level_index_(0)
|
||||
, current_era_index_(0)
|
||||
, current_mod_index_(0)
|
||||
, level_name_filter_()
|
||||
, player_count_filter_(1)
|
||||
, type_map_()
|
||||
@ -519,12 +518,9 @@ level& create_engine::current_level() const
|
||||
return *type_map_.at(current_level_type_.v).games[current_level_index_];
|
||||
}
|
||||
|
||||
const create_engine::extras_metadata& create_engine::current_extra(const MP_EXTRA extra_type) const
|
||||
const create_engine::extras_metadata& create_engine::current_era() const
|
||||
{
|
||||
const size_t index = (extra_type == ERA) ?
|
||||
current_era_index_ : current_mod_index_;
|
||||
|
||||
return *get_const_extras_by_type(extra_type)[index];
|
||||
return *get_const_extras_by_type(ERA)[current_era_index_];
|
||||
}
|
||||
|
||||
void create_engine::set_current_level(const size_t index)
|
||||
@ -556,10 +552,10 @@ void create_engine::set_current_era_index(const size_t index, bool force)
|
||||
dependency_manager_->try_era_by_index(index, force);
|
||||
}
|
||||
|
||||
bool create_engine::toggle_current_mod(bool force)
|
||||
bool create_engine::toggle_mod(int index, bool force)
|
||||
{
|
||||
bool is_active = dependency_manager_->is_modification_active(current_mod_index_);
|
||||
dependency_manager_->try_modification_by_index(current_mod_index_, !is_active, force);
|
||||
bool is_active = dependency_manager_->is_modification_active(index);
|
||||
dependency_manager_->try_modification_by_index(index, !is_active, force);
|
||||
|
||||
state_.mp_settings().active_mods = dependency_manager_->get_modifications();
|
||||
|
||||
|
@ -343,7 +343,7 @@ public:
|
||||
std::vector<size_t> get_filtered_level_indices(level::TYPE type) const;
|
||||
|
||||
level& current_level() const;
|
||||
const extras_metadata& current_extra(const MP_EXTRA extra_type) const;
|
||||
const extras_metadata& current_era() const;
|
||||
|
||||
void set_current_level_type(const level::TYPE type)
|
||||
{
|
||||
@ -358,27 +358,18 @@ public:
|
||||
void set_current_level(const size_t index);
|
||||
|
||||
void set_current_era_index(const size_t index, bool force = false);
|
||||
void set_current_mod_index(const size_t index)
|
||||
{
|
||||
current_mod_index_ = index;
|
||||
}
|
||||
|
||||
size_t current_era_index() const
|
||||
{
|
||||
return current_era_index_;
|
||||
}
|
||||
|
||||
size_t current_mod_index() const
|
||||
{
|
||||
return current_mod_index_;
|
||||
}
|
||||
|
||||
const config& curent_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_current_mod(bool force = false);
|
||||
bool toggle_mod(int index, bool force = false);
|
||||
|
||||
bool generator_assigned() const;
|
||||
bool generator_has_settings() const;
|
||||
@ -418,7 +409,6 @@ private:
|
||||
size_t current_level_index_;
|
||||
|
||||
size_t current_era_index_;
|
||||
size_t current_mod_index_;
|
||||
|
||||
std::string level_name_filter_;
|
||||
int player_count_filter_;
|
||||
|
@ -358,8 +358,7 @@ void campaign_selection::mod_toggled(window& window)
|
||||
|
||||
for(unsigned i = 0; i < mod_states_.size(); i++) {
|
||||
if(mod_states_[i]) {
|
||||
engine_.set_current_mod_index(i);
|
||||
engine_.toggle_current_mod();
|
||||
engine_.toggle_mod(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -515,8 +515,7 @@ void mp_create_game::on_tab_select(window& window)
|
||||
|
||||
void mp_create_game::on_mod_toggle(window& window, const int index)
|
||||
{
|
||||
create_engine_.set_current_mod_index(index);
|
||||
create_engine_.toggle_current_mod();
|
||||
create_engine_.toggle_mod(index);
|
||||
|
||||
sync_with_depcheck(window);
|
||||
|
||||
@ -527,7 +526,7 @@ void mp_create_game::on_era_select(window& window)
|
||||
{
|
||||
create_engine_.set_current_era_index(find_widget<menu_button>(&window, "eras", false).get_value());
|
||||
|
||||
find_widget<menu_button>(&window, "eras", false).set_tooltip(create_engine_.current_extra(ng::create_engine::ERA).description);
|
||||
find_widget<menu_button>(&window, "eras", false).set_tooltip(create_engine_.current_era().description);
|
||||
|
||||
sync_with_depcheck(window);
|
||||
|
||||
@ -812,7 +811,7 @@ void mp_create_game::post_show(window& window)
|
||||
prefs::set_modifications(create_engine_.active_mods());
|
||||
prefs::set_level_type(create_engine_.current_level_type().v);
|
||||
prefs::set_level(create_engine_.current_level().id());
|
||||
prefs::set_era(create_engine_.current_extra(ng::create_engine::ERA).id);
|
||||
prefs::set_era(create_engine_.current_era().id);
|
||||
|
||||
create_engine_.prepare_for_era_and_mods();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user