From 19c719db4e5afab25329eab5ff5974f47a12321d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Oct 2020 22:53:12 +0200 Subject: [PATCH] - image scroller is working again. --- source/common/menu/menu.cpp | 15 +++++++++++++++ source/common/menu/menudef.cpp | 1 + source/core/mainloop.cpp | 3 +++ wadsrc/static/zscript/ui/menu/imagescroller.zs | 10 +++++++--- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 5fc5021aa..6dc786c74 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -550,6 +550,21 @@ void M_SetMenu(FName menu, int param) } M_ActivateMenu(newmenu); } + else if ((*desc)->IsKindOf(RUNTIME_CLASS(DImageScrollerDescriptor))) + { + auto ld = static_cast(*desc); + PClass* cls = ld->mClass; + if (cls == nullptr) cls = DefaultOptionMenuClass; + if (cls == nullptr) cls = PClass::FindClass("ImageScrollerMenu"); + + DMenu* newmenu = (DMenu*)cls->CreateNew(); + IFVIRTUALPTRNAME(newmenu, "ImageScrollerMenu", Init) + { + VMValue params[3] = { newmenu, CurrentMenu, ld }; + VMCall(func, params, 3, nullptr, 0); + } + M_ActivateMenu(newmenu); + } return; } else diff --git a/source/common/menu/menudef.cpp b/source/common/menu/menudef.cpp index 86ce761e8..756af5da8 100644 --- a/source/common/menu/menudef.cpp +++ b/source/common/menu/menudef.cpp @@ -1249,6 +1249,7 @@ static void ParseImageScroller(FScanner& sc) DImageScrollerDescriptor* desc = Create(); + desc->mMenuName = sc.String; desc->textBackground.SetInvalid(); desc->textBackgroundBrightness = 0xffffffff; desc->textFont = SmallFont; diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index cd9508a41..a5dd241f7 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -648,6 +648,7 @@ void MainLoop () Printf (PRINT_BOLD, "\n%s\n", error.GetMessage()); } gi->ErrorCleanup(); + M_ClearMenus(); C_FullConsole(); gameaction = ga_nothing; } @@ -656,6 +657,8 @@ void MainLoop () error.MaybePrintMessage(); Printf("%s", error.stacktrace.GetChars()); gi->ErrorCleanup(); + twod->SetOffset(DVector2(0, 0)); + M_ClearMenus(); C_FullConsole(); } } diff --git a/wadsrc/static/zscript/ui/menu/imagescroller.zs b/wadsrc/static/zscript/ui/menu/imagescroller.zs index f0a2fadb2..62e0bbad5 100644 --- a/wadsrc/static/zscript/ui/menu/imagescroller.zs +++ b/wadsrc/static/zscript/ui/menu/imagescroller.zs @@ -154,12 +154,14 @@ class ImageScrollerMenu : Menu current = to; } - void Init(Menu parent, ImageScrollerDescriptor desc) + virtual void Init(Menu parent, ImageScrollerDescriptor desc) { mParentMenu = parent; index = 0; mDesc = desc; AnimatedTransition = desc.mAnimatedTransition; + current = mDesc.mItems[0]; + previous = null; } //============================================================================= @@ -240,9 +242,9 @@ class ImageScrollerMenu : Menu double factor = screen.GetWidth()/2; double phase = (now - start) / length * 180. + 90.; - screen.SetOffset(0, factor * dir * (sin(phase) - 1.)); + screen.SetOffset(factor * dir * (sin(phase) - 1.), 0); previous.Drawer(false); - screen.SetOffset(0, factor * dir * (sin(phase) + 1.)); + screen.SetOffset(factor * dir * (sin(phase) + 1.), 0); current.Drawer(false); screen.SetOffset(0, 0); return true; @@ -261,9 +263,11 @@ class ImageScrollerMenu : Menu { if (previous != null) { + Animated = true; if (DrawTransition()) return; previous = null; } current.Drawer(false); + Animated = false; } }