summaryrefslogtreecommitdiff
path: root/src/gfx.cpp
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2021-04-22 01:17:30 +0100
committerPeterN <peter@fuzzle.org>2021-04-30 17:08:15 +0100
commit2efa390a7d2091b2c2cef4aa7f986fdcb24eac2a (patch)
tree7021cf6b4568e76755d84b5d371779811664d02b /src/gfx.cpp
parent4f93dd95e4251e3227a55ee125838cefce173ef3 (diff)
downloadopenttd-2efa390a7d2091b2c2cef4aa7f986fdcb24eac2a.tar.xz
Codechange: Simplify calling of DrawCharCentered()
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r--src/gfx.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index d540f4dfe..d3c730be1 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -891,15 +891,17 @@ const char *GetCharAtPosition(const char *str, int x, FontSize start_fontsize)
/**
* Draw single character horizontally centered around (x,y)
* @param c Character (glyph) to draw
- * @param x X position to draw character
- * @param y Y position to draw character
+ * @param r Rectangle to draw character within
* @param colour Colour to use, for details see _string_colourmap in
* table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
*/
-void DrawCharCentered(WChar c, int x, int y, TextColour colour)
+void DrawCharCentered(WChar c, const Rect &r, TextColour colour)
{
SetColourRemap(colour);
- GfxMainBlitter(GetGlyph(FS_NORMAL, c), x - GetCharacterWidth(FS_NORMAL, c) / 2, y, BM_COLOUR_REMAP);
+ GfxMainBlitter(GetGlyph(FS_NORMAL, c),
+ CenterBounds(r.left, r.right, GetCharacterWidth(FS_NORMAL, c)),
+ CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL),
+ BM_COLOUR_REMAP);
}
/**