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),
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]);
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;
477 _smallmap_contours_andor[t].mand
491 if (rti !=
nullptr) {
494 _smallmap_contours_andor[t].mand
506 return ApplyMask(cs->
default_colour, &_smallmap_contours_andor[t]);
522 static const uint32 _vegetation_clear_bits[] = {
556 return ApplyMask(MKCOLOUR_XXXX(
PC_GRASS_LAND), &_smallmap_vehicles_andor[t]);
604 inline Point SmallMapWindow::SmallmapRemapCoords(
int x,
int y)
const 620 int x_offset = tile_x - this->scroll_x / (int)
TILE_SIZE;
621 int y_offset = tile_y - this->scroll_y / (int)
TILE_SIZE;
623 if (this->zoom == 1)
return SmallmapRemapCoords(x_offset, y_offset);
626 if (x_offset < 0) x_offset -= this->zoom - 1;
627 if (y_offset < 0) y_offset -= this->zoom - 1;
629 return SmallmapRemapCoords(x_offset / this->zoom, y_offset / this->zoom);
644 if (add_sub) px += this->subscroll;
648 Point pt = {((py >> 1) - (px >> 2)) * this->zoom, ((py >> 1) + (px >> 2)) * this->zoom};
676 assert(x >= 0 && y >= 0);
679 Point tile_xy = PixelToTile(x, y, &new_sub,
false);
686 scroll.x = (tx + this->zoom) *
TILE_SIZE;
687 scroll.y = (ty - this->zoom) *
TILE_SIZE;
690 scroll.x = (tx + 2 * this->zoom) *
TILE_SIZE;
691 scroll.y = (ty - 2 * this->zoom) *
TILE_SIZE;
704 static const int zoomlevels[] = {1, 2, 4, 6, 8};
705 static const int MIN_ZOOM_INDEX = 0;
706 static const int MAX_ZOOM_INDEX =
lengthof(zoomlevels) - 1;
708 int new_index, cur_index, sub;
713 new_index = MIN_ZOOM_INDEX;
719 for (cur_index = MIN_ZOOM_INDEX; cur_index <= MAX_ZOOM_INDEX; cur_index++) {
720 if (this->zoom == zoomlevels[cur_index])
break;
722 assert(cur_index <= MAX_ZOOM_INDEX);
724 tile = this->PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
725 new_index =
Clamp(cur_index + ((change == ZLC_ZOOM_IN) ? -1 : 1), MIN_ZOOM_INDEX, MAX_ZOOM_INDEX);
728 default: NOT_REACHED();
731 if (new_index != cur_index) {
732 this->zoom = zoomlevels[new_index];
733 if (cur_index >= 0) {
734 Point new_tile = this->PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
735 this->SetNewScroll(this->scroll_x + (tile.x - new_tile.x) *
TILE_SIZE,
736 this->scroll_y + (tile.y - new_tile.y) *
TILE_SIZE, sub);
737 }
else if (this->map_type == SMT_LINKSTATS) {
738 this->overlay->SetDirty();
740 this->SetWidgetDisabledState(
WID_SM_ZOOM_IN, this->zoom == zoomlevels[MIN_ZOOM_INDEX]);
741 this->SetWidgetDisabledState(
WID_SM_ZOOM_OUT, this->zoom == zoomlevels[MAX_ZOOM_INDEX]);
774 if (this->map_type == SMT_INDUSTRY) {
801 switch (this->map_type) {
823 default: NOT_REACHED();
842 void *dst_ptr_abs_end = blitter->
MoveTo(_screen.dst_ptr, 0, _screen.height);
850 if (dst < _screen.dst_ptr)
continue;
851 if (dst >= dst_ptr_abs_end)
continue;
855 if (min_xy == 1 && (xc == 0 || yc == 0)) {
856 if (this->zoom == 1)
continue;
858 ta =
TileArea(
TileXY(
max(min_xy, xc),
max(min_xy, yc)), this->zoom - (xc == 0), this->zoom - (yc == 0));
864 uint32 val = this->GetTileColours(ta);
865 uint8 *val8 = (uint8 *)&val;
866 int idx =
max(0, -start_pos);
867 for (
int pos =
max(0, start_pos); pos < end_pos; pos++) {
868 blitter->
SetPixel(dst, idx, 0, val8[idx]);
872 }
while (xc += this->zoom, yc += this->zoom, dst = blitter->
MoveTo(dst, pitch, 0), --reps != 0);
890 int y = pt.y - dpi->top;
894 int x = pt.x - this->subscroll - 3 - dpi->left;
898 if (++x != 0)
continue;
900 }
else if (x >= dpi->width - 1) {
902 if (x != dpi->width - 1)
continue;
910 blitter->
SetPixel(dpi->dst_ptr, x, y, colour);
911 if (!skip) blitter->
SetPixel(dpi->dst_ptr, x + 1, y, colour);
930 x < dpi->left + dpi->width &&
932 y < dpi->top + dpi->height) {
951 Point upper_left = this->RemapTile(upper_left_smallmap_coord.x / (
int)
TILE_SIZE, upper_left_smallmap_coord.y / (
int)TILE_SIZE);
952 upper_left.x -= this->subscroll;
954 Point lower_right = this->RemapTile(lower_right_smallmap_coord.x / (
int)TILE_SIZE, lower_right_smallmap_coord.y / (
int)TILE_SIZE);
955 lower_right.x -= this->subscroll;
984 GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1,
PC_BLACK);
988 Point tile = this->PixelToTile(dpi->left, dpi->top, &dx);
989 int tile_x = this->scroll_x / (int)
TILE_SIZE + tile.x;
990 int tile_y = this->scroll_y / (
int)
TILE_SIZE + tile.y;
992 void *ptr = blitter->
MoveTo(dpi->dst_ptr, -dx - 4, 0);
999 if (x >= dpi->width)
break;
1001 int end_pos =
min(dpi->width, x + 4);
1002 int reps = (dpi->height - y + 1) / 2;
1004 this->DrawSmallMapColumn(ptr, tile_x, tile_y, dpi->pitch * 2, reps, x, end_pos, blitter);
1009 tile_y += this->zoom;
1011 ptr = blitter->
MoveTo(ptr, 0, 1);
1013 tile_x -= this->zoom;
1015 ptr = blitter->
MoveTo(ptr, 0, -1);
1017 ptr = blitter->
MoveTo(ptr, 2, 0);
1022 if (this->map_type == SMT_CONTOUR || this->map_type == SMT_VEHICLES) this->DrawVehicles(dpi, blitter);
1025 if (this->map_type == SMT_LINKSTATS) this->overlay->Draw(dpi);
1028 if (this->show_towns) this->DrawTowns(dpi);
1031 this->DrawMapIndicators();
1045 switch (this->map_type) {
1047 legend_tooltip = STR_SMALLMAP_TOOLTIP_INDUSTRY_SELECTION;
1048 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_INDUSTRIES;
1049 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_INDUSTRIES;
1054 legend_tooltip = STR_SMALLMAP_TOOLTIP_COMPANY_SELECTION;
1055 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_COMPANIES;
1056 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_COMPANIES;
1061 legend_tooltip = STR_SMALLMAP_TOOLTIP_CARGO_SELECTION;
1062 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_CARGOS;
1063 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_CARGOS;
1068 legend_tooltip = STR_NULL;
1069 enable_all_tooltip = STR_NULL;
1070 disable_all_tooltip = STR_NULL;
1081 SmallMapWindow::SmallMapWindow(
WindowDesc *desc,
int window_number) :
Window(desc), refresh(
GUITimer(FORCE_REFRESH_PERIOD))
1085 this->InitNested(window_number);
1088 this->RebuildColourIndexIfNecessary();
1094 this->SetupWidgetData();
1096 this->SetZoomLevel(ZLC_INITIALIZE,
nullptr);
1097 this->SmallMapCenterOnCurrentPos();
1098 this->SetOverlayCargoMask();
1101 SmallMapWindow::~SmallMapWindow()
1103 delete this->overlay;
1104 this->BreakIndustryChainLink();
1115 for (uint n = 0; n <
lengthof(_heightmap_schemes); n++) {
1120 for (
int z = 0; z < heights; z++) {
1121 size_t access_index = (_heightmap_schemes[n].
colour_count * z) / heights;
1136 SetDParam(0, STR_SMALLMAP_TYPE_CONTOURS + this->map_type);
1144 this->min_number_of_columns = INDUSTRY_MIN_NUMBER_OF_COLUMNS;
1146 for (uint i = 0; i <
lengthof(_legend_table); i++) {
1148 uint num_columns = 1;
1151 if (i == SMT_INDUSTRY) {
1154 str = STR_SMALLMAP_INDUSTRY;
1155 }
else if (i == SMT_LINKSTATS) {
1157 str = STR_SMALLMAP_LINKSTATS;
1158 }
else if (i == SMT_OWNER) {
1168 str = STR_SMALLMAP_COMPANY;
1173 if (tbl->col_break) {
1174 this->min_number_of_fixed_rows =
max(this->min_number_of_fixed_rows, height);
1183 this->min_number_of_fixed_rows =
max(this->min_number_of_fixed_rows, height);
1184 this->min_number_of_columns =
max(this->min_number_of_columns, num_columns);
1193 if (this->map_type == SMT_OWNER) {
1198 this->InvalidateData(1);
1204 this->DrawWidgets();
1212 if (!
FillDrawPixelInfo(&new_dpi, r.left + 1, r.top + 1, r.right - r.left - 1, r.bottom - r.top - 1))
return;
1213 this->DrawSmallMap(&new_dpi);
1218 uint columns = this->GetNumberColumnsLegend(r.right - r.left + 1);
1219 uint number_of_rows = this->GetNumberRowsLegend(columns);
1228 uint text_right = this->column_width - 1 - (rtl ? LEGEND_BLOB_WIDTH +
WD_FRAMERECT_RIGHT : 0);
1229 uint blob_left = rtl ? this->column_width - 1 - LEGEND_BLOB_WIDTH : 0;
1230 uint blob_right = rtl ? this->column_width - 1 : LEGEND_BLOB_WIDTH;
1233 switch (this->map_type) {
1235 string = STR_SMALLMAP_INDUSTRY;
1238 string = STR_SMALLMAP_LINKSTATS;
1241 string = STR_SMALLMAP_COMPANY;
1248 if (tbl->col_break || ((this->map_type == SMT_INDUSTRY || this->map_type == SMT_OWNER || this->map_type == SMT_LINKSTATS) && i++ >= number_of_rows)) {
1251 x += rtl ? -(int)this->column_width : this->column_width;
1256 uint8 legend_colour = tbl->colour;
1258 switch (this->map_type) {
1275 if (this->map_type == SMT_OWNER)
SetDParam(0, tbl->company);
1276 if (!tbl->show_on_map) {
1279 DrawString(x + text_left, x + text_right, y,
string, TC_GREY);
1281 DrawString(x + text_left, x + text_right, y,
string, TC_BLACK);
1292 DrawString(x + text_left, x + text_right, y, tbl->legend);
1295 GfxFillRect(x + blob_left + 1, y + 2, x + blob_right - 1, y + row_height - 2, legend_colour);
1310 this->map_type = map_type;
1313 this->SetupWidgetData();
1315 if (map_type == SMT_LINKSTATS) this->overlay->SetDirty();
1316 if (map_type != SMT_INDUSTRY) this->BreakIndustryChainLink();
1333 return max(this->min_number_of_fixed_rows,
max(num_rows_linkstats, num_rows_others));
1351 bool changes =
false;
1352 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1353 bool new_state = (i == click_pos);
1354 if (legend[i].show_on_map != new_state) {
1361 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1369 if (this->map_type == SMT_INDUSTRY) this->BreakIndustryChainLink();
1377 CargoTypes cargo_mask = 0;
1379 if (_legend_linkstats[i].show_on_map)
SetBit(cargo_mask, _legend_linkstats[i].type);
1381 this->overlay->SetCargoMask(cargo_mask);
1393 uint columns = this->GetNumberColumnsLegend(wi->
current_x);
1394 uint number_of_rows = this->GetNumberRowsLegend(columns);
1395 if (line >= number_of_rows)
return -1;
1398 int x = pt.x - wi->
pos_x;
1402 return (column * number_of_rows) + line;
1408 if (widget ==
WID_SM_LEGEND && this->map_type == SMT_INDUSTRY) {
1409 int industry_pos = GetPositionOnLegend(pt);
1411 new_highlight = _legend_from_industries[industry_pos].
type;
1426 if (click_count > 0) this->mouse_capture_widget = widget;
1431 pt = this->PixelToTile(pt.x - wid->
pos_x, pt.y - wid->
pos_y, &sub);
1442 this->SetZoomLevel((widget ==
WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
1459 this->SmallMapCenterOnCurrentPos();
1465 this->show_towns = !this->show_towns;
1473 if (this->map_type == SMT_INDUSTRY || this->map_type == SMT_LINKSTATS || this->map_type == SMT_OWNER) {
1474 int click_pos = this->GetPositionOnLegend(pt);
1475 if (click_pos < 0)
break;
1478 if (this->map_type == SMT_INDUSTRY) {
1483 }
else if (this->map_type == SMT_LINKSTATS) {
1486 this->SetOverlayCargoMask();
1488 }
else if (this->map_type == SMT_OWNER) {
1500 switch (this->map_type) {
1503 this->BreakIndustryChainLink();
1514 for (;!tbl->
end && tbl->
legend != STR_LINKGRAPH_LEGEND_UNUSED; ++tbl) {
1517 if (this->map_type == SMT_LINKSTATS) this->SetOverlayCargoMask();
1540 if (!gui_scope)
return;
1550 if (this->map_type != SMT_INDUSTRY) this->SwitchMapType(SMT_INDUSTRY);
1553 _legend_from_industries[i].
show_on_map = _displayed_industries.test(_legend_from_industries[i].type);
1559 this->RebuildColourIndexIfNecessary();
1562 default: NOT_REACHED();
1579 int cursor_x = _cursor.
pos.x - this->left - wid->
pos_x;
1580 int cursor_y = _cursor.
pos.y - this->top - wid->
pos_y;
1582 Point pt = {cursor_x, cursor_y};
1583 this->SetZoomLevel((wheel < 0) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
1591 if (!this->refresh.Elapsed(delta_ms))
return;
1593 if (this->map_type == SMT_LINKSTATS) {
1594 uint32 company_mask = this->GetOverlayCompanyMask();
1595 if (this->overlay->GetCompanyMask() != company_mask) {
1596 this->overlay->SetCompanyMask(company_mask);
1598 this->overlay->SetDirty();
1638 this->scroll_x = sx;
1639 this->scroll_y = sy;
1640 this->subscroll = sub;
1641 if (this->map_type == SMT_LINKSTATS) this->overlay->SetDirty();
1650 Point pt = this->PixelToTile(delta.x, delta.y, &sub);
1651 this->SetNewScroll(this->scroll_x + pt.x *
TILE_SIZE, this->scroll_y + pt.y *
TILE_SIZE, sub);
1666 Point sxy = this->ComputeScroll(viewport_center.x / (
int)
TILE_SIZE, viewport_center.y / (
int)TILE_SIZE,
1668 this->SetNewScroll(sxy.x, sxy.y, sub);
1679 int x = (st->
rect.right + st->
rect.left + 1) / 2;
1680 int y = (st->
rect.bottom + st->
rect.top + 1) / 2;
1681 Point ret = this->RemapTile(x, y);
1686 ret.x -= 3 + this->subscroll;
1707 this->smallmap_window =
nullptr;
1719 assert(this->smallmap_window !=
nullptr);
1732 this->current_x = given_width;
1733 this->current_y = given_height;
1739 this->smallest_x = given_width;
1740 this->smallest_y = given_height;
1746 uint bar_height =
max(bar->
smallest_y, this->smallmap_window->GetLegendHeight(this->smallmap_window->GetNumberColumnsLegend(given_width - bar->
smallest_x)));
1747 uint display_height = given_height - bar_height;
1754 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return nullptr;
1755 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1757 if (widget !=
nullptr)
return widget;
1764 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) child_wid->Draw(w);
1771 NWidget(
WWT_INSET, COLOUR_BROWN,
WID_SM_MAP),
SetMinimalSize(346, 140),
SetResize(1, 1),
SetPadding(2, 2, 2, 2),
EndContainer(),
1784 SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
SetFill(1, 1),
1790 SetDataTip(SPR_IMG_SHOW_COUNTOURS, STR_SMALLMAP_TOOLTIP_SHOW_LAND_CONTOURS_ON_MAP),
SetFill(1, 1),
1792 SetDataTip(SPR_IMG_SHOW_VEHICLES, STR_SMALLMAP_TOOLTIP_SHOW_VEHICLES_ON_MAP),
SetFill(1, 1),
1794 SetDataTip(SPR_IMG_INDUSTRY, STR_SMALLMAP_TOOLTIP_SHOW_INDUSTRIES_ON_MAP),
SetFill(1, 1),
1799 SetDataTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
SetFill(1, 1),
1801 SetDataTip(SPR_IMG_TOWN, STR_SMALLMAP_TOOLTIP_TOGGLE_TOWN_NAMES_ON_OFF),
SetFill(1, 1),
1803 SetDataTip(SPR_IMG_CARGOFLOW, STR_SMALLMAP_TOOLTIP_SHOW_LINK_STATS_ON_MAP),
SetFill(1, 1),
1805 SetDataTip(SPR_IMG_SHOW_ROUTES, STR_SMALLMAP_TOOLTIP_SHOW_TRANSPORT_ROUTES_ON),
SetFill(1, 1),
1807 SetDataTip(SPR_IMG_PLANTTREES, STR_SMALLMAP_TOOLTIP_SHOW_VEGETATION_ON_MAP),
SetFill(1, 1),
1809 SetDataTip(SPR_IMG_COMPANY_GENERAL, STR_SMALLMAP_TOOLTIP_SHOW_LAND_OWNERS_ON_MAP),
SetFill(1, 1),
1817 static NWidgetBase *SmallMapDisplay(
int *biggest_index)
1821 MakeNWidgets(_nested_smallmap_display,
lengthof(_nested_smallmap_display), biggest_index, map_display);
1822 MakeNWidgets(_nested_smallmap_bar,
lengthof(_nested_smallmap_bar), biggest_index, map_display);
1827 static const NWidgetPart _nested_smallmap_widgets[] = {
1857 _nested_smallmap_widgets,
lengthof(_nested_smallmap_widgets)
1865 AllocateWindowDescFront<SmallMapWindow>(&_smallmap_desc, 0);
1884 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.
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.
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.
Tindex index
Index of this pool item.
#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.
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 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.
void OnPaint() override
The window must be repainted.
StringID name
Name of this type of cargo.
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.
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.
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
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.
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 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.
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.
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.
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.
VehicleType type
Type of vehicle.
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.
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.
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.
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)...
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.
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.
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.
static const uint8 PC_GRASS_LAND
Dark green palette colour for grass land.
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.