MP Create: move options config getter to mp_options_helper
This commit is contained in:
parent
725df26dd2
commit
0498934b38
3 changed files with 21 additions and 11 deletions
|
@ -764,17 +764,7 @@ void tmp_create_game::post_show(twindow& window)
|
|||
// Since we don't have a tfield handling this option, we need to save the value manually
|
||||
prefs::set_random_faction_mode(mp_game_settings::RANDOM_FACTION_MODE::enum_to_string(rfm_types_[selected_rfm_index_]));
|
||||
|
||||
config options;
|
||||
for(const auto& source : options_manager_->get_visible_options()) {
|
||||
config& mod = options.add_child(source.level_type);
|
||||
mod["id"] = source.id;
|
||||
for(const auto& option : options_manager_->get_options_data()[source]) {
|
||||
// TODO: change this to some key=value format as soon as we drop the old mp configure screen.
|
||||
mod.add_child("option", config_of("id", option.first)("value", option.second));
|
||||
}
|
||||
}
|
||||
|
||||
config_engine_->set_options(options);
|
||||
config_engine_->set_options(options_manager_->get_options_config());
|
||||
|
||||
// Set game name
|
||||
const std::string name = find_widget<ttext_box>(&window, "game_name", false).get_value();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "gui/dialogs/multiplayer/mp_options_helper.hpp"
|
||||
|
||||
#include "config_assign.hpp"
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/menu_button.hpp"
|
||||
|
@ -258,4 +259,19 @@ void tmp_options_helper::display_custom_options(ttree_view& tree, std::string&&
|
|||
}
|
||||
}
|
||||
|
||||
const config tmp_options_helper::get_options_config()
|
||||
{
|
||||
config options;
|
||||
for(const auto& source : visible_options_) {
|
||||
config& mod = options.add_child(source.level_type);
|
||||
mod["id"] = source.id;
|
||||
for(const auto& option : options_data_[source]) {
|
||||
// TODO: change this to some key=value format as soon as we drop the old mp configure screen.
|
||||
mod.add_child("option", config_of("id", option.first)("value", option.second));
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include "game_initialization/create_engine.hpp"
|
||||
|
||||
class config;
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
|
@ -31,6 +33,8 @@ public:
|
|||
|
||||
void update_options_list();
|
||||
|
||||
const config get_options_config();
|
||||
|
||||
private:
|
||||
struct option_source {
|
||||
std::string level_type;
|
||||
|
|
Loading…
Add table
Reference in a new issue