Add CenterText MENUDEF flag

This commit is contained in:
jekyllgrim 2023-10-02 02:01:06 +03:00 committed by Rachael Alexanderson
parent 56803317f5
commit decaf07637
4 changed files with 9 additions and 1 deletions

View file

@ -88,6 +88,7 @@ public:
EColorRange mFontColor; EColorRange mFontColor;
EColorRange mFontColor2; EColorRange mFontColor2;
bool mCenter; bool mCenter;
bool mCenterText;
bool mFromEngine; bool mFromEngine;
bool mAnimated; bool mAnimated;
bool mAnimatedTransition; bool mAnimatedTransition;

View file

@ -431,6 +431,10 @@ static void DoParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &s
{ {
desc->mForceList = true; desc->mForceList = true;
} }
else if (sc.Compare("CenterText"))
{
desc->mCenterText = true;
}
else else
{ {
// all item classes from which we know that they support sized scaling. // 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->mWLeft = 0;
desc->mWRight = 0; desc->mWRight = 0;
desc->mCenter = false; desc->mCenter = false;
desc->mCenterText = false;
desc->mFromEngine = fileSystem.GetFileContainer(sc.LumpNum) == 0; // flags menu if the definition is from the IWAD. desc->mFromEngine = fileSystem.GetFileContainer(sc.LumpNum) == 0; // flags menu if the definition is from the IWAD.
desc->mVirtWidth = -2; desc->mVirtWidth = -2;
desc->mCustomSizeSet = false; desc->mCustomSizeSet = false;

View file

@ -55,6 +55,7 @@ class ListMenuDescriptor : MenuDescriptor native
native int mFontColor; native int mFontColor;
native int mFontColor2; native int mFontColor2;
native bool mCenter; native bool mCenter;
native bool mCenterText;
native bool mAnimatedTransition; native bool mAnimatedTransition;
native bool mAnimated; native bool mAnimated;
native bool mDontBlur; native bool mDontBlur;

View file

@ -161,7 +161,7 @@ class ListMenuItemStaticText : ListMenuItem
mText = text; mText = text;
mFont = desc.mFont; mFont = desc.mFont;
mColor = color >= 0? color : desc.mFontColor; 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) 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) override void Draw(bool selected, ListMenuDescriptor desc)
{ {
let font = menuDelegate.PickFont(mFont); let font = menuDelegate.PickFont(mFont);
if (desc.mCenterText) x -= font.StringWidth(mText) / 2;
DrawText(desc, font, selected ? mColorSelected : mColor, mXpos, mYpos, mText); DrawText(desc, font, selected ? mColorSelected : mColor, mXpos, mYpos, mText);
} }