|
OpenTTD Source
14.0-beta1
|
#include "stdafx.h"#include "core/backup_type.hpp"#include "clear_map.h"#include "industry.h"#include "station_map.h"#include "landscape.h"#include "tree_map.h"#include "viewport_func.h"#include "town.h"#include "tunnelbridge_map.h"#include "core/endian_func.hpp"#include "vehicle_base.h"#include "sound_func.h"#include "window_func.h"#include "company_base.h"#include "zoom_func.h"#include "strings_func.h"#include "blitter/factory.hpp"#include "linkgraph/linkgraph_gui.h"#include "widgets/smallmap_widget.h"#include "timer/timer.h"#include "timer/timer_window.h"#include "smallmap_gui.h"#include "table/strings.h"#include <bitset>#include "safeguards.h"#include "table/heightmap_colours.h"Go to the source code of this file.
Data Structures | |
| struct | LegendAndColour |
| Structure for holding relevant data for legends in small map. More... | |
| struct | SmallMapColourScheme |
| Colour scheme of the smallmap. More... | |
| struct | AndOr |
| class | SmallMapWindow |
| Class managing the smallmap window. More... | |
| class | NWidgetSmallmapDisplay |
| Custom container class for displaying smallmap with a vertically resizing legend panel. More... | |
Macros | |
| #define | MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} |
| Macro for ordinary entry of LegendAndColour. | |
| #define | MC(col_break) {0, STR_TINY_BLACK_HEIGHT, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, col_break} |
| Macro for a height legend entry with configurable colour. | |
| #define | MO(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} |
| Macro for non-company owned property entry of LegendAndColour. | |
| #define | MOEND() {0, 0, INVALID_INDUSTRYTYPE, 0, OWNER_NONE, true, true, false} |
| Macro used for forcing a rebuild of the owner legend the first time it is used. | |
| #define | MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, true, false} |
| Macro for end of list marker in arrays of LegendAndColour. | |
| #define | MS(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, true} |
| Macro for break marker in arrays of LegendAndColour. More... | |
| #define | MKCOLOUR(x) TO_LE32X(x) |
| #define | MKCOLOUR_XXXX(x) (MKCOLOUR(0x01010101) * (uint)(x)) |
| #define | MKCOLOUR_X0X0(x) (MKCOLOUR(0x01000100) * (uint)(x)) |
| #define | MKCOLOUR_0X0X(x) (MKCOLOUR(0x00010001) * (uint)(x)) |
| #define | MKCOLOUR_0XX0(x) (MKCOLOUR(0x00010100) * (uint)(x)) |
| #define | MKCOLOUR_X00X(x) (MKCOLOUR(0x01000001) * (uint)(x)) |
| #define | MKCOLOUR_XYXY(x, y) (MKCOLOUR_X0X0(x) | MKCOLOUR_0X0X(y)) |
| #define | MKCOLOUR_XYYX(x, y) (MKCOLOUR_X00X(x) | MKCOLOUR_0XX0(y)) |
| #define | MKCOLOUR_0000 MKCOLOUR_XXXX(0x00) |
| #define | MKCOLOUR_0FF0 MKCOLOUR_0XX0(0xFF) |
| #define | MKCOLOUR_F00F MKCOLOUR_X00X(0xFF) |
| #define | MKCOLOUR_FFFF MKCOLOUR_XXXX(0xFF) |
Enumerations | |
| enum | SmallMapType : byte { SMT_CONTOUR, SMT_VEHICLES, SMT_INDUSTRY, SMT_LINKSTATS, SMT_ROUTES, SMT_VEGETATION, SMT_OWNER } |
| Types of legends in the WID_SM_LEGEND widget. | |
Functions | |
| void | BuildIndustriesLegend () |
| Fills an array for the industries legends. | |
| void | BuildLinkStatsLegend () |
| Populate legend table for the link stat view. | |
| void | BuildLandLegend () |
| (Re)build the colour tables for the legends. | |
| void | BuildOwnerLegend () |
| Completes the array for the owned property legend. | |
| static uint32_t | ApplyMask (uint32_t colour, const AndOr *mask) |
| static uint32_t | GetSmallMapContoursPixels (TileIndex tile, TileType t) |
| Return the colour a tile would be displayed with in the small map in mode "Contour". More... | |
| static uint32_t | GetSmallMapVehiclesPixels (TileIndex, TileType t) |
| Return the colour a tile would be displayed with in the small map in mode "Vehicles". More... | |
| static uint32_t | GetSmallMapIndustriesPixels (TileIndex tile, TileType t) |
| Return the colour a tile would be displayed with in the small map in mode "Industries". More... | |
| static uint32_t | GetSmallMapRoutesPixels (TileIndex tile, TileType t) |
| Return the colour a tile would be displayed with in the small map in mode "Routes". More... | |
| static uint32_t | GetSmallMapLinkStatsPixels (TileIndex tile, TileType t) |
| Return the colour a tile would be displayed with in the small map in mode "link stats". More... | |
| static uint32_t | GetSmallMapVegetationPixels (TileIndex tile, TileType t) |
| Return the colour a tile would be displayed with in the smallmap in mode "Vegetation". More... | |
| uint32_t | GetSmallMapOwnerPixels (TileIndex tile, TileType t, IncludeHeightmap include_heightmap) |
| Return the colour a tile would be displayed with in the small map in mode "Owner". More... | |
| static std::unique_ptr< NWidgetBase > | SmallMapDisplay () |
| void | ShowSmallMap () |
| Show the smallmap window. | |
| bool | ScrollMainWindowTo (int x, int y, int z, bool instant) |
| Scrolls the main window to given coordinates. More... | |
| Point | GetSmallMapStationMiddle (const Window *w, const Station *st) |
| Determine the middle of a station in the smallmap window. More... | |
Variables | |
| static int | _smallmap_industry_count |
| Number of used industries. | |
| static int | _smallmap_company_count |
| Number of entries in the owner legend. | |
| static int | _smallmap_cargo_count |
| Number of cargos in the link stats legend. | |
| static uint8_t | _linkstat_colours_in_legenda [] = {0, 1, 3, 5, 7, 9, 11} |
| Link stat colours shown in legenda. | |
| static const int | NUM_NO_COMPANY_ENTRIES = 4 |
| Number of entries in the owner legend that are not companies. | |
| static LegendAndColour | _legend_land_contours [] |
| Legend text giving the colours to look for on the minimap. More... | |
| static const LegendAndColour | _legend_vehicles [] |
| static const LegendAndColour | _legend_routes [] |
| static const LegendAndColour | _legend_vegetation [] |
| static LegendAndColour | _legend_land_owners [NUM_NO_COMPANY_ENTRIES+MAX_COMPANIES+1] |
| static LegendAndColour | _legend_linkstats [NUM_CARGO+lengthof(_linkstat_colours_in_legenda)+1] |
| Legend entries for the link stats view. | |
| 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 slots all filled up. | |
| static uint | _industry_to_list_pos [NUM_INDUSTRYTYPES] |
| For connecting industry type to position in industries list(small map legend) | |
| static bool | _smallmap_show_heightmap = false |
| Show heightmap in industry and owner mode of smallmap window. | |
| static IndustryType | _smallmap_industry_highlight = INVALID_INDUSTRYTYPE |
| Highlight a specific industry type. | |
| static bool | _smallmap_industry_highlight_state |
| State of highlight blinking. | |
| static uint | _company_to_list_pos [MAX_COMPANIES] |
| For connecting company ID to position in owner list (small map legend) | |
| static const LegendAndColour *const | _legend_table [] |
| static SmallMapColourScheme | _heightmap_schemes [] |
| Available colour schemes for height maps. More... | |
| static const AndOr | _smallmap_contours_andor [] |
| Colour masks for "Contour" and "Routes" modes. More... | |
| static const AndOr | _smallmap_vehicles_andor [] |
| Colour masks for "Vehicles", "Industry", and "Vegetation" modes. More... | |
| static const byte | _tiletype_importance [] |
| Mapping of tile type to importance of the tile (higher number means more interesting to show). More... | |
| static const uint32_t | _vegetation_clear_bits [] |
| static const byte | _vehicle_type_colours [6] |
| Vehicle colours in #SMT_VEHICLES mode. More... | |
| static constexpr NWidgetPart | _nested_smallmap_display [] |
| Widget parts of the smallmap display. More... | |
| static constexpr NWidgetPart | _nested_smallmap_bar [] |
| Widget parts of the smallmap legend bar + image buttons. | |
| static constexpr NWidgetPart | _nested_smallmap_widgets [] |
| static WindowDesc | _smallmap_desc (__FILE__, __LINE__, WDP_AUTO, "smallmap", 484, 314, WC_SMALLMAP, WC_NONE, 0, std::begin(_nested_smallmap_widgets), std::end(_nested_smallmap_widgets)) |
GUI that shows a small map of the world with metadata like owner or height.
Definition in file smallmap_gui.cpp.
| #define MS | ( | a, | |
| b | |||
| ) | {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, true} |
Macro for break marker in arrays of LegendAndColour.
It will have valid data, though
Definition at line 80 of file smallmap_gui.cpp.
Return the colour a tile would be displayed with in the small map in mode "Contour".
| tile | The tile of which we would like to get the colour. |
| t | Effective tile type of the tile (see SmallMapWindow::GetTileColours). |
Definition at line 431 of file smallmap_gui.cpp.
References _heightmap_schemes, _settings_client, ClientSettings::gui, and GUISettings::smallmap_land_colour.
Referenced by GetSmallMapLinkStatsPixels().
Return the colour a tile would be displayed with in the small map in mode "Industries".
| tile | The tile of which we would like to get the colour. |
| t | Effective tile type of the tile (see SmallMapWindow::GetTileColours). |
Definition at line 457 of file smallmap_gui.cpp.
References _heightmap_schemes, _settings_client, ClientSettings::gui, and GUISettings::smallmap_land_colour.
Return the colour a tile would be displayed with in the small map in mode "link stats".
| tile | The tile of which we would like to get the colour. |
| t | Effective tile type of the tile (see SmallMapWindow::GetTileColours). |
Definition at line 526 of file smallmap_gui.cpp.
References _smallmap_show_heightmap, GetSmallMapContoursPixels(), and GetSmallMapRoutesPixels().
| uint32_t GetSmallMapOwnerPixels | ( | TileIndex | tile, |
| TileType | t, | ||
| IncludeHeightmap | include_heightmap | ||
| ) |
Return the colour a tile would be displayed with in the small map in mode "Owner".
| tile | The tile of which we would like to get the colour. |
| t | Effective tile type of the tile (see SmallMapWindow::GetTileColours). |
| include_heightmap | Whether to return the heightmap/contour colour of this tile (instead of the default land tile colour) |
Definition at line 582 of file smallmap_gui.cpp.
References MP_VOID.
Return the colour a tile would be displayed with in the small map in mode "Routes".
| tile | The tile of which we would like to get the colour. |
| t | Effective tile type of the tile (see SmallMapWindow::GetTileColours). |
Definition at line 470 of file smallmap_gui.cpp.
References GetStationType(), and MP_STATION.
Referenced by GetSmallMapLinkStatsPixels().
Determine the middle of a station in the smallmap window.
| st | The station we're looking for. |
Definition at line 2028 of file smallmap_gui.cpp.
Return the colour a tile would be displayed with in the smallmap in mode "Vegetation".
| tile | The tile of which we would like to get the colour. |
| t | Effective tile type of the tile (see SmallMapWindow::GetTileColours). |
Definition at line 549 of file smallmap_gui.cpp.
References CLEAR_GRASS, GetClearDensity(), IsClearGround(), and MP_CLEAR.
Return the colour a tile would be displayed with in the small map in mode "Vehicles".
| tile | The tile of which we would like to get the colour. |
| t | Effective tile type of the tile (see SmallMapWindow::GetTileColours). |
Definition at line 444 of file smallmap_gui.cpp.
References _heightmap_schemes, _settings_client, ClientSettings::gui, and GUISettings::smallmap_land_colour.
| bool ScrollMainWindowTo | ( | int | x, |
| int | y, | ||
| int | z, | ||
| bool | instant | ||
| ) |
Scrolls the main window to given coordinates.
| x | x coordinate |
| y | y coordinate |
| z | z coordinate; -1 to scroll to terrain height |
| instant | scroll instantly (meaningful only when smooth_scrolling is active) |
Definition at line 2007 of file smallmap_gui.cpp.
Referenced by ScrollMainWindowToTile().
|
static |
Available colour schemes for height maps.
Definition at line 283 of file smallmap_gui.cpp.
Referenced by BuildLandLegend(), GetSmallMapContoursPixels(), GetSmallMapIndustriesPixels(), GetSmallMapVehiclesPixels(), and SmallMapWindow::RebuildColourIndexIfNecessary().
|
static |
Legend text giving the colours to look for on the minimap.
Definition at line 83 of file smallmap_gui.cpp.
Referenced by BuildLandLegend().
|
static |
Definition at line 149 of file smallmap_gui.cpp.
|
static |
Definition at line 119 of file smallmap_gui.cpp.
|
static |
Definition at line 246 of file smallmap_gui.cpp.
|
static |
Definition at line 132 of file smallmap_gui.cpp.
|
static |
Definition at line 108 of file smallmap_gui.cpp.
|
staticconstexpr |
Widget parts of the smallmap display.
Definition at line 1900 of file smallmap_gui.cpp.
|
staticconstexpr |
Definition at line 1958 of file smallmap_gui.cpp.
|
static |
Colour masks for "Contour" and "Routes" modes.
Definition at line 377 of file smallmap_gui.cpp.
|
static |
Colour masks for "Vehicles", "Industry", and "Vegetation" modes.
Definition at line 393 of file smallmap_gui.cpp.
|
static |
Mapping of tile type to importance of the tile (higher number means more interesting to show).
Definition at line 409 of file smallmap_gui.cpp.
|
static |
Definition at line 531 of file smallmap_gui.cpp.
|
static |
Vehicle colours in #SMT_VEHICLES mode.
Indexed by VehicleType.
Definition at line 610 of file smallmap_gui.cpp.