1
0
Fork 0

Codechange: Remove ZOOM_LVL_GUI macro. (#14423)

pull/14391/merge
Peter Nelson 2025-07-09 11:05:06 +01:00 committed by GitHub
parent 8de32c4509
commit d2ee2add28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 15 additions and 16 deletions

View File

@ -88,12 +88,12 @@ void UndrawMouseCursor();
void RedrawScreenRect(int left, int top, int right, int bottom);
void GfxScroll(int left, int top, int width, int height, int xo, int yo);
Dimension GetSpriteSize(SpriteID sprid, Point *offset = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI);
Dimension GetSpriteSize(SpriteID sprid, Point *offset = nullptr, ZoomLevel zoom = _gui_zoom);
Dimension GetScaledSpriteSize(SpriteID sprid); /* widget.cpp */
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr);
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI);
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr, ZoomLevel zoom = _gui_zoom);
void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, StringAlignment align); /* widget.cpp */
std::unique_ptr<uint32_t[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom = ZOOM_LVL_GUI);
std::unique_ptr<uint32_t[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom = _gui_zoom);
int DrawString(int left, int right, int top, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
int DrawString(int left, int right, int top, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);

View File

@ -526,7 +526,7 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
}
if (sprite_type == SpriteType::Font && _font_zoom != ZoomLevel::Min) {
/* Make ZoomLevel::Min be ZOOM_LVL_GUI */
/* Make ZoomLevel::Min the desired font zoom level. */
sprite[ZoomLevel::Min] = sprite[_font_zoom];
}

View File

@ -1080,9 +1080,9 @@ void OpenGLBackend::DrawMouseCursor()
const OpenGLSprite *spr = this->cursor_cache.Get(cs.image.sprite).get();
this->RenderOglSprite(spr, cs.image.pal,
this->cursor_pos.x + cs.pos.x + UnScaleByZoom(spr->x_offs, ZOOM_LVL_GUI),
this->cursor_pos.y + cs.pos.y + UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI),
ZOOM_LVL_GUI);
this->cursor_pos.x + cs.pos.x + UnScaleByZoom(spr->x_offs, _gui_zoom),
this->cursor_pos.y + cs.pos.y + UnScaleByZoom(spr->y_offs, _gui_zoom),
_gui_zoom);
}
}
}

View File

@ -44,7 +44,7 @@ static std::string GetStringForWidget(const Window *w, const NWidgetCore *nwid,
/**
* Scale a RectPadding to GUI zoom level.
* @param r RectPadding at ZOOM_BASE (traditional "normal" interface size).
* @return RectPadding at #ZOOM_LVL_GUI (current interface size).
* @return RectPadding at current interface size.
*/
static inline RectPadding ScaleGUITrad(const RectPadding &r)
{
@ -54,7 +54,7 @@ static inline RectPadding ScaleGUITrad(const RectPadding &r)
/**
* Scale a Dimension to GUI zoom level.
* @param d Dimension at ZOOM_BASE (traditional "normal" interface size).
* @return Dimension at #ZOOM_LVL_GUI (current interface size).
* @return Dimension at current interface size.
*/
static inline Dimension ScaleGUITrad(const Dimension &dim)
{

View File

@ -72,11 +72,11 @@ inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
/**
* Short-hand to apply GUI zoom level.
* @param value Pixel amount at #ZoomLevel::Min (full zoom in).
* @return Pixel amount at #ZOOM_LVL_GUI (current interface size).
* @return Pixel amount at current interface size.
*/
inline int UnScaleGUI(int value)
{
return UnScaleByZoom(value, ZOOM_LVL_GUI);
return UnScaleByZoom(value, _gui_zoom);
}
/**
@ -86,7 +86,7 @@ inline int UnScaleGUI(int value)
*/
inline ZoomLevel ScaleZoomGUI(ZoomLevel value)
{
return std::clamp(value + (ZOOM_LVL_GUI - ZoomLevel::Normal), ZoomLevel::Min, ZoomLevel::Max);
return std::clamp(value + (_gui_zoom - ZoomLevel::Normal), ZoomLevel::Min, ZoomLevel::Max);
}
/**
@ -96,13 +96,13 @@ inline ZoomLevel ScaleZoomGUI(ZoomLevel value)
*/
inline ZoomLevel UnScaleZoomGUI(ZoomLevel value)
{
return std::clamp(value - (ZOOM_LVL_GUI - ZoomLevel::Normal), ZoomLevel::Min, ZoomLevel::Max);
return std::clamp(value - (_gui_zoom - ZoomLevel::Normal), ZoomLevel::Min, ZoomLevel::Max);
}
/**
* Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
* @param value Pixel amount at #ZOOM_BASE (traditional "normal" interface size).
* @return Pixel amount at #ZOOM_LVL_GUI (current interface size).
* @return Pixel amount at current interface size.
*/
inline int ScaleSpriteTrad(int value)
{
@ -112,7 +112,7 @@ inline int ScaleSpriteTrad(int value)
/**
* Scale traditional pixel dimensions to GUI zoom level.
* @param value Pixel amount at #ZOOM_BASE (traditional "normal" interface size).
* @return Pixel amount at #ZOOM_LVL_GUI (current interface size).
* @return Pixel amount at current interface size.
*/
inline int ScaleGUITrad(int value)
{

View File

@ -52,7 +52,6 @@ extern int _gui_scale_cfg;
extern ZoomLevel _gui_zoom;
extern ZoomLevel _font_zoom;
#define ZOOM_LVL_GUI (_gui_zoom)
static const int MIN_INTERFACE_SCALE = 100;
static const int MAX_INTERFACE_SCALE = 500;