@@ -569,12 +569,18 @@ static inline uint32 GetSmallMapOwnerPix
/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleTypeByte. */
static const byte _vehicle_type_colours[6] = {
PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED
};
/** 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;
pt.x = (y - x) * 2;
pt.y = y + x;
return pt;
@@ -1066,12 +1072,18 @@ SmallMapWindow::SmallMapWindow(WindowDes
this->SetZoomLevel(ZLC_INITIALIZE, NULL);
this->SmallMapCenterOnCurrentPos();
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.
*/
void SmallMapWindow::RebuildColourIndexIfNecessary()
/* Rebuild colour indices if necessary. */
@@ -1275,12 +1287,13 @@ void SmallMapWindow::SwitchMapType(Small
this->map_type = map_type;
this->LowerWidget(this->map_type + WID_SM_CONTOUR);
this->SetupWidgetData();
if (map_type == SMT_LINKSTATS) this->overlay->RebuildCache();
if (map_type != SMT_INDUSTRY) this->BreakIndustryChainLink();
this->SetDirty();
* Get the number of rows in the legend from the number of columns. Those
* are at least min_number_of_fixed_rows and possibly more if there are so
@@ -1326,12 +1339,14 @@ void SmallMapWindow::SelectLegendItem(in
legend[i].show_on_map = true;
} else {
legend[click_pos].show_on_map = !legend[click_pos].show_on_map;
if (this->map_type == SMT_INDUSTRY) this->BreakIndustryChainLink();
* Set the link graph overlay cargo mask from the legend.
void SmallMapWindow::SetOverlayCargoMask()
@@ -1380,15 +1395,12 @@ int SmallMapWindow::GetPositionOnLegend(
/* 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. */
switch (widget) {
case WID_SM_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
@@ -1470,12 +1482,13 @@ int SmallMapWindow::GetPositionOnLegend(
case WID_SM_ENABLE_ALL:
case WID_SM_DISABLE_ALL: {
LegendAndColour *tbl = NULL;
switch (this->map_type) {
case SMT_INDUSTRY:
tbl = _legend_from_industries;
break;
case SMT_OWNER:
tbl = &(_legend_land_owners[NUM_NO_COMPANY_ENTRIES]);
case SMT_LINKSTATS:
tbl = _legend_linkstats;
@@ -79,12 +79,13 @@ protected:
int32 subscroll; ///< Number of pixels (0..3) between the right end of the base tile and the pixel at the top-left corner of the smallmap display.
int zoom; ///< Zoom level. Bigger number means more zoom-out (further away).
uint8 refresh; ///< Refresh counter, zeroed every FORCE_REFRESH_PERIOD ticks.
LinkGraphOverlay *overlay;
static void BreakIndustryChainLink();
Point SmallmapRemapCoords(int x, int y) const;
* Draws vertical part of map indicator
* @param x X coord of left/right border of main viewport
* @param y Y coord of top border of main viewport
@@ -170,13 +171,13 @@ protected:
int GetPositionOnLegend(Point pt);
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;
virtual void SetStringParameters(int widget) const;
virtual void OnInit();
Status change: