Scroll Segments Satisfied.

Just the Stops and Delays...in one segment.
Yeah, maybe those should be split up at some point.
This commit is contained in:
Jason Felds
2011-06-01 08:44:09 -04:00
parent d50eb4830d
commit 50e93045cc
7 changed files with 92 additions and 101 deletions
+3 -3
View File
@@ -999,11 +999,11 @@ void NoteField::DrawPrimitives()
{
FOREACH_CONST( ScrollSegment, timing.m_ScrollSegments, 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) )
DrawScrollText( fBeat, seg->m_fPercent );
DrawScrollText( fBeat, seg->GetRatio() );
}
}
}
+1 -1
View File
@@ -139,7 +139,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
w.Init( "SCROLLS" );
FOREACH_CONST( ScrollSegment, timing.m_ScrollSegments, ss )
w.Write( ss->m_iStartRow, ss->m_fPercent );
w.Write( ss->GetRow(), ss->GetRatio() );
w.Finish();
if( !bIsSong )
+1 -1
View File
@@ -4023,7 +4023,7 @@ void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice
ScreenTextEntry::TextEntry(
SM_BackFromScrollChange,
ENTER_SCROLL_VALUE,
ssprintf( "%.5f", GetAppropriateTiming().GetScrollSegmentAtBeat( GetBeat() ).m_fPercent ),
ssprintf( "%.5f", GetAppropriateTiming().GetScrollSegmentAtBeat( GetBeat() ).GetRatio() ),
10
);
break;
+22 -19
View File
@@ -299,25 +299,25 @@ void TimingData::SetScrollAtRow( int iRow, float fPercent )
unsigned i;
for( i = 0; i < m_ScrollSegments.size(); i++ )
{
if( m_ScrollSegments[i].m_iStartRow >= iRow)
if( m_ScrollSegments[i].GetRow() >= iRow)
break;
}
if ( i == m_ScrollSegments.size() || m_ScrollSegments[i].m_iStartRow != iRow )
if ( i == m_ScrollSegments.size() || m_ScrollSegments[i].GetRow() != iRow )
{
// the core mod itself matters the most for comparisons.
if( i == 0 || m_ScrollSegments[i-1].m_fPercent != fPercent )
if( i == 0 || m_ScrollSegments[i-1].GetRatio() != fPercent )
AddScrollSegment( ScrollSegment(iRow, fPercent) );
}
else
{
// The others aren't compared: only the mod itself matters.
if( i > 0 && m_ScrollSegments[i-1].m_fPercent == fPercent )
if( i > 0 && m_ScrollSegments[i-1].GetRatio() == fPercent )
m_ScrollSegments.erase( m_ScrollSegments.begin()+i,
m_ScrollSegments.begin()+i+1 );
else
{
m_ScrollSegments[i].m_fPercent = fPercent;
m_ScrollSegments[i].SetRatio(fPercent);
}
}
}
@@ -434,7 +434,7 @@ unsigned short TimingData::GetSpeedModeAtRow( int iRow )
float TimingData::GetScrollAtRow( int iRow )
{
return GetScrollSegmentAtRow( iRow ).m_fPercent;
return GetScrollSegmentAtRow( iRow ).GetRatio();
}
float TimingData::GetFakeAtRow( int iFakeRow ) const
@@ -628,7 +628,7 @@ int TimingData::GetScrollSegmentIndexAtRow( int iRow ) const
{
unsigned i;
for (i=0; i < m_ScrollSegments.size() - 1; i++ )
if( m_ScrollSegments[i+1].m_iStartRow > iRow )
if( m_ScrollSegments[i+1].GetRow() > iRow )
break;
return static_cast<int>(i);
}
@@ -665,7 +665,7 @@ ScrollSegment& TimingData::GetScrollSegmentAtRow( int iRow )
{
unsigned i;
for( i=0; i<m_ScrollSegments.size()-1; i++ )
if( m_ScrollSegments[i+1].m_iStartRow > iRow )
if( m_ScrollSegments[i+1].GetRow() > iRow )
break;
return m_ScrollSegments[i];
}
@@ -1003,10 +1003,13 @@ float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
float TimingData::GetDisplayedBeat( float fBeat ) const
{
unsigned index = GetScrollSegmentIndexAtBeat(fBeat);
float fOutBeat = ( fBeat - NoteRowToBeat(m_ScrollSegments[index].m_iStartRow) ) * m_ScrollSegments[index].m_fPercent;
const ScrollSegment &s = m_ScrollSegments[index];
float fOutBeat = ( fBeat - s.GetBeat() ) * s.GetRatio();
for( unsigned i = 0; i < index; i ++ )
{
fOutBeat += ( NoteRowToBeat(m_ScrollSegments[i + 1].m_iStartRow) - NoteRowToBeat(m_ScrollSegments[i].m_iStartRow) ) * m_ScrollSegments[i].m_fPercent;
const ScrollSegment &future = m_ScrollSegments[i+1];
const ScrollSegment &current = m_ScrollSegments[i];
fOutBeat += ( future.GetBeat() - current.GetBeat() ) * current.GetRatio();
}
return fOutBeat;
}
@@ -1147,13 +1150,13 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool
for( unsigned i = 0; i < m_ScrollSegments.size(); i++ )
{
ScrollSegment &s = m_ScrollSegments[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);
}
// adjust BPM changes to preserve timing
@@ -1258,9 +1261,9 @@ void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
for( unsigned i = 0; i < m_ScrollSegments.size(); i++ )
{
ScrollSegment &scrl = m_ScrollSegments[i];
if( scrl.m_iStartRow < iStartRow )
if( scrl.GetRow() < iStartRow )
continue;
scrl.m_iStartRow += iRowsToAdd;
scrl.SetRow(scrl.GetRow() + iRowsToAdd);
}
if( iStartRow == 0 )
@@ -1453,17 +1456,17 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
for( unsigned i = 0; i < m_ScrollSegments.size(); i++ )
{
ScrollSegment &scrl = m_ScrollSegments[i];
if( scrl.m_iStartRow < iStartRow )
int keyRow = scrl.GetRow();
if( keyRow < iStartRow )
continue;
if( scrl.m_iStartRow < iStartRow+iRowsToDelete )
if( keyRow < iStartRow+iRowsToDelete )
{
m_ScrollSegments.erase( m_ScrollSegments.begin()+i, m_ScrollSegments.begin()+i+1 );
--i;
continue;
}
scrl.m_iStartRow -= iRowsToDelete;
scrl.SetRow(keyRow - iRowsToDelete);
}
this->SetBPMAtRow( iStartRow, fNewBPM );
-76
View File
@@ -119,82 +119,6 @@ struct StopSegment
bool operator>=( const StopSegment &other ) const { return !operator<(other); }
};
/**
* @brief Identifies when the chart scroll changes.
*
* ScrollSegments adjusts the scrolling speed of the note field.
* Unlike forced attacks, these cannot be turned off at a set time:
* reset it by setting the precentage back to 1.
*
* These were inspired by the Pump It Up series. */
struct ScrollSegment
{
/** @brief Sets up the ScrollSegment with default values. */
ScrollSegment(): m_iStartRow(0), m_fPercent(1) {}
/**
* @brief Sets up the ScrollSegment with specified values.
* @param i The row this activates.
* @param p The percentage to use. */
ScrollSegment(int i, float p): m_iStartRow(i), m_fPercent(p) {}
/**
* @brief Sets up the ScrollSegment with specified values.
* @param r The beat this activates.
* @param p The percentage to use. */
ScrollSegment(float r, float p): m_iStartRow(BeatToNoteRow(r)), m_fPercent(p) {}
/** @brief The row in which the ScrollSegment activates. */
int m_iStartRow;
/** @brief The percentage to use when multiplying the chart's scroll rate. */
float m_fPercent;
/**
* @brief Compares two ScrollSegment to see if they are equal to each other.
* @param other the other ScrollSegment to compare to.
* @return the equality of the two segments.
*/
bool operator==( const ScrollSegment &other ) const
{
COMPARE( m_iStartRow );
COMPARE( m_fPercent );
return true;
}
/**
* @brief Compares two ScrollSegment to see if they are not equal to each other.
* @param other the other ScrollSegment to compare to.
* @return the inequality of the two segments.
*/
bool operator!=( const ScrollSegment &other ) const { return !operator==(other); }
/**
* @brief Compares two ScrollSegment to see if one is less than the other.
* @param other the other ScrollSegment to compare to.
* @return the truth/falsehood of if the first is less than the second.
*/
bool operator<( const ScrollSegment &other ) const { return m_iStartRow < other.m_iStartRow; }
/**
* @brief Compares two ScrollSegment to see if one is less than or equal to the other.
* @param other the other ScrollSegment to compare to.
* @return the truth/falsehood of if the first is less or equal to than the second.
*/
bool operator<=( const ScrollSegment &other ) const
{
return ( operator<(other) || operator==(other) );
}
/**
* @brief Compares two ScrollSegment to see if one is greater than the other.
* @param other the other ScrollSegment to compare to.
* @return the truth/falsehood of if the first is greater than the second.
*/
bool operator>( const ScrollSegment &other ) const { return !operator<=(other); }
/**
* @brief Compares two ScrollSegment to see if one is greater than or equal to the other.
* @param other the other ScrollSegment to compare to.
* @return the truth/falsehood of if the first is greater than or equal to the second.
*/
bool operator>=( const ScrollSegment &other ) const { return !operator<(other); }
};
/**
* @brief Holds data for translating beats<->seconds.
*/
+16
View File
@@ -234,6 +234,22 @@ bool SpeedSegment::operator<( const SpeedSegment &other ) const
return false;
}
float ScrollSegment::GetRatio() const
{
return this->ratio;
}
void ScrollSegment::SetRatio(const float i)
{
this->ratio = i;
}
bool ScrollSegment::operator<( const ScrollSegment &other ) const
{
LTCOMPARE(GetRow());
LTCOMPARE(GetRatio());
return false;
}
/**
* @file
+49 -1
View File
@@ -688,12 +688,60 @@ private:
*
* 0: beats
* 1: seconds
* other
* other values are undetermined at this time, but we're prepared this way.
*/
unsigned short unit;
};
/**
* @brief Identifies when the chart scroll changes.
*
* ScrollSegments adjusts the scrolling speed of the note field.
* Unlike forced attacks, these cannot be turned off at a set time:
* reset it by setting the precentage back to 1.
*
* These were inspired by the Pump It Up series. */
struct ScrollSegment : public TimingSegment<ScrollSegment>
{
/** @brief Sets up the ScrollSegment with default values. */
ScrollSegment(): TimingSegment<ScrollSegment>(0),
ratio(1) {}
/**
* @brief Sets up the ScrollSegment with specified values.
* @param s The row / beat this activates.
* @param p The percentage to use. */
template <typename StartType>
ScrollSegment( StartType s, float p):
TimingSegment<ScrollSegment>(max((StartType)0, s)),
ratio(p) {}
ScrollSegment(const ScrollSegment &other) :
TimingSegment<ScrollSegment>(other),
ratio(other.GetRatio()) {}
/**
* @brief Get the ratio in this SpeedSegment.
* @return the ratio. */
float GetRatio() const;
/**
* @brief Set the ratio in this SpeedSegment.
* @param i the ratio. */
void SetRatio(const float i);
/**
* @brief Compares two ScrollSegment to see if one is less than the other.
* @param other the other ScrollSegment to compare to.
* @return the truth/falsehood of if the first is less than the second.
*/
bool operator<( const ScrollSegment &other ) const;
private:
/** @brief The ratio / percentage to use when multiplying the chart's scroll rate. */
float ratio;
};
#endif
/**