Import combined Enhanced viewport: zoom out, overlays & tooltips (r53_27127) patch
https://www.tt-forums.net/viewtopic.php?f=33&t=53394
This commit is contained in:

committed by
Jonathan G Rennison

parent
fd3388467f
commit
536a95dfd0
@@ -24,6 +24,7 @@
|
||||
#include "window_func.h"
|
||||
#include "company_base.h"
|
||||
|
||||
#include "smallmap_colours.h"
|
||||
#include "smallmap_gui.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
@@ -37,15 +38,6 @@ static int _smallmap_cargo_count; ///< Number of cargos in the link stats leg
|
||||
/** Link stat colours shown in legenda. */
|
||||
static uint8 _linkstat_colours_in_legenda[] = {0, 1, 3, 5, 7, 9, 11};
|
||||
|
||||
static const int NUM_NO_COMPANY_ENTRIES = 4; ///< Number of entries in the owner legend that are not companies.
|
||||
|
||||
static const uint8 PC_ROUGH_LAND = 0x52; ///< Dark green palette colour for rough land.
|
||||
static const uint8 PC_GRASS_LAND = 0x54; ///< Dark green palette colour for grass land.
|
||||
static const uint8 PC_BARE_LAND = 0x37; ///< Brown palette colour for bare land.
|
||||
static const uint8 PC_FIELDS = 0x25; ///< Light brown palette colour for fields.
|
||||
static const uint8 PC_TREES = 0x57; ///< Green palette colour for trees.
|
||||
static const uint8 PC_WATER = 0xCA; ///< Dark blue palette colour for water.
|
||||
|
||||
/** Macro for ordinary entry of LegendAndColour */
|
||||
#define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false}
|
||||
|
||||
@@ -133,7 +125,7 @@ static const LegendAndColour _legend_vegetation[] = {
|
||||
MKEND()
|
||||
};
|
||||
|
||||
static LegendAndColour _legend_land_owners[NUM_NO_COMPANY_ENTRIES + MAX_COMPANIES + 1] = {
|
||||
LegendAndColour _legend_land_owners[NUM_NO_COMPANY_ENTRIES + MAX_COMPANIES + 1] = {
|
||||
MO(PC_WATER, STR_SMALLMAP_LEGENDA_WATER),
|
||||
MO(0x00, STR_SMALLMAP_LEGENDA_NO_OWNER), // This colour will vary depending on settings.
|
||||
MO(PC_DARK_RED, STR_SMALLMAP_LEGENDA_TOWNS),
|
||||
@@ -155,17 +147,17 @@ static LegendAndColour _legend_linkstats[NUM_CARGO + lengthof(_linkstat_colours_
|
||||
* Allow room for all industries, plus a terminator entry
|
||||
* This is required in order to have the industry slots all filled up
|
||||
*/
|
||||
static LegendAndColour _legend_from_industries[NUM_INDUSTRYTYPES + 1];
|
||||
LegendAndColour _legend_from_industries[NUM_INDUSTRYTYPES + 1];
|
||||
/** For connecting industry type to position in industries list(small map legend) */
|
||||
static uint _industry_to_list_pos[NUM_INDUSTRYTYPES];
|
||||
uint _industry_to_list_pos[NUM_INDUSTRYTYPES];
|
||||
/** Show heightmap in industry and owner mode of smallmap window. */
|
||||
static bool _smallmap_show_heightmap = false;
|
||||
bool _smallmap_show_heightmap = false;
|
||||
/** Highlight a specific industry type */
|
||||
static IndustryType _smallmap_industry_highlight = INVALID_INDUSTRYTYPE;
|
||||
/** State of highlight blinking */
|
||||
static bool _smallmap_industry_highlight_state;
|
||||
/** For connecting company ID to position in owner list (small map legend) */
|
||||
static uint _company_to_list_pos[MAX_COMPANIES];
|
||||
uint _company_to_list_pos[MAX_COMPANIES];
|
||||
|
||||
/**
|
||||
* Fills an array for the industries legends.
|
||||
@@ -241,35 +233,9 @@ static const LegendAndColour * const _legend_table[] = {
|
||||
_legend_land_owners,
|
||||
};
|
||||
|
||||
#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)
|
||||
|
||||
#include "table/heightmap_colours.h"
|
||||
|
||||
/** Colour scheme of the smallmap. */
|
||||
struct SmallMapColourScheme {
|
||||
uint32 *height_colours; ///< Cached colours for each level in a map.
|
||||
const uint32 *height_colours_base; ///< Base table for determining the colours
|
||||
size_t colour_count; ///< The number of colours.
|
||||
uint32 default_colour; ///< Default colour of the land.
|
||||
};
|
||||
|
||||
/** Available colour schemes for height maps. */
|
||||
static SmallMapColourScheme _heightmap_schemes[] = {
|
||||
{NULL, _green_map_heights, lengthof(_green_map_heights), MKCOLOUR_XXXX(0x54)}, ///< Green colour scheme.
|
||||
SmallMapColourScheme _heightmap_schemes[] = {
|
||||
{NULL, _green_map_heights, lengthof(_green_map_heights), MKCOLOUR_XXXX(0x5B)}, ///< Green colour scheme.
|
||||
{NULL, _dark_green_map_heights, lengthof(_dark_green_map_heights), MKCOLOUR_XXXX(0x62)}, ///< Dark green colour scheme.
|
||||
{NULL, _violet_map_heights, lengthof(_violet_map_heights), MKCOLOUR_XXXX(0x82)}, ///< Violet colour scheme.
|
||||
};
|
||||
@@ -351,66 +317,6 @@ void BuildOwnerLegend()
|
||||
_smallmap_company_count = i;
|
||||
}
|
||||
|
||||
struct AndOr {
|
||||
uint32 mor;
|
||||
uint32 mand;
|
||||
};
|
||||
|
||||
static inline uint32 ApplyMask(uint32 colour, const AndOr *mask)
|
||||
{
|
||||
return (colour & mask->mand) | mask->mor;
|
||||
}
|
||||
|
||||
|
||||
/** Colour masks for "Contour" and "Routes" modes. */
|
||||
static const AndOr _smallmap_contours_andor[] = {
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_CLEAR
|
||||
{MKCOLOUR_0XX0(PC_GREY ), MKCOLOUR_F00F}, // MP_RAILWAY
|
||||
{MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F}, // MP_ROAD
|
||||
{MKCOLOUR_0XX0(PC_DARK_RED ), MKCOLOUR_F00F}, // MP_HOUSE
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_TREES
|
||||
{MKCOLOUR_XXXX(PC_LIGHT_BLUE), MKCOLOUR_0000}, // MP_STATION
|
||||
{MKCOLOUR_XXXX(PC_WATER ), MKCOLOUR_0000}, // MP_WATER
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_VOID
|
||||
{MKCOLOUR_XXXX(PC_DARK_RED ), MKCOLOUR_0000}, // MP_INDUSTRY
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_TUNNELBRIDGE
|
||||
{MKCOLOUR_0XX0(PC_DARK_RED ), MKCOLOUR_F00F}, // MP_OBJECT
|
||||
{MKCOLOUR_0XX0(PC_GREY ), MKCOLOUR_F00F},
|
||||
};
|
||||
|
||||
/** Colour masks for "Vehicles", "Industry", and "Vegetation" modes. */
|
||||
static const AndOr _smallmap_vehicles_andor[] = {
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_CLEAR
|
||||
{MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F}, // MP_RAILWAY
|
||||
{MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F}, // MP_ROAD
|
||||
{MKCOLOUR_0XX0(PC_DARK_RED ), MKCOLOUR_F00F}, // MP_HOUSE
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_TREES
|
||||
{MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F}, // MP_STATION
|
||||
{MKCOLOUR_XXXX(PC_WATER ), MKCOLOUR_0000}, // MP_WATER
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_VOID
|
||||
{MKCOLOUR_XXXX(PC_DARK_RED ), MKCOLOUR_0000}, // MP_INDUSTRY
|
||||
{MKCOLOUR_0000 , MKCOLOUR_FFFF}, // MP_TUNNELBRIDGE
|
||||
{MKCOLOUR_0XX0(PC_DARK_RED ), MKCOLOUR_F00F}, // MP_OBJECT
|
||||
{MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F},
|
||||
};
|
||||
|
||||
/** Mapping of tile type to importance of the tile (higher number means more interesting to show). */
|
||||
static const byte _tiletype_importance[] = {
|
||||
2, // MP_CLEAR
|
||||
8, // MP_RAILWAY
|
||||
7, // MP_ROAD
|
||||
5, // MP_HOUSE
|
||||
2, // MP_TREES
|
||||
9, // MP_STATION
|
||||
2, // MP_WATER
|
||||
1, // MP_VOID
|
||||
6, // MP_INDUSTRY
|
||||
8, // MP_TUNNELBRIDGE
|
||||
2, // MP_OBJECT
|
||||
0,
|
||||
};
|
||||
|
||||
|
||||
static inline TileType GetEffectiveTileType(TileIndex tile)
|
||||
{
|
||||
TileType t = GetTileType(tile);
|
||||
@@ -522,17 +428,6 @@ static inline uint32 GetSmallMapLinkStatsPixels(TileIndex tile, TileType t)
|
||||
return _smallmap_show_heightmap ? GetSmallMapContoursPixels(tile, t) : GetSmallMapRoutesPixels(tile, t);
|
||||
}
|
||||
|
||||
static const uint32 _vegetation_clear_bits[] = {
|
||||
MKCOLOUR_XXXX(PC_GRASS_LAND), ///< full grass
|
||||
MKCOLOUR_XXXX(PC_ROUGH_LAND), ///< rough land
|
||||
MKCOLOUR_XXXX(PC_GREY), ///< rocks
|
||||
MKCOLOUR_XXXX(PC_FIELDS), ///< fields
|
||||
MKCOLOUR_XXXX(PC_LIGHT_BLUE), ///< snow
|
||||
MKCOLOUR_XXXX(PC_ORANGE), ///< desert
|
||||
MKCOLOUR_XXXX(PC_GRASS_LAND), ///< unused
|
||||
MKCOLOUR_XXXX(PC_GRASS_LAND), ///< unused
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the colour a tile would be displayed with in the smallmap in mode "Vegetation".
|
||||
*
|
||||
@@ -592,6 +487,16 @@ static inline uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t)
|
||||
return MKCOLOUR_XXXX(_legend_land_owners[_company_to_list_pos[o]].colour);
|
||||
}
|
||||
|
||||
static void NotifyAllViewports(ViewportMapType map_type)
|
||||
{
|
||||
Window *w;
|
||||
FOR_ALL_WINDOWS_FROM_BACK(w) {
|
||||
if (w->viewport != NULL)
|
||||
if (w->viewport->zoom >= ZOOM_LVL_DRAW_MAP && w->viewport->map_type == map_type)
|
||||
w->InvalidateData();
|
||||
}
|
||||
}
|
||||
|
||||
/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleTypeByte. */
|
||||
static const byte _vehicle_type_colours[6] = {
|
||||
PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED
|
||||
@@ -1483,6 +1388,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
|
||||
/* If click on industries label, find right industry type and enable/disable it. */
|
||||
if (click_pos < _smallmap_industry_count) {
|
||||
this->SelectLegendItem(click_pos, _legend_from_industries, _smallmap_industry_count);
|
||||
NotifyAllViewports(VPMT_INDUSTRY);
|
||||
}
|
||||
} else if (this->map_type == SMT_LINKSTATS) {
|
||||
if (click_pos < _smallmap_cargo_count) {
|
||||
@@ -1492,6 +1398,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
|
||||
} else if (this->map_type == SMT_OWNER) {
|
||||
if (click_pos < _smallmap_company_count) {
|
||||
this->SelectLegendItem(click_pos, _legend_land_owners, _smallmap_company_count, NUM_NO_COMPANY_ENTRIES);
|
||||
NotifyAllViewports(VPMT_OWNER);
|
||||
}
|
||||
}
|
||||
this->SetDirty();
|
||||
@@ -1505,9 +1412,11 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
|
||||
switch (this->map_type) {
|
||||
case SMT_INDUSTRY:
|
||||
tbl = _legend_from_industries;
|
||||
NotifyAllViewports(VPMT_INDUSTRY);
|
||||
break;
|
||||
case SMT_OWNER:
|
||||
tbl = &(_legend_land_owners[NUM_NO_COMPANY_ENTRIES]);
|
||||
NotifyAllViewports(VPMT_OWNER);
|
||||
break;
|
||||
case SMT_LINKSTATS:
|
||||
tbl = _legend_linkstats;
|
||||
@@ -1526,6 +1435,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
|
||||
case WID_SM_SHOW_HEIGHT: // Enable/disable showing of heightmap.
|
||||
_smallmap_show_heightmap = !_smallmap_show_heightmap;
|
||||
this->SetWidgetLoweredState(WID_SM_SHOW_HEIGHT, _smallmap_show_heightmap);
|
||||
NotifyAllViewports(VPMT_INDUSTRY);
|
||||
this->SetDirty();
|
||||
break;
|
||||
}
|
||||
@@ -1572,7 +1482,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
|
||||
{
|
||||
if (widget != WID_SM_MAP || _scrolling_viewport) return false;
|
||||
|
||||
_scrolling_viewport = true;
|
||||
_scrolling_viewport = this;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user