mirror of
https://github.com/ZDoom/Raze.git
synced 2025-05-31 09:20:59 +00:00
- work on menu transitions.
This commit is contained in:
parent
a7e25a116f
commit
cc7290e313
4 changed files with 56 additions and 31 deletions
|
@ -101,6 +101,7 @@ static bool MenuEnabled = true;
|
|||
DMenu *CurrentMenu;
|
||||
int MenuTime;
|
||||
DObject* menuDelegate;
|
||||
static MenuTransition transition;
|
||||
|
||||
|
||||
extern PClass *DefaultListMenuClass;
|
||||
|
@ -193,6 +194,8 @@ void M_MarkMenus()
|
|||
}
|
||||
GC::Mark(CurrentMenu);
|
||||
GC::Mark(menuDelegate);
|
||||
GC::Mark(transition.previous);
|
||||
GC::Mark(transition.current);
|
||||
}
|
||||
|
||||
|
||||
|
@ -202,8 +205,6 @@ void M_MarkMenus()
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
static MenuTransition transition;
|
||||
|
||||
bool MenuTransition::StartTransition(DMenu* from, DMenu* to, MenuTransitionType animtype)
|
||||
{
|
||||
if (!from->canAnimate() || !to->canAnimate() || animtype == MA_None)
|
||||
|
@ -215,10 +216,11 @@ bool MenuTransition::StartTransition(DMenu* from, DMenu* to, MenuTransitionType
|
|||
start = I_GetTimeNS() * (120. / 1'000'000'000.);
|
||||
length = 30;
|
||||
dir = animtype == MA_Advance ? 1 : -1;
|
||||
destroyprev = animtype == MA_Return;
|
||||
previous = from;
|
||||
current = to;
|
||||
if (from) GC::AddSoftRoot(from);
|
||||
if (to) GC::AddSoftRoot(to);
|
||||
if (from) GC::WriteBarrier(from);
|
||||
if (to) GC::WriteBarrier(to);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -241,8 +243,9 @@ bool MenuTransition::Draw()
|
|||
current->CallDrawer();
|
||||
return true;
|
||||
}
|
||||
if (previous) GC::DelSoftRoot(previous);
|
||||
if (current) GC::DelSoftRoot(current);
|
||||
if (destroyprev && previous) previous->Destroy();
|
||||
previous = nullptr;
|
||||
current = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -352,27 +355,24 @@ void DMenu::Close ()
|
|||
assert(CurrentMenu == this);
|
||||
CurrentMenu = mParentMenu;
|
||||
|
||||
if (false)// todo: && mParentMenu && transition.StartTransition(this, mParentMenu, MA_Return))
|
||||
if (CurrentMenu != nullptr)
|
||||
{
|
||||
return;
|
||||
GC::WriteBarrier(CurrentMenu);
|
||||
IFVIRTUALPTR(CurrentMenu, DMenu, OnReturn)
|
||||
{
|
||||
VMValue params[] = { CurrentMenu };
|
||||
VMCall(func, params, 1, nullptr, 0);
|
||||
}
|
||||
if (transition.StartTransition(this, CurrentMenu, MA_Return))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy();
|
||||
if (CurrentMenu != nullptr)
|
||||
{
|
||||
GC::WriteBarrier(CurrentMenu);
|
||||
IFVIRTUALPTR(CurrentMenu, DMenu, OnReturn)
|
||||
{
|
||||
VMValue params[] = { CurrentMenu };
|
||||
VMCall(func, params, 1, nullptr, 0);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
M_ClearMenus();
|
||||
}
|
||||
Destroy();
|
||||
if (CurrentMenu == nullptr)
|
||||
{
|
||||
M_ClearMenus();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,7 @@ void M_ActivateMenu(DMenu *menu)
|
|||
CurrentMenu->mMouseCapture = false;
|
||||
I_ReleaseMouseCapture();
|
||||
}
|
||||
//transition.StartTransition(CurrentMenu, menu, MA_Advance);
|
||||
transition.StartTransition(CurrentMenu, menu, MA_Advance);
|
||||
}
|
||||
CurrentMenu = menu;
|
||||
GC::WriteBarrier(CurrentMenu);
|
||||
|
@ -826,10 +826,25 @@ void M_Drawer (void)
|
|||
{
|
||||
if (sysCallbacks.MenuDim) sysCallbacks.MenuDim();
|
||||
}
|
||||
CurrentMenu->CallDrawer();
|
||||
bool going = false;
|
||||
if (transition.previous)
|
||||
{
|
||||
going = transition.Draw();
|
||||
if (!going)
|
||||
{
|
||||
if (transition.dir == -1) delete transition.previous;
|
||||
transition.previous = nullptr;
|
||||
transition.current = nullptr;
|
||||
}
|
||||
}
|
||||
if (!going)
|
||||
{
|
||||
CurrentMenu->CallDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
|
@ -838,6 +853,9 @@ void M_Drawer (void)
|
|||
|
||||
void M_ClearMenus()
|
||||
{
|
||||
transition.previous = transition.current = nullptr;
|
||||
transition.dir = 0;
|
||||
|
||||
while (CurrentMenu != nullptr)
|
||||
{
|
||||
DMenu* parent = CurrentMenu->mParentMenu;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue