Added support for monospacing alignment modes to HUDFont / BaseStatusBar.DrawString (#810)
* - Added support for monospacing alignment modes to HUDFont / BaseStatusBar.DrawString * - added underlying type declaration for EMonospacing * - replaced "#include v_video.h" with a declaration of EMonospacing
This commit is contained in:
parent
4668fa95e3
commit
747906730c
9 changed files with 33 additions and 25 deletions
|
|
@ -1586,8 +1586,10 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, double y, int flags, double Alpha, int translation, int spacing, bool monospaced, int shadowX, int shadowY)
|
||||
void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY)
|
||||
{
|
||||
bool monospaced = monospacing != EMonospacing::Off;
|
||||
|
||||
switch (flags & DI_TEXT_ALIGN)
|
||||
{
|
||||
default:
|
||||
|
|
@ -1671,6 +1673,11 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d
|
|||
rw = c->GetDisplayWidthDouble();
|
||||
rh = c->GetDisplayHeightDouble();
|
||||
|
||||
if (monospacing == EMonospacing::CellCenter)
|
||||
rx += (spacing - rw) / 2;
|
||||
else if (monospacing == EMonospacing::CellRight)
|
||||
rx += (spacing - rw);
|
||||
|
||||
if (!fullscreenOffsets)
|
||||
{
|
||||
StatusbarToRealCoords(rx, ry, rw, rh);
|
||||
|
|
@ -1707,7 +1714,6 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d
|
|||
else
|
||||
x += spacing;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SBar_DrawString(DBaseStatusBar *self, DHUDFont *font, const FString &string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing)
|
||||
|
|
@ -1729,13 +1735,13 @@ void SBar_DrawString(DBaseStatusBar *self, DHUDFont *font, const FString &string
|
|||
auto brk = V_BreakLines(font->mFont, wrapwidth, string, true);
|
||||
for (auto &line : brk)
|
||||
{
|
||||
self->DrawString(font->mFont, line.Text, x, y, flags, alpha, trans, font->mSpacing, font->mMonospaced, font->mShadowX, font->mShadowY);
|
||||
self->DrawString(font->mFont, line.Text, x, y, flags, alpha, trans, font->mSpacing, font->mMonospacing, font->mShadowX, font->mShadowY);
|
||||
y += font->mFont->GetHeight() + linespacing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self->DrawString(font->mFont, string, x, y, flags, alpha, trans, font->mSpacing, font->mMonospaced, font->mShadowX, font->mShadowY);
|
||||
self->DrawString(font->mFont, string, x, y, flags, alpha, trans, font->mSpacing, font->mMonospacing, font->mShadowX, font->mShadowY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue