- image scroller is working again.

This commit is contained in:
Christoph Oelckers 2020-10-08 22:53:12 +02:00
parent 6ba06f5ed0
commit 19c719db4e
4 changed files with 26 additions and 3 deletions

View file

@ -550,6 +550,21 @@ void M_SetMenu(FName menu, int param)
} }
M_ActivateMenu(newmenu); M_ActivateMenu(newmenu);
} }
else if ((*desc)->IsKindOf(RUNTIME_CLASS(DImageScrollerDescriptor)))
{
auto ld = static_cast<DImageScrollerDescriptor*>(*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; return;
} }
else else

View file

@ -1249,6 +1249,7 @@ static void ParseImageScroller(FScanner& sc)
DImageScrollerDescriptor* desc = Create<DImageScrollerDescriptor>(); DImageScrollerDescriptor* desc = Create<DImageScrollerDescriptor>();
desc->mMenuName = sc.String;
desc->textBackground.SetInvalid(); desc->textBackground.SetInvalid();
desc->textBackgroundBrightness = 0xffffffff; desc->textBackgroundBrightness = 0xffffffff;
desc->textFont = SmallFont; desc->textFont = SmallFont;

View file

@ -648,6 +648,7 @@ void MainLoop ()
Printf (PRINT_BOLD, "\n%s\n", error.GetMessage()); Printf (PRINT_BOLD, "\n%s\n", error.GetMessage());
} }
gi->ErrorCleanup(); gi->ErrorCleanup();
M_ClearMenus();
C_FullConsole(); C_FullConsole();
gameaction = ga_nothing; gameaction = ga_nothing;
} }
@ -656,6 +657,8 @@ void MainLoop ()
error.MaybePrintMessage(); error.MaybePrintMessage();
Printf("%s", error.stacktrace.GetChars()); Printf("%s", error.stacktrace.GetChars());
gi->ErrorCleanup(); gi->ErrorCleanup();
twod->SetOffset(DVector2(0, 0));
M_ClearMenus();
C_FullConsole(); C_FullConsole();
} }
} }

View file

@ -154,12 +154,14 @@ class ImageScrollerMenu : Menu
current = to; current = to;
} }
void Init(Menu parent, ImageScrollerDescriptor desc) virtual void Init(Menu parent, ImageScrollerDescriptor desc)
{ {
mParentMenu = parent; mParentMenu = parent;
index = 0; index = 0;
mDesc = desc; mDesc = desc;
AnimatedTransition = desc.mAnimatedTransition; AnimatedTransition = desc.mAnimatedTransition;
current = mDesc.mItems[0];
previous = null;
} }
//============================================================================= //=============================================================================
@ -240,9 +242,9 @@ class ImageScrollerMenu : Menu
double factor = screen.GetWidth()/2; double factor = screen.GetWidth()/2;
double phase = (now - start) / length * 180. + 90.; 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); previous.Drawer(false);
screen.SetOffset(0, factor * dir * (sin(phase) + 1.)); screen.SetOffset(factor * dir * (sin(phase) + 1.), 0);
current.Drawer(false); current.Drawer(false);
screen.SetOffset(0, 0); screen.SetOffset(0, 0);
return true; return true;
@ -261,9 +263,11 @@ class ImageScrollerMenu : Menu
{ {
if (previous != null) if (previous != null)
{ {
Animated = true;
if (DrawTransition()) return; if (DrawTransition()) return;
previous = null; previous = null;
} }
current.Drawer(false); current.Drawer(false);
Animated = false;
} }
} }