GUI2: split default return value enum into its own file

This avoid having to include gui/widgets/window.hpp every time you just want to
check a dialog's return value.
This commit is contained in:
Charles Dang 2018-03-12 12:00:07 +11:00
parent ab354737ef
commit 26e8c148b1
72 changed files with 201 additions and 179 deletions

View file

@ -3848,6 +3848,7 @@
<ClInclude Include="..\..\src\gui\widgets\password_box.hpp" />
<ClInclude Include="..\..\src\gui\widgets\progress_bar.hpp" />
<ClInclude Include="..\..\src\gui\widgets\repeating_button.hpp" />
<ClInclude Include="..\..\src\gui\widgets\retval.hpp" />
<ClInclude Include="..\..\src\gui\widgets\scrollbar.hpp" />
<ClInclude Include="..\..\src\gui\widgets\scrollbar_container.hpp" />
<ClInclude Include="..\..\src\gui\widgets\scrollbar_container_private.hpp" />

View file

@ -3021,6 +3021,9 @@
<Filter>Gui\Dialogs</Filter>
</ClInclude>
<ClInclude Include="..\..\src\deprecation.hpp" />
<ClInclude Include="..\..\src\gui\widgets\retval.hpp">
<Filter>Gui\Widgets</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\src\tests\test_sdl_utils.hpp">

View file

@ -25,7 +25,7 @@
#include "preferences/game.hpp"
#include "game_data.hpp" //resources::gamedata->phase()
#include "gui/dialogs/unit_advance.hpp"
#include "gui/widgets/window.hpp" //gui2::window::OK
#include "gui/widgets/retval.hpp" //gui2::retval::OK
#include "log.hpp"
#include "play_controller.hpp" //resources::controller
#include "random.hpp"
@ -79,7 +79,7 @@ namespace
dlg.show();
if (dlg.get_retval() == gui2::window::OK) {
if (dlg.get_retval() == gui2::retval::OK) {
return dlg.get_selected_index();
}

View file

@ -23,7 +23,7 @@
#include "gettext.hpp"
#include "gui/dialogs/addon/install_dependencies.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "log.hpp"
#include "random.hpp"
#include "serialization/parser.hpp"
@ -377,7 +377,7 @@ addons_client::install_result addons_client::do_resolve_addon_dependencies(const
broken_deps_report += "\n " + font::unicode_bullet + " " + make_addon_title(broken_dep_id);
}
if(gui2::show_message(_("Broken Dependencies"), broken_deps_report, gui2::dialogs::message::yes_no_buttons) != gui2::window::OK) {
if(gui2::show_message(_("Broken Dependencies"), broken_deps_report, gui2::dialogs::message::yes_no_buttons) != gui2::retval::OK) {
result.outcome = install_outcome::abort;
return result; // canceled by user
}
@ -423,7 +423,7 @@ addons_client::install_result addons_client::do_resolve_addon_dependencies(const
"The following dependencies could not be installed. Do you still wish to continue?",
failed_titles.size()) + std::string("\n\n") + utils::bullet_list(failed_titles);
result.outcome = gui2::show_message(_("Dependencies Installation Failed"), failed_deps_report, gui2::dialogs::message::yes_no_buttons) == gui2::window::OK ? install_outcome::success : install_outcome::abort; // If the user cancels, return abort. Otherwise, return success, since the user chose to ignore the failure.
result.outcome = gui2::show_message(_("Dependencies Installation Failed"), failed_deps_report, gui2::dialogs::message::yes_no_buttons) == gui2::retval::OK ? install_outcome::success : install_outcome::abort; // If the user cancels, return abort. Otherwise, return success, since the user chose to ignore the failure.
return result;
}
@ -460,7 +460,7 @@ bool addons_client::do_check_before_overwriting_addon(const addon_info& addon)
text += utils::bullet_list(extra_items) + "\n\n";
text += _("Do you really wish to continue?");
return gui2::show_message(_("Confirm"), text, gui2::dialogs::message::yes_no_buttons) == gui2::window::OK;
return gui2::show_message(_("Confirm"), text, gui2::dialogs::message::yes_no_buttons) == gui2::retval::OK;
}
addons_client::install_result addons_client::install_addon_with_checks(const addons_list& addons, const addon_info& addon)

View file

@ -25,7 +25,7 @@
#include "gui/dialogs/simple_item_selector.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "log.hpp"
#include "serialization/parser.hpp"
#include "version.hpp"

View file

