Changeset - r15733:a851a8352431
[Not reviewed]
master
0 1 0
alberth - 14 years ago 2010-08-08 10:47:09
alberth@openttd.org
(svn r20410) -Codechange: Move smallmap map-type switching to a function.
1 file changed with 17 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/smallmap_gui.cpp
Show inline comments
 
@@ -1127,24 +1127,40 @@ public:
 

	
 
					y += row_height;
 
				}
 
			}
 
		}
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		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) {
 
			case SM_WIDGET_MAP: { // Map window
 
				/*
 
				 * XXX: scrolling with the left mouse button is done by subsequently
 
				 * clicking with the left mouse button; clicking once centers the
 
				 * large map at the selected point. So by unclicking the left mouse
 
				 * button here, it gets reclicked during the next inputloop, which
 
				 * would make it look like the mouse is being dragged, while it is
 
				 * actually being (virtually) clicked every inputloop.
 
				 */
 
@@ -1171,32 +1187,25 @@ public:
 
				Point pt = {wid->current_x / 2, wid->current_y / 2};
 
				this->SetZoomLevel((widget == SM_WIDGET_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
 
				SndPlayFx(SND_15_BEEP);
 
				break;
 
			}
 

	
 
			case SM_WIDGET_CONTOUR:    // Show land contours
 
			case SM_WIDGET_VEHICLES:   // Show vehicles
 
			case SM_WIDGET_INDUSTRIES: // Show industries
 
			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;
 

	
 
			case SM_WIDGET_CENTERMAP: // Center the smallmap again
 
				this->SmallMapCenterOnCurrentPos();
 
				this->HandleButtonClick(SM_WIDGET_CENTERMAP);
 
				SndPlayFx(SND_15_BEEP);
 
				break;
 

	
 
			case SM_WIDGET_TOGGLETOWNNAME: // Toggle town names
 
				this->show_towns = !this->show_towns;
 
				this->SetWidgetLoweredState(SM_WIDGET_TOGGLETOWNNAME, this->show_towns);
0 comments (0 inline, 0 general)