mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-20 18:42:17 +00:00
- added monospacing support to Screen.DrawText and its native counterparts.
# Conflicts: # src/g_statusbar/shared_sbar.cpp # src/v_draw.cpp # src/v_video.h Without the HUD modifications. (drfrag) # Conflicts: # src/v_draw.cpp # wadsrc/static/zscript/base.zs
This commit is contained in:
parent
2887bc6afc
commit
a6491c71b5
5 changed files with 52 additions and 1 deletions
|
@ -524,6 +524,8 @@ bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t t
|
|||
parms->cellx = parms->celly = 0;
|
||||
parms->maxstrlen = INT_MAX;
|
||||
parms->virtBottom = false;
|
||||
parms->monospace = EMonospacing::MOff;
|
||||
parms->spacing = 0;
|
||||
|
||||
// Parse the tag list for attributes. (For floating point attributes,
|
||||
// consider that the C ABI dictates that all floats be promoted to
|
||||
|
@ -856,6 +858,14 @@ bool DCanvas::ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t t
|
|||
parms->celly = ListGetInt(tags);
|
||||
break;
|
||||
|
||||
case DTA_Monospace:
|
||||
parms->monospace = ListGetInt(tags);
|
||||
break;
|
||||
|
||||
case DTA_Spacing:
|
||||
parms->spacing = ListGetInt(tags);
|
||||
break;
|
||||
|
||||
}
|
||||
tag = ListGetInt(tags);
|
||||
}
|
||||
|
|
|
@ -169,6 +169,10 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c
|
|||
cx = x;
|
||||
cy = y;
|
||||
|
||||
if (parms.monospace == EMonospacing::CellCenter)
|
||||
cx += parms.spacing / 2;
|
||||
else if (parms.monospace == EMonospacing::CellRight)
|
||||
cx += parms.spacing;
|
||||
|
||||
while ((const char *)ch - string < parms.maxstrlen)
|
||||
{
|
||||
|
@ -204,9 +208,24 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c
|
|||
parms.destwidth = parms.cellx;
|
||||
parms.destheight = parms.celly;
|
||||
}
|
||||
if (parms.monospace == EMonospacing::CellLeft)
|
||||
parms.left = 0;
|
||||
else if (parms.monospace == EMonospacing::CellCenter)
|
||||
parms.left = w / 2.;
|
||||
else if (parms.monospace == EMonospacing::CellRight)
|
||||
parms.left = w;
|
||||
|
||||
DrawTextureParms(pic, parms);
|
||||
}
|
||||
cx += (w + kerning) * parms.scalex;
|
||||
if (parms.monospace == EMonospacing::MOff)
|
||||
{
|
||||
cx += (w + kerning + parms.spacing) * parms.scalex;
|
||||
}
|
||||
else
|
||||
{
|
||||
cx += (parms.spacing) * parms.scalex;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,16 @@ enum
|
|||
// New additions.
|
||||
DTA_Color,
|
||||
DTA_LegacyRenderStyle, // takes an old-style STYLE_* constant instead of an FRenderStyle
|
||||
DTA_Spacing, // Strings only: Additional spacing between characters
|
||||
DTA_Monospace, // Fonts only: Use a fixed distance between characters.
|
||||
};
|
||||
|
||||
enum EMonospacing
|
||||
{
|
||||
MOff = 0,
|
||||
CellLeft = 1,
|
||||
CellCenter = 2,
|
||||
CellRight = 3
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -179,6 +189,8 @@ struct DrawParms
|
|||
struct FColormapStyle *colormapstyle;
|
||||
int scalex, scaley;
|
||||
int cellx, celly;
|
||||
int monospace;
|
||||
int spacing;
|
||||
int maxstrlen;
|
||||
bool fortext;
|
||||
bool virtBottom;
|
||||
|
|
|
@ -168,6 +168,8 @@ enum DrawTextureTags
|
|||
|
||||
DTA_Color,
|
||||
DTA_LegacyRenderStyle, // takes an old-style STYLE_* constant instead of an FRenderStyle
|
||||
DTA_Spacing, // Strings only: Additional spacing between characters
|
||||
DTA_Monospace, // Strings only: Use a fixed distance between characters.
|
||||
};
|
||||
|
||||
class Shape2D : Object native
|
||||
|
|
|
@ -1344,3 +1344,11 @@ enum ECompatFlags
|
|||
COMPATF2_EXPLODE2 = 1 << 9, // Use original explosion code throughout.
|
||||
COMPATF2_RAILING = 1 << 10, // Bugged Strife railings.
|
||||
};
|
||||
|
||||
enum EMonospacing
|
||||
{
|
||||
Mono_Off = 0,
|
||||
Mono_CellLeft = 1,
|
||||
Mono_CellCenter = 2,
|
||||
Mono_CellRight = 3
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue