2019-04-29 14:58:15 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file screenshot_gui.cpp GUI functions related to screenshots. */
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "window_func.h"
|
|
|
|
#include "window_gui.h"
|
|
|
|
#include "screenshot.h"
|
|
|
|
#include "widgets/screenshot_widget.h"
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
|
|
|
struct ScreenshotWindow : Window {
|
2020-06-17 21:50:22 +00:00
|
|
|
ScreenshotWindow(WindowDesc *desc) : Window(desc)
|
|
|
|
{
|
2019-04-29 14:58:15 +00:00
|
|
|
this->CreateNestedTree();
|
|
|
|
this->FinishInitNested();
|
|
|
|
}
|
|
|
|
|
2020-06-17 21:50:22 +00:00
|
|
|
void OnPaint() override
|
|
|
|
{
|
2019-04-29 14:58:15 +00:00
|
|
|
this->DrawWidgets();
|
|
|
|
}
|
|
|
|
|
2020-06-17 21:50:22 +00:00
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
|
|
|
{
|
2019-04-29 14:58:15 +00:00
|
|
|
if (widget < 0) return;
|
|
|
|
ScreenshotType st;
|
|
|
|
switch (widget) {
|
|
|
|
default:
|
|
|
|
case WID_SC_TAKE: st = SC_VIEWPORT; break;
|
|
|
|
case WID_SC_TAKE_ZOOMIN: st = SC_ZOOMEDIN; break;
|
|
|
|
case WID_SC_TAKE_DEFAULTZOOM: st = SC_DEFAULTZOOM; break;
|
|
|
|
case WID_SC_TAKE_WORLD: st = SC_WORLD; break;
|
2021-03-06 02:33:02 +00:00
|
|
|
case WID_SC_TAKE_WORLD_ZOOM: st = SC_WORLD_ZOOM; break;
|
2019-04-29 14:58:15 +00:00
|
|
|
case WID_SC_TAKE_HEIGHTMAP: st = SC_HEIGHTMAP; break;
|
2020-01-04 16:47:37 +00:00
|
|
|
case WID_SC_TAKE_MINIMAP: st = SC_MINIMAP; break;
|
2021-06-11 18:14:56 +00:00
|
|
|
case WID_SC_TAKE_TOPOGRAPHY: st = SC_TOPOGRAPHY; break;
|
|
|
|
case WID_SC_TAKE_INDUSTRY: st = SC_INDUSTRY; break;
|
2019-04-29 14:58:15 +00:00
|
|
|
}
|
2020-06-20 05:12:31 +00:00
|
|
|
MakeScreenshotWithConfirm(st);
|
2019-04-29 14:58:15 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const NWidgetPart _nested_screenshot[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_SCREENSHOT_CAPTION, 0),
|
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_VERTICAL, NC_EQUALSIZE),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_ZOOMIN), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_ZOOMIN_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_DEFAULTZOOM), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_DEFAULTZOOM_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_WORLD), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_WORLD_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
|
2021-03-06 02:33:02 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_WORLD_ZOOM), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_WORLD_SCREENSHOT_CURRENT_ZOOM, 0), SetMinimalTextLines(2, 0),
|
2019-04-29 14:58:15 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_HEIGHTMAP), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_HEIGHTMAP_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
|
2020-01-04 16:47:37 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_MINIMAP), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_MINIMAP_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
|
2021-06-11 18:14:56 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_TOPOGRAPHY), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_TOPOGRAPHY_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SC_TAKE_INDUSTRY), SetFill(1, 1), SetDataTip(STR_SCREENSHOT_INDUSTRY_SCREENSHOT, 0), SetMinimalTextLines(2, 0),
|
2019-04-29 14:58:15 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
|
|
|
static WindowDesc _screenshot_window_desc(
|
|
|
|
WDP_AUTO, "take_a_screenshot", 200, 100,
|
|
|
|
WC_SCREENSHOT, WC_NONE,
|
|
|
|
0,
|
|
|
|
_nested_screenshot, lengthof(_nested_screenshot)
|
|
|
|
);
|
|
|
|
|
2020-06-17 21:50:22 +00:00
|
|
|
void ShowScreenshotWindow()
|
|
|
|
{
|
2019-04-29 14:58:15 +00:00
|
|
|
DeleteWindowById(WC_SCREENSHOT, 0);
|
|
|
|
new ScreenshotWindow(&_screenshot_window_desc);
|
|
|
|
}
|
2020-08-06 19:43:33 +00:00
|
|
|
|
|
|
|
void SetScreenshotWindowHidden(bool hidden)
|
|
|
|
{
|
|
|
|
ScreenshotWindow *scw = (ScreenshotWindow *) FindWindowById(WC_SCREENSHOT, 0);
|
|
|
|
if (scw != nullptr) {
|
|
|
|
if (hidden) {
|
|
|
|
scw->SetDirtyAsBlocks();
|
|
|
|
SetBit(scw->left, 30);
|
|
|
|
} else {
|
|
|
|
ClrBit(scw->left, 30);
|
|
|
|
scw->SetDirtyAsBlocks();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|