summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-08-08 10:47:09 +0000
committeralberth <alberth@openttd.org>2010-08-08 10:47:09 +0000
commitabc14d8fbfb9ca313d6a5ab50fc726a2507de6a4 (patch)
tree3643afa1b3eed1d7fa451697788391ea1a9af403 /src
parent412bb37f595756eea74d02d3163d7043f84cf93a (diff)
downloadopenttd-abc14d8fbfb9ca313d6a5ab50fc726a2507de6a4.tar.xz
(svn r20410) -Codechange: Move smallmap map-type switching to a function.
Diffstat (limited to 'src')
-rw-r--r--src/smallmap_gui.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 611e767af..846fc1073 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -1136,6 +1136,22 @@ public:
this->DrawWidgets();
}
+ /**
+ * Select a new map type.
+ * @param map_type New map type.
+ */
+ void SwitchMapType(SmallMapType map_type)
+ {
+ this->RaiseWidget(this->map_type + SM_WIDGET_CONTOUR);
+ this->map_type = map_type;
+ this->LowerWidget(this->map_type + SM_WIDGET_CONTOUR);
+
+ /* Hide Enable all/Disable all buttons if is not industry type small map */
+ this->GetWidget<NWidgetStacked>(SM_WIDGET_SELECTINDUSTRIES)->SetDisplayedPlane(this->map_type != SMT_INDUSTRY);
+
+ this->SetDirty();
+ }
+
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
@@ -1180,14 +1196,7 @@ public:
case SM_WIDGET_ROUTES: // Show transport routes
case SM_WIDGET_VEGETATION: // Show vegetation
case SM_WIDGET_OWNERS: // Show land owners
- this->RaiseWidget(this->map_type + SM_WIDGET_CONTOUR);
- this->map_type = (SmallMapType)(widget - SM_WIDGET_CONTOUR);
- this->LowerWidget(this->map_type + SM_WIDGET_CONTOUR);
-
- /* Hide Enable all/Disable all buttons if is not industry type small map */
- this->GetWidget<NWidgetStacked>(SM_WIDGET_SELECTINDUSTRIES)->SetDisplayedPlane(this->map_type != SMT_INDUSTRY);
-
- this->SetDirty();
+ this->SwitchMapType((SmallMapType)(widget - SM_WIDGET_CONTOUR));
SndPlayFx(SND_15_BEEP);
break;