30 #include "table/strings.h" 53 #define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} 56 #define MC(col_break) {0, STR_TINY_BLACK_HEIGHT, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, col_break} 59 #define MO(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} 62 #define MOEND() {0, 0, INVALID_INDUSTRYTYPE, 0, OWNER_NONE, true, true, false} 65 #define MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, true, false} 71 #define MS(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, true} 76 MK(
PC_GREY, STR_SMALLMAP_LEGENDA_RAILROADS),
100 MK(
PC_RED, STR_SMALLMAP_LEGENDA_TRAINS),
105 MS(
PC_BLACK, STR_SMALLMAP_LEGENDA_TRANSPORT_ROUTES),
112 MK(
PC_GREY, STR_SMALLMAP_LEGENDA_RAILROADS),
116 MK(
PC_ORANGE, STR_SMALLMAP_LEGENDA_TRUCK_LOADING_BAY),
118 MK(
PC_RED, STR_SMALLMAP_LEGENDA_AIRPORT_HELIPORT),
134 MK(
PC_BLACK, STR_SMALLMAP_LEGENDA_TRANSPORT_ROUTES),
141 MO(0x00, STR_SMALLMAP_LEGENDA_NO_OWNER),
185 _legend_from_industries[j].
legend = indsp->
name;
187 _legend_from_industries[j].
type = ind;
189 _legend_from_industries[j].
col_break =
false;
190 _legend_from_industries[j].
end =
false;
198 _legend_from_industries[j].
end =
true;
210 memset(_legend_linkstats, 0,
sizeof(_legend_linkstats));
217 _legend_linkstats[i].
colour = cs->legend_colour;
226 _legend_linkstats[i].
legend = STR_EMPTY;
232 _legend_linkstats[i - 1].
legend = STR_LINKGRAPH_LEGEND_OVERLOADED;
234 _legend_linkstats[i].
end =
true;
247 #define MKCOLOUR(x) TO_LE32X(x) 249 #define MKCOLOUR_XXXX(x) (MKCOLOUR(0x01010101) * (uint)(x)) 250 #define MKCOLOUR_X0X0(x) (MKCOLOUR(0x01000100) * (uint)(x)) 251 #define MKCOLOUR_0X0X(x) (MKCOLOUR(0x00010001) * (uint)(x)) 252 #define MKCOLOUR_0XX0(x) (MKCOLOUR(0x00010100) * (uint)(x)) 253 #define MKCOLOUR_X00X(x) (MKCOLOUR(0x01000001) * (uint)(x)) 255 #define MKCOLOUR_XYXY(x, y) (MKCOLOUR_X0X0(x) | MKCOLOUR_0X0X(y)) 256 #define MKCOLOUR_XYYX(x, y) (MKCOLOUR_X00X(x) | MKCOLOUR_0XX0(y)) 258 #define MKCOLOUR_0000 MKCOLOUR_XXXX(0x00) 259 #define MKCOLOUR_0FF0 MKCOLOUR_0XX0(0xFF) 260 #define MKCOLOUR_F00F MKCOLOUR_X00X(0xFF) 261 #define MKCOLOUR_FFFF MKCOLOUR_XXXX(0xFF) 308 uint deltas[][2] = { { 24, 2 }, { 48, 4 }, { 72, 6 }, { 120, 10 }, { 180, 15 }, { 240, 20 }, {
MAX_TILE_HEIGHT + 1, 25 }};
313 uint delta = deltas[i][1];
316 int rows =
CeilDiv(total_entries, 2);
319 for (i = 0; i <
lengthof(_legend_land_contours) - 1 && j < total_entries; i++) {
320 if (_legend_land_contours[i].legend != STR_TINY_BLACK_HEIGHT)
continue;
322 _legend_land_contours[i].
col_break = j % rows == 0;
323 _legend_land_contours[i].
end =
false;
324 _legend_land_contours[i].
height = j * delta;
328 _legend_land_contours[i].
end =
true;
340 FOR_ALL_COMPANIES(c) {
344 _legend_land_owners[i].
col_break =
false;
345 _legend_land_owners[i].
end =
false;
351 _legend_land_owners[i].
end =
true;
362 static inline uint32 ApplyMask(uint32 colour,
const AndOr *mask)
364 return (colour & mask->mand) | mask->mor;
370 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
371 {MKCOLOUR_0XX0(
PC_GREY ), MKCOLOUR_F00F},
372 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
374 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
376 {MKCOLOUR_XXXX(
PC_WATER ), MKCOLOUR_0000},
377 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
379 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
381 {MKCOLOUR_0XX0(
PC_GREY ), MKCOLOUR_F00F},
386 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
387 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
388 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
390 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
391 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
392 {MKCOLOUR_XXXX(
PC_WATER ), MKCOLOUR_0000},
393 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
395 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
397 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
439 return ApplyMask(cs->
default_colour, &_smallmap_vehicles_andor[t]);
467 case STATION_AIRPORT:
return MKCOLOUR_XXXX(
PC_RED);
468 case STATION_TRUCK:
return MKCOLOUR_XXXX(
PC_ORANGE);
469 case STATION_BUS:
return MKCOLOUR_XXXX(
PC_YELLOW);
471 default:
return MKCOLOUR_FFFF;
476 _smallmap_contours_andor[t].mand
485 return ApplyMask(cs->
default_colour, &_smallmap_contours_andor[t]);
500 static const uint32 _vegetation_clear_bits[] = {
534 return ApplyMask(MKCOLOUR_XXXX(
PC_GRASS_LAND), &_smallmap_vehicles_andor[t]);
582 inline Point SmallMapWindow::SmallmapRemapCoords(
int x,
int y)
const 598 int x_offset = tile_x - this->scroll_x / (int)
TILE_SIZE;
599 int y_offset = tile_y - this->scroll_y / (int)
TILE_SIZE;
601 if (this->zoom == 1)
return SmallmapRemapCoords(x_offset, y_offset);
604 if (x_offset < 0) x_offset -= this->zoom - 1;
605 if (y_offset < 0) y_offset -= this->zoom - 1;
607 return SmallmapRemapCoords(x_offset / this->zoom, y_offset / this->zoom);
622 if (add_sub) px += this->subscroll;
626 Point pt = {((py >> 1) - (px >> 2)) * this->zoom, ((py >> 1) + (px >> 2)) * this->zoom};
654 assert(x >= 0 && y >= 0);
657 Point tile_xy = PixelToTile(x, y, &new_sub,
false);
664 scroll.x = (tx + this->zoom) *
TILE_SIZE;
665 scroll.y = (ty - this->zoom) *
TILE_SIZE;
668 scroll.x = (tx + 2 * this->zoom) *
TILE_SIZE;
669 scroll.y = (ty - 2 * this->zoom) *
TILE_SIZE;
682 static const int zoomlevels[] = {1, 2, 4, 6, 8};
683 static const int MIN_ZOOM_INDEX = 0;
684 static const int MAX_ZOOM_INDEX =
lengthof(zoomlevels) - 1;
686 int new_index, cur_index, sub;
691 new_index = MIN_ZOOM_INDEX;
697 for (cur_index = MIN_ZOOM_INDEX; cur_index <= MAX_ZOOM_INDEX; cur_index++) {
698 if (this->zoom == zoomlevels[cur_index])
break;
700 assert(cur_index <= MAX_ZOOM_INDEX);
702 tile = this->PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
703 new_index =
Clamp(cur_index + ((change == ZLC_ZOOM_IN) ? -1 : 1), MIN_ZOOM_INDEX, MAX_ZOOM_INDEX);
706 default: NOT_REACHED();
709 if (new_index != cur_index) {
710 this->zoom = zoomlevels[new_index];
711 if (cur_index >= 0) {
712 Point new_tile = this->PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
713 this->SetNewScroll(this->scroll_x + (tile.x - new_tile.x) *
TILE_SIZE,
714 this->scroll_y + (tile.y - new_tile.y) *
TILE_SIZE, sub);
715 }
else if (this->map_type == SMT_LINKSTATS) {
716 this->overlay->SetDirty();
718 this->SetWidgetDisabledState(
WID_SM_ZOOM_IN, this->zoom == zoomlevels[MIN_ZOOM_INDEX]);
719 this->SetWidgetDisabledState(
WID_SM_ZOOM_OUT, this->zoom == zoomlevels[MAX_ZOOM_INDEX]);
752 if (this->map_type == SMT_INDUSTRY) {
779 switch (this->map_type) {
801 default: NOT_REACHED();
820 void *dst_ptr_abs_end = blitter->
MoveTo(_screen.dst_ptr, 0, _screen.height);
828 if (dst < _screen.dst_ptr)
continue;
829 if (dst >= dst_ptr_abs_end)
continue;
833 if (min_xy == 1 && (xc == 0 || yc == 0)) {
834 if (this->zoom == 1)
continue;
836 ta =
TileArea(
TileXY(
max(min_xy, xc),
max(min_xy, yc)), this->zoom - (xc == 0), this->zoom - (yc == 0));
842 uint32 val = this->GetTileColours(ta);
843 uint8 *val8 = (uint8 *)&val;
844 int idx =
max(0, -start_pos);
845 for (
int pos =
max(0, start_pos); pos < end_pos; pos++) {
846 blitter->
SetPixel(dst, idx, 0, val8[idx]);
850 }
while (xc += this->zoom, yc += this->zoom, dst = blitter->
MoveTo(dst, pitch, 0), --reps != 0);
868 int y = pt.y - dpi->top;
872 int x = pt.x - this->subscroll - 3 - dpi->left;
876 if (++x != 0)
continue;
878 }
else if (x >= dpi->width - 1) {
880 if (x != dpi->width - 1)
continue;
888 blitter->
SetPixel(dpi->dst_ptr, x, y, colour);
889 if (!skip) blitter->
SetPixel(dpi->dst_ptr, x + 1, y, colour);
908 x < dpi->left + dpi->width &&
910 y < dpi->top + dpi->height) {
929 Point upper_left = this->RemapTile(upper_left_smallmap_coord.x / (
int)
TILE_SIZE, upper_left_smallmap_coord.y / (
int)TILE_SIZE);
930 upper_left.x -= this->subscroll;
932 Point lower_right = this->RemapTile(lower_right_smallmap_coord.x / (
int)TILE_SIZE, lower_right_smallmap_coord.y / (
int)TILE_SIZE);
933 lower_right.x -= this->subscroll;
962 GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1,
PC_BLACK);
966 Point tile = this->PixelToTile(dpi->left, dpi->top, &dx);
967 int tile_x = this->scroll_x / (int)
TILE_SIZE + tile.x;
968 int tile_y = this->scroll_y / (
int)
TILE_SIZE + tile.y;
970 void *ptr = blitter->
MoveTo(dpi->dst_ptr, -dx - 4, 0);
977 if (x >= dpi->width)
break;
979 int end_pos =
min(dpi->width, x + 4);
980 int reps = (dpi->height - y + 1) / 2;
982 this->DrawSmallMapColumn(ptr, tile_x, tile_y, dpi->pitch * 2, reps, x, end_pos, blitter);
987 tile_y += this->zoom;
989 ptr = blitter->
MoveTo(ptr, 0, 1);
991 tile_x -= this->zoom;
993 ptr = blitter->
MoveTo(ptr, 0, -1);
995 ptr = blitter->
MoveTo(ptr, 2, 0);
1000 if (this->map_type == SMT_CONTOUR || this->map_type == SMT_VEHICLES) this->DrawVehicles(dpi, blitter);
1003 if (this->map_type == SMT_LINKSTATS) this->overlay->Draw(dpi);
1006 if (this->show_towns) this->DrawTowns(dpi);
1009 this->DrawMapIndicators();
1023 switch (this->map_type) {
1025 legend_tooltip = STR_SMALLMAP_TOOLTIP_INDUSTRY_SELECTION;
1026 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_INDUSTRIES;
1027 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_INDUSTRIES;
1032 legend_tooltip = STR_SMALLMAP_TOOLTIP_COMPANY_SELECTION;
1033 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_COMPANIES;
1034 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_COMPANIES;
1039 legend_tooltip = STR_SMALLMAP_TOOLTIP_CARGO_SELECTION;
1040 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_CARGOS;
1041 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_CARGOS;
1046 legend_tooltip = STR_NULL;
1047 enable_all_tooltip = STR_NULL;
1048 disable_all_tooltip = STR_NULL;
1059 SmallMapWindow::SmallMapWindow(
WindowDesc *desc,
int window_number) :
Window(desc), refresh(
GUITimer(FORCE_REFRESH_PERIOD))
1063 this->InitNested(window_number);
1066 this->RebuildColourIndexIfNecessary();
1072 this->SetupWidgetData();
1074 this->SetZoomLevel(ZLC_INITIALIZE, NULL);
1075 this->SmallMapCenterOnCurrentPos();
1076 this->SetOverlayCargoMask();
1079 SmallMapWindow::~SmallMapWindow()
1081 delete this->overlay;
1082 this->BreakIndustryChainLink();
1093 for (uint n = 0; n <
lengthof(_heightmap_schemes); n++) {
1098 for (
int z = 0; z < heights; z++) {
1099 size_t access_index = (_heightmap_schemes[n].
colour_count * z) / heights;
1114 SetDParam(0, STR_SMALLMAP_TYPE_CONTOURS + this->map_type);
1122 this->min_number_of_columns = INDUSTRY_MIN_NUMBER_OF_COLUMNS;
1124 for (uint i = 0; i <
lengthof(_legend_table); i++) {
1126 uint num_columns = 1;
1129 if (i == SMT_INDUSTRY) {
1132 str = STR_SMALLMAP_INDUSTRY;
1133 }
else if (i == SMT_LINKSTATS) {
1135 str = STR_SMALLMAP_LINKSTATS;
1136 }
else if (i == SMT_OWNER) {
1146 str = STR_SMALLMAP_COMPANY;
1151 if (tbl->col_break) {
1152 this->min_number_of_fixed_rows =
max(this->min_number_of_fixed_rows, height);
1161 this->min_number_of_fixed_rows =
max(this->min_number_of_fixed_rows, height);
1162 this->min_number_of_columns =
max(this->min_number_of_columns, num_columns);
1171 if (this->map_type == SMT_OWNER) {
1176 this->InvalidateData(1);
1182 this->DrawWidgets();
1190 if (!
FillDrawPixelInfo(&new_dpi, r.left + 1, r.top + 1, r.right - r.left - 1, r.bottom - r.top - 1))
return;
1191 this->DrawSmallMap(&new_dpi);
1196 uint columns = this->GetNumberColumnsLegend(r.right - r.left + 1);
1197 uint number_of_rows = this->GetNumberRowsLegend(columns);
1206 uint text_right = this->column_width - 1 - (rtl ? LEGEND_BLOB_WIDTH +
WD_FRAMERECT_RIGHT : 0);
1207 uint blob_left = rtl ? this->column_width - 1 - LEGEND_BLOB_WIDTH : 0;
1208 uint blob_right = rtl ? this->column_width - 1 : LEGEND_BLOB_WIDTH;
1211 switch (this->map_type) {
1213 string = STR_SMALLMAP_INDUSTRY;
1216 string = STR_SMALLMAP_LINKSTATS;
1219 string = STR_SMALLMAP_COMPANY;
1226 if (tbl->col_break || ((this->map_type == SMT_INDUSTRY || this->map_type == SMT_OWNER || this->map_type == SMT_LINKSTATS) && i++ >= number_of_rows)) {
1229 x += rtl ? -(int)this->column_width : this->column_width;
1234 uint8 legend_colour = tbl->colour;
1236 switch (this->map_type) {
1253 if (this->map_type == SMT_OWNER)
SetDParam(0, tbl->company);
1254 if (!tbl->show_on_map) {
1257 DrawString(x + text_left, x + text_right, y,
string, TC_GREY);
1259 DrawString(x + text_left, x + text_right, y,
string, TC_BLACK);
1270 DrawString(x + text_left, x + text_right, y, tbl->legend);
1273 GfxFillRect(x + blob_left + 1, y + 2, x + blob_right - 1, y + row_height - 2, legend_colour);
1288 this->map_type = map_type;
1291 this->SetupWidgetData();
1293 if (map_type == SMT_LINKSTATS) this->overlay->SetDirty();
1294 if (map_type != SMT_INDUSTRY) this->BreakIndustryChainLink();
1311 return max(this->min_number_of_fixed_rows,
max(num_rows_linkstats, num_rows_others));
1329 bool changes =
false;
1330 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1331 bool new_state = (i == click_pos);
1332 if (legend[i].show_on_map != new_state) {
1339 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1347 if (this->map_type == SMT_INDUSTRY) this->BreakIndustryChainLink();
1355 CargoTypes cargo_mask = 0;
1357 if (_legend_linkstats[i].show_on_map)
SetBit(cargo_mask, _legend_linkstats[i].type);
1359 this->overlay->SetCargoMask(cargo_mask);
1371 uint columns = this->GetNumberColumnsLegend(wi->
current_x);
1372 uint number_of_rows = this->GetNumberRowsLegend(columns);
1373 if (line >= number_of_rows)
return -1;
1376 int x = pt.x - wi->
pos_x;
1380 return (column * number_of_rows) + line;
1386 if (widget ==
WID_SM_LEGEND && this->map_type == SMT_INDUSTRY) {
1387 int industry_pos = GetPositionOnLegend(pt);
1389 new_highlight = _legend_from_industries[industry_pos].
type;
1404 if (click_count > 0) this->mouse_capture_widget = widget;
1409 pt = this->PixelToTile(pt.x - wid->
pos_x, pt.y - wid->
pos_y, &sub);
1420 this->SetZoomLevel((widget ==
WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
1437 this->SmallMapCenterOnCurrentPos();
1443 this->show_towns = !this->show_towns;
1451 if (this->map_type == SMT_INDUSTRY || this->map_type == SMT_LINKSTATS || this->map_type == SMT_OWNER) {
1452 int click_pos = this->GetPositionOnLegend(pt);
1453 if (click_pos < 0)
break;
1456 if (this->map_type == SMT_INDUSTRY) {
1461 }
else if (this->map_type == SMT_LINKSTATS) {
1464 this->SetOverlayCargoMask();
1466 }
else if (this->map_type == SMT_OWNER) {
1478 switch (this->map_type) {
1481 this->BreakIndustryChainLink();
1492 for (;!tbl->
end && tbl->
legend != STR_LINKGRAPH_LEGEND_UNUSED; ++tbl) {
1495 if (this->map_type == SMT_LINKSTATS) this->SetOverlayCargoMask();
1518 if (!gui_scope)
return;
1528 if (this->map_type != SMT_INDUSTRY) this->SwitchMapType(SMT_INDUSTRY);
1531 _legend_from_industries[i].
show_on_map = _displayed_industries.test(_legend_from_industries[i].type);
1537 this->RebuildColourIndexIfNecessary();
1540 default: NOT_REACHED();
1557 int cursor_x = _cursor.
pos.x - this->left - wid->
pos_x;
1558 int cursor_y = _cursor.
pos.y - this->top - wid->
pos_y;
1560 Point pt = {cursor_x, cursor_y};
1561 this->SetZoomLevel((wheel < 0) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
1569 if (!this->refresh.Elapsed(delta_ms))
return;
1571 if (this->map_type == SMT_LINKSTATS) {
1572 uint32 company_mask = this->GetOverlayCompanyMask();
1573 if (this->overlay->GetCompanyMask() != company_mask) {
1574 this->overlay->SetCompanyMask(company_mask);
1576 this->overlay->SetDirty();
1616 this->scroll_x = sx;
1617 this->scroll_y = sy;
1618 this->subscroll = sub;
1619 if (this->map_type == SMT_LINKSTATS) this->overlay->SetDirty();
1628 Point pt = this->PixelToTile(delta.x, delta.y, &sub);
1629 this->SetNewScroll(this->scroll_x + pt.x *
TILE_SIZE, this->scroll_y + pt.y *
TILE_SIZE, sub);
1644 Point sxy = this->ComputeScroll(viewport_center.x / (
int)
TILE_SIZE, viewport_center.y / (
int)TILE_SIZE,
1646 this->SetNewScroll(sxy.x, sxy.y, sub);
1657 int x = (st->
rect.right + st->
rect.left + 1) / 2;
1658 int y = (st->
rect.bottom + st->
rect.top + 1) / 2;
1659 Point ret = this->RemapTile(x, y);
1664 ret.x -= 3 + this->subscroll;
1685 this->smallmap_window = NULL;
1697 assert(this->smallmap_window != NULL);
1710 this->current_x = given_width;
1711 this->current_y = given_height;
1717 this->smallest_x = given_width;
1718 this->smallest_y = given_height;
1724 uint bar_height =
max(bar->
smallest_y, this->smallmap_window->GetLegendHeight(this->smallmap_window->GetNumberColumnsLegend(given_width - bar->
smallest_x)));
1725 uint display_height = given_height - bar_height;
1732 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return NULL;
1733 for (
NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->
next) {
1735 if (widget != NULL)
return widget;
1742 for (
NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->
next) child_wid->Draw(w);
1749 NWidget(
WWT_INSET, COLOUR_BROWN,
WID_SM_MAP),
SetMinimalSize(346, 140),
SetResize(1, 1),
SetPadding(2, 2, 2, 2),
EndContainer(),
1762 SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
SetFill(1, 1),
1768 SetDataTip(SPR_IMG_SHOW_COUNTOURS, STR_SMALLMAP_TOOLTIP_SHOW_LAND_CONTOURS_ON_MAP),
SetFill(1, 1),
1770 SetDataTip(SPR_IMG_SHOW_VEHICLES, STR_SMALLMAP_TOOLTIP_SHOW_VEHICLES_ON_MAP),
SetFill(1, 1),
1772 SetDataTip(SPR_IMG_INDUSTRY, STR_SMALLMAP_TOOLTIP_SHOW_INDUSTRIES_ON_MAP),
SetFill(1, 1),
1777 SetDataTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
SetFill(1, 1),
1779 SetDataTip(SPR_IMG_TOWN, STR_SMALLMAP_TOOLTIP_TOGGLE_TOWN_NAMES_ON_OFF),
SetFill(1, 1),
1781 SetDataTip(SPR_IMG_CARGOFLOW, STR_SMALLMAP_TOOLTIP_SHOW_LINK_STATS_ON_MAP),
SetFill(1, 1),
1783 SetDataTip(SPR_IMG_SHOW_ROUTES, STR_SMALLMAP_TOOLTIP_SHOW_TRANSPORT_ROUTES_ON),
SetFill(1, 1),
1785 SetDataTip(SPR_IMG_PLANTTREES, STR_SMALLMAP_TOOLTIP_SHOW_VEGETATION_ON_MAP),
SetFill(1, 1),
1787 SetDataTip(SPR_IMG_COMPANY_GENERAL, STR_SMALLMAP_TOOLTIP_SHOW_LAND_OWNERS_ON_MAP),
SetFill(1, 1),
1795 static NWidgetBase *SmallMapDisplay(
int *biggest_index)
1799 MakeNWidgets(_nested_smallmap_display,
lengthof(_nested_smallmap_display), biggest_index, map_display);
1800 MakeNWidgets(_nested_smallmap_bar,
lengthof(_nested_smallmap_bar), biggest_index, map_display);
1805 static const NWidgetPart _nested_smallmap_widgets[] = {
1835 _nested_smallmap_widgets,
lengthof(_nested_smallmap_widgets)
1843 AllocateWindowDescFront<SmallMapWindow>(&_smallmap_desc, 0);
1862 if (res)
return res;
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
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.
virtual void OnPaint()
The window must be repainted.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
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...
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.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
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...
Specification of a cargo type.
static const uint8 PC_TREES
Green palette colour for trees.
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.
IndustryType _sorted_industry_types[NUM_INDUSTRYTYPES]
Industry types sorted by name.
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".
uint8 _sorted_cargo_specs_size
Number of cargo specifications stored at the _sorted_cargo_specs array (including special cargoes)...
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.
static bool IsInsideBS(const T x, const uint base, const uint size)
Checks if a value is between a window started at some base point.
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.
Tindex index
Index of this pool item.
#define MK(a, b)
Macro for ordinary entry of LegendAndColour.
Structure for holding relevant data for legends in small map.
static const uint8 PC_LIGHT_BLUE
Light blue palette colour.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
static IndustryType _smallmap_industry_highlight
Highlight a specific industry type.
uint GetLegendHeight(uint num_columns) const
Compute height given a number of columns.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Function to handling different endian machines.
Map accessors for tree tiles.
uint8 height
Height in tiles. Only valid for height legend entries.
Colour scheme of the smallmap.
How all blitters should look like.
virtual bool OnRightClick(Point pt, int widget)
A click with the right mouse button has been made on the window.
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 const uint8 PC_FIELDS
Light brown palette colour for fields.
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.
StringID name
Name of this type of cargo.
StringID name
Displayed name of the industry.
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 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.
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.
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.
uint8 scroll_mode
viewport scroll mode
SmallMapType
Types of legends in the WID_SM_LEGEND widget.
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.
TileIndex xy
town center tile
static const uint8 PC_DARK_GREY
Dark grey palette colour.
static const AndOr _smallmap_vehicles_andor[]
Colour masks for "Vehicles", "Industry", and "Vegetation" modes.
ViewportSign sign
Location of name sign, UpdateVirtCoord updates this.
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.
virtual void OnRealtimeTick(uint delta_ms)
Called periodically.
size_t colour_count
The number of colours.
SoundSettings sound
sound effect settings
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.
#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.
virtual void OnMouseWheel(int wheel)
The mouse wheel has been turned.
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.
virtual void OnScroll(Point delta)
Handle the request for (viewport) scrolling.
Effect vehicle type (smoke, explosions, sparks, bubbles)
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.
virtual void OnMouseOver(Point pt, int widget)
The mouse is currently moving over the window or has just moved outside of the window.
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
The tile has no ownership.
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.
virtual void OnInit()
Notification that the nested widget tree gets initialized.
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.
Maximum number of companies.
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 const uint8 PC_BARE_LAND
Brown palette colour for bare land.
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 const uint8 PC_WATER
Dark blue palette colour for water.
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.
static const uint8 PC_YELLOW
Yellow palette colour.
static const uint8 PC_DARK_RED
Dark red palette colour.
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
static const IndustryType INVALID_INDUSTRYTYPE
one above amount is considered invalid
GUISettings gui
settings related to the GUI
Tunnel entry/exit and bridge heads.
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.
A town owns the tile, or a town is expanding.
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.
byte colour
Company colour.
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.
TownCache cache
Container for all cacheable data.
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
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.
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-NULL) Titem.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
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.
static const uint8 PC_ROUGH_LAND
Dark green palette colour for rough land.
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...
#define FOR_ALL_VEHICLES(var)
Iterate over all vehicles.
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)...
int virtual_top
Virtual top coordinate.
GameCreationSettings game_creation
settings used during the creation of a game (map)
A tile without any structures, i.e. grass, rocks, farm fields etc.
Specification of a rectangle with absolute coordinates of all edges.
uint16 width_small
The width when zoomed out (small font)
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.
Owner
Enum for all companies/owners.
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.
const CargoSpec * _sorted_cargo_specs[NUM_CARGO]
Cargo specifications sorted alphabetically by name.
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.
static const uint8 PC_GRASS_LAND
Dark green palette colour for grass land.
Industry cargoes chain; Window numbers:
The tile/execution is done by "water".
VehicleTypeByte type
Type of vehicle.
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.