From 9854553e10f279256e929612c64260650312386f Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 4 Apr 2024 18:27:34 +0100 Subject: [PATCH] Codechange: ZOOM_LVL_SHIFT/BASE are not actually ZOOM_LVLs. Rename to ZOOM_BASE_SHIFT and ZOOM_BASE respectively, and derive from ZOOM_LVL instead of numeric value. --- src/fontcache/spritefontcache.cpp | 4 ++-- src/gfx.cpp | 2 +- src/landscape.h | 6 ++--- src/saveload/afterload.cpp | 6 ++--- src/signs.cpp | 2 +- src/smallmap_gui.cpp | 2 +- src/station_cmd.cpp | 4 ++-- src/texteff.cpp | 2 +- src/tile_type.h | 10 ++++---- src/town_cmd.cpp | 2 +- src/vehicle.cpp | 20 ++++++++-------- src/viewport.cpp | 40 +++++++++++++++---------------- src/waypoint_cmd.cpp | 2 +- src/widget.cpp | 4 ++-- src/zoom_func.h | 6 ++--- src/zoom_type.h | 7 +++--- 16 files changed, 59 insertions(+), 60 deletions(-) diff --git a/src/fontcache/spritefontcache.cpp b/src/fontcache/spritefontcache.cpp index aa577e1b11..264a691526 100644 --- a/src/fontcache/spritefontcache.cpp +++ b/src/fontcache/spritefontcache.cpp @@ -23,12 +23,12 @@ static const int ASCII_LETTERSTART = 32; ///< First printable ASCII letter. /** * Scale traditional pixel dimensions to font zoom level, for drawing sprite fonts. - * @param value Pixel amount at #ZOOM_LVL_BASE (traditional "normal" interface size). + * @param value Pixel amount at #ZOOM_BASE (traditional "normal" interface size). * @return Pixel amount at _font_zoom (current interface size). */ static int ScaleFontTrad(int value) { - return UnScaleByZoom(value * ZOOM_LVL_BASE, _font_zoom); + return UnScaleByZoom(value * ZOOM_BASE, _font_zoom); } /** diff --git a/src/gfx.cpp b/src/gfx.cpp index 2731220f0c..a4a3267548 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1210,7 +1210,7 @@ std::unique_ptr DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel static void GfxMainBlitterViewport(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub, SpriteID sprite_id) { - GfxBlitter(sprite, x, y, mode, sub, sprite_id, _cur_dpi->zoom); + GfxBlitter(sprite, x, y, mode, sub, sprite_id, _cur_dpi->zoom); } static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub, SpriteID sprite_id, ZoomLevel zoom) diff --git a/src/landscape.h b/src/landscape.h index 7d92ce1273..98221c5019 100644 --- a/src/landscape.h +++ b/src/landscape.h @@ -79,8 +79,8 @@ inline std::tuple GetFoundationPixelSlope(TileIndex tile) inline Point RemapCoords(int x, int y, int z) { Point pt; - pt.x = (y - x) * 2 * ZOOM_LVL_BASE; - pt.y = (y + x - z) * ZOOM_LVL_BASE; + pt.x = (y - x) * 2 * ZOOM_BASE; + pt.y = (y + x - z) * ZOOM_BASE; return pt; } @@ -108,7 +108,7 @@ inline Point RemapCoords2(int x, int y) */ inline Point InverseRemapCoords(int x, int y) { - Point pt = {(y * 2 - x) >> (2 + ZOOM_LVL_SHIFT), (y * 2 + x) >> (2 + ZOOM_LVL_SHIFT)}; + Point pt = {(y * 2 - x) >> (2 + ZOOM_BASE_SHIFT), (y * 2 + x) >> (2 + ZOOM_BASE_SHIFT)}; return pt; } diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index bc203e16dc..9bfb99506b 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2838,9 +2838,9 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_165)) { /* Adjust zoom level to account for new levels */ - _saved_scrollpos_zoom = static_cast(_saved_scrollpos_zoom + ZOOM_LVL_SHIFT); - _saved_scrollpos_x *= ZOOM_LVL_BASE; - _saved_scrollpos_y *= ZOOM_LVL_BASE; + _saved_scrollpos_zoom = static_cast(_saved_scrollpos_zoom + ZOOM_BASE_SHIFT); + _saved_scrollpos_x *= ZOOM_BASE; + _saved_scrollpos_y *= ZOOM_BASE; } /* When any NewGRF has been changed the availability of some vehicles might diff --git a/src/signs.cpp b/src/signs.cpp index 0f1d7a78f0..453c55841b 100644 --- a/src/signs.cpp +++ b/src/signs.cpp @@ -50,7 +50,7 @@ void Sign::UpdateVirtCoord() if (this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeSign(this->index)); SetDParam(0, this->index); - this->sign.UpdatePosition(pt.x, pt.y - 6 * ZOOM_LVL_BASE, STR_WHITE_SIGN); + this->sign.UpdatePosition(pt.x, pt.y - 6 * ZOOM_BASE, STR_WHITE_SIGN); _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeSign(this->index)); } diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 4bfa47b6de..18d25d7083 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -843,7 +843,7 @@ protected: void SetNewScroll(int sx, int sy, int sub) { const NWidgetBase *wi = this->GetWidget(WID_SM_MAP); - Point hv = InverseRemapCoords(wi->current_x * ZOOM_LVL_BASE * TILE_SIZE / 2, wi->current_y * ZOOM_LVL_BASE * TILE_SIZE / 2); + Point hv = InverseRemapCoords(wi->current_x * ZOOM_BASE * TILE_SIZE / 2, wi->current_y * ZOOM_BASE * TILE_SIZE / 2); hv.x *= this->zoom; hv.y *= this->zoom; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 5ae1b6735d..5385d78887 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -441,8 +441,8 @@ void Station::UpdateVirtCoord() { Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE); - pt.y -= 32 * ZOOM_LVL_BASE; - if ((this->facilities & FACIL_AIRPORT) && this->airport.type == AT_OILRIG) pt.y -= 16 * ZOOM_LVL_BASE; + pt.y -= 32 * ZOOM_BASE; + if ((this->facilities & FACIL_AIRPORT) && this->airport.type == AT_OILRIG) pt.y -= 16 * ZOOM_BASE; if (this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeStation(this->index)); diff --git a/src/texteff.cpp b/src/texteff.cpp index 930df8421c..10b276232e 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -104,7 +104,7 @@ IntervalTimer move_all_text_effects_interval = {std::chrono::millis te.MarkDirty(ZOOM_LVL_TEXT_EFFECT); te.duration -= count; - te.top -= count * ZOOM_LVL_BASE; + te.top -= count * ZOOM_BASE; te.MarkDirty(ZOOM_LVL_TEXT_EFFECT); } }}; diff --git a/src/tile_type.h b/src/tile_type.h index 261fe58fc2..d1a7a3eb93 100644 --- a/src/tile_type.h +++ b/src/tile_type.h @@ -14,12 +14,12 @@ static const uint TILE_SIZE = 16; ///< Tile size in world coordinates. static const uint TILE_UNIT_MASK = TILE_SIZE - 1; ///< For masking in/out the inner-tile world coordinate units. -static const uint TILE_PIXELS = 32; ///< Pixel distance between tile columns/rows in #ZOOM_LVL_BASE. -static const uint TILE_HEIGHT = 8; ///< Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE. +static const uint TILE_PIXELS = 32; ///< Pixel distance between tile columns/rows in #ZOOM_BASE. +static const uint TILE_HEIGHT = 8; ///< Height of a height level in world coordinate AND in pixels in #ZOOM_BASE. -static const uint MAX_BUILDING_PIXELS = 200; ///< Maximum height of a building in pixels in #ZOOM_LVL_BASE. (Also applies to "bridge buildings" on the bridge floor.) -static const int MAX_VEHICLE_PIXEL_X = 192; ///< Maximum width of a vehicle in pixels in #ZOOM_LVL_BASE. -static const int MAX_VEHICLE_PIXEL_Y = 96; ///< Maximum height of a vehicle in pixels in #ZOOM_LVL_BASE. +static const uint MAX_BUILDING_PIXELS = 200; ///< Maximum height of a building in pixels in #ZOOM_BASE. (Also applies to "bridge buildings" on the bridge floor.) +static const int MAX_VEHICLE_PIXEL_X = 192; ///< Maximum width of a vehicle in pixels in #ZOOM_BASE. +static const int MAX_VEHICLE_PIXEL_Y = 96; ///< Maximum height of a vehicle in pixels in #ZOOM_BASE. static const uint MAX_TILE_HEIGHT = 255; ///< Maximum allowed tile height diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index c44cf48b04..8634fb0b7a 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -409,7 +409,7 @@ void Town::UpdateVirtCoord() SetDParam(0, this->index); SetDParam(1, this->cache.population); - this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE, + this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_BASE, _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN, STR_VIEWPORT_TOWN_TINY_WHITE); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 7d6e8489ea..c8fefff234 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -74,13 +74,13 @@ static const uint GEN_HASHX_BUCKET_BITS = 7; static const uint GEN_HASHY_BUCKET_BITS = 6; /* Compute hash for vehicle coord */ -#define GEN_HASHX(x) GB((x), GEN_HASHX_BUCKET_BITS + ZOOM_LVL_SHIFT, GEN_HASHX_BITS) -#define GEN_HASHY(y) (GB((y), GEN_HASHY_BUCKET_BITS + ZOOM_LVL_SHIFT, GEN_HASHY_BITS) << GEN_HASHX_BITS) +#define GEN_HASHX(x) GB((x), GEN_HASHX_BUCKET_BITS + ZOOM_BASE_SHIFT, GEN_HASHX_BITS) +#define GEN_HASHY(y) (GB((y), GEN_HASHY_BUCKET_BITS + ZOOM_BASE_SHIFT, GEN_HASHY_BITS) << GEN_HASHX_BITS) #define GEN_HASH(x, y) (GEN_HASHY(y) + GEN_HASHX(x)) /* Maximum size until hash repeats */ -static const int GEN_HASHX_SIZE = 1 << (GEN_HASHX_BUCKET_BITS + GEN_HASHX_BITS + ZOOM_LVL_SHIFT); -static const int GEN_HASHY_SIZE = 1 << (GEN_HASHY_BUCKET_BITS + GEN_HASHY_BITS + ZOOM_LVL_SHIFT); +static const int GEN_HASHX_SIZE = 1 << (GEN_HASHX_BUCKET_BITS + GEN_HASHX_BITS + ZOOM_BASE_SHIFT); +static const int GEN_HASHY_SIZE = 1 << (GEN_HASHY_BUCKET_BITS + GEN_HASHY_BITS + ZOOM_BASE_SHIFT); /* Increments to reach next bucket in hash table */ static const int GEN_HASHX_INC = 1; @@ -1158,8 +1158,8 @@ void ViewportAddVehicles(DrawPixelInfo *dpi) const int b = dpi->top + dpi->height; /* Border size of MAX_VEHICLE_PIXEL_xy */ - const int xb = MAX_VEHICLE_PIXEL_X * ZOOM_LVL_BASE; - const int yb = MAX_VEHICLE_PIXEL_Y * ZOOM_LVL_BASE; + const int xb = MAX_VEHICLE_PIXEL_X * ZOOM_BASE; + const int yb = MAX_VEHICLE_PIXEL_Y * ZOOM_BASE; /* The hash area to scan */ int xl, xu, yl, yu; @@ -1254,8 +1254,8 @@ Vehicle *CheckClickOnVehicle(const Viewport *vp, int x, int y) y = ScaleByZoom(y, vp->zoom) + vp->virtual_top; /* Border size of MAX_VEHICLE_PIXEL_xy */ - const int xb = MAX_VEHICLE_PIXEL_X * ZOOM_LVL_BASE; - const int yb = MAX_VEHICLE_PIXEL_Y * ZOOM_LVL_BASE; + const int xb = MAX_VEHICLE_PIXEL_X * ZOOM_BASE; + const int yb = MAX_VEHICLE_PIXEL_Y * ZOOM_BASE; /* The hash area to scan */ int xl = GEN_HASHX(x - xb); @@ -1695,8 +1695,8 @@ void Vehicle::UpdateBoundingBoxCoordinates(bool update_cache) const Point pt = RemapCoords(this->x_pos + this->x_offs, this->y_pos + this->y_offs, this->z_pos); new_coord.left += pt.x; new_coord.top += pt.y; - new_coord.right += pt.x + 2 * ZOOM_LVL_BASE; - new_coord.bottom += pt.y + 2 * ZOOM_LVL_BASE; + new_coord.right += pt.x + 2 * ZOOM_BASE; + new_coord.bottom += pt.y + 2 * ZOOM_BASE; if (update_cache) { /* diff --git a/src/viewport.cpp b/src/viewport.cpp index d940d52b1f..3e82735c79 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -106,10 +106,10 @@ ViewportSignKdtree _viewport_sign_kdtree(&Kdtree_ViewportSignXYFunc); static int _viewport_sign_maxwidth = 0; -static const int MAX_TILE_EXTENT_LEFT = ZOOM_LVL_BASE * TILE_PIXELS; ///< Maximum left extent of tile relative to north corner. -static const int MAX_TILE_EXTENT_RIGHT = ZOOM_LVL_BASE * TILE_PIXELS; ///< Maximum right extent of tile relative to north corner. -static const int MAX_TILE_EXTENT_TOP = ZOOM_LVL_BASE * MAX_BUILDING_PIXELS; ///< Maximum top extent of tile relative to north corner (not considering bridges). -static const int MAX_TILE_EXTENT_BOTTOM = ZOOM_LVL_BASE * (TILE_PIXELS + 2 * TILE_HEIGHT); ///< Maximum bottom extent of tile relative to north corner (worst case: #SLOPE_STEEP_N). +static const int MAX_TILE_EXTENT_LEFT = ZOOM_BASE * TILE_PIXELS; ///< Maximum left extent of tile relative to north corner. +static const int MAX_TILE_EXTENT_RIGHT = ZOOM_BASE * TILE_PIXELS; ///< Maximum right extent of tile relative to north corner. +static const int MAX_TILE_EXTENT_TOP = ZOOM_BASE * MAX_BUILDING_PIXELS; ///< Maximum top extent of tile relative to north corner (not considering bridges). +static const int MAX_TILE_EXTENT_BOTTOM = ZOOM_BASE * (TILE_PIXELS + 2 * TILE_HEIGHT); ///< Maximum bottom extent of tile relative to north corner (worst case: #SLOPE_STEEP_N). struct StringSpriteToDraw { std::string string; @@ -570,9 +570,9 @@ void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32_t x, int32_t y, int if (_vd.foundation[_vd.foundation_part] != -1) { Point pt = RemapCoords(x, y, z); - AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, pt.x + extra_offs_x * ZOOM_LVL_BASE, pt.y + extra_offs_y * ZOOM_LVL_BASE); + AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, pt.x + extra_offs_x * ZOOM_BASE, pt.y + extra_offs_y * ZOOM_BASE); } else { - AddTileSpriteToDraw(image, pal, _cur_ti.x + x, _cur_ti.y + y, _cur_ti.z + z, sub, extra_offs_x * ZOOM_LVL_BASE, extra_offs_y * ZOOM_LVL_BASE); + AddTileSpriteToDraw(image, pal, _cur_ti.x + x, _cur_ti.y + y, _cur_ti.z + z, sub, extra_offs_x * ZOOM_BASE, extra_offs_y * ZOOM_BASE); } } @@ -614,8 +614,8 @@ void OffsetGroundSprite(int x, int y) /* _vd.last_child == nullptr if foundation sprite was clipped by the viewport bounds */ if (_vd.last_child != nullptr) _vd.foundation[_vd.foundation_part] = (uint)_vd.parent_sprites_to_draw.size() - 1; - _vd.foundation_offset[_vd.foundation_part].x = x * ZOOM_LVL_BASE; - _vd.foundation_offset[_vd.foundation_part].y = y * ZOOM_LVL_BASE; + _vd.foundation_offset[_vd.foundation_part].x = x * ZOOM_BASE; + _vd.foundation_offset[_vd.foundation_part].y = y * ZOOM_BASE; _vd.last_foundation_child[_vd.foundation_part] = _vd.last_child; } @@ -845,8 +845,8 @@ void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool tran cs.image = image; cs.pal = pal; cs.sub = sub; - cs.x = scale ? x * ZOOM_LVL_BASE : x; - cs.y = scale ? y * ZOOM_LVL_BASE : y; + cs.x = scale ? x * ZOOM_BASE : x; + cs.y = scale ? y * ZOOM_BASE : y; cs.relative = relative; cs.next = -1; @@ -892,7 +892,7 @@ static void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *t AddTileSpriteToDraw(image, pal, ti->x, ti->y, ti->z + z_offset, nullptr, extra_offs_x, extra_offs_y); } else { /* draw on top of foundation */ - AddChildSpriteToFoundation(image, pal, nullptr, foundation_part, extra_offs_x, extra_offs_y - z_offset * ZOOM_LVL_BASE); + AddChildSpriteToFoundation(image, pal, nullptr, foundation_part, extra_offs_x, extra_offs_y - z_offset * ZOOM_BASE); } } @@ -1177,7 +1177,7 @@ draw_inner: static int GetViewportY(Point tile) { /* Each increment in X or Y direction moves down by half a tile, i.e. TILE_PIXELS / 2. */ - return (tile.y * (int)(TILE_PIXELS / 2) + tile.x * (int)(TILE_PIXELS / 2) - TilePixelHeightOutsideMap(tile.x, tile.y)) << ZOOM_LVL_SHIFT; + return (tile.y * (int)(TILE_PIXELS / 2) + tile.x * (int)(TILE_PIXELS / 2) - TilePixelHeightOutsideMap(tile.x, tile.y)) << ZOOM_BASE_SHIFT; } /** @@ -1207,7 +1207,7 @@ static void ViewportAddLandscape() int left_column = (upper_left.y - upper_left.x) / (int)TILE_SIZE - 2; int right_column = (upper_right.y - upper_right.x) / (int)TILE_SIZE + 2; - int potential_bridge_height = ZOOM_LVL_BASE * TILE_HEIGHT * _settings_game.construction.max_bridge_height; + int potential_bridge_height = ZOOM_BASE * TILE_HEIGHT * _settings_game.construction.max_bridge_height; /* Rows overlap with neighbouring rows by a half tile. * The first row that could possibly be visible is the row above upper_left (if it is at height 0). @@ -1267,7 +1267,7 @@ static void ViewportAddLandscape() if (IsBridgeAbove(_cur_ti.tile)) { /* Is the bridge visible? */ TileIndex bridge_tile = GetNorthernBridgeEnd(_cur_ti.tile); - int bridge_height = ZOOM_LVL_BASE * (GetBridgePixelHeight(bridge_tile) - TilePixelHeight(_cur_ti.tile)); + int bridge_height = ZOOM_BASE * (GetBridgePixelHeight(bridge_tile) - TilePixelHeight(_cur_ti.tile)); if (min_visible_height < bridge_height + MAX_TILE_EXTENT_TOP) tile_visible = true; } @@ -1883,7 +1883,7 @@ static inline void ClampViewportToMap(const Viewport *vp, int *scroll_x, int *sc static void ClampSmoothScroll(uint32_t delta_ms, int64_t delta_hi, int64_t delta_lo, int &delta_hi_clamped, int &delta_lo_clamped) { /** A tile is 64 pixels in width at 1x zoom; viewport coordinates are in 4x zoom. */ - constexpr int PIXELS_PER_TILE = TILE_PIXELS * 2 * ZOOM_LVL_BASE; + constexpr int PIXELS_PER_TILE = TILE_PIXELS * 2 * ZOOM_BASE; assert(delta_hi != 0); @@ -2053,7 +2053,7 @@ void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_heigh Point pt = RemapCoords(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, tile_height_override * TILE_HEIGHT); MarkAllViewportsDirty( pt.x - MAX_TILE_EXTENT_LEFT, - pt.y - MAX_TILE_EXTENT_TOP - ZOOM_LVL_BASE * TILE_HEIGHT * bridge_level_offset, + pt.y - MAX_TILE_EXTENT_TOP - ZOOM_BASE * TILE_HEIGHT * bridge_level_offset, pt.x + MAX_TILE_EXTENT_RIGHT, pt.y + MAX_TILE_EXTENT_BOTTOM); } @@ -2131,15 +2131,15 @@ static void SetSelectionTilesDirty() /* the 'x' coordinate of 'top' and 'bot' is the same (and always in the same distance from tile middle), * tile height/slope affects only the 'y' on-screen coordinate! */ - int l = top.x - TILE_PIXELS * ZOOM_LVL_BASE; // 'x' coordinate of left side of the dirty rectangle + int l = top.x - TILE_PIXELS * ZOOM_BASE; // 'x' coordinate of left side of the dirty rectangle int t = top.y; // 'y' coordinate of top side of the dirty rectangle - int r = top.x + TILE_PIXELS * ZOOM_LVL_BASE; // 'x' coordinate of right side of the dirty rectangle + int r = top.x + TILE_PIXELS * ZOOM_BASE; // 'x' coordinate of right side of the dirty rectangle int b = bot.y; // 'y' coordinate of bottom side of the dirty rectangle - static const int OVERLAY_WIDTH = 4 * ZOOM_LVL_BASE; // part of selection sprites is drawn outside the selected area (in particular: terraforming) + static const int OVERLAY_WIDTH = 4 * ZOOM_BASE; // part of selection sprites is drawn outside the selected area (in particular: terraforming) /* For halftile foundations on SLOPE_STEEP_S the sprite extents some more towards the top */ - MarkAllViewportsDirty(l - OVERLAY_WIDTH, t - OVERLAY_WIDTH - TILE_HEIGHT * ZOOM_LVL_BASE, r + OVERLAY_WIDTH, b + OVERLAY_WIDTH); + MarkAllViewportsDirty(l - OVERLAY_WIDTH, t - OVERLAY_WIDTH - TILE_HEIGHT * ZOOM_BASE, r + OVERLAY_WIDTH, b + OVERLAY_WIDTH); /* haven't we reached the topmost tile yet? */ if (top_x != x_start) { diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp index 52e0ca725c..2bf7ce5e52 100644 --- a/src/waypoint_cmd.cpp +++ b/src/waypoint_cmd.cpp @@ -44,7 +44,7 @@ void Waypoint::UpdateVirtCoord() if (this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeWaypoint(this->index)); SetDParam(0, this->index); - this->sign.UpdatePosition(pt.x, pt.y - 32 * ZOOM_LVL_BASE, STR_VIEWPORT_WAYPOINT); + this->sign.UpdatePosition(pt.x, pt.y - 32 * ZOOM_BASE, STR_VIEWPORT_WAYPOINT); _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeWaypoint(this->index)); diff --git a/src/widget.cpp b/src/widget.cpp index dd91856b05..820534ddcb 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -29,7 +29,7 @@ WidgetDimensions WidgetDimensions::scaled = {}; /** * Scale a RectPadding to GUI zoom level. - * @param r RectPadding at ZOOM_LVL_BASE (traditional "normal" interface size). + * @param r RectPadding at ZOOM_BASE (traditional "normal" interface size). * @return RectPadding at #ZOOM_LVL_GUI (current interface size). */ static inline RectPadding ScaleGUITrad(const RectPadding &r) @@ -39,7 +39,7 @@ static inline RectPadding ScaleGUITrad(const RectPadding &r) /** * Scale a Dimension to GUI zoom level. - * @param d Dimension at ZOOM_LVL_BASE (traditional "normal" interface size). + * @param d Dimension at ZOOM_BASE (traditional "normal" interface size). * @return Dimension at #ZOOM_LVL_GUI (current interface size). */ static inline Dimension ScaleGUITrad(const Dimension &dim) diff --git a/src/zoom_func.h b/src/zoom_func.h index 25d8b92e8a..4ff4a84a10 100644 --- a/src/zoom_func.h +++ b/src/zoom_func.h @@ -101,17 +101,17 @@ inline ZoomLevel UnScaleZoomGUI(ZoomLevel value) /** * Scale traditional pixel dimensions to GUI zoom level, for drawing sprites. - * @param value Pixel amount at #ZOOM_LVL_BASE (traditional "normal" interface size). + * @param value Pixel amount at #ZOOM_BASE (traditional "normal" interface size). * @return Pixel amount at #ZOOM_LVL_GUI (current interface size). */ inline int ScaleSpriteTrad(int value) { - return UnScaleGUI(value * ZOOM_LVL_BASE); + return UnScaleGUI(value * ZOOM_BASE); } /** * Scale traditional pixel dimensions to GUI zoom level. - * @param value Pixel amount at #ZOOM_LVL_BASE (traditional "normal" interface size). + * @param value Pixel amount at #ZOOM_BASE (traditional "normal" interface size). * @return Pixel amount at #ZOOM_LVL_GUI (current interface size). */ inline int ScaleGUITrad(int value) diff --git a/src/zoom_type.h b/src/zoom_type.h index f5db67e2fc..9552fceca9 100644 --- a/src/zoom_type.h +++ b/src/zoom_type.h @@ -12,9 +12,6 @@ #include "core/enum_type.hpp" -static uint const ZOOM_LVL_SHIFT = 2; -static uint const ZOOM_LVL_BASE = 1 << ZOOM_LVL_SHIFT; - /** All zoom levels we know. */ enum ZoomLevel : uint8_t { /* Our possible zoom-levels */ @@ -43,11 +40,13 @@ enum ZoomLevel : uint8_t { ZOOM_LVL_MIN = ZOOM_LVL_NORMAL, ///< Minimum zoom level. ZOOM_LVL_MAX = ZOOM_LVL_OUT_32X, ///< Maximum zoom level. - }; DECLARE_POSTFIX_INCREMENT(ZoomLevel) DECLARE_ENUM_AS_ADDABLE(ZoomLevel) +static uint const ZOOM_BASE_SHIFT = static_cast(ZOOM_LVL_OUT_4X); +static uint const ZOOM_BASE = 1U << ZOOM_BASE_SHIFT; + extern int _gui_scale; extern int _gui_scale_cfg;