Beispiel #1
0
void GraphDisplay::Set( const StageStats &ss, const PlayerStageStats &pss )
{
    float fTotalStepSeconds = ss.GetTotalPossibleStepsSeconds();

    m_Values.resize( VALUE_RESOLUTION );
    pss.GetLifeRecord( &m_Values[0], VALUE_RESOLUTION, ss.GetTotalPossibleStepsSeconds() );
    for (auto &value: m_Values)
    {
        value = Rage::clamp( value, 0.f, 1.f );
    }

    UpdateVerts();

    // Show song boundaries
    float fSec = 0;
    auto &songs = ss.m_vpPossibleSongs;
    for (auto song = songs.begin(); song != songs.end(); ++song)
    {
        if( song == songs.end()-1 )
            continue;
        fSec += (*song)->GetStepsSeconds();

        Actor *p = m_sprSongBoundary->Copy();
        m_vpSongBoundaries.push_back( p );
        float fX = Rage::scale( fSec, 0.f, fTotalStepSeconds, m_quadVertices.left, m_quadVertices.right );
        p->SetX( fX );
        this->AddChild( p );
    }

    if( !pss.m_bFailed )
    {
        // Search for the min life record to show "Just Barely!"
        float fMinLifeSoFar = 1.0f;
        int iMinLifeSoFarAt = 0;

        for( int i = 0; i < VALUE_RESOLUTION; ++i )
        {
            float fLife = m_Values[i];
            if( fLife < fMinLifeSoFar )
            {
                fMinLifeSoFar = fLife;
                iMinLifeSoFarAt = i;
            }
        }

        if( fMinLifeSoFar > 0.0f  &&  fMinLifeSoFar < 0.1f )
        {
            float fX = Rage::scale( float(iMinLifeSoFarAt), 0.0f, float(VALUE_RESOLUTION-1), m_quadVertices.left, m_quadVertices.right );
            m_sprBarely->SetX( fX );
        }
        else
        {
            m_sprBarely->SetVisible( false );
        }
        this->AddChild( m_sprBarely );
    }
}
Beispiel #2
0
void ComboGraph::Set( const StageStats &s, const PlayerStageStats &pss )
{
	using std::max;
	const float fFirstSecond = 0;
	const float fLastSecond = s.GetTotalPossibleStepsSeconds();

	// Find the largest combo.
	int iMaxComboSize = 0;
	for( unsigned i = 0; i < pss.m_ComboList.size(); ++i )
		iMaxComboSize = max( iMaxComboSize, pss.m_ComboList[i].GetStageCnt() );

	for( unsigned i = 0; i < pss.m_ComboList.size(); ++i )
	{
		const PlayerStageStats::Combo_t &combo = pss.m_ComboList[i];
		if( combo.GetStageCnt() < MinComboSizeToShow )
			continue; // too small

		const bool bIsMax = (combo.GetStageCnt() == iMaxComboSize);

		LOG->Trace( "combo %i is %f+%f of %f", i, combo.m_fStartSecond, combo.m_fSizeSeconds, fLastSecond );
		Actor *pSprite = bIsMax? m_pMaxCombo->Copy() : m_pNormalCombo->Copy();

		const float fStart = Rage::scale( combo.m_fStartSecond, fFirstSecond, fLastSecond, 0.0f, 1.0f );
		const float fSize = Rage::scale( combo.m_fSizeSeconds, 0.f, fLastSecond-fFirstSecond, 0.0f, 1.0f );
		pSprite->SetCropLeft ( Rage::scale( fSize, 0.0f, 1.0f, 0.5f, 0.0f ) );
		pSprite->SetCropRight( Rage::scale( fSize, 0.0f, 1.0f, 0.5f, 0.0f ) );

		pSprite->SetCropLeft( fStart );
		pSprite->SetCropRight( 1 - (fSize + fStart) );

		this->AddChild( pSprite );
	}

	for( unsigned i = 0; i < pss.m_ComboList.size(); ++i )
	{
		const PlayerStageStats::Combo_t &combo = pss.m_ComboList[i];
		if( combo.GetStageCnt() < MinComboSizeToShow )
			continue; // too small

		if( !iMaxComboSize )
			continue;

		const bool bIsMax = (combo.GetStageCnt() == iMaxComboSize);
		if( !bIsMax )
			continue;

		BitmapText *pText = m_pComboNumber->Copy();

		const float fStart = Rage::scale( combo.m_fStartSecond, fFirstSecond, fLastSecond, 0.0f, 1.0f );
		const float fSize = Rage::scale( combo.m_fSizeSeconds, 0.f, fLastSecond-fFirstSecond, 0.0f, 1.0f );

		const float fCenterPercent = fStart + fSize/2;
		const float fCenterXPos = Rage::scale( fCenterPercent, 0.0f, 1.0f, -BODY_WIDTH/2.0f, BODY_WIDTH/2.0f );
		pText->SetX( fCenterXPos );

		pText->SetText( fmt::sprintf("%i",combo.GetStageCnt()) );

		this->AddChild( pText );
	}

	// Hide the templates.
	m_pNormalCombo->SetVisible( false );
	m_pMaxCombo->SetVisible( false );
	m_pComboNumber->SetVisible( false );
}