Changeset - r21180:49341613f030
[Not reviewed]
master
0 3 0
fonsinchen - 11 years ago 2014-01-19 09:26:56
fonsinchen@openttd.org
(svn r26266) -Fix [FS#5860]: Update smallmap overlay if player joins different company and make sure company masks are valid
3 files changed with 21 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/linkgraph/linkgraph_gui.h
Show inline comments
 
@@ -48,14 +48,13 @@ public:
 
	 * @param w Window to be drawn into.
 
	 * @param wid ID of the widget to draw into.
 
	 * @param cargo_mask Bitmask of cargoes to be shown.
 
	 * @param company_mask Bitmask of companies to be shown.
 
	 * @param scale Desired thickness of lines and size of station dots.
 
	 */
 
	LinkGraphOverlay(const Window *w, uint wid, uint32 cargo_mask = 0xFFFFFFFF,
 
			uint32 company_mask = 1 << _local_company, uint scale = 1) :
 
	LinkGraphOverlay(const Window *w, uint wid, uint32 cargo_mask, uint32 company_mask, uint scale) :
 
			window(w), widget_id(wid), cargo_mask(cargo_mask), company_mask(company_mask), scale(scale)
 
	{}
 

	
 
	void RebuildCache();
 
	void Draw(const DrawPixelInfo *dpi) const;
 
	void SetCargoMask(uint32 cargo_mask);
src/smallmap_gui.cpp
Show inline comments
 
@@ -1046,13 +1046,13 @@ void SmallMapWindow::SetupWidgetData()
 
	this->GetWidget<NWidgetStacked>(WID_SM_SELECT_BUTTONS)->SetDisplayedPlane(plane);
 
}
 

	
 
SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc), refresh(FORCE_REFRESH_PERIOD)
 
{
 
	_smallmap_industry_highlight = INVALID_INDUSTRYTYPE;
 
	this->overlay = new LinkGraphOverlay(this, WID_SM_MAP);
 
	this->overlay = new LinkGraphOverlay(this, WID_SM_MAP, 0, this->GetOverlayCompanyMask(), 1);
 
	this->InitNested(window_number);
 
	this->LowerWidget(this->map_type + WID_SM_CONTOUR);
 

	
 
	BuildLandLegend();
 
	this->SetWidgetLoweredState(WID_SM_SHOW_HEIGHT, _smallmap_show_heightmap);
 

	
 
@@ -1527,13 +1527,20 @@ int SmallMapWindow::GetPositionOnLegend(
 

	
 
/* virtual */ void SmallMapWindow::OnTick()
 
{
 
	/* Update the window every now and then */
 
	if (--this->refresh != 0) return;
 

	
 
	if (this->map_type == SMT_LINKSTATS) this->overlay->RebuildCache();
 
	if (this->map_type == SMT_LINKSTATS) {
 
		uint32 company_mask = this->GetOverlayCompanyMask();
 
		if (this->overlay->GetCompanyMask() != company_mask) {
 
			this->overlay->SetCompanyMask(company_mask);
 
		} else {
 
			this->overlay->RebuildCache();
 
		}
 
	}
 
	_smallmap_industry_highlight_state = !_smallmap_industry_highlight_state;
 

	
 
	this->refresh = _smallmap_industry_highlight != INVALID_INDUSTRYTYPE ? BLINK_PERIOD : FORCE_REFRESH_PERIOD;
 
	this->SetDirty();
 
}
 

	
src/smallmap_gui.h
Show inline comments
 
@@ -10,12 +10,13 @@
 
/** @file smallmap_gui.h Smallmap GUI functions. */
 

	
 
#ifndef SMALLMAP_GUI_H
 
#define SMALLMAP_GUI_H
 

	
 
#include "industry_type.h"
 
#include "company_base.h"
 
#include "window_gui.h"
 
#include "strings_func.h"
 
#include "blitter/factory.hpp"
 
#include "linkgraph/linkgraph_gui.h"
 
#include "widgets/smallmap_widget.h"
 

	
 
@@ -132,12 +133,22 @@ protected:
 
	inline uint GetLegendHeight(uint num_columns) const
 
	{
 
		return WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM +
 
				this->GetNumberRowsLegend(num_columns) * FONT_HEIGHT_SMALL;
 
	}
 

	
 
	/**
 
	 * Get a bitmask for company links to be displayed. Usually this will be
 
	 * the _local_company. Spectators get to see all companies' links.
 
	 * @return Company mask.
 
	 */
 
	inline uint32 GetOverlayCompanyMask() const
 
	{
 
		return Company::IsValidID(_local_company) ? 1U << _local_company : 0xffffffff;
 
	}
 

	
 
	uint GetNumberRowsLegend(uint columns) const;
 
	void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item = 0);
 
	void SwitchMapType(SmallMapType map_type);
 
	void SetNewScroll(int sx, int sy, int sub);
 

	
 
	void DrawMapIndicators() const;
0 comments (0 inline, 0 general)