Used the return value of modal_dialog::show instead of an explicit retval check when possible

This commit is contained in:
Charles Dang 2018-07-14 16:17:59 +11:00
parent 85e9b40495
commit 637e69f271
6 changed files with 7 additions and 19 deletions

View file

@ -26,7 +26,6 @@
#include "game_data.hpp" //resources::gamedata->phase()
#include "gettext.hpp"
#include "gui/dialogs/unit_advance.hpp"
#include "gui/widgets/retval.hpp" //gui2::retval::OK
#include "log.hpp"
#include "play_controller.hpp" //resources::controller
#include "random.hpp"
@ -78,9 +77,7 @@ namespace
if (previews.size() > 1 || always_display) {
gui2::dialogs::unit_advance dlg(previews, num_real_advances);
dlg.show();
if (dlg.get_retval() == gui2::retval::OK) {
if(dlg.show()) {
return dlg.get_selected_index();
}

View file

@ -685,9 +685,8 @@ void context_manager::generate_map_dialog()
gui2::dialogs::editor_generate_map dialog(map_generators_);
dialog.select_map_generator(last_map_generator_);
dialog.show();
if(dialog.get_retval() == gui2::retval::OK) {
if(dialog.show()) {
std::string map_string;
map_generator* const map_generator = dialog.get_selected_map_generator();
try {

View file

@ -398,8 +398,7 @@ void command_executor::show_menu(const std::vector<config>& items_arg, int xloc,
{
SDL_Rect pos {xloc, yloc, 1, 1};
gui2::dialogs::drop_down_menu mmenu(pos, items, -1, true, false); // TODO: last value should be variable
mmenu.show();
if(mmenu.get_retval() == gui2::retval::OK) {
if(mmenu.show()) {
res = mmenu.selected_item();
}
} // This will kill the dialog.

View file

@ -284,9 +284,7 @@ void menu_handler::recruit(int side_num, const map_location& last_hex)
gui2::dialogs::unit_recruit dlg(sample_units, board().get_team(side_num));
dlg.show();
if(dlg.get_retval() == gui2::retval::OK) {
if(dlg.show()) {
map_location recruit_hex = last_hex;
do_recruit(sample_units[dlg.get_selected_index()]->id(), side_num, recruit_hex);
}
@ -382,9 +380,7 @@ void menu_handler::recall(int side_num, const map_location& last_hex)
gui2::dialogs::unit_recall dlg(recall_list_team, current_team);
dlg.show();
if(dlg.get_retval() != gui2::retval::OK) {
if(!dlg.show()) {
return;
}

View file

@ -24,7 +24,6 @@
#include "gettext.hpp" // for _
#include "gui/dialogs/transient_message.hpp" // for show_transient_message
#include "gui/dialogs/unit_attack.hpp" // for unit_attack
#include "gui/widgets/retval.hpp" // for enum
#include "language.hpp" // for string_table, symbol_table
#include "log.hpp" // for LOG_STREAM, logger, etc
#include "map/map.hpp" // for gamemap
@ -994,9 +993,7 @@ int mouse_handler::show_attack_dialog(const map_location& attacker_loc, const ma
gui2::dialogs::unit_attack dlg(attacker, defender, bc_vector, best);
dlg.show();
if(dlg.get_retval() == gui2::retval::OK) {
if(dlg.show()) {
return dlg.get_selected_weapon();
}

View file

@ -100,7 +100,7 @@ bool loadgame::show_difficulty_dialog()
difficulty_dlg.show();
// Return if canceled, since otherwise load_data_.difficulty will be set to 'CANCEL'
if (difficulty_dlg.get_retval() != gui2::retval::OK) {
if(!difficulty_dlg.show()) {
return false;
}