(svn r24806) -Feature [FS#3148]: Ask for confirmation before creating giant screenshots.

This commit is contained in:
frosch 2012-12-09 16:53:21 +00:00
parent e19ba0f72a
commit 44b1a558d0
2 changed files with 39 additions and 18 deletions

View File

@ -3826,6 +3826,9 @@ STR_WARNING_HEIGHTMAP_SCALE_MESSAGE :{YELLOW}Resizin
STR_WARNING_FALLBACK_SOUNDSET :{WHITE}Only a fallback sound set was found. If you want sounds, install a sound set via the content download system
# Screenshot related messages
STR_WARNING_SCREENSHOT_SIZE_CAPTION :{WHITE}Huge screenshot
STR_WARNING_SCREENSHOT_SIZE_MESSAGE :{YELLOW}The screenshot will have a resolution of {COMMA} x {COMMA} pixels. Taking the screenshot may take a while. Do you want to continue?
STR_MESSAGE_SCREENSHOT_SUCCESSFULLY :{WHITE}Screenshot successfully saved as '{RAW_STRING}'
STR_ERROR_SCREENSHOT_FAILED :{WHITE}Screenshot failed!

View File

@ -53,6 +53,8 @@
RailType _last_built_railtype;
RoadType _last_built_roadtype;
static ScreenshotType _confirmed_screenshot_type; ///< Screenshot type the current query is about to confirm.
/** Toobar modes */
enum ToolbarMode {
TB_NORMAL,
@ -958,19 +960,35 @@ static void MenuClickSmallScreenshot()
MakeScreenshot(SC_VIEWPORT, NULL);
}
static void MenuClickZoomedInScreenshot()
/**
* Callback on the confirmation window for huge screenshots.
* @param w Window with viewport
* @param confirmed true on confirmation
*/
static void ScreenshotConfirmCallback(Window *w, bool confirmed)
{
MakeScreenshot(SC_ZOOMEDIN, NULL);
if (confirmed) MakeScreenshot(_confirmed_screenshot_type, NULL);
}
static void MenuClickDefaultZoomScreenshot()
/**
* Make a screenshot of the world.
* Ask for confirmation if the screenshot will be huge.
* @param t Screenshot type: World or viewport screenshot
*/
static void MenuClickLargeWorldScreenshot(ScreenshotType t)
{
MakeScreenshot(SC_DEFAULTZOOM, NULL);
}
static void MenuClickWorldScreenshot()
{
MakeScreenshot(SC_WORLD, NULL);
ViewPort vp;
SetupScreenshotViewport(t, &vp);
if (vp.width * vp.height > 8192 * 8192) {
/* Ask for confirmation */
SetDParam(0, vp.width);
SetDParam(1, vp.height);
_confirmed_screenshot_type = t;
ShowQuery(STR_WARNING_SCREENSHOT_SIZE_CAPTION, STR_WARNING_SCREENSHOT_SIZE_MESSAGE, NULL, ScreenshotConfirmCallback);
} else {
/* Less than 4M pixels, just do it */
MakeScreenshot(t, NULL);
}
}
/**
@ -1019,9 +1037,9 @@ static CallBackFunction MenuClickHelp(int index)
case 2: IConsoleSwitch(); break;
case 3: ShowAIDebugWindow(); break;
case 4: MenuClickSmallScreenshot(); break;
case 5: MenuClickZoomedInScreenshot(); break;
case 6: MenuClickDefaultZoomScreenshot(); break;
case 7: MenuClickWorldScreenshot(); break;
case 5: MenuClickLargeWorldScreenshot(SC_ZOOMEDIN); break;
case 6: MenuClickLargeWorldScreenshot(SC_DEFAULTZOOM); break;
case 7: MenuClickLargeWorldScreenshot(SC_WORLD); break;
case 8: ShowAboutWindow(); break;
case 9: ShowSpriteAlignerWindow(); break;
case 10: ToggleBoundingBoxes(); break;
@ -1599,9 +1617,9 @@ struct MainToolbarWindow : Window {
case MTHK_MUSIC: ShowMusicWindow(); break;
case MTHK_AI_DEBUG: ShowAIDebugWindow(); break;
case MTHK_SMALL_SCREENSHOT: MenuClickSmallScreenshot(); break;
case MTHK_ZOOMEDIN_SCREENSHOT: MenuClickZoomedInScreenshot(); break;
case MTHK_DEFAULTZOOM_SCREENSHOT: MenuClickDefaultZoomScreenshot(); break;
case MTHK_GIANT_SCREENSHOT: MenuClickWorldScreenshot(); break;
case MTHK_ZOOMEDIN_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_ZOOMEDIN); break;
case MTHK_DEFAULTZOOM_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_DEFAULTZOOM); break;
case MTHK_GIANT_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_WORLD); break;
case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
case MTHK_TERRAFORM: ShowTerraformToolbar(); break;
case MTHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break;
@ -1924,9 +1942,9 @@ struct ScenarioEditorToolbarWindow : Window {
case MTEHK_MUSIC: ShowMusicWindow(); break;
case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo(); break;
case MTEHK_SMALL_SCREENSHOT: MenuClickSmallScreenshot(); break;
case MTEHK_ZOOMEDIN_SCREENSHOT: MenuClickZoomedInScreenshot(); break;
case MTEHK_DEFAULTZOOM_SCREENSHOT: MenuClickDefaultZoomScreenshot(); break;
case MTEHK_GIANT_SCREENSHOT: MenuClickWorldScreenshot(); break;
case MTEHK_ZOOMEDIN_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_ZOOMEDIN); break;
case MTEHK_DEFAULTZOOM_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_DEFAULTZOOM); break;
case MTEHK_GIANT_SCREENSHOT: MenuClickLargeWorldScreenshot(SC_WORLD); break;
case MTEHK_ZOOM_IN: ToolbarZoomInClick(this); break;
case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
case MTEHK_TERRAFORM: ShowEditorTerraformToolbar(); break;