From 6bf0b0c304bf8c2851b94f144dde37466b5310dc Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 2 Apr 2003 05:41:22 +0000 Subject: [PATCH] Add Actor::Reset While I'm recompiling everything anyway, move some functions out of Actor.h --- stepmania/src/Actor.cpp | 63 +++++++++++++++++++++++++++++++++++++++-- stepmania/src/Actor.h | 52 ++++------------------------------ 2 files changed, 66 insertions(+), 49 deletions(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index b4af66b225..e947b148d2 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -18,10 +18,12 @@ #include "GameConstantsAndTypes.h" #include "RageLog.h" - -Actor::Actor() +/* This is Reset instead of Init since many derived classes have Init() functions + * that shouldn't change the position of the actor. */ +void Actor::Reset() { - m_bFirstUpdate = true; + m_TweenStates.clear(); + m_TweenInfo.clear(); m_baseRotation = RageVector3( 0, 0, 0 ); m_baseScale = RageVector3( 1, 1, 1 ); @@ -47,6 +49,12 @@ Actor::Actor() m_bBlendAdd = false; } +Actor::Actor() +{ + Reset(); + m_bFirstUpdate = true; +} + void Actor::Draw() { // call the most-derived versions @@ -339,6 +347,24 @@ void Actor::ScaleTo( const RectI &rect, StretchType st ) SetZoom( fNewZoom ); } +void Actor::SetHorizAlign( CString s ) +{ + s.MakeLower(); + if (s=="left") m_HorizAlign = align_left; + else if(s=="center") m_HorizAlign = align_center; + else if(s=="right") m_HorizAlign = align_right; + else ASSERT(0); +} + +void Actor::SetVertAlign( CString s ) +{ + s.MakeLower(); + if (s=="top") m_VertAlign = align_top; + else if(s=="middle") m_VertAlign = align_middle; + else if(s=="bottom") m_VertAlign = align_bottom; + else ASSERT(0); +} + void Actor::StretchTo( const RectI &r ) { RectF r2( (float)r.left, (float)r.top, (float)r.right, (float)r.bottom ); @@ -469,6 +495,17 @@ void Actor::SetEffectPulse( float fPeriod, float fMinZoom, float fMaxZoom ) } +void Actor::SetShadowLength( float fLength ) +{ + if( fLength==0 ) + m_bShadow = false; + else + { + m_fShadowLength = fLength; + m_bShadow = true; + } +} + void Actor::Fade( float fSleepSeconds, CString sFadeString, float fFadeSeconds, bool bFadingOff ) { sFadeString.MakeLower(); @@ -686,3 +723,23 @@ float Actor::GetTweenTimeLeft() const return tot; } + +void Actor::TweenState::Init() +{ + pos = RageVector3( 0, 0, 0 ); + rotation = RageVector3( 0, 0, 0 ); + scale = RageVector3( 1, 1, 1 ); + for(int i=0; i<4; i++) + diffuse[i] = RageColor( 1, 1, 1, 1 ); + glow = RageColor( 1, 1, 1, 0 ); +} + +void Actor::TweenState::MakeWeightedAverage( TweenState& average_out, const TweenState& ts1, const TweenState& ts2, float fPercentBetween ) +{ + average_out.pos = ts1.pos + (ts2.pos - ts1.pos )*fPercentBetween; + average_out.scale = ts1.scale + (ts2.scale - ts1.scale )*fPercentBetween; + average_out.rotation = ts1.rotation+ (ts2.rotation - ts1.rotation)*fPercentBetween; + for(int i=0; i<4; i++) + average_out.diffuse[i] = ts1.diffuse[i]+ (ts2.diffuse[i] - ts1.diffuse[i])*fPercentBetween; + average_out.glow = ts1.glow + (ts2.glow - ts1.glow )*fPercentBetween; +} diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 3a6c30dbdc..7b67163355 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -19,6 +19,7 @@ class Actor public: Actor(); virtual ~Actor() { } + void Reset(); enum TweenType { TWEEN_LINEAR, @@ -45,25 +46,8 @@ public: RageColor diffuse[4]; RageColor glow; - void Init() - { - pos = RageVector3( 0, 0, 0 ); - rotation = RageVector3( 0, 0, 0 ); - scale = RageVector3( 1, 1, 1 ); - for(int i=0; i<4; i++) - diffuse[i] = RageColor( 1, 1, 1, 1 ); - glow = RageColor( 1, 1, 1, 0 ); - }; - - static void MakeWeightedAverage( TweenState& average_out, const TweenState& ts1, const TweenState& ts2, float fPercentBetween ) - { - average_out.pos = ts1.pos + (ts2.pos - ts1.pos )*fPercentBetween; - average_out.scale = ts1.scale + (ts2.scale - ts1.scale )*fPercentBetween; - average_out.rotation = ts1.rotation+ (ts2.rotation - ts1.rotation)*fPercentBetween; - for(int i=0; i<4; i++) - average_out.diffuse[i] = ts1.diffuse[i]+ (ts2.diffuse[i] - ts1.diffuse[i])*fPercentBetween; - average_out.glow = ts1.glow + (ts2.glow - ts1.glow )*fPercentBetween; - } + void Init(); + static void MakeWeightedAverage( TweenState& average_out, const TweenState& ts1, const TweenState& ts2, float fPercentBetween ); }; // let subclasses override @@ -182,26 +166,11 @@ public: enum HorizAlign { align_left, align_center, align_right }; virtual void SetHorizAlign( HorizAlign ha ) { m_HorizAlign = ha; } - virtual void SetHorizAlign( CString s ) - { - s.MakeLower(); - if (s=="left") m_HorizAlign = align_left; - else if(s=="center") m_HorizAlign = align_center; - else if(s=="right") m_HorizAlign = align_right; - else ASSERT(0); - } + virtual void SetHorizAlign( CString s ); enum VertAlign { align_top, align_middle, align_bottom }; virtual void SetVertAlign( VertAlign va ) { m_VertAlign = va; } - virtual void SetVertAlign( CString s ) - { - s.MakeLower(); - if (s=="top") m_VertAlign = align_top; - else if(s=="middle") m_VertAlign = align_middle; - else if(s=="bottom") m_VertAlign = align_bottom; - else ASSERT(0); - } - + virtual void SetVertAlign( CString s ); // effects @@ -250,16 +219,7 @@ public: // // other properties // - void SetShadowLength( float fLength ) - { - if( fLength==0 ) - m_bShadow = false; - else - { - m_fShadowLength = fLength; - m_bShadow = true; - } - } + void SetShadowLength( float fLength ); void EnableShadow( bool b ) { m_bShadow = b; }