Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
yamp committed Mar 4, 2005
1 parent c3aff72 commit ca1d0be
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
61 changes: 33 additions & 28 deletions mediaportal/Core/guilib/Animator.cs
Expand Up @@ -23,14 +23,13 @@ public enum AnimationType


protected AnimationType animType=AnimationType.None; //current animation type
protected DateTime m_DateTimeStart=DateTime.MinValue; //time animation started
protected bool m_Animating=false; //boolean indicating if we're animating

protected long lTime;

public Animator(AnimationType type)
{
animType=type;
m_DateTimeStart=DateTime.Now;
lTime=0;
m_Animating=true;
}

Expand Down Expand Up @@ -62,48 +61,48 @@ public void Animate(long timePassed,ref int x, ref int y, ref int width, ref int
if ( IsDone() ) return;

//check if animation should end
TimeSpan ts =DateTime.Now-m_DateTimeStart;
int iFrame = (int)Math.Floor(ts.TotalMilliseconds/FRAME_DURATION_IN_MSEC);
if (iFrame > NUMBEROFFRAMES)
{
float fTotalTime=FRAME_DURATION_IN_MSEC*NUMBEROFFRAMES;
float fTime=(float)lTime;
if (lTime >= fTotalTime)
{
//yes, then end the animation
m_Animating=false;
return;
}

//keep copy of original control rectangle
int posx=x;
int posy=y;
int w=width;
int h=height;
float posx=(float)x;
float posy=(float)y;
float w=(float)width;
float h=(float)height;

//modify the coordinates,width,height for the current animation type
switch (animType )
{
case AnimationType.FlyInFromLeft:
{
int iStepX= (x+width) / NUMBEROFFRAMES;
float iStepX= ( (float)(x+width)) / fTotalTime;
if (iStepX<=0) iStepX=1;
posx = iStepX*iFrame;
posx -=width;
posx = iStepX*fTime;
posx -= (float)width;
if (posx > x) posx=x;
}
break;

case AnimationType.FlyInFromRight:
{
int iStepX= (GUIGraphicsContext.Width-x) / NUMBEROFFRAMES;
float iStepX= ((float)(GUIGraphicsContext.Width-x)) / fTotalTime;
if (iStepX<=0) iStepX=1;
posx = x + GUIGraphicsContext.Width- (iStepX*iFrame);
posx = x + GUIGraphicsContext.Width- (iStepX*fTime);
if (posx < x) posx=x;
}
break;

case AnimationType.FlyInFromTop:
{
int iStepy= (y+height) / NUMBEROFFRAMES;
float iStepy= ((float)(y+height)) / fTotalTime;
if (iStepy<=0) iStepy=1;
posy = iStepy*iFrame;
posy = iStepy*fTime;
posy -=height;
if (posy > y) posy=y;
}
Expand All @@ -112,21 +111,21 @@ public void Animate(long timePassed,ref int x, ref int y, ref int width, ref int

case AnimationType.FlyInFromBottom:
{
int iStepY= (GUIGraphicsContext.Height-y) / NUMBEROFFRAMES;
float iStepY= ((float)(GUIGraphicsContext.Height-y)) / fTotalTime;
if (iStepY<=0) iStepY=1;
posy = y + GUIGraphicsContext.Height- (iStepY*iFrame);
posy = y + GUIGraphicsContext.Height- (iStepY*fTime);
if (posy < y) posy=y;
}
break;
case AnimationType.ZoomInFromMiddle:
{
int iStepY= (height/2) / (NUMBEROFFRAMES );
float iStepY= ((float)(height/2)) / (fTotalTime );
if (iStepY<=0) iStepY=1;
int iStepX= (width/2) / (NUMBEROFFRAMES );
float iStepX= ((float)(width/2)) / (fTotalTime );
if (iStepX<=0) iStepX=1;

iStepY*=iFrame;
iStepX*=iFrame;
iStepY*=fTime;
iStepX*=fTime;


posy = y+(height/2)-iStepY;
Expand All @@ -137,10 +136,16 @@ public void Animate(long timePassed,ref int x, ref int y, ref int width, ref int
break;
}
// and return the modified coordinates,with,height
x=posx;
y=posy;
width=w;
height=h;
x=(int)posx;
y=(int)posy;
width=(int)w;
height=(int)h;

}
public void Advance(long timePassed)
{
lTime+=timePassed;
}
}

}
1 change: 1 addition & 0 deletions mediaportal/Core/guilib/GUIGroup.cs
Expand Up @@ -84,6 +84,7 @@ public override void Render(long timePassed)
if (cntl!=null) cntl.Animate(timePassed,m_animator);
}
}
m_animator.Advance(timePassed);
}
}

Expand Down
4 changes: 2 additions & 2 deletions mediaportal/Core/guilib/GraphicContext.cs
Expand Up @@ -790,9 +790,9 @@ static public long TimePassed
get
{
float time = DXUtil.Timer(DirectXTimer.GetAbsoluteTime);
float difftime=lasttime-time;
float difftime=time-lasttime;
lasttime=time;
return ( (long)(time*1000.0f) );
return ( (long)(difftime*1000f) );
}
}
}
Expand Down

0 comments on commit ca1d0be

Please sign in to comment.