From ed6f31f601ef92e098f5555e9bb2b1492c5a7e79 Mon Sep 17 00:00:00 2001 From: TechGeekNZ Date: Thu, 18 Jun 2020 09:50:22 +1200 Subject: Cleanup: Remove redundant implementation of TakeScreenshot --- src/screenshot_gui.cpp | 50 ++++++++------------------------------------------ 1 file changed, 8 insertions(+), 42 deletions(-) (limited to 'src/screenshot_gui.cpp') diff --git a/src/screenshot_gui.cpp b/src/screenshot_gui.cpp index 323002024..ae5854fb7 100644 --- a/src/screenshot_gui.cpp +++ b/src/screenshot_gui.cpp @@ -8,31 +8,26 @@ /** @file screenshot_gui.cpp GUI functions related to screenshots. */ #include "stdafx.h" -#include "gui.h" -#include "viewport_func.h" #include "window_func.h" #include "window_gui.h" #include "screenshot.h" -#include "textbuf_gui.h" -#include "strings_func.h" - #include "widgets/screenshot_widget.h" - #include "table/strings.h" -static ScreenshotType _screenshot_type; - struct ScreenshotWindow : Window { - ScreenshotWindow(WindowDesc *desc) : Window(desc) { + ScreenshotWindow(WindowDesc *desc) : Window(desc) + { this->CreateNestedTree(); this->FinishInitNested(); } - void OnPaint() override { + void OnPaint() override + { this->DrawWidgets(); } - void OnClick(Point pt, int widget, int click_count) override { + void OnClick(Point pt, int widget, int click_count) override + { if (widget < 0) return; ScreenshotType st; switch (widget) { @@ -46,36 +41,6 @@ struct ScreenshotWindow : Window { } TakeScreenshot(st); } - - /** - * Make a screenshot. - * Ask for confirmation if the screenshot will be huge. - * @param t Screenshot type: World, defaultzoom, heightmap or viewport screenshot - */ - static void TakeScreenshot(ScreenshotType st) { - ViewPort vp; - SetupScreenshotViewport(st, &vp); - if ((uint64)vp.width * (uint64)vp.height > 8192 * 8192) { - /* Ask for confirmation */ - _screenshot_type = st; - SetDParam(0, vp.width); - SetDParam(1, vp.height); - ShowQuery(STR_WARNING_SCREENSHOT_SIZE_CAPTION, STR_WARNING_SCREENSHOT_SIZE_MESSAGE, nullptr, ScreenshotConfirmationCallback); - } - else { - /* Less than 64M pixels, just do it */ - MakeScreenshot(st, nullptr); - } - } - - /** - * Callback on the confirmation window for huge screenshots. - * @param w Window with viewport - * @param confirmed true on confirmation - */ - static void ScreenshotConfirmationCallback(Window *w, bool confirmed) { - if (confirmed) MakeScreenshot(_screenshot_type, nullptr); - } }; static const NWidgetPart _nested_screenshot[] = { @@ -102,7 +67,8 @@ static WindowDesc _screenshot_window_desc( _nested_screenshot, lengthof(_nested_screenshot) ); -void ShowScreenshotWindow() { +void ShowScreenshotWindow() +{ DeleteWindowById(WC_SCREENSHOT, 0); new ScreenshotWindow(&_screenshot_window_desc); } -- cgit v1.2.3-54-g00ecf