Changeset - r13300:254239a952de
[Not reviewed]
master
0 1 0
smatz - 15 years ago 2009-10-20 17:36:06
smatz@openttd.org
(svn r17819) -Codechange: replace magic constant by symbolic constant
1 file changed with 8 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/smallmap_gui.cpp
Show inline comments
 
@@ -553,25 +553,27 @@ class SmallMapWindow : public Window
 
		SMT_INDUSTRY,
 
		SMT_ROUTES,
 
		SMT_VEGETATION,
 
		SMT_OWNER,
 
	};
 

	
 
	static SmallMapType map_type;
 
	static bool show_towns;
 

	
 
	int32 scroll_x;
 
	int32 scroll_y;
 
	int32 subscroll;
 
	uint8 refresh;
 

	
 
	static const uint8 FORCE_REFRESH_PERIOD = 0x1F; ///< map is redrawn after that many ticks
 
	uint8 refresh; ///< refresh counter, zeroed every FORCE_REFRESH_PERIOD ticks
 

	
 
	static const int COLUMN_WIDTH = 119;
 
	static const int MIN_LEGEND_HEIGHT = 6 * 7;
 

	
 
	/**
 
	 * Remap a map's tile X coordinate (TileX(TileIndex)) to
 
	 * a location on this smallmap.
 
	 * @param tile_x the tile's X coordinate.
 
	 * @return the X coordinate to draw on.
 
	 */
 
	inline int RemapX(int tile_x)
 
	{
 
@@ -865,25 +867,25 @@ public:
 
			legend->top++;
 

	
 
			/* Resize map border widget so the window stays the same size */
 
			ResizeWindowForWidget(this, SM_WIDGET_MAP_BORDER, 0, rows - new_rows);
 
			/* Manually adjust the map widget as it lies completely within
 
			 * the map border widget */
 
			this->widget[SM_WIDGET_MAP].bottom += rows - new_rows;
 

	
 
			this->SetDirty();
 
		}
 
	}
 

	
 
	SmallMapWindow(const WindowDesc *desc, int window_number) : Window(desc, window_number)
 
	SmallMapWindow(const WindowDesc *desc, int window_number) : Window(desc, window_number), refresh(FORCE_REFRESH_PERIOD)
 
	{
 
		this->LowerWidget(this->map_type + SM_WIDGET_CONTOUR);
 
		this->SetWidgetLoweredState(SM_WIDGET_TOGGLETOWNNAME, this->show_towns);
 

	
 
		this->SmallMapCenterOnCurrentPos();
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		DrawPixelInfo new_dpi;
 

	
 
@@ -1041,25 +1043,28 @@ public:
 
	{
 
		if (widget == SM_WIDGET_MAP) {
 
			if (_scrolling_viewport) return;
 
			_scrolling_viewport = true;
 
			_cursor.delta.x = 0;
 
			_cursor.delta.y = 0;
 
		}
 
	}
 

	
 
	virtual void OnTick()
 
	{
 
		/* update the window every now and then */
 
		if ((++this->refresh & 0x1F) == 0) this->SetDirty();
 
		if (--this->refresh != 0) return;
 

	
 
		this->refresh = FORCE_REFRESH_PERIOD;
 
		this->SetDirty();
 
	}
 

	
 
	virtual void OnScroll(Point delta)
 
	{
 
		_cursor.fix_at = true;
 

	
 
		int x = this->scroll_x;
 
		int y = this->scroll_y;
 

	
 
		int sub = this->subscroll + delta.x;
 

	
 
		x -= (sub >> 2) << 4;
0 comments (0 inline, 0 general)