MP Create: implement savegame loading via Load Game button
This commit is contained in:
parent
fae6da9ad1
commit
ae7ed76b58
2 changed files with 32 additions and 7 deletions
|
@ -118,6 +118,10 @@ void tmp_create_game::pre_show(twindow& window)
|
|||
find_widget<tbutton>(&window, "random_map_settings", false),
|
||||
std::bind(&tmp_create_game::show_generator_settings, this, std::ref(window)));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "load_game", false),
|
||||
std::bind(&tmp_create_game::load_game_callback, this, std::ref(window)));
|
||||
|
||||
// Custom dialog close hook
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "create_game", false),
|
||||
|
@ -315,6 +319,13 @@ void tmp_create_game::on_era_select(twindow& window)
|
|||
create_engine_.current_extra(ng::create_engine::ERA).description);
|
||||
}
|
||||
|
||||
void tmp_create_game::update_games_list(twindow& window)
|
||||
{
|
||||
const int index = find_widget<tcombobox>(&window, "game_types", false).get_value();
|
||||
|
||||
display_games_of_type(window, level_types_[index].first);
|
||||
}
|
||||
|
||||
void tmp_create_game::display_games_of_type(twindow& window, ng::level::TYPE type)
|
||||
{
|
||||
create_engine_.set_current_level_type(type);
|
||||
|
@ -478,13 +489,6 @@ void tmp_create_game::display_custom_options(ttree_view& tree, std::string&& typ
|
|||
}
|
||||
}
|
||||
|
||||
void tmp_create_game::update_games_list(twindow& window)
|
||||
{
|
||||
const int index = find_widget<tcombobox>(&window, "game_types", false).get_value();
|
||||
|
||||
display_games_of_type(window, level_types_[index].first);
|
||||
}
|
||||
|
||||
void tmp_create_game::update_options_list(twindow& window)
|
||||
{
|
||||
ttree_view& options_tree = find_widget<ttree_view>(&window, "custom_options", false);
|
||||
|
@ -520,6 +524,25 @@ void tmp_create_game::regenerate_random_map(twindow& window)
|
|||
update_details(window);
|
||||
}
|
||||
|
||||
void tmp_create_game::load_game_callback(twindow& window)
|
||||
{
|
||||
try {
|
||||
savegame::loadgame load(window.video(), cfg_, create_engine_.get_state());
|
||||
|
||||
if(!load.load_multiplayer_game()) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if(load.cancel_orders()) {
|
||||
create_engine_.get_state().cancel_orders();
|
||||
}
|
||||
|
||||
create_engine_.prepare_for_saved_game();
|
||||
|
||||
window.set_retval(twindow::OK);
|
||||
} catch(config::error&) {}
|
||||
}
|
||||
|
||||
int tmp_create_game::convert_to_game_filtered_index(const int initial_index)
|
||||
{
|
||||
const std::vector<size_t>& filtered_indices = create_engine_.get_filtered_level_indices(create_engine_.current_level_type());
|
||||
|
|
|
@ -116,6 +116,8 @@ private:
|
|||
|
||||
int convert_to_game_filtered_index(const int initial_index);
|
||||
|
||||
void load_game_callback(twindow& window);
|
||||
|
||||
public:
|
||||
// another map selected
|
||||
void update_details(twindow& window);
|
||||
|
|
Loading…
Add table
Reference in a new issue