From 46d1f8517a13634cb8856d720f3172ff12671fac Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Nov 2019 22:05:52 +0100 Subject: [PATCH] - animated transitions are working. --- source/common/menu/listmenu.cpp | 1 + source/common/menu/menu.cpp | 12 ++++++----- source/common/menu/menu.h | 5 +++-- source/common/menu/menudef.cpp | 4 ++++ wadsrc/static/demolition/menudef.txt | 31 +++++++++++++++++++++++++++- 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/source/common/menu/listmenu.cpp b/source/common/menu/listmenu.cpp index 86ceb66d4..bff609e2e 100644 --- a/source/common/menu/listmenu.cpp +++ b/source/common/menu/listmenu.cpp @@ -64,6 +64,7 @@ void DListMenu::Init(DMenu *parent, FListMenuDescriptor *desc) { mParentMenu = parent; mDesc = desc; + canAnimate = !!(mDesc->mFlags & LMF_Animate); if (mDesc->mScriptId >= 0) scriptID = mDesc->mScriptId; #if 0 if (desc->mCenter) diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index ce5fab649..7e7b6d7d8 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -133,6 +133,7 @@ bool M_DrawTransition(MenuTransition &transition) transition.previous->origin.X = factor * transition.dir * (sin(phase) - 1.); transition.current->origin.X = factor * transition.dir * (sin(phase) + 1.); + Printf("prev.X = %2.5f, next.X = %2.5f\n", transition.previous->origin.X, transition.current->origin.X); transition.previous->Drawer(); transition.current->Drawer(); return true; @@ -763,6 +764,7 @@ void M_Ticker (void) if (DMenu::MenuTime & 3) return; if (DMenu::CurrentMenu != NULL && menuactive != MENU_Off) { + if (transition.previous) transition.previous->Ticker(); DMenu::CurrentMenu->Ticker(); for (int i = 0; i < NUM_MKEYS; ++i) @@ -804,18 +806,18 @@ void M_Drawer (void) { if (DMenu::CurrentMenu->DimAllowed() && fade && !DrawBackground) twod.AddColorOnlyQuad(0, 0, screen->GetWidth(), screen->GetHeight(), fade); - bool done = false; + bool going = false; if (transition.previous) { - done = M_DrawTransition(transition); - if (!done) + going = M_DrawTransition(transition); + if (!going) { - delete transition.previous; + if (transition.dir == -1) delete transition.previous; transition.previous = nullptr; transition.current = nullptr; } } - if (!done) + if (!going) { DMenu::CurrentMenu->origin = { 0,0 }; // else if (DrawBackground) Menu_DrawBackground(origin); diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index cbabae10c..b13dbe08f 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -167,7 +167,8 @@ class FOptionMenuItem; enum ListMenuFlags { LMF_Centered = 1, - LMF_DontSpace = 2 + LMF_DontSpace = 2, + LMF_Animate = 4, }; struct FListMenuDescriptor : public FMenuDescriptor @@ -318,7 +319,7 @@ public: static int MenuTime; DMenu *mParentMenu; - DVector2 origin; + DVector2 origin = { 0,0 }; int scriptID = INT_MAX; bool canAnimate = false; diff --git a/source/common/menu/menudef.cpp b/source/common/menu/menudef.cpp index 49920aef3..c1ba3ea16 100644 --- a/source/common/menu/menudef.cpp +++ b/source/common/menu/menudef.cpp @@ -284,6 +284,10 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc) { desc->mFlags |= LMF_Centered; } + else if (sc.Compare("animatedtransition")) + { + desc->mFlags |= LMF_Animate; + } else if (sc.Compare("Fixedspacing")) { sc.MustGetNumber(); diff --git a/wadsrc/static/demolition/menudef.txt b/wadsrc/static/demolition/menudef.txt index 0fa8099b0..b9b0a345b 100644 --- a/wadsrc/static/demolition/menudef.txt +++ b/wadsrc/static/demolition/menudef.txt @@ -18,6 +18,7 @@ LISTMENU "MainMenu" { position 160, 55, 115 centermenu + animatedtransition } class "Duke.MainMenu" NativeTextItem "$MNU_NEWGAME", "n", "EpisodeMenu" @@ -81,6 +82,7 @@ LISTMENU "IngameMenu" { position 160, 55, 115 centermenu + animatedtransition } linespacing 15 class "Duke.MainMenu" @@ -134,6 +136,7 @@ LISTMENU "EpisodeMenu" position 160, 48, 142 centermenu fixedspacing 5 + animatedtransition class "Duke.ListMenu" } @@ -149,17 +152,20 @@ LISTMENU "SkillMenu" centermenu fixedspacing 5 class "Duke.ListMenu" + animatedtransition } - ScriptId 110 } +// The custom menus are only supported by the EDuke32 frontend. LISTMENU "CustomGameMenu" { position 160, 48, 142 centermenu fixedspacing 5 ScriptId 102 + class "Duke.ListMenu" + animatedtransition } LISTMENU "CustomSubMenu1" @@ -168,6 +174,8 @@ LISTMENU "CustomSubMenu1" centermenu fixedspacing 5 ScriptId 103 + class "Duke.ListMenu" + animatedtransition } LISTMENU "CustomSubMenu2" @@ -176,6 +184,8 @@ LISTMENU "CustomSubMenu2" centermenu fixedspacing 5 ScriptId 103 + class "Duke.ListMenu" + animatedtransition } LISTMENU "CustomSubMenu3" @@ -184,6 +194,8 @@ LISTMENU "CustomSubMenu3" centermenu fixedspacing 5 ScriptId 103 + class "Duke.ListMenu" + animatedtransition } LISTMENU "CustomSubMenu4" @@ -192,6 +204,8 @@ LISTMENU "CustomSubMenu4" centermenu fixedspacing 5 ScriptId 103 + class "Duke.ListMenu" + animatedtransition } LISTMENU "CustomSubMenu5" @@ -200,6 +214,8 @@ LISTMENU "CustomSubMenu5" centermenu fixedspacing 5 ScriptId 103 + class "Duke.ListMenu" + animatedtransition } LISTMENU "CustomSubMenu6" @@ -208,6 +224,8 @@ LISTMENU "CustomSubMenu6" centermenu fixedspacing 5 ScriptId 103 + class "Duke.ListMenu" + animatedtransition } LISTMENU "CustomSubMenu7" @@ -216,10 +234,21 @@ LISTMENU "CustomSubMenu7" centermenu fixedspacing 5 ScriptId 103 + class "Duke.ListMenu" + animatedtransition } LISTMENU "MultiMenu" { + ifgame(Duke, Nam, WW2GI, Fury) // Ion Fury does not use this menu. + { + position 160, 55, 135 + centermenu + fixedspacing 5 + class "Duke.ListMenu" + animatedtransition + } + Caption "$MNU_NETWORKGAME" NativeTextItem "$MNU_PLAYERSETUP", "p", "PlayerSetupMenu" NativeTextItem "$MNU_JOINGAME", "j", "JoinGameMenu"