OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
28 #include "table/strings.h"
44 #define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false}
47 #define MC(col_break) {0, STR_TINY_BLACK_HEIGHT, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, col_break}
50 #define MO(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false}
53 #define MOEND() {0, 0, INVALID_INDUSTRYTYPE, 0, OWNER_NONE, true, true, false}
56 #define MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, true, false}
62 #define MS(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, true}
67 MK(
PC_GREY, STR_SMALLMAP_LEGENDA_RAILROADS),
91 MK(
PC_RED, STR_SMALLMAP_LEGENDA_TRAINS),
96 MS(
PC_BLACK, STR_SMALLMAP_LEGENDA_TRANSPORT_ROUTES),
103 MK(
PC_GREY, STR_SMALLMAP_LEGENDA_RAILROADS),
107 MK(
PC_ORANGE, STR_SMALLMAP_LEGENDA_TRUCK_LOADING_BAY),
109 MK(
PC_RED, STR_SMALLMAP_LEGENDA_AIRPORT_HELIPORT),
126 MK(
PC_BLACK, STR_SMALLMAP_LEGENDA_TRANSPORT_ROUTES),
133 MO(0x00, STR_SMALLMAP_LEGENDA_NO_OWNER),
238 #define MKCOLOUR(x) TO_LE32X(x)
240 #define MKCOLOUR_XXXX(x) (MKCOLOUR(0x01010101) * (uint)(x))
241 #define MKCOLOUR_X0X0(x) (MKCOLOUR(0x01000100) * (uint)(x))
242 #define MKCOLOUR_0X0X(x) (MKCOLOUR(0x00010001) * (uint)(x))
243 #define MKCOLOUR_0XX0(x) (MKCOLOUR(0x00010100) * (uint)(x))
244 #define MKCOLOUR_X00X(x) (MKCOLOUR(0x01000001) * (uint)(x))
246 #define MKCOLOUR_XYXY(x, y) (MKCOLOUR_X0X0(x) | MKCOLOUR_0X0X(y))
247 #define MKCOLOUR_XYYX(x, y) (MKCOLOUR_X00X(x) | MKCOLOUR_0XX0(y))
249 #define MKCOLOUR_0000 MKCOLOUR_XXXX(0x00)
250 #define MKCOLOUR_0FF0 MKCOLOUR_0XX0(0xFF)
251 #define MKCOLOUR_F00F MKCOLOUR_X00X(0xFF)
252 #define MKCOLOUR_FFFF MKCOLOUR_XXXX(0xFF)
299 uint deltas[][2] = { { 24, 2 }, { 48, 4 }, { 72, 6 }, { 120, 10 }, { 180, 15 }, { 240, 20 }, {
MAX_TILE_HEIGHT + 1, 25 }};
304 uint delta = deltas[i][1];
307 int rows =
CeilDiv(total_entries, 2);
332 _legend_land_owners[i].
company = c->index;
334 _legend_land_owners[i].
col_break =
false;
335 _legend_land_owners[i].
end =
false;
341 _legend_land_owners[i].
end =
true;
352 static inline uint32 ApplyMask(uint32 colour,
const AndOr *mask)
354 return (colour & mask->mand) | mask->mor;
360 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
361 {MKCOLOUR_0XX0(
PC_GREY ), MKCOLOUR_F00F},
362 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
364 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
366 {MKCOLOUR_XXXX(
PC_WATER ), MKCOLOUR_0000},
367 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
369 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
371 {MKCOLOUR_0XX0(
PC_GREY ), MKCOLOUR_F00F},
376 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
377 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
378 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
380 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
381 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
382 {MKCOLOUR_XXXX(
PC_WATER ), MKCOLOUR_0000},
383 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
385 {MKCOLOUR_0000 , MKCOLOUR_FFFF},
387 {MKCOLOUR_0XX0(
PC_BLACK ), MKCOLOUR_F00F},
458 case STATION_AIRPORT:
return MKCOLOUR_XXXX(
PC_RED);
459 case STATION_TRUCK:
return MKCOLOUR_XXXX(
PC_ORANGE);
460 case STATION_BUS:
return MKCOLOUR_XXXX(
PC_YELLOW);
462 default:
return MKCOLOUR_FFFF;
482 if (rti !=
nullptr) {
513 static const uint32 _vegetation_clear_bits[] = {
599 inline Point SmallMapWindow::SmallmapRemapCoords(
int x,
int y)
const
618 if (this->
zoom == 1)
return SmallmapRemapCoords(x_offset, y_offset);
621 if (x_offset < 0) x_offset -= this->
zoom - 1;
622 if (y_offset < 0) y_offset -= this->
zoom - 1;
624 return SmallmapRemapCoords(x_offset / this->
zoom, y_offset / this->
zoom);
643 Point pt = {((py >> 1) - (px >> 2)) * this->
zoom, ((py >> 1) + (px >> 2)) * this->
zoom};
671 assert(x >= 0 && y >= 0);
699 static const int zoomlevels[] = {1, 2, 4, 6, 8};
700 static const int MIN_ZOOM_INDEX = 0;
701 static const int MAX_ZOOM_INDEX =
lengthof(zoomlevels) - 1;
703 int new_index, cur_index, sub;
708 new_index = MIN_ZOOM_INDEX;
714 for (cur_index = MIN_ZOOM_INDEX; cur_index <= MAX_ZOOM_INDEX; cur_index++) {
715 if (this->
zoom == zoomlevels[cur_index])
break;
717 assert(cur_index <= MAX_ZOOM_INDEX);
719 tile = this->
PixelToTile(zoom_pt->x, zoom_pt->y, &sub);
720 new_index =
Clamp(cur_index + ((change ==
ZLC_ZOOM_IN) ? -1 : 1), MIN_ZOOM_INDEX, MAX_ZOOM_INDEX);
723 default: NOT_REACHED();
726 if (new_index != cur_index) {
727 this->
zoom = zoomlevels[new_index];
728 if (cur_index >= 0) {
731 this->scroll_y + (tile.y - new_tile.y) *
TILE_SIZE, sub);
732 }
else if (this->
map_type == SMT_LINKSTATS) {
769 if (this->
map_type == SMT_INDUSTRY) {
818 default: NOT_REACHED();
837 void *dst_ptr_abs_end = blitter->
MoveTo(_screen.dst_ptr, 0, _screen.height);
845 if (dst < _screen.dst_ptr)
continue;
846 if (dst >= dst_ptr_abs_end)
continue;
850 if (min_xy == 1 && (xc == 0 || yc == 0)) {
851 if (this->
zoom == 1)
continue;
853 ta =
TileArea(
TileXY(std::max(min_xy, xc), std::max(min_xy, yc)), this->
zoom - (xc == 0), this->
zoom - (yc == 0));
860 uint8 *val8 = (uint8 *)&val;
861 int idx = std::max(0, -start_pos);
862 for (
int pos = std::max(0, start_pos); pos < end_pos; pos++) {
863 blitter->
SetPixel(dst, idx, 0, val8[idx]);
867 }
while (xc += this->
zoom, yc += this->
zoom, dst = blitter->
MoveTo(dst, pitch, 0), --reps != 0);
884 int y = pt.y - dpi->top;
888 int x = pt.x - this->
subscroll - 3 - dpi->left;
892 if (++x != 0)
continue;
894 }
else if (x >= dpi->width - 1) {
896 if (x != dpi->width - 1)
continue;
904 blitter->
SetPixel(dpi->dst_ptr, x, y, colour);
905 if (!skip) blitter->
SetPixel(dpi->dst_ptr, x + 1, y, colour);
918 int x = pt.x - this->
subscroll - (t->cache.sign.width_small >> 1);
922 if (x + t->cache.sign.width_small > dpi->left &&
923 x < dpi->
left + dpi->width &&
925 y < dpi->
top + dpi->height) {
928 DrawString(x, x + t->cache.sign.width_small, y, STR_SMALLMAP_TOWN);
977 GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1,
PC_BLACK);
983 int tile_y = this->scroll_y / (
int)
TILE_SIZE + tile.y;
985 void *ptr = blitter->
MoveTo(dpi->dst_ptr, -dx - 4, 0);
992 if (x >= dpi->width)
break;
994 int end_pos = std::min(dpi->width, x + 4);
995 int reps = (dpi->height - y + 1) / 2;
997 this->
DrawSmallMapColumn(ptr, tile_x, tile_y, dpi->pitch * 2, reps, x, end_pos, blitter);
1002 tile_y += this->
zoom;
1004 ptr = blitter->
MoveTo(ptr, 0, 1);
1006 tile_x -= this->
zoom;
1008 ptr = blitter->
MoveTo(ptr, 0, -1);
1010 ptr = blitter->
MoveTo(ptr, 2, 0);
1018 if (this->
map_type == SMT_LINKSTATS) this->overlay->
Draw(dpi);
1040 legend_tooltip = STR_SMALLMAP_TOOLTIP_INDUSTRY_SELECTION;
1041 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_INDUSTRIES;
1042 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_INDUSTRIES;
1047 legend_tooltip = STR_SMALLMAP_TOOLTIP_COMPANY_SELECTION;
1048 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_COMPANIES;
1049 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_COMPANIES;
1054 legend_tooltip = STR_SMALLMAP_TOOLTIP_CARGO_SELECTION;
1055 enable_all_tooltip = STR_SMALLMAP_TOOLTIP_ENABLE_ALL_CARGOS;
1056 disable_all_tooltip = STR_SMALLMAP_TOOLTIP_DISABLE_ALL_CARGOS;
1061 legend_tooltip = STR_NULL;
1062 enable_all_tooltip = STR_NULL;
1063 disable_all_tooltip = STR_NULL;
1068 this->GetWidget<NWidgetCore>(
WID_SM_LEGEND)->SetDataTip(STR_NULL, legend_tooltip);
1069 this->GetWidget<NWidgetCore>(
WID_SM_ENABLE_ALL)->SetDataTip(STR_SMALLMAP_ENABLE_ALL, enable_all_tooltip);
1070 this->GetWidget<NWidgetCore>(
WID_SM_DISABLE_ALL)->SetDataTip(STR_SMALLMAP_DISABLE_ALL, disable_all_tooltip);
1074 SmallMapWindow::SmallMapWindow(
WindowDesc *desc,
int window_number) :
Window(desc), refresh(
GUITimer(FORCE_REFRESH_PERIOD))
1094 SmallMapWindow::~SmallMapWindow()
1096 delete this->overlay;
1113 for (
int z = 0; z < heights; z++) {
1139 for (uint i = 0; i <
lengthof(_legend_table); i++) {
1141 uint num_columns = 1;
1144 if (i == SMT_INDUSTRY) {
1147 str = STR_SMALLMAP_INDUSTRY;
1148 }
else if (i == SMT_LINKSTATS) {
1150 str = STR_SMALLMAP_LINKSTATS;
1151 }
else if (i == SMT_OWNER) {
1161 str = STR_SMALLMAP_COMPANY;
1166 if (tbl->col_break) {
1205 if (!
FillDrawPixelInfo(&new_dpi, r.left + 1, r.top + 1, r.right - r.left - 1, r.bottom - r.top - 1))
return;
1228 string = STR_SMALLMAP_INDUSTRY;
1231 string = STR_SMALLMAP_LINKSTATS;
1234 string = STR_SMALLMAP_COMPANY;
1241 if (tbl->col_break || ((this->map_type == SMT_INDUSTRY || this->map_type == SMT_OWNER || this->map_type == SMT_LINKSTATS) && i++ >= number_of_rows)) {
1249 uint8 legend_colour = tbl->colour;
1269 if (!tbl->show_on_map) {
1272 DrawString(x + text_left, x + text_right, y,
string, TC_GREY);
1274 DrawString(x + text_left, x + text_right, y,
string, TC_BLACK);
1285 DrawString(x + text_left, x + text_right, y, tbl->legend);
1288 GfxFillRect(x + blob_left + 1, y + 2, x + blob_right - 1, y + row_height - 2, legend_colour);
1308 if (map_type == SMT_LINKSTATS) this->overlay->
SetDirty();
1344 bool changes =
false;
1345 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1346 bool new_state = (i == click_pos);
1347 if (legend[i].show_on_map != new_state) {
1354 for (
int i = begin_legend_item; i != end_legend_item; i++) {
1370 CargoTypes cargo_mask = 0;
1388 if (line >= number_of_rows)
return -1;
1391 int x = pt.x - wi->
pos_x;
1395 return (column * number_of_rows) + line;
1468 if (click_pos < 0)
break;
1471 if (this->
map_type == SMT_INDUSTRY) {
1476 }
else if (this->
map_type == SMT_LINKSTATS) {
1481 }
else if (this->
map_type == SMT_OWNER) {
1507 for (;!tbl->
end && tbl->
legend != STR_LINKGRAPH_LEGEND_UNUSED; ++tbl) {
1533 if (!gui_scope)
return;
1555 default: NOT_REACHED();
1572 int cursor_x = _cursor.
pos.x - this->
left - wid->
pos_x;
1573 int cursor_y = _cursor.
pos.y - this->
top - wid->
pos_y;
1575 Point pt = {cursor_x, cursor_y};
1586 if (this->
map_type == SMT_LINKSTATS) {
1672 int x = (st->
rect.right + st->
rect.left + 1) / 2;
1673 int y = (st->
rect.bottom + st->
rect.top + 1) / 2;
1700 this->smallmap_window =
nullptr;
1712 assert(this->smallmap_window !=
nullptr);
1739 uint bar_height = std::max(bar->
smallest_y, this->smallmap_window->GetLegendHeight(this->smallmap_window->GetNumberColumnsLegend(given_width - bar->
smallest_x)));
1740 uint display_height = given_height - bar_height;
1748 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) {
1750 if (widget !=
nullptr)
return widget;
1757 for (
NWidgetBase *child_wid = this->
head; child_wid !=
nullptr; child_wid = child_wid->
next) child_wid->Draw(w);
1764 NWidget(
WWT_INSET, COLOUR_BROWN,
WID_SM_MAP),
SetMinimalSize(346, 140),
SetResize(1, 1),
SetPadding(2, 2, 2, 2),
EndContainer(),
1777 SetDataTip(SPR_IMG_ZOOMIN, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_IN),
SetFill(1, 1),
1783 SetDataTip(SPR_IMG_SHOW_COUNTOURS, STR_SMALLMAP_TOOLTIP_SHOW_LAND_CONTOURS_ON_MAP),
SetFill(1, 1),
1785 SetDataTip(SPR_IMG_SHOW_VEHICLES, STR_SMALLMAP_TOOLTIP_SHOW_VEHICLES_ON_MAP),
SetFill(1, 1),
1787 SetDataTip(SPR_IMG_INDUSTRY, STR_SMALLMAP_TOOLTIP_SHOW_INDUSTRIES_ON_MAP),
SetFill(1, 1),
1792 SetDataTip(SPR_IMG_ZOOMOUT, STR_TOOLBAR_TOOLTIP_ZOOM_THE_VIEW_OUT),
SetFill(1, 1),
1794 SetDataTip(SPR_IMG_TOWN, STR_SMALLMAP_TOOLTIP_TOGGLE_TOWN_NAMES_ON_OFF),
SetFill(1, 1),
1796 SetDataTip(SPR_IMG_CARGOFLOW, STR_SMALLMAP_TOOLTIP_SHOW_LINK_STATS_ON_MAP),
SetFill(1, 1),
1798 SetDataTip(SPR_IMG_SHOW_ROUTES, STR_SMALLMAP_TOOLTIP_SHOW_TRANSPORT_ROUTES_ON),
SetFill(1, 1),
1800 SetDataTip(SPR_IMG_PLANTTREES, STR_SMALLMAP_TOOLTIP_SHOW_VEGETATION_ON_MAP),
SetFill(1, 1),
1802 SetDataTip(SPR_IMG_COMPANY_GENERAL, STR_SMALLMAP_TOOLTIP_SHOW_LAND_OWNERS_ON_MAP),
SetFill(1, 1),
1810 static NWidgetBase *SmallMapDisplay(
int *biggest_index)
1820 static const NWidgetPart _nested_smallmap_widgets[] = {
1850 _nested_smallmap_widgets,
lengthof(_nested_smallmap_widgets)
1858 AllocateWindowDescFront<SmallMapWindow>(&_smallmap_desc, 0);
1877 if (res)
return res;
std::array< IndustryType, NUM_INDUSTRYTYPES > _sorted_industry_types
Industry types sorted by name.
static const uint8 PC_WHITE
White palette colour.
@ MP_CLEAR
A tile without any structures, i.e. grass, rocks, farm fields etc.
@ MP_HOUSE
A house by a town.
void BuildOwnerLegend()
Completes the array for the owned property legend.
IndustryType type
Type of industry. Only valid for industry entries.
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
uint32 TileIndex
The index/ID of a Tile.
static const uint8 LINK_COLOURS[]
Colours for the various "load" states of links.
static uint32 GetSmallMapRoutesPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Routes".
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 const uint32 _green_map_heights[]
Height map colours for the green colour scheme, ordered by height.
uint min_number_of_fixed_rows
Minimal number of rows in the legends for the fixed layouts only (all except #SMT_INDUSTRY).
byte map_colour
colour used for the small map
static bool _smallmap_show_heightmap
Show heightmap in industry and owner mode of smallmap window.
virtual void SetPixel(void *video, int x, int y, uint8 colour)=0
Draw a pixel with a given colour on the video-buffer.
@ WC_INDUSTRY_CARGOES
Industry cargoes chain; Window numbers:
static SmallMapType map_type
Currently displayed legends.
bool ScrollWindowTo(int x, int y, int z, Window *w, bool instant)
Scrolls the viewport in a window to a given location.
static const uint LEGEND_BLOB_WIDTH
Width of the coloured blob in front of a line text in the WID_SM_LEGEND widget.
uint8 max_heightlevel
maximum allowed heightlevel
static const uint8 PC_YELLOW
Yellow palette colour.
static const uint8 PC_DARK_RED
Dark red palette colour.
byte landscape
the landscape we're currently in
const uint32 * height_colours_base
Base table for determining the colours.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
#define MOEND()
Macro used for forcing a rebuild of the owner legend the first time it is used.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
@ TRANSPORT_RAIL
Transport by train.
void OnPaint() override
The window must be repainted.
How all blitters should look like.
static int _smallmap_cargo_count
Number of cargos in the link stats legend.
void SmallMapCenterOnCurrentPos()
Center the small map on the current center of the viewport.
@ INVALID_ROADTYPE
flag for invalid roadtype
ViewportData * viewport
Pointer to viewport data, if present.
static const uint8 PC_ORANGE
Orange palette colour.
static const uint8 PC_RED
Red palette colour.
static void DrawHorizMapIndicator(int x, int x2, int y)
Draws horizontal part of map indicator.
CompanyID company
Company to display. Only valid for company entries of the owner legend.
#define MS(a, b)
Macro for break marker in arrays of LegendAndColour.
bool OnRightClick(Point pt, int widget) override
A click with the right mouse button has been made on the window.
static const uint8 PC_RAINFOREST
Pale green palette colour for rainforest.
@ TROPICZONE_RAINFOREST
Rainforest tile.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
uint32 GetOverlayCompanyMask() const
Get a bitmask for company links to be displayed.
static bool IsClearGround(TileIndex t, ClearGround ct)
Set the type of clear tile.
void SetupWidgetData()
Function to set up widgets depending on the information being shown on the smallmap.
bool _ctrl_pressed
Is Ctrl pressed?
@ SND_15_BEEP
19 == 0x13 GUI button click
static const uint TILE_SIZE
Tile size in world coordinates.
uint32 GetTileColours(const TileArea &ta) const
Decide which colours to show to the user for a group of tiles.
ClientSettings _settings_client
The current settings for this game.
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.
uint32 default_colour
Default colour of the land.
Specification of a cargo type.
@ VSM_VIEWPORT_RMB_FIXED
Viewport moves with mouse movement on holding right mouse button, cursor position is fixed.
@ MP_INDUSTRY
Part of an industry.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static int _smallmap_industry_count
Number of used industries.
int zoom
Zoom level. Bigger number means more zoom-out (further away).
static const uint MAX_TILE_HEIGHT
Maximum allowed tile height.
TransportType
Available types of transport.
static const uint8 PC_GRASS_LAND
Dark green palette colour for grass land.
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
int virtual_top
Virtual top coordinate.
void SwitchMapType(SmallMapType map_type)
Select a new map type.
Owner
Enum for all companies/owners.
@ MP_ROAD
A tile with road (or tram tracks)
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
uint column_width
Width of a column in the WID_SM_LEGEND widget.
void OnInit() override
Notification that the nested widget tree gets initialized.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
uint min_number_of_columns
Minimal number of columns in legends.
static const uint32 _dark_green_map_heights[]
Height map colours for the dark green colour scheme, ordered by height.
int32 scroll_x
Horizontal world coordinate of the base tile left of the top-left corner of the smallmap display.
Class managing the smallmap window.
static bool show_towns
Display town names in the smallmap.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
static ClearGround GetClearGround(TileIndex t)
Get the type of clear tile.
void SetCompanyMask(uint32 company_mask)
Set a new company mask and rebuild the cache.
static uint TileX(TileIndex tile)
Get the X component of a tile.
uint GetNumberColumnsLegend(uint width) const
Return number of columns that can be displayed in width pixels.
void DrawSmallMap(DrawPixelInfo *dpi) const
Draws the small map.
GameCreationSettings game_creation
settings used during the creation of a game (map)
Point GetStationMiddle(const Station *st) const
Get the center of the given station as point on the screen in the smallmap window.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
void SetZoomLevel(ZoomLevelChange change, const Point *zoom_pt)
Initialize or change the zoom level.
static bool IsTileOnWater(TileIndex t)
Tests if the tile was built on water.
static bool _smallmap_industry_highlight_state
State of highlight blinking.
High level window description.
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,...
@ TRANSPORT_ROAD
Transport by road vehicle.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
uint GetMinLegendWidth() const
Compute minimal required width of the legends.
uint8 scrollwheel_scrolling
scrolling using the scroll wheel?
Handles drawing of links into some window.
@ VS_HIDDEN
Vehicle is not visible.
CargoID Index() const
Determines index of this cargospec.
Data structure for viewport, display of a part of the world.
static const NWidgetPart _nested_smallmap_bar[]
Widget parts of the smallmap legend bar + image buttons.
@ WDP_AUTO
Find a place automatically.
ZoomLevelChange
Available kinds of zoomlevel changes.
static uint GetClearDensity(TileIndex t)
Get the density of a non-field clear tile.
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.
uint GetNumberRowsLegend(uint columns) const
Get the number of rows in the legend from the number of columns.
static Point InverseRemapCoords(int x, int y)
Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
void DrawVehicles(const DrawPixelInfo *dpi, Blitter *blitter) const
Adds vehicles to the smallmap.
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
SoundSettings sound
sound effect settings
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
static const byte _vehicle_type_colours[6]
Vehicle colours in #SMT_VEHICLES mode.
void SetCargoMask(CargoTypes cargo_mask)
Set a new cargo mask and rebuild the cache.
static const size_t MAX_SIZE
Make template parameter accessible from outside.
static void DrawVertMapIndicator(int x, int y, int y2)
Draws vertical part of map indicator.
int virtual_left
Virtual left coordinate.
IndustryType type
type of industry.
int height
Height of the window (number of pixels down in y direction)
StationRect rect
NOSAVE: Station spread out rectangle maintained by StationRect::xxx() functions.
bool col_break
Perform a column break and go further at the next column.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
static LegendAndColour _legend_land_contours[]
Legend text giving the colours to look for on the minimap.
void DrawMapIndicators() const
Adds map indicators to the smallmap.
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 AndOr _smallmap_contours_andor[]
Colour masks for "Contour" and "Routes" modes.
Colour scheme of the smallmap.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
static StationType GetStationType(TileIndex t)
Get the station type of this tile.
static int _smallmap_company_count
Number of entries in the owner legend.
static const byte _tiletype_importance[]
Mapping of tile type to importance of the tile (higher number means more interesting to show).
static int max_heightlevel
Currently used/cached maximum heightlevel.
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 IndustryType _smallmap_industry_highlight
Highlight a specific industry type.
Represents the covered area of e.g.
@ VEH_EFFECT
Effect vehicle type (smoke, explosions, sparks, bubbles)
#define MC(col_break)
Macro for a height legend entry with configurable colour.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
int GetPositionOnLegend(Point pt)
Determines the mouse position on the legend.
StringID legend
String corresponding to the coloured item.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
@ MAX_COMPANIES
Maximum number of companies.
int left
x position of left edge of the window
bool freeform_edges
allow terraforming the tiles at the map edges
bool fix_at
mouse is moving, but cursor is not (used for scrolling)
static uint _industry_to_list_pos[NUM_INDUSTRYTYPES]
For connecting industry type to position in industries list(small map legend)
std::bitset< NUM_INDUSTRYTYPES > _displayed_industries
Communication from the industry chain window to the smallmap window about what industries to display.
static const AndOr _smallmap_vehicles_andor[]
Colour masks for "Vehicles", "Industry", and "Vegetation" modes.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
static SmallMapColourScheme _heightmap_schemes[]
Available colour schemes for height maps.
@ VSM_MAP_RMB_FIXED
Map moves with mouse movement on holding right mouse button, cursor position is fixed.
int virtual_width
width << zoom
Coordinates of a point in 2D.
bool ScrollMainWindowTo(int x, int y, int z, bool instant)
Scrolls the main window to given coordinates.
static uint32 GetSmallMapIndustriesPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Industries".
SmallMapType
Types of legends in the WID_SM_LEGEND widget.
static const uint8 PC_BLACK
Black palette colour.
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.
Defines the data structure for constructing industry.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
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,...
int mouse_capture_widget
Widgetindex of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse captu...
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
static const uint8 PC_TREES
Green palette colour for trees.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
static uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Owner".
Point InverseRemapCoords2(int x, int y, bool clamp_to_map, bool *clamped)
Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
static const uint8 PC_GREY
Grey palette colour.
static void BreakIndustryChainLink()
Notify the industry chain window to stop sending newly selected industries.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
static const uint8 PC_FIELDS
Light brown palette colour for fields.
void BuildIndustriesLegend()
Fills an array for the industries legends.
bool IsTileForestIndustry(TileIndex tile)
Check whether the tile is a forest.
@ MP_TREES
Tile got trees.
#define MK(a, b)
Macro for ordinary entry of LegendAndColour.
static const uint8 PC_VERY_DARK_BROWN
Almost-black brown palette colour.
bool enabled
entity still available (by default true).newgrf can disable it, though
#define MKEND()
Macro for end of list marker in arrays of LegendAndColour.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
int32 subscroll
Number of pixels (0..3) between the right end of the base tile and the pixel at the top-left corner o...
void OnScroll(Point delta) override
Handle the request for (viewport) scrolling.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static uint16 GetIndustryTypeCount(IndustryType type)
Get the count of industries for this type.
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
static uint32 GetSmallMapLinkStatsPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "link stats".
@ MP_VOID
Invisible tiles at the SW and SE border.
void OnMouseOver(Point pt, int widget) override
The mouse is currently moving over the window or has just moved outside of the window.
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...
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static const IndustryType INVALID_INDUSTRYTYPE
one above amount is considered invalid
void SetOverlayCargoMask()
Set the link graph overlay cargo mask from the legend.
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...
static const uint32 _violet_map_heights[]
Height map colours for the violet colour scheme, ordered by height.
TileType
The different types of tiles.
static const uint INDUSTRY_MIN_NUMBER_OF_COLUMNS
Minimal number of columns in the WID_SM_LEGEND widget for the #SMT_INDUSTRY legend.
static const uint8 PC_ROUGH_LAND
Dark green palette colour for rough land.
uint8 height
Height in tiles. Only valid for height legend entries.
uint8 colour
Colour of the item on the map.
void Draw(const DrawPixelInfo *dpi)
Draw the linkgraph overlay or some part of it, in the area given.
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...
@ OWNER_NONE
The tile has no ownership.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
void ShowSmallMap()
Show the smallmap window.
@ MP_STATION
A tile of a station.
bool show_on_map
For filtering industries, if true, industry is shown on the map in colour.
byte map_colour
Colour on mini-map.
@ NUM_CARGO
Maximal number of cargo types in a game.
void DrawTowns(const DrawPixelInfo *dpi) const
Adds town names to the smallmap.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
static uint _company_to_list_pos[MAX_COMPANIES]
For connecting company ID to position in owner list (small map legend)
StringID name
Name of this type of cargo.
@ WC_MAIN_WINDOW
Main window; Window numbers:
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
static const uint8 PC_WATER
Dark blue palette colour for water.
int top
y position of top edge of the window
static TreeGround GetTreeGround(TileIndex t)
Returns the groundtype for tree tiles.
bool Elapsed(uint delta)
Test if a timer has elapsed.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Point RemapTile(int tile_x, int tile_y) const
Remap tile to location on this smallmap.
uint8 smallmap_land_colour
colour used for land and heightmap at the smallmap
@ VS_UNCLICKABLE
Vehicle is not clickable by the user (shadow vehicles).
void SetDirty()
Mark the linkgraph dirty to be rebuilt next time Draw() is called.
static LegendAndColour _legend_linkstats[NUM_CARGO+lengthof(_linkstat_colours_in_legenda)+1]
Legend entries for the link stats view.
bool click_beep
Beep on a random selection of buttons.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
#define lengthof(x)
Return the length of an fixed size array.
int width
width of the window (number of pixels to the right in x direction)
uint32 GetCompanyMask()
Get a bitmask of the currently shown companies.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
@ INVALID_COMPANY
An invalid company.
static const int TILE_HEIGHT_STEP
One Z unit tile height difference is displayed as 50m.
@ TREE_GROUND_SNOW_DESERT
a desert or snow tile, depend on landscape
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
ConstructionSettings construction
construction of things in-game
GUITimer refresh
Refresh timer.
const IndustrySpec * GetIndustrySpec(IndustryType thistype)
Accessor for array _industry_specs.
int32 scroll_y
Vertical world coordinate of the base tile left of the top-left corner of the smallmap display.
Data structure for an opened window.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
StringID name
Displayed name of the industry.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
void SelectLegendItem(int click_pos, LegendAndColour *legend, int end_legend_item, int begin_legend_item=0)
Select and toggle a legend item.
uint8 scroll_mode
viewport scroll mode
void DrawWidgets() const
Paint all widgets of a window.
void RebuildColourIndexIfNecessary()
Rebuilds the colour indices used for fast access to the smallmap contour colours based on the heightl...
static const uint8 PC_DARK_GREY
Dark grey palette colour.
int virtual_height
height << zoom
@ ZLC_INITIALIZE
Initialize zoom level.
uint32 * height_colours
Cached colours for each level in a map.
static const uint8 PC_LIGHT_BLUE
Light blue palette colour.
static uint32 GetSmallMapVehiclesPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Vehicles".
void ClampToMap()
Clamp the tile area to map borders.
#define MO(a, b)
Macro for non-company owned property entry of LegendAndColour.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
Structure for holding relevant data for legends in small map.
Specification of a rectangle with absolute coordinates of all edges.
Point pos
logical mouse position
void LowerWidget(byte widget_index)
Marks a widget as lowered.
bool end
This is the end of the list.
@ OWNER_WATER
The tile/execution is done by "water".
static uint8 _linkstat_colours_in_legenda[]
Link stat colours shown in legenda.
void BuildLinkStatsLegend()
Populate legend table for the link stat view.
bool _scrolling_viewport
A viewport is being scrolled with the mouse.
@ WC_SMALLMAP
Small map; Window numbers:
static const uint8 PC_GREEN
Green palette colour.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
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...
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
static const int NUM_NO_COMPANY_ENTRIES
Number of entries in the owner legend that are not companies.
static const uint FORCE_REFRESH_PERIOD
map is redrawn after that many milliseconds.
@ OWNER_TOWN
A town owns the tile, or a town is expanding.
uint GetLegendHeight(uint num_columns) const
Compute height given a number of columns.
void OnMouseWheel(int wheel) override
The mouse wheel has been turned.
GUISettings gui
settings related to the GUI
static const uint8 PC_BARE_LAND
Brown palette colour for bare land.
void BuildLandLegend()
(Re)build the colour tables for the legends.
size_t colour_count
The number of colours.
Data about how and where to blit pixels.
static uint32 GetSmallMapVegetationPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the smallmap in mode "Vegetation".
static const NWidgetPart _nested_smallmap_display[]
Widget parts of the smallmap display.
static const uint BLINK_PERIOD
highlight blinking interval in milliseconds.
static uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t)
Return the colour a tile would be displayed with in the small map in mode "Contour".
@ TREE_GROUND_ROUGH_SNOW
A snow tile that is rough underneath.