MP Create: make use of window exit hook for showing the difficulty dialog
This commit is contained in:
parent
d858c6b739
commit
969018f7df
6 changed files with 11 additions and 23 deletions
|
@ -732,8 +732,7 @@
|
|||
[toggle_panel]
|
||||
id = "game_list_panel"
|
||||
definition = "default"
|
||||
# We don't use return_value_id since we have a custom double click hook that handles
|
||||
# campaign difficulty and closes the dialog itself.
|
||||
return_value_id = "ok"
|
||||
|
||||
[grid]
|
||||
|
||||
|
|
|
@ -378,9 +378,7 @@
|
|||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
[button]
|
||||
# We don't use id = 'ok' since we have a custom double click hook that handles
|
||||
# campaign difficulty and closes the dialog itself.
|
||||
id = "create_game"
|
||||
id = "ok"
|
||||
definition = "default"
|
||||
|
||||
label = _ "Create Game"
|
||||
|
|
|
@ -346,9 +346,7 @@
|
|||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
[button]
|
||||
# We don't use id = 'ok' since we have a custom double click hook that handles
|
||||
# campaign difficulty and closes the dialog itself.
|
||||
id = "create_game"
|
||||
id = "ok"
|
||||
definition = "default"
|
||||
|
||||
label = _ "Create Game"
|
||||
|
|
|
@ -311,9 +311,7 @@
|
|||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
[button]
|
||||
# We don't use id = 'ok' since we have a custom double click hook that handles
|
||||
# campaign difficulty and closes the dialog itself.
|
||||
id = "create_game"
|
||||
id = "ok"
|
||||
definition = "default"
|
||||
|
||||
label = _ "Create Game"
|
||||
|
|
|
@ -132,9 +132,7 @@ void tmp_create_game::pre_show(twindow& window)
|
|||
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),
|
||||
std::bind(&tmp_create_game::dialog_exit_hook, this, std::ref(window)));
|
||||
window.set_exit_hook_ok_only([this](twindow& w)->bool { return dialog_exit_hook(w); });
|
||||
|
||||
//
|
||||
// Set up the options manager. Needs to be done before selecting an initial tab
|
||||
|
@ -511,10 +509,7 @@ void tmp_create_game::display_games_of_type(twindow& window, ng::level::TYPE typ
|
|||
item["label"] = game.get()->name();
|
||||
data.emplace("game_name", item);
|
||||
|
||||
tgrid* row_grid = &list.add_row(data);
|
||||
|
||||
find_widget<ttoggle_panel>(row_grid, "game_list_panel", false).set_callback_mouse_left_double_click(
|
||||
std::bind(&tmp_create_game::dialog_exit_hook, this, std::ref(window)));
|
||||
list.add_row(data);
|
||||
}
|
||||
|
||||
// Recalculate which rows should be visisble
|
||||
|
@ -573,7 +568,7 @@ void tmp_create_game::load_game_callback(twindow& window)
|
|||
|
||||
create_engine_.prepare_for_saved_game();
|
||||
|
||||
dialog_exit_hook(window);
|
||||
window.set_retval(twindow::OK);
|
||||
} catch(config::error&) {}
|
||||
}
|
||||
|
||||
|
@ -701,16 +696,16 @@ void tmp_create_game::update_map_settings(twindow& window)
|
|||
}
|
||||
}
|
||||
|
||||
void tmp_create_game::dialog_exit_hook(twindow& window) {
|
||||
bool tmp_create_game::dialog_exit_hook(twindow&) {
|
||||
if(create_engine_.current_level_type() == ng::level::TYPE::CAMPAIGN ||
|
||||
create_engine_.current_level_type() == ng::level::TYPE::SP_CAMPAIGN) {
|
||||
|
||||
if(create_engine_.select_campaign_difficulty() == "CANCEL") {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
window.set_retval(twindow::OK);
|
||||
return true;
|
||||
}
|
||||
|
||||
void tmp_create_game::post_show(twindow& window)
|
||||
|
|
|
@ -122,7 +122,7 @@ private:
|
|||
void update_details(twindow& window);
|
||||
void update_map_settings(twindow& window);
|
||||
|
||||
void dialog_exit_hook(twindow& window);
|
||||
bool dialog_exit_hook(twindow&);
|
||||
|
||||
int convert_to_game_filtered_index(const int initial_index);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue