29 #include "table/strings.h" 52 #define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} 55 #define MC(col_break) {0, STR_TINY_BLACK_HEIGHT, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, col_break} 58 #define MO(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} 61 #define MOEND() {0, 0, INVALID_INDUSTRYTYPE, 0, OWNER_NONE, true, true, false} 64 #define MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, true, false} 70 #define MS(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, true} 75 MK(
PC_GREY, STR_SMALLMAP_LEGENDA_RAILROADS),
99 MK(
PC_RED, STR_SMALLMAP_LEGENDA_TRAINS),
104 MS(
PC_BLACK, STR_SMALLMAP_LEGENDA_TRANSPORT_ROUTES),
111 MK(
PC_GREY, STR_SMALLMAP_LEGENDA_RAILROADS),
115 MK(
PC_ORANGE, STR_SMALLMAP_LEGENDA_TRUCK_LOADING_BAY),
117 MK(
PC_RED, STR_SMALLMAP_LEGENDA_AIRPORT_HELIPORT),
133 MK(
PC_BLACK, STR_SMALLMAP_LEGENDA_TRANSPORT_ROUTES),
140 MO(0x00, STR_SMALLMAP_LEGENDA_NO_OWNER),
184 _legend_from_industries[j].
legend = indsp->
name;
186 _legend_from_industries[j].
type = ind;
188 _legend_from_industries[j].
col_break =
false;
189 _legend_from_industries[j].
end =
false;
197 _legend_from_industries[j].
end =
true;
209 memset(_legend_linkstats, 0,
sizeof(_legend_linkstats));
216 _legend_linkstats[i].
colour = cs->legend_colour;
225 _legend_linkstats[i].
legend = STR_EMPTY;
231 _legend_linkstats[i - 1].
legend = STR_LINKGRAPH_LEGEND_OVERLOADED;
233 _legend_linkstats[i].
end =
true;
246 #define MKCOLOUR(x) TO_LE32X(x) 248 #define MKCOLOUR_XXXX(x) (MKCOLOUR(0x01010101) * (uint)(x)) 249 #define MKCOLOUR_X0X0(x) (MKCOLOUR(0x01000100) * (uint)(x)) 250 #define MKCOLOUR_0X0X(x) (MKCOLOUR(0x00010001) * (uint)(x)) 251 #define MKCOLOUR_0XX0(x) (MKCOLOUR(0x00010100) * (uint)(x)) 252 #define MKCOLOUR_X00X(x) (MKCOLOUR(0x01000001) * (uint)(x)) 254 #define MKCOLOUR_XYXY(x, y) (MKCOLOUR_X0X0(x) | MKCOLOUR_0X0X(y)) 255 #define MKCOLOUR_XYYX(x, y) (MKCOLOUR_X00X(x) | MKCOLOUR_0XX0(y)) 257 #define MKCOLOUR_0000 MKCOLOUR_XXXX(0x00) 258 #define MKCOLOUR_0FF0 MKCOLOUR_0XX0(0xFF) 259 #define MKCOLOUR_F00F MKCOLOUR_X00X(0xFF) 260 #define MKCOLOUR_FFFF MKCOLOUR_XXXX(0xFF) 307 uint deltas[][2] = { { 24, 2 }, { 48, 4 }, { 72, 6 }, { 120, 10 }, { 180, 15 }, { 240, 20 }, {
MAX_TILE_HEIGHT + 1, 25 }};
312 uint delta = deltas[i][1];
315 int rows =
CeilDiv(total_entries, 2);
318 for (i = 0; i <
lengthof(_legend_land_contours) - 1 && j < total_entries; i++) {
319 if (_legend_land_contours[i].legend != STR_TINY_BLACK_HEIGHT)
continue;
321 _legend_land_contours[i].
col_break = j % rows == 0;
322 _legend_land_contours[i].
end =
false;
323 _legend_land_contours[i].
height = j * delta;
327 _legend_land_contours[i].
end =
true;
339 FOR_ALL_COMPANIES(c) {
343 _legend_land_owners[i].
col_break =
false;
344 _legend_land_owners[i].
end =
false;
350 _legend_land_owners[i].
end =
true;
361 static inline uint32 ApplyMask(uint32 colour,
const AndOr *mask)
363 return (colour & mask->mand) | mask->mor;
369 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
370 {MKCOLOUR_0XX0(
PC_GREY ), MKCOLOUR_F00F},
371 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
373 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
375 {MKCOLOUR_XXXX(
PC_WATER ), MKCOLOUR_0000},
376 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
378 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
380 {MKCOLOUR_0XX0(
PC_GREY ), MKCOLOUR_F00F},
385 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
386 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
387 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
389 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
390 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
391 {MKCOLOUR_XXXX(
PC_WATER ), MKCOLOUR_0000},
392 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
394 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
396 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
438 return ApplyMask(cs->
default_colour, &_smallmap_vehicles_andor[t]);
466 case STATION_AIRPORT:
return MKCOLOUR_XXXX(
PC_RED);
467 case STATION_TRUCK:
return MKCOLOUR_XXXX(
PC_ORANGE);
468 case STATION_BUS:
return MKCOLOUR_XXXX(
PC_YELLOW);
470 default:
return MKCOLOUR_FFFF;
475 _smallmap_contours_andor[t].mand
484 return ApplyMask(cs->
default_colour, &_smallmap_contours_andor[t]);
499 static const uint32 _vegetation_clear_bits[] = {
533 return ApplyMask(MKCOLOUR_XXXX(
PC_GRASS_LAND), &_smallmap_vehicles_andor[t]);
581 inline Point SmallMapWindow::SmallmapRemapCoords(
int x,
int y)
const 597 int x_offset = tile_x - this->scroll_x / (int)
TILE_SIZE;
598 int y_offset = tile_y - this->scroll_y / (int)
TILE_SIZE;
600 if (this->zoom == 1)
return SmallmapRemapCoords(x_offset, y_offset);
603 if (x_offset < 0) x_offset -= this->zoom - 1;
604 if (y_offset < 0) y_offset -= this->zoom - 1;
606 return SmallmapRemapCoords(x_offset / this->zoom, y_offset / this->zoom);
621 if (add_sub) px += this->subscroll;
625 Point pt = {((py >> 1) - (px >> 2)) * this->zoom, ((py >> 1) + (px >> 2)) * this->zoom};
653 assert(x >= 0 && y >= 0);
656 Point tile_xy = PixelToTile(x, y, &new_sub,
false);
663 scroll.x = (tx + this->zoom) *
TILE_SIZE;
664 scroll.y = (ty - this->zoom) *
TILE_SIZE;
667 scroll.x = (tx + 2 * this->zoom) *
TILE_SIZE;
668 scroll.y = (ty - 2 * this->zoom) *
TILE_SIZE;
681 static const int zoomlevels[] = {1, 2, 4, 6, 8};
682 static const int MIN_ZOOM_INDEX = 0;
683 static const int MAX_ZOOM_INDEX =
lengthof(zoomlevels) - 1;
685 int new_index, cur_index, sub;
690 new_index = MIN_ZOOM_INDEX;
696 for (cur_index = MIN_ZOOM_INDEX; cur_index <= MAX_ZOOM_INDEX; cur_index++) {
697 if (this->zoom == zoomlevels[cur_index])
break;
699 assert(cur_index <= MAX_ZOOM_INDEX);
701 tile = this->PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
702 new_index =
Clamp(cur_index + ((change == ZLC_ZOOM_IN) ? -1 : 1), MIN_ZOOM_INDEX, MAX_ZOOM_INDEX);
705 default: NOT_REACHED();
708 if (new_index != cur_index) {
709 this->zoom = zoomlevels[new_index];
710 if (cur_index >= 0) {
711 Point new_tile = this->PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
712 this->SetNewScroll(this->scroll_x + (tile.x - new_tile.x) *
TILE_SIZE,
713 this->scroll_y + (tile.y - new_tile.y) *
TILE_SIZE, sub);
714 }
else if (this->map_type == SMT_LINKSTATS) {
715 this->overlay->RebuildCache();
717 this->SetWidgetDisabledState(
WID_SM_ZOOM_IN, this->zoom == zoomlevels[MIN_ZOOM_INDEX]);
718 this->SetWidgetDisabledState(
WID_SM_ZOOM_OUT, this->zoom == zoomlevels[MAX_ZOOM_INDEX]);
751 if (this->map_type == SMT_INDUSTRY) {
778 switch (this->map_type) {
800 default: NOT_REACHED();
819 void *dst_ptr_abs_end = blitter->
MoveTo(_screen.dst_ptr, 0, _screen.height);
827 if (dst < _screen.dst_ptr)
continue;
828 if (dst >= dst_ptr_abs_end)
continue;
832 if (min_xy == 1 && (xc == 0 || yc == 0)) {
833 if (this->zoom == 1)
continue;
835 ta =
TileArea(
TileXY(
max(min_xy, xc),
max(min_xy, yc)), this->zoom - (xc == 0), this->zoom - (yc == 0));
841 uint32 val = this->GetTileColours(ta);
842 uint8 *val8 = (uint8 *)&val;
843 int idx =
max(0, -start_pos);
844 for (
int pos =
max(0, start_pos); pos < end_pos; pos++) {
845 blitter->
SetPixel(dst, idx, 0, val8[idx]);
849 }
while (xc += this->zoom, yc += this->zoom, dst = blitter->
MoveTo(dst, pitch, 0), --reps != 0);
867 int y = pt.y - dpi->top;
871 int x = pt.x - this->subscroll - 3 - dpi->left;
875 if (++x != 0)
continue;
877 }
else if (x >= dpi->width - 1) {
879 if (x != dpi->width - 1)
continue;
887 blitter->
SetPixel(dpi->dst_ptr, x, y, colour);
888 if (!skip) blitter->
SetPixel(dpi->dst_ptr, x + 1, y, colour);
907 x < dpi->left + dpi->width &&
909 y < dpi->top + dpi->height) {
928 Point upper_left = this->RemapTile(upper_left_smallmap_coord.x / (
int)
TILE_SIZE, upper_left_smallmap_coord.y / (
int)TILE_SIZE);
929 upper_left.x -= this->subscroll;
931 Point lower_right = this->RemapTile(lower_right_smallmap_coord.x / (
int)TILE_SIZE, lower_right_smallmap_coord.y / (
int)TILE_SIZE);
932 lower_right.x -= this->subscroll;
961 GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1,
PC_BLACK);
965 Point tile = this->PixelToTile(dpi->left, dpi->top, &dx);
966 int tile_x = this->scroll_x / (int)
TILE_SIZE + tile.x;
967 int tile_y = this->scroll_y / (
int)
TILE_SIZE + tile.y;
969 void *ptr = blitter->
MoveTo(dpi->dst_ptr, -dx - 4, 0);
976 if (x >= dpi->width)
break;
978 int end_pos =
min(dpi->width, x + 4);
979 int reps = (dpi->height - y + 1) / 2;
981 this->DrawSmallMapColumn(ptr, tile_x, tile_y, dpi->pitch * 2, reps, x, end_pos, blitter);
986 tile_y += this->zoom;
988 ptr = blitter->
MoveTo(ptr, 0, 1);
990 tile_x -= this->zoom;
992 ptr = blitter->
MoveTo(ptr, 0, -1);
994 ptr = blitter->
MoveTo(ptr, 2, 0);
999 if (this->map_type == SMT_CONTOUR || this->map_type == SMT_VEHICLES) this->DrawVehicles(dpi, blitter);
1002 if (this->map_type == SMT_LINKSTATS) this->overlay->Draw(dpi);
1005 if (this->show_towns) this->DrawTowns(dpi);
1008 this->DrawMapIndicators();
1022 switch (this->map_type) {
1024 legend_tooltip = STR_SMALLMAP_TOOLTIP_INDUSTRY_SELECTION;
1025 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_INDUSTRIES;
1026 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_INDUSTRIES;
1031 legend_tooltip = STR_SMALLMAP_TOOLTIP_COMPANY_SELECTION;
1032 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_COMPANIES;
1033 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_COMPANIES;
1038 legend_tooltip = STR_SMALLMAP_TOOLTIP_CARGO_SELECTION;
1039 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_CARGOS;
1040 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_CARGOS;
1045 legend_tooltip = STR_NULL;
1046 enable_all_tooltip = STR_NULL;
1047 disable_all_tooltip = STR_NULL;
1058 SmallMapWindow::SmallMapWindow(
WindowDesc *desc,
int window_number) :
Window(desc), refresh(FORCE_REFRESH_PERIOD)
1062 this->InitNested(window_number);
1065 this->RebuildColourIndexIfNecessary();
1071 this->SetupWidgetData();
1073 this->SetZoomLevel(ZLC_INITIALIZE, NULL);
1074 this->SmallMapCenterOnCurrentPos();
1075 this->SetOverlayCargoMask();
1078 SmallMapWindow::~SmallMapWindow()
1080 delete this->overlay;
1081 this->BreakIndustryChainLink();
1092 for (uint n = 0; n <
lengthof(_heightmap_schemes); n++) {
1097 for (
int z = 0; z < heights; z++) {
1098 size_t access_index = (_heightmap_schemes[n].
colour_count * z) / heights;
1113 SetDParam(0, STR_SMALLMAP_TYPE_CONTOURS + this->map_type);
1121 this->min_number_of_columns = INDUSTRY_MIN_NUMBER_OF_COLUMNS;
1123 for (uint i = 0; i <
lengthof(_legend_table); i++) {
1125 uint num_columns = 1;
1128 if (i == SMT_INDUSTRY) {
1131 str = STR_SMALLMAP_INDUSTRY;
1132 }
else if (i == SMT_LINKSTATS) {
1134 str = STR_SMALLMAP_LINKSTATS;
1135 }
else if (i == SMT_OWNER) {
1145 str = STR_SMALLMAP_COMPANY;
1150 if (tbl->col_break) {
1151 this->min_number_of_fixed_rows =
max(this->min_number_of_fixed_rows, height);
1160 this->min_number_of_fixed_rows =
max(this->min_number_of_fixed_rows, height);
1161 this->min_number_of_columns =
max(this->min_number_of_columns, num_columns);
1170 if (this->map_type == SMT_OWNER) {
1175 this->InvalidateData(1);
1181 this->DrawWidgets();
1189 if (!
FillDrawPixelInfo(&new_dpi, r.left + 1, r.top + 1, r.right - r.left - 1, r.bottom - r.top - 1))
return;
1190 this->DrawSmallMap(&new_dpi);
1195 uint columns = this->GetNumberColumnsLegend(r.right - r.left + 1);
1196 uint number_of_rows = this->GetNumberRowsLegend(columns);
1205 uint text_right = this->column_width - 1 - (rtl ? LEGEND_BLOB_WIDTH +
WD_FRAMERECT_RIGHT : 0);
1206 uint blob_left = rtl ? this->column_width - 1 - LEGEND_BLOB_WIDTH : 0;
1207 uint blob_right = rtl ? this->column_width - 1 : LEGEND_BLOB_WIDTH;
1210 switch (this->map_type) {
1212 string = STR_SMALLMAP_INDUSTRY;
1215 string = STR_SMALLMAP_LINKSTATS;
1218 string = STR_SMALLMAP_COMPANY;
1225 if (tbl->col_break || ((this->map_type == SMT_INDUSTRY || this->map_type == SMT_OWNER || this->map_type == SMT_LINKSTATS) && i++ >= number_of_rows)) {
1228 x += rtl ? -(int)this->column_width : this->column_width;
1233 uint8 legend_colour = tbl->colour;
1235 switch (this->map_type) {
1252 if (this->map_type == SMT_OWNER)
SetDParam(0, tbl->company);
1253 if (!tbl->show_on_map) {
1256 DrawString(x + text_left, x + text_right, y,
string, TC_GREY);
1258 DrawString(x + text_left, x + text_right, y,
string, TC_BLACK);
1269 DrawString(x + text_left, x + text_right, y, tbl->legend);
1272 GfxFillRect(x + blob_left + 1, y + 2, x + blob_right - 1, y + row_height - 2, legend_colour);
1287 this->map_type = map_type;
1290 this->SetupWidgetData();
1292 if (map_type == SMT_LINKSTATS) this->overlay->RebuildCache();
1293 if (map_type != SMT_INDUSTRY) this->BreakIndustryChainLink();
1310 return max(this->min_number_of_fixed_rows,
max(num_rows_linkstats, num_rows_others));
1328 bool changes =
false;
1329 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1330 bool new_state = (i == click_pos);
1331 if (legend[i].show_on_map != new_state) {
1338 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1346 if (this->map_type == SMT_INDUSTRY) this->BreakIndustryChainLink();
1354 uint32 cargo_mask = 0;
1356 if (_legend_linkstats[i].show_on_map)
SetBit(cargo_mask, _legend_linkstats[i].type);
1358 this->overlay->SetCargoMask(cargo_mask);
1370 uint columns = this->GetNumberColumnsLegend(wi->
current_x);
1371 uint number_of_rows = this->GetNumberRowsLegend(columns);
1372 if (line >= number_of_rows)
return -1;
1375 int x = pt.x - wi->
pos_x;
1379 return (column * number_of_rows) + line;
1385 if (widget ==
WID_SM_LEGEND && this->map_type == SMT_INDUSTRY) {
1386 int industry_pos = GetPositionOnLegend(pt);
1388 new_highlight = _legend_from_industries[industry_pos].
type;
1416 pt = this->PixelToTile(pt.x - wid->
pos_x, pt.y - wid->
pos_y, &sub);
1427 this->SetZoomLevel((widget ==
WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
1444 this->SmallMapCenterOnCurrentPos();
1450 this->show_towns = !this->show_towns;
1458 if (this->map_type == SMT_INDUSTRY || this->map_type == SMT_LINKSTATS || this->map_type == SMT_OWNER) {
1459 int click_pos = this->GetPositionOnLegend(pt);
1460 if (click_pos < 0)
break;
1463 if (this->map_type == SMT_INDUSTRY) {
1468 }
else if (this->map_type == SMT_LINKSTATS) {
1471 this->SetOverlayCargoMask();
1473 }
else if (this->map_type == SMT_OWNER) {
1485 switch (this->map_type) {
1488 this->BreakIndustryChainLink();
1499 for (;!tbl->
end && tbl->
legend != STR_LINKGRAPH_LEGEND_UNUSED; ++tbl) {
1502 if (this->map_type == SMT_LINKSTATS) this->SetOverlayCargoMask();
1525 if (!gui_scope)
return;
1535 if (this->map_type != SMT_INDUSTRY) this->SwitchMapType(SMT_INDUSTRY);
1538 _legend_from_industries[i].
show_on_map = _displayed_industries.test(_legend_from_industries[i].type);
1544 this->RebuildColourIndexIfNecessary();
1547 default: NOT_REACHED();
1564 int cursor_x = _cursor.
pos.x - this->left - wid->
pos_x;
1565 int cursor_y = _cursor.
pos.y - this->top - wid->
pos_y;
1567 Point pt = {cursor_x, cursor_y};
1568 this->SetZoomLevel((wheel < 0) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
1576 if (--this->refresh != 0)
return;
1578 if (this->map_type == SMT_LINKSTATS) {
1579 uint32 company_mask = this->GetOverlayCompanyMask();
1580 if (this->overlay->GetCompanyMask() != company_mask) {
1581 this->overlay->SetCompanyMask(company_mask);
1583 this->overlay->RebuildCache();
1623 this->scroll_x = sx;
1624 this->scroll_y = sy;
1625 this->subscroll = sub;
1626 if (this->map_type == SMT_LINKSTATS) this->overlay->RebuildCache();
1635 Point pt = this->PixelToTile(delta.x, delta.y, &sub);
1636 this->SetNewScroll(this->scroll_x + pt.x *
TILE_SIZE, this->scroll_y + pt.y *
TILE_SIZE, sub);
1651 Point sxy = this->ComputeScroll(viewport_center.x / (
int)
TILE_SIZE, viewport_center.y / (
int)TILE_SIZE,
1653 this->SetNewScroll(sxy.x, sxy.y, sub);
1664 int x = (st->
rect.right + st->
rect.left + 1) / 2;
1665 int y = (st->
rect.bottom + st->
rect.top + 1) / 2;
1666 Point ret = this->RemapTile(x, y);
1671 ret.x -= 3 + this->subscroll;
1692 this->smallmap_window = NULL;
1704 assert(this->smallmap_window != NULL);
1717 this->current_x = given_width;
1718 this->current_y = given_height;
1724 this->smallest_x = given_width;
1725 this->smallest_y = given_height;
1731 uint bar_height =
max(bar->
smallest_y, this->smallmap_window->GetLegendHeight(this->smallmap_window->GetNumberColumnsLegend(given_width - bar->
smallest_x)));
1732 uint display_height = given_height - bar_height;
1739 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return NULL;
1740 for (
NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->
next) {
1742 if (widget != NULL)
return widget;
1749 for (
NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->
next) child_wid->Draw(w);
1756 NWidget(
WWT_INSET, COLOUR_BROWN,
WID_SM_MAP),
SetMinimalSize(346, 140),
SetResize(1, 1),
SetPadding(2, 2, 2, 2),
EndContainer(),
1769 SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
SetFill(1, 1),
1775 SetDataTip(SPR_IMG_SHOW_COUNTOURS, STR_SMALLMAP_TOOLTIP_SHOW_LAND_CONTOURS_ON_MAP),
SetFill(1, 1),
1777 SetDataTip(SPR_IMG_SHOW_VEHICLES, STR_SMALLMAP_TOOLTIP_SHOW_VEHICLES_ON_MAP),
SetFill(1, 1),
1779 SetDataTip(SPR_IMG_INDUSTRY, STR_SMALLMAP_TOOLTIP_SHOW_INDUSTRIES_ON_MAP),
SetFill(1, 1),
1784 SetDataTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
SetFill(1, 1),
1786 SetDataTip(SPR_IMG_TOWN, STR_SMALLMAP_TOOLTIP_TOGGLE_TOWN_NAMES_ON_OFF),
SetFill(1, 1),
1788 SetDataTip(SPR_IMG_CARGOFLOW, STR_SMALLMAP_TOOLTIP_SHOW_LINK_STATS_ON_MAP),
SetFill(1, 1),
1790 SetDataTip(SPR_IMG_SHOW_ROUTES, STR_SMALLMAP_TOOLTIP_SHOW_TRANSPORT_ROUTES_ON),
SetFill(1, 1),
1792 SetDataTip(SPR_IMG_PLANTTREES, STR_SMALLMAP_TOOLTIP_SHOW_VEGETATION_ON_MAP),
SetFill(1, 1),
1794 SetDataTip(SPR_IMG_COMPANY_GENERAL, STR_SMALLMAP_TOOLTIP_SHOW_LAND_OWNERS_ON_MAP),
SetFill(1, 1),
1802 static NWidgetBase *SmallMapDisplay(
int *biggest_index)
1806 MakeNWidgets(_nested_smallmap_display,
lengthof(_nested_smallmap_display), biggest_index, map_display);
1807 MakeNWidgets(_nested_smallmap_bar,
lengthof(_nested_smallmap_bar), biggest_index, map_display);
1812 static const NWidgetPart _nested_smallmap_widgets[] = {
1842 _nested_smallmap_widgets,
lengthof(_nested_smallmap_widgets)
1850 AllocateWindowDescFront<SmallMapWindow>(&_smallmap_desc, 0);
1869 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
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.
int height
Screen height of the viewport.
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)
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.
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 void OnTick()
Called once per (game) tick.
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.
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.
bool _left_button_clicked
Is left mouse button clicked?
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.
Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y, bool clamp_to_map)
Translate screen coordinate in a viewport to a tile coordinate.
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.
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.
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.
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.
Maximal number of cargo types in a game.
static uint GetClearDensity(TileIndex t)
Get the density of a non-field clear tile.
int left
Screen coordinate left egde of the viewport.
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.
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.
#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)...
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.
int top
Screen coordinate top edge of the viewport.
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.
int width
Screen width of the viewport.
void BuildIndustriesLegend()
Fills an array for the industries legends.