Labels templated.
Six more to go.
This commit is contained in:
+3
-3
@@ -972,11 +972,11 @@ void NoteField::DrawPrimitives()
|
|||||||
// Label text
|
// Label text
|
||||||
FOREACH_CONST( LabelSegment, timing.m_LabelSegments, seg )
|
FOREACH_CONST( LabelSegment, timing.m_LabelSegments, 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) )
|
if( IS_ON_SCREEN(fBeat) )
|
||||||
DrawLabelText( fBeat, seg->m_sLabel );
|
DrawLabelText( fBeat, seg->GetLabel() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
|
|||||||
|
|
||||||
w.Init( "LABELS" );
|
w.Init( "LABELS" );
|
||||||
FOREACH_CONST( LabelSegment, timing.m_LabelSegments, ls )
|
FOREACH_CONST( LabelSegment, timing.m_LabelSegments, ls )
|
||||||
w.Write( ls->m_iStartRow, ls->m_sLabel.c_str() );
|
w.Write( ls->GetRow(), ls->GetLabel().c_str() );
|
||||||
w.Finish();
|
w.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-24
@@ -248,20 +248,20 @@ void TimingData::SetLabelAtRow( int iRow, const RString sLabel )
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for( i=0; i<m_LabelSegments.size(); i++ )
|
for( i=0; i<m_LabelSegments.size(); i++ )
|
||||||
if( m_LabelSegments[i].m_iStartRow >= iRow )
|
if( m_LabelSegments[i].GetRow() >= iRow )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( i == m_LabelSegments.size() || m_LabelSegments[i].m_iStartRow != iRow )
|
if( i == m_LabelSegments.size() || m_LabelSegments[i].GetRow() != iRow )
|
||||||
{
|
{
|
||||||
if( i == 0 || m_LabelSegments[i-1].m_sLabel != sLabel )
|
if( i == 0 || m_LabelSegments[i-1].GetLabel() != sLabel )
|
||||||
AddLabelSegment( LabelSegment(iRow, sLabel ) );
|
AddLabelSegment( LabelSegment(iRow, sLabel ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( i > 0 && ( m_LabelSegments[i-1].m_sLabel == sLabel || sLabel == "" ) )
|
if( i > 0 && ( m_LabelSegments[i-1].GetLabel() == sLabel || sLabel == "" ) )
|
||||||
m_LabelSegments.erase( m_LabelSegments.begin()+i, m_LabelSegments.begin()+i+1 );
|
m_LabelSegments.erase( m_LabelSegments.begin()+i, m_LabelSegments.begin()+i+1 );
|
||||||
else
|
else
|
||||||
m_LabelSegments[i].m_sLabel = sLabel;
|
m_LabelSegments[i].SetLabel(sLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ int TimingData::GetComboAtRow( int iNoteRow ) const
|
|||||||
|
|
||||||
RString TimingData::GetLabelAtRow( int iRow ) const
|
RString TimingData::GetLabelAtRow( int iRow ) const
|
||||||
{
|
{
|
||||||
return m_LabelSegments[GetLabelSegmentIndexAtRow( iRow )].m_sLabel;
|
return m_LabelSegments[GetLabelSegmentIndexAtRow( iRow )].GetLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
float TimingData::GetWarpAtRow( int iWarpRow ) const
|
float TimingData::GetWarpAtRow( int iWarpRow ) const
|
||||||
@@ -610,7 +610,7 @@ int TimingData::GetLabelSegmentIndexAtRow( int iRow ) const
|
|||||||
for( i=0; i<m_LabelSegments.size()-1; i++ )
|
for( i=0; i<m_LabelSegments.size()-1; i++ )
|
||||||
{
|
{
|
||||||
const LabelSegment& s = m_LabelSegments[i+1];
|
const LabelSegment& s = m_LabelSegments[i+1];
|
||||||
if( s.m_iStartRow > iRow )
|
if( s.GetRow() > iRow )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return static_cast<int>(i);
|
return static_cast<int>(i);
|
||||||
@@ -694,7 +694,7 @@ LabelSegment& TimingData::GetLabelSegmentAtRow( int iRow )
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for( i=0; i<m_LabelSegments.size()-1; i++ )
|
for( i=0; i<m_LabelSegments.size()-1; i++ )
|
||||||
if( m_LabelSegments[i+1].m_iStartRow > iRow )
|
if( m_LabelSegments[i+1].GetRow() > iRow )
|
||||||
break;
|
break;
|
||||||
return m_LabelSegments[i];
|
return m_LabelSegments[i];
|
||||||
}
|
}
|
||||||
@@ -758,11 +758,11 @@ float TimingData::GetPreviousLabelSegmentBeatAtRow( int iRow ) const
|
|||||||
float backup = -1;
|
float backup = -1;
|
||||||
for (unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
for (unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
||||||
{
|
{
|
||||||
if( m_LabelSegments[i].m_iStartRow >= iRow )
|
if( m_LabelSegments[i].GetRow() >= iRow )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
backup = NoteRowToBeat(m_LabelSegments[i].m_iStartRow);
|
backup = m_LabelSegments[i].GetBeat();
|
||||||
}
|
}
|
||||||
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
return (backup > -1) ? backup : NoteRowToBeat(iRow);
|
||||||
}
|
}
|
||||||
@@ -771,11 +771,11 @@ float TimingData::GetNextLabelSegmentBeatAtRow( int iRow ) const
|
|||||||
{
|
{
|
||||||
for (unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
for (unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
||||||
{
|
{
|
||||||
if( m_LabelSegments[i].m_iStartRow <= iRow )
|
if( m_LabelSegments[i].GetRow() <= iRow )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return NoteRowToBeat(m_LabelSegments[i].m_iStartRow);
|
return m_LabelSegments[i].GetBeat();
|
||||||
}
|
}
|
||||||
return NoteRowToBeat(iRow);
|
return NoteRowToBeat(iRow);
|
||||||
}
|
}
|
||||||
@@ -784,7 +784,7 @@ bool TimingData::DoesLabelExist( RString sLabel ) const
|
|||||||
{
|
{
|
||||||
FOREACH_CONST( LabelSegment, m_LabelSegments, seg )
|
FOREACH_CONST( LabelSegment, m_LabelSegments, seg )
|
||||||
{
|
{
|
||||||
if( seg->m_sLabel == sLabel )
|
if( seg->GetLabel() == sLabel )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -1097,13 +1097,14 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool
|
|||||||
|
|
||||||
for ( unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
for ( unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
||||||
{
|
{
|
||||||
const int iSegStart = m_LabelSegments[i].m_iStartRow;
|
LabelSegment &l = m_LabelSegments[i];
|
||||||
|
const int iSegStart = l.GetRow();
|
||||||
if( iSegStart < iStartIndex )
|
if( iSegStart < iStartIndex )
|
||||||
continue;
|
continue;
|
||||||
else if( iSegStart > iEndIndex )
|
else if( iSegStart > iEndIndex )
|
||||||
m_LabelSegments[i].m_iStartRow += lrintf( (iEndIndex - iStartIndex) * (fScale - 1) );
|
l.SetRow(l.GetRow() + lrintf( (iEndIndex - iStartIndex) * (fScale - 1) ));
|
||||||
else
|
else
|
||||||
m_LabelSegments[i].m_iStartRow = lrintf( (iSegStart - iStartIndex) * fScale ) + iStartIndex;
|
l.SetRow(lrintf( (iSegStart - iStartIndex) * fScale ) + iStartIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
for ( unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
||||||
@@ -1228,9 +1229,9 @@ void TimingData::InsertRows( int iStartRow, int iRowsToAdd )
|
|||||||
for( unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
for( unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
||||||
{
|
{
|
||||||
LabelSegment &labl = m_LabelSegments[i];
|
LabelSegment &labl = m_LabelSegments[i];
|
||||||
if( labl.m_iStartRow < iStartRow )
|
if( labl.GetRow() < iStartRow )
|
||||||
continue;
|
continue;
|
||||||
labl.m_iStartRow += iRowsToAdd;
|
labl.SetRow(labl.GetRow() + iRowsToAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
for( unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
||||||
@@ -1398,17 +1399,17 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete )
|
|||||||
for( unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
for( unsigned i = 0; i < m_LabelSegments.size(); i++ )
|
||||||
{
|
{
|
||||||
LabelSegment &labl = m_LabelSegments[i];
|
LabelSegment &labl = m_LabelSegments[i];
|
||||||
|
int keyRow = labl.GetRow();
|
||||||
if( labl.m_iStartRow < iStartRow )
|
if( keyRow < iStartRow )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( labl.m_iStartRow < iStartRow+iRowsToDelete )
|
if( keyRow < iStartRow+iRowsToDelete )
|
||||||
{
|
{
|
||||||
m_LabelSegments.erase( m_LabelSegments.begin()+i, m_LabelSegments.begin()+i+1 );
|
m_LabelSegments.erase( m_LabelSegments.begin()+i, m_LabelSegments.begin()+i+1 );
|
||||||
--i;
|
--i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
labl.m_iStartRow -= iRowsToDelete;
|
labl.SetRow(keyRow - iRowsToDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
for( unsigned i = 0; i < m_SpeedSegments.size(); i++ )
|
||||||
@@ -1693,8 +1694,8 @@ public:
|
|||||||
vector<RString> vLabels;
|
vector<RString> vLabels;
|
||||||
FOREACH_CONST( LabelSegment, p->m_LabelSegments, seg )
|
FOREACH_CONST( LabelSegment, p->m_LabelSegments, seg )
|
||||||
{
|
{
|
||||||
const float fStartRow = NoteRowToBeat(seg->m_iStartRow);
|
const float fStartRow = seg->GetBeat();
|
||||||
const RString sLabel = seg->m_sLabel;
|
const RString sLabel = seg->GetLabel();
|
||||||
vLabels.push_back( ssprintf("%f=%s", fStartRow, sLabel.c_str()) );
|
vLabels.push_back( ssprintf("%f=%s", fStartRow, sLabel.c_str()) );
|
||||||
}
|
}
|
||||||
LuaHelpers::CreateTableFromArray(vLabels, L);
|
LuaHelpers::CreateTableFromArray(vLabels, L);
|
||||||
|
|||||||
@@ -385,89 +385,6 @@ struct ComboSegment
|
|||||||
bool operator>=( const ComboSegment &other ) const { return !operator<(other); }
|
bool operator>=( const ComboSegment &other ) const { return !operator<(other); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Identifies when a chart is entering a different section.
|
|
||||||
*
|
|
||||||
* This is meant for helping to identify different sections of a chart
|
|
||||||
* versus relying on measures and beats alone.
|
|
||||||
*/
|
|
||||||
struct LabelSegment
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @brief Creates a simple Label Segment with default values.
|
|
||||||
*
|
|
||||||
* It is best to override the values as soon as possible.
|
|
||||||
*/
|
|
||||||
LabelSegment() : m_iStartRow(-1), m_sLabel("") { }
|
|
||||||
/**
|
|
||||||
* @brief Creates a Label Segment with the specified starting row and label.
|
|
||||||
* @param s the starting row of this segment.
|
|
||||||
* @param l the label for this section.
|
|
||||||
*/
|
|
||||||
LabelSegment( int s, RString l ): m_iStartRow(max(0, s)),
|
|
||||||
m_sLabel(l) {}
|
|
||||||
/**
|
|
||||||
* @brief Creates a Label Segment with the specified starting beat and label.
|
|
||||||
* @param s the starting beat of this segment.
|
|
||||||
* @param l the label for this section.
|
|
||||||
*/
|
|
||||||
LabelSegment( float s, RString l ):
|
|
||||||
m_iStartRow(max(0, BeatToNoteRow(s))), m_sLabel(l) {}
|
|
||||||
/**
|
|
||||||
* @brief The row in which the ComboSegment activates.
|
|
||||||
*/
|
|
||||||
int m_iStartRow;
|
|
||||||
/**
|
|
||||||
* @brief The label/section name for this point.
|
|
||||||
*/
|
|
||||||
RString m_sLabel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Compares two LabelSegments to see if they are equal to each other.
|
|
||||||
* @param other the other LabelSegment to compare to.
|
|
||||||
* @return the equality of the two segments.
|
|
||||||
*/
|
|
||||||
bool operator==( const LabelSegment &other ) const
|
|
||||||
{
|
|
||||||
COMPARE( m_iStartRow );
|
|
||||||
COMPARE( m_sLabel );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Compares two LabelSegments to see if they are not equal to each other.
|
|
||||||
* @param other the other LabelSegment to compare to.
|
|
||||||
* @return the inequality of the two segments.
|
|
||||||
*/
|
|
||||||
bool operator!=( const LabelSegment &other ) const { return !operator==(other); }
|
|
||||||
/**
|
|
||||||
* @brief Compares two LabelSegments to see if one is less than the other.
|
|
||||||
* @param other the other LabelSegment to compare to.
|
|
||||||
* @return the truth/falsehood of if the first is less than the second.
|
|
||||||
*/
|
|
||||||
bool operator<( const LabelSegment &other ) const { return m_iStartRow < other.m_iStartRow; }
|
|
||||||
/**
|
|
||||||
* @brief Compares two LabelSegments to see if one is less than or equal to the other.
|
|
||||||
* @param other the other LabelSegment to compare to.
|
|
||||||
* @return the truth/falsehood of if the first is less or equal to than the second.
|
|
||||||
*/
|
|
||||||
bool operator<=( const LabelSegment &other ) const
|
|
||||||
{
|
|
||||||
return ( operator<(other) || operator==(other) );
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Compares two LabelSegments to see if one is greater than the other.
|
|
||||||
* @param other the other LabelSegment to compare to.
|
|
||||||
* @return the truth/falsehood of if the first is greater than the second.
|
|
||||||
*/
|
|
||||||
bool operator>( const LabelSegment &other ) const { return !operator<=(other); }
|
|
||||||
/**
|
|
||||||
* @brief Compares two LabelSegments to see if one is greater than or equal to the other.
|
|
||||||
* @param other the other LabelSegment to compare to.
|
|
||||||
* @return the truth/falsehood of if the first is greater than or equal to the second.
|
|
||||||
*/
|
|
||||||
bool operator>=( const LabelSegment &other ) const { return !operator<(other); }
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Identifies when the arrow scroll changes.
|
* @brief Identifies when the arrow scroll changes.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -89,6 +89,23 @@ bool TickcountSegment::operator<( const TickcountSegment &other ) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RString LabelSegment::GetLabel() const
|
||||||
|
{
|
||||||
|
return this->label;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LabelSegment::SetLabel(const RString l)
|
||||||
|
{
|
||||||
|
this->label = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LabelSegment::operator<( const LabelSegment &other ) const
|
||||||
|
{
|
||||||
|
LTCOMPARE(GetRow());
|
||||||
|
LTCOMPARE(GetLabel());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* @author Jason Felds (c) 2011
|
* @author Jason Felds (c) 2011
|
||||||
|
|||||||
@@ -283,6 +283,56 @@ private:
|
|||||||
int ticks;
|
int ticks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Identifies when a chart is entering a different section.
|
||||||
|
*
|
||||||
|
* This is meant for helping to identify different sections of a chart
|
||||||
|
* versus relying on measures and beats alone.
|
||||||
|
*/
|
||||||
|
struct LabelSegment : public TimingSegment<LabelSegment>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief Creates a simple Label Segment with default values.
|
||||||
|
*
|
||||||
|
* It is best to override the values as soon as possible.
|
||||||
|
*/
|
||||||
|
LabelSegment() :
|
||||||
|
TimingSegment<LabelSegment>(), label("") { }
|
||||||
|
/**
|
||||||
|
* @brief Creates a Label Segment with the specified values.
|
||||||
|
* @param s the starting row / beat of this segment.
|
||||||
|
* @param l the label for this section.
|
||||||
|
*/
|
||||||
|
template <typename StartType>
|
||||||
|
LabelSegment( StartType s, RString l ):
|
||||||
|
TimingSegment<LabelSegment>(max((StartType)0, s)),
|
||||||
|
label(l) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the label in this LabelSegment.
|
||||||
|
* @return the label. */
|
||||||
|
RString GetLabel() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the label in this LabelSegment.
|
||||||
|
* @param l the label. */
|
||||||
|
void SetLabel(const RString l);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Compares two LabelSegments to see if one is less than the other.
|
||||||
|
* @param other the other LabelSegment to compare to.
|
||||||
|
* @return the truth/falsehood of if the first is less than the second.
|
||||||
|
*/
|
||||||
|
bool operator<( const LabelSegment &other ) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief The label/section name for this point.
|
||||||
|
*/
|
||||||
|
RString label;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef COMPARE
|
#undef COMPARE
|
||||||
|
|||||||
Reference in New Issue
Block a user