More menu smoothing.
This commit is contained in:
parent
d7614bdf73
commit
b1e155d07c
4 changed files with 75 additions and 19 deletions
|
|
@ -62,13 +62,15 @@ Class DemolitionistMenu : GenericMenu
|
|||
Vector2 curmouse;
|
||||
bool isrclick;
|
||||
// somehow Drawer can be called while closing prematurely, which is big bollocks
|
||||
bool isclosing;
|
||||
bool isclosing, forceclose;
|
||||
// the tabs
|
||||
Array<DemolitionistMenuTab> tabs;
|
||||
int curtab;
|
||||
int oldtab; // used for returning from help tab
|
||||
// fonts
|
||||
Font mSmallFont, mTinyFont;
|
||||
// for open/close animation
|
||||
double animtimer;
|
||||
|
||||
int GenTUID()
|
||||
{
|
||||
|
|
@ -129,10 +131,8 @@ Class DemolitionistMenu : GenericMenu
|
|||
return -1;
|
||||
}
|
||||
|
||||
private void DoClose( bool PlaySound = false )
|
||||
private void DoClose()
|
||||
{
|
||||
isclosing = true;
|
||||
if ( PlaySound ) MenuSound("menu/democlose");
|
||||
EventHandler.SendNetworkEvent("swwmclearalltransactions",consoleplayer);
|
||||
for ( int i=0; i<tabs.Size(); i++ )
|
||||
{
|
||||
|
|
@ -143,17 +143,17 @@ Class DemolitionistMenu : GenericMenu
|
|||
}
|
||||
tabs[i].Destroy();
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
||||
override void Init( Menu parent )
|
||||
{
|
||||
Super.Init(parent);
|
||||
Animated = true;
|
||||
Animated = DontDim = DontBlur = true;
|
||||
// can't open this menu outside of the game or if dead
|
||||
// also can't if you're not the Demolitionist
|
||||
if ( (gamestate != GS_LEVEL) || (players[consoleplayer].Health <= 0) || !(players[consoleplayer].mo is 'Demolitionist') )
|
||||
{
|
||||
animtimer = -1.;
|
||||
isclosing = true;
|
||||
return;
|
||||
}
|
||||
|
|
@ -222,6 +222,7 @@ Class DemolitionistMenu : GenericMenu
|
|||
|
||||
override bool MenuEvent( int mkey, bool fromcontroller )
|
||||
{
|
||||
if ( isclosing || (animtimer < 1.) ) return false;
|
||||
// pachinko code only handled if the tab lacks direct input
|
||||
if ( !tabs[curtab].bDirectInput )
|
||||
{
|
||||
|
|
@ -268,7 +269,8 @@ Class DemolitionistMenu : GenericMenu
|
|||
switch ( mkey )
|
||||
{
|
||||
case MKEY_BACK:
|
||||
DoClose(true);
|
||||
isclosing = true;
|
||||
MenuSound("menu/democlose");
|
||||
return true;
|
||||
case MKEY_PAGEDOWN:
|
||||
int next = GetNextTab();
|
||||
|
|
@ -315,10 +317,11 @@ Class DemolitionistMenu : GenericMenu
|
|||
override void Ticker()
|
||||
{
|
||||
Super.Ticker();
|
||||
if ( (gamestate != GS_LEVEL) || (players[consoleplayer].Health <= 0) || isclosing )
|
||||
if ( ((gamestate != GS_LEVEL) || (players[consoleplayer].Health <= 0) || isclosing) && (animtimer <= 0.) )
|
||||
{
|
||||
// ded (or force close)
|
||||
DoClose();
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
if ( swwm_menupause ) menuactive = Menu.On;
|
||||
|
|
@ -335,12 +338,25 @@ Class DemolitionistMenu : GenericMenu
|
|||
// update money
|
||||
muns = SWWMCredits.Get(players[consoleplayer]);
|
||||
munstr = String.Format("\cg¥\c-%09d",muns);
|
||||
if ( isclosing )
|
||||
{
|
||||
if ( animtimer >= 1. ) DontDim = DontBlur = true;
|
||||
animtimer -= .1;
|
||||
return;
|
||||
}
|
||||
if ( animtimer < 1. )
|
||||
{
|
||||
animtimer += .1;
|
||||
if ( animtimer < 1. ) return; // ensure tabs tick before first draw
|
||||
else DontDim = DontBlur = false;
|
||||
}
|
||||
if ( (tabs.Size() <= 0) || (curtab == -1) || !tabs[curtab] ) return;
|
||||
tabs[curtab].Ticker();
|
||||
}
|
||||
|
||||
override bool MouseEvent( int type, int mx, int my )
|
||||
{
|
||||
if ( isclosing || (animtimer < 1.) ) return false;
|
||||
bool res = Super.MouseEvent(type,mx,my);
|
||||
Vector2 mpos = (mx/hs,my/hs)-origin;
|
||||
if ( type == MOUSE_Click )
|
||||
|
|
@ -390,6 +406,7 @@ Class DemolitionistMenu : GenericMenu
|
|||
|
||||
override bool OnUiEvent( UIEvent ev )
|
||||
{
|
||||
if ( isclosing || (animtimer < 1.) ) return false;
|
||||
if ( tabs[curtab].bDirectInput && ((ev.type == UIEvent.Type_KeyDown) || (ev.type == UIEvent.Type_KeyUp)) )
|
||||
return tabs[curtab].DirectInput(ev);
|
||||
switch ( ev.type )
|
||||
|
|
@ -433,7 +450,8 @@ Class DemolitionistMenu : GenericMenu
|
|||
}
|
||||
if( (ikey[0] && (ev.keystring == mkey[0])) || (ikey[1] && (ev.keystring == mkey[1])) )
|
||||
{
|
||||
DoClose(true);
|
||||
isclosing = true;
|
||||
MenuSound("menu/democlose");
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
|
@ -480,20 +498,20 @@ Class DemolitionistMenu : GenericMenu
|
|||
x += origin.x;
|
||||
y += origin.y;
|
||||
Screen.DrawTexture(FrameTex,false,x,y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,0.,DTA_SrcY,0.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,1);
|
||||
Screen.DrawTexture(FrameTex,false,x+1,y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,1.,DTA_SrcY,0.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,int(w-2),DTA_DestHeight,1);
|
||||
Screen.DrawTexture(FrameTex,false,x,y+1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,0.,DTA_SrcY,1.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,int(h-2));
|
||||
if ( w > 2 ) Screen.DrawTexture(FrameTex,false,x+1,y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,1.,DTA_SrcY,0.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,int(w-2),DTA_DestHeight,1);
|
||||
if ( h > 2 ) Screen.DrawTexture(FrameTex,false,x,y+1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,0.,DTA_SrcY,1.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,int(h-2));
|
||||
Screen.DrawTexture(FrameTex,false,(x+w)-1,y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,2.,DTA_SrcY,0.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,1);
|
||||
Screen.DrawTexture(FrameTex,false,x,(y+h)-1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,0.,DTA_SrcY,2.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,1);
|
||||
if ( shadow )
|
||||
{
|
||||
Screen.DrawTexture(FrameTex,false,(x+w)-1,y+1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,2.,DTA_SrcY,1.,DTA_SrcWidth,2.,DTA_SrcHeight,1.,DTA_DestWidth,2,DTA_DestHeight,int(h-2));
|
||||
Screen.DrawTexture(FrameTex,false,x+1,(y+h)-1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,1.,DTA_SrcY,2.,DTA_SrcWidth,1.,DTA_SrcHeight,2.,DTA_DestWidth,int(w-2),DTA_DestHeight,2);
|
||||
if ( h > 2 ) Screen.DrawTexture(FrameTex,false,(x+w)-1,y+1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,2.,DTA_SrcY,1.,DTA_SrcWidth,2.,DTA_SrcHeight,1.,DTA_DestWidth,2,DTA_DestHeight,int(h-2));
|
||||
if ( w > 2 ) Screen.DrawTexture(FrameTex,false,x+1,(y+h)-1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,1.,DTA_SrcY,2.,DTA_SrcWidth,1.,DTA_SrcHeight,2.,DTA_DestWidth,int(w-2),DTA_DestHeight,2);
|
||||
Screen.DrawTexture(FrameTex,false,(x+w)-1,(y+h)-1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,2.,DTA_SrcY,2.,DTA_SrcWidth,2.,DTA_SrcHeight,2.,DTA_DestWidth,2,DTA_DestHeight,2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Screen.DrawTexture(FrameTex,false,(x+w)-1,y+1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,2.,DTA_SrcY,1.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,int(h-2));
|
||||
Screen.DrawTexture(FrameTex,false,x+1,(y+h)-1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,1.,DTA_SrcY,2.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,int(w-2),DTA_DestHeight,1);
|
||||
if ( h > 2 ) Screen.DrawTexture(FrameTex,false,(x+w)-1,y+1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,2.,DTA_SrcY,1.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,int(h-2));
|
||||
if ( w > 2 ) Screen.DrawTexture(FrameTex,false,x+1,(y+h)-1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,1.,DTA_SrcY,2.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,int(w-2),DTA_DestHeight,1);
|
||||
Screen.DrawTexture(FrameTex,false,(x+w)-1,(y+h)-1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcX,2.,DTA_SrcY,2.,DTA_SrcWidth,1.,DTA_SrcHeight,1.,DTA_DestWidth,1,DTA_DestHeight,1);
|
||||
}
|
||||
}
|
||||
|
|
@ -518,7 +536,44 @@ Class DemolitionistMenu : GenericMenu
|
|||
|
||||
override void Drawer()
|
||||
{
|
||||
if ( isclosing ) return;
|
||||
if ( animtimer < 0 ) return;
|
||||
// animated frame (more math)
|
||||
if ( isclosing || (animtimer < 1.) )
|
||||
{
|
||||
double intp, xfact, yfact;
|
||||
if ( isclosing )
|
||||
{
|
||||
intp = animtimer-.1*System.GetTimeFrac();
|
||||
xfact = clamp(intp*2.,0.,1.)**2.;
|
||||
yfact = clamp(intp,0.,1.)**5.;
|
||||
}
|
||||
else
|
||||
{
|
||||
intp = animtimer+.1*System.GetTimeFrac();
|
||||
xfact = clamp(intp*2,0.,1.)**2.;
|
||||
yfact = clamp(intp,0.,1.)**5.;
|
||||
}
|
||||
double rwsx = int(SWWMUtility.Lerp(2,ws.x,xfact));
|
||||
double rwsy = int(SWWMUtility.Lerp(2,ws.y,yfact));
|
||||
if ( (rwsx == 2) && (rwsy == 2) ) return;
|
||||
double rox = int(ss.x-rwsx)/2;
|
||||
double roy = int(ss.y-rwsy)/2;
|
||||
// copy the menu dim below the window during animations, so the transition looks smoother
|
||||
Screen.Dim((dimamount<0)?Color("Black"):dimcolor,(dimamount<0)?.5:dimamount,int(rox*hs),int(roy*hs),int(rwsx*hs),int(rwsy*hs));
|
||||
// draw the background and main frame
|
||||
if ( swwm_fuzz )
|
||||
{
|
||||
// fuzz was designed for 16:10, so we'll have to extend it at taller ratios
|
||||
int count = int(ceil(ws.y/400.));
|
||||
Screen.SetClipRect(int(rox*hs),int(roy*hs),int(rwsx*hs),int(rwsy*hs));
|
||||
for ( int i=0; i<count; i++ )
|
||||
Screen.DrawTexture(FancyBg,false,origin.x,origin.y+400.*i,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,.5);
|
||||
Screen.ClearClipRect();
|
||||
}
|
||||
Screen.Dim("Black",.8,int(rox*hs),int(roy*hs),int(rwsx*hs),int(rwsy*hs));
|
||||
DrawFrame(rox-origin.x,roy-origin.y,rwsx,rwsy,true);
|
||||
return;
|
||||
}
|
||||
// draw the background and main frame
|
||||
if ( swwm_fuzz )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue