2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2001-12-28 10:15:59 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
File: BPMDisplay.h
|
|
|
|
|
|
|
|
|
|
Desc: A graphic displayed in the BPMDisplay during Dancing.
|
|
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2001-12-28 10:15:59 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "BPMDisplay.h"
|
|
|
|
|
#include "RageUtil.h"
|
2002-05-01 19:14:55 +00:00
|
|
|
#include "GameConstantsAndTypes.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "PrefsManager.h"
|
2002-08-28 22:42:40 +00:00
|
|
|
#include "GameState.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2001-12-28 10:15:59 +00:00
|
|
|
|
|
|
|
|
|
2003-02-23 01:32:39 +00:00
|
|
|
#define NORMAL_COLOR THEME->GetMetricC("BPMDisplay","NormalColor")
|
|
|
|
|
#define CHANGE_COLOR THEME->GetMetricC("BPMDisplay","ChangeColor")
|
|
|
|
|
#define EXTRA_COLOR THEME->GetMetricC("BPMDisplay","ExtraColor")
|
2002-08-28 22:42:40 +00:00
|
|
|
|
2001-12-28 10:15:59 +00:00
|
|
|
|
|
|
|
|
BPMDisplay::BPMDisplay()
|
|
|
|
|
{
|
|
|
|
|
m_fCurrentBPM = m_fLowBPM = m_fHighBPM = 0;
|
|
|
|
|
m_fTimeLeftInState = 0;
|
2003-03-30 19:30:54 +00:00
|
|
|
m_CountingState = holding_down;
|
2001-12-28 10:15:59 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_textBPM.LoadFromNumbers( THEME->GetPathToN("BPMDisplay") );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_textBPM.EnableShadow( false );
|
2003-02-23 01:32:39 +00:00
|
|
|
m_textBPM.SetHorizAlign( Actor::align_right );
|
|
|
|
|
m_textBPM.SetDiffuse( NORMAL_COLOR );
|
2003-02-23 01:53:36 +00:00
|
|
|
m_textBPM.SetXY( 0, 0 );
|
2003-02-23 01:32:39 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_sprLabel.Load( THEME->GetPathToG("BPMDisplay label") );
|
2003-03-02 01:43:33 +00:00
|
|
|
m_sprLabel.EnableShadow( false );
|
2003-02-23 01:32:39 +00:00
|
|
|
m_sprLabel.SetDiffuse( NORMAL_COLOR );
|
|
|
|
|
m_sprLabel.SetHorizAlign( Actor::align_left );
|
|
|
|
|
m_sprLabel.SetXY( 0, 0 );
|
|
|
|
|
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textBPM );
|
2003-02-23 01:32:39 +00:00
|
|
|
this->AddChild( &m_sprLabel );
|
2001-12-28 10:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BPMDisplay::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
ActorFrame::Update( fDeltaTime );
|
|
|
|
|
|
2003-03-30 19:30:54 +00:00
|
|
|
m_fTimeLeftInState -= fDeltaTime;
|
|
|
|
|
if( m_fTimeLeftInState < 0 )
|
2001-12-28 10:15:59 +00:00
|
|
|
{
|
2003-03-30 19:30:54 +00:00
|
|
|
// go to next state
|
|
|
|
|
switch( m_CountingState )
|
2001-12-28 10:15:59 +00:00
|
|
|
{
|
2003-03-30 19:30:54 +00:00
|
|
|
case counting_up:
|
|
|
|
|
m_CountingState = holding_up;
|
|
|
|
|
m_fTimeLeftInState = 1; // reset timer
|
|
|
|
|
break;
|
|
|
|
|
case holding_up:
|
|
|
|
|
m_CountingState = counting_down;
|
|
|
|
|
m_fTimeLeftInState = 1; // reset timer
|
|
|
|
|
break;
|
|
|
|
|
case counting_down:
|
|
|
|
|
m_CountingState = holding_down;
|
|
|
|
|
m_fTimeLeftInState = 1; // reset timer
|
|
|
|
|
break;
|
|
|
|
|
case holding_down:
|
|
|
|
|
m_CountingState = counting_up;
|
|
|
|
|
m_fTimeLeftInState = 1; // reset timer
|
|
|
|
|
break;
|
|
|
|
|
case cycle_randomly:
|
2003-03-30 18:12:57 +00:00
|
|
|
m_textBPM.SetText( (RandomFloat(0,1)>0.90) ? "xxx" : ssprintf("%03.0f",RandomFloat(0,600)) );
|
2002-08-28 22:42:40 +00:00
|
|
|
m_fTimeLeftInState = 0.2f; // reset timer
|
2003-03-30 19:30:54 +00:00
|
|
|
break;
|
|
|
|
|
case no_bpm:
|
|
|
|
|
m_fTimeLeftInState = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
2001-12-28 10:15:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-03-30 19:30:54 +00:00
|
|
|
|
|
|
|
|
// update m_fCurrentBPM
|
2003-05-13 13:47:08 +00:00
|
|
|
// int iLastCurBPM = (int)m_fCurrentBPM;
|
2003-03-30 19:30:54 +00:00
|
|
|
switch( m_CountingState )
|
2001-12-28 10:15:59 +00:00
|
|
|
{
|
2003-03-30 19:30:54 +00:00
|
|
|
case counting_down: m_fCurrentBPM = m_fLowBPM + (m_fHighBPM-m_fLowBPM)*m_fTimeLeftInState; break;
|
|
|
|
|
case counting_up: m_fCurrentBPM = m_fHighBPM + (m_fLowBPM-m_fHighBPM)*m_fTimeLeftInState; break;
|
|
|
|
|
case holding_up: m_fCurrentBPM = m_fHighBPM; break;
|
|
|
|
|
case holding_down: m_fCurrentBPM = m_fLowBPM; break;
|
|
|
|
|
case cycle_randomly: break;
|
|
|
|
|
case no_bpm: break;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
|
|
|
|
}
|
2002-08-28 22:42:40 +00:00
|
|
|
|
2003-03-30 19:30:54 +00:00
|
|
|
// update text
|
|
|
|
|
switch( m_CountingState )
|
|
|
|
|
{
|
|
|
|
|
case counting_down:
|
|
|
|
|
case counting_up:
|
|
|
|
|
case holding_up:
|
|
|
|
|
case holding_down:
|
2003-05-12 11:17:09 +00:00
|
|
|
//if( (int)m_fCurrentBPM != iLastCurBPM )
|
|
|
|
|
// m_textBPM.SetText( ssprintf("%03.0f", m_fCurrentBPM) );
|
|
|
|
|
|
|
|
|
|
/* BUG FIXED:: Just set the BPM.. This was causing an error that would not change
|
|
|
|
|
the BPM to what it should be, if you changed the selection from a Group
|
|
|
|
|
to a song. There's no great reason to check if it is higher or lower
|
|
|
|
|
than the previous BPM -- Miryokuteki */
|
|
|
|
|
m_textBPM.SetText( ssprintf("%03.0f", m_fCurrentBPM) );
|
2003-03-30 19:30:54 +00:00
|
|
|
break;
|
2001-12-28 10:15:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BPMDisplay::SetBPMRange( float fLowBPM, float fHighBPM )
|
|
|
|
|
{
|
|
|
|
|
m_fLowBPM = fLowBPM;
|
|
|
|
|
m_fHighBPM = fHighBPM;
|
|
|
|
|
if( m_fCurrentBPM > m_fHighBPM )
|
|
|
|
|
m_CountingState = counting_down;
|
|
|
|
|
else
|
|
|
|
|
m_CountingState = counting_up;
|
|
|
|
|
m_fTimeLeftInState = 1;
|
|
|
|
|
|
2002-09-02 21:59:58 +00:00
|
|
|
m_textBPM.StopTweening();
|
2003-02-23 01:32:39 +00:00
|
|
|
m_sprLabel.StopTweening();
|
2002-08-28 22:42:40 +00:00
|
|
|
m_textBPM.BeginTweening(0.5f);
|
2003-02-23 01:32:39 +00:00
|
|
|
m_sprLabel.BeginTweening(0.5f);
|
2002-08-28 22:42:40 +00:00
|
|
|
|
|
|
|
|
if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() )
|
|
|
|
|
{
|
2003-04-12 06:16:12 +00:00
|
|
|
m_textBPM.SetDiffuse( EXTRA_COLOR );
|
|
|
|
|
m_sprLabel.SetDiffuse( EXTRA_COLOR );
|
2002-08-28 22:42:40 +00:00
|
|
|
}
|
|
|
|
|
else if( m_fLowBPM != m_fHighBPM )
|
2001-12-28 10:15:59 +00:00
|
|
|
{
|
2003-04-12 06:16:12 +00:00
|
|
|
m_textBPM.SetDiffuse( CHANGE_COLOR );
|
|
|
|
|
m_sprLabel.SetDiffuse( CHANGE_COLOR );
|
2001-12-28 10:15:59 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-04-12 06:16:12 +00:00
|
|
|
m_textBPM.SetDiffuse( NORMAL_COLOR );
|
|
|
|
|
m_sprLabel.SetDiffuse( NORMAL_COLOR );
|
2001-12-28 10:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
2003-02-16 04:56:36 +00:00
|
|
|
}
|
2003-03-30 19:30:54 +00:00
|
|
|
|
|
|
|
|
void BPMDisplay::CycleRandomly()
|
|
|
|
|
{
|
|
|
|
|
m_CountingState = cycle_randomly;
|
|
|
|
|
m_fTimeLeftInState = 0;
|
2003-03-30 21:02:15 +00:00
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_textBPM.SetDiffuse( NORMAL_COLOR );
|
|
|
|
|
m_sprLabel.SetDiffuse( NORMAL_COLOR );
|
2003-03-30 19:30:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BPMDisplay::NoBPM()
|
|
|
|
|
{
|
|
|
|
|
m_CountingState = no_bpm;
|
|
|
|
|
m_textBPM.SetText( "..." );
|
2003-03-30 21:02:15 +00:00
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
m_textBPM.SetDiffuse( NORMAL_COLOR );
|
|
|
|
|
m_sprLabel.SetDiffuse( NORMAL_COLOR );
|
2003-03-30 19:30:54 +00:00
|
|
|
}
|