diff options
author | frosch <frosch@openttd.org> | 2012-12-09 16:53:21 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-12-09 16:53:21 +0000 |
commit | 04a24969eaaa98a39e34957b450c5d1958ec8c84 (patch) | |
tree | 315f813f0f092d96ca077acc30d4c05c6d630d10 | |
parent | fccf0ac84dae8c23ba9b55b4b2200d07530ba28c (diff) | |
download | openttd-04a24969eaaa98a39e34957b450c5d1958ec8c84.tar.xz |
(svn r24806) -Feature [FS#3148]: Ask for confirmation before creating giant screenshots.
-rw-r--r-- | src/lang/english.txt | 3 | ||||
-rw-r--r-- | src/toolbar_gui.cpp | 56 |
2 files changed, 40 insertions, 19 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt index 53a489dac..0baa88f1b 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -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! diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 0f71ade24..9b5879c85 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -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() -{ - MakeScreenshot(SC_ZOOMEDIN, NULL); -} - -static void MenuClickDefaultZoomScreenshot() +/** + * 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_DEFAULTZOOM, NULL); + if (confirmed) MakeScreenshot(_confirmed_screenshot_type, NULL); } -static void MenuClickWorldScreenshot() -{ - MakeScreenshot(SC_WORLD, NULL); +/** + * 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) +{ + 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; |