Files
itgmania212121/stepmania/src/Combo.cpp
T

185 lines
6.1 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-02-24 01:43:11 +00:00
#include "Combo.h"
#include "ThemeManager.h"
2005-02-16 03:25:45 +00:00
#include "StatsManager.h"
2004-03-10 07:54:12 +00:00
#include "GameState.h"
2004-03-13 01:47:52 +00:00
#include "song.h"
2005-05-01 22:59:00 +00:00
#include "PlayerState.h"
2002-02-24 01:43:11 +00:00
2005-02-26 05:45:51 +00:00
Combo::Combo()
{
2005-04-29 03:04:16 +00:00
m_iLastSeenCombo = -1;
2005-05-01 22:59:00 +00:00
m_pPlayerState = NULL;
m_pPlayerStageStats = NULL;
this->SubscribeToMessage( Message_BeatCrossed );
2005-02-26 05:45:51 +00:00
}
2002-02-24 01:43:11 +00:00
2005-05-01 22:59:00 +00:00
void Combo::Load( PlayerState *pPlayerState, PlayerStageStats *pPlayerStageStats )
2005-02-26 05:45:51 +00:00
{
2005-04-29 03:04:16 +00:00
ASSERT( m_SubActors.empty() ); // don't load twice
2005-05-01 22:59:00 +00:00
m_pPlayerState = pPlayerState;
m_pPlayerStageStats = pPlayerStageStats;
2002-08-26 08:11:52 +00:00
2005-04-29 03:04:16 +00:00
SHOW_COMBO_AT .Load(m_sName,"ShowComboAt");
2006-03-01 10:21:12 +00:00
LABEL_X .Load(m_sName,"LabelX");
LABEL_Y .Load(m_sName,"LabelY");
2005-04-29 03:04:16 +00:00
LABEL_ON_COMMAND .Load(m_sName,"LabelOnCommand");
2006-03-01 10:21:12 +00:00
NUMBER_X .Load(m_sName,"NumberX");
NUMBER_Y .Load(m_sName,"NumberY");
2005-04-29 03:04:16 +00:00
NUMBER_ON_COMMAND .Load(m_sName,"NumberOnCommand");
NUMBER_MIN_ZOOM .Load(m_sName,"NumberMinZoom");
NUMBER_MAX_ZOOM .Load(m_sName,"NumberMaxZoom");
NUMBER_MAX_ZOOM_AT .Load(m_sName,"NumberMaxZoomAt");
PULSE_COMMAND .Load(m_sName,"PulseCommand");
FULL_COMBO_W3_COMMAND .Load(m_sName,"FullComboW3Command");
FULL_COMBO_W2_COMMAND .Load(m_sName,"FullComboW2Command");
FULL_COMBO_W1_COMMAND .Load(m_sName,"FullComboW1Command");
FULL_COMBO_BROKEN_COMMAND .Load(m_sName,"FullComboBrokenCommand");
2006-03-01 10:21:12 +00:00
MISS_COMBO_COMMAND .Load(m_sName,"MissComboCommand");
2005-04-29 03:04:16 +00:00
2005-05-02 03:31:53 +00:00
m_spr100Milestone.Load( THEME->GetPathG(m_sName,"100milestone") );
this->AddChild( m_spr100Milestone );
m_spr1000Milestone.Load( THEME->GetPathG(m_sName,"1000milestone") );
this->AddChild( m_spr1000Milestone );
2002-08-26 08:11:52 +00:00
2005-02-26 05:45:51 +00:00
m_sprComboLabel.Load( THEME->GetPathG(m_sName,"label") );
2005-04-29 03:04:16 +00:00
m_sprComboLabel->StopAnimating();
m_sprComboLabel->SetXY( LABEL_X, LABEL_Y );
m_sprComboLabel->RunCommands( LABEL_ON_COMMAND );
m_sprComboLabel->SetHidden( true );
this->AddChild( m_sprComboLabel );
2004-07-31 21:26:11 +00:00
2005-02-26 05:45:51 +00:00
m_sprMissesLabel.Load( THEME->GetPathG(m_sName,"misses") );
2005-04-29 03:04:16 +00:00
m_sprMissesLabel->StopAnimating();
m_sprMissesLabel->SetXY( LABEL_X, LABEL_Y );
m_sprMissesLabel->RunCommands( LABEL_ON_COMMAND );
m_sprMissesLabel->SetHidden( true );
this->AddChild( m_sprMissesLabel );
2004-07-31 21:26:11 +00:00
2005-02-26 05:45:51 +00:00
m_textNumber.LoadFromFont( THEME->GetPathF(m_sName,"numbers") );
2004-07-31 21:26:11 +00:00
m_textNumber.SetXY( NUMBER_X, NUMBER_Y );
2005-04-28 22:32:06 +00:00
m_textNumber.RunCommands( NUMBER_ON_COMMAND );
2004-07-31 21:26:11 +00:00
m_textNumber.SetHidden( true );
2005-04-29 03:04:16 +00:00
this->AddChild( &m_textNumber );
2003-02-17 12:19:42 +00:00
}
2002-02-24 01:43:11 +00:00
2004-07-31 21:26:11 +00:00
void Combo::SetCombo( int iCombo, int iMisses )
2002-02-24 01:43:11 +00:00
{
bool bComboOfMisses = iMisses > 0;
int iNum = bComboOfMisses ? iMisses : iCombo;
bool bShowCombo = iNum >= (int)SHOW_COMBO_AT;
2004-07-31 21:26:11 +00:00
if( !bShowCombo )
{
2005-04-29 03:04:16 +00:00
m_sprComboLabel->SetHidden( true );
m_sprMissesLabel->SetHidden( true );
2004-07-31 21:26:11 +00:00
m_textNumber.SetHidden( true );
return;
}
2005-04-29 03:04:16 +00:00
if( m_iLastSeenCombo == -1 ) // first update, don't set bIsMilestone=true
m_iLastSeenCombo = iCombo;
2005-05-02 03:31:53 +00:00
bool b100Milestone = false;
bool b1000Milestone = false;
2005-04-29 03:04:16 +00:00
for( int i=m_iLastSeenCombo+1; i<=iCombo; i++ )
{
if( i < 600 )
2005-05-02 03:31:53 +00:00
b100Milestone |= ((i % 100) == 0);
2005-04-29 03:04:16 +00:00
else
b1000Milestone |= ((i % 200) == 0);
2005-04-29 03:04:16 +00:00
}
m_iLastSeenCombo = iCombo;
m_sprComboLabel->SetHidden( bComboOfMisses );
m_sprMissesLabel->SetHidden( !bComboOfMisses );
2004-07-31 21:26:11 +00:00
m_textNumber.SetHidden( false );
2003-03-16 20:55:45 +00:00
2006-01-22 01:00:06 +00:00
RString txt = ssprintf("%d", iNum);
2005-05-01 22:59:00 +00:00
// Do pulse even if the number isn't changing.
2004-07-31 21:26:11 +00:00
m_textNumber.SetText( txt );
float fNumberZoom = SCALE(iNum,0.f,(float)NUMBER_MAX_ZOOM_AT,(float)NUMBER_MIN_ZOOM,(float)NUMBER_MAX_ZOOM);
CLAMP( fNumberZoom, (float)NUMBER_MIN_ZOOM, (float)NUMBER_MAX_ZOOM );
2005-04-29 03:04:16 +00:00
m_textNumber.FinishTweening();
2004-07-31 21:26:11 +00:00
m_textNumber.SetZoom( fNumberZoom );
2005-04-28 22:32:06 +00:00
m_textNumber.RunCommands( PULSE_COMMAND );
2003-03-16 20:55:45 +00:00
AutoActor &sprLabel = bComboOfMisses ? m_sprMissesLabel : m_sprComboLabel;
2005-04-29 03:04:16 +00:00
sprLabel->FinishTweening();
sprLabel->RunCommands( PULSE_COMMAND );
2004-03-10 07:54:12 +00:00
2005-05-02 03:31:53 +00:00
if( b100Milestone )
m_spr100Milestone->PlayCommand( "Milestone" );
if( b1000Milestone )
m_spr1000Milestone->PlayCommand( "Milestone" );
2004-03-10 07:54:12 +00:00
2004-07-31 21:26:11 +00:00
// don't show a colored combo until 1/4 of the way through the song
bool bPastMidpoint = GAMESTATE->GetCourseSongIndex()>0 ||
GAMESTATE->m_fMusicSeconds > GAMESTATE->m_pCurSong->m_fMusicLengthSeconds/4;
2004-03-10 07:54:12 +00:00
if( bComboOfMisses )
{
sprLabel->RunCommands( MISS_COMBO_COMMAND );
m_textNumber.RunCommands( MISS_COMBO_COMMAND );
}
else if( bPastMidpoint )
2004-07-31 21:26:11 +00:00
{
if( m_pPlayerStageStats->FullComboOfScore(TNS_W1) )
2004-07-31 21:26:11 +00:00
{
sprLabel->RunCommands( FULL_COMBO_W1_COMMAND );
m_textNumber.RunCommands( FULL_COMBO_W1_COMMAND );
2004-07-31 21:26:11 +00:00
}
else if( bPastMidpoint && m_pPlayerStageStats->FullComboOfScore(TNS_W2) )
2004-07-31 21:26:11 +00:00
{
sprLabel->RunCommands( FULL_COMBO_W2_COMMAND );
m_textNumber.RunCommands( FULL_COMBO_W2_COMMAND );
2004-07-31 21:26:11 +00:00
}
else if( bPastMidpoint && m_pPlayerStageStats->FullComboOfScore(TNS_W3) )
2004-03-10 07:54:12 +00:00
{
sprLabel->RunCommands( FULL_COMBO_W3_COMMAND );
m_textNumber.RunCommands( FULL_COMBO_W3_COMMAND );
2004-03-10 07:54:12 +00:00
}
else
{
2005-04-29 03:04:16 +00:00
sprLabel->RunCommands( FULL_COMBO_BROKEN_COMMAND );
2004-12-03 05:19:46 +00:00
m_textNumber.RunCommands( FULL_COMBO_BROKEN_COMMAND );
2004-03-10 07:54:12 +00:00
}
}
2003-03-16 20:55:45 +00:00
else
2003-01-13 08:31:34 +00:00
{
2005-04-29 03:04:16 +00:00
sprLabel->RunCommands( FULL_COMBO_BROKEN_COMMAND );
2004-12-03 05:19:46 +00:00
m_textNumber.RunCommands( FULL_COMBO_BROKEN_COMMAND );
2002-02-24 01:43:11 +00:00
}
}
2004-06-08 00:08:04 +00:00
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/