changeset 18574:55442966daa9 draft

(svn r23419) -Fix [FS#4864] (r23316): the sprite aligner was broken as it didn't scale properly to 'GUI' scale
author rubidium <rubidium@openttd.org>
date Sun, 04 Dec 2011 09:15:13 +0000
parents 36da76b1633f
children 49d90fd3afe3
files src/newgrf_debug_gui.cpp
diffstat 1 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf_debug_gui.cpp
+++ b/src/newgrf_debug_gui.cpp
@@ -685,8 +685,8 @@
 
 			case SAW_OFFSETS: {
 				const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
-				SetDParam(0, spr->x_offs);
-				SetDParam(1, spr->y_offs);
+				SetDParam(0, spr->x_offs / ZOOM_LVL_BASE);
+				SetDParam(1, spr->y_offs / ZOOM_LVL_BASE);
 				break;
 			}
 
@@ -714,18 +714,18 @@
 				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 - spr->x_offs + (width  - spr->width) / 2;
-				int y = r.top  - spr->y_offs + (height - spr->height) / 2;
+				int x = r.left - spr->x_offs / ZOOM_LVL_BASE + (width  - spr->width / ZOOM_LVL_BASE) / 2;
+				int y = r.top  - spr->y_offs / ZOOM_LVL_BASE + (height - spr->height / ZOOM_LVL_BASE) / 2;
 
 				/* And draw only the part within the sprite area */
 				SubSprite subspr = {
-					spr->x_offs + (spr->width  - width)  / 2 + 1,
-					spr->y_offs + (spr->height - height) / 2 + 1,
-					spr->x_offs + (spr->width  + width)  / 2 - 1,
-					spr->y_offs + (spr->height + height) / 2 - 1,
+					spr->x_offs + (spr->width  - width  * ZOOM_LVL_BASE) / 2 + 1,
+					spr->y_offs + (spr->height - height * ZOOM_LVL_BASE) / 2 + 1,
+					spr->x_offs + (spr->width  + width  * ZOOM_LVL_BASE) / 2 - 1,
+					spr->y_offs + (spr->height + height * ZOOM_LVL_BASE) / 2 - 1,
 				};
 
-				DrawSprite(this->current_sprite, PAL_NONE, x, y, &subspr, ZOOM_LVL_NORMAL);
+				DrawSprite(this->current_sprite, PAL_NONE, x, y, &subspr, ZOOM_LVL_GUI);
 				break;
 			}
 
@@ -806,10 +806,10 @@
 				 */
 				Sprite *spr = const_cast<Sprite *>(GetSprite(this->current_sprite, ST_NORMAL));
 				switch (widget) {
-					case SAW_UP:    spr->y_offs--; break;
-					case SAW_DOWN:  spr->y_offs++; break;
-					case SAW_LEFT:  spr->x_offs--; break;
-					case SAW_RIGHT: spr->x_offs++; break;
+					case SAW_UP:    spr->y_offs -= ZOOM_LVL_BASE; break;
+					case SAW_DOWN:  spr->y_offs += ZOOM_LVL_BASE; break;
+					case SAW_LEFT:  spr->x_offs -= ZOOM_LVL_BASE; break;
+					case SAW_RIGHT: spr->x_offs += ZOOM_LVL_BASE; break;
 				}
 				/* Ofcourse, we need to redraw the sprite, but where is it used?
 				 * Everywhere is a safe bet. */