summaryrefslogtreecommitdiff
path: root/src/town_gui.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2019-03-30 16:59:43 +0000
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-04-25 09:14:01 +0200
commit81d335b081db006ddb883e2452f73984442f9823 (patch)
tree619035d47c5c68f12c8e796a803cd4c7c6e4576c /src/town_gui.cpp
parent81f0f9740690d0f3307d946d848375e269c8d2ee (diff)
downloadopenttd-81d335b081db006ddb883e2452f73984442f9823.tar.xz
Feature: Add station coverage area display for towns.
Diffstat (limited to 'src/town_gui.cpp')
-rw-r--r--src/town_gui.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 07f0d638d..ebc696994 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -321,11 +321,24 @@ public:
this->SetWidgetDisabledState(WID_TV_CHANGE_NAME, _networking && !_network_server);
}
+ ~TownViewWindow()
+ {
+ SetViewportCatchmentTown(Town::Get(this->window_number), false);
+ }
+
void SetStringParameters(int widget) const override
{
if (widget == WID_TV_CAPTION) SetDParam(0, this->town->index);
}
+ void OnPaint() override
+ {
+ extern const Town *_viewport_highlight_town;
+ this->SetWidgetLoweredState(WID_TV_CATCHMENT, _viewport_highlight_town == this->town);
+
+ this->DrawWidgets();
+ }
+
void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_TV_INFO) return;
@@ -432,6 +445,10 @@ public:
ShowQueryString(STR_TOWN_NAME, STR_TOWN_VIEW_RENAME_TOWN_BUTTON, MAX_LENGTH_TOWN_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
break;
+ case WID_TV_CATCHMENT:
+ SetViewportCatchmentTown(Town::Get(this->window_number), !this->IsWidgetLowered(WID_TV_CATCHMENT));
+ break;
+
case WID_TV_EXPAND: { // expand town - only available on Scenario editor
/* Warn the user if towns are not allowed to build roads, but do this only once per OpenTTD run. */
static bool _warn_town_no_roads = false;
@@ -552,6 +569,7 @@ static const NWidgetPart _nested_town_game_view_widgets[] = {
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_SHOW_AUTHORITY), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_TOWN_VIEW_LOCAL_AUTHORITY_BUTTON, STR_TOWN_VIEW_LOCAL_AUTHORITY_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CHANGE_NAME), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_RENAME, STR_TOWN_VIEW_RENAME_TOOLTIP),
EndContainer(),
+ NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_TV_CATCHMENT), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_BUTTON_CATCHMENT, STR_TOOLTIP_CATCHMENT),
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
EndContainer(),
};