Stops (and Delays) now templated.

This is all of them at this present time.

At some point in the future, we should make
DelaySegments separate from StopSegments.
This commit is contained in:
Jason Felds
2011-06-01 09:50:34 -04:00
parent 50e93045cc
commit df6a00b53e
16 changed files with 197 additions and 194 deletions
+6 -6
View File
@@ -269,11 +269,11 @@ void AdjustSync::AutosyncTempo()
FOREACH( BPMSegment, GAMESTATE->m_pCurSong->m_SongTiming.m_BPMSegments, i )
i->SetBPM( i->GetBPM() * fScaleBPM );
// We assume that the stops were measured as a number of beats.
// Therefore, if we change the bpms, we need to make a similar
// change to the stops.
/* We assume that the stops were measured as a number of beats.
* Therefore, if we change the bpms, we need to make a similar
* change to the stops. */
FOREACH( StopSegment, GAMESTATE->m_pCurSong->m_SongTiming.m_StopSegments, i )
i->m_fStopSeconds *= 1.0f - fSlope;
i->SetPause(i->GetPause() * (1.0f - fSlope));
SCREENMAN->SystemMessage( AUTOSYNC_CORRECTION_APPLIED.GetValue() );
}
@@ -366,8 +366,8 @@ void AdjustSync::GetSyncChangeTextSong( vector<RString> &vsAddTo )
for( unsigned i=0; i< testing.m_StopSegments.size(); i++ )
{
float fOld = Quantize( original.m_StopSegments[i].m_fStopSeconds, 0.001f );
float fNew = Quantize( testing.m_StopSegments[i].m_fStopSeconds, 0.001f );
float fOld = Quantize( original.m_StopSegments[i].GetPause(), 0.001f );
float fNew = Quantize( testing.m_StopSegments[i].GetPause(), 0.001f );
float fDelta = fNew - fOld;
if( fabsf(fDelta) > 0.0001f )
+3 -3
View File
@@ -910,11 +910,11 @@ void NoteField::DrawPrimitives()
// Freeze text
FOREACH_CONST( StopSegment, timing.m_StopSegments, seg )
{
if( seg->m_iStartRow >= iFirstRowToDraw && seg->m_iStartRow <= iLastRowToDraw )
if( seg->GetRow() >= iFirstRowToDraw && seg->GetRow() <= iLastRowToDraw )
{
float fBeat = NoteRowToBeat(seg->m_iStartRow);
float fBeat = seg->GetBeat();
if( IS_ON_SCREEN(fBeat) )
DrawFreezeText( fBeat, seg->m_fStopSeconds, seg->m_bDelay );
DrawFreezeText( fBeat, seg->GetPause(), seg->GetDelay() );
}
}
+1 -1
View File
@@ -664,7 +664,7 @@ static bool LoadFromBMSFile( const RString &sPath, const NameToData_t &mapNameTo
StopSegment newSeg( BeatToNoteRow(fBeat), fFreezeSecs );
out.m_Timing.AddStopSegment( newSeg );
LOG->Trace( "Inserting new Freeze at beat %f, secs %f", fBeat, newSeg.m_fStopSeconds );
LOG->Trace( "Inserting new Freeze at beat %f, secs %f", fBeat, newSeg.GetPause() );
}
else
{
+2 -2
View File
@@ -23,8 +23,8 @@ void Deserialize(BPMSegment &seg, const Json::Value &root)
static void Deserialize(StopSegment &seg, const Json::Value &root)
{
seg.m_iStartRow = BeatToNoteRow((float)(root["Beat"].asDouble()));
seg.m_fStopSeconds = (float)root["Seconds"].asDouble();
seg.SetBeat((float)(root["Beat"].asDouble()));
seg.SetPause((float)(root["Seconds"].asDouble()));
}
static void Deserialize(TimingData &td, const Json::Value &root)
+1 -1
View File
@@ -722,7 +722,7 @@ static void ReadGlobalTags( const NameToData_t &mapNameToData, Song &out, Measur
StopSegment newSeg( BeatToNoteRow(fBeat), fFreezeSecs );
out.m_SongTiming.AddStopSegment( newSeg );
LOG->Trace( "Inserting new Freeze at beat %f, secs %f", fBeat, newSeg.m_fStopSeconds );
LOG->Trace( "Inserting new Freeze at beat %f, secs %f", fBeat, newSeg.GetPause() );
}
else
{
+3 -3
View File
@@ -342,10 +342,10 @@ void SMLoader::ProcessDelays( TimingData &out, const RString sParam )
const float fFreezeBeat = StringToFloat( arrayDelayValues[0] );
const float fFreezeSeconds = StringToFloat( arrayDelayValues[1] );
StopSegment new_seg( BeatToNoteRow(fFreezeBeat), fFreezeSeconds, true );
StopSegment new_seg( fFreezeBeat, fFreezeSeconds, true );
// XXX: Remove Negatives Bug?
new_seg.m_iStartRow = BeatToNoteRow(fFreezeBeat);
new_seg.m_fStopSeconds = fFreezeSeconds;
new_seg.SetBeat(fFreezeBeat);
new_seg.SetPause(fFreezeSeconds);
// LOG->Trace( "Adding a delay segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds );
+3 -3
View File
@@ -209,10 +209,10 @@ void SMALoader::ProcessDelays( TimingData &out, const int iRowsPerBeat, const RS
const float fFreezeBeat = RowToBeat( arrayDelayValues[0], iRowsPerBeat );
const float fFreezeSeconds = StringToFloat( arrayDelayValues[1] );
StopSegment new_seg( BeatToNoteRow(fFreezeBeat), fFreezeSeconds, true );
StopSegment new_seg( fFreezeBeat, fFreezeSeconds, true );
// XXX: Remove Negatives Bug?
new_seg.m_iStartRow = BeatToNoteRow(fFreezeBeat);
new_seg.m_fStopSeconds = fFreezeSeconds;
new_seg.SetBeat(fFreezeBeat);
new_seg.SetPause(fFreezeSeconds);
// LOG->Trace( "Adding a delay segment: beat: %f, seconds = %f", new_seg.m_fStartBeat, new_seg.m_fStopSeconds );
+2 -2
View File
@@ -381,8 +381,8 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
for( unsigned i=0; i<out.m_SongTiming.m_StopSegments.size(); i++ )
{
const StopSegment &fs = out.m_SongTiming.m_StopSegments[i];
f.Write( ssprintf("%.3f=%.3f", fs.m_iStartRow * 4.0f / ROWS_PER_BEAT,
roundf(fs.m_fStopSeconds*1000)) );
f.Write( ssprintf("%.3f=%.3f", fs.GetRow() * 4.0f / ROWS_PER_BEAT,
roundf(fs.GetPause()*1000)) );
if( i != out.m_SongTiming.m_StopSegments.size()-1 )
f.Write( "," );
}
+2 -2
View File
@@ -17,8 +17,8 @@ void Serialize(const BPMSegment &seg, Json::Value &root)
static void Serialize(const StopSegment &seg, Json::Value &root)
{
root["Beat"] = NoteRowToBeat(seg.m_iStartRow);
root["Seconds"] = seg.m_fStopSeconds;
root["Beat"] = seg.GetBeat();
root["Seconds"] = seg.GetPause();
}
static void Serialize(const TimingData &td, Json::Value &root)
+11 -17
View File
@@ -116,10 +116,7 @@ static void WriteGlobalTags( RageFile &f, Song &out )
int iRow = out.m_SongTiming.m_WarpSegments[i].GetRow();
float fBPS = 60 / out.m_SongTiming.GetBPMAtRow(iRow);
float fSkip = fBPS * out.m_SongTiming.m_WarpSegments[i].GetLength();
StopSegment ss;
ss.m_iStartRow = iRow;
ss.m_fStopSeconds = -fSkip;
ss.m_bDelay = false; // Best to be sure.
StopSegment ss(iRow, -fSkip, false);
out.m_SongTiming.AddStopSegment( ss );
}
}
@@ -128,21 +125,18 @@ static void WriteGlobalTags( RageFile &f, Song &out )
for( unsigned i=0; i<out.m_SongTiming.m_StopSegments.size(); i++ )
{
const StopSegment &fs = out.m_SongTiming.m_StopSegments[i];
int iRow = fs.m_iStartRow;
float fBeat = NoteRowToBeat(!fs.m_bDelay ? iRow : iRow - 1);
float fBeat = fs.GetBeat();
if (fs.GetDelay()) fBeat--;
if(!fs.m_bDelay)
f.PutLine( ssprintf( "%.3f=%.3f", fBeat, fs.GetPause() ) );
if( i != out.m_SongTiming.m_StopSegments.size()-1 )
f.Write( "," );
if( fs.GetPause() < 0 )
{
f.PutLine( ssprintf( "%.3f=%.3f", fBeat, fs.m_fStopSeconds ) );
if( i != out.m_SongTiming.m_StopSegments.size()-1 )
f.Write( "," );
if( fs.m_fStopSeconds < 0 )
{
out.m_SongTiming.m_StopSegments.erase(
out.m_SongTiming.m_StopSegments.begin()+i,
out.m_SongTiming.m_StopSegments.begin()+i+1 );
i--;
}
out.m_SongTiming.m_StopSegments.erase(
out.m_SongTiming.m_StopSegments.begin()+i,
out.m_SongTiming.m_StopSegments.begin()+i+1 );
i--;
}
}
f.PutLine( ";" );
+4 -4
View File
@@ -98,14 +98,14 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
w.Init( "STOPS" );
FOREACH_CONST( StopSegment, timing.m_StopSegments, ss )
if( !ss->m_bDelay )
w.Write( ss->m_iStartRow, ss->m_fStopSeconds );
if( !ss->GetDelay() )
w.Write( ss->GetRow(), ss->GetPause() );
w.Finish();
w.Init( "DELAYS" );
FOREACH_CONST( StopSegment, timing.m_StopSegments, ss )
if( ss->m_bDelay )
w.Write( ss->m_iStartRow, ss->m_fStopSeconds );
if( ss->GetDelay() )
w.Write( ss->GetRow(), ss->GetPause() );
w.Finish();
w.Init( "WARPS" );
+6 -6
View File
@@ -1698,7 +1698,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
unsigned i;
for( i=0; i<GetAppropriateTiming().m_StopSegments.size(); i++ )
{
if( GetAppropriateTiming().m_StopSegments[i].m_iStartRow == BeatToNoteRow( GetBeat() ) )
if( GetAppropriateTiming().m_StopSegments[i].GetRow() == GetRow() )
break;
}
@@ -1706,14 +1706,14 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
{
// create a new StopSegment
if( fDelta > 0 )
GetAppropriateTiming().AddStopSegment( StopSegment(BeatToNoteRow( GetBeat() ), fDelta) );
GetAppropriateTiming().AddStopSegment( StopSegment( GetRow(), fDelta) );
}
else // StopSegment being modified is m_SongTiming.m_StopSegments[i]
{
GetAppropriateTiming().m_StopSegments[i].m_fStopSeconds += fDelta;
if( GetAppropriateTiming().m_StopSegments[i].m_fStopSeconds <= 0 )
GetAppropriateTiming().m_StopSegments.erase( GetAppropriateTiming().m_StopSegments.begin()+i,
GetAppropriateTiming().m_StopSegments.begin()+i+1);
vector<StopSegment> &s = GetAppropriateTiming().m_StopSegments;
s[i].SetPause(s[i].GetPause() + fDelta);
if( s[i].GetPause() <= 0 )
s.erase( s.begin()+i, s.begin()+i+1);
}
(fDelta>0 ? m_soundValueIncrease : m_soundValueDecrease).Play();
SetDirty( true );
+33 -32
View File
@@ -111,7 +111,7 @@ void TimingData::SetStopAtRow( int iRow, float fSeconds, bool bDelay )
{
unsigned i;
for( i=0; i<m_StopSegments.size(); i++ )
if( m_StopSegments[i].m_iStartRow == iRow && m_StopSegments[i].m_bDelay == bDelay )
if( m_StopSegments[i].GetRow() == iRow && m_StopSegments[i].GetDelay() == bDelay )
break;
if( i == m_StopSegments.size() ) // there is no Stop/Delay Segment at the current beat
@@ -126,7 +126,7 @@ void TimingData::SetStopAtRow( int iRow, float fSeconds, bool bDelay )
{
if( fSeconds > 0 )
{
m_StopSegments[i].m_fStopSeconds = fSeconds;
m_StopSegments[i].SetPause(fSeconds);
}
else
m_StopSegments.erase( m_StopSegments.begin()+i, m_StopSegments.begin()+i+1 );
@@ -376,9 +376,10 @@ float TimingData::GetStopAtRow( int iNoteRow, bool bDelay ) const
{
for( unsigned i=0; i<m_StopSegments.size(); i++ )
{
if( m_StopSegments[i].m_bDelay == bDelay && m_StopSegments[i].m_iStartRow == iNoteRow )
const StopSegment &s = m_StopSegments[i];
if( s.GetDelay() == bDelay && s.GetRow() == iNoteRow )
{
return m_StopSegments[i].m_fStopSeconds;
return s.GetPause();
}
}
return 0;
@@ -513,7 +514,7 @@ int TimingData::GetStopSegmentIndexAtRow( int iNoteRow, bool bDelay ) const
for( i=0; i<m_StopSegments.size()-1; i++ )
{
const StopSegment& s = m_StopSegments[i+1];
if( s.m_iStartRow > iNoteRow && s.m_bDelay == bDelay )
if( s.GetRow() > iNoteRow && s.GetDelay() == bDelay )
break;
}
return static_cast<int>(i);
@@ -839,9 +840,9 @@ void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float
iEventRow = itBPMS->GetRow();
iEventType = FOUND_BPM_CHANGE;
}
if( itSS != m_StopSegments.end() && itSS->m_iStartRow < iEventRow )
if( itSS != m_StopSegments.end() && itSS->GetRow() < iEventRow )
{
iEventRow = itSS->m_iStartRow;
iEventRow = itSS->GetRow();
iEventType = FOUND_STOP;
}
if( itWS != m_WarpSegments.end() && itWS->GetRow() < iEventRow )
@@ -871,14 +872,14 @@ void TimingData::GetBeatAndBPSFromElapsedTimeNoOffset( float fElapsedTime, float
break;
case FOUND_STOP:
{
fTimeToNextEvent = itSS->m_fStopSeconds;
fTimeToNextEvent = itSS->GetPause();
fNextEventTime = fLastTime + fTimeToNextEvent;
const bool bIsDelay = itSS->m_bDelay;
const bool bIsDelay = itSS->GetDelay();
if ( fElapsedTime < fNextEventTime )
{
bFreezeOut = !bIsDelay;
bDelayOut = bIsDelay;
fBeatOut = NoteRowToBeat( itSS->m_iStartRow );
fBeatOut = itSS->GetBeat();
fBPSOut = fBPS;
return;
}
@@ -941,9 +942,9 @@ float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
iEventRow = itBPMS->GetRow();
iEventType = FOUND_BPM_CHANGE;
}
if( itSS != m_StopSegments.end() && itSS->m_bDelay && itSS->m_iStartRow < iEventRow ) // delays (come before marker)
if( itSS != m_StopSegments.end() && itSS->GetDelay() && itSS->GetRow() < iEventRow ) // delays (come before marker)
{
iEventRow = itSS->m_iStartRow;
iEventRow = itSS->GetRow();
iEventType = FOUND_STOP;
}
if( BeatToNoteRow(fBeat) < iEventRow )
@@ -951,9 +952,9 @@ float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
iEventRow = BeatToNoteRow(fBeat);
iEventType = FOUND_MARKER;
}
if( itSS != m_StopSegments.end() && !itSS->m_bDelay && itSS->m_iStartRow < iEventRow ) // stops (come after marker)
if( itSS != m_StopSegments.end() && !itSS->GetDelay() && itSS->GetRow() < iEventRow ) // stops (come after marker)
{
iEventRow = itSS->m_iStartRow;
iEventRow = itSS->GetRow();
iEventType = FOUND_STOP;
}
if( itWS != m_WarpSegments.end() && itWS->GetRow() < iEventRow )
@@ -974,7 +975,7 @@ float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
itBPMS ++;
break;
case FOUND_STOP:
fTimeToNextEvent = itSS->m_fStopSeconds;
fTimeToNextEvent = itSS->GetPause();
fNextEventTime = fLastTime + fTimeToNextEvent;
fLastTime = fNextEventTime;
itSS ++;
@@ -1035,13 +1036,13 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool
for( unsigned i = 0; i < m_StopSegments.size(); i++ )
{
StopSegment &s = m_StopSegments[i];
const int iSegStartRow = s.m_iStartRow;
const int iSegStartRow = s.GetRow();
if( iSegStartRow < iStartIndex )
continue;
else if( iSegStartRow > iEndIndex )
s.m_iStartRow += lrintf((iEndIndex - iStartIndex) * (fScale - 1));
s.SetRow(s.GetRow() + lrintf((iEndIndex - iStartIndex) * (fScale - 1)));
else
s.m_iStartRow = lrintf((iSegStartRow - iStartIndex) * fScale) + iStartIndex;
s.SetRow(lrintf((iSegStartRow - iStartIndex) * fScale) + iStartIndex);
}
for( unsigned i = 0; i < m_vTimeSignatureSegments.size(); i++ )
@@ -1198,9 +1199,9 @@ void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
for( unsigned i = 0; i < m_StopSegments.size(); i++ )
{
StopSegment &stop = m_StopSegments[i];
if( stop.m_iStartRow < iStartRow )
if( stop.GetRow() < iStartRow )
continue;
stop.m_iStartRow += iRowsToAdd;
stop.SetRow(stop.GetRow() + iRowsToAdd);
}
for( unsigned i = 0; i < m_WarpSegments.size(); i++ )
@@ -1306,13 +1307,13 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
for( unsigned i = 0; i < m_StopSegments.size(); i++ )
{
StopSegment &stop = m_StopSegments[i];
int keyRow = stop.GetRow();
// Before deleted region:
if( stop.m_iStartRow < iStartRow )
if( keyRow < iStartRow )
continue;
// Inside deleted region:
if( stop.m_iStartRow < iStartRow+iRowsToDelete )
if( keyRow < iStartRow+iRowsToDelete )
{
m_StopSegments.erase( m_StopSegments.begin()+i, m_StopSegments.begin()+i+1 );
--i;
@@ -1320,7 +1321,7 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
}
// After deleted region:
stop.m_iStartRow -= iRowsToDelete;
stop.SetRow(keyRow - iRowsToDelete);
}
for( unsigned i = 0; i < m_WarpSegments.size(); i++ )
@@ -1663,10 +1664,10 @@ public:
vector<RString> vStops;
FOREACH_CONST( StopSegment, p->m_StopSegments, seg )
{
const float fStartRow = NoteRowToBeat(seg->m_iStartRow);
const float fStopLength = seg->m_fStopSeconds;
if(!seg->m_bDelay)
vStops.push_back( ssprintf("%f=%f", fStartRow, fStopLength) );
const float fStartBeat = seg->GetBeat();
const float fStopLength = seg->GetPause();
if(!seg->GetDelay())
vStops.push_back( ssprintf("%f=%f", fStartBeat, fStopLength) );
}
LuaHelpers::CreateTableFromArray(vStops, L);
@@ -1677,10 +1678,10 @@ public:
vector<RString> vDelays;
FOREACH_CONST( StopSegment, p->m_StopSegments, seg )
{
const float fStartRow = NoteRowToBeat(seg->m_iStartRow);
const float fStopLength = seg->m_fStopSeconds;
if(seg->m_bDelay)
vDelays.push_back( ssprintf("%f=%f", fStartRow, fStopLength) );
const float fStartBeat = seg->GetBeat();
const float fStopLength = seg->GetPause();
if(seg->GetDelay())
vDelays.push_back( ssprintf("%f=%f", fStartBeat, fStopLength) );
}
LuaHelpers::CreateTableFromArray(vDelays, L);
-110
View File
@@ -9,116 +9,6 @@ struct lua_State;
/** @brief Compare a TimingData segment's properties with one another. */
#define COMPARE(x) if(x!=other.x) return false;
/**
* @brief Identifies when a song has a stop or a delay.
*
* It is hopeful that stops and delays can be made into their own segments at some point.
*/
struct StopSegment
{
/**
* @brief Creates a simple Stop Segment with default values.
*
* It is best to override the values as soon as possible.
*/
StopSegment() : m_iStartRow(-1), m_fStopSeconds(-1.0f), m_bDelay(false) { }
/**
* @brief Creates a Stop Segment at the specified row for the specified length of time.
*
* This will not create a dedicated delay segment. Use the third constructor for
* making delays.
* @param s the starting row of this segment.
* @param f the length of time to pause the note scrolling.
*/
StopSegment( int s, float f ) : m_iStartRow(max(0, s)),
m_fStopSeconds(f), m_bDelay(false)
{
if (!PREFSMAN->m_bQuirksMode) m_fStopSeconds = max( 0.0f, f );
}
/**
* @brief Creates a Stop (or Delay) Segment at the specified row for the specified length of time.
* @param s the starting row of this segment.
* @param f the length of time to pause the note scrolling.
* @param d the flag that makes this Stop Segment a Delay Segment.
*/
StopSegment( int s, float f, bool d ) : m_iStartRow(max(0, s)),
m_fStopSeconds(f), m_bDelay(d)
{
if (!PREFSMAN->m_bQuirksMode) m_fStopSeconds = max( 0.0f, f );
}
/**
* @brief The row in which the StopSegment activates.
*/
int m_iStartRow;
/**
* @brief The amount of time to complete the pause at the given row.
*/
float m_fStopSeconds;
/**
* @brief If true, the Stop Segment is treated as a Delay Segment, similar to the Pump It Up series.
*/
bool m_bDelay;
/**
* @brief Compares two StopSegments to see if they are equal to each other.
* @param other the other StopSegment to compare to.
* @return the equality of the two segments.
*/
bool operator==( const StopSegment &other ) const
{
COMPARE( m_iStartRow );
COMPARE( m_fStopSeconds );
COMPARE( m_bDelay );
return true;
}
/**
* @brief Compares two StopSegments to see if they are not equal to each other.
* @param other the other StopSegment to compare to.
* @return the inequality of the two segments.
*/
bool operator!=( const StopSegment &other ) const { return !operator==(other); }
/**
* @brief Compares two StopSegments to see if one is less than the other.
*
* It should be observed that Delay Segments have to come before Stop Segments.
* Otherwise, it will act like a Stop Segment with extra time from the Delay at
* the same row.
* @param other the other StopSegment to compare to.
* @return the truth/falsehood of if the first is less than the second.
*/
bool operator<( const StopSegment &other ) const
{
return ( m_iStartRow < other.m_iStartRow ) ||
( m_iStartRow == other.m_iStartRow &&
( ( m_bDelay && !other.m_bDelay ) || m_fStopSeconds < other.m_fStopSeconds ));
}
/**
* @brief Compares two StopSegments to see if one is less than or equal to the other.
* @param other the other StopSegment to compare to.
* @return the truth/falsehood of if the first is less or equal to than the second.
*/
bool operator<=( const StopSegment &other ) const
{
return ( operator<(other) || operator==(other) );
}
/**
* @brief Compares two StopSegments to see if one is greater than the other.
*
* Similar to the less than operator function, stops must come after delays
* to avoid rendering the point of delays pointless.
* @param other the other StopSegment to compare to.
* @return the truth/falsehood of if the first is greater than the second.
*/
bool operator>( const StopSegment &other ) const { return !operator<=(other); }
/**
* @brief Compares two StopSegments to see if one is greater than or equal to the other.
* @param other the other StopSegment to compare to.
* @return the truth/falsehood of if the first is greater than or equal to the second.
*/
bool operator>=( const StopSegment &other ) const { return !operator<(other); }
};
/**
* @brief Holds data for translating beats<->seconds.
*/
+29
View File
@@ -251,6 +251,35 @@ bool ScrollSegment::operator<( const ScrollSegment &other ) const
return false;
}
float StopSegment::GetPause() const
{
return this->pauseSeconds;
}
void StopSegment::SetPause(const float i)
{
this->pauseSeconds = i;
}
bool StopSegment::GetDelay() const
{
return this->isDelay;
}
void StopSegment::SetDelay(const bool i)
{
this->isDelay = i;
}
bool StopSegment::operator<( const StopSegment &other ) const
{
LTCOMPARE(GetRow());
if (this->GetDelay() && !other.GetDelay()) return true;
if (!this->GetDelay() && other.GetDelay()) return false;
LTCOMPARE(GetPause());
return false;
}
/**
* @file
* @author Jason Felds (c) 2011
+91 -2
View File
@@ -722,12 +722,12 @@ struct ScrollSegment : public TimingSegment<ScrollSegment>
ratio(other.GetRatio()) {}
/**
* @brief Get the ratio in this SpeedSegment.
* @brief Get the ratio in this ScrollSegment.
* @return the ratio. */
float GetRatio() const;
/**
* @brief Set the ratio in this SpeedSegment.
* @brief Set the ratio in this ScrollSegment.
* @param i the ratio. */
void SetRatio(const float i);
@@ -742,6 +742,95 @@ private:
float ratio;
};
/**
* @brief Identifies when a song has a stop or a delay.
*
* It is hopeful that stops and delays can be made into their own segments at some point.
*/
struct StopSegment : public TimingSegment<StopSegment>
{
/**
* @brief Creates a simple Stop Segment with default values.
*
* It is best to override the values as soon as possible.
*/
StopSegment() : TimingSegment<StopSegment>(-1),
pauseSeconds(-1.0f), isDelay(false) {}
StopSegment (const StopSegment &other):
TimingSegment<StopSegment>(other),
pauseSeconds(other.GetPause()),
isDelay(other.GetDelay()) {}
/**
* @brief Creates a Stop Segment with specified values.
*
* This will not create a dedicated delay segment.
* Use the third constructor for making delays.
* @param s the starting row / beat of this segment.
* @param f the length of time to pause the note scrolling.
*/
template <typename StartType>
StopSegment( StartType s, float f ):
TimingSegment<StopSegment>(max((StartType)0, s)),
pauseSeconds(f), isDelay(false) {}
/**
* @brief Creates a Stop/Delay Segment with specified values.
* @param s the starting row / beat of this segment.
* @param f the length of time to pause the note scrolling.
* @param d the flag that makes this Stop Segment a Delay Segment.
*/
template <typename StartType>
StopSegment( StartType s, float f, bool d ):
TimingSegment<StopSegment>(max((StartType)0, s)),
pauseSeconds(f), isDelay(d) {}
/**
* @brief Get the pause length in this StopSegment.
* @return the pause length. */
float GetPause() const;
/**
* @brief Set the pause length in this StopSegment.
* @param i the pause length. */
void SetPause(const float i);
/**
* @brief Get the behavior in this StopSegment.
* @return the behavior. */
bool GetDelay() const;
/**
* @brief Set the behavior in this StopSegment.
* @param i the behavior. */
void SetDelay(const bool i);
/**
* @brief Compares two StopSegments to see if one is less than the other.
*
* It should be observed that Delay Segments have to come before Stop Segments.
* Otherwise, it will act like a Stop Segment with extra time from the Delay at
* the same row.
* @param other the other StopSegment to compare to.
* @return the truth/falsehood of if the first is less than the second.
*/
bool operator<( const StopSegment &other ) const;
private:
/**
* @brief The amount of time to complete the pause at the given row.
*/
float pauseSeconds;
/**
* @brief How does this StopSegment behave?
*
* If true, the Stop Segment is treated as a Delay Segment, similar to the Pump It Up series.
* If false, this behaves similar to the DDR/ITG style games.
*
* TODO: Separate out DelaySegments in the future.
*/
bool isDelay;
};
#endif
/**