mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-31 19:33:34 +00:00
(svn r26941) -Codechange: Make NewGRF sprite aligner work with GUI size.
This commit is contained in:
parent
8385e6268e
commit
1273ca8e8d
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user