Fixed RollingNumbers to work with corner diffuse colors. Changed diffuse loops to use NUM_DIFFUSE_COLORS instead of 4.

This commit is contained in:
Kyzentun
2014-11-01 16:42:51 -06:00
parent 1f844d6627
commit 50df61a0ca
5 changed files with 38 additions and 28 deletions
+9 -9
View File
@@ -370,21 +370,21 @@ void Actor::PreDraw() // calculate actor properties
/* XXX: Should diffuse_blink and diffuse_shift multiply the tempState color?
* (That would have the same effect with 1,1,1,1, and allow tweening the diffuse
* while blinking and shifting.) */
for(int i=0; i<4; i++)
for(int i=0; i<NUM_DIFFUSE_COLORS; i++)
{
tempState.diffuse[i] = bBlinkOn ? m_effectColor1 : m_effectColor2;
tempState.diffuse[i].a *= fOriginalAlpha; // multiply the alphas so we can fade even while an effect is playing
}
break;
case diffuse_shift:
for(int i=0; i<4; i++)
for(int i=0; i<NUM_DIFFUSE_COLORS; i++)
{
tempState.diffuse[i] = m_effectColor1*fPercentBetweenColors + m_effectColor2*(1.0f-fPercentBetweenColors);
tempState.diffuse[i].a *= fOriginalAlpha; // multiply the alphas so we can fade even while an effect is playing
}
break;
case diffuse_ramp:
for(int i=0; i<4; i++)
for(int i=0; i<NUM_DIFFUSE_COLORS; i++)
{
tempState.diffuse[i] = m_effectColor1*fPercentThroughEffect + m_effectColor2*(1.0f-fPercentThroughEffect);
tempState.diffuse[i].a *= fOriginalAlpha; // multiply the alphas so we can fade even while an effect is playing
@@ -408,7 +408,7 @@ void Actor::PreDraw() // calculate actor properties
RageFastCos( fPercentBetweenColors*2*PI + PI * 2.0f / 3.0f ) * 0.5f + 0.5f,
RageFastCos( fPercentBetweenColors*2*PI + PI * 4.0f / 3.0f) * 0.5f + 0.5f,
fOriginalAlpha );
for( int i=1; i<4; i++ )
for( int i=1; i<NUM_DIFFUSE_COLORS; i++ )
tempState.diffuse[i] = tempState.diffuse[0];
break;
case wag:
@@ -471,7 +471,7 @@ void Actor::PreDraw() // calculate actor properties
tempState = m_current;
}
for( int i=0; i<4; i++ )
for( int i=0; i<NUM_DIFFUSE_COLORS; i++ )
{
tempState.diffuse[i] *= m_internalDiffuse;
}
@@ -1186,7 +1186,7 @@ float Actor::GetTweenTimeLeft() const
* being manipulated, which would add overhead ... */
void Actor::SetGlobalDiffuseColor( RageColor c )
{
for( int i=0; i<4; i++ ) // color, not alpha
for( int i=0; i<NUM_DIFFUSE_COLORS; i++ ) // color, not alpha
{
for( unsigned ts = 0; ts < m_Tweens.size(); ++ts )
{
@@ -1205,7 +1205,7 @@ void Actor::SetGlobalDiffuseColor( RageColor c )
void Actor::SetDiffuseColor( RageColor c )
{
for( int i=0; i<4; i++ )
for( int i=0; i<NUM_DIFFUSE_COLORS; i++ )
{
DestTweenState().diffuse[i].r = c.r;
DestTweenState().diffuse[i].g = c.g;
@@ -1224,7 +1224,7 @@ void Actor::TweenState::Init()
fSkewY = 0;
crop = RectF( 0,0,0,0 );
fade = RectF( 0,0,0,0 );
for( int i=0; i<4; i++ )
for( int i=0; i<NUM_DIFFUSE_COLORS; i++ )
diffuse[i] = RageColor( 1, 1, 1, 1 );
glow = RageColor( 1, 1, 1, 0 );
aux = 0;
@@ -1268,7 +1268,7 @@ void Actor::TweenState::MakeWeightedAverage( TweenState& average_out, const Twee
average_out.fade.right = lerp( fPercentBetween, ts1.fade.right, ts2.fade.right );
average_out.fade.bottom = lerp( fPercentBetween, ts1.fade.bottom, ts2.fade.bottom );
for( int i=0; i<4; ++i )
for( int i=0; i<NUM_DIFFUSE_COLORS; ++i )
average_out.diffuse[i] = lerp( fPercentBetween, ts1.diffuse[i], ts2.diffuse[i] );
average_out.glow = lerp( fPercentBetween, ts1.glow, ts2.glow );
+10 -3
View File
@@ -65,6 +65,13 @@ LuaDeclareType( VertAlign );
/** @brief The bottom vertical alignment constant. */
#define align_bottom 1.0f
// This is the number of colors in Actor::diffuse. Actor has multiple
// diffuse colors so that each edge can be a different color, and the actor
// is drawn with a gradient between them.
// I doubt I actually found all the places that touch diffuse and rely on the
// number of diffuse colors, so change this at your own risk. -Kyz
#define NUM_DIFFUSE_COLORS 4
// ssc futures:
/*
enum EffectAction
@@ -218,7 +225,7 @@ public:
* @brief Four values making up the diffuse in this TweenState.
*
* 0 = UpperLeft, 1 = UpperRight, 2 = LowerLeft, 3 = LowerRight */
RageColor diffuse[4];
RageColor diffuse[NUM_DIFFUSE_COLORS];
/** @brief The glow color for this TweenState. */
RageColor glow;
/** @brief A magical value that nobody really knows the use for. ;) */
@@ -433,8 +440,8 @@ public:
void SetGlobalDiffuseColor( RageColor c );
virtual void SetDiffuse( RageColor c ) { for(int i=0; i<4; i++) DestTweenState().diffuse[i] = c; };
virtual void SetDiffuseAlpha( float f ) { for(int i = 0; i < 4; ++i) { RageColor c = GetDiffuses( i ); c.a = f; SetDiffuses( i, c ); } }
virtual void SetDiffuse( RageColor c ) { for(int i=0; i<NUM_DIFFUSE_COLORS; i++) DestTweenState().diffuse[i] = c; };
virtual void SetDiffuseAlpha( float f ) { for(int i = 0; i < NUM_DIFFUSE_COLORS; ++i) { RageColor c = GetDiffuses( i ); c.a = f; SetDiffuses( i, c ); } }
float GetCurrentDiffuseAlpha() const { return m_current.diffuse[0].a; }
void SetDiffuseColor( RageColor c );
void SetDiffuses( int i, RageColor c ) { DestTweenState().diffuse[i] = c; };
+16 -13
View File
@@ -25,12 +25,12 @@ void RollingNumbers::Load( const RString &sMetricsGroup )
UpdateText();
}
void RollingNumbers::DrawPart(RageColor const& diffuse, RageColor const& stroke,
void RollingNumbers::DrawPart(RageColor const* diffuse, RageColor const& stroke,
float crop_left, float crop_right)
{
for(int i= 0; i < 4; ++i)
for(int i= 0; i < NUM_DIFFUSE_COLORS; ++i)
{
m_pTempState->diffuse[i]= diffuse;
m_pTempState->diffuse[i]= diffuse[i];
}
SetStrokeColor(stroke);
m_pTempState->crop.left= crop_left;
@@ -40,16 +40,18 @@ void RollingNumbers::DrawPart(RageColor const& diffuse, RageColor const& stroke,
void RollingNumbers::DrawPrimitives()
{
RageColor c_orig = this->GetDiffuse();
RageColor c2_orig = this->GetStrokeColor();
RageColor diffuse_orig[NUM_DIFFUSE_COLORS];
RageColor diffuse_temp[NUM_DIFFUSE_COLORS];
RageColor stroke_orig= GetStrokeColor();
RageColor stroke_temp= GetStrokeColor() * LEADING_ZERO_MULTIPLY_COLOR;
for(int i= 0; i < NUM_DIFFUSE_COLORS; ++i)
{
diffuse_orig[i]= m_pTempState->diffuse[i];
diffuse_temp[i]= m_pTempState->diffuse[i] * LEADING_ZERO_MULTIPLY_COLOR;
}
float original_crop_left= m_pTempState->crop.left;
float original_crop_right= m_pTempState->crop.right;
RageColor c = this->GetDiffuse();
c *= LEADING_ZERO_MULTIPLY_COLOR;
RageColor c2 = this->GetStrokeColor();
c2 *= LEADING_ZERO_MULTIPLY_COLOR;
RString s = this->GetText();
int i;
// find the first non-zero non-comma character, or the last character
@@ -68,10 +70,11 @@ void RollingNumbers::DrawPrimitives()
float f = i / (float)s.length();
// draw leading part
DrawPart(c, c2, max(0, original_crop_left), max(1-f, original_crop_right));
DrawPart(diffuse_temp, stroke_temp,
max(0, original_crop_left), max(1-f, original_crop_right));
// draw regular color part
DrawPart(c_orig, c2_orig, max(f, original_crop_left),
max(0, original_crop_right));
DrawPart(diffuse_orig, stroke_orig,
max(f, original_crop_left), max(0, original_crop_right));
m_pTempState->crop.left= original_crop_left;
m_pTempState->crop.right= original_crop_right;
+1 -1
View File
@@ -13,7 +13,7 @@ public:
void Load( const RString &sMetricsGroup );
virtual RollingNumbers *Copy() const;
void DrawPart(RageColor const& diffuse, RageColor const& stroke,
void DrawPart(RageColor const* diffuse, RageColor const& stroke,
float crop_left, float crop_right);
virtual void DrawPrimitives();
virtual void Update( float fDeltaTime );
+2 -2
View File
@@ -673,7 +673,7 @@ void ScreenOptions::PositionRows( bool bTween )
i < first_start ||
(i >= first_end && i < second_start) ||
i >= second_end;
for( int j=0; j<4; j++ )
for( int j=0; j<NUM_DIFFUSE_COLORS; j++ )
tsDestination.diffuse[j].a = bHidden? 0.0f:1.0f;
if( !bHidden )
pos++;
@@ -686,7 +686,7 @@ void ScreenOptions::PositionRows( bool bTween )
tsDestination.Init();
tsDestination.pos.y = SEPARATE_EXIT_ROW_Y;
for( int j=0; j<4; j++ )
for( int j=0; j<NUM_DIFFUSE_COLORS; j++ )
tsDestination.diffuse[j].a = 1.0f;
pSeparateExitRow->SetDestination( tsDestination, bTween );
}