Skip to content

Commit

Permalink
ui: Check whether screenshot creation succeeded and report otherwise
Browse files Browse the repository at this point in the history
This displays an actual error message in the UI if screenshot creation
fails, instead of just saying "Screenshot Done" and assuming the best
(???).

NOTE: I could make it so display::screenshot() returns an object
including both the operation's result and the SDL_GetError text if
applicable, but I don't see the point for complicating this code further
right now, since it's relatively rare for screenshot creation to fail.
Furthermore, SDL_GetError's text is not translatable, which is a major
inconvenience for us.

The current error message is horribly general in scope and may not
accurately represent the actual issue at hand, but I think it's better
than asking users to check "the log" (which basic users don't really
know about) and read text that they might not even understand if they
don't know English. Someone who really wants to know what's going on
will ask us for help and we'll tell them how to access the log with
details anyway.
  • Loading branch information
irydacea committed Apr 10, 2015
1 parent a62914e commit 1c0ead2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/hotkey/command_executor.cpp
Expand Up @@ -649,11 +649,13 @@ void execute_command(display& disp, const hotkey_command& command, command_execu
std::string ext = ".bmp";
#endif
filename = filesystem::get_next_filename(filename, ext);
int size = disp.screenshot(filename, map_screenshot);
if (size > 0) {
const bool res = disp.screenshot(filename, map_screenshot);
if (res) {
gui2::tscreenshot_notification::display(filename, disp.video());
} else {
gui2::show_message(disp.video(), _("Screenshot Done"), "");
gui2::show_error_message(disp.video(),
_("Screenshot creation failed.\n\n"
"Make sure there is enough space on the drive holding Wesnoth’s player resource files and that file permissions are set up correctly."));
}
break;
}
Expand Down

0 comments on commit 1c0ead2

Please sign in to comment.