2004-07-22 21:02:07 +00:00
|
|
|
/*
|
|
|
|
|
* This stores a single note pattern for a song.
|
|
|
|
|
*
|
|
|
|
|
* We can have too much data to keep everything decompressed as NoteData, so most
|
|
|
|
|
* songs are kept in memory compressed as SMData until requested. NoteData is normally
|
|
|
|
|
* not requested casually during gameplay; we can move through screens, the music
|
|
|
|
|
* wheel, etc. without touching any NoteData.
|
|
|
|
|
*
|
|
|
|
|
* To save more memory, if data is cached on disk, read it from disk on demand. Not
|
|
|
|
|
* all Steps will have an associated file for this purpose. (Profile edits don't do
|
|
|
|
|
* this yet.)
|
|
|
|
|
*
|
|
|
|
|
* Data can be on disk (always compressed), compressed in memory, and uncompressed in
|
|
|
|
|
* memory.
|
|
|
|
|
*/
|
2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2003-08-03 00:57:20 +00:00
|
|
|
#include "Steps.h"
|
2004-07-22 21:02:07 +00:00
|
|
|
#include "StepsUtil.h"
|
2005-07-03 03:05:54 +00:00
|
|
|
#include "song.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "RageLog.h"
|
2002-07-03 03:13:13 +00:00
|
|
|
#include "NoteData.h"
|
2002-08-23 00:22:27 +00:00
|
|
|
#include "GameManager.h"
|
2003-08-07 06:36:34 +00:00
|
|
|
#include "NoteDataUtil.h"
|
2004-07-22 21:02:07 +00:00
|
|
|
#include "NotesLoaderSM.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2006-07-28 03:34:14 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
Steps::Steps()
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2005-03-08 07:57:14 +00:00
|
|
|
m_bSavedToDisk = false;
|
2006-09-26 20:28:46 +00:00
|
|
|
m_StepsType = StepsType_Invalid;
|
2006-10-07 03:32:16 +00:00
|
|
|
m_LoadedFromProfile = ProfileSlot_Invalid;
|
2006-08-23 20:45:30 +00:00
|
|
|
m_iHash = 0;
|
2006-10-07 04:39:48 +00:00
|
|
|
m_Difficulty = Difficulty_Invalid;
|
2002-05-20 08:59:37 +00:00
|
|
|
m_iMeter = 0;
|
2002-06-30 23:19:33 +00:00
|
|
|
|
2005-07-01 04:38:41 +00:00
|
|
|
m_pNoteData = new NoteData;
|
2005-03-08 21:17:21 +00:00
|
|
|
m_bNoteDataIsFilled = false;
|
|
|
|
|
m_sNoteDataCompressed = "";
|
2003-01-02 22:10:51 +00:00
|
|
|
parent = NULL;
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
Steps::~Steps()
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-23 20:42:26 +00:00
|
|
|
unsigned Steps::GetHash() const
|
|
|
|
|
{
|
|
|
|
|
if( parent )
|
|
|
|
|
return parent->GetHash();
|
2006-08-23 20:45:30 +00:00
|
|
|
if( m_iHash )
|
|
|
|
|
return m_iHash;
|
2006-08-23 20:42:26 +00:00
|
|
|
if( m_sNoteDataCompressed.empty() )
|
|
|
|
|
{
|
|
|
|
|
if( !m_bNoteDataIsFilled )
|
|
|
|
|
return 0; // No data, no hash.
|
|
|
|
|
NoteDataUtil::GetSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed );
|
|
|
|
|
}
|
2006-08-23 20:45:30 +00:00
|
|
|
m_iHash = GetHashForString( m_sNoteDataCompressed );
|
|
|
|
|
return m_iHash;
|
2006-08-23 20:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
2004-10-23 17:43:49 +00:00
|
|
|
void Steps::SetNoteData( const NoteData& noteDataNew )
|
2002-07-03 21:27:26 +00:00
|
|
|
{
|
2004-10-23 17:43:49 +00:00
|
|
|
ASSERT( noteDataNew.GetNumTracks() == GameManager::StepsTypeToNumTracks(m_StepsType) );
|
2002-12-14 21:43:00 +00:00
|
|
|
|
2006-11-12 04:38:44 +00:00
|
|
|
DeAutogen( false );
|
2003-01-02 22:10:51 +00:00
|
|
|
|
2005-07-01 04:38:41 +00:00
|
|
|
*m_pNoteData = noteDataNew;
|
2005-03-08 21:17:21 +00:00
|
|
|
m_bNoteDataIsFilled = true;
|
2004-04-23 00:53:29 +00:00
|
|
|
|
2006-09-30 05:33:47 +00:00
|
|
|
m_sNoteDataCompressed = RString();
|
2006-08-23 20:45:30 +00:00
|
|
|
m_iHash = 0;
|
2006-09-30 05:33:47 +00:00
|
|
|
m_sFilename = RString(); // We can no longer read from the file because it has changed in memory.
|
2002-07-03 21:27:26 +00:00
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2004-10-23 17:43:49 +00:00
|
|
|
void Steps::GetNoteData( NoteData& noteDataOut ) const
|
2002-07-03 03:13:13 +00:00
|
|
|
{
|
2002-12-14 21:43:00 +00:00
|
|
|
Decompress();
|
2003-07-15 19:40:41 +00:00
|
|
|
|
2005-03-08 21:17:21 +00:00
|
|
|
if( m_bNoteDataIsFilled )
|
|
|
|
|
{
|
2005-07-01 04:38:41 +00:00
|
|
|
noteDataOut = *m_pNoteData;
|
2005-03-08 21:17:21 +00:00
|
|
|
}
|
2003-07-15 19:40:41 +00:00
|
|
|
else
|
|
|
|
|
{
|
2004-10-23 17:43:49 +00:00
|
|
|
noteDataOut.ClearAll();
|
|
|
|
|
noteDataOut.SetNumTracks( GameManager::StepsTypeToNumTracks(m_StepsType) );
|
2003-07-15 19:40:41 +00:00
|
|
|
}
|
2002-07-03 03:13:13 +00:00
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void Steps::SetSMNoteData( const RString ¬es_comp_ )
|
2002-12-14 21:33:29 +00:00
|
|
|
{
|
2005-07-01 04:38:41 +00:00
|
|
|
m_pNoteData->Init();
|
2005-03-08 21:17:21 +00:00
|
|
|
m_bNoteDataIsFilled = false;
|
2002-12-14 21:43:00 +00:00
|
|
|
|
2005-03-08 21:17:21 +00:00
|
|
|
m_sNoteDataCompressed = notes_comp_;
|
2006-08-23 20:45:30 +00:00
|
|
|
m_iHash = 0;
|
2006-09-30 05:33:47 +00:00
|
|
|
m_sFilename = RString(); // We can no longer read from the file because it has changed in memory.
|
2002-12-14 21:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-28 06:15:01 +00:00
|
|
|
/* XXX: this function should pull data from m_sFilename, like Decompress() */
|
2006-01-22 01:00:06 +00:00
|
|
|
void Steps::GetSMNoteData( RString ¬es_comp_out ) const
|
2002-12-14 21:33:29 +00:00
|
|
|
{
|
2005-03-08 21:17:21 +00:00
|
|
|
if( m_sNoteDataCompressed.empty() )
|
2002-12-14 21:43:00 +00:00
|
|
|
{
|
2005-03-08 21:17:21 +00:00
|
|
|
if( !m_bNoteDataIsFilled )
|
2003-11-17 03:38:24 +00:00
|
|
|
{
|
|
|
|
|
/* no data is no data */
|
2004-10-23 23:41:49 +00:00
|
|
|
notes_comp_out = "";
|
2003-11-17 03:38:24 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-01 04:38:41 +00:00
|
|
|
NoteDataUtil::GetSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed );
|
2002-12-14 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-08 21:17:21 +00:00
|
|
|
notes_comp_out = m_sNoteDataCompressed;
|
2002-12-14 21:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
2003-12-18 21:24:30 +00:00
|
|
|
float Steps::PredictMeter() const
|
2003-12-18 20:35:46 +00:00
|
|
|
{
|
2003-12-19 03:18:52 +00:00
|
|
|
float pMeter = 0.775f;
|
|
|
|
|
|
2006-01-07 04:11:29 +00:00
|
|
|
const float RadarCoeffs[NUM_RadarCategory] =
|
2003-12-19 04:11:11 +00:00
|
|
|
{
|
|
|
|
|
10.1f, 5.27f,-0.905f, -1.10f, 2.86f,
|
2005-04-25 09:35:22 +00:00
|
|
|
0,0,0,0,0,0
|
2003-12-19 04:11:11 +00:00
|
|
|
};
|
2006-07-28 03:34:14 +00:00
|
|
|
const RadarValues &rv = GetRadarValues( PLAYER_1 );
|
2006-01-07 04:11:29 +00:00
|
|
|
for( int r = 0; r < NUM_RadarCategory; ++r )
|
2006-07-28 03:34:14 +00:00
|
|
|
pMeter += rv[r] * RadarCoeffs[r];
|
2003-12-19 03:18:52 +00:00
|
|
|
|
2006-01-07 04:11:29 +00:00
|
|
|
const float DifficultyCoeffs[NUM_Difficulty] =
|
2003-12-19 04:11:11 +00:00
|
|
|
{
|
2004-02-08 01:05:53 +00:00
|
|
|
-0.877f, -0.877f, 0, 0.722f, 0.722f, 0
|
2003-12-19 04:11:11 +00:00
|
|
|
};
|
2003-12-19 03:35:23 +00:00
|
|
|
pMeter += DifficultyCoeffs[this->GetDifficulty()];
|
2003-12-19 03:18:52 +00:00
|
|
|
|
2003-12-18 21:23:52 +00:00
|
|
|
// Init non-radar values
|
2006-07-28 03:34:14 +00:00
|
|
|
const float SV = rv[RadarCategory_Stream] * rv[RadarCategory_Voltage];
|
|
|
|
|
const float ChaosSquare = rv[RadarCategory_Chaos] * rv[RadarCategory_Chaos];
|
2003-12-19 03:35:23 +00:00
|
|
|
pMeter += -6.35f * SV;
|
|
|
|
|
pMeter += -2.58f * ChaosSquare;
|
2003-12-22 18:26:17 +00:00
|
|
|
if (pMeter < 1) pMeter = 1;
|
2003-12-18 20:35:46 +00:00
|
|
|
return pMeter;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::TidyUpData()
|
2002-10-06 16:56:58 +00:00
|
|
|
{
|
2006-10-07 04:39:48 +00:00
|
|
|
if( GetDifficulty() == Difficulty_Invalid )
|
2003-12-03 00:28:17 +00:00
|
|
|
SetDifficulty( StringToDifficulty(GetDescription()) );
|
2003-01-21 22:23:01 +00:00
|
|
|
|
2006-10-07 04:39:48 +00:00
|
|
|
if( GetDifficulty() == Difficulty_Invalid )
|
2003-01-21 22:23:01 +00:00
|
|
|
{
|
2006-02-25 00:08:55 +00:00
|
|
|
if( GetMeter() == 1 ) SetDifficulty( DIFFICULTY_BEGINNER );
|
2003-12-03 00:28:17 +00:00
|
|
|
else if( GetMeter() <= 3 ) SetDifficulty( DIFFICULTY_EASY );
|
|
|
|
|
else if( GetMeter() <= 6 ) SetDifficulty( DIFFICULTY_MEDIUM );
|
2006-02-25 00:08:55 +00:00
|
|
|
else SetDifficulty( DIFFICULTY_HARD );
|
2002-10-06 16:56:58 +00:00
|
|
|
}
|
2003-12-03 00:28:17 +00:00
|
|
|
|
2003-02-05 23:40:52 +00:00
|
|
|
if( GetMeter() < 1) // meter is invalid
|
2003-12-19 07:28:32 +00:00
|
|
|
SetMeter( int(PredictMeter()) );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-03 21:43:29 +00:00
|
|
|
void Steps::CalculateRadarValues( float fMusicLengthSeconds )
|
|
|
|
|
{
|
|
|
|
|
// If we're autogen, don't calculate values. GetRadarValues will take from our parent.
|
|
|
|
|
if( parent != NULL )
|
|
|
|
|
return;
|
2006-07-28 03:34:14 +00:00
|
|
|
|
2006-04-04 21:42:21 +00:00
|
|
|
// Do write radar values, and leave it up to the reading app whether they want to trust
|
|
|
|
|
// the cached values without recalculating them.
|
|
|
|
|
/*
|
2005-04-03 21:43:29 +00:00
|
|
|
// If we're an edit, leave the RadarValues invalid.
|
|
|
|
|
if( IsAnEdit() )
|
|
|
|
|
return;
|
2006-04-04 21:42:21 +00:00
|
|
|
*/
|
2005-04-03 21:43:29 +00:00
|
|
|
|
|
|
|
|
NoteData tempNoteData;
|
|
|
|
|
this->GetNoteData( tempNoteData );
|
2006-07-28 03:34:14 +00:00
|
|
|
|
|
|
|
|
FOREACH_PlayerNumber( pn )
|
|
|
|
|
m_CachedRadarValues[pn].Zero();
|
|
|
|
|
|
|
|
|
|
if( tempNoteData.IsComposite() )
|
|
|
|
|
{
|
|
|
|
|
vector<NoteData> vParts;
|
|
|
|
|
|
|
|
|
|
NoteDataUtil::SplitCompositeNoteData( tempNoteData, vParts );
|
|
|
|
|
for( size_t pn = 0; pn < min(vParts.size(), size_t(NUM_PLAYERS)); ++pn )
|
|
|
|
|
NoteDataUtil::CalculateRadarValues( vParts[pn], fMusicLengthSeconds, m_CachedRadarValues[pn] );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NoteDataUtil::CalculateRadarValues( tempNoteData, fMusicLengthSeconds, m_CachedRadarValues[0] );
|
|
|
|
|
fill_n( m_CachedRadarValues + 1, NUM_PLAYERS-1, m_CachedRadarValues[0] );
|
|
|
|
|
}
|
2005-04-03 21:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::Decompress() const
|
2002-12-14 21:43:00 +00:00
|
|
|
{
|
2005-03-08 21:17:21 +00:00
|
|
|
if( m_bNoteDataIsFilled )
|
2003-03-13 01:26:50 +00:00
|
|
|
return; // already decompressed
|
2004-07-22 21:02:07 +00:00
|
|
|
|
2006-07-28 03:34:14 +00:00
|
|
|
if( parent )
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
2005-07-01 04:38:41 +00:00
|
|
|
// get autogen m_pNoteData
|
2004-10-23 17:43:49 +00:00
|
|
|
NoteData notedata;
|
|
|
|
|
parent->GetNoteData( notedata );
|
2003-01-02 22:10:51 +00:00
|
|
|
|
2005-03-08 21:17:21 +00:00
|
|
|
m_bNoteDataIsFilled = true;
|
2003-11-01 19:40:18 +00:00
|
|
|
|
2006-09-12 04:27:48 +00:00
|
|
|
int iNewTracks = GameManager::StepsTypeToNumTracks( m_StepsType );
|
2003-11-01 19:40:18 +00:00
|
|
|
|
2004-05-20 19:05:37 +00:00
|
|
|
if( this->m_StepsType == STEPS_TYPE_LIGHTS_CABINET )
|
|
|
|
|
{
|
2005-07-01 04:38:41 +00:00
|
|
|
NoteDataUtil::LoadTransformedLights( notedata, *m_pNoteData, iNewTracks );
|
2005-03-08 21:17:21 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-07-01 04:38:41 +00:00
|
|
|
NoteDataUtil::LoadTransformedSlidingWindow( notedata, *m_pNoteData, iNewTracks );
|
2003-11-01 19:40:18 +00:00
|
|
|
|
2005-07-01 04:38:41 +00:00
|
|
|
NoteDataUtil::RemoveStretch( *m_pNoteData, m_StepsType );
|
2004-05-20 19:05:37 +00:00
|
|
|
}
|
2004-07-22 21:02:07 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-08 21:17:21 +00:00
|
|
|
if( !m_sFilename.empty() && m_sNoteDataCompressed.empty() )
|
2004-07-22 21:02:07 +00:00
|
|
|
{
|
|
|
|
|
/* We have data on disk and not in memory. Load it. */
|
|
|
|
|
Song s;
|
|
|
|
|
SMLoader ld;
|
|
|
|
|
if( !ld.LoadFromSMFile( m_sFilename, s, true ) )
|
|
|
|
|
{
|
|
|
|
|
LOG->Warn( "Couldn't load \"%s\"", m_sFilename.c_str() );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find the steps. */
|
|
|
|
|
StepsID ID;
|
|
|
|
|
ID.FromSteps( this );
|
|
|
|
|
|
2004-08-12 04:49:15 +00:00
|
|
|
Steps *pSteps = ID.ToSteps( &s, true, false ); // don't use cache
|
2004-07-22 21:02:07 +00:00
|
|
|
if( pSteps == NULL )
|
|
|
|
|
{
|
|
|
|
|
LOG->Warn( "Couldn't find %s in \"%s\"", ID.ToString().c_str(), m_sFilename.c_str() );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-08 21:17:21 +00:00
|
|
|
pSteps->GetSMNoteData( m_sNoteDataCompressed );
|
2003-01-02 22:10:51 +00:00
|
|
|
}
|
2004-07-22 21:02:07 +00:00
|
|
|
|
2005-03-08 21:17:21 +00:00
|
|
|
if( m_sNoteDataCompressed.empty() )
|
2003-03-13 01:26:50 +00:00
|
|
|
{
|
2003-08-07 06:16:17 +00:00
|
|
|
/* there is no data, do nothing */
|
2003-03-13 01:26:50 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// load from compressed
|
2006-06-26 09:33:11 +00:00
|
|
|
bool bComposite = m_StepsType == STEPS_TYPE_DANCE_ROUTINE;
|
2005-03-08 21:17:21 +00:00
|
|
|
m_bNoteDataIsFilled = true;
|
2005-07-01 04:38:41 +00:00
|
|
|
m_pNoteData->SetNumTracks( GameManager::StepsTypeToNumTracks(m_StepsType) );
|
2003-01-02 22:10:51 +00:00
|
|
|
|
2006-06-26 09:33:11 +00:00
|
|
|
NoteDataUtil::LoadFromSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed, bComposite );
|
2003-03-13 01:26:50 +00:00
|
|
|
}
|
2002-12-14 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-03 00:57:20 +00:00
|
|
|
void Steps::Compress() const
|
2002-12-14 21:43:00 +00:00
|
|
|
{
|
2005-04-29 00:30:28 +00:00
|
|
|
/* Always leave lights data uncompressed. */
|
|
|
|
|
if( this->m_StepsType == STEPS_TYPE_LIGHTS_CABINET && m_bNoteDataIsFilled )
|
|
|
|
|
{
|
2006-09-30 05:33:47 +00:00
|
|
|
m_sNoteDataCompressed = RString();
|
2005-04-29 00:30:28 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-07 03:32:16 +00:00
|
|
|
if( !m_sFilename.empty() && m_LoadedFromProfile == ProfileSlot_Invalid )
|
2004-07-22 21:02:07 +00:00
|
|
|
{
|
2006-03-11 06:06:48 +00:00
|
|
|
/*
|
|
|
|
|
* We have a file on disk; clear all data in memory.
|
|
|
|
|
*
|
|
|
|
|
* Data on profiles can't be accessed normally (need to mount and time-out the
|
|
|
|
|
* device), and when we start a game and load edits, we want to be sure that
|
|
|
|
|
* it'll be available if the user picks it and pulls the device. Also,
|
|
|
|
|
* Decompress() doesn't know how to load .edits.
|
|
|
|
|
*/
|
2005-07-01 04:38:41 +00:00
|
|
|
m_pNoteData->Init();
|
2005-03-08 21:17:21 +00:00
|
|
|
m_bNoteDataIsFilled = false;
|
2004-10-30 07:18:28 +00:00
|
|
|
|
2005-03-08 21:17:21 +00:00
|
|
|
/* Be careful; 'x = ""', m_sNoteDataCompressed.clear() and m_sNoteDataCompressed.reserve(0)
|
2006-06-20 06:34:16 +00:00
|
|
|
* don't always free the allocated memory. */
|
2006-09-30 05:33:47 +00:00
|
|
|
m_sNoteDataCompressed = RString();
|
2005-04-28 06:15:01 +00:00
|
|
|
return;
|
2004-07-22 21:02:07 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-28 02:04:46 +00:00
|
|
|
/* We have no file on disk. Compress the data, if necessary. */
|
2005-03-08 21:17:21 +00:00
|
|
|
if( m_sNoteDataCompressed.empty() )
|
2002-12-14 21:43:00 +00:00
|
|
|
{
|
2005-04-28 06:15:01 +00:00
|
|
|
if( !m_bNoteDataIsFilled )
|
|
|
|
|
return; /* no data is no data */
|
2005-07-01 04:38:41 +00:00
|
|
|
NoteDataUtil::GetSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed );
|
2002-12-14 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
2005-07-01 04:38:41 +00:00
|
|
|
m_pNoteData->Init();
|
2005-03-08 21:17:21 +00:00
|
|
|
m_bNoteDataIsFilled = false;
|
2002-12-14 21:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-02 22:10:51 +00:00
|
|
|
/* Copy our parent's data. This is done when we're being changed from autogen
|
|
|
|
|
* to normal. (needed?) */
|
2006-11-12 04:38:44 +00:00
|
|
|
void Steps::DeAutogen( bool bCopyNoteData )
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
2006-07-28 03:34:14 +00:00
|
|
|
if( !parent )
|
2003-01-02 22:10:51 +00:00
|
|
|
return; /* OK */
|
|
|
|
|
|
2006-11-12 04:38:44 +00:00
|
|
|
if( bCopyNoteData )
|
|
|
|
|
Decompress(); // fills in m_pNoteData with sliding window transform
|
2003-03-13 01:26:50 +00:00
|
|
|
|
2006-02-25 00:08:55 +00:00
|
|
|
m_sDescription = Real()->m_sDescription;
|
|
|
|
|
m_Difficulty = Real()->m_Difficulty;
|
2004-02-07 05:57:19 +00:00
|
|
|
m_iMeter = Real()->m_iMeter;
|
2006-07-28 03:34:14 +00:00
|
|
|
copy( Real()->m_CachedRadarValues, Real()->m_CachedRadarValues + NUM_PLAYERS, m_CachedRadarValues );
|
2003-01-02 22:10:51 +00:00
|
|
|
|
|
|
|
|
parent = NULL;
|
2003-03-13 01:26:50 +00:00
|
|
|
|
2006-11-12 04:38:44 +00:00
|
|
|
if( bCopyNoteData )
|
|
|
|
|
Compress();
|
2003-01-02 22:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
2003-12-29 22:50:54 +00:00
|
|
|
void Steps::AutogenFrom( const Steps *parent_, StepsType ntTo )
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
parent = parent_;
|
2003-08-07 06:36:34 +00:00
|
|
|
m_StepsType = ntTo;
|
2003-01-02 22:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
2005-04-03 21:43:29 +00:00
|
|
|
void Steps::CopyFrom( Steps* pSource, StepsType ntTo, float fMusicLengthSeconds ) // pSource does not have to be of the same StepsType
|
2003-01-30 07:18:33 +00:00
|
|
|
{
|
2003-08-07 06:36:34 +00:00
|
|
|
m_StepsType = ntTo;
|
2003-01-30 07:18:33 +00:00
|
|
|
NoteData noteData;
|
2004-10-23 17:43:49 +00:00
|
|
|
pSource->GetNoteData( noteData );
|
2006-08-23 21:16:46 +00:00
|
|
|
noteData.SetNumTracks( GameManager::StepsTypeToNumTracks(ntTo) );
|
|
|
|
|
parent = NULL;
|
2004-10-23 17:43:49 +00:00
|
|
|
this->SetNoteData( noteData );
|
2005-03-05 23:07:42 +00:00
|
|
|
this->SetDescription( pSource->GetDescription() );
|
2003-01-30 07:18:33 +00:00
|
|
|
this->SetDifficulty( pSource->GetDifficulty() );
|
|
|
|
|
this->SetMeter( pSource->GetMeter() );
|
2005-04-03 21:43:29 +00:00
|
|
|
this->CalculateRadarValues( fMusicLengthSeconds );
|
2003-01-30 07:18:33 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-07 06:16:17 +00:00
|
|
|
void Steps::CreateBlank( StepsType ntTo )
|
2003-01-30 07:18:33 +00:00
|
|
|
{
|
2003-08-07 06:36:34 +00:00
|
|
|
m_StepsType = ntTo;
|
2003-01-30 07:18:33 +00:00
|
|
|
NoteData noteData;
|
2004-07-12 02:19:24 +00:00
|
|
|
noteData.SetNumTracks( GameManager::StepsTypeToNumTracks(ntTo) );
|
2004-10-23 17:43:49 +00:00
|
|
|
this->SetNoteData( noteData );
|
2003-01-30 07:18:33 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void Steps::SetDifficultyAndDescription( Difficulty dc, RString sDescription )
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
DeAutogen();
|
2005-04-13 08:45:00 +00:00
|
|
|
m_Difficulty = dc;
|
|
|
|
|
m_sDescription = sDescription;
|
2005-04-13 08:05:48 +00:00
|
|
|
if( GetDifficulty() == DIFFICULTY_EDIT )
|
|
|
|
|
MakeValidEditDescription( m_sDescription );
|
2005-03-07 05:23:18 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
bool Steps::MakeValidEditDescription( RString &sPreferredDescription )
|
2005-03-07 05:23:18 +00:00
|
|
|
{
|
2005-07-29 02:23:02 +00:00
|
|
|
if( int(sPreferredDescription.size()) > MAX_EDIT_STEPS_DESCRIPTION_LENGTH )
|
2005-03-07 05:23:18 +00:00
|
|
|
{
|
2005-07-29 02:23:02 +00:00
|
|
|
sPreferredDescription = sPreferredDescription.Left( MAX_EDIT_STEPS_DESCRIPTION_LENGTH );
|
2005-03-07 05:23:18 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2003-01-02 22:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-12 03:23:28 +00:00
|
|
|
void Steps::SetMeter( int meter )
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
DeAutogen();
|
|
|
|
|
m_iMeter = meter;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-28 03:34:14 +00:00
|
|
|
void Steps::SetCachedRadarValues( const RadarValues v[NUM_PLAYERS] )
|
2003-01-02 22:10:51 +00:00
|
|
|
{
|
|
|
|
|
DeAutogen();
|
2006-07-28 03:34:14 +00:00
|
|
|
copy( v, v + NUM_PLAYERS, m_CachedRadarValues );
|
2003-01-02 22:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-22 23:06:51 +00:00
|
|
|
|
|
|
|
|
// lua start
|
|
|
|
|
#include "LuaBinding.h"
|
|
|
|
|
|
2005-06-20 05:02:03 +00:00
|
|
|
class LunaSteps: public Luna<Steps>
|
2005-02-22 23:06:51 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2006-08-22 14:10:25 +00:00
|
|
|
DEFINE_METHOD( GetStepsType, m_StepsType )
|
|
|
|
|
DEFINE_METHOD( GetDifficulty, GetDifficulty() )
|
|
|
|
|
DEFINE_METHOD( GetDescription, GetDescription() )
|
|
|
|
|
DEFINE_METHOD( GetMeter, GetMeter() )
|
|
|
|
|
DEFINE_METHOD( GetFilename, GetFilename() )
|
|
|
|
|
DEFINE_METHOD( IsAutogen, IsAutogen() )
|
2006-08-16 21:35:01 +00:00
|
|
|
|
|
|
|
|
static int GetRadarValues( T* p, lua_State *L )
|
|
|
|
|
{
|
2006-09-27 06:21:34 +00:00
|
|
|
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
|
2006-08-16 21:35:01 +00:00
|
|
|
RadarValues &rv = const_cast<RadarValues &>(p->GetRadarValues(pn));
|
|
|
|
|
rv.PushSelf(L);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2005-02-22 23:06:51 +00:00
|
|
|
|
2006-09-27 20:03:31 +00:00
|
|
|
LunaSteps()
|
2005-02-22 23:06:51 +00:00
|
|
|
{
|
2005-09-10 02:47:04 +00:00
|
|
|
ADD_METHOD( GetStepsType );
|
|
|
|
|
ADD_METHOD( GetDifficulty );
|
|
|
|
|
ADD_METHOD( GetDescription );
|
|
|
|
|
ADD_METHOD( GetMeter );
|
2005-12-06 12:39:43 +00:00
|
|
|
ADD_METHOD( GetFilename );
|
2006-08-16 21:35:01 +00:00
|
|
|
ADD_METHOD( GetRadarValues );
|
|
|
|
|
ADD_METHOD( IsAutogen );
|
2005-02-22 23:06:51 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
LUA_REGISTER_CLASS( Steps )
|
|
|
|
|
// lua end
|
|
|
|
|
|
|
|
|
|
|
2004-05-31 21:35:31 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 Chris Danford, Glenn Maynard, David Wilson
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|