Update comments. Consistent naming.

TODO: Look into using NotesWriterSM in NotesWriterSSC
for common functionality.
This commit is contained in:
Jason Felds
2011-02-18 22:27:59 -05:00
parent 5e3165c855
commit 7539c2f97e
3 changed files with 50 additions and 8 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ namespace NotesWriterSM
* @brief Get some contents about the edit file first. * @brief Get some contents about the edit file first.
* @param pSong the Song in question. * @param pSong the Song in question.
* @param pSteps the Steps in question. * @param pSteps the Steps in question.
* @param sOut unused? * @param sOut the start of the file contents.
*/ */
void GetEditFileContents( const Song *pSong, const Steps *pSteps, RString &sOut ); void GetEditFileContents( const Song *pSong, const Steps *pSteps, RString &sOut );
/** /**
+20 -3
View File
@@ -16,6 +16,10 @@
#include "Song.h" #include "Song.h"
#include "Steps.h" #include "Steps.h"
/**
* @brief Turn the BackgroundChange into a string.
* @param bgc the BackgroundChange in question.
* @return the converted string. */
static RString BackgroundChangeToString( const BackgroundChange &bgc ) static RString BackgroundChangeToString( const BackgroundChange &bgc )
{ {
// TODO: Technically we need to double-escape the filename (because it might contain '=') and then // TODO: Technically we need to double-escape the filename (because it might contain '=') and then
@@ -37,6 +41,10 @@ static RString BackgroundChangeToString( const BackgroundChange &bgc )
return s; return s;
} }
/**
* @brief Write out the common tags for .SM files.
* @param f the file in question.
* @param out the Song in question. */
static void WriteGlobalTags( RageFile &f, const Song &out ) static void WriteGlobalTags( RageFile &f, const Song &out )
{ {
f.PutLine( ssprintf( "#VERSION:%.2f;", out.m_fVersion ) ); f.PutLine( ssprintf( "#VERSION:%.2f;", out.m_fVersion ) );
@@ -238,6 +246,10 @@ static void WriteGlobalTags( RageFile &f, const Song &out )
f.PutLine( ";" ); f.PutLine( ";" );
} }
/**
* @brief Turn a vector of lines into a single line joined by newline characters.
* @param lines the list of lines to join.
* @return the joined lines. */
static RString JoinLineList( vector<RString> &lines ) static RString JoinLineList( vector<RString> &lines )
{ {
for( unsigned i = 0; i < lines.size(); ++i ) for( unsigned i = 0; i < lines.size(); ++i )
@@ -251,7 +263,12 @@ static RString JoinLineList( vector<RString> &lines )
return join( "\r\n", lines.begin()+j, lines.end() ); return join( "\r\n", lines.begin()+j, lines.end() );
} }
static RString GetSSCNotesTag( const Song &song, const Steps &in, bool bSavingCache ) /**
* @brief Retrieve the individual batches of NoteData.
* @param song the Song in question.
* @param in the Steps in question.
* @return the NoteData in RString form. */
static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCache )
{ {
vector<RString> lines; vector<RString> lines;
@@ -396,7 +413,7 @@ bool NotesWriterSSC::Write( RString sPath, const Song &out, const vector<Steps*>
FOREACH_CONST( Steps*, vpStepsToSave, s ) FOREACH_CONST( Steps*, vpStepsToSave, s )
{ {
const Steps* pSteps = *s; const Steps* pSteps = *s;
RString sTag = GetSSCNotesTag( out, *pSteps, bSavingCache ); RString sTag = GetSSCNoteData( out, *pSteps, bSavingCache );
f.PutLine( sTag ); f.PutLine( sTag );
} }
if( f.Flush() == -1 ) if( f.Flush() == -1 )
@@ -416,7 +433,7 @@ void NotesWriterSSC::GetEditFileContents( const Song *pSong, const Steps *pSteps
if( asParts.size() ) if( asParts.size() )
sDir = join( "/", asParts.begin()+1, asParts.end() ); sDir = join( "/", asParts.begin()+1, asParts.end() );
sOut += ssprintf( "#SONG:%s;\r\n", sDir.c_str() ); sOut += ssprintf( "#SONG:%s;\r\n", sDir.c_str() );
sOut += GetSSCNotesTag( *pSong, *pSteps, false ); sOut += GetSSCNoteData( *pSong, *pSteps, false );
} }
RString NotesWriterSSC::GetEditFileName( const Song *pSong, const Steps *pSteps ) RString NotesWriterSSC::GetEditFileName( const Song *pSong, const Steps *pSteps )
+29 -4
View File
@@ -1,22 +1,47 @@
/* NotesWriterSSC - Writes a Song to an .SSC file. */
#ifndef NOTES_WRITER_SSC_H #ifndef NOTES_WRITER_SSC_H
#define NOTES_WRITER_SSC_H #define NOTES_WRITER_SSC_H
class Song; class Song;
class Steps; class Steps;
/** @brief Writes a Song to an .SSC file. */
namespace NotesWriterSSC namespace NotesWriterSSC
{ {
/**
* @brief Write the song out to a file.
* @param sPath the path to write the file.
* @param out the Song to be written out.
* @param vpStepsToSave the Steps to save.
* @param bSavingCache a flag to see if we're saving certain cache data.
* @return its success or failure. */
bool Write( RString sPath, const Song &out, const vector<Steps*>& vpStepsToSave, bool bSavingCache ); bool Write( RString sPath, const Song &out, const vector<Steps*>& vpStepsToSave, bool bSavingCache );
/**
* @brief Get some contents about the edit file first.
* @param pSong the Song in question.
* @param pSteps the Steps in question.
* @param sOut the start of the file contents.
*/
void GetEditFileContents( const Song *pSong, const Steps *pSteps, RString &sOut ); void GetEditFileContents( const Song *pSong, const Steps *pSteps, RString &sOut );
/**
* @brief Get the name of the edit file to use.
* @param pSong the Song in question.
* @param pSteps the Steps in question.
* @return the name of the edit file. */
RString GetEditFileName( const Song *pSong, const Steps *pSteps ); RString GetEditFileName( const Song *pSong, const Steps *pSteps );
/**
* @param Write the edit file to the machine for future use.
* @param pSong the Song in question.
* @param pSteps the Steps in question.
* @param sErrorOut any error messages that may have occurred.
* @return its success or failure. */
bool WriteEditFileToMachine( const Song *pSong, Steps *pSteps, RString &sErrorOut ); bool WriteEditFileToMachine( const Song *pSong, Steps *pSteps, RString &sErrorOut );
} }
#endif #endif
/* /**
* (c) 2011 Jason Felds * @file
* @author Jason Felds (c) 2011
* @section LICENSE
* All rights reserved. * All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a