summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2020-12-27 23:18:25 +0100
committerfrosch <github@elsenhans.name>2021-01-11 22:15:58 +0100
commit1432dbac53aba7c71d12633a0272d64190551d6e (patch)
treee9aefbe09b6eeb641e83143f1422d1d60b0dba09
parent5bfcd742b8220e291f7c1e034c3771915476eb85 (diff)
downloadopenttd-1432dbac53aba7c71d12633a0272d64190551d6e.tar.xz
Add: another go-to-location button to the sign window.
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/signs_gui.cpp13
-rw-r--r--src/widgets/sign_widget.h1
3 files changed, 15 insertions, 0 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 1076a77f3..99025ae62 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3100,6 +3100,7 @@ STR_SIGN_LIST_MATCH_CASE_TOOLTIP :{BLACK}Toggle m
# Sign window
STR_EDIT_SIGN_CAPTION :{WHITE}Edit sign text
+STR_EDIT_SIGN_LOCATION_TOOLTIP :{BLACK}Centre the main view on sign location. Ctrl+Click opens a new viewport on sign location
STR_EDIT_SIGN_NEXT_SIGN_TOOLTIP :{BLACK}Go to next sign
STR_EDIT_SIGN_PREVIOUS_SIGN_TOOLTIP :{BLACK}Go to previous sign
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 39f209a36..e3b270fbf 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -25,6 +25,7 @@
#include "core/geometry_func.hpp"
#include "hotkeys.h"
#include "transparency.h"
+#include "gui.h"
#include "widgets/sign_widget.h"
@@ -486,6 +487,17 @@ struct SignWindow : Window, SignList {
void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
+ case WID_QES_LOCATION: {
+ const Sign *si = Sign::Get(this->cur_sign);
+ TileIndex tile = TileVirtXY(si->x, si->y);
+ if (_ctrl_pressed) {
+ ShowExtraViewportWindow(tile);
+ } else {
+ ScrollMainWindowToTile(tile);
+ }
+ break;
+ }
+
case WID_QES_PREVIOUS:
case WID_QES_NEXT: {
const Sign *si = this->PrevNextSign(widget == WID_QES_NEXT);
@@ -523,6 +535,7 @@ static const NWidgetPart _nested_query_sign_edit_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_QES_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
+ NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_QES_LOCATION), SetMinimalSize(12, 14), SetDataTip(SPR_GOTO_LOCATION, STR_EDIT_SIGN_LOCATION_TOOLTIP),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QES_TEXT), SetMinimalSize(256, 12), SetDataTip(STR_EDIT_SIGN_SIGN_OSKTITLE, STR_NULL), SetPadding(2, 2, 2, 2),
diff --git a/src/widgets/sign_widget.h b/src/widgets/sign_widget.h
index 2225eb8b1..1a05dd349 100644
--- a/src/widgets/sign_widget.h
+++ b/src/widgets/sign_widget.h
@@ -24,6 +24,7 @@ enum SignListWidgets {
/** Widgets of the #SignWindow class. */
enum QueryEditSignWidgets {
WID_QES_CAPTION, ///< Caption of the window.
+ WID_QES_LOCATION, ///< Scroll to sign location.
WID_QES_TEXT, ///< Text of the query.
WID_QES_OK, ///< OK button.
WID_QES_CANCEL, ///< Cancel button.