Skip to content

Commit

Permalink
Added animation support for OptionMenus
Browse files Browse the repository at this point in the history
Adds Animated and AnimatedTransition MENUDEF instructions for OptionMenus. Added DontDim and DontBlur MENUDEF instructions for all menus.
  • Loading branch information
Boondorl authored and coelckers committed Nov 24, 2022
1 parent b002d5b commit f322792
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/common/menu/menu.cpp
Expand Up @@ -1033,6 +1033,8 @@ DEFINE_FIELD(DListMenuDescriptor, mFontColor2)
DEFINE_FIELD(DListMenuDescriptor, mAnimatedTransition)
DEFINE_FIELD(DListMenuDescriptor, mAnimated)
DEFINE_FIELD(DListMenuDescriptor, mCenter)
DEFINE_FIELD(DListMenuDescriptor, mDontDim)
DEFINE_FIELD(DListMenuDescriptor, mDontBlur)
DEFINE_FIELD(DListMenuDescriptor, mVirtWidth)
DEFINE_FIELD(DListMenuDescriptor, mVirtHeight)

Expand All @@ -1045,6 +1047,9 @@ DEFINE_FIELD(DOptionMenuDescriptor, mScrollPos)
DEFINE_FIELD(DOptionMenuDescriptor, mIndent)
DEFINE_FIELD(DOptionMenuDescriptor, mPosition)
DEFINE_FIELD(DOptionMenuDescriptor, mDontDim)
DEFINE_FIELD(DOptionMenuDescriptor, mDontBlur)
DEFINE_FIELD(DOptionMenuDescriptor, mAnimatedTransition)
DEFINE_FIELD(DOptionMenuDescriptor, mAnimated)
DEFINE_FIELD(DOptionMenuDescriptor, mFont)

DEFINE_FIELD(FOptionMenuSettings, mTitleColor)
Expand All @@ -1063,6 +1068,8 @@ DEFINE_FIELD(DImageScrollerDescriptor,textFont)
DEFINE_FIELD(DImageScrollerDescriptor, textScale)
DEFINE_FIELD(DImageScrollerDescriptor, mAnimatedTransition)
DEFINE_FIELD(DImageScrollerDescriptor, mAnimated)
DEFINE_FIELD(DImageScrollerDescriptor, mDontDim)
DEFINE_FIELD(DImageScrollerDescriptor, mDontBlur)
DEFINE_FIELD(DImageScrollerDescriptor, virtWidth)
DEFINE_FIELD(DImageScrollerDescriptor, virtHeight)

Expand Down
7 changes: 7 additions & 0 deletions src/common/menu/menu.h
Expand Up @@ -91,6 +91,8 @@ class DListMenuDescriptor : public DMenuDescriptor
bool mFromEngine;
bool mAnimated;
bool mAnimatedTransition;
bool mDontDim;
bool mDontBlur;
int mVirtWidth;
int mVirtHeight;
bool mCustomSizeSet;
Expand Down Expand Up @@ -124,6 +126,9 @@ class DOptionMenuDescriptor : public DMenuDescriptor
int mIndent;
int mPosition;
bool mDontDim;
bool mDontBlur;
bool mAnimatedTransition;
bool mAnimated;
FFont *mFont;

