2003-10-23 06:15:10 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "ComboGraph.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
#include "RageLog.h"
|
2003-12-22 23:27:54 +00:00
|
|
|
#include "StageStats.h"
|
2003-12-28 06:00:27 +00:00
|
|
|
#include "ActorUtil.h"
|
2003-10-23 06:15:10 +00:00
|
|
|
|
|
|
|
|
const int MinComboSizeToShow = 5;
|
|
|
|
|
|
|
|
|
|
void ComboGraph::Load( CString Path, const StageStats &s, PlayerNumber pn )
|
|
|
|
|
{
|
2003-12-28 06:00:27 +00:00
|
|
|
ASSERT( m_SubActors.size() == 0 );
|
2003-10-23 06:15:10 +00:00
|
|
|
|
|
|
|
|
/* Find the largest combo. */
|
|
|
|
|
int MaxComboSize = 0;
|
|
|
|
|
unsigned i;
|
|
|
|
|
for( i = 0; i < s.ComboList[pn].size(); ++i )
|
2003-12-22 23:25:33 +00:00
|
|
|
MaxComboSize = max( MaxComboSize, s.ComboList[pn][i].GetStageCnt() );
|
2003-10-23 06:15:10 +00:00
|
|
|
|
|
|
|
|
float width = -1;
|
|
|
|
|
for( i = 0; i < s.ComboList[pn].size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
const StageStats::Combo_t &combo = s.ComboList[pn][i];
|
2003-12-22 23:25:33 +00:00
|
|
|
if( combo.GetStageCnt() < MinComboSizeToShow )
|
2003-10-23 06:15:10 +00:00
|
|
|
continue; /* too small */
|
|
|
|
|
|
2003-12-22 23:25:33 +00:00
|
|
|
const bool IsMax = (combo.GetStageCnt() == MaxComboSize);
|
2003-10-23 06:15:10 +00:00
|
|
|
|
|
|
|
|
LOG->Trace("combo %i is %f+%f", i, combo.start, combo.size);
|
|
|
|
|
Sprite *sprite = new Sprite;
|
2003-12-28 06:00:27 +00:00
|
|
|
sprite->SetName( "ComboBar" );
|
2003-10-23 06:15:10 +00:00
|
|
|
const CString path = ssprintf( "%s %s", Path.c_str(), IsMax? "max":"normal" );
|
|
|
|
|
sprite->Load( THEME->GetPathToG(path) );
|
|
|
|
|
|
2003-12-22 01:55:03 +00:00
|
|
|
const float start = SCALE( combo.start, s.fFirstPos[pn], s.fLastPos[pn], 0.0f, 1.0f );
|
|
|
|
|
const float size = SCALE( combo.size, 0, s.fLastPos[pn]-s.fFirstPos[pn], 0.0f, 1.0f );
|
|
|
|
|
sprite->SetCropLeft ( SCALE( size, 0.0f, 1.0f, 0.5f, 0.0f ) );
|
|
|
|
|
sprite->SetCropRight( SCALE( size, 0.0f, 1.0f, 0.5f, 0.0f ) );
|
2003-10-23 06:15:10 +00:00
|
|
|
|
|
|
|
|
sprite->BeginTweening( .5f );
|
2003-12-22 01:55:03 +00:00
|
|
|
sprite->SetCropLeft( start );
|
|
|
|
|
sprite->SetCropRight( 1 - (size + start) );
|
2003-10-23 06:15:10 +00:00
|
|
|
|
|
|
|
|
if( width < 0 )
|
|
|
|
|
width = sprite->GetUnzoomedWidth();
|
|
|
|
|
|
2003-12-28 06:00:27 +00:00
|
|
|
m_Sprites.push_back( sprite );
|
2003-10-23 06:15:10 +00:00
|
|
|
this->AddChild( sprite );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < s.ComboList[pn].size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
const StageStats::Combo_t &combo = s.ComboList[pn][i];
|
2003-12-22 23:25:33 +00:00
|
|
|
if( combo.GetStageCnt() < MinComboSizeToShow )
|
2003-10-23 06:15:10 +00:00
|
|
|
continue; /* too small */
|
|
|
|
|
|
2003-12-23 04:44:34 +00:00
|
|
|
if( !MaxComboSize )
|
|
|
|
|
continue;
|
|
|
|
|
|
2003-12-22 23:25:33 +00:00
|
|
|
const bool IsMax = (combo.GetStageCnt() == MaxComboSize);
|
2003-10-23 06:15:10 +00:00
|
|
|
if( !IsMax )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
BitmapText *text = new BitmapText;
|
2003-12-28 06:00:27 +00:00
|
|
|
text->SetName( "ComboMaxNumber" );
|
2003-10-23 06:15:10 +00:00
|
|
|
text->LoadFromFont( THEME->GetPathToF(Path) );
|
|
|
|
|
|
2003-12-22 01:55:03 +00:00
|
|
|
const float start = SCALE( combo.start, s.fFirstPos[pn], s.fLastPos[pn], 0.0f, 1.0f );
|
|
|
|
|
const float size = SCALE( combo.size, 0, s.fLastPos[pn]-s.fFirstPos[pn], 0.0f, 1.0f );
|
|
|
|
|
|
|
|
|
|
const float CenterPercent = start + size/2;
|
2003-10-23 06:15:10 +00:00
|
|
|
const float CenterXPos = SCALE( CenterPercent, 0.0f, 1.0f, -width/2.0f, width/2.0f );
|
|
|
|
|
text->SetX( CenterXPos );
|
|
|
|
|
|
2003-12-22 23:25:33 +00:00
|
|
|
text->SetText( ssprintf("%i",combo.GetStageCnt()) );
|
2003-12-28 06:00:27 +00:00
|
|
|
ON_COMMAND( text );
|
2003-10-23 06:15:10 +00:00
|
|
|
|
2003-12-28 06:00:27 +00:00
|
|
|
m_Numbers.push_back( text );
|
2003-10-23 06:15:10 +00:00
|
|
|
this->AddChild( text );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-28 06:00:27 +00:00
|
|
|
void ComboGraph::TweenOffScreen()
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i = 0; i < m_SubActors.size(); ++i )
|
|
|
|
|
OFF_COMMAND( m_SubActors[i] );
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-23 06:15:10 +00:00
|
|
|
void ComboGraph::Unload()
|
|
|
|
|
{
|
2003-12-28 06:00:27 +00:00
|
|
|
for( unsigned i = 0; i < m_SubActors.size(); ++i )
|
|
|
|
|
delete m_SubActors[i];
|
2003-10-23 06:15:10 +00:00
|
|
|
|
2003-12-28 06:00:27 +00:00
|
|
|
m_Sprites.clear();
|
|
|
|
|
m_Numbers.clear();
|
2003-10-23 06:15:10 +00:00
|
|
|
m_SubActors.clear();
|
|
|
|
|
}
|
|
|
|
|
|