Skip to content

Commit

Permalink
Merge pull request #2221 from Vultraz/master
Browse files Browse the repository at this point in the history
Removed CVideo parameters from dialog show() functions, simplified display/execute implementation
  • Loading branch information
Vultraz committed Nov 20, 2017
2 parents 321c350 + 3029107 commit 7fad714
Show file tree
Hide file tree
Showing 121 changed files with 560 additions and 749 deletions.
2 changes: 1 addition & 1 deletion src/actions/advancement.cpp
Expand Up @@ -77,7 +77,7 @@ namespace
if (previews.size() > 1 || always_display) {
gui2::dialogs::unit_advance dlg(previews, num_real_advances);

dlg.show(CVideo::get_singleton());
dlg.show();

if (dlg.get_retval() == gui2::window::OK) {
return dlg.get_selected_index();
Expand Down
16 changes: 8 additions & 8 deletions src/addon/client.cpp
Expand Up @@ -252,13 +252,13 @@ bool addons_client::install_addon(config& archive_cfg, const addon_info& info)
i18n_symbols["addon_title"] = font::escape_text(info.title);

if(!check_names_legal(archive_cfg)) {
gui2::show_error_message(v_,
gui2::show_error_message(
vgettext("The add-on <i>$addon_title</i> has an invalid file or directory "
"name and cannot be installed.", i18n_symbols));
return false;
}
if(!check_case_insensitive_duplicates(archive_cfg)){
gui2::show_error_message(v_,
gui2::show_error_message(
vgettext("The add-on <i>$addon_title</i> has file or directory names "
"with case conflicts. This may cause problems.", i18n_symbols));
}
Expand Down Expand Up @@ -315,7 +315,7 @@ bool addons_client::try_fetch_addon(const addon_info & addon)
)) {
const std::string& server_error = get_last_server_error();
if(!server_error.empty()) {
gui2::show_error_message(v_,
gui2::show_error_message(
_("The server responded with an error:") + "\n" + server_error);
}
return false;
Expand Down Expand Up @@ -365,7 +365,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(v_, _("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::window::OK) {
result.outcome = install_outcome::abort;
return result; // canceled by user
}
Expand All @@ -384,7 +384,7 @@ addons_client::install_result addons_client::do_resolve_addon_dependencies(const
}

gui2::dialogs::install_dependencies dlg(options);
bool cont = dlg.show(v_);
bool cont = dlg.show();
if(!cont) {
return result; // the user has chosen to continue without installing anything.
}
Expand Down Expand Up @@ -412,7 +412,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(v_, _("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::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.
return result;
}

Expand Down Expand Up @@ -449,7 +449,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(v_, _("Confirm"), text, gui2::dialogs::message::yes_no_buttons) == gui2::window::OK;
return gui2::show_message(_("Confirm"), text, gui2::dialogs::message::yes_no_buttons) == gui2::window::OK;
}

addons_client::install_result addons_client::install_addon_with_checks(const addons_list& addons, const addon_info& addon)
Expand Down Expand Up @@ -550,7 +550,7 @@ void addons_client::wait_for_transfer_done(const std::string& status_message, bo
stat_->set_connection_data(*cd);
}

if(!stat_->show(v_)) {
if(!stat_->show()) {
// Notify the caller chain that the user aborted the operation.
throw user_exit();
}
Expand Down
51 changes: 25 additions & 26 deletions src/addon/manager_ui.cpp
Expand Up @@ -74,47 +74,46 @@ bool addons_manager_ui(CVideo& v, const std::string& remote_address)
client.connect();

gui2::dialogs::addon_manager dlg(client);
dlg.show(v);
dlg.show();

need_wml_cache_refresh = dlg.get_need_wml_cache_refresh();
} catch(const config::error& e) {
ERR_CFG << "config::error thrown during transaction with add-on server; \""<< e.message << "\"" << std::endl;
gui2::show_error_message(v, _("Network communication error."));
gui2::show_error_message(_("Network communication error."));
} catch(const network_asio::error& e) {
ERR_NET << "network_asio::error thrown during transaction with add-on server; \""<< e.what() << "\"" << std::endl;
gui2::show_error_message(v, _("Remote host disconnected."));
gui2::show_error_message(_("Remote host disconnected."));
} catch(const filesystem::io_exception& e) {
ERR_FS << "filesystem::io_exception thrown while installing an addon; \"" << e.what() << "\"" << std::endl;
gui2::show_error_message(v, _("A problem occurred when trying to create the files necessary to install this add-on."));
gui2::show_error_message(_("A problem occurred when trying to create the files necessary to install this add-on."));
} catch(const invalid_pbl_exception& e) {
ERR_CFG << "could not read .pbl file " << e.path << ": " << e.message << std::endl;

utils::string_map symbols;
symbols["path"] = e.path;
symbols["msg"] = e.message;

gui2::show_error_message(v,
gui2::show_error_message(
vgettext("A local file with add-on publishing information could not be read.\n\nFile: $path\nError message: $msg", symbols));
} catch(wml_exception& e) {
e.show(v);
e.show();
} catch(const addons_client::user_exit&) {
LOG_AC << "initial connection canceled by user\n";
} catch(const addons_client::invalid_server_address&) {
gui2::show_error_message(v, _("The add-ons server address specified is not valid."));
gui2::show_error_message(_("The add-ons server address specified is not valid."));
}

return need_wml_cache_refresh;
}

bool uninstall_local_addons(CVideo& v)
bool uninstall_local_addons()
{
const std::string list_lead = "\n\n";

const std::vector<std::string>& addons = installed_addons();

if(addons.empty()) {
gui2::show_error_message(v,
_("You have no add-ons installed."));
gui2::show_error_message(_("You have no add-ons installed."));
return false;
}

Expand Down Expand Up @@ -151,7 +150,7 @@ bool uninstall_local_addons(CVideo& v)

do {
gui2::dialogs::addon_uninstall_list dlg(addon_titles_map);
dlg.show(v);
dlg.show();

remove_ids = dlg.selected_addons();
if(remove_ids.empty()) {
Expand All @@ -169,8 +168,8 @@ bool uninstall_local_addons(CVideo& v)
"Are you sure you want to remove the following installed add-ons?",
remove_ids.size()) + list_lead + utils::bullet_list(remove_names);

res = gui2::show_message(v
, _("Confirm")
res = gui2::show_message(
_("Confirm")
, confirm_message
, gui2::dialogs::message::yes_no_buttons);
} while (res != gui2::window::OK);
Expand All @@ -196,11 +195,11 @@ bool uninstall_local_addons(CVideo& v)
skipped_names.size());

gui2::show_error_message(
v, dlg_msg + list_lead + utils::bullet_list(skipped_names));
dlg_msg + list_lead + utils::bullet_list(skipped_names));
}

if(!failed_names.empty()) {
gui2::show_error_message(v, _n(
gui2::show_error_message(_n(
"The following add-on could not be deleted properly:",
"The following add-ons could not be deleted properly:",
failed_names.size()) + list_lead + utils::bullet_list(failed_names));
Expand All @@ -215,7 +214,7 @@ bool uninstall_local_addons(CVideo& v)
succeeded_names.size());

gui2::show_transient_message(
v, dlg_title,
dlg_title,
dlg_msg + list_lead + utils::bullet_list(succeeded_names), "", false, false, true);

return true;
Expand All @@ -236,7 +235,7 @@ bool manage_addons(CVideo& v)
const bool have_addons = !installed_addons().empty();

gui2::dialogs::addon_connect addon_dlg(host_name, have_addons);
addon_dlg.show(v);
addon_dlg.show();
int res = addon_dlg.get_retval();

if(res == gui2::window::OK) {
Expand All @@ -247,7 +246,7 @@ bool manage_addons(CVideo& v)
case addon_download:
return addons_manager_ui(v, host_name);
case addon_uninstall:
return uninstall_local_addons(v);
return uninstall_local_addons();
default:
return false;
}
Expand All @@ -266,7 +265,7 @@ bool ad_hoc_addon_fetch_session(CVideo& v, const std::vector<std::string>& addon
addons_list addons;

if(!get_addons_list(client, addons)) {
gui2::show_error_message(v, _("An error occurred while downloading the add-ons list from the server."));
gui2::show_error_message(_("An error occurred while downloading the add-ons list from the server."));
return false;
}

Expand All @@ -280,7 +279,7 @@ bool ad_hoc_addon_fetch_session(CVideo& v, const std::vector<std::string>& addon
} else {
utils::string_map symbols;
symbols["addon_id"] = addon_id;
gui2::show_error_message(v, vgettext("Could not find an add-on matching id $addon_id on the add-on server.", symbols));
gui2::show_error_message(vgettext("Could not find an add-on matching id $addon_id on the add-on server.", symbols));
return_value = false;
}
}
Expand All @@ -289,28 +288,28 @@ bool ad_hoc_addon_fetch_session(CVideo& v, const std::vector<std::string>& addon

} catch(const config::error& e) {
ERR_CFG << "config::error thrown during transaction with add-on server; \""<< e.message << "\"" << std::endl;
gui2::show_error_message(v, _("Network communication error."));
gui2::show_error_message(_("Network communication error."));
} catch(const network_asio::error& e) {
ERR_NET << "network_asio::error thrown during transaction with add-on server; \""<< e.what() << "\"" << std::endl;
gui2::show_error_message(v, _("Remote host disconnected."));
gui2::show_error_message(_("Remote host disconnected."));
} catch(const filesystem::io_exception& e) {
ERR_FS << "io_exception thrown while installing an addon; \"" << e.what() << "\"" << std::endl;
gui2::show_error_message(v, _("A problem occurred when trying to create the files necessary to install this add-on."));
gui2::show_error_message(_("A problem occurred when trying to create the files necessary to install this add-on."));
} catch(const invalid_pbl_exception& e) {
ERR_CFG << "could not read .pbl file " << e.path << ": " << e.message << std::endl;

utils::string_map symbols;
symbols["path"] = e.path;
symbols["msg"] = e.message;

gui2::show_error_message(v,
gui2::show_error_message(
vgettext("A local file with add-on publishing information could not be read.\n\nFile: $path\nError message: $msg", symbols));
} catch(wml_exception& e) {
e.show(v);
e.show();
} catch(const addons_client::user_exit&) {
LOG_AC << "initial connection canceled by user\n";
} catch(const addons_client::invalid_server_address&) {
gui2::show_error_message(v, _("The add-ons server address specified is not valid."));
gui2::show_error_message(_("The add-ons server address specified is not valid."));
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion src/editor/action/mouse/mouse_action_map_label.cpp
Expand Up @@ -83,7 +83,7 @@ editor_action* mouse_action_map_label::up_left(editor_display& disp, int x, int
gui2::dialogs::editor_edit_label d(label, immutable, visible_fog, visible_shroud, color, category);

editor_action* a = nullptr;
if(d.show(disp.video())) {
if(d.show()) {
a = new editor_action_label(hex, label, team_name, color
, visible_fog, visible_shroud, immutable, category);
update_brush_highlights(disp, hex);
Expand Down
15 changes: 7 additions & 8 deletions src/editor/controller/editor_controller.cpp
Expand Up @@ -174,10 +174,10 @@ EXIT_STATUS editor_controller::main_loop()
play_slice();
}
} catch (editor_exception& e) {
gui2::show_transient_message(gui().video(), _("Fatal error"), e.what());
gui2::show_transient_message(_("Fatal error"), e.what());
return EXIT_ERROR;
} catch (wml_exception& e) {
e.show(gui().video());
e.show();
}
return quit_mode_;
}
Expand All @@ -192,7 +192,7 @@ void editor_controller::do_screenshot(const std::string& screenshot_filename /*
ERR_ED << "Screenshot creation failed!\n";
}
} catch (wml_exception& e) {
e.show(gui().video());
e.show();
}
}

Expand All @@ -216,14 +216,13 @@ bool editor_controller::quit_confirm()
void editor_controller::custom_tods_dialog()
{
if (tods_.empty()) {
gui2::show_error_message(gui().video(),
_("No editor time-of-day found."));
gui2::show_error_message(_("No editor time-of-day found."));
return;
}

tod_manager& manager = *get_current_map_context().get_time_manager();

if(gui2::dialogs::custom_tod::execute(manager.times(), manager.get_current_time(), gui().video())) {
if(gui2::dialogs::custom_tod::execute(manager.times(), manager.get_current_time())) {
// TODO save the new tod here
}

Expand Down Expand Up @@ -1143,7 +1142,7 @@ void editor_controller::change_unit_id()

if(un != units.end()) {
std::string id = un->id();
if (gui2::dialogs::edit_text::execute(title, label, id, gui_->video())) {
if (gui2::dialogs::edit_text::execute(title, label, id)) {
un->set_id(id);
}
}
Expand All @@ -1160,7 +1159,7 @@ void editor_controller::rename_unit()

if(un != units.end()) {
std::string name = un->name();
if(gui2::dialogs::edit_text::execute(title, label, name, gui_->video())) {
if(gui2::dialogs::edit_text::execute(title, label, name)) {
//TODO we may not want a translated name here.
un->set_name(name);
}
Expand Down

0 comments on commit 7fad714

Please sign in to comment.