void CalcIndent();
Expand All @@ -143,6 +148,8 @@ class DImageScrollerDescriptor : public DMenuDescriptor
double textScale;
bool mAnimatedTransition;
bool mAnimated;
bool mDontDim;
bool mDontBlur;
int virtWidth, virtHeight;

};
Expand Down
44 changes: 43 additions & 1 deletion src/common/menu/menudef.cpp
Expand Up @@ -358,6 +358,14 @@ static void DoParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &s
{
desc->mAnimated = true;
}
else if (sc.Compare("DontDim"))
{
desc->mDontDim = true;
}
else if (sc.Compare("DontBlur"))
{
desc->mDontBlur = true;
}
else if (sc.Compare("MouseWindow"))
{
sc.MustGetNumber();
Expand Down Expand Up @@ -763,6 +771,10 @@ static void ParseListMenu(FScanner &sc)
desc->mFromEngine = fileSystem.GetFileContainer(sc.LumpNum) == 0; // flags menu if the definition is from the IWAD.
desc->mVirtWidth = -2;
desc->mCustomSizeSet = false;
desc->mAnimatedTransition = false;
desc->mAnimated = false;
desc->mDontDim = false;
desc->mDontBlur = false;
desc->mForceList = false;
if (DefaultListMenuSettings->mCustomSizeSet)
{
Expand Down Expand Up @@ -1020,6 +1032,22 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc, int i
sc.MustGetNumber();
desc->mIndent = sc.Number;
}
else if (sc.Compare("AnimatedTransition"))
{
desc->mAnimatedTransition = true;
}
else if (sc.Compare("Animated"))
{
desc->mAnimated = true;
}
else if (sc.Compare("DontDim"))
{
desc->mDontDim = true;
}
else if (sc.Compare("DontBlur"))
{
desc->mDontBlur = true;
}
else
{
bool success = false;
Expand Down Expand Up @@ -1189,7 +1217,10 @@ static void ParseOptionMenu(FScanner &sc)
desc->mPosition = DefaultOptionMenuSettings->mPosition;
desc->mScrollTop = DefaultOptionMenuSettings->mScrollTop;
desc->mIndent = DefaultOptionMenuSettings->mIndent;
desc->mDontDim = DefaultOptionMenuSettings->mDontDim;
desc->mDontDim = false;
desc->mDontBlur = false;
desc->mAnimatedTransition = false;
desc->mAnimated = false;
desc->mProtected = sc.CheckString("protected");

ParseOptionMenuBody(sc, desc, -1);
Expand Down Expand Up @@ -1275,6 +1306,14 @@ static void ParseImageScrollerBody(FScanner& sc, DImageScrollerDescriptor* desc)
{
desc->mAnimated = true;
}
else if (sc.Compare("DontDim"))
{
desc->mDontDim = true;
}
else if (sc.Compare("DontBlur"))
{
desc->mDontBlur = true;
}
else if (sc.Compare("textBackground"))
{
sc.MustGetString();
Expand Down Expand Up @@ -1450,7 +1489,10 @@ static void ParseImageScroller(FScanner& sc)
desc->textBackgroundBrightness = 0xffffffff;
desc->textFont = SmallFont;
desc->textScale = 1;
desc->mDontDim = false;
desc->mDontBlur = false;
desc->mAnimatedTransition = false;
desc->mAnimated = false;
desc->virtWidth = 320;
desc->virtHeight = 200;

Expand Down
9 changes: 9 additions & 0 deletions src/menu/doommenu.cpp
Expand Up @@ -694,6 +694,9 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs)
od->mScrollTop = 0;
od->mIndent = 160;
od->mDontDim = false;
od->mDontBlur = false;
od->mAnimatedTransition = false;
od->mAnimated = false;
GC::WriteBarrier(od);
for(unsigned i = 0; i < AllEpisodes.Size(); i++)
{
Expand Down Expand Up @@ -829,6 +832,9 @@ static void BuildPlayerclassMenu()
od->mScrollTop = 0;
od->mIndent = 160;
od->mDontDim = false;
od->mDontBlur = false;
od->mAnimatedTransition = false;
od->mAnimated = false;
od->mNetgameMessage = "$NEWGAME";
GC::WriteBarrier(od);
for (unsigned i = 0; i < PlayerClasses.Size (); i++)
Expand Down Expand Up @@ -1252,6 +1258,9 @@ void M_StartupSkillMenu(FNewGameStartup *gs)
od->mScrollTop = 0;
od->mIndent = 160;
od->mDontDim = false;
od->mDontBlur = false;
od->mAnimatedTransition = false;
od->mAnimated = false;
GC::WriteBarrier(od);
}
else
Expand Down
8 changes: 6 additions & 2 deletions wadsrc/static/zscript/engine/ui/menu/imagescroller.zs
Expand Up @@ -41,6 +41,8 @@ class ImageScrollerDescriptor : MenuDescriptor native
native double textScale;
native bool mAnimatedTransition;
native bool mAnimated;
native bool mDontBlur;
native bool mDontDim;
native int virtWidth, virtHeight;
}

Expand Down Expand Up @@ -168,8 +170,10 @@ class ImageScrollerMenu : Menu
mParentMenu = parent;
index = 0;
mDesc = desc;
AnimatedTransition = desc.mAnimatedTransition;
Animated = desc.mAnimated;
AnimatedTransition = mDesc.mAnimatedTransition;
Animated = mDesc.mAnimated;
DontBlur = mDesc.mDontBlur;
DontDim = mDesc.mDontDim;
current = mDesc.mItems[0];
current.onStartPage();
previous = null;
Expand Down
4 changes: 4 additions & 0 deletions wadsrc/static/zscript/engine/ui/menu/listmenu.zs
Expand Up @@ -57,6 +57,8 @@ class ListMenuDescriptor : MenuDescriptor native
native bool mCenter;
native bool mAnimatedTransition;
native bool mAnimated;
native bool mDontBlur;
native bool mDontDim;
native int mVirtWidth, mVirtHeight;

native void Reset();
Expand Down Expand Up @@ -89,6 +91,8 @@ class ListMenu : Menu
mDesc = desc;
AnimatedTransition = mDesc.mAnimatedTransition;
Animated = mDesc.mAnimated;
DontBlur = mDesc.mDontBlur;
DontDim = mDesc.mDontDim;
if (desc.mCenter)
{
double center = 160;
Expand Down
6 changes: 6 additions & 0 deletions wadsrc/static/zscript/engine/ui/menu/optionmenu.zs
Expand Up @@ -55,6 +55,9 @@ class OptionMenuDescriptor : MenuDescriptor native
native int mIndent;
native int mPosition;
native bool mDontDim;
native bool mDontBlur;
native bool mAnimatedTransition;
native bool mAnimated;
native Font mFont;

void Reset()
Expand Down Expand Up @@ -106,6 +109,9 @@ class OptionMenu : Menu
mParentMenu = parent;
mDesc = desc;
DontDim = desc.mDontDim;
DontBlur = desc.mDontBlur;
AnimatedTransition = desc.mAnimatedTransition;
Animated = desc.mAnimated;

let itemCount = mDesc.mItems.size();
if (itemCount > 0)
Expand Down

0 comments on commit f322792

Please sign in to comment.