Merge 1.9.0-beta2

This commit is contained in:
Pavel Stupnikov
2019-02-14 00:47:22 +03:00
1364 changed files with 22213 additions and 10721 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: smallmap_gui.cpp 27905 2017-08-31 06:48:55Z adf88 $ */
/* $Id$ */
/*
* This file is part of OpenTTD.
@@ -23,6 +23,7 @@
#include "sound_func.h"
#include "window_func.h"
#include "company_base.h"
#include "guitimer_func.h"
#include "smallmap_gui.h"
@@ -416,7 +417,7 @@ static const byte _tiletype_importance[] = {
/**
* Return the colour a tile would be displayed with in the small map in mode "Contour".
* @param tile The tile of which we would like to get the colour.
* @param t Effective tile type of the tile (see #GetTileColours).
* @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours).
* @return The colour of tile in the small map in mode "Contour"
*/
static inline uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t)
@@ -429,7 +430,7 @@ static inline uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t)
* Return the colour a tile would be displayed with in the small map in mode "Vehicles".
*
* @param tile The tile of which we would like to get the colour.
* @param t Effective tile type of the tile (see #GetTileColours).
* @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours).
* @return The colour of tile in the small map in mode "Vehicles"
*/
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile, TileType t)
@@ -442,7 +443,7 @@ static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile, TileType t)
* Return the colour a tile would be displayed with in the small map in mode "Industries".
*
* @param tile The tile of which we would like to get the colour.
* @param t Effective tile type of the tile (see #GetTileColours).
* @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours).
* @return The colour of tile in the small map in mode "Industries"
*/
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile, TileType t)
@@ -455,7 +456,7 @@ static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile, TileType t)
* Return the colour a tile would be displayed with in the small map in mode "Routes".
*
* @param tile The tile of which we would like to get the colour.
* @param t Effective tile type of the tile (see #GetTileColours).
* @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours).
* @return The colour of tile in the small map in mode "Routes"
*/
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile, TileType t)
@@ -488,7 +489,7 @@ static inline uint32 GetSmallMapRoutesPixels(TileIndex tile, TileType t)
* Return the colour a tile would be displayed with in the small map in mode "link stats".
*
* @param tile The tile of which we would like to get the colour.
* @param t Effective tile type of the tile (see #GetTileColours).
* @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours).
* @return The colour of tile in the small map in mode "link stats"
*/
static inline uint32 GetSmallMapLinkStatsPixels(TileIndex tile, TileType t)
@@ -511,7 +512,7 @@ static const uint32 _vegetation_clear_bits[] = {
* Return the colour a tile would be displayed with in the smallmap in mode "Vegetation".
*
* @param tile The tile of which we would like to get the colour.
* @param t Effective tile type of the tile (see #GetTileColours).
* @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours).
* @return The colour of tile in the smallmap in mode "Vegetation"
*/
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile, TileType t)
@@ -538,7 +539,7 @@ static inline uint32 GetSmallMapVegetationPixels(TileIndex tile, TileType t)
* Return the colour a tile would be displayed with in the small map in mode "Owner".
*
* @param tile The tile of which we would like to get the colour.
* @param t Effective tile type of the tile (see #GetTileColours).
* @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours).
* @return The colour of tile in the small map in mode "Owner"
*/
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t)
@@ -611,7 +612,7 @@ inline Point SmallMapWindow::RemapTile(int tile_x, int tile_y) const
* that tile for a point in the smallmap.
* @param px Horizontal coordinate of the pixel.
* @param py Vertical coordinate of the pixel.
* @param sub[out] Pixel position at the tile (0..3).
* @param[out] sub Pixel position at the tile (0..3).
* @param add_sub Add current #subscroll to the position.
* @return Tile being displayed at the given position relative to #scroll_x and #scroll_y.
* @note The #subscroll offset is already accounted for.
@@ -641,11 +642,11 @@ inline Point SmallMapWindow::PixelToTile(int px, int py, int *sub, bool add_sub)
/**
* Compute base parameters of the smallmap such that tile (\a tx, \a ty) starts at pixel (\a x, \a y).
* @param tx Tile x coordinate.
* @param ty Tile y coordinate.
* @param x Non-negative horizontal position in the display where the tile starts.
* @param y Non-negative vertical position in the display where the tile starts.
* @param sub [out] Value of #subscroll needed.
* @param tx Tile x coordinate.
* @param ty Tile y coordinate.
* @param x Non-negative horizontal position in the display where the tile starts.
* @param y Non-negative vertical position in the display where the tile starts.
* @param[out] sub Value of #subscroll needed.
* @return #scroll_x, #scroll_y values.
*/
Point SmallMapWindow::ComputeScroll(int tx, int ty, int x, int y, int *sub)
@@ -922,8 +923,8 @@ void SmallMapWindow::DrawMapIndicators() const
/* Find main viewport. */
const ViewPort *vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
Point upper_left_smallmap_coord = TranslateXYToTileCoord(vp, vp->left, vp->top, false);
Point lower_right_smallmap_coord = TranslateXYToTileCoord(vp, vp->left + vp->width - 1, vp->top + vp->height - 1, false);
Point upper_left_smallmap_coord = InverseRemapCoords2(vp->virtual_left, vp->virtual_top);
Point lower_right_smallmap_coord = InverseRemapCoords2(vp->virtual_left + vp->virtual_width - 1, vp->virtual_top + vp->virtual_height - 1);
Point upper_left = this->RemapTile(upper_left_smallmap_coord.x / (int)TILE_SIZE, upper_left_smallmap_coord.y / (int)TILE_SIZE);
upper_left.x -= this->subscroll;
@@ -1055,7 +1056,7 @@ void SmallMapWindow::SetupWidgetData()
this->GetWidget<NWidgetStacked>(WID_SM_SELECT_BUTTONS)->SetDisplayedPlane(plane);
}
SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc), refresh(FORCE_REFRESH_PERIOD)
SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc), refresh(GUITimer(FORCE_REFRESH_PERIOD))
{
_smallmap_industry_highlight = INVALID_INDUSTRYTYPE;
this->overlay = new LinkGraphOverlay(this, WID_SM_MAP, 0, this->GetOverlayCompanyMask(), 1);
@@ -1351,7 +1352,7 @@ void SmallMapWindow::SelectLegendItem(int click_pos, LegendAndColour *legend, in
*/
void SmallMapWindow::SetOverlayCargoMask()
{
uint32 cargo_mask = 0;
CargoTypes cargo_mask = 0;
for (int i = 0; i != _smallmap_cargo_count; ++i) {
if (_legend_linkstats[i].show_on_map) SetBit(cargo_mask, _legend_linkstats[i].type);
}
@@ -1390,7 +1391,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
}
if (new_highlight != _smallmap_industry_highlight) {
_smallmap_industry_highlight = new_highlight;
this->refresh = _smallmap_industry_highlight != INVALID_INDUSTRYTYPE ? BLINK_PERIOD : FORCE_REFRESH_PERIOD;
this->refresh.SetInterval(_smallmap_industry_highlight != INVALID_INDUSTRYTYPE ? BLINK_PERIOD : FORCE_REFRESH_PERIOD);
_smallmap_industry_highlight_state = true;
this->SetDirty();
}
@@ -1559,7 +1560,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
/* virtual */ void SmallMapWindow::OnMouseWheel(int wheel)
{
if (_settings_client.gui.scrollwheel_scrolling == 0) {
if (_settings_client.gui.scrollwheel_scrolling != 2) {
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP);
int cursor_x = _cursor.pos.x - this->left - wid->pos_x;
int cursor_y = _cursor.pos.y - this->top - wid->pos_y;
@@ -1570,10 +1571,10 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
}
}
/* virtual */ void SmallMapWindow::OnTick()
/* virtual */ void SmallMapWindow::OnRealtimeTick(uint delta_ms)
{
/* Update the window every now and then */
if (--this->refresh != 0) return;
if (!this->refresh.Elapsed(delta_ms)) return;
if (this->map_type == SMT_LINKSTATS) {
uint32 company_mask = this->GetOverlayCompanyMask();
@@ -1585,7 +1586,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
}
_smallmap_industry_highlight_state = !_smallmap_industry_highlight_state;
this->refresh = _smallmap_industry_highlight != INVALID_INDUSTRYTYPE ? BLINK_PERIOD : FORCE_REFRESH_PERIOD;
this->refresh.SetInterval(_smallmap_industry_highlight != INVALID_INDUSTRYTYPE ? BLINK_PERIOD : FORCE_REFRESH_PERIOD);
this->SetDirty();
}
@@ -1628,7 +1629,7 @@ void SmallMapWindow::SetNewScroll(int sx, int sy, int sub)
/* virtual */ void SmallMapWindow::OnScroll(Point delta)
{
_cursor.fix_at = true;
if (_settings_client.gui.scroll_mode == VSM_VIEWPORT_RMB_FIXED || _settings_client.gui.scroll_mode == VSM_MAP_RMB_FIXED) _cursor.fix_at = true;
/* While tile is at (delta.x, delta.y)? */
int sub;
@@ -1644,7 +1645,7 @@ void SmallMapWindow::SetNewScroll(int sx, int sy, int sub)
void SmallMapWindow::SmallMapCenterOnCurrentPos()
{
const ViewPort *vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
Point viewport_center = TranslateXYToTileCoord(vp, vp->left + vp->width / 2, vp->top + vp->height / 2);
Point viewport_center = InverseRemapCoords2(vp->virtual_left + vp->virtual_width / 2, vp->virtual_top + vp->virtual_height / 2);
int sub;
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP);