mirror of https://github.com/OpenTTD/OpenTTD
Before variable-scaling, the padding was always 1x1 pixel. This was changed to be scaled, except using the wrong dimension of 2x1 pixels instead of 1x1 pixel.pull/10276/head
parent
c179c10048
commit
f6e7e44169
|
@ -1301,7 +1301,7 @@ void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const Vie
|
||||||
int right = left + dpi->width;
|
int right = left + dpi->width;
|
||||||
int bottom = top + dpi->height;
|
int bottom = top + dpi->height;
|
||||||
|
|
||||||
int sign_height = ScaleByZoom(WidgetDimensions::scaled.framerect.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.framerect.bottom, dpi->zoom);
|
int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.bottom, dpi->zoom);
|
||||||
int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, dpi->zoom);
|
int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, dpi->zoom);
|
||||||
|
|
||||||
if (bottom < sign->top ||
|
if (bottom < sign->top ||
|
||||||
|
@ -1329,8 +1329,8 @@ static Rect ExpandRectWithViewportSignMargins(Rect r, ZoomLevel zoom)
|
||||||
/* Pessimistically always use normal font, but also assume small font is never larger in either dimension */
|
/* Pessimistically always use normal font, but also assume small font is never larger in either dimension */
|
||||||
const int fh = FONT_HEIGHT_NORMAL;
|
const int fh = FONT_HEIGHT_NORMAL;
|
||||||
const int max_tw = _viewport_sign_maxwidth / 2 + 1;
|
const int max_tw = _viewport_sign_maxwidth / 2 + 1;
|
||||||
const int expand_y = ScaleByZoom(WidgetDimensions::scaled.framerect.top + fh + WidgetDimensions::scaled.framerect.bottom, zoom);
|
const int expand_y = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + fh + WidgetDimensions::scaled.fullbevel.bottom, zoom);
|
||||||
const int expand_x = ScaleByZoom(WidgetDimensions::scaled.framerect.left + max_tw + WidgetDimensions::scaled.framerect.right, zoom);
|
const int expand_x = ScaleByZoom(WidgetDimensions::scaled.fullbevel.left + max_tw + WidgetDimensions::scaled.fullbevel.right, zoom);
|
||||||
|
|
||||||
r.left -= expand_x;
|
r.left -= expand_x;
|
||||||
r.right += expand_x;
|
r.right += expand_x;
|
||||||
|
@ -1451,14 +1451,14 @@ void ViewportSign::UpdatePosition(int center, int top, StringID str, StringID st
|
||||||
char buffer[DRAW_STRING_BUFFER];
|
char buffer[DRAW_STRING_BUFFER];
|
||||||
|
|
||||||
GetString(buffer, str, lastof(buffer));
|
GetString(buffer, str, lastof(buffer));
|
||||||
this->width_normal = WidgetDimensions::scaled.framerect.left + Align(GetStringBoundingBox(buffer).width, 2) + WidgetDimensions::scaled.framerect.right;
|
this->width_normal = WidgetDimensions::scaled.fullbevel.left + Align(GetStringBoundingBox(buffer).width, 2) + WidgetDimensions::scaled.fullbevel.right;
|
||||||
this->center = center;
|
this->center = center;
|
||||||
|
|
||||||
/* zoomed out version */
|
/* zoomed out version */
|
||||||
if (str_small != STR_NULL) {
|
if (str_small != STR_NULL) {
|
||||||
GetString(buffer, str_small, lastof(buffer));
|
GetString(buffer, str_small, lastof(buffer));
|
||||||
}
|
}
|
||||||
this->width_small = WidgetDimensions::scaled.framerect.left + Align(GetStringBoundingBox(buffer, FS_SMALL).width, 2) + WidgetDimensions::scaled.framerect.right;
|
this->width_small = WidgetDimensions::scaled.fullbevel.left + Align(GetStringBoundingBox(buffer, FS_SMALL).width, 2) + WidgetDimensions::scaled.fullbevel.right;
|
||||||
|
|
||||||
this->MarkDirty();
|
this->MarkDirty();
|
||||||
}
|
}
|
||||||
|
@ -1478,7 +1478,7 @@ void ViewportSign::MarkDirty(ZoomLevel maxzoom) const
|
||||||
zoomlevels[zoom].left = this->center - ScaleByZoom(this->width_normal / 2 + 1, zoom);
|
zoomlevels[zoom].left = this->center - ScaleByZoom(this->width_normal / 2 + 1, zoom);
|
||||||
zoomlevels[zoom].top = this->top - ScaleByZoom(1, zoom);
|
zoomlevels[zoom].top = this->top - ScaleByZoom(1, zoom);
|
||||||
zoomlevels[zoom].right = this->center + ScaleByZoom(this->width_normal / 2 + 1, zoom);
|
zoomlevels[zoom].right = this->center + ScaleByZoom(this->width_normal / 2 + 1, zoom);
|
||||||
zoomlevels[zoom].bottom = this->top + ScaleByZoom(WidgetDimensions::scaled.framerect.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.framerect.bottom + 1, zoom);
|
zoomlevels[zoom].bottom = this->top + ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.bottom + 1, zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const Window *w : Window::Iterate()) {
|
for (const Window *w : Window::Iterate()) {
|
||||||
|
@ -1688,7 +1688,7 @@ static void ViewportDrawStrings(ZoomLevel zoom, const StringSpriteToDrawVector *
|
||||||
int w = GB(ss.width, 0, 15);
|
int w = GB(ss.width, 0, 15);
|
||||||
int x = UnScaleByZoom(ss.x, zoom);
|
int x = UnScaleByZoom(ss.x, zoom);
|
||||||
int y = UnScaleByZoom(ss.y, zoom);
|
int y = UnScaleByZoom(ss.y, zoom);
|
||||||
int h = WidgetDimensions::scaled.framerect.top + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.framerect.bottom;
|
int h = WidgetDimensions::scaled.fullbevel.top + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom;
|
||||||
|
|
||||||
SetDParam(0, ss.params[0]);
|
SetDParam(0, ss.params[0]);
|
||||||
SetDParam(1, ss.params[1]);
|
SetDParam(1, ss.params[1]);
|
||||||
|
@ -1712,7 +1712,7 @@ static void ViewportDrawStrings(ZoomLevel zoom, const StringSpriteToDrawVector *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawString(x + WidgetDimensions::scaled.framerect.left, x + w - 1 - WidgetDimensions::scaled.framerect.right, y + WidgetDimensions::scaled.framerect.top, ss.string, colour, SA_HOR_CENTER);
|
DrawString(x + WidgetDimensions::scaled.fullbevel.left, x + w - 1 - WidgetDimensions::scaled.fullbevel.right, y + WidgetDimensions::scaled.fullbevel.top, ss.string, colour, SA_HOR_CENTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2131,7 +2131,7 @@ static bool CheckClickOnViewportSign(const Viewport *vp, int x, int y, const Vie
|
||||||
{
|
{
|
||||||
bool small = (vp->zoom >= ZOOM_LVL_OUT_16X);
|
bool small = (vp->zoom >= ZOOM_LVL_OUT_16X);
|
||||||
int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, vp->zoom);
|
int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, vp->zoom);
|
||||||
int sign_height = ScaleByZoom(WidgetDimensions::scaled.framerect.top + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.framerect.bottom, vp->zoom);
|
int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom, vp->zoom);
|
||||||
|
|
||||||
return y >= sign->top && y < sign->top + sign_height &&
|
return y >= sign->top && y < sign->top + sign_height &&
|
||||||
x >= sign->center - sign_half_width && x < sign->center + sign_half_width;
|
x >= sign->center - sign_half_width && x < sign->center + sign_half_width;
|
||||||
|
|
Loading…
Reference in New Issue