@ -27,7 +27,7 @@
#include "gui/dialogs/addon/connect.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "log.hpp"
#include "wml_exception.hpp"
@ -174,7 +174,7 @@ bool uninstall_local_addons()
_("Confirm")
, confirm_message
, gui2::dialogs::message::yes_no_buttons);
} while (res != gui2::window::OK);
} while (res != gui2::retval::OK);
std::set<std::string> failed_names, skipped_names, succeeded_names;
@ -240,7 +240,7 @@ bool manage_addons()
addon_dlg.show();
int res = addon_dlg.get_retval();
if(res == gui2::window::OK) {
if(res == gui2::retval::OK) {
res = addon_download;
}

View file

@ -33,12 +33,13 @@
#include "gui/dialogs/preferences_dialog.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/dialogs/unit_list.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "wml_exception.hpp"
#include "resources.hpp"
#include "reports.hpp"
#include "cursor.hpp"
#include "desktop/clipboard.hpp"
#include "floating_label.hpp"
#include "game_board.hpp"

View file

@ -37,7 +37,7 @@
#include "gui/dialogs/file_dialog.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "gui/dialogs/editor/edit_scenario.hpp"
#include "gui/dialogs/editor/edit_side.hpp"
@ -689,7 +689,7 @@ void context_manager::generate_map_dialog()
dialog.select_map_generator(last_map_generator_);
dialog.show();
if(dialog.get_retval() == gui2::window::OK) {
if(dialog.get_retval() == gui2::retval::OK) {
std::string map_string;
map_generator* const map_generator = dialog.get_selected_map_generator();
try {
@ -717,7 +717,7 @@ bool context_manager::confirm_discard()
if(get_map_context().modified()) {
const int res = gui2::show_message(_("Unsaved Changes"),
_("Do you want to discard all changes made to the map since the last save?"), gui2::dialogs::message::yes_no_buttons);
return gui2::window::CANCEL != res;
return gui2::retval::CANCEL != res;
}
return true;

View file

@ -34,7 +34,7 @@
#include "preferences/game.hpp"
#include "gettext.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "log.hpp"
#include "map/map.hpp"
#include "map/exception.hpp"

View file

@ -226,7 +226,7 @@ std::pair<wesnothd_connection_ptr, config> open_connection(std::string host)
warning_msg += "\n\n";
warning_msg += _("Do you want to continue?");
if(gui2::show_message(_("Warning"), warning_msg, gui2::dialogs::message::yes_no_buttons) != gui2::window::OK) {
if(gui2::show_message(_("Warning"), warning_msg, gui2::dialogs::message::yes_no_buttons) != gui2::retval::OK) {
return std::make_pair(wesnothd_connection_ptr(), config());
}
}
@ -240,7 +240,7 @@ std::pair<wesnothd_connection_ptr, config> open_connection(std::string host)
std::string password = preferences::password(host, login);
bool fall_through = (*error)["force_confirmation"].to_bool() ?
(gui2::show_message(_("Confirm"), (*error)["message"], gui2::dialogs::message::ok_cancel_buttons) == gui2::window::CANCEL) :
(gui2::show_message(_("Confirm"), (*error)["message"], gui2::dialogs::message::ok_cancel_buttons) == gui2::retval::CANCEL) :
false;
const bool is_pw_request = !((*error)["password_request"].empty()) && !(password.empty());
@ -359,7 +359,7 @@ std::pair<wesnothd_connection_ptr, config> open_connection(std::string host)
switch(dlg.get_retval()) {
//Log in with password
case gui2::window::OK:
case gui2::retval::OK:
break;
//Request a password reminder
case 1:
@ -449,7 +449,7 @@ void enter_wait_mode(mp_workflow_helper_ptr helper, int game_id, bool observe)
}
dlg.show();
dlg_ok = dlg.get_retval() == gui2::window::OK;
dlg_ok = dlg.get_retval() == gui2::retval::OK;
}
if(dlg_ok) {
@ -480,7 +480,7 @@ void enter_staging_mode(mp_workflow_helper_ptr helper)
gui2::dialogs::mp_staging dlg(*connect_engine, *helper->lobby_info, helper->connection);
dlg.show();
dlg_ok = dlg.get_retval() == gui2::window::OK;
dlg_ok = dlg.get_retval() == gui2::retval::OK;
} // end connect_engine_ptr, dlg scope
if(dlg_ok) {
@ -508,7 +508,7 @@ void enter_create_mode(mp_workflow_helper_ptr helper)
// The Create Game dialog also has a LOAD_GAME retval besides OK.
// Do a did-not-cancel check here to catch that
dlg_ok = dlg.get_retval() != gui2::window::CANCEL;
dlg_ok = dlg.get_retval() != gui2::retval::CANCEL;
}
if(dlg_ok) {

View file

@ -28,7 +28,7 @@
#include "generators/map_generator.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "persist_manager.hpp"
#include "playmp_controller.hpp"
#include "log.hpp"
@ -343,7 +343,7 @@ LEVEL_RESULT campaign_controller::play_game()
_("This scenario has ended. Do you want to continue the campaign?"),
gui2::dialogs::message::yes_no_buttons);
if(dlg_res == gui2::window::CANCEL) {
if(dlg_res == gui2::retval::CANCEL) {
return res;
}
}

View file

@ -18,7 +18,7 @@
#include "gui/dialogs/message.hpp"
#include "gui/dialogs/multiplayer/mp_staging.hpp"
#include "gui/dialogs/sp_options_configure.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "wml_exception.hpp"
static lg::log_domain log_engine("engine");
@ -56,7 +56,7 @@ bool enter_create_mode(saved_game& state, jump_to_campaign_info jump_to_campaign
return false;
}
if(dlg.get_retval() != gui2::window::OK) {
if(dlg.get_retval() != gui2::retval::OK) {
return false;
}

View file

@ -40,7 +40,7 @@
#include "gui/dialogs/transient_message.hpp" // for show_transient_message
#include "gui/dialogs/title_screen.hpp" // for show_debug_clock_button
#include "gui/widgets/settings.hpp" // for new_widgets
#include "gui/widgets/window.hpp" // for window, etc
#include "gui/widgets/retval.hpp" // for window, etc
#include "language.hpp" // for language_def, etc
#include "log.hpp" // for LOG_STREAM, logger, general, etc
#include "map/exception.hpp"
@ -921,7 +921,7 @@ bool game_launcher::change_language()
{
gui2::dialogs::language_selection dlg;
dlg.show();
if (dlg.get_retval() != gui2::window::OK) return false;
if (dlg.get_retval() != gui2::retval::OK) return false;
if (!(cmdline_opts_.nogui || cmdline_opts_.headless_unit_test)) {
video().set_window_title(game_config::get_default_title_string());

View file

@ -82,7 +82,7 @@ void addon_connect::pre_show(window& window)
void addon_connect::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
text_box& host_widget
= find_widget<text_box>(&window, "host_name", false);

View file

@ -31,7 +31,7 @@ public:
* @param [in, out]host_name The parameter's usage is:
* - Input: The initial value for the host_name.
* - Output :The final value of the host_name if
* the dialog returns @ref window::OK or 3
* the dialog returns @ref retval::OK or 3
* undefined otherwise.
* @param allow_remove Sets @ref allow_remove_.
*/

View file

@ -727,7 +727,7 @@ void addon_manager::publish_addon(const addon_info& addon, window& window)
_("The remote version of this add-on is greater or equal to the version being uploaded. Do you really wish to continue?"),
gui2::dialogs::message::yes_no_buttons);
if(res != gui2::window::OK) {
if(res != gui2::retval::OK) {
return;
}
}
@ -737,7 +737,7 @@ void addon_manager::publish_addon(const addon_info& addon, window& window)
} else if(!client_.request_distribution_terms(server_msg)) {
gui2::show_error_message(
_("The server responded with an error:") + "\n" + client_.get_last_server_error());
} else if(gui2::show_message(_("Terms"), server_msg, gui2::dialogs::message::ok_cancel_buttons, true) == gui2::window::OK) {
} else if(gui2::show_message(_("Terms"), server_msg, gui2::dialogs::message::ok_cancel_buttons, true) == gui2::retval::OK) {
if(!client_.upload_addon(addon_id, server_msg, cfg)) {
const std::string& msg = _("The server responded with an error:") +
"\n\n" + client_.get_last_server_error();
@ -772,7 +772,7 @@ void addon_manager::delete_addon(const addon_info& addon, window& window)
const int res = gui2::show_message(_("Confirm"), text, gui2::dialogs::message::yes_no_buttons);
if(res != gui2::window::OK) {
if(res != gui2::retval::OK) {
return;
}
@ -800,7 +800,7 @@ void addon_manager::execute_default_action(const addon_info& addon, window& wind
int res = gui2::show_message(_("Uninstall add-on"),
vgettext("Do you want to uninstall '$addon|'?", symbols),
gui2::dialogs::message::ok_cancel_buttons);
if(res == gui2::window::OK) {
if(res == gui2::retval::OK) {
uninstall_addon(addon, window);
}
}

View file

@ -90,7 +90,7 @@ void addon_uninstall_list::post_show(window& window)
assert(rows == this->ids_.size() && rows == this->titles_map_.size());
if(!rows || get_retval() != window::OK) {
if(!rows || get_retval() != retval::OK) {
return;
}

View file

@ -94,7 +94,7 @@ void advanced_graphics_options::update_scale_case(const std::string& case_id)
void advanced_graphics_options::post_show(window& /*window*/)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
for(const std::string& i : scale_cases) {
update_scale_case(i);
}

View file

@ -159,7 +159,7 @@ void campaign_difficulty::pre_show(window& window)
void campaign_difficulty::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
listbox& list = find_widget<listbox>(&window, "listbox", false);
selected_difficulty_ = difficulties_.child("difficulty", list.get_selected_row())["define"].str();
}

View file

@ -106,7 +106,7 @@ void depcheck_select_new::pre_show(window& window)
void depcheck_select_new::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
listbox& items = find_widget<listbox>(&window, "itemlist", false);
result_ = items.get_selected_row();
}

View file

@ -74,9 +74,9 @@ namespace
SDL_Rect rect = window.get_rectangle();
if(!sdl::point_in_rect(coordinate, rect)) {
window.set_retval(window::CANCEL);
window.set_retval(retval::CANCEL);
} else if(!keep_open) {
window.set_retval(window::OK);
window.set_retval(retval::OK);
}
}
@ -96,7 +96,7 @@ namespace
void resize_callback(window& window)
{
window.set_retval(window::CANCEL);
window.set_retval(retval::CANCEL);
window.close();
}
}

View file

@ -30,14 +30,14 @@ public:
* @param [in, out] label The parameter's usage is:
* - Input: The initial value of the label.
* - Output: The label text the user entered if
* the dialog returns @ref window::OK
* the dialog returns @ref retval::OK
* undefined otherwise.
* @param [in, out] team_only The parameter's usage is:
* - Input: The initial value of the team only
* toggle.
* - Output: The final value of the team only
* toggle if the dialog returns @ref
* window::OK undefined otherwise.
* retval::OK undefined otherwise.
*/
edit_label(std::string& label, bool& team_only);

View file

@ -32,7 +32,7 @@ public:
* @param [in, out] text The parameter's usage is:
* - Input: The initial value of the text field.
* - Output: The new unit name the user entered
* if the dialog returns @ref window::OK,
* if the dialog returns @ref retval::OK,
* undefined otherwise.
*/
edit_text(const std::string& title,

View file

@ -345,7 +345,7 @@ void custom_tod::post_show(window& window)
{
update_tod_display(window);
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
// TODO: save ToD
}
}

View file

@ -31,7 +31,7 @@ public:
* @param[in, out] text The parameter's usage is:
* - Input: The initial value of the label.
* - Output: The label text the user entered if
* the dialog returns @ref window::OK
* the dialog returns @ref retval::OK
* undefined otherwise.
*/
editor_edit_label(std::string& text,

View file

@ -33,12 +33,12 @@ public:
* @param [in, out] width The parameter's usage is:
* - Input: The initial width of the map.
* - Output: The selected width of the map if
* the dialog returns @ref window::OK
* the dialog returns @ref retval::OK
* undefined otherwise.
* @param [in, out] height The parameter's usage is:
* - Input: The initial height of the map.
* - Output: The selected height of the map if
* the dialog returns @ref window::OK
* the dialog returns @ref retval::OK
* undefined otherwise.
*/
editor_new_map(const t_string& title, int& width, int& height);

View file

@ -45,18 +45,18 @@ public:
* @param [in, out] width The parameter's usage is:
* - Input: The initial width of the map.
* - Output: The selected width of the map if
* the dialog returns @ref window::OK
* the dialog returns @ref retval::OK
* undefined otherwise.
*
* @param [in, out] height The parameter's usage is:
* - Input: The initial height of the map.
* - Output: The selected height of the map if
* the dialog returns @ref window::OK
* the dialog returns @ref retval::OK
* undefined otherwise.
*
* @param [out] expand_direction
* The selected expand direction if the dialog
* returns @ref window::OK undefined
* returns @ref retval::OK undefined
* otherwise.
*
* @param [in, out] copy_edge_terrain
@ -65,7 +65,7 @@ public:
* toggle.
* - Output: The final value of the copy edge
* toggle if the dialog returns @ref
* window::OK undefined otherwise.
* retval::OK undefined otherwise.
*/
editor_resize_map(int& width,
int& height,

View file

@ -115,7 +115,7 @@ void editor_set_starting_position::pre_show(window& window)
void editor_set_starting_position::post_show(window& window)
{
if(get_retval() != window::OK) {
if(get_retval() != retval::OK) {
return;
}

View file

@ -271,7 +271,7 @@ bool file_dialog::on_exit(window& window)
// Attempting to exit by double clicking items -- only proceeds if the item
// was a file.
if(process_fileview_submit(window)) {
window.set_retval(window::OK, false);
window.set_retval(retval::OK, false);
return true;
} else {
return false;
@ -279,7 +279,7 @@ bool file_dialog::on_exit(window& window)
}
if(window.get_retval() == window::OK) {
if(window.get_retval() == retval::OK) {
// Attempting to exit by pressing Enter/clicking OK -- only proceeds if the
// textbox was not altered by the user to point to a different directory.
return process_textbox_submit(window);
@ -305,7 +305,7 @@ bool file_dialog::confirm_overwrite(window& /*window*/, file_dialog::SELECTION_T
const std::string& message
= _("The file already exists. Do you wish to overwrite it?");
return gui2::show_message(_("Confirm"), message, message::yes_no_buttons) != gui2::window::CANCEL;
return gui2::show_message(_("Confirm"), message, message::yes_no_buttons) != gui2::retval::CANCEL;
}
bool file_dialog::process_submit_common(window& window, const std::string& name)
@ -731,7 +731,7 @@ void file_dialog::on_file_delete_cmd(window& window)
: _("The following file will be permanently deleted:"))
+ "\n\n" + selection + "\n\n" + _("Do you wish to continue?");
if(gui2::show_message(_("Confirm"), message, message::yes_no_buttons) == gui2::window::CANCEL) {
if(gui2::show_message(_("Confirm"), message, message::yes_no_buttons) == gui2::retval::CANCEL) {
return;
}

View file

@ -32,7 +32,7 @@ public:
* - Input: A suggested folder name.
* - Output: The folder name the user actually
* entered if the dialog returns @ref
* window::OK; undefined otherwise.
* retval::OK; undefined otherwise.
*/
folder_create(std::string& folder_name);

View file

@ -174,25 +174,25 @@ void formula_debugger::pre_show(window& window)
void formula_debugger::callback_continue_button(window& window)
{
fdb_.add_breakpoint_continue_to_end();
window.set_retval(window::OK);
window.set_retval(retval::OK);
}
void formula_debugger::callback_next_button(window& window)
{
fdb_.add_breakpoint_next();
window.set_retval(window::OK);
window.set_retval(retval::OK);
}
void formula_debugger::callback_step_button(window& window)
{
fdb_.add_breakpoint_step_into();
window.set_retval(window::OK);
window.set_retval(retval::OK);
}
void formula_debugger::callback_stepout_button(window& window)
{
fdb_.add_breakpoint_step_out();
window.set_retval(window::OK);
window.set_retval(retval::OK);
}
} // namespace dialogs

View file

@ -385,7 +385,7 @@ void game_load::delete_button_callback(window& window)
// Close the dialog if there are no more saves
if(list.get_item_count() == 0) {
window.set_retval(window::CANCEL);
window.set_retval(retval::CANCEL);
}
display_savegame(window);

View file

@ -259,7 +259,7 @@ void game_stats::on_tab_select(window& window)
void game_stats::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
const int selected_tab = find_widget<listbox>(&window, "tab_bar", false).get_selected_row();
const std::string list_id = selected_tab == 0 ? "game_stats_list" : "scenario_settings_list";

View file

@ -48,7 +48,7 @@ void hotkey_bind::sdl_event_callback(window& win, const SDL_Event &event)
new_binding_ = hotkey::create_hotkey(hotkey_id_, event);
}
if(new_binding_) {
win.set_retval(window::OK);
win.set_retval(retval::OK);
}
}

View file

@ -82,7 +82,7 @@ void language_selection::pre_show(window& window)
void language_selection::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
const int res = find_widget<listbox>(&window, "language_list", false)
.get_selected_row();

View file

@ -58,7 +58,7 @@ struct message_implementation
button_status.ptr->set_label(button_status.caption);
}
if(button_status.retval != window::NONE) {
if(button_status.retval != retval::NONE) {
button_status.ptr->set_retval(button_status.retval);
}
}
@ -141,7 +141,7 @@ message::button_status::button_status()
: ptr(nullptr)
, caption()
, visible(widget::visibility::invisible)
, retval(window::NONE)
, retval(retval::NONE)
{
}

View file

@ -65,7 +65,7 @@ bool modal_dialog::show(const unsigned auto_close_time)
if (pm && pm->any_running())
{
plugins_context pc("Dialog");
pc.set_callback("skip_dialog", [this](config) { retval_ = window::OK; }, false);
pc.set_callback("skip_dialog", [this](config) { retval_ = retval::OK; }, false);
pc.set_callback("quit", [](config) {}, false);
pc.play_slice();
}
@ -103,7 +103,7 @@ bool modal_dialog::show(const unsigned auto_close_time)
*/
SDL_FlushEvent(DOUBLE_CLICK_EVENT);
finalize_fields(*window_, (retval_ == window::OK || always_save_fields_));
finalize_fields(*window_, (retval_ == retval::OK || always_save_fields_));
post_show(*window_);
@ -113,7 +113,7 @@ bool modal_dialog::show(const unsigned auto_close_time)
// Reset window object.
window_.reset(nullptr);
return retval_ == window::OK;
return retval_ == retval::OK;
}
field_bool* modal_dialog::register_bool(

View file

@ -166,7 +166,7 @@ public:
* there's no guarantee about how fast it closes
* after the minimum.
*
* @returns Whether the final retval_ == window::OK
* @returns Whether the final retval_ == retval::OK
*/
bool show(const unsigned auto_close_time = 0);
@ -335,7 +335,7 @@ private:
/**
* Always save the fields upon closing.
*
* Normally fields are only saved when the window::OK button is pressed.
* Normally fields are only saved when the retval::OK button is pressed.
* With this flag set is always saves. Be careful with the flag since it
* also updates upon canceling, which can be a problem when the field sets
* a preference.

View file

@ -260,7 +260,7 @@ bool handle_addon_requirements_gui(const std::vector<mp::game_info::required_add
assert(needs_download.size() > 0);
if(gui2::show_message(e_title, err_msg, message::yes_no_buttons, true) == gui2::window::OK) {
if(gui2::show_message(e_title, err_msg, message::yes_no_buttons, true) == gui2::retval::OK) {
// Begin download session
return ad_hoc_addon_fetch_session(needs_download);
}
@ -711,7 +711,7 @@ void mp_lobby::update_selected_game()
bool mp_lobby::exit_hook(window& window)
{
if(window.get_retval() == window::CANCEL) {
if(window.get_retval() == retval::CANCEL) {
return quit();
}
@ -835,7 +835,7 @@ void mp_lobby::pre_show(window& window)
}, true);
plugins_context_->set_callback("create", [&window](const config&) { window.set_retval(CREATE); }, true);
plugins_context_->set_callback("quit", [&window](const config&) { window.set_retval(window::CANCEL); }, false);
plugins_context_->set_callback("quit", [&window](const config&) { window.set_retval(retval::CANCEL); }, false);
plugins_context_->set_callback("chat", [this](const config& cfg) { chatbox_->send_chat_message(cfg["message"], false); }, true);
plugins_context_->set_callback("select_game", [this](const config& cfg) {

View file

@ -192,7 +192,7 @@ void mp_change_control::highlight_side_nick(window& window)
void mp_change_control::post_show(window& window)
{
if(window.get_retval() == window::OK) {
if(window.get_retval() == retval::OK) {
DBG_GUI << "Main: changing control of side "
<< sides_[selected_side_] << " to nick "
<< nicks_[selected_nick_] << std::endl;

View file

@ -115,7 +115,7 @@ void mp_server_list::pre_show(window& window)
void mp_server_list::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
const listbox& list
= find_widget<const listbox>(&window, "server_list", false);
@ -158,7 +158,7 @@ show_server_list(window& window, field_text* host_name)
mp_server_list dlg;
dlg.show();
if(dlg.get_retval() == window::OK) {
if(dlg.get_retval() == retval::OK) {
host_name->set_widget_value(window, dlg.host_name());
}
}

View file

@ -358,8 +358,8 @@ void mp_create_game::pre_show(window& win)
//
plugins_context_.reset(new plugins_context("Multiplayer Create"));
plugins_context_->set_callback("create", [&win](const config&) { win.set_retval(window::OK); }, false);
plugins_context_->set_callback("quit", [&win](const config&) { win.set_retval(window::CANCEL); }, false);
plugins_context_->set_callback("create", [&win](const config&) { win.set_retval(retval::OK); }, false);
plugins_context_->set_callback("quit", [&win](const config&) { win.set_retval(retval::CANCEL); }, false);
plugins_context_->set_callback("load", [this, &win](const config&) { load_game_callback(win); }, false);
#define UPDATE_ATTRIBUTE(field, convert) \
@ -845,7 +845,7 @@ void mp_create_game::post_show(window& window)
return;
}
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
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());

View file

@ -216,7 +216,7 @@ bool mp_join_game::fetch_game_config()
gui2::dialogs::faction_select dlg(flg, color, side_num);
dlg.show();
if(dlg.get_retval() != gui2::window::OK) {
if(dlg.get_retval() != gui2::retval::OK) {
return true;
}
@ -301,8 +301,8 @@ void mp_join_game::pre_show(window& window)
//
plugins_context_.reset(new plugins_context("Multiplayer Join"));
plugins_context_->set_callback("launch", [&window](const config&) { window.set_retval(window::OK); }, false);
plugins_context_->set_callback("quit", [&window](const config&) { window.set_retval(window::CANCEL); }, false);
plugins_context_->set_callback("launch", [&window](const config&) { window.set_retval(retval::OK); }, false);
plugins_context_->set_callback("quit", [&window](const config&) { window.set_retval(retval::CANCEL); }, false);
plugins_context_->set_callback("chat", [&chat](const config& cfg) { chat.send_chat_message(cfg["message"], false); }, true);
}
@ -424,7 +424,7 @@ void mp_join_game::network_handler(window& window)
{
// If the game has already started, close the dialog immediately.
if(level_["started"].to_bool()) {
window.set_retval(window::OK);
window.set_retval(retval::OK);
return;
}
@ -441,12 +441,12 @@ void mp_join_game::network_handler(window& window)
}
if(data["failed"].to_bool()) {
window.set_retval(window::CANCEL);
window.set_retval(retval::CANCEL);
} else if(data.child("start_game")) {
level_["started"] = true;
window.set_retval(window::OK);
window.set_retval(retval::OK);
} else if(data.child("leave_game")) {
window.set_retval(window::CANCEL);
window.set_retval(retval::CANCEL);
}
if(data.child("stop_updates")) {
@ -494,7 +494,7 @@ void mp_join_game::post_show(window& window)
update_timer_ = 0;
}
if(window.get_retval() == window::OK) {
if(window.get_retval() == retval::OK) {
if(const config& stats = level_.child("statistics")) {
statistics::fresh_stats();
statistics::read_stats(stats);

View file

@ -30,7 +30,7 @@ public:
* @param [in, out] password The parameter's usage is:
* - Input: The initial value for the password.
* - Output: The password input by the user
* if the dialog returns @ref window::OK,
* if the dialog returns @ref retval::OK,
* undefined otherwise.
*/
explicit mp_join_game_password_prompt(std::string& password);

View file

@ -117,7 +117,7 @@ void mp_login::pre_show(window& win)
}
void mp_login::post_show(window& win) {
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
save_password(win);
}
}

View file

@ -72,7 +72,7 @@ void mp_method_selection::pre_show(window& window)
void mp_method_selection::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
text_box& user_widget
= find_widget<text_box>(&window, "user_name", false);
listbox& list = find_widget<listbox>(&window, "method_list", false);

View file

@ -124,8 +124,8 @@ void mp_staging::pre_show(window& window)
//
plugins_context_.reset(new plugins_context("Multiplayer Staging"));
plugins_context_->set_callback("launch", [&window](const config&) { window.set_retval(window::OK); }, false);
plugins_context_->set_callback("quit", [&window](const config&) { window.set_retval(window::CANCEL); }, false);
plugins_context_->set_callback("launch", [&window](const config&) { window.set_retval(retval::OK); }, false);
plugins_context_->set_callback("quit", [&window](const config&) { window.set_retval(retval::CANCEL); }, false);
plugins_context_->set_callback("chat", [&chat](const config& cfg) { chat.send_chat_message(cfg["message"], false); }, true);
}
@ -397,7 +397,7 @@ void mp_staging::select_leader_callback(ng::side_engine_ptr side, grid& row_grid
gui2::dialogs::faction_select dlg(side->flg(), side->color_id(), side->index() + 1);
dlg.show();
if(dlg.get_retval() == window::OK) {
if(dlg.get_retval() == retval::OK) {
update_leader_display(side, row_grid);
set_state_changed();
@ -491,7 +491,7 @@ void mp_staging::network_handler(window& window)
std::tie(quit_signal_received, std::ignore) = connect_engine_.process_network_data(data);
if(quit_signal_received) {
window.set_retval(window::CANCEL);
window.set_retval(retval::CANCEL);
}
// Update side leader displays
@ -536,7 +536,7 @@ void mp_staging::post_show(window& window)
update_timer_ = 0;
}
if(window.get_retval() == window::OK) {
if(window.get_retval() == retval::OK) {
connect_engine_.start_game();
} else {
connect_engine_.leave_game();

View file

@ -40,7 +40,7 @@ void network_transmission::pump_monitor::process(events::pump_info&)
return;
connection_->poll();
if(connection_->finished()) {
window_.get().set_retval(window::OK);
window_.get().set_retval(retval::OK);
} else {
size_t completed, total;
completed = connection_->current();
@ -89,7 +89,7 @@ void network_transmission::post_show(window& /*window*/)
{
pump_monitor_.window_.reset();
if(get_retval() == window::retval::CANCEL) {
if(get_retval() == retval::CANCEL) {
connection_->cancel();
}
}

View file

@ -879,7 +879,7 @@ void preferences_dialog::add_hotkey_callback(listbox& hotkeys)
});
const int res = gui2::show_message(_("Reassign Hotkey"), text, gui2::dialogs::message::yes_no_buttons, true);
if(res != gui2::window::OK) {
if(res != gui2::retval::OK) {
return;
}
}

View file

@ -61,7 +61,7 @@ void select_orb_colors::pre_show(window& window)
void select_orb_colors::post_show(window&)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
preferences::set_show_unmoved_orb(show_unmoved_);
preferences::set_show_partial_orb(show_partial_);
preferences::set_show_moved_orb(show_moved_);

View file

@ -120,7 +120,7 @@ void simple_item_selector::pre_show(window& window)
void simple_item_selector::post_show(window& window)
{
if(get_retval() == window::OK || single_button_) {
if(get_retval() == retval::OK || single_button_) {
index_ = find_widget<listbox>(&window, "listbox", false).get_selected_row();
}
}

View file

@ -40,7 +40,7 @@ void sp_options_configure::pre_show(window& window)
void sp_options_configure::post_show(window& window)
{
if(window.get_retval() == window::OK) {
if(window.get_retval() == retval::OK) {
config_engine_.set_options(options_manager_->get_options_config());
}
}

View file

@ -90,7 +90,7 @@ void theme_list::pre_show(window& window)
void theme_list::post_show(window& window)
{
if(get_retval() != window::OK) {
if(get_retval() != retval::OK) {
return;
}

View file

@ -485,7 +485,7 @@ void title_screen::button_callback_multiplayer(window& window)
gui2::dialogs::mp_method_selection dlg;
dlg.show();
if(dlg.get_retval() != gui2::window::OK) {
if(dlg.get_retval() != gui2::retval::OK) {
return;
}

View file

@ -47,7 +47,7 @@ public:
*/
enum result {
// Window was resized, so needs redrawing
REDRAW_BACKGROUND = 0, // Needs to be 0, the value of gui2::window::NONE
REDRAW_BACKGROUND = 0, // Needs to be 0, the value of gui2::retval::NONE
// Start playing a single-player game, such as the tutorial or a campaign
LAUNCH_GAME,
// Connect to an MP server

View file

@ -118,7 +118,7 @@ void unit_advance::show_help()
void unit_advance::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
selected_index_ = find_widget<listbox>(&window, "advance_choice", false)
.get_selected_row();
}

View file

@ -184,7 +184,7 @@ void unit_attack::pre_show(window& window)
void unit_attack::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
selected_weapon_ = find_widget<listbox>(&window, "weapon_list", false).get_selected_row();
}
}

View file

@ -164,7 +164,7 @@ void unit_create::post_show(window& window)
choice_ = "";
if(get_retval() != window::OK) {
if(get_retval() != retval::OK) {
return;
}

View file

@ -188,7 +188,7 @@ void unit_list::list_item_clicked(window& window)
void unit_list::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
const int selected_row = find_widget<listbox>(&window, "units_list", false).get_selected_row();
scroll_to_ = unit_list_[selected_row]->get_location();

View file

@ -281,7 +281,7 @@ void unit_recall::dismiss_unit(window& window)
if(!message.str().empty()) {
const int res = gui2::show_message(_("Dismiss Unit"), message.str(), message::yes_no_buttons);
if(res != gui2::window::OK) {
if(res != gui2::retval::OK) {
return;
}
}
@ -309,7 +309,7 @@ void unit_recall::dismiss_unit(window& window)
// Close the dialog if all units are dismissed
if(list.get_item_count() == 0) {
window.set_retval(window::CANCEL);
window.set_retval(retval::CANCEL);
}
}
@ -336,7 +336,7 @@ void unit_recall::post_show(window& window)
listbox& list = find_widget<listbox>(&window, "recall_list", false);
sort_last = list.get_active_sorting_option();
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
selected_index_ = list.get_selected_row();
}
}

View file

@ -129,7 +129,7 @@ void unit_recruit::show_help()
void unit_recruit::post_show(window& window)
{
if(get_retval() == window::OK) {
if(get_retval() == retval::OK) {
selected_index_ = find_widget<listbox>(&window, "recruit_list", false)
.get_selected_row();
}

View file

@ -170,7 +170,7 @@ void label::signal_handler_left_button_click(const event::ui_event /* event */,
DBG_GUI_E << "Clicked Link:\"" << link << "\"\n";
const int res = show_message(_("Confirm"), _("Do you want to open this link?") + std::string("\n\n") + link, dialogs::message::yes_no_buttons);
if(res == gui2::window::OK) {
if(res == gui2::retval::OK) {
desktop::open_object(link);
}

View file

@ -0,0 +1,43 @@
/*
Copyright (C) 2007 - 2018 by Mark de Wever <koraq@xs4all.nl>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#pragma once
namespace gui2
{
/**
* Default window/dialog return values.
*
* These values are named return values and most are assigned to a widget
* automatically when using a certain id for that widget (ie, a widget with
* the id "ok" will be assigned the OK return value.
*
* The automatic return values are always a negative number.
*/
enum retval : int
{
/** Default, unset return value. */
NONE = 0,
/** Dialog was closed with the OK button. */
OK = -1,
/** Dialog was closed with the CANCEL button. */
CANCEL = -2,
/** The dialog was closed automatically as its timeout had been reached. */
AUTO_CLOSE = -3,
};
} // namespace gui2

View file

@ -277,7 +277,7 @@ window::window(const builder_window::window_resolution* definition)
, video_(CVideo::get_singleton())
, status_(NEW)
, show_mode_(none)
, retval_(NONE)
, retval_(retval::NONE)
, owner_(nullptr)
, need_layout_(true)
, variables_()
@ -434,16 +434,16 @@ window* window::window_instance(const unsigned handle)
* * cancel cancels the dialog.
*
*/
window::retval window::get_retval_by_id(const std::string& id)
retval window::get_retval_by_id(const std::string& id)
{
// Note it might change to a map later depending on the number
// of items.
if(id == "ok") {
return OK;
return retval::OK;
} else if(id == "cancel" || id == "quit") {
return CANCEL;
return retval::CANCEL;
} else {
return NONE;
return retval::NONE;
}
}
@ -969,7 +969,7 @@ void window::layout()
connect_signal_mouse_left_click(
*click_dismiss_button,
std::bind(&window::set_retval, this, OK, true));
std::bind(&window::set_retval, this, retval::OK, true));
layout_initialize(true);
generate_dot_file("layout_initialize", LAYOUT);
@ -1122,7 +1122,7 @@ bool window::click_dismiss(const int mouse_button_mask)
{
if(does_click_dismiss()) {
if((mouse_button_state_ & mouse_button_mask) == 0) {
set_retval(OK);
set_retval(retval::OK);
} else {
mouse_button_state_ &= ~mouse_button_mask;
}
@ -1361,10 +1361,10 @@ void window::signal_handler_sdl_key_down(const event::ui_event event,
}
}
if(!enter_disabled_ && (key == SDLK_KP_ENTER || key == SDLK_RETURN)) {
set_retval(OK);
set_retval(retval::OK);
handled = true;
} else if(key == SDLK_ESCAPE && !escape_disabled_) {
set_retval(CANCEL);
set_retval(retval::CANCEL);
handled = true;
} else if(key == SDLK_SPACE) {
handled = click_dismiss(0);
@ -1440,7 +1440,7 @@ void window::signal_handler_request_placement(const event::ui_event event,
void window::signal_handler_close_window()
{
set_retval(AUTO_CLOSE);
set_retval(retval::AUTO_CLOSE);
}
// }---------- DEFINITION ---------{

View file

@ -27,6 +27,7 @@
#include "gui/core/event/handler.hpp"
#include "gui/core/window_builder.hpp"
#include "gui/widgets/panel.hpp"
#include "gui/widgets/retval.hpp"
#include <functional>
#include <map>
@ -81,35 +82,6 @@ public:
*/
static window* window_instance(const unsigned handle);
/**
* Default return values.
*
* These values are named return values and most are assigned to a widget
* automatically when using a certain id for that widget. The automatic
* return values are always a negative number.
*
* Note this might be moved somewhere else since it will force people to
* include the button, while it should be and implementation detail for most
* callers.
*/
enum retval {
NONE = 0, /**<
* Dialog is closed with no return
* value, should be rare but eg a
* message popup can do it.
*/
OK = -1, /**< Dialog is closed with ok button. */
CANCEL = -2, /**<
* Dialog is closed with the cancel
* button.
*/
AUTO_CLOSE = -3 /**<
* The dialog is closed automatically
* since it's timeout has been
* triggered.
*/
};
/** Gets the retval for the default buttons. */
static retval get_retval_by_id(const std::string& id);

View file

@ -20,7 +20,7 @@
#include "gui/dialogs/screenshot_notification.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/dialogs/drop_down_menu.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "filesystem.hpp"
#include "gettext.hpp"
#include "log.hpp"
@ -366,7 +366,7 @@ bool command_executor::do_execute_command(const hotkey_command& cmd, int /*inde
}
void command_executor::surrender_game() {
if(gui2::show_message(_("Surrender"), _("Do you really want to surrender the game?"), gui2::dialogs::message::yes_no_buttons) != gui2::window::CANCEL) {
if(gui2::show_message(_("Surrender"), _("Do you really want to surrender the game?"), gui2::dialogs::message::yes_no_buttons) != gui2::retval::CANCEL) {
playmp_controller* pmc = dynamic_cast<playmp_controller*>(resources::controller);
if(pmc && !pmc->is_linger_mode() && !pmc->is_observer()) {
pmc->surrender(display::get_singleton()->viewing_team());
@ -386,7 +386,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::window::OK) {
if(mmenu.get_retval() == gui2::retval::OK) {
res = mmenu.selected_item();
}
} // This will kill the dialog.

View file

@ -58,7 +58,7 @@
#include "gui/dialogs/unit_recall.hpp"
#include "gui/dialogs/unit_recruit.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "help/help.hpp"
#include "log.hpp"
#include "map/label.hpp"
@ -280,7 +280,7 @@ void menu_handler::recruit(int side_num, const map_location& last_hex)
dlg.show();
if(dlg.get_retval() == gui2::window::OK) {
if(dlg.get_retval() == gui2::retval::OK) {
do_recruit(sample_units[dlg.get_selected_index()]->id(), side_num, last_hex);
}
}
@ -377,7 +377,7 @@ void menu_handler::recall(int side_num, const map_location& last_hex)
dlg.show();
if(dlg.get_retval() != gui2::window::OK) {
if(dlg.get_retval() != gui2::retval::OK) {
return;
}
@ -551,7 +551,7 @@ bool menu_handler::end_turn(int side_num)
const int res = gui2::show_message("",
_("You have not started your turn yet. Do you really want to end your turn?"),
gui2::dialogs::message::yes_no_buttons);
if(res == gui2::window::CANCEL) {
if(res == gui2::retval::CANCEL) {
return false;
}
}
@ -560,7 +560,7 @@ bool menu_handler::end_turn(int side_num)
const int res = gui2::show_message("",
_("Some units have movement left. Do you really want to end your turn?"),
gui2::dialogs::message::yes_no_buttons);
if(res == gui2::window::CANCEL) {
if(res == gui2::retval::CANCEL) {
return false;
}
}
@ -569,7 +569,7 @@ bool menu_handler::end_turn(int side_num)
const int res = gui2::show_message("",
_("Some units have not moved. Do you really want to end your turn?"),
gui2::dialogs::message::yes_no_buttons);
if(res == gui2::window::CANCEL) {
if(res == gui2::retval::CANCEL) {
return false;
}
}
@ -803,7 +803,7 @@ void menu_handler::clear_labels()
gui2::dialogs::message::yes_no_buttons
);
if(res == gui2::window::OK) {
if(res == gui2::retval::OK) {
gui_->labels().clear(gui_->current_team_name(), false);
resources::recorder->clear_labels(gui_->current_team_name(), false);
}
@ -1745,7 +1745,7 @@ void console_handler::do_unsafe_lua()
"malicious add-ons or other programs you may have installed.\n\n"
"Do not continue unless you really know what you are doing."), gui2::dialogs::message::ok_cancel_buttons);
if(retval == gui2::window::OK) {
if(retval == gui2::retval::OK) {
print(get_cmd(), _("Unsafe mode enabled!"));
menu_handler_.gamestate().lua_kernel_->load_package();
}
@ -1870,7 +1870,7 @@ void console_handler::do_undiscover()
{
const int res = gui2::show_message("Undiscover",
_("Do you wish to clear all of your discovered units from help?"), gui2::dialogs::message::yes_no_buttons);
if(res != gui2::window::CANCEL) {
if(res != gui2::retval::CANCEL) {
preferences::encountered_units().clear();
}
}

View file

@ -27,7 +27,7 @@
#include "gui/dialogs/transient_message.hpp" // for show_transient_message
#include "gui/dialogs/unit_attack.hpp" // for unit_attack
#include "gui/widgets/settings.hpp" // for new_widgets
#include "gui/widgets/window.hpp" // for enum
#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
@ -999,7 +999,7 @@ int mouse_handler::show_attack_dialog(const map_location& attacker_loc, const ma
dlg.show();
if(dlg.get_retval() == gui2::window::OK) {
if(dlg.get_retval() == gui2::retval::OK) {
return dlg.get_selected_weapon();
}

View file

@ -21,6 +21,7 @@
#include "preferences/display.hpp"
#include "cursor.hpp"
#include "display.hpp"
#include "filesystem.hpp"
#include "formula/string_utils.hpp"
@ -31,7 +32,7 @@
#include "gui/dialogs/preferences_dialog.hpp"
#include "gui/dialogs/theme_list.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "log.hpp"
#include "play_controller.hpp"
#include "game_data.hpp"

View file

@ -20,7 +20,7 @@
#include "playmp_controller.hpp"
#include "gui/dialogs/surrender_quit.hpp"
#include "gui/dialogs/message.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include <boost/range/adaptor/reversed.hpp>
@ -57,7 +57,7 @@ void quit_confirmation::quit_to_desktop()
bool quit_confirmation::show_prompt(const std::string& message)
{
return gui2::show_message(_("Quit"), message,
gui2::dialogs::message::yes_no_buttons) != gui2::window::CANCEL;
gui2::dialogs::message::yes_no_buttons) != gui2::retval::CANCEL;
}
bool quit_confirmation::default_prompt()

View file

@ -19,6 +19,7 @@
#include "save_index.hpp"
#include "carryover.hpp"
#include "cursor.hpp"
#include "format_time_summary.hpp"
#include "formatter.hpp"
#include "formula/string_utils.hpp"
@ -32,7 +33,7 @@
#include "gui/dialogs/campaign_difficulty.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"
#include "gui/widgets/retval.hpp"
#include "log.hpp"
#include "persist_manager.hpp"
#include "resources.hpp"
@ -99,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::window::OK) {
if (difficulty_dlg.get_retval() != gui2::retval::OK) {
return false;
}
@ -251,7 +252,7 @@ bool loadgame::check_version_compatibility(const version_info & save_version)
symbols["version_number"] = save_version.str();
const int res = gui2::show_message(_("Load Game"), utils::interpolate_variables_into_string(message, &symbols),
gui2::dialogs::message::yes_no_buttons);
return res == gui2::window::OK;
return res == gui2::retval::OK;
}
return true;
@ -359,7 +360,7 @@ bool savegame::save_game_interactive(const std::string& message, DIALOG_TYPE dia
throw_quit_game_exception(); //Quit game
}
if (res == gui2::window::OK && check_overwrite()) {
if (res == gui2::retval::OK && check_overwrite()) {
return save_game();
}
@ -382,7 +383,7 @@ int savegame::show_save_dialog(const std::string& message, DIALOG_TYPE dialog_ty
}
if (!check_filename(filename_)) {
res = gui2::window::CANCEL;
res = gui2::retval::CANCEL;
}
return res;
@ -397,7 +398,7 @@ bool savegame::check_overwrite()
std::ostringstream message;
message << _("Save already exists. Do you want to overwrite it?") << "\n" << _("Name: ") << filename_;
const int res = gui2::show_message(_("Overwrite?"), message.str(), gui2::dialogs::message::yes_no_buttons);
return res == gui2::window::OK;
return res == gui2::retval::OK;
}
@ -613,7 +614,7 @@ int oos_savegame::show_save_dialog(const std::string& message, DIALOG_TYPE /*dia
}
if (!check_filename(filename_)) {
res = gui2::window::CANCEL;
res = gui2::retval::CANCEL;
}
return res;

View file

@ -443,7 +443,7 @@ int show_message_box(lua_State* L) {
if(style) {
int result = gui2::show_message(title, message, *style, markup, markup);
if(style == button_style::ok_cancel_buttons || style == button_style::yes_no_buttons) {
lua_pushboolean(L, result == gui2::window::OK);
lua_pushboolean(L, result == gui2::retval::OK);
return 1;
}
} else {