- fixed: The alternative HUD's number printing function did not take texture scaling into account when calculating the printing position.

SVN r2947 (trunk)
This commit is contained in:
Christoph Oelckers 2010-10-16 16:21:19 +00:00
parent 8806ec294f
commit 650da24364
2 changed files with 12 additions and 9 deletions

View file

@ -124,16 +124,16 @@ void SetHUDIcon(PClass *cls, FTextureID tex)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void DrawImageToBox(FTexture * tex, int x, int y, int w, int h, int trans=0xc000) static void DrawImageToBox(FTexture * tex, int x, int y, int w, int h, int trans=0xc000)
{ {
float scale1, scale2; double scale1, scale2;
if (tex) if (tex)
{ {
int texwidth=tex->GetWidth(); int texwidth=tex->GetWidth();
int texheight=tex->GetHeight(); int texheight=tex->GetHeight();
if (w<texwidth) scale1=(float)w/texwidth; if (w<texwidth) scale1=(double)w/texwidth;
else scale1=1.0f; else scale1=1.0f;
if (h<texheight) scale2=(float)h/texheight; if (h<texheight) scale2=(double)h/texheight;
else scale2=1.0f; else scale2=1.0f;
if (scale2<scale1) scale1=scale2; if (scale2<scale1) scale1=scale2;
@ -170,11 +170,14 @@ static void DrawHudText(FFont *font, int color, char * text, int x, int y, int t
FTexture *texc = font->GetChar(text[i], &width); FTexture *texc = font->GetChar(text[i], &width);
if (texc != NULL) if (texc != NULL)
{ {
int offset = texc->TopOffset - tex_zero->TopOffset + tex_zero->GetHeight(); double offset = texc->GetScaledTopOffsetDouble()
- tex_zero->GetScaledTopOffsetDouble()
+ tex_zero->GetScaledHeightDouble();
screen->DrawChar(font, color, x, y, text[i], screen->DrawChar(font, color, x, y, text[i],
DTA_KeepRatio, true, DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, trans, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, trans,
DTA_LeftOffset, width/2, DTA_TopOffset, offset, DTA_LeftOffset, width/2, DTA_TopOffsetF, offset,
/*DTA_CenterBottomOffset, 1,*/ TAG_DONE); /*DTA_CenterBottomOffset, 1,*/ TAG_DONE);
} }
x += zerowidth; x += zerowidth;

View file

@ -182,13 +182,13 @@ public:
int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); } int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); }
int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); } int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); }
double GetScaledWidthDouble () { return (Width * 65536.f) / xScale; } double GetScaledWidthDouble () { return (Width * 65536.) / xScale; }
double GetScaledHeightDouble () { return (Height * 65536.f) / yScale; } double GetScaledHeightDouble () { return (Height * 65536.) / yScale; }
int GetScaledLeftOffset () { int foo = (LeftOffset << 17) / xScale; return (foo >> 1) + (foo & 1); } int GetScaledLeftOffset () { int foo = (LeftOffset << 17) / xScale; return (foo >> 1) + (foo & 1); }
int GetScaledTopOffset () { int foo = (TopOffset << 17) / yScale; return (foo >> 1) + (foo & 1); } int GetScaledTopOffset () { int foo = (TopOffset << 17) / yScale; return (foo >> 1) + (foo & 1); }
double GetScaledLeftOffsetDouble() { return (LeftOffset * 65536.f) / xScale; } double GetScaledLeftOffsetDouble() { return (LeftOffset * 65536.) / xScale; }
double GetScaledTopOffsetDouble() { return (TopOffset * 65536.f) / yScale; } double GetScaledTopOffsetDouble() { return (TopOffset * 65536.) / yScale; }
virtual void SetFrontSkyLayer(); virtual void SetFrontSkyLayer();