summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-02-28 20:09:49 +0000
committerfrosch <frosch@openttd.org>2015-02-28 20:09:49 +0000
commita4756c477d5203bf898cd6509af8b3cdb325e4f0 (patch)
treec6dcc68584c8d2519b6abfe53c8e35d616caa6c5
parent70e575e7d7e5762c65c03fd0ac80deed846fd4c2 (diff)
downloadopenttd-a4756c477d5203bf898cd6509af8b3cdb325e4f0.tar.xz
(svn r27173) -Fix [FS#6237] (r27134): Use the regular clipping functions in the sprite aligner instead of some magic.
-rw-r--r--src/newgrf_debug_gui.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp
index 4831b691a..e757379c1 100644
--- a/src/newgrf_debug_gui.cpp
+++ b/src/newgrf_debug_gui.cpp
@@ -856,20 +856,20 @@ struct SpriteAlignerWindow : Window {
case WID_SA_SPRITE: {
/* Center the sprite ourselves */
const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
- int width = r.right - r.left + 1;
- int height = r.bottom - r.top + 1;
- int x = r.left - UnScaleGUI(spr->x_offs) + (width - UnScaleGUI(spr->width) ) / 2;
- int y = r.top - UnScaleGUI(spr->y_offs) + (height - UnScaleGUI(spr->height)) / 2;
-
- /* And draw only the part within the sprite area */
- SubSprite subspr = {
- spr->x_offs + (spr->width - UnScaleGUI(width) ) / 2 + 1,
- spr->y_offs + (spr->height - UnScaleGUI(height)) / 2 + 1,
- spr->x_offs + (spr->width + UnScaleGUI(width) ) / 2 - 1,
- spr->y_offs + (spr->height + UnScaleGUI(height)) / 2 - 1,
- };
-
- DrawSprite(this->current_sprite, PAL_NONE, x, y, &subspr, ZOOM_LVL_GUI);
+ int width = r.right - r.left + 1 - WD_BEVEL_LEFT - WD_BEVEL_RIGHT;
+ int height = r.bottom - r.top + 1 - WD_BEVEL_TOP - WD_BEVEL_BOTTOM;
+ int x = -UnScaleGUI(spr->x_offs) + (width - UnScaleGUI(spr->width) ) / 2;
+ int y = -UnScaleGUI(spr->y_offs) + (height - UnScaleGUI(spr->height)) / 2;
+
+ DrawPixelInfo new_dpi;
+ if (!FillDrawPixelInfo(&new_dpi, r.left + WD_BEVEL_LEFT, r.top + WD_BEVEL_TOP, width, height)) break;
+ DrawPixelInfo *old_dpi = _cur_dpi;
+ _cur_dpi = &new_dpi;
+
+ DrawSprite(this->current_sprite, PAL_NONE, x, y, NULL, ZOOM_LVL_GUI);
+
+ _cur_dpi = old_dpi;
+
break;
}