28 #include "table/strings.h" 44 #define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} 47 #define MC(col_break) {0, STR_TINY_BLACK_HEIGHT, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, col_break} 50 #define MO(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} 53 #define MOEND() {0, 0, INVALID_INDUSTRYTYPE, 0, OWNER_NONE, true, true, false} 56 #define MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, true, false} 62 #define MS(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, true} 67 MK(
PC_GREY, STR_SMALLMAP_LEGENDA_RAILROADS),
91 MK(
PC_RED, STR_SMALLMAP_LEGENDA_TRAINS),
96 MS(
PC_BLACK, STR_SMALLMAP_LEGENDA_TRANSPORT_ROUTES),
103 MK(
PC_GREY, STR_SMALLMAP_LEGENDA_RAILROADS),
107 MK(
PC_ORANGE, STR_SMALLMAP_LEGENDA_TRUCK_LOADING_BAY),
109 MK(
PC_RED, STR_SMALLMAP_LEGENDA_AIRPORT_HELIPORT),
125 MK(
PC_BLACK, STR_SMALLMAP_LEGENDA_TRANSPORT_ROUTES),
132 MO(0x00, STR_SMALLMAP_LEGENDA_NO_OWNER),
175 _legend_from_industries[j].
legend = indsp->
name;
177 _legend_from_industries[j].
type = ind;
179 _legend_from_industries[j].
col_break =
false;
180 _legend_from_industries[j].
end =
false;
188 _legend_from_industries[j].
end =
true;
200 memset(_legend_linkstats, 0,
sizeof(_legend_linkstats));
207 _legend_linkstats[i].
colour = cs->legend_colour;
216 _legend_linkstats[i].
legend = STR_EMPTY;
222 _legend_linkstats[i - 1].
legend = STR_LINKGRAPH_LEGEND_OVERLOADED;
224 _legend_linkstats[i].
end =
true;
237 #define MKCOLOUR(x) TO_LE32X(x) 239 #define MKCOLOUR_XXXX(x) (MKCOLOUR(0x01010101) * (uint)(x)) 240 #define MKCOLOUR_X0X0(x) (MKCOLOUR(0x01000100) * (uint)(x)) 241 #define MKCOLOUR_0X0X(x) (MKCOLOUR(0x00010001) * (uint)(x)) 242 #define MKCOLOUR_0XX0(x) (MKCOLOUR(0x00010100) * (uint)(x)) 243 #define MKCOLOUR_X00X(x) (MKCOLOUR(0x01000001) * (uint)(x)) 245 #define MKCOLOUR_XYXY(x, y) (MKCOLOUR_X0X0(x) | MKCOLOUR_0X0X(y)) 246 #define MKCOLOUR_XYYX(x, y) (MKCOLOUR_X00X(x) | MKCOLOUR_0XX0(y)) 248 #define MKCOLOUR_0000 MKCOLOUR_XXXX(0x00) 249 #define MKCOLOUR_0FF0 MKCOLOUR_0XX0(0xFF) 250 #define MKCOLOUR_F00F MKCOLOUR_X00X(0xFF) 251 #define MKCOLOUR_FFFF MKCOLOUR_XXXX(0xFF) 298 uint deltas[][2] = { { 24, 2 }, { 48, 4 }, { 72, 6 }, { 120, 10 }, { 180, 15 }, { 240, 20 }, {
MAX_TILE_HEIGHT + 1, 25 }};
303 uint delta = deltas[i][1];
306 int rows =
CeilDiv(total_entries, 2);
309 for (i = 0; i <
lengthof(_legend_land_contours) - 1 && j < total_entries; i++) {
310 if (_legend_land_contours[i].legend != STR_TINY_BLACK_HEIGHT)
continue;
312 _legend_land_contours[i].
col_break = j % rows == 0;
313 _legend_land_contours[i].
end =
false;
314 _legend_land_contours[i].
height = j * delta;
318 _legend_land_contours[i].
end =
true;
331 _legend_land_owners[i].
company = c->index;
333 _legend_land_owners[i].
col_break =
false;
334 _legend_land_owners[i].
end =
false;
340 _legend_land_owners[i].
end =
true;
351 static inline uint32 ApplyMask(uint32 colour,
const AndOr *mask)
353 return (colour & mask->mand) | mask->mor;
359 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
360 {MKCOLOUR_0XX0(
PC_GREY ), MKCOLOUR_F00F},
361 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
363 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
365 {MKCOLOUR_XXXX(
PC_WATER ), MKCOLOUR_0000},
366 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
368 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
370 {MKCOLOUR_0XX0(
PC_GREY ), MKCOLOUR_F00F},
375 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
376 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
377 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
379 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
380 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
381 {MKCOLOUR_XXXX(
PC_WATER ), MKCOLOUR_0000},
382 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
384 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
386 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
428 return ApplyMask(cs->
default_colour, &_smallmap_vehicles_andor[t]);
457 case STATION_AIRPORT:
return MKCOLOUR_XXXX(
PC_RED);
458 case STATION_TRUCK:
return MKCOLOUR_XXXX(
PC_ORANGE);
459 case STATION_BUS:
return MKCOLOUR_XXXX(
PC_YELLOW);
461 default:
return MKCOLOUR_FFFF;
467 _smallmap_contours_andor[t].mand
481 if (rti !=
nullptr) {
484 _smallmap_contours_andor[t].mand
496 return ApplyMask(cs->
default_colour, &_smallmap_contours_andor[t]);
512 static const uint32 _vegetation_clear_bits[] = {
546 return ApplyMask(MKCOLOUR_XXXX(
PC_GRASS_LAND), &_smallmap_vehicles_andor[t]);
594 inline Point SmallMapWindow::SmallmapRemapCoords(
int x,
int y)
const 610 int x_offset = tile_x - this->scroll_x / (int)
TILE_SIZE;
611 int y_offset = tile_y - this->scroll_y / (int)
TILE_SIZE;
613 if (this->zoom == 1)
return SmallmapRemapCoords(x_offset, y_offset);
616 if (x_offset < 0) x_offset -= this->zoom - 1;
617 if (y_offset < 0) y_offset -= this->zoom - 1;
619 return SmallmapRemapCoords(x_offset / this->zoom, y_offset / this->zoom);
634 if (add_sub) px += this->subscroll;
638 Point pt = {((py >> 1) - (px >> 2)) * this->zoom, ((py >> 1) + (px >> 2)) * this->zoom};
666 assert(x >= 0 && y >= 0);
669 Point tile_xy = PixelToTile(x, y, &new_sub,
false);
676 scroll.x = (tx + this->zoom) *
TILE_SIZE;
677 scroll.y = (ty - this->zoom) *
TILE_SIZE;
680 scroll.x = (tx + 2 * this->zoom) *
TILE_SIZE;
681 scroll.y = (ty - 2 * this->zoom) *
TILE_SIZE;
694 static const int zoomlevels[] = {1, 2, 4, 6, 8};
695 static const int MIN_ZOOM_INDEX = 0;
696 static const int MAX_ZOOM_INDEX =
lengthof(zoomlevels) - 1;
698 int new_index, cur_index, sub;
703 new_index = MIN_ZOOM_INDEX;
709 for (cur_index = MIN_ZOOM_INDEX; cur_index <= MAX_ZOOM_INDEX; cur_index++) {
710 if (this->zoom == zoomlevels[cur_index])
break;
712 assert(cur_index <= MAX_ZOOM_INDEX);
714 tile = this->PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
715 new_index =
Clamp(cur_index + ((change == ZLC_ZOOM_IN) ? -1 : 1), MIN_ZOOM_INDEX, MAX_ZOOM_INDEX);
718 default: NOT_REACHED();
721 if (new_index != cur_index) {
722 this->zoom = zoomlevels[new_index];
723 if (cur_index >= 0) {
724 Point new_tile = this->PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
725 this->SetNewScroll(this->scroll_x + (tile.x - new_tile.x) *
TILE_SIZE,
726 this->scroll_y + (tile.y - new_tile.y) *
TILE_SIZE, sub);
727 }
else if (this->map_type == SMT_LINKSTATS) {
728 this->overlay->SetDirty();
730 this->SetWidgetDisabledState(
WID_SM_ZOOM_IN, this->zoom == zoomlevels[MIN_ZOOM_INDEX]);
731 this->SetWidgetDisabledState(
WID_SM_ZOOM_OUT, this->zoom == zoomlevels[MAX_ZOOM_INDEX]);
764 if (this->map_type == SMT_INDUSTRY) {
791 switch (this->map_type) {
813 default: NOT_REACHED();
832 void *dst_ptr_abs_end = blitter->
MoveTo(_screen.dst_ptr, 0, _screen.height);
840 if (dst < _screen.dst_ptr)
continue;
841 if (dst >= dst_ptr_abs_end)
continue;
845 if (min_xy == 1 && (xc == 0 || yc == 0)) {
846 if (this->zoom == 1)
continue;
848 ta =
TileArea(
TileXY(
max(min_xy, xc),
max(min_xy, yc)), this->zoom - (xc == 0), this->zoom - (yc == 0));
854 uint32 val = this->GetTileColours(ta);
855 uint8 *val8 = (uint8 *)&val;
856 int idx =
max(0, -start_pos);
857 for (
int pos =
max(0, start_pos); pos < end_pos; pos++) {
858 blitter->
SetPixel(dst, idx, 0, val8[idx]);
862 }
while (xc += this->zoom, yc += this->zoom, dst = blitter->
MoveTo(dst, pitch, 0), --reps != 0);
877 Point pt = this->RemapTile(v->x_pos / (
int)
TILE_SIZE, v->y_pos / (
int)TILE_SIZE);
879 int y = pt.y - dpi->top;
883 int x = pt.x - this->subscroll - 3 - dpi->left;
887 if (++x != 0)
continue;
889 }
else if (x >= dpi->width - 1) {
891 if (x != dpi->width - 1)
continue;
899 blitter->
SetPixel(dpi->dst_ptr, x, y, colour);
900 if (!skip) blitter->
SetPixel(dpi->dst_ptr, x + 1, y, colour);
913 int x = pt.x - this->subscroll - (t->cache.sign.width_small >> 1);
917 if (x + t->cache.sign.width_small > dpi->left &&
918 x < dpi->left + dpi->width &&
920 y < dpi->top + dpi->height) {
923 DrawString(x, x + t->cache.sign.width_small, y, STR_SMALLMAP_TOWN);
939 Point upper_left = this->RemapTile(upper_left_smallmap_coord.x / (
int)
TILE_SIZE, upper_left_smallmap_coord.y / (
int)TILE_SIZE);
940 upper_left.x -= this->subscroll;
942 Point lower_right = this->RemapTile(lower_right_smallmap_coord.x / (
int)TILE_SIZE, lower_right_smallmap_coord.y / (
int)TILE_SIZE);
943 lower_right.x -= this->subscroll;
972 GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1,
PC_BLACK);
976 Point tile = this->PixelToTile(dpi->left, dpi->top, &dx);
977 int tile_x = this->scroll_x / (int)
TILE_SIZE + tile.x;
978 int tile_y = this->scroll_y / (
int)
TILE_SIZE + tile.y;
980 void *ptr = blitter->
MoveTo(dpi->dst_ptr, -dx - 4, 0);
987 if (x >= dpi->width)
break;
989 int end_pos =
min(dpi->width, x + 4);
990 int reps = (dpi->height - y + 1) / 2;
992 this->DrawSmallMapColumn(ptr, tile_x, tile_y, dpi->pitch * 2, reps, x, end_pos, blitter);
997 tile_y += this->zoom;
999 ptr = blitter->
MoveTo(ptr, 0, 1);
1001 tile_x -= this->zoom;
1003 ptr = blitter->
MoveTo(ptr, 0, -1);
1005 ptr = blitter->
MoveTo(ptr, 2, 0);
1010 if (this->map_type == SMT_CONTOUR || this->map_type == SMT_VEHICLES) this->DrawVehicles(dpi, blitter);
1013 if (this->map_type == SMT_LINKSTATS) this->overlay->Draw(dpi);
1016 if (this->show_towns) this->DrawTowns(dpi);
1019 this->DrawMapIndicators();
1033 switch (this->map_type) {
1035 legend_tooltip = STR_SMALLMAP_TOOLTIP_INDUSTRY_SELECTION;
1036 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_INDUSTRIES;
1037 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_INDUSTRIES;
1042 legend_tooltip = STR_SMALLMAP_TOOLTIP_COMPANY_SELECTION;
1043 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_COMPANIES;
1044 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_COMPANIES;
1049 legend_tooltip = STR_SMALLMAP_TOOLTIP_CARGO_SELECTION;
1050 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_CARGOS;
1051 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_CARGOS;
1056 legend_tooltip = STR_NULL;
1057 enable_all_tooltip = STR_NULL;
1058 disable_all_tooltip = STR_NULL;
1069 SmallMapWindow::SmallMapWindow(
WindowDesc *desc,
int window_number) :
Window(desc), refresh(
GUITimer(FORCE_REFRESH_PERIOD))
1073 this->InitNested(window_number);
1076 this->RebuildColourIndexIfNecessary();
1082 this->SetupWidgetData();
1084 this->SetZoomLevel(ZLC_INITIALIZE,
nullptr);
1085 this->SmallMapCenterOnCurrentPos();
1086 this->SetOverlayCargoMask();
1089 SmallMapWindow::~SmallMapWindow()
1091 delete this->overlay;
1092 this->BreakIndustryChainLink();
1103 for (uint n = 0; n <
lengthof(_heightmap_schemes); n++) {
1108 for (
int z = 0; z < heights; z++) {
1109 size_t access_index = (_heightmap_schemes[n].
colour_count * z) / heights;
1124 SetDParam(0, STR_SMALLMAP_TYPE_CONTOURS + this->map_type);
1132 this->min_number_of_columns = INDUSTRY_MIN_NUMBER_OF_COLUMNS;
1134 for (uint i = 0; i <
lengthof(_legend_table); i++) {
1136 uint num_columns = 1;
1139 if (i == SMT_INDUSTRY) {
1142 str = STR_SMALLMAP_INDUSTRY;
1143 }
else if (i == SMT_LINKSTATS) {
1145 str = STR_SMALLMAP_LINKSTATS;
1146 }
else if (i == SMT_OWNER) {
1156 str = STR_SMALLMAP_COMPANY;
1161 if (tbl->col_break) {
1162 this->min_number_of_fixed_rows =
max(this->min_number_of_fixed_rows, height);
1171 this->min_number_of_fixed_rows =
max(this->min_number_of_fixed_rows, height);
1172 this->min_number_of_columns =
max(this->min_number_of_columns, num_columns);
1181 if (this->map_type == SMT_OWNER) {
1186 this->InvalidateData(1);
1192 this->DrawWidgets();
1200 if (!
FillDrawPixelInfo(&new_dpi, r.left + 1, r.top + 1, r.right - r.left - 1, r.bottom - r.top - 1))
return;
1201 this->DrawSmallMap(&new_dpi);
1206 uint columns = this->GetNumberColumnsLegend(r.right - r.left + 1);
1207 uint number_of_rows = this->GetNumberRowsLegend(columns);
1216 uint text_right = this->column_width - 1 - (rtl ? LEGEND_BLOB_WIDTH +
WD_FRAMERECT_RIGHT : 0);
1217 uint blob_left = rtl ? this->column_width - 1 - LEGEND_BLOB_WIDTH : 0;
1218 uint blob_right = rtl ? this->column_width - 1 : LEGEND_BLOB_WIDTH;
1221 switch (this->map_type) {
1223 string = STR_SMALLMAP_INDUSTRY;
1226 string = STR_SMALLMAP_LINKSTATS;
1229 string = STR_SMALLMAP_COMPANY;
1236 if (tbl->col_break || ((this->map_type == SMT_INDUSTRY || this->map_type == SMT_OWNER || this->map_type == SMT_LINKSTATS) && i++ >= number_of_rows)) {
1239 x += rtl ? -(int)this->column_width : this->column_width;
1244 uint8 legend_colour = tbl->colour;
1246 switch (this->map_type) {
1263 if (this->map_type == SMT_OWNER)
SetDParam(0, tbl->company);
1264 if (!tbl->show_on_map) {
1267 DrawString(x + text_left, x + text_right, y,
string, TC_GREY);
1269 DrawString(x + text_left, x + text_right, y,
string, TC_BLACK);
1280 DrawString(x + text_left, x + text_right, y, tbl->legend);
1283 GfxFillRect(x + blob_left + 1, y + 2, x + blob_right - 1, y + row_height - 2, legend_colour);
1298 this->map_type = map_type;
1301 this->SetupWidgetData();
1303 if (map_type == SMT_LINKSTATS) this->overlay->SetDirty();
1304 if (map_type != SMT_INDUSTRY) this->BreakIndustryChainLink();
1321 return max(this->min_number_of_fixed_rows,
max(num_rows_linkstats, num_rows_others));
1339 bool changes =
false;
1340 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1341 bool new_state = (i == click_pos);
1342 if (legend[i].show_on_map != new_state) {
1349 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1357 if (this->map_type == SMT_INDUSTRY) this->BreakIndustryChainLink();
1365 CargoTypes cargo_mask = 0;
1367 if (_legend_linkstats[i].show_on_map)
SetBit(cargo_mask, _legend_linkstats[i].type);
1369 this->overlay->SetCargoMask(cargo_mask);
1381 uint columns = this->GetNumberColumnsLegend(wi->
current_x);
1382 uint number_of_rows = this->GetNumberRowsLegend(columns);
1383 if (line >= number_of_rows)
return -1;
1386 int x = pt.x - wi->
pos_x;
1390 return (column * number_of_rows) + line;
1396 if (widget ==
WID_SM_LEGEND && this->map_type == SMT_INDUSTRY) {
1397 int industry_pos = GetPositionOnLegend(pt);
1399 new_highlight = _legend_from_industries[industry_pos].
type;
1414 if (click_count > 0) this->mouse_capture_widget = widget;
1419 pt = this->PixelToTile(pt.x - wid->
pos_x, pt.y - wid->
pos_y, &sub);
1430 this->SetZoomLevel((widget ==
WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
1447 this->SmallMapCenterOnCurrentPos();
1453 this->show_towns = !this->show_towns;
1461 if (this->map_type == SMT_INDUSTRY || this->map_type == SMT_LINKSTATS || this->map_type == SMT_OWNER) {
1462 int click_pos = this->GetPositionOnLegend(pt);
1463 if (click_pos < 0)
break;
1466 if (this->map_type == SMT_INDUSTRY) {
1471 }
else if (this->map_type == SMT_LINKSTATS) {
1474 this->SetOverlayCargoMask();
1476 }
else if (this->map_type == SMT_OWNER) {
1488 switch (this->map_type) {
1491 this->BreakIndustryChainLink();
1502 for (;!tbl->
end && tbl->
legend != STR_LINKGRAPH_LEGEND_UNUSED; ++tbl) {
1505 if (this->map_type == SMT_LINKSTATS) this->SetOverlayCargoMask();
1528 if (!gui_scope)
return;
1538 if (this->map_type != SMT_INDUSTRY) this->SwitchMapType(SMT_INDUSTRY);
1541 _legend_from_industries[i].
show_on_map = _displayed_industries.test(_legend_from_industries[i].type);
1547 this->RebuildColourIndexIfNecessary();
1550 default: NOT_REACHED();
1567 int cursor_x = _cursor.
pos.x - this->left - wid->
pos_x;
1568 int cursor_y = _cursor.
pos.y - this->top - wid->
pos_y;
1570 Point pt = {cursor_x, cursor_y};
1571 this->SetZoomLevel((wheel < 0) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
1579 if (!this->refresh.Elapsed(delta_ms))
return;
1581 if (this->map_type == SMT_LINKSTATS) {
1582 uint32 company_mask = this->GetOverlayCompanyMask();
1583 if (this->overlay->GetCompanyMask() != company_mask) {
1584 this->overlay->SetCompanyMask(company_mask);
1586 this->overlay->SetDirty();
1626 this->scroll_x = sx;
1627 this->scroll_y = sy;
1628 this->subscroll = sub;
1629 if (this->map_type == SMT_LINKSTATS) this->overlay->SetDirty();
1638 Point pt = this->PixelToTile(delta.x, delta.y, &sub);
1639 this->SetNewScroll(this->scroll_x + pt.x *
TILE_SIZE, this->scroll_y + pt.y *
TILE_SIZE, sub);
1654 Point sxy = this->ComputeScroll(viewport_center.x / (
int)
TILE_SIZE, viewport_center.y / (
int)TILE_SIZE,
1656 this->SetNewScroll(sxy.x, sxy.y, sub);
1667 int x = (st->
rect.right + st->
rect.left + 1) / 2;
1668 int y = (st->
rect.bottom + st->
rect.top + 1) / 2;
1669 Point ret = this->RemapTile(x, y);
1674 ret.x -= 3 + this->subscroll;
1695 this->smallmap_window =
nullptr;
1707 assert(this->smallmap_window !=
nullptr);
1720 this->current_x = given_width;
1721 this->current_y = given_height;
1727 this->smallest_x = given_width;
1728 this->smallest_y = given_height;
1734 uint bar_height =
max(bar->
smallest_y, this->smallmap_window->GetLegendHeight(this->smallmap_window->GetNumberColumnsLegend(given_width - bar->
smallest_x)));
1735 uint display_height = given_height - bar_height;
1742 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return nullptr;
1743 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1745 if (widget !=
nullptr)
return widget;
1752 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) child_wid->Draw(w);
1759 NWidget(
WWT_INSET, COLOUR_BROWN,
WID_SM_MAP),
SetMinimalSize(346, 140),
SetResize(1, 1),
SetPadding(2, 2, 2, 2),
EndContainer(),
1772 SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
SetFill(1, 1),
1778 SetDataTip(SPR_IMG_SHOW_COUNTOURS, STR_SMALLMAP_TOOLTIP_SHOW_LAND_CONTOURS_ON_MAP),
SetFill(1, 1),
1780 SetDataTip(SPR_IMG_SHOW_VEHICLES, STR_SMALLMAP_TOOLTIP_SHOW_VEHICLES_ON_MAP),
SetFill(1, 1),
1782 SetDataTip(SPR_IMG_INDUSTRY, STR_SMALLMAP_TOOLTIP_SHOW_INDUSTRIES_ON_MAP),
SetFill(1, 1),
1787 SetDataTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
SetFill(1, 1),
1789 SetDataTip(SPR_IMG_TOWN, STR_SMALLMAP_TOOLTIP_TOGGLE_TOWN_NAMES_ON_OFF),
SetFill(1, 1),
1791 SetDataTip(SPR_IMG_CARGOFLOW, STR_SMALLMAP_TOOLTIP_SHOW_LINK_STATS_ON_MAP),
SetFill(1, 1),
1793 SetDataTip(SPR_IMG_SHOW_ROUTES, STR_SMALLMAP_TOOLTIP_SHOW_TRANSPORT_ROUTES_ON),
SetFill(1, 1),
1795 SetDataTip(SPR_IMG_PLANTTREES, STR_SMALLMAP_TOOLTIP_SHOW_VEGETATION_ON_MAP),
SetFill(1, 1),
1797 SetDataTip(SPR_IMG_COMPANY_GENERAL, STR_SMALLMAP_TOOLTIP_SHOW_LAND_OWNERS_ON_MAP),
SetFill(1, 1),
1805 static NWidgetBase *SmallMapDisplay(
int *biggest_index)
1809 MakeNWidgets(_nested_smallmap_display,
lengthof(_nested_smallmap_display), biggest_index, map_display);
1810 MakeNWidgets(_nested_smallmap_bar,
lengthof(_nested_smallmap_bar), biggest_index, map_display);
1815 static const NWidgetPart _nested_smallmap_widgets[] = {
1845 _nested_smallmap_widgets,
lengthof(_nested_smallmap_widgets)
1853 AllocateWindowDescFront<SmallMapWindow>(&_smallmap_desc, 0);
1872 if (res)
return res;
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Owner
Enum for all companies/owners.
void ClampToMap()
Clamp the tile area to map borders.
uint8 max_heightlevel
maximum allowed heightlevel
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of stuff that is very close to a company, like the company struct itself.
bool enabled
entity still available (by default true).newgrf can disable it, though
int virtual_left
Virtual left coordinate.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
Data about how and where to blit pixels.
static const uint8 PC_WHITE
White palette colour.
uint8 colour
Colour of the item on the map.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen...
Point pos
logical mouse position
The colour tables for heightmaps.
byte landscape
the landscape we're currently in
Maps accessors for stations.
void BuildOwnerLegend()
Completes the array for the owned property legend.
static const uint MAX_TILE_HEIGHT
Maximum allowed tile height.
High level window description.
byte map_colour
colour used for the small map
uint32 default_colour
Default colour of the land.
void SwitchMapType(SmallMapType map_type)
Select a new map type.
byte map_colour
Colour on mini-map.
static uint32 GetSmallMapVegetationPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the smallmap in mode "Vegetation".
TileType
The different types of tiles.
Offset at top to draw the frame rectangular area.
static void DrawVertMapIndicator(int x, int y, int y2)
Draws vertical part of map indicator.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
void ShowSmallMap()
Show the smallmap window.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
A tile with road (or tram tracks)
Maximal number of cargo types in a game.
void DrawMapIndicators() const
Adds map indicators to the smallmap.
void RebuildColourIndexIfNecessary()
Rebuilds the colour indices used for fast access to the smallmap contour colours based on the heightl...
A town owns the tile, or a town is expanding.
Specification of a cargo type.
virtual void SetPixel(void *video, int x, int y, uint8 colour)=0
Draw a pixel with a given colour on the video-buffer.
static uint _company_to_list_pos[MAX_COMPANIES]
For connecting company ID to position in owner list (small map legend)
A snow tile that is rough underneath.
uint GetMinLegendWidth() const
Compute minimal required width of the legends.
static const uint8 LINK_COLOURS[]
Colours for the various "load" states of links.
int virtual_height
height << zoom
static uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Owner".
static uint TileX(TileIndex tile)
Get the X component of a tile.
ZoomLevelChange
Available kinds of zoomlevel changes.
static bool _smallmap_industry_highlight_state
State of highlight blinking.
static const uint32 _green_map_heights[]
Height map colours for the green colour scheme, ordered by height.
int GetPositionOnLegend(Point pt)
Determines the mouse position on the legend.
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
static SmallMapColourScheme _heightmap_schemes[]
Available colour schemes for height maps.
#define MK(a, b)
Macro for ordinary entry of LegendAndColour.
flag for invalid roadtype
Structure for holding relevant data for legends in small map.
static const uint8 PC_LIGHT_BLUE
Light blue palette colour.
static IndustryType _smallmap_industry_highlight
Highlight a specific industry type.
uint GetLegendHeight(uint num_columns) const
Compute height given a number of columns.
Function to handling different endian machines.
Map accessors for tree tiles.
uint8 height
Height in tiles. Only valid for height legend entries.
static const uint8 PC_FIELDS
Light brown palette colour for fields.
Colour scheme of the smallmap.
How all blitters should look like.
static T max(const T a, const T b)
Returns the maximum of two values.
static bool IsClearGround(TileIndex t, ClearGround ct)
Set the type of clear tile.
Map moves with mouse movement on holding right mouse button, cursor position is fixed.
bool show_on_map
For filtering industries, if true, industry is shown on the map in colour.
static int _smallmap_industry_count
Number of used industries.
const uint32 * height_colours_base
Base table for determining the colours.
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
static const uint TILE_SIZE
Tile size in world coordinates.
void OnPaint() override
The window must be repainted.
StringID name
Name of this type of cargo.
static const uint8 PC_GRASS_LAND
Dark green palette colour for grass land.
StringID name
Displayed name of the industry.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
static const AndOr _smallmap_contours_andor[]
Colour masks for "Contour" and "Routes" modes.
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
static const NWidgetPart _nested_smallmap_display[]
Widget parts of the smallmap display.
void SmallMapCenterOnCurrentPos()
Center the small map on the current center of the viewport.
Functions related to (drawing on) viewports.
static void DrawHorizMapIndicator(int x, int x2, int y)
Draws horizontal part of map indicator.
static const uint8 PC_TREES
Green palette colour for trees.
bool freeform_edges
allow terraforming the tiles at the map edges
Data structure for an opened window.
static SmallMapType map_type
Currently displayed legends.
#define MOEND()
Macro used for forcing a rebuild of the owner legend the first time it is used.
bool _ctrl_pressed
Is Ctrl pressed?
static const size_t MAX_SIZE
Make template parameter accessible from outside.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
static const uint8 PC_GREEN
Green palette colour.
static const byte _vehicle_type_colours[6]
Vehicle colours in #SMT_VEHICLES mode.
static const uint32 _dark_green_map_heights[]
Height map colours for the dark green colour scheme, ordered by height.
Main window; Window numbers:
static const int NUM_NO_COMPANY_ENTRIES
Number of entries in the owner legend that are not companies.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
uint8 scroll_mode
viewport scroll mode
SmallMapType
Types of legends in the WID_SM_LEGEND widget.
The tile has no ownership.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
uint32 * height_colours
Cached colours for each level in a map.
bool end
This is the end of the list.
static const uint8 PC_DARK_GREY
Dark grey palette colour.
static const AndOr _smallmap_vehicles_andor[]
Colour masks for "Vehicles", "Industry", and "Vegetation" modes.
IndustryType type
Type of industry. Only valid for industry entries.
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
Class managing the smallmap window.
void DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, int reps, int start_pos, int end_pos, Blitter *blitter) const
Draws one column of tiles of the small map in a certain mode onto the screen buffer, skipping the shifted rows in between.
size_t colour_count
The number of colours.
SoundSettings sound
sound effect settings
std::array< IndustryType, NUM_INDUSTRYTYPES > _sorted_industry_types
Industry types sorted by name.
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
Small map; Window numbers:
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
ClientSettings _settings_client
The current settings for this game.
uint8 scrollwheel_scrolling
scrolling using the scroll wheel?
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void OnInit() override
Notification that the nested widget tree gets initialized.
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
Definition of base types and functions in a cross-platform compatible way.
uint min_number_of_columns
Minimal number of columns in legends.
A number of safeguards to prevent using unsafe methods.
void SetupWidgetData()
Function to set up widgets depending on the information being shown on the smallmap.
static LegendAndColour _legend_land_contours[]
Legend text giving the colours to look for on the minimap.
IndustryType type
type of industry.
static const uint8 PC_BARE_LAND
Brown palette colour for bare land.
void DrawSmallMap(DrawPixelInfo *dpi) const
Draws the small map.
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
#define MKEND()
Macro for end of list marker in arrays of LegendAndColour.
Point GetStationMiddle(const Station *st) const
Get the center of the given station as point on the screen in the smallmap window.
void SetZoomLevel(ZoomLevelChange change, const Point *zoom_pt)
Initialize or change the zoom level.
#define MO(a, b)
Macro for non-company owned property entry of LegendAndColour.
uint32 GetTileColours(const TileArea &ta) const
Decide which colours to show to the user for a group of tiles.
static int _smallmap_company_count
Number of entries in the owner legend.
void SetOverlayCargoMask()
Set the link graph overlay cargo mask from the legend.
CompanyID company
Company to display. Only valid for company entries of the owner legend.
Represents the covered area of e.g.
Point ComputeScroll(int tx, int ty, int x, int y, int *sub)
Compute base parameters of the smallmap such that tile (tx, ty) starts at pixel (x, y).
Point RemapTile(int tile_x, int tile_y) const
Remap tile to location on this smallmap.
bool fix_at
mouse is moving, but cursor is not (used for scrolling)
Defines the data structure for constructing industry.
static uint16 GetIndustryTypeCount(IndustryType type)
Get the count of industries for this type.
int virtual_width
width << zoom
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
static uint _industry_to_list_pos[NUM_INDUSTRYTYPES]
For connecting industry type to position in industries list(small map legend)
#define lengthof(x)
Return the length of an fixed size array.
static uint32 GetSmallMapVehiclesPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Vehicles".
static bool show_towns
Display town names in the smallmap.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
static T min(const T a, const T b)
Returns the minimum of two values.
static ClearGround GetClearGround(TileIndex t)
Get the type of clear tile.
Functions related to sound.
static uint32 GetSmallMapIndustriesPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Industries".
uint32 StringID
Numeric value that represents a string, independent of the selected language.
a desert or snow tile, depend on landscape
static const uint8 PC_BLACK
Black palette colour.
void BuildLinkStatsLegend()
Populate legend table for the link stat view.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static int max_heightlevel
Currently used/cached maximum heightlevel.
static uint32 GetSmallMapRoutesPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Routes".
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
static uint GetClearDensity(TileIndex t)
Get the density of a non-field clear tile.
static const int TILE_HEIGHT_STEP
One Z unit tile height difference is displayed as 50m.
No window, redirects to WC_MAIN_WINDOW.
uint GetNumberRowsLegend(uint columns) const
Get the number of rows in the legend from the number of columns.
void BuildLandLegend()
(Re)build the colour tables for the legends.
std::bitset< NUM_INDUSTRYTYPES > _displayed_industries
Communication from the industry chain window to the smallmap window about what industries to display...
static const uint8 PC_GREY
Grey palette colour.
void DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) const
Adds vehicles to the smallmap.
Effect vehicle type (smoke, explosions, sparks, bubbles)
static const uint8 PC_YELLOW
Yellow palette colour.
static const uint8 PC_DARK_RED
Dark red palette colour.
The tile/execution is done by "water".
bool ScrollMainWindowTo(int x, int y, int z, bool instant)
Scrolls the main window to given coordinates.
uint8 smallmap_land_colour
colour used for land and heightmap at the smallmap
void OnMouseWheel(int wheel) override
The mouse wheel has been turned.
static const IndustryType INVALID_INDUSTRYTYPE
one above amount is considered invalid
GUISettings gui
settings related to the GUI
Tunnel entry/exit and bridge heads.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item=0)
Select and toggle a legend item.
Invisible tiles at the SW and SE border.
Base class for all vehicles.
Data structure for viewport, display of a part of the world.
Point InverseRemapCoords2(int x, int y, bool clamp_to_map, bool *clamped)
Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
uint32 TileIndex
The index/ID of a Tile.
Map accessors for 'clear' tiles.
static const uint8 PC_ORANGE
Orange palette colour.
TextDirection _current_text_dir
Text direction of the currently selected language.
static TreeGround GetTreeGround(TileIndex t)
Returns the groundtype for tree tiles.
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static LegendAndColour _legend_linkstats[NUM_CARGO+lengthof(_linkstat_colours_in_legenda)+1]
Legend entries for the link stats view.
TransportType
Available types of transport.
static const uint8 PC_VERY_DARK_BROWN
Almost-black brown palette colour.
static const uint8 PC_RED
Red palette colour.
static const NWidgetPart _nested_smallmap_bar[]
Widget parts of the smallmap legend bar + image buttons.
Point PixelToTile(int px, int py, int *sub, bool add_sub=true) const
Determine the tile relative to the base tile of the smallmap, and the pixel position at that tile for...
static void BreakIndustryChainLink()
Notify the industry chain window to stop sending newly selected industries.
static uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Contour".
static Point InverseRemapCoords(int x, int y)
Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
bool col_break
Perform a column break and go further at the next column.
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
Maximum number of companies.
Viewport moves with mouse movement on holding right mouse button, cursor position is fixed...
#define MC(col_break)
Macro for a height legend entry with configurable colour.
Transport by road vehicle.
virtual void * MoveTo(void *video, int x, int y)=0
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
Functions related to OTTD's landscape.
static uint8 _linkstat_colours_in_legenda[]
Link stat colours shown in legenda.
Coordinates of a point in 2D.
static const uint8 PC_WATER
Dark blue palette colour for water.
CargoID Index() const
Determines index of this cargospec.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
static const uint8 PC_ROUGH_LAND
Dark green palette colour for rough land.
StringID legend
String corresponding to the coloured item.
ConstructionSettings construction
construction of things in-game
Functions that have tunnels and bridges in common.
static const uint32 _violet_map_heights[]
Height map colours for the violet colour scheme, ordered by height.
Offset at right to draw the frame rectangular area.
static LegendAndColour _legend_from_industries[NUM_INDUSTRYTYPES+1]
Allow room for all industries, plus a terminator entry This is required in order to have the industry...
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
static const byte _tiletype_importance[]
Mapping of tile type to importance of the tile (higher number means more interesting to show)...
void OnRealtimeTick(uint delta_ms) override
Called periodically.
int virtual_top
Virtual top coordinate.
GameCreationSettings game_creation
settings used during the creation of a game (map)
bool OnRightClick(Point pt, int widget) override
A click with the right mouse button has been made on the window.
A tile without any structures, i.e. grass, rocks, farm fields etc.
Specification of a rectangle with absolute coordinates of all edges.
Text is written right-to-left by default.
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
bool _scrolling_viewport
A viewport is being scrolled with the mouse.
static uint32 GetSmallMapLinkStatsPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "link stats".
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Window functions not directly related to making/drawing windows.
static bool _smallmap_show_heightmap
Show heightmap in industry and owner mode of smallmap window.
Find a place automatically.
void OnScroll(Point delta) override
Handle the request for (viewport) scrolling.
static bool IsTileOnWater(TileIndex t)
Tests if the tile was built on water.
void DrawTowns(const DrawPixelInfo *dpi) const
Adds town names to the smallmap.
ViewportData * viewport
Pointer to viewport data, if present.
#define MS(a, b)
Macro for break marker in arrays of LegendAndColour.
void OnMouseOver(Point pt, int widget) override
The mouse is currently moving over the window or has just moved outside of the window.
Industry cargoes chain; Window numbers:
void SetNewScroll(int sx, int sy, int sub)
Set new scroll_x, scroll_y, and subscroll values after limiting them such that the center of the smal...
bool ScrollWindowTo(int x, int y, int z, Window *w, bool instant)
Scrolls the viewport in a window to a given location.
bool click_beep
Beep on a random selection of buttons.
Offset at left to draw the frame rectangular area.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
Handles drawing of links into some window.
Vehicle is not clickable by the user (shadow vehicles).
static int _smallmap_cargo_count
Number of cargos in the link stats legend.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
void BuildIndustriesLegend()
Fills an array for the industries legends.