Merge branch 'origin/master' commit 'a499e9acdd385b57dd43caf88af3a6f7f53716ba'
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
@@ -42,13 +40,6 @@ static uint8 _linkstat_colours_in_legenda[] = {0, 1, 3, 5, 7};
|
||||
|
||||
static const int NUM_NO_COMPANY_ENTRIES = 4; ///< Number of entries in the owner legend that are not companies.
|
||||
|
||||
static const uint8 PC_ROUGH_LAND = 0x52; ///< Dark green palette colour for rough land.
|
||||
static const uint8 PC_GRASS_LAND = 0x54; ///< Dark green palette colour for grass land.
|
||||
static const uint8 PC_BARE_LAND = 0x37; ///< Brown palette colour for bare land.
|
||||
static const uint8 PC_FIELDS = 0x25; ///< Light brown palette colour for fields.
|
||||
static const uint8 PC_TREES = 0x57; ///< Green palette colour for trees.
|
||||
static const uint8 PC_WATER = 0xCA; ///< Dark blue palette colour for water.
|
||||
|
||||
/** Macro for ordinary entry of LegendAndColour */
|
||||
#define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false}
|
||||
|
||||
@@ -180,8 +171,7 @@ void BuildIndustriesLegend()
|
||||
uint j = 0;
|
||||
|
||||
/* Add each name */
|
||||
for (uint i = 0; i < NUM_INDUSTRYTYPES; i++) {
|
||||
IndustryType ind = _sorted_industry_types[i];
|
||||
for (IndustryType ind : _sorted_industry_types) {
|
||||
const IndustrySpec *indsp = GetIndustrySpec(ind);
|
||||
if (indsp->enabled) {
|
||||
_legend_from_industries[j].legend = indsp->name;
|
||||
@@ -212,7 +202,7 @@ void BuildLinkStatsLegend()
|
||||
memset(_legend_linkstats, 0, sizeof(_legend_linkstats));
|
||||
|
||||
uint i = 0;
|
||||
for (; i < _sorted_cargo_specs_size; ++i) {
|
||||
for (; i < _sorted_cargo_specs.size(); ++i) {
|
||||
const CargoSpec *cs = _sorted_cargo_specs[i];
|
||||
|
||||
_legend_linkstats[i].legend = cs->name;
|
||||
@@ -275,9 +265,9 @@ struct SmallMapColourScheme {
|
||||
|
||||
/** Available colour schemes for height maps. */
|
||||
static SmallMapColourScheme _heightmap_schemes[] = {
|
||||
{NULL, _green_map_heights, lengthof(_green_map_heights), MKCOLOUR_XXXX(0x54)}, ///< Green colour scheme.
|
||||
{NULL, _dark_green_map_heights, lengthof(_dark_green_map_heights), MKCOLOUR_XXXX(0x62)}, ///< Dark green colour scheme.
|
||||
{NULL, _violet_map_heights, lengthof(_violet_map_heights), MKCOLOUR_XXXX(0x82)}, ///< Violet colour scheme.
|
||||
{nullptr, _green_map_heights, lengthof(_green_map_heights), MKCOLOUR_XXXX(0x54)}, ///< Green colour scheme.
|
||||
{nullptr, _dark_green_map_heights, lengthof(_dark_green_map_heights), MKCOLOUR_XXXX(0x62)}, ///< Dark green colour scheme.
|
||||
{nullptr, _violet_map_heights, lengthof(_violet_map_heights), MKCOLOUR_XXXX(0x81)}, ///< Violet colour scheme.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -286,7 +276,7 @@ static SmallMapColourScheme _heightmap_schemes[] = {
|
||||
void BuildLandLegend()
|
||||
{
|
||||
/* The smallmap window has never been initialized, so no need to change the legend. */
|
||||
if (_heightmap_schemes[0].height_colours == NULL) return;
|
||||
if (_heightmap_schemes[0].height_colours == nullptr) return;
|
||||
|
||||
/*
|
||||
* The general idea of this function is to fill the legend with an appropriate evenly spaced
|
||||
@@ -339,8 +329,7 @@ void BuildOwnerLegend()
|
||||
_legend_land_owners[1].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].default_colour;
|
||||
|
||||
int i = NUM_NO_COMPANY_ENTRIES;
|
||||
const Company *c;
|
||||
FOR_ALL_COMPANIES(c) {
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
_legend_land_owners[i].colour = _colour_gradient[c->colour][5];
|
||||
_legend_land_owners[i].company = c->index;
|
||||
_legend_land_owners[i].show_on_map = true;
|
||||
@@ -464,28 +453,51 @@ static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile, TileType t)
|
||||
*/
|
||||
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile, TileType t)
|
||||
{
|
||||
if (t == MP_STATION) {
|
||||
switch (GetStationType(tile)) {
|
||||
case STATION_RAIL: return MKCOLOUR_XXXX(PC_VERY_DARK_BROWN);
|
||||
case STATION_AIRPORT: return MKCOLOUR_XXXX(PC_RED);
|
||||
case STATION_TRUCK: return MKCOLOUR_XXXX(PC_ORANGE);
|
||||
case STATION_BUS: return MKCOLOUR_XXXX(PC_YELLOW);
|
||||
case STATION_DOCK: return MKCOLOUR_XXXX(PC_LIGHT_BLUE);
|
||||
default: return MKCOLOUR_FFFF;
|
||||
switch (t) {
|
||||
case MP_STATION:
|
||||
switch (GetStationType(tile)) {
|
||||
case STATION_RAIL: return MKCOLOUR_XXXX(PC_VERY_DARK_BROWN);
|
||||
case STATION_AIRPORT: return MKCOLOUR_XXXX(PC_RED);
|
||||
case STATION_TRUCK: return MKCOLOUR_XXXX(PC_ORANGE);
|
||||
case STATION_BUS: return MKCOLOUR_XXXX(PC_YELLOW);
|
||||
case STATION_DOCK: return MKCOLOUR_XXXX(PC_LIGHT_BLUE);
|
||||
default: return MKCOLOUR_FFFF;
|
||||
}
|
||||
|
||||
case MP_RAILWAY: {
|
||||
AndOr andor = {
|
||||
MKCOLOUR_0XX0(GetRailTypeInfo(GetRailType(tile))->map_colour),
|
||||
_smallmap_contours_andor[t].mand
|
||||
};
|
||||
|
||||
const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
|
||||
return ApplyMask(cs->default_colour, &andor);
|
||||
}
|
||||
} else if (t == MP_RAILWAY) {
|
||||
AndOr andor = {
|
||||
MKCOLOUR_0XX0(GetRailTypeInfo(GetRailType(tile))->map_colour),
|
||||
_smallmap_contours_andor[t].mand
|
||||
};
|
||||
|
||||
const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
|
||||
return ApplyMask(cs->default_colour, &andor);
|
||||
case MP_ROAD: {
|
||||
const RoadTypeInfo *rti = nullptr;
|
||||
if (GetRoadTypeRoad(tile) != INVALID_ROADTYPE) {
|
||||
rti = GetRoadTypeInfo(GetRoadTypeRoad(tile));
|
||||
} else {
|
||||
rti = GetRoadTypeInfo(GetRoadTypeTram(tile));
|
||||
}
|
||||
if (rti != nullptr) {
|
||||
AndOr andor = {
|
||||
MKCOLOUR_0XX0(rti->map_colour),
|
||||
_smallmap_contours_andor[t].mand
|
||||
};
|
||||
|
||||
const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
|
||||
return ApplyMask(cs->default_colour, &andor);
|
||||
}
|
||||
FALLTHROUGH;
|
||||
}
|
||||
|
||||
default:
|
||||
/* Ground colour */
|
||||
const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
|
||||
return ApplyMask(cs->default_colour, &_smallmap_contours_andor[t]);
|
||||
}
|
||||
|
||||
/* Ground colour */
|
||||
const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
|
||||
return ApplyMask(cs->default_colour, &_smallmap_contours_andor[t]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -570,7 +582,7 @@ static inline uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t)
|
||||
return MKCOLOUR_XXXX(_legend_land_owners[_company_to_list_pos[o]].colour);
|
||||
}
|
||||
|
||||
/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleTypeByte. */
|
||||
/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleType. */
|
||||
static const byte _vehicle_type_colours[6] = {
|
||||
PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED
|
||||
};
|
||||
@@ -860,8 +872,7 @@ void SmallMapWindow::DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch,
|
||||
*/
|
||||
void SmallMapWindow::DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) const
|
||||
{
|
||||
const Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
for (const Vehicle *v : Vehicle::Iterate()) {
|
||||
if (v->type == VEH_EFFECT) continue;
|
||||
if (v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) continue;
|
||||
|
||||
@@ -899,8 +910,7 @@ void SmallMapWindow::DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) co
|
||||
*/
|
||||
void SmallMapWindow::DrawTowns(const DrawPixelInfo *dpi) const
|
||||
{
|
||||
const Town *t;
|
||||
FOR_ALL_TOWNS(t) {
|
||||
for (const Town *t : Town::Iterate()) {
|
||||
/* Remap the town coordinate */
|
||||
Point pt = this->RemapTile(TileX(t->xy), TileY(t->xy));
|
||||
int x = pt.x - this->subscroll - (t->cache.sign.width_small >> 1);
|
||||
@@ -1079,7 +1089,7 @@ SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) :
|
||||
|
||||
this->SetupWidgetData();
|
||||
|
||||
this->SetZoomLevel(ZLC_INITIALIZE, NULL);
|
||||
this->SetZoomLevel(ZLC_INITIALIZE, nullptr);
|
||||
this->SmallMapCenterOnCurrentPos();
|
||||
this->SetOverlayCargoMask();
|
||||
}
|
||||
@@ -1490,7 +1500,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
|
||||
|
||||
case WID_SM_ENABLE_ALL:
|
||||
case WID_SM_DISABLE_ALL: {
|
||||
LegendAndColour *tbl = NULL;
|
||||
LegendAndColour *tbl = nullptr;
|
||||
switch (this->map_type) {
|
||||
case SMT_INDUSTRY:
|
||||
tbl = _legend_from_industries;
|
||||
@@ -1706,10 +1716,10 @@ class NWidgetSmallmapDisplay : public NWidgetContainer {
|
||||
public:
|
||||
NWidgetSmallmapDisplay() : NWidgetContainer(NWID_VERTICAL)
|
||||
{
|
||||
this->smallmap_window = NULL;
|
||||
this->smallmap_window = nullptr;
|
||||
}
|
||||
|
||||
virtual void SetupSmallestSize(Window *w, bool init_array)
|
||||
void SetupSmallestSize(Window *w, bool init_array) override
|
||||
{
|
||||
NWidgetBase *display = this->head;
|
||||
NWidgetBase *bar = display->next;
|
||||
@@ -1718,9 +1728,8 @@ public:
|
||||
bar->SetupSmallestSize(w, init_array);
|
||||
|
||||
this->smallmap_window = dynamic_cast<SmallMapWindow *>(w);
|
||||
|
||||
assert(this->smallmap_window != NULL);
|
||||
this->smallest_x = max(display->smallest_x, max(bar->smallest_x, WD_FRAMERECT_LEFT + smallmap_window->column_width));
|
||||
assert(this->smallmap_window != nullptr);
|
||||
this->smallest_x = max(display->smallest_x, bar->smallest_x + smallmap_window->GetMinLegendWidth());
|
||||
this->smallest_y = display->smallest_y + max(bar->smallest_y, smallmap_window->GetLegendHeight(smallmap_window->min_number_of_columns));
|
||||
this->fill_x = max(display->fill_x, bar->fill_x);
|
||||
this->fill_y = (display->fill_y == 0 && bar->fill_y == 0) ? 0 : min(display->fill_y, bar->fill_y);
|
||||
@@ -1728,7 +1737,7 @@ public:
|
||||
this->resize_y = min(display->resize_y, bar->resize_y);
|
||||
}
|
||||
|
||||
virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
|
||||
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
|
||||
{
|
||||
this->pos_x = x;
|
||||
this->pos_y = y;
|
||||
@@ -1752,19 +1761,19 @@ public:
|
||||
bar->AssignSizePosition(ST_RESIZE, x, y + display_height, given_width, bar_height, rtl);
|
||||
}
|
||||
|
||||
virtual NWidgetCore *GetWidgetFromPos(int x, int y)
|
||||
NWidgetCore *GetWidgetFromPos(int x, int y) override
|
||||
{
|
||||
if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return NULL;
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
|
||||
if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr;
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
||||
NWidgetCore *widget = child_wid->GetWidgetFromPos(x, y);
|
||||
if (widget != NULL) return widget;
|
||||
if (widget != nullptr) return widget;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void Draw(const Window *w)
|
||||
void Draw(const Window *w) override
|
||||
{
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) child_wid->Draw(w);
|
||||
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) child_wid->Draw(w);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1893,7 +1902,7 @@ bool ScrollMainWindowTo(int x, int y, int z, bool instant)
|
||||
if (res) return res;
|
||||
|
||||
SmallMapWindow *w = dynamic_cast<SmallMapWindow*>(FindWindowById(WC_SMALLMAP, 0));
|
||||
if (w != NULL) w->SmallMapCenterOnCurrentPos();
|
||||
if (w != nullptr) w->SmallMapCenterOnCurrentPos();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user