summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-11-22 20:56:39 +0000
committerfrosch <frosch@openttd.org>2009-11-22 20:56:39 +0000
commit8e85bb82e9eacf5a34ef6b5db5fd98c2e3ca787d (patch)
treef2f83e071ef10bed062161c7df3ec7f36e229142 /src
parentff5a1f446120a2490de2fdd39cfa2850eeadb143 (diff)
downloadopenttd-8e85bb82e9eacf5a34ef6b5db5fd98c2e3ca787d.tar.xz
(svn r18246) -Codechange: Make signs and station/town names big font aware.
Diffstat (limited to 'src')
-rw-r--r--src/viewport.cpp57
1 files changed, 16 insertions, 41 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 866a3d502..86bb24636 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1080,24 +1080,18 @@ static void ViewportAddString(const DrawPixelInfo *dpi, const ViewportSign *sign
int right = left + dpi->width;
int bottom = top + dpi->height;
- switch (dpi->zoom) {
- 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;
+ int sign_height = FONT_HEIGHT_NORMAL + 2;
+ switch (dpi->zoom) {
case ZOOM_LVL_OUT_2X:
right += 2;
bottom += 2;
-
+ /* FALL THROUGH */
+ case ZOOM_LVL_NORMAL:
if (bottom > sign->top &&
- top < sign->top + 24 &&
+ top < sign->top + ScaleByZoom(sign_height, dpi->zoom) &&
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);
}
break;
@@ -1108,7 +1102,7 @@ static void ViewportAddString(const DrawPixelInfo *dpi, const ViewportSign *sign
bottom += ScaleByZoom(1, dpi->zoom) + 1;
if (bottom > sign->top &&
- top < sign->top + ScaleByZoom(12, dpi->zoom) &&
+ top < sign->top + ScaleByZoom(sign_height, dpi->zoom) &&
right > sign->left &&
left < sign->left + ScaleByZoom(sign->width_small, dpi->zoom)) {
int shadow_offset = 0;
@@ -1213,7 +1207,7 @@ void ViewportSign::MarkDirty() const
this->left - 6,
this->top - 3,
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)
@@ -1728,35 +1722,16 @@ void SetSelectionRed(bool b)
*/
static bool CheckClickOnViewportSign(const ViewPort *vp, int x, int y, const ViewportSign *sign)
{
- switch (vp->zoom) {
- case ZOOM_LVL_NORMAL:
- 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);
+ int sign_width = (vp->zoom >= ZOOM_LVL_OUT_4X ? sign->width_small : sign->width_normal);
+ int sign_height = FONT_HEIGHT_NORMAL + 2;
- 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);
+ 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;
- 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;
- y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top;
-
- return (y >= sign->top &&
- y < sign->top + ScaleByZoom(12, vp->zoom) &&
- x >= sign->left &&
- x < sign->left + ScaleByZoom(sign->width_small, vp->zoom));
-
- default: NOT_REACHED();
- }
+ return (y >= sign->top &&
+ y < sign->top + ScaleByZoom(sign_height, vp->zoom) &&
+ x >= sign->left &&
+ x < sign->left + ScaleByZoom(sign_width, vp->zoom));
}
static bool CheckClickOnTown(const ViewPort *vp, int x, int y)