Changeset - r21796:7fcd1d326f73
[Not reviewed]
master
0 1 0
peter1138 - 10 years ago 2014-09-30 11:29:23
peter1138@openttd.org
(svn r26941) -Codechange: Make NewGRF sprite aligner work with GUI size.
1 file changed with 7 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -19,6 +19,7 @@
 
#include "strings_func.h"
 
#include "textbuf_gui.h"
 
#include "vehicle_gui.h"
 
#include "zoom_func.h"
 

	
 
#include "engine_base.h"
 
#include "industry.h"
 
@@ -857,15 +858,15 @@ struct SpriteAlignerWindow : Window {
 
				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 / 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;
 
				int x = r.left - UnScaleByZoom(spr->x_offs, ZOOM_LVL_GUI) + (width  - UnScaleByZoom(spr->width, ZOOM_LVL_GUI)) / 2;
 
				int y = r.top  - UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI) + (height - UnScaleByZoom(spr->height, ZOOM_LVL_GUI)) / 2;
 

	
 
				/* And draw only the part within the sprite area */
 
				SubSprite subspr = {
 
					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,
 
					spr->x_offs + (spr->width  - ScaleByZoom(width,  ZOOM_LVL_GUI)) / 2 + 1,
 
					spr->y_offs + (spr->height - ScaleByZoom(height, ZOOM_LVL_GUI)) / 2 + 1,
 
					spr->x_offs + (spr->width  + ScaleByZoom(width,  ZOOM_LVL_GUI)) / 2 - 1,
 
					spr->y_offs + (spr->height + ScaleByZoom(height, ZOOM_LVL_GUI)) / 2 - 1,
 
				};
 

	
 
				DrawSprite(this->current_sprite, PAL_NONE, x, y, &subspr, ZOOM_LVL_GUI);
0 comments (0 inline, 0 general)