New GFX functions to draw cenetered sprites
This commit is contained in:
44
src/gfx.cpp
44
src/gfx.cpp
@@ -856,6 +856,50 @@ void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a sprite, centered at x:y, not in a viewport
|
||||||
|
* @param img Image number to draw
|
||||||
|
* @param pal Palette to use.
|
||||||
|
* @param x Left coordinate of image in pixels
|
||||||
|
* @param y Top coordinate of image in pixels
|
||||||
|
* @param sub If available, draw only specified part of the sprite
|
||||||
|
* @param zoom Zoom level of sprite
|
||||||
|
*/
|
||||||
|
void DrawSpriteCentered(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
|
||||||
|
{
|
||||||
|
Dimension size = GetSpriteSize(img, NULL, zoom);
|
||||||
|
DrawSprite(img, pal, x - size.width / 2, y - size.height / 2, sub, zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a sprite, centered in rect, not in a viewport
|
||||||
|
* @param img Image number to draw
|
||||||
|
* @param pal Palette to use.
|
||||||
|
* @param left Left coordinate of image bounding box in pixels
|
||||||
|
* @param top Top coordinate of image bounding box in pixels
|
||||||
|
* @param right Right coordinate of image bounding box in pixels
|
||||||
|
* @param bottom Bottom coordinate of image bounding box in pixels
|
||||||
|
* @param sub If available, draw only specified part of the sprite
|
||||||
|
* @param zoom Zoom level of sprite
|
||||||
|
*/
|
||||||
|
void DrawSpriteCenteredInRect(SpriteID img, PaletteID pal, int left, int top, int right, int bottom, const SubSprite *sub, ZoomLevel zoom)
|
||||||
|
{
|
||||||
|
DrawSpriteCentered(img, pal, (left + right) / 2, (top + bottom) / 2, sub, zoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a sprite, centered in rect, not in a viewport
|
||||||
|
* @param img Image number to draw
|
||||||
|
* @param pal Palette to use.
|
||||||
|
* @param rect Image bounding box in pixels
|
||||||
|
* @param sub If available, draw only specified part of the sprite
|
||||||
|
* @param zoom Zoom level of sprite
|
||||||
|
*/
|
||||||
|
void DrawSpriteCenteredInRect(SpriteID img, PaletteID pal, const Rect &rect, const SubSprite *sub, ZoomLevel zoom)
|
||||||
|
{
|
||||||
|
DrawSpriteCenteredInRect(img, pal, rect.left, rect.top, rect.right, rect.bottom, sub, zoom);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The code for setting up the blitter mode and sprite information before finally drawing the sprite.
|
* The code for setting up the blitter mode and sprite information before finally drawing the sprite.
|
||||||
* @param sprite The sprite to draw.
|
* @param sprite The sprite to draw.
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo);
|
|||||||
Dimension GetSpriteSize(SpriteID sprid, Point *offset = NULL, ZoomLevel zoom = ZOOM_LVL_GUI);
|
Dimension GetSpriteSize(SpriteID sprid, Point *offset = NULL, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||||
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = NULL);
|
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = NULL);
|
||||||
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = NULL, ZoomLevel zoom = ZOOM_LVL_GUI);
|
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = NULL, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||||
|
void DrawSpriteCentered(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = NULL, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||||
|
void DrawSpriteCenteredInRect(SpriteID img, PaletteID pal, int left, int top, int right, int bottom, const SubSprite *sub = NULL, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||||
|
void DrawSpriteCenteredInRect(SpriteID img, PaletteID pal, const Rect &r, const SubSprite *sub = NULL, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||||
|
|
||||||
/** How to align the to-be drawn text. */
|
/** How to align the to-be drawn text. */
|
||||||
enum StringAlignment {
|
enum StringAlignment {
|
||||||
|
|||||||
Reference in New Issue
Block a user