summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-09-28 21:58:06 +0000
committerterkhen <terkhen@openttd.org>2010-09-28 21:58:06 +0000
commit897bb71621ef72490bd8667ab02355fdb40817fb (patch)
tree76405ce8d18b158ef51161dce524a2b8e2add301
parent97c0b40ab764f1ba08b6a3d0bad3169da06bd0f1 (diff)
downloadopenttd-897bb71621ef72490bd8667ab02355fdb40817fb.tar.xz
(svn r20856) -Fix [FS#4141]: Road/water toolbars did not get updated when the first vehicle of their type becomes available.
-rw-r--r--src/dock_gui.cpp11
-rw-r--r--src/engine.cpp8
-rw-r--r--src/road_gui.cpp15
3 files changed, 28 insertions, 6 deletions
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 069fd3bbb..7062a6456 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -173,6 +173,7 @@ struct BuildDocksToolbarWindow : Window {
BuildDocksToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
{
this->InitNested(desc, window_number);
+ this->OnInvalidateData();
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
}
@@ -181,9 +182,17 @@ struct BuildDocksToolbarWindow : Window {
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
}
+ void OnInvalidateData(int data = 0)
+ {
+ this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP),
+ DTW_DEPOT,
+ DTW_STATION,
+ DTW_BUOY,
+ WIDGET_LIST_END);
+ }
+
virtual void OnPaint()
{
- this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), DTW_DEPOT, DTW_STATION, DTW_BUOY, WIDGET_LIST_END);
this->DrawWidgets();
}
diff --git a/src/engine.cpp b/src/engine.cpp
index e03d81cbf..e563ac9f5 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -605,6 +605,10 @@ static void AcceptEnginePreview(EngineID eid, CompanyID company)
if (company == _local_company) {
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
}
+
+ /* Update the toolbar. */
+ if (e->type == VEH_ROAD) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_ROAD);
+ if (e->type == VEH_SHIP) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_WATER);
}
/**
@@ -749,6 +753,10 @@ static void NewVehicleAvailable(Engine *e)
SetDParam(0, GetEngineCategoryName(index));
SetDParam(1, index);
AddNewsItem(STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE, NS_NEW_VEHICLES, NR_ENGINE, index);
+
+ /* Update the toolbar. */
+ if (e->type == VEH_ROAD) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_ROAD);
+ if (e->type == VEH_SHIP) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_WATER);
}
void EnginesMonthlyLoop()
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 7fc5152fa..71a568fca 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -457,11 +457,7 @@ struct BuildRoadToolbarWindow : Window {
RTW_ONE_WAY,
WIDGET_LIST_END);
- this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD),
- RTW_DEPOT,
- RTW_BUS_STATION,
- RTW_TRUCK_STATION,
- WIDGET_LIST_END);
+ this->OnInvalidateData();
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
}
@@ -471,6 +467,15 @@ struct BuildRoadToolbarWindow : Window {
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
}
+ void OnInvalidateData(int data = 0)
+ {
+ this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD),
+ RTW_DEPOT,
+ RTW_BUS_STATION,
+ RTW_TRUCK_STATION,
+ WIDGET_LIST_END);
+ }
+
/**
* Update the remove button lowered state of the road toolbar
*