Esempio n. 1
0
void NotesWriterSM::WriteSMNotesTag( const Steps &in, RageFile &f, bool bSavingCache )
{
	f.PutLine( "" );
	f.PutLine( ssprintf( "//---------------%s - %s----------------",
		GameManager::StepsTypeToString(in.m_StepsType).c_str(), in.GetDescription().c_str() ) );
	f.PutLine( "#NOTES:" );
	f.PutLine( ssprintf( "     %s:", GameManager::StepsTypeToString(in.m_StepsType).c_str() ) );
	f.PutLine( ssprintf( "     %s:", in.GetDescription().c_str() ) );
	f.PutLine( ssprintf( "     %s:", DifficultyToString(in.GetDifficulty()).c_str() ) );
	f.PutLine( ssprintf( "     %d:", in.GetMeter() ) );
	
	int MaxRadar = bSavingCache? NUM_RADAR_CATEGORIES:5;
	CStringArray asRadarValues;
	for( int r=0; r < MaxRadar; r++ )
		asRadarValues.push_back( ssprintf("%.3f", in.GetRadarValues()[r]) );
	/* Don't append a newline here; it's added in NoteDataUtil::GetSMNoteDataString.
	 * If we add it here, then every time we write unmodified data we'll add an extra
	 * newline and they'll accumulate. */
	f.Write( ssprintf( "     %s:", join(",",asRadarValues).c_str() ) );

	CString sNoteData;
	CString sAttackData;
	in.GetSMNoteData( sNoteData, sAttackData );

	vector<CString> lines;

	split( sNoteData, "\n", lines, false );
	WriteLineList( f, lines, true, true );

	if( sAttackData.empty() )
		f.PutLine( ";" );
	else
	{
		f.PutLine( ":" );

		lines.clear();
		split( sAttackData, "\n", lines, false );
		WriteLineList( f, lines, true, true );

		f.PutLine( ";" );
	}
}
Esempio n. 2
0
void Steps::Decompress() const
{
    if( m_bNoteDataIsFilled )
        return;	// already decompressed

    if( parent )
    {
        // get autogen m_pNoteData
        NoteData notedata;
        parent->GetNoteData( notedata );

        m_bNoteDataIsFilled = true;

        int iNewTracks = GAMEMAN->GetStepsTypeInfo(m_StepsType).iNumTracks;

        if( this->m_StepsType == StepsType_lights_cabinet )
        {
            NoteDataUtil::LoadTransformedLights( notedata, *m_pNoteData, iNewTracks );
        }
        else
        {
            NoteDataUtil::LoadTransformedSlidingWindow( notedata, *m_pNoteData, iNewTracks );

            NoteDataUtil::RemoveStretch( *m_pNoteData, m_StepsType );
        }
        return;
    }

    if( !m_sFilename.empty() && m_sNoteDataCompressed.empty() )
    {
        /* We have data on disk and not in memory.  Load it. */
        Song s;
        if( !SMLoader::LoadFromSMFile(m_sFilename, s, true) )
        {
            LOG->Warn( "Couldn't load \"%s\"", m_sFilename.c_str() );
            return;
        }

        /* Find the steps. */
        StepsID ID;
        ID.FromSteps( this );

        /* We're using a StepsID to search in a different copy of a Song than
         * the one it was created with.  Clear the cache before doing this,
         * or search results will come from cache and point to the original
         * copy. */
        CachedObject<Steps>::ClearCacheAll();
        Steps *pSteps = ID.ToSteps( &s, true );
        if( pSteps == NULL )
        {
            LOG->Warn( "Couldn't find %s in \"%s\"", ID.ToString().c_str(), m_sFilename.c_str() );
            return;
        }

        pSteps->GetSMNoteData( m_sNoteDataCompressed );
    }

    if( m_sNoteDataCompressed.empty() )
    {
        /* there is no data, do nothing */
    }
    else
    {
        // load from compressed
        bool bComposite = GAMEMAN->GetStepsTypeInfo(m_StepsType).m_StepsTypeCategory == StepsTypeCategory_Routine;
        m_bNoteDataIsFilled = true;
        m_pNoteData->SetNumTracks( GAMEMAN->GetStepsTypeInfo(m_StepsType).iNumTracks );

        NoteDataUtil::LoadFromSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed, bComposite );
    }
}