Step Attacks will be written.

The cache won't be incremented until this is
given some testing.
This commit is contained in:
Jason Felds
2011-06-24 11:27:20 -04:00
parent cde793dc57
commit b51eec691d
6 changed files with 45 additions and 17 deletions
+11 -9
View File
@@ -10,7 +10,6 @@
#include "Song.h" #include "Song.h"
#include "SongManager.h" #include "SongManager.h"
#include "Steps.h" #include "Steps.h"
#include "Attack.h"
#include "PrefsManager.h" #include "PrefsManager.h"
void SMLoader::SetSongTitle(const RString & title) void SMLoader::SetSongTitle(const RString & title)
@@ -143,19 +142,21 @@ void SMLoader::ProcessBGChanges( Song &out, const RString &sValueName, const RSt
} }
} }
void SMLoader::ProcessAttacks( Song &out, MsdFile::value_t sParams ) void SMLoader::ProcessAttackString( vector<RString> & attacks, MsdFile::value_t params )
{ {
// Build the RString vector here so we can write it to file again later for( unsigned s=1; s < params.params.size(); ++s )
for( unsigned s=1; s < sParams.params.size(); ++s ) attacks.push_back( params[s] );
out.m_sAttackString.push_back( sParams[s] ); }
void SMLoader::ProcessAttacks( AttackArray &attacks, MsdFile::value_t params )
{
Attack attack; Attack attack;
float end = -9999; float end = -9999;
for( unsigned j=1; j < sParams.params.size(); ++j ) for( unsigned j=1; j < params.params.size(); ++j )
{ {
vector<RString> sBits; vector<RString> sBits;
split( sParams[j], "=", sBits, false ); split( params[j], "=", sBits, false );
// Need an identifer and a value for this to work // Need an identifer and a value for this to work
if( sBits.size() < 2 ) if( sBits.size() < 2 )
@@ -183,7 +184,7 @@ void SMLoader::ProcessAttacks( Song &out, MsdFile::value_t sParams )
if( attack.fSecsRemaining < 0.0f ) if( attack.fSecsRemaining < 0.0f )
attack.fSecsRemaining = 0.0f; attack.fSecsRemaining = 0.0f;
out.m_Attacks.push_back( attack ); attacks.push_back( attack );
} }
} }
} }
@@ -913,7 +914,8 @@ bool SMLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCache
// Attacks loaded from file // Attacks loaded from file
else if( sValueName=="ATTACKS" ) else if( sValueName=="ATTACKS" )
{ {
ProcessAttacks( out, sParams ); ProcessAttackString(out.m_sAttackString, sParams);
ProcessAttacks(out.m_Attacks, sParams);
} }
else if( sValueName=="NOTES" || sValueName=="NOTES2" ) else if( sValueName=="NOTES" || sValueName=="NOTES2" )
+13 -1
View File
@@ -3,6 +3,7 @@
#include "GameConstantsAndTypes.h" #include "GameConstantsAndTypes.h"
#include "BackgroundUtil.h" #include "BackgroundUtil.h"
#include "Attack.h"
#include "MsdFile.h" // we require the struct from here. #include "MsdFile.h" // we require the struct from here.
class Song; class Song;
@@ -133,7 +134,18 @@ struct SMLoader
virtual void ProcessBGChanges( Song &out, const RString &sValueName, virtual void ProcessBGChanges( Song &out, const RString &sValueName,
const RString &sPath, const RString &sParam ); const RString &sPath, const RString &sParam );
void ProcessAttacks( Song &out, MsdFile::value_t sParams );
/**
* @brief Put the attacks in the attacks string.
* @param attacks the attack string.
* @param params the params from the simfile. */
virtual void ProcessAttackString(vector<RString> &attacks, MsdFile::value_t params);
/**
* @brief Put the attacks in the attacks array.
* @param attacks the attacks array.
* @param params the params from the simfile. */
void ProcessAttacks( AttackArray &attacks, MsdFile::value_t params );
void ProcessInstrumentTracks( Song &out, const RString &sParam ); void ProcessInstrumentTracks( Song &out, const RString &sParam );
/** /**
+2 -1
View File
@@ -432,7 +432,8 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
// Attacks loaded from file // Attacks loaded from file
else if( sValueName=="ATTACKS" ) else if( sValueName=="ATTACKS" )
{ {
SMLoader::ProcessAttacks( out, sParams ); ProcessAttackString(out.m_sAttackString, sParams);
ProcessAttacks(out.m_Attacks, sParams);
} }
else if( sValueName=="NOTES" || sValueName=="NOTES2" ) else if( sValueName=="NOTES" || sValueName=="NOTES2" )
+4 -2
View File
@@ -344,7 +344,8 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
// Attacks loaded from file // Attacks loaded from file
else if( sValueName=="ATTACKS" ) else if( sValueName=="ATTACKS" )
{ {
SMLoader::ProcessAttacks( out, sParams ); ProcessAttackString(out.m_sAttackString, sParams);
ProcessAttacks(out.m_Attacks, sParams);
} }
else if( sValueName=="OFFSET" ) else if( sValueName=="OFFSET" )
@@ -559,7 +560,8 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach
else if( sValueName=="ATTACKS" ) else if( sValueName=="ATTACKS" )
{ {
// Step Attacks aren't in yet. ProcessAttackString(pNewNotes->m_sAttackString, sParams);
ProcessAttacks(pNewNotes->m_Attacks, sParams);
} }
else if( sValueName=="OFFSET" ) else if( sValueName=="OFFSET" )
+11 -2
View File
@@ -320,8 +320,17 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa
GetTimingTags( lines, in.m_Timing ); GetTimingTags( lines, in.m_Timing );
// For now, attacks are NOT in use for the step. RString attacks = "";
lines.push_back( "#ATTACKS:;" ); for( unsigned a=0; a < in.m_sAttackString.size(); a++ )
{
RString sData = in.m_sAttackString[a];
attacks += sData;
if( a != (in.m_sAttackString.size() - 1) )
attacks += ":"; // Not the end, so write a divider ':'
}
lines.push_back( ssprintf( "#ATTACKS:%s;", attacks.c_str()));
lines.push_back( ssprintf( "#OFFSET:%.6f;", in.m_Timing.m_fBeat0OffsetInSeconds ) ); lines.push_back( ssprintf( "#OFFSET:%.6f;", in.m_Timing.m_fBeat0OffsetInSeconds ) );
RString sNoteData; RString sNoteData;
+3 -1
View File
@@ -154,7 +154,9 @@ Steps *Song::CreateSteps()
void Song::InitSteps(Steps *pSteps) void Song::InitSteps(Steps *pSteps)
{ {
pSteps->m_Timing = m_SongTiming; pSteps->m_Timing = this->m_SongTiming;
pSteps->m_sAttackString = this->m_sAttackString;
pSteps->m_Attacks = this->m_Attacks;
} }
void Song::GetDisplayBpms( DisplayBpms &AddTo ) const void Song::GetDisplayBpms( DisplayBpms &AddTo ) const