mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 06:42:08 +00:00
Add CenterText MENUDEF flag
This commit is contained in:
parent
56803317f5
commit
decaf07637
4 changed files with 9 additions and 1 deletions
|
@ -88,6 +88,7 @@ public:
|
|||
EColorRange mFontColor;
|
||||
EColorRange mFontColor2;
|
||||
bool mCenter;
|
||||
bool mCenterText;
|
||||
bool mFromEngine;
|
||||
bool mAnimated;
|
||||
bool mAnimatedTransition;
|
||||
|
|
|
@ -431,6 +431,10 @@ static void DoParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &s
|
|||
{
|
||||
desc->mForceList = true;
|
||||
}
|
||||
else if (sc.Compare("CenterText"))
|
||||
{
|
||||
desc->mCenterText = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// all item classes from which we know that they support sized scaling.
|
||||
|
@ -768,6 +772,7 @@ static void ParseListMenu(FScanner &sc)
|
|||
desc->mWLeft = 0;
|
||||
desc->mWRight = 0;
|
||||
desc->mCenter = false;
|
||||
desc->mCenterText = false;
|
||||
desc->mFromEngine = fileSystem.GetFileContainer(sc.LumpNum) == 0; // flags menu if the definition is from the IWAD.
|
||||
desc->mVirtWidth = -2;
|
||||
desc->mCustomSizeSet = false;
|
||||
|
|
|
@ -55,6 +55,7 @@ class ListMenuDescriptor : MenuDescriptor native
|
|||
native int mFontColor;
|
||||
native int mFontColor2;
|
||||
native bool mCenter;
|
||||
native bool mCenterText;
|
||||
native bool mAnimatedTransition;
|
||||
native bool mAnimated;
|
||||
native bool mDontBlur;
|
||||
|
|
|
@ -161,7 +161,7 @@ class ListMenuItemStaticText : ListMenuItem
|
|||
mText = text;
|
||||
mFont = desc.mFont;
|
||||
mColor = color >= 0? color : desc.mFontColor;
|
||||
mCentered = false;
|
||||
mCentered = desc.mCenterText;
|
||||
}
|
||||
|
||||
void InitDirect(double x, double y, String text, Font font, int color = Font.CR_UNTRANSLATED, bool centered = false)
|
||||
|
@ -294,6 +294,7 @@ class ListMenuItemTextItem : ListMenuItemSelectable
|
|||
override void Draw(bool selected, ListMenuDescriptor desc)
|
||||
{
|
||||
let font = menuDelegate.PickFont(mFont);
|
||||
if (desc.mCenterText) x -= font.StringWidth(mText) / 2;
|
||||
DrawText(desc, font, selected ? mColorSelected : mColor, mXpos, mYpos, mText);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue