28 #include "table/strings.h" 51 #define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} 54 #define MC(col_break) {0, STR_TINY_BLACK_HEIGHT, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, col_break} 57 #define MO(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} 60 #define MOEND() {0, 0, INVALID_INDUSTRYTYPE, 0, OWNER_NONE, true, true, false} 63 #define MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, true, false} 69 #define MS(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, true} 74 MK(
PC_GREY, STR_SMALLMAP_LEGENDA_RAILROADS),
98 MK(
PC_RED, STR_SMALLMAP_LEGENDA_TRAINS),
103 MS(
PC_BLACK, STR_SMALLMAP_LEGENDA_TRANSPORT_ROUTES),
110 MK(
PC_GREY, STR_SMALLMAP_LEGENDA_RAILROADS),
114 MK(
PC_ORANGE, STR_SMALLMAP_LEGENDA_TRUCK_LOADING_BAY),
116 MK(
PC_RED, STR_SMALLMAP_LEGENDA_AIRPORT_HELIPORT),
132 MK(
PC_BLACK, STR_SMALLMAP_LEGENDA_TRANSPORT_ROUTES),
139 MO(0x00, STR_SMALLMAP_LEGENDA_NO_OWNER),
182 _legend_from_industries[j].
legend = indsp->
name;
184 _legend_from_industries[j].
type = ind;
186 _legend_from_industries[j].
col_break =
false;
187 _legend_from_industries[j].
end =
false;
195 _legend_from_industries[j].
end =
true;
207 memset(_legend_linkstats, 0,
sizeof(_legend_linkstats));
214 _legend_linkstats[i].
colour = cs->legend_colour;
223 _legend_linkstats[i].
legend = STR_EMPTY;
229 _legend_linkstats[i - 1].
legend = STR_LINKGRAPH_LEGEND_OVERLOADED;
231 _legend_linkstats[i].
end =
true;
244 #define MKCOLOUR(x) TO_LE32X(x) 246 #define MKCOLOUR_XXXX(x) (MKCOLOUR(0x01010101) * (uint)(x)) 247 #define MKCOLOUR_X0X0(x) (MKCOLOUR(0x01000100) * (uint)(x)) 248 #define MKCOLOUR_0X0X(x) (MKCOLOUR(0x00010001) * (uint)(x)) 249 #define MKCOLOUR_0XX0(x) (MKCOLOUR(0x00010100) * (uint)(x)) 250 #define MKCOLOUR_X00X(x) (MKCOLOUR(0x01000001) * (uint)(x)) 252 #define MKCOLOUR_XYXY(x, y) (MKCOLOUR_X0X0(x) | MKCOLOUR_0X0X(y)) 253 #define MKCOLOUR_XYYX(x, y) (MKCOLOUR_X00X(x) | MKCOLOUR_0XX0(y)) 255 #define MKCOLOUR_0000 MKCOLOUR_XXXX(0x00) 256 #define MKCOLOUR_0FF0 MKCOLOUR_0XX0(0xFF) 257 #define MKCOLOUR_F00F MKCOLOUR_X00X(0xFF) 258 #define MKCOLOUR_FFFF MKCOLOUR_XXXX(0xFF) 305 uint deltas[][2] = { { 24, 2 }, { 48, 4 }, { 72, 6 }, { 120, 10 }, { 180, 15 }, { 240, 20 }, {
MAX_TILE_HEIGHT + 1, 25 }};
310 uint delta = deltas[i][1];
313 int rows =
CeilDiv(total_entries, 2);
316 for (i = 0; i <
lengthof(_legend_land_contours) - 1 && j < total_entries; i++) {
317 if (_legend_land_contours[i].legend != STR_TINY_BLACK_HEIGHT)
continue;
319 _legend_land_contours[i].
col_break = j % rows == 0;
320 _legend_land_contours[i].
end =
false;
321 _legend_land_contours[i].
height = j * delta;
325 _legend_land_contours[i].
end =
true;
338 _legend_land_owners[i].
company = c->index;
340 _legend_land_owners[i].
col_break =
false;
341 _legend_land_owners[i].
end =
false;
347 _legend_land_owners[i].
end =
true;
358 static inline uint32 ApplyMask(uint32 colour,
const AndOr *mask)
360 return (colour & mask->mand) | mask->mor;
366 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
367 {MKCOLOUR_0XX0(
PC_GREY ), MKCOLOUR_F00F},
368 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
370 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
372 {MKCOLOUR_XXXX(
PC_WATER ), MKCOLOUR_0000},
373 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
375 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
377 {MKCOLOUR_0XX0(
PC_GREY ), MKCOLOUR_F00F},
382 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
383 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
384 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
386 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
387 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
388 {MKCOLOUR_XXXX(
PC_WATER ), MKCOLOUR_0000},
389 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
391 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
393 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
435 return ApplyMask(cs->
default_colour, &_smallmap_vehicles_andor[t]);
464 case STATION_AIRPORT:
return MKCOLOUR_XXXX(
PC_RED);
465 case STATION_TRUCK:
return MKCOLOUR_XXXX(
PC_ORANGE);
466 case STATION_BUS:
return MKCOLOUR_XXXX(
PC_YELLOW);
468 default:
return MKCOLOUR_FFFF;
474 _smallmap_contours_andor[t].mand
488 if (rti !=
nullptr) {
491 _smallmap_contours_andor[t].mand
503 return ApplyMask(cs->
default_colour, &_smallmap_contours_andor[t]);
519 static const uint32 _vegetation_clear_bits[] = {
553 return ApplyMask(MKCOLOUR_XXXX(
PC_GRASS_LAND), &_smallmap_vehicles_andor[t]);
601 inline Point SmallMapWindow::SmallmapRemapCoords(
int x,
int y)
const 617 int x_offset = tile_x - this->scroll_x / (int)
TILE_SIZE;
618 int y_offset = tile_y - this->scroll_y / (int)
TILE_SIZE;
620 if (this->zoom == 1)
return SmallmapRemapCoords(x_offset, y_offset);
623 if (x_offset < 0) x_offset -= this->zoom - 1;
624 if (y_offset < 0) y_offset -= this->zoom - 1;
626 return SmallmapRemapCoords(x_offset / this->zoom, y_offset / this->zoom);
641 if (add_sub) px += this->subscroll;
645 Point pt = {((py >> 1) - (px >> 2)) * this->zoom, ((py >> 1) + (px >> 2)) * this->zoom};
673 assert(x >= 0 && y >= 0);
676 Point tile_xy = PixelToTile(x, y, &new_sub,
false);
683 scroll.x = (tx + this->zoom) *
TILE_SIZE;
684 scroll.y = (ty - this->zoom) *
TILE_SIZE;
687 scroll.x = (tx + 2 * this->zoom) *
TILE_SIZE;
688 scroll.y = (ty - 2 * this->zoom) *
TILE_SIZE;
701 static const int zoomlevels[] = {1, 2, 4, 6, 8};
702 static const int MIN_ZOOM_INDEX = 0;
703 static const int MAX_ZOOM_INDEX =
lengthof(zoomlevels) - 1;
705 int new_index, cur_index, sub;
710 new_index = MIN_ZOOM_INDEX;
716 for (cur_index = MIN_ZOOM_INDEX; cur_index <= MAX_ZOOM_INDEX; cur_index++) {
717 if (this->zoom == zoomlevels[cur_index])
break;
719 assert(cur_index <= MAX_ZOOM_INDEX);
721 tile = this->PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
722 new_index =
Clamp(cur_index + ((change == ZLC_ZOOM_IN) ? -1 : 1), MIN_ZOOM_INDEX, MAX_ZOOM_INDEX);
725 default: NOT_REACHED();
728 if (new_index != cur_index) {
729 this->zoom = zoomlevels[new_index];
730 if (cur_index >= 0) {
731 Point new_tile = this->PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
732 this->SetNewScroll(this->scroll_x + (tile.x - new_tile.x) *
TILE_SIZE,
733 this->scroll_y + (tile.y - new_tile.y) *
TILE_SIZE, sub);
734 }
else if (this->map_type == SMT_LINKSTATS) {
735 this->overlay->SetDirty();
737 this->SetWidgetDisabledState(
WID_SM_ZOOM_IN, this->zoom == zoomlevels[MIN_ZOOM_INDEX]);
738 this->SetWidgetDisabledState(
WID_SM_ZOOM_OUT, this->zoom == zoomlevels[MAX_ZOOM_INDEX]);
771 if (this->map_type == SMT_INDUSTRY) {
798 switch (this->map_type) {
820 default: NOT_REACHED();
839 void *dst_ptr_abs_end = blitter->
MoveTo(_screen.dst_ptr, 0, _screen.height);
847 if (dst < _screen.dst_ptr)
continue;
848 if (dst >= dst_ptr_abs_end)
continue;
852 if (min_xy == 1 && (xc == 0 || yc == 0)) {
853 if (this->zoom == 1)
continue;
855 ta =
TileArea(
TileXY(
max(min_xy, xc),
max(min_xy, yc)), this->zoom - (xc == 0), this->zoom - (yc == 0));
861 uint32 val = this->GetTileColours(ta);
862 uint8 *val8 = (uint8 *)&val;
863 int idx =
max(0, -start_pos);
864 for (
int pos =
max(0, start_pos); pos < end_pos; pos++) {
865 blitter->
SetPixel(dst, idx, 0, val8[idx]);
869 }
while (xc += this->zoom, yc += this->zoom, dst = blitter->
MoveTo(dst, pitch, 0), --reps != 0);
884 Point pt = this->RemapTile(v->x_pos / (
int)
TILE_SIZE, v->y_pos / (
int)TILE_SIZE);
886 int y = pt.y - dpi->top;
890 int x = pt.x - this->subscroll - 3 - dpi->left;
894 if (++x != 0)
continue;
896 }
else if (x >= dpi->width - 1) {
898 if (x != dpi->width - 1)
continue;
906 blitter->
SetPixel(dpi->dst_ptr, x, y, colour);
907 if (!skip) blitter->
SetPixel(dpi->dst_ptr, x + 1, y, colour);
920 int x = pt.x - this->subscroll - (t->cache.sign.width_small >> 1);
924 if (x + t->cache.sign.width_small > dpi->left &&
925 x < dpi->left + dpi->width &&
927 y < dpi->top + dpi->height) {
930 DrawString(x, x + t->cache.sign.width_small, y, STR_SMALLMAP_TOWN);
946 Point upper_left = this->RemapTile(upper_left_smallmap_coord.x / (
int)
TILE_SIZE, upper_left_smallmap_coord.y / (
int)TILE_SIZE);
947 upper_left.x -= this->subscroll;
949 Point lower_right = this->RemapTile(lower_right_smallmap_coord.x / (
int)TILE_SIZE, lower_right_smallmap_coord.y / (
int)TILE_SIZE);
950 lower_right.x -= this->subscroll;
979 GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1,
PC_BLACK);
983 Point tile = this->PixelToTile(dpi->left, dpi->top, &dx);
984 int tile_x = this->scroll_x / (int)
TILE_SIZE + tile.x;
985 int tile_y = this->scroll_y / (
int)
TILE_SIZE + tile.y;
987 void *ptr = blitter->
MoveTo(dpi->dst_ptr, -dx - 4, 0);
994 if (x >= dpi->width)
break;
996 int end_pos =
min(dpi->width, x + 4);
997 int reps = (dpi->height - y + 1) / 2;
999 this->DrawSmallMapColumn(ptr, tile_x, tile_y, dpi->pitch * 2, reps, x, end_pos, blitter);
1004 tile_y += this->zoom;
1006 ptr = blitter->
MoveTo(ptr, 0, 1);
1008 tile_x -= this->zoom;
1010 ptr = blitter->
MoveTo(ptr, 0, -1);
1012 ptr = blitter->
MoveTo(ptr, 2, 0);
1017 if (this->map_type == SMT_CONTOUR || this->map_type == SMT_VEHICLES) this->DrawVehicles(dpi, blitter);
1020 if (this->map_type == SMT_LINKSTATS) this->overlay->Draw(dpi);
1023 if (this->show_towns) this->DrawTowns(dpi);
1026 this->DrawMapIndicators();
1040 switch (this->map_type) {
1042 legend_tooltip = STR_SMALLMAP_TOOLTIP_INDUSTRY_SELECTION;
1043 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_INDUSTRIES;
1044 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_INDUSTRIES;
1049 legend_tooltip = STR_SMALLMAP_TOOLTIP_COMPANY_SELECTION;
1050 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_COMPANIES;
1051 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_COMPANIES;
1056 legend_tooltip = STR_SMALLMAP_TOOLTIP_CARGO_SELECTION;
1057 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_CARGOS;
1058 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_CARGOS;
1063 legend_tooltip = STR_NULL;
1064 enable_all_tooltip = STR_NULL;
1065 disable_all_tooltip = STR_NULL;
1076 SmallMapWindow::SmallMapWindow(
WindowDesc *desc,
int window_number) :
Window(desc), refresh(
GUITimer(FORCE_REFRESH_PERIOD))
1080 this->InitNested(window_number);
1083 this->RebuildColourIndexIfNecessary();
1089 this->SetupWidgetData();
1091 this->SetZoomLevel(ZLC_INITIALIZE,
nullptr);
1092 this->SmallMapCenterOnCurrentPos();
1093 this->SetOverlayCargoMask();
1096 SmallMapWindow::~SmallMapWindow()
1098 delete this->overlay;
1099 this->BreakIndustryChainLink();
1110 for (uint n = 0; n <
lengthof(_heightmap_schemes); n++) {
1115 for (
int z = 0; z < heights; z++) {
1116 size_t access_index = (_heightmap_schemes[n].
colour_count * z) / heights;
1131 SetDParam(0, STR_SMALLMAP_TYPE_CONTOURS + this->map_type);
1139 this->min_number_of_columns = INDUSTRY_MIN_NUMBER_OF_COLUMNS;
1141 for (uint i = 0; i <
lengthof(_legend_table); i++) {
1143 uint num_columns = 1;
1146 if (i == SMT_INDUSTRY) {
1149 str = STR_SMALLMAP_INDUSTRY;
1150 }
else if (i == SMT_LINKSTATS) {
1152 str = STR_SMALLMAP_LINKSTATS;
1153 }
else if (i == SMT_OWNER) {
1163 str = STR_SMALLMAP_COMPANY;
1168 if (tbl->col_break) {
1169 this->min_number_of_fixed_rows =
max(this->min_number_of_fixed_rows, height);
1178 this->min_number_of_fixed_rows =
max(this->min_number_of_fixed_rows, height);
1179 this->min_number_of_columns =
max(this->min_number_of_columns, num_columns);
1188 if (this->map_type == SMT_OWNER) {
1193 this->InvalidateData(1);
1199 this->DrawWidgets();
1207 if (!
FillDrawPixelInfo(&new_dpi, r.left + 1, r.top + 1, r.right - r.left - 1, r.bottom - r.top - 1))
return;
1208 this->DrawSmallMap(&new_dpi);
1213 uint columns = this->GetNumberColumnsLegend(r.right - r.left + 1);
1214 uint number_of_rows = this->GetNumberRowsLegend(columns);
1223 uint text_right = this->column_width - 1 - (rtl ? LEGEND_BLOB_WIDTH +
WD_FRAMERECT_RIGHT : 0);
1224 uint blob_left = rtl ? this->column_width - 1 - LEGEND_BLOB_WIDTH : 0;
1225 uint blob_right = rtl ? this->column_width - 1 : LEGEND_BLOB_WIDTH;
1228 switch (this->map_type) {
1230 string = STR_SMALLMAP_INDUSTRY;
1233 string = STR_SMALLMAP_LINKSTATS;
1236 string = STR_SMALLMAP_COMPANY;
1243 if (tbl->col_break || ((this->map_type == SMT_INDUSTRY || this->map_type == SMT_OWNER || this->map_type == SMT_LINKSTATS) && i++ >= number_of_rows)) {
1246 x += rtl ? -(int)this->column_width : this->column_width;
1251 uint8 legend_colour = tbl->colour;
1253 switch (this->map_type) {
1270 if (this->map_type == SMT_OWNER)
SetDParam(0, tbl->company);
1271 if (!tbl->show_on_map) {
1274 DrawString(x + text_left, x + text_right, y,
string, TC_GREY);
1276 DrawString(x + text_left, x + text_right, y,
string, TC_BLACK);
1287 DrawString(x + text_left, x + text_right, y, tbl->legend);
1290 GfxFillRect(x + blob_left + 1, y + 2, x + blob_right - 1, y + row_height - 2, legend_colour);
1305 this->map_type = map_type;
1308 this->SetupWidgetData();
1310 if (map_type == SMT_LINKSTATS) this->overlay->SetDirty();
1311 if (map_type != SMT_INDUSTRY) this->BreakIndustryChainLink();
1328 return max(this->min_number_of_fixed_rows,
max(num_rows_linkstats, num_rows_others));
1346 bool changes =
false;
1347 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1348 bool new_state = (i == click_pos);
1349 if (legend[i].show_on_map != new_state) {
1356 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1364 if (this->map_type == SMT_INDUSTRY) this->BreakIndustryChainLink();
1372 CargoTypes cargo_mask = 0;
1374 if (_legend_linkstats[i].show_on_map)
SetBit(cargo_mask, _legend_linkstats[i].type);
1376 this->overlay->SetCargoMask(cargo_mask);
1388 uint columns = this->GetNumberColumnsLegend(wi->
current_x);
1389 uint number_of_rows = this->GetNumberRowsLegend(columns);
1390 if (line >= number_of_rows)
return -1;
1393 int x = pt.x - wi->
pos_x;
1397 return (column * number_of_rows) + line;
1403 if (widget ==
WID_SM_LEGEND && this->map_type == SMT_INDUSTRY) {
1404 int industry_pos = GetPositionOnLegend(pt);
1406 new_highlight = _legend_from_industries[industry_pos].
type;
1421 if (click_count > 0) this->mouse_capture_widget = widget;
1426 pt = this->PixelToTile(pt.x - wid->
pos_x, pt.y - wid->
pos_y, &sub);
1437 this->SetZoomLevel((widget ==
WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
1454 this->SmallMapCenterOnCurrentPos();
1460 this->show_towns = !this->show_towns;
1468 if (this->map_type == SMT_INDUSTRY || this->map_type == SMT_LINKSTATS || this->map_type == SMT_OWNER) {
1469 int click_pos = this->GetPositionOnLegend(pt);
1470 if (click_pos < 0)
break;
1473 if (this->map_type == SMT_INDUSTRY) {
1478 }
else if (this->map_type == SMT_LINKSTATS) {
1481 this->SetOverlayCargoMask();
1483 }
else if (this->map_type == SMT_OWNER) {
1495 switch (this->map_type) {
1498 this->BreakIndustryChainLink();
1509 for (;!tbl->
end && tbl->
legend != STR_LINKGRAPH_LEGEND_UNUSED; ++tbl) {
1512 if (this->map_type == SMT_LINKSTATS) this->SetOverlayCargoMask();
1535 if (!gui_scope)
return;
1545 if (this->map_type != SMT_INDUSTRY) this->SwitchMapType(SMT_INDUSTRY);
1548 _legend_from_industries[i].
show_on_map = _displayed_industries.test(_legend_from_industries[i].type);
1554 this->RebuildColourIndexIfNecessary();
1557 default: NOT_REACHED();
1574 int cursor_x = _cursor.
pos.x - this->left - wid->
pos_x;
1575 int cursor_y = _cursor.
pos.y - this->top - wid->
pos_y;
1577 Point pt = {cursor_x, cursor_y};
1578 this->SetZoomLevel((wheel < 0) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &pt);
1586 if (!this->refresh.Elapsed(delta_ms))
return;
1588 if (this->map_type == SMT_LINKSTATS) {
1589 uint32 company_mask = this->GetOverlayCompanyMask();
1590 if (this->overlay->GetCompanyMask() != company_mask) {
1591 this->overlay->SetCompanyMask(company_mask);
1593 this->overlay->SetDirty();
1633 this->scroll_x = sx;
1634 this->scroll_y = sy;
1635 this->subscroll = sub;
1636 if (this->map_type == SMT_LINKSTATS) this->overlay->SetDirty();
1645 Point pt = this->PixelToTile(delta.x, delta.y, &sub);
1646 this->SetNewScroll(this->scroll_x + pt.x *
TILE_SIZE, this->scroll_y + pt.y *
TILE_SIZE, sub);
1661 Point sxy = this->ComputeScroll(viewport_center.x / (
int)
TILE_SIZE, viewport_center.y / (
int)TILE_SIZE,
1663 this->SetNewScroll(sxy.x, sxy.y, sub);
1674 int x = (st->
rect.right + st->
rect.left + 1) / 2;
1675 int y = (st->
rect.bottom + st->
rect.top + 1) / 2;
1676 Point ret = this->RemapTile(x, y);
1681 ret.x -= 3 + this->subscroll;
1702 this->smallmap_window =
nullptr;
1714 assert(this->smallmap_window !=
nullptr);
1727 this->current_x = given_width;
1728 this->current_y = given_height;
1734 this->smallest_x = given_width;
1735 this->smallest_y = given_height;
1741 uint bar_height =
max(bar->
smallest_y, this->smallmap_window->GetLegendHeight(this->smallmap_window->GetNumberColumnsLegend(given_width - bar->
smallest_x)));
1742 uint display_height = given_height - bar_height;
1749 if (!
IsInsideBS(x, this->pos_x, this->current_x) || !
IsInsideBS(y, this->pos_y, this->current_y))
return nullptr;
1750 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1752 if (widget !=
nullptr)
return widget;
1759 for (
NWidgetBase *child_wid = this->head; child_wid !=
nullptr; child_wid = child_wid->
next) child_wid->Draw(w);
1766 NWidget(
WWT_INSET, COLOUR_BROWN,
WID_SM_MAP),
SetMinimalSize(346, 140),
SetResize(1, 1),
SetPadding(2, 2, 2, 2),
EndContainer(),
1779 SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
SetFill(1, 1),
1785 SetDataTip(SPR_IMG_SHOW_COUNTOURS, STR_SMALLMAP_TOOLTIP_SHOW_LAND_CONTOURS_ON_MAP),
SetFill(1, 1),
1787 SetDataTip(SPR_IMG_SHOW_VEHICLES, STR_SMALLMAP_TOOLTIP_SHOW_VEHICLES_ON_MAP),
SetFill(1, 1),
1789 SetDataTip(SPR_IMG_INDUSTRY, STR_SMALLMAP_TOOLTIP_SHOW_INDUSTRIES_ON_MAP),
SetFill(1, 1),
1794 SetDataTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
SetFill(1, 1),
1796 SetDataTip(SPR_IMG_TOWN, STR_SMALLMAP_TOOLTIP_TOGGLE_TOWN_NAMES_ON_OFF),
SetFill(1, 1),
1798 SetDataTip(SPR_IMG_CARGOFLOW, STR_SMALLMAP_TOOLTIP_SHOW_LINK_STATS_ON_MAP),
SetFill(1, 1),
1800 SetDataTip(SPR_IMG_SHOW_ROUTES, STR_SMALLMAP_TOOLTIP_SHOW_TRANSPORT_ROUTES_ON),
SetFill(1, 1),
1802 SetDataTip(SPR_IMG_PLANTTREES, STR_SMALLMAP_TOOLTIP_SHOW_VEGETATION_ON_MAP),
SetFill(1, 1),
1804 SetDataTip(SPR_IMG_COMPANY_GENERAL, STR_SMALLMAP_TOOLTIP_SHOW_LAND_OWNERS_ON_MAP),
SetFill(1, 1),
1812 static NWidgetBase *SmallMapDisplay(
int *biggest_index)
1816 MakeNWidgets(_nested_smallmap_display,
lengthof(_nested_smallmap_display), biggest_index, map_display);
1817 MakeNWidgets(_nested_smallmap_bar,
lengthof(_nested_smallmap_bar), biggest_index, map_display);
1822 static const NWidgetPart _nested_smallmap_widgets[] = {
1852 _nested_smallmap_widgets,
lengthof(_nested_smallmap_widgets)
1860 AllocateWindowDescFront<SmallMapWindow>(&_smallmap_desc, 0);
1879 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.
#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.
static const uint8 PC_DARK_GREY
Dark grey palette colour.
static const AndOr _smallmap_vehicles_andor[]
Colour masks for "Vehicles", "Industry", and "Vegetation" modes.
IndustryType type
Type of industry. Only valid for industry entries.
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
Class managing the smallmap window.
void DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, int reps, int start_pos, int end_pos, Blitter *blitter) const
Draws one column of tiles of the small map in a certain mode onto the screen buffer, skipping the shifted rows in between.
size_t colour_count
The number of colours.
SoundSettings sound
sound effect settings
std::array< IndustryType, NUM_INDUSTRYTYPES > _sorted_industry_types
Industry types sorted by name.
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
Small map; Window numbers:
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
ClientSettings _settings_client
The current settings for this game.
uint8 scrollwheel_scrolling
scrolling using the scroll wheel?
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void OnInit() override
Notification that the nested widget tree gets initialized.
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
Definition of base types and functions in a cross-platform compatible way.
uint min_number_of_columns
Minimal number of columns in legends.
A number of safeguards to prevent using unsafe methods.
void SetupWidgetData()
Function to set up widgets depending on the information being shown on the smallmap.
static LegendAndColour _legend_land_contours[]
Legend text giving the colours to look for on the minimap.
IndustryType type
type of industry.
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.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item=0)
Select and toggle a legend item.
Invisible tiles at the SW and SE border.
Base class for all vehicles.
Data structure for viewport, display of a part of the world.
Point InverseRemapCoords2(int x, int y, bool clamp_to_map, bool *clamped)
Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
uint32 TileIndex
The index/ID of a Tile.
Map accessors for 'clear' tiles.
static const uint8 PC_ORANGE
Orange palette colour.
TextDirection _current_text_dir
Text direction of the currently selected language.
static TreeGround GetTreeGround(TileIndex t)
Returns the groundtype for tree tiles.
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static LegendAndColour _legend_linkstats[NUM_CARGO+lengthof(_linkstat_colours_in_legenda)+1]
Legend entries for the link stats view.
TransportType
Available types of transport.
static const uint8 PC_VERY_DARK_BROWN
Almost-black brown palette colour.
static const uint8 PC_RED
Red palette colour.
static const NWidgetPart _nested_smallmap_bar[]
Widget parts of the smallmap legend bar + image buttons.
Point PixelToTile(int px, int py, int *sub, bool add_sub=true) const
Determine the tile relative to the base tile of the smallmap, and the pixel position at that tile for...
static void BreakIndustryChainLink()
Notify the industry chain window to stop sending newly selected industries.
static uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Contour".
static Point InverseRemapCoords(int x, int y)
Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
bool col_break
Perform a column break and go further at the next column.
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
Maximum number of companies.
Viewport moves with mouse movement on holding right mouse button, cursor position is fixed...
#define MC(col_break)
Macro for a height legend entry with configurable colour.
Transport by road vehicle.
virtual void * MoveTo(void *video, int x, int y)=0
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
Functions related to OTTD's landscape.
static uint8 _linkstat_colours_in_legenda[]
Link stat colours shown in legenda.
Coordinates of a point in 2D.
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...
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
static const byte _tiletype_importance[]
Mapping of tile type to importance of the tile (higher number means more interesting to show)...
void OnRealtimeTick(uint delta_ms) override
Called periodically.
int virtual_top
Virtual top coordinate.
GameCreationSettings game_creation
settings used during the creation of a game (map)
bool OnRightClick(Point pt, int widget) override
A click with the right mouse button has been made on the window.
A tile without any structures, i.e. grass, rocks, farm fields etc.
Specification of a rectangle with absolute coordinates of all edges.
Text is written right-to-left by default.
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
bool _scrolling_viewport
A viewport is being scrolled with the mouse.
static uint32 GetSmallMapLinkStatsPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "link stats".
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Window functions not directly related to making/drawing windows.
static bool _smallmap_show_heightmap
Show heightmap in industry and owner mode of smallmap window.
Find a place automatically.
void OnScroll(Point delta) override
Handle the request for (viewport) scrolling.
static bool IsTileOnWater(TileIndex t)
Tests if the tile was built on water.
void DrawTowns(const DrawPixelInfo *dpi) const
Adds town names to the smallmap.
ViewportData * viewport
Pointer to viewport data, if present.
#define MS(a, b)
Macro for break marker in arrays of LegendAndColour.
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.