summaryrefslogtreecommitdiff
path: root/src/station_gui.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2019-02-22 18:14:06 +0000
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-04-25 09:14:01 +0200
commitb6733edd172cb8488f81245addf613152f8a8015 (patch)
tree3f047d32e02f23a8e41bda2307c913daad24073f /src/station_gui.cpp
parent37daf430379610536b5725fabd07847907499d41 (diff)
downloadopenttd-b6733edd172cb8488f81245addf613152f8a8015.tar.xz
Feature: Add coverage area display for existing stations.
Diffstat (limited to 'src/station_gui.cpp')
-rw-r--r--src/station_gui.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 4e6b94caf..1cc6a126f 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -785,6 +785,7 @@ static const NWidgetPart _nested_station_view_widgets[] = {
EndContainer(),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SV_CLOSE_AIRPORT), SetMinimalSize(45, 12), SetResize(1, 0), SetFill(1, 1),
SetDataTip(STR_STATION_VIEW_CLOSE_AIRPORT, STR_STATION_VIEW_CLOSE_AIRPORT_TOOLTIP),
+ NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SV_CATCHMENT), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_BUTTON_CATCHMENT, STR_TOOLTIP_CATCHMENT),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SV_TRAINS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_TRAIN, STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SV_ROADVEHS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_LORRY, STR_STATION_VIEW_SCHEDULED_ROAD_VEHICLES_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SV_SHIPS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP),
@@ -1313,6 +1314,8 @@ struct StationViewWindow : public Window {
DeleteWindowById(WC_ROADVEH_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_ROAD, this->owner, this->window_number).Pack(), false);
DeleteWindowById(WC_SHIPS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_SHIP, this->owner, this->window_number).Pack(), false);
DeleteWindowById(WC_AIRCRAFT_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_AIRCRAFT, this->owner, this->window_number).Pack(), false);
+
+ SetViewportCatchmentStation(Station::Get(this->window_number), false);
}
/**
@@ -1402,6 +1405,10 @@ struct StationViewWindow : public Window {
this->SetWidgetDisabledState(WID_SV_CLOSE_AIRPORT, !(st->facilities & FACIL_AIRPORT) || st->owner != _local_company || st->owner == OWNER_NONE); // Also consider SE, where _local_company == OWNER_NONE
this->SetWidgetLoweredState(WID_SV_CLOSE_AIRPORT, (st->facilities & FACIL_AIRPORT) && (st->airport.flags & AIRPORT_CLOSED_block) != 0);
+ extern const Station *_viewport_highlight_station;
+ this->SetWidgetDisabledState(WID_SV_CATCHMENT, st->facilities == FACIL_NONE);
+ this->SetWidgetLoweredState(WID_SV_CATCHMENT, _viewport_highlight_station == st);
+
this->DrawWidgets();
if (!this->IsShaded()) {
@@ -1883,6 +1890,10 @@ struct StationViewWindow : public Window {
this->HandleCargoWaitingClick(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SV_WAITING, WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL) - this->vscroll->GetPosition());
break;
+ case WID_SV_CATCHMENT:
+ SetViewportCatchmentStation(Station::Get(this->window_number), !this->IsWidgetLowered(WID_SV_CATCHMENT));
+ break;
+
case WID_SV_LOCATION:
if (_ctrl_pressed) {
ShowExtraViewPortWindow(Station::Get(this->window_number)->xy);
@@ -2247,6 +2258,11 @@ struct SelectStationWindow : Window {
this->OnInvalidateData(0);
}
+ ~SelectStationWindow()
+ {
+ if (_settings_client.gui.station_show_coverage) SetViewportCatchmentStation(nullptr, true);
+ }
+
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget != WID_JS_PANEL) return;