summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoradf88 <adf88@openttd.org>2017-08-31 06:48:55 +0000
committeradf88 <adf88@openttd.org>2017-08-31 06:48:55 +0000
commit74e1fe130c8d7292771e3374180190e5a28e5175 (patch)
tree5f6f212280c0a1c55e067e6cd96f1aa5ee1a9b74 /src
parent88726f71b615b2f1c7525c4e62bf52c535b08f51 (diff)
downloadopenttd-74e1fe130c8d7292771e3374180190e5a28e5175.tar.xz
(svn r27905) -Fix [FS#6585]: Keep the "link" between industry chain and smallmap windows whenever possible
Diffstat (limited to 'src')
-rw-r--r--src/smallmap_gui.cpp19
-rw-r--r--src/smallmap_gui.h3
2 files changed, 18 insertions, 4 deletions
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 0bb2997e5..4ea887c06 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -572,6 +572,12 @@ static const byte _vehicle_type_colours[6] = {
};
+/** Notify the industry chain window to stop sending newly selected industries. */
+/* static */ void SmallMapWindow::BreakIndustryChainLink()
+{
+ InvalidateWindowClassesData(WC_INDUSTRY_CARGOES, NUM_INDUSTRYTYPES);
+}
+
inline Point SmallMapWindow::SmallmapRemapCoords(int x, int y) const
{
Point pt;
@@ -1069,6 +1075,12 @@ SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(des
this->SetOverlayCargoMask();
}
+SmallMapWindow::~SmallMapWindow()
+{
+ delete this->overlay;
+ this->BreakIndustryChainLink();
+}
+
/**
* Rebuilds the colour indices used for fast access to the smallmap contour colours based on the heightlevel.
*/
@@ -1278,6 +1290,7 @@ void SmallMapWindow::SwitchMapType(SmallMapType map_type)
this->SetupWidgetData();
if (map_type == SMT_LINKSTATS) this->overlay->RebuildCache();
+ if (map_type != SMT_INDUSTRY) this->BreakIndustryChainLink();
this->SetDirty();
}
@@ -1329,6 +1342,8 @@ void SmallMapWindow::SelectLegendItem(int click_pos, LegendAndColour *legend, in
} else {
legend[click_pos].show_on_map = !legend[click_pos].show_on_map;
}
+
+ if (this->map_type == SMT_INDUSTRY) this->BreakIndustryChainLink();
}
/**
@@ -1383,9 +1398,6 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
/* virtual */ void SmallMapWindow::OnClick(Point pt, int widget, int click_count)
{
- /* User clicked something, notify the industry chain window to stop sending newly selected industries. */
- InvalidateWindowClassesData(WC_INDUSTRY_CARGOES, NUM_INDUSTRYTYPES);
-
switch (widget) {
case WID_SM_MAP: { // Map window
/*
@@ -1473,6 +1485,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
switch (this->map_type) {
case SMT_INDUSTRY:
tbl = _legend_from_industries;
+ this->BreakIndustryChainLink();
break;
case SMT_OWNER:
tbl = &(_legend_land_owners[NUM_NO_COMPANY_ENTRIES]);
diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h
index 2903544a6..c3151b1a7 100644
--- a/src/smallmap_gui.h
+++ b/src/smallmap_gui.h
@@ -82,6 +82,7 @@ protected:
uint8 refresh; ///< Refresh counter, zeroed every FORCE_REFRESH_PERIOD ticks.
LinkGraphOverlay *overlay;
+ static void BreakIndustryChainLink();
Point SmallmapRemapCoords(int x, int y) const;
/**
@@ -173,7 +174,7 @@ public:
friend class NWidgetSmallmapDisplay;
SmallMapWindow(WindowDesc *desc, int window_number);
- virtual ~SmallMapWindow() { delete this->overlay; }
+ virtual ~SmallMapWindow();
void SmallMapCenterOnCurrentPos();
Point GetStationMiddle(const Station *st) const;