mirror of https://github.com/OpenTTD/OpenTTD
(svn r18246) -Codechange: Make signs and station/town names big font aware.
parent
ff5a1f4461
commit
8e85bb82e9
|
@ -1080,24 +1080,18 @@ static void ViewportAddString(const DrawPixelInfo *dpi, const ViewportSign *sign
|
||||||
int right = left + dpi->width;
|
int right = left + dpi->width;
|
||||||
int bottom = top + dpi->height;
|
int bottom = top + dpi->height;
|
||||||
|
|
||||||
switch (dpi->zoom) {
|
int sign_height = FONT_HEIGHT_NORMAL + 2;
|
||||||
case ZOOM_LVL_NORMAL:
|
|
||||||
if (bottom > sign->top &&
|
|
||||||
top < sign->top + 12 &&
|
|
||||||
right > sign->left &&
|
|
||||||
left < sign->left + sign->width_normal) {
|
|
||||||
AddStringToDraw(sign->left + 1, sign->top + 1, string_normal, params_1, params_2, colour, colour != 0 ? sign->width_normal : 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
switch (dpi->zoom) {
|
||||||
case ZOOM_LVL_OUT_2X:
|
case ZOOM_LVL_OUT_2X:
|
||||||
right += 2;
|
right += 2;
|
||||||
bottom += 2;
|
bottom += 2;
|
||||||
|
/* FALL THROUGH */
|
||||||
|
case ZOOM_LVL_NORMAL:
|
||||||
if (bottom > sign->top &&
|
if (bottom > sign->top &&
|
||||||
top < sign->top + 24 &&
|
top < sign->top + ScaleByZoom(sign_height, dpi->zoom) &&
|
||||||
right > sign->left &&
|
right > sign->left &&
|
||||||
left < sign->left + sign->width_normal * 2) {
|
left < sign->left + ScaleByZoom(sign->width_normal, dpi->zoom)) {
|
||||||
AddStringToDraw(sign->left + 1, sign->top + 1, string_normal, params_1, params_2, colour, colour != 0 ? sign->width_normal : 0);
|
AddStringToDraw(sign->left + 1, sign->top + 1, string_normal, params_1, params_2, colour, colour != 0 ? sign->width_normal : 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1108,7 +1102,7 @@ static void ViewportAddString(const DrawPixelInfo *dpi, const ViewportSign *sign
|
||||||
bottom += ScaleByZoom(1, dpi->zoom) + 1;
|
bottom += ScaleByZoom(1, dpi->zoom) + 1;
|
||||||
|
|
||||||
if (bottom > sign->top &&
|
if (bottom > sign->top &&
|
||||||
top < sign->top + ScaleByZoom(12, dpi->zoom) &&
|
top < sign->top + ScaleByZoom(sign_height, dpi->zoom) &&
|
||||||
right > sign->left &&
|
right > sign->left &&
|
||||||
left < sign->left + ScaleByZoom(sign->width_small, dpi->zoom)) {
|
left < sign->left + ScaleByZoom(sign->width_small, dpi->zoom)) {
|
||||||
int shadow_offset = 0;
|
int shadow_offset = 0;
|
||||||
|
@ -1213,7 +1207,7 @@ void ViewportSign::MarkDirty() const
|
||||||
this->left - 6,
|
this->left - 6,
|
||||||
this->top - 3,
|
this->top - 3,
|
||||||
this->left + ScaleByZoom(this->width_normal + 12, ZOOM_LVL_MAX),
|
this->left + ScaleByZoom(this->width_normal + 12, ZOOM_LVL_MAX),
|
||||||
this->top + ScaleByZoom(12, ZOOM_LVL_MAX));
|
this->top + ScaleByZoom(FONT_HEIGHT_NORMAL + 2, ZOOM_LVL_MAX));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ViewportDrawTileSprites(const TileSpriteToDrawVector *tstdv)
|
static void ViewportDrawTileSprites(const TileSpriteToDrawVector *tstdv)
|
||||||
|
@ -1728,35 +1722,16 @@ void SetSelectionRed(bool b)
|
||||||
*/
|
*/
|
||||||
static bool CheckClickOnViewportSign(const ViewPort *vp, int x, int y, const ViewportSign *sign)
|
static bool CheckClickOnViewportSign(const ViewPort *vp, int x, int y, const ViewportSign *sign)
|
||||||
{
|
{
|
||||||
switch (vp->zoom) {
|
int sign_width = (vp->zoom >= ZOOM_LVL_OUT_4X ? sign->width_small : sign->width_normal);
|
||||||
case ZOOM_LVL_NORMAL:
|
int sign_height = FONT_HEIGHT_NORMAL + 2;
|
||||||
x = x - vp->left + vp->virtual_left;
|
|
||||||
y = y - vp->top + vp->virtual_top;
|
|
||||||
return (y >= sign->top &&
|
|
||||||
y < sign->top + 12 &&
|
|
||||||
x >= sign->left &&
|
|
||||||
x < sign->left + sign->width_normal);
|
|
||||||
|
|
||||||
case ZOOM_LVL_OUT_2X:
|
|
||||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
|
||||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
|
||||||
return (y >= sign->top &&
|
|
||||||
y < sign->top + 24 &&
|
|
||||||
x >= sign->left &&
|
|
||||||
x < sign->left + sign->width_normal * 2);
|
|
||||||
|
|
||||||
case ZOOM_LVL_OUT_4X:
|
|
||||||
case ZOOM_LVL_OUT_8X:
|
|
||||||
x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left;
|
x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left;
|
||||||
y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top;
|
y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top;
|
||||||
|
|
||||||
return (y >= sign->top &&
|
return (y >= sign->top &&
|
||||||
y < sign->top + ScaleByZoom(12, vp->zoom) &&
|
y < sign->top + ScaleByZoom(sign_height, vp->zoom) &&
|
||||||
x >= sign->left &&
|
x >= sign->left &&
|
||||||
x < sign->left + ScaleByZoom(sign->width_small, vp->zoom));
|
x < sign->left + ScaleByZoom(sign_width, vp->zoom));
|
||||||
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
|
static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
|
||||||
|
|
Loading…
Reference in New Issue