summaryrefslogtreecommitdiff
path: root/src/screenshot_gui.cpp
diff options
context:
space:
mode:
authorTechGeekNZ <git@tech.geek.nz>2020-06-18 09:50:22 +1200
committerCharles Pigott <charlespigott@googlemail.com>2020-06-27 14:19:35 +0100
commited6f31f601ef92e098f5555e9bb2b1492c5a7e79 (patch)
tree540359b092a9c4bed40f948037c3027262129e02 /src/screenshot_gui.cpp
parenta2e1102b15cd7f5ae86ab3ea5da4a534b6b58389 (diff)
downloadopenttd-ed6f31f601ef92e098f5555e9bb2b1492c5a7e79.tar.xz
Cleanup: Remove redundant implementation of TakeScreenshot
Diffstat (limited to 'src/screenshot_gui.cpp')
-rw-r--r--src/screenshot_gui.cpp50
1 files changed, 8 insertions, 42 deletions
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);
}