[splittiming] SpeedSegments run on Seconds now.

ScreenEdit's code probably needs to be redone.
At least, someone find a way to remove "Beats"
or "Seconds" from the text entry area.
This commit is contained in:
Jason Felds
2011-05-15 23:48:03 -04:00
parent 059f0357ba
commit e2766cf644
11 changed files with 177 additions and 28 deletions
+7 -3
View File
@@ -558,6 +558,7 @@ Baked Random=Baked Random
Bar=Bar
Battery=Battery
Beat=Beat
Beats=Beats
Big=Big
Blind=Blind
Blink=Blink
@@ -694,6 +695,7 @@ Right=Right
Roll=Roll
Romanization=Transliterate
SHOW=Show
Seconds=Seconds
Select=Select
Servers=Servers
Shift Left=Shift Left
@@ -853,7 +855,8 @@ Edit combo=Edit combo
Edit label=Edit label
Edit warp=Edit warp
Edit speed (percent)=Edit speed (percent)
Edit speed (wait)=Edit speed (wait in beats)
Edit speed (wait)=Edit speed (length)
Edit speed (mode)=Edit speed (mode)
Editor options=Options
EditorShowBGChangesPlay=Show Backgrounds
Erase step timing=Erase step timing
@@ -1229,8 +1232,9 @@ Enter a new Tickcount value.=Enter a new Tickcount value.
Enter a new Combo value.=Enter a new Combo value.
Enter a new Label value.=Enter a name for this section of the chart.
Enter a new Warp value.=Enter the beat you will warp to when you reach this point.
Enter a new Speed percent value.=Enter the ratio for speed scrolling. 1 is the default.
Enter a new Speed wait value.=Enter how long in beats it takes to change. 0 is instant.
Enter a new Speed percent value.=Enter the ratio for speed scrolling.\n\n1 is the default scroll.
Enter a new Speed wait value.=Enter how long in seconds/beats it takes to change.\n\n0 is instant.
Enter a new Speed mode value.=Enter how this segment is handled.\n\nType "0" for beats, "1" for seconds.
Are you sure you want to erase this chart's timing data?=Are you sure you want to erase this chart's timing data?
Enter a new artist transliteration.=Enter a new artist transliteration.
Enter a new artist.=Enter a new artist.
+15 -3
View File
@@ -259,12 +259,24 @@ float ArrowEffects::GetYOffset( const PlayerState* pPlayerState, int iCol, float
{
SpeedSegment &seg = tim.GetSpeedSegmentAtBeat( fSongBeat );
float fStartBeat = NoteRowToBeat(seg.m_iStartRow);
float fStartTime = tim.GetElapsedTimeFromBeat( fStartBeat );
float fEndTime;
if( fStartBeat + seg.m_fWait >= fSongBeat )
if( seg.m_usMode == 1 ) // seconds
{
fEndTime = fStartTime + seg.m_fWait;
}
else
{
fEndTime = tim.GetElapsedTimeFromBeat( fStartBeat + seg.m_fWait );
}
float fCurTime = tim.GetElapsedTimeFromBeat( fSongBeat );
if( fEndTime >= fCurTime )
{
const float fPriorSpeed = tim.m_SpeedSegments[index - 1].m_fPercent;
float fBeatsUsed = fSongBeat - fStartBeat;
float fRatioUsed = fBeatsUsed / seg.m_fWait;
float fTimeUsed = fCurTime - fStartTime;
float fRatioUsed = fTimeUsed / (fEndTime - fStartTime);
float fDistance = fPriorSpeed - seg.m_fPercent;
float fRatioNeed = fRatioUsed * -fDistance;
+3 -3
View File
@@ -602,7 +602,7 @@ void NoteField::DrawLabelText( const float fBeat, RString sLabel )
m_textMeasureNumber.Draw();
}
void NoteField::DrawSpeedText( const float fBeat, float fPercent, float fWait )
void NoteField::DrawSpeedText( const float fBeat, float fPercent, float fWait, unsigned short usMode )
{
const float fYOffset = ArrowEffects::GetYOffset( m_pPlayerState, 0, fBeat );
const float fYPos = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffset, m_fYReverseOffsetPixels );
@@ -614,7 +614,7 @@ void NoteField::DrawSpeedText( const float fBeat, float fPercent, float fWait )
m_textMeasureNumber.SetHorizAlign( SPEED_IS_LEFT_SIDE ? align_right : align_left );
m_textMeasureNumber.SetDiffuse( SPEED_COLOR );
m_textMeasureNumber.SetGlow( RageColor(1,1,1,RageFastCos(RageTimer::GetTimeSinceStartFast()*2)/2+0.5f) );
m_textMeasureNumber.SetText( ssprintf("%.3f\n--\n%.3f", fPercent, fWait) );
m_textMeasureNumber.SetText( ssprintf("%.3f\n%s\n%.3f", fPercent, (usMode == 1 ? "S" : "B"), fWait) );
m_textMeasureNumber.SetXY( (SPEED_IS_LEFT_SIDE ? -xBase - xOffset : xBase + xOffset), fYPos );
m_textMeasureNumber.Draw();
}
@@ -941,7 +941,7 @@ void NoteField::DrawPrimitives()
{
float fBeat = NoteRowToBeat(seg->m_iStartRow);
if( IS_ON_SCREEN(fBeat) )
DrawSpeedText( fBeat, seg->m_fPercent, seg->m_fWait );
DrawSpeedText( fBeat, seg->m_fPercent, seg->m_fWait, seg->m_usMode );
}
}
}
+1 -1
View File
@@ -64,7 +64,7 @@ protected:
void DrawTickcountText( const float fBeat, int iTicks );
void DrawComboText( const float fBeat, int iCombo );
void DrawLabelText( const float fBeat, RString sLabel );
void DrawSpeedText( const float fBeat, float fPercent, float fWait );
void DrawSpeedText( const float fBeat, float fPercent, float fWait, unsigned short usMode );
void DrawAttackText( const float fBeat, const Attack &attack );
void DrawBGChangeText( const float fBeat, const RString sNewBGName );
float GetWidth() const;
+9 -1
View File
@@ -306,6 +306,11 @@ void SMALoader::ProcessBeatsPerMeasure( TimingData &out, const RString sParam )
}
}
float BeatToSeconds(float fromBeat, RString toSomething)
{
return 0;
}
void SMALoader::ProcessSpeeds( TimingData &out, const int iRowsPerBeat, const RString sParam )
{
vector<RString> vs1;
@@ -329,7 +334,10 @@ void SMALoader::ProcessSpeeds( TimingData &out, const int iRowsPerBeat, const RS
const float fBeat = RowToBeat( vs2[0], iRowsPerBeat );
SpeedSegment seg( fBeat, StringToFloat( vs2[1] ), StringToFloat( vs2[2] ));
unsigned short tmp = ( (vs2[2].find("s") || vs2[2].find("S") )
? 1 : 0);
SpeedSegment seg( fBeat, StringToFloat( vs2[1] ), StringToFloat( vs2[2] ), tmp);
if( fBeat < 0 )
{
+7 -2
View File
@@ -141,7 +141,12 @@ void SSCLoader::ProcessSpeeds( TimingData &out, const RString sParam )
vs2.push_back("0");
}
if( vs2.size() < 3 )
if( vs2.size() == 3 )
{
vs2.push_back("0");
}
if( vs2.size() < 4 )
{
LOG->UserLog( "Song file", "(UNKNOWN)", "has an speed change with %i values.", (int)vs2.size() );
continue;
@@ -149,7 +154,7 @@ void SSCLoader::ProcessSpeeds( TimingData &out, const RString sParam )
const float fBeat = StringToFloat( vs2[0] );
SpeedSegment seg( fBeat, StringToFloat( vs2[1] ), StringToFloat( vs2[2] ));
SpeedSegment seg( fBeat, StringToFloat( vs2[1] ), StringToFloat( vs2[2] ), static_cast<unsigned short>(StringToInt(vs2[3])));
if( fBeat < 0 )
{
+3 -1
View File
@@ -77,6 +77,8 @@ struct TimingTagWriter {
void Write( const int row, const int value ) { Write( row, ssprintf( "%d", value ) ); }
void Write( const int row, const int a, const int b ) { Write( row, ssprintf( "%d=%d", a, b ) ); }
void Write( const int row, const float a, const float b ) { Write( row, ssprintf( "%.6f=%.6f", a, b) ); }
void Write( const int row, const float a, const float b, const unsigned short c )
{ Write( row, ssprintf( "%.6f=%.6f=%hd", a, b, c) ); }
void Init( const RString sTag ) { m_sNext = "#" + sTag + ":"; }
void Finish( ) { m_pvsLines->push_back( ( m_sNext != "," ? m_sNext : "" ) + ";" ); }
@@ -136,7 +138,7 @@ static void GetTimingTags( vector<RString> &lines, TimingData timing, bool bIsSo
{
w.Init( "SPEEDS" );
FOREACH_CONST( SpeedSegment, timing.m_SpeedSegments, ss )
w.Write( ss->m_iStartRow, ss->m_fPercent, ss->m_fWait );
w.Write( ss->m_iStartRow, ss->m_fPercent, ss->m_fWait, ss->m_usMode );
w.Finish();
}
+34
View File
@@ -85,6 +85,7 @@ AutoScreenMessage( SM_BackFromLabelChange );
AutoScreenMessage( SM_BackFromWarpChange );
AutoScreenMessage( SM_BackFromSpeedPercentChange );
AutoScreenMessage( SM_BackFromSpeedWaitChange );
AutoScreenMessage( SM_BackFromSpeedModeChange );
AutoScreenMessage( SM_DoEraseStepTiming );
AutoScreenMessage( SM_DoSaveAndExit );
AutoScreenMessage( SM_DoExit );
@@ -580,6 +581,7 @@ static MenuDef g_TimingDataInformation(
MenuRowDef( ScreenEdit::warp, "Edit warp", true, EditMode_Full, true, true, 0, NULL ),
MenuRowDef( ScreenEdit::speed_percent, "Edit speed (percent)", true, EditMode_Full, true, true, 0, NULL ),
MenuRowDef( ScreenEdit::speed_wait, "Edit speed (wait)", true, EditMode_Full, true, true, 0, NULL ),
MenuRowDef( ScreenEdit::speed_mode, "Edit speed (mode)", true, EditMode_Full, true, true, 0, "Beats", "Seconds" ),
MenuRowDef( ScreenEdit::erase_step_timing, "Erase step timing", true, EditMode_Full, true, true, 0, NULL )
);
@@ -2779,6 +2781,19 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
}
SetDirty( true );
}
else if ( SM == SM_BackFromSpeedModeChange )
{
int tmp = StringToInt(ScreenTextEntry::s_sLastAnswer );
if( tmp == 0 )
{
GetAppropriateTiming().SetSpeedModeAtBeat( GetBeat(), 0 );
}
else
{
GetAppropriateTiming().SetSpeedModeAtBeat( GetBeat(), 1 );
}
SetDirty( true );
}
else if( SM == SM_BackFromBGChange )
{
@@ -3200,11 +3215,15 @@ void ScreenEdit::DisplayTimingMenu()
g_TimingDataInformation.rows[speed_percent].SetOneUnthemedChoice( ssprintf("%.5f", pTime.GetSpeedPercentAtBeat( fBeat ) ) );
g_TimingDataInformation.rows[speed_wait].SetOneUnthemedChoice( ssprintf("%.5f", pTime.GetSpeedWaitAtBeat( fBeat ) ) );
RString starting = ( pTime.GetSpeedModeAtBeat( fBeat ) == 1 ? "Seconds" : "Beats" );
g_TimingDataInformation.rows[speed_mode].SetOneUnthemedChoice( starting.c_str() );
g_TimingDataInformation.rows[tickcount].bEnabled = GAMESTATE->m_bIsEditorStepTiming;
g_TimingDataInformation.rows[combo].bEnabled = GAMESTATE->m_bIsEditorStepTiming;
g_TimingDataInformation.rows[warp].bEnabled = GAMESTATE->m_bIsEditorStepTiming;
g_TimingDataInformation.rows[speed_percent].bEnabled = GAMESTATE->m_bIsEditorStepTiming;
g_TimingDataInformation.rows[speed_wait].bEnabled = GAMESTATE->m_bIsEditorStepTiming;
g_TimingDataInformation.rows[speed_mode].bEnabled = GAMESTATE->m_bIsEditorStepTiming;
EditMiniMenu( &g_TimingDataInformation, SM_BackFromTimingDataInformation );
}
@@ -3885,6 +3904,7 @@ static LocalizedString ENTER_LABEL_VALUE ( "ScreenEdit", "Enter a new Label va
static LocalizedString ENTER_WARP_VALUE ( "ScreenEdit", "Enter a new Warp value." );
static LocalizedString ENTER_SPEED_PERCENT_VALUE ( "ScreenEdit", "Enter a new Speed percent value." );
static LocalizedString ENTER_SPEED_WAIT_VALUE ( "ScreenEdit", "Enter a new Speed wait value." );
static LocalizedString ENTER_SPEED_MODE_VALUE ( "ScreenEdit", "Enter a new Speed mode value." );
static LocalizedString CONFIRM_TIMING_ERASE ( "ScreenEdit", "Are you sure you want to erase this chart's timing data?" );
void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice c, const vector<int> &iAnswers )
{
@@ -3984,9 +4004,23 @@ void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice
10
);
break;
case speed_mode:
{
RString sMode = ( GetAppropriateTiming().GetSpeedModeAtBeat( GetBeat() ) == 0 ?
"Beats" : "Seconds" );
ScreenTextEntry::TextEntry(
SM_BackFromSpeedModeChange,
ENTER_SPEED_MODE_VALUE,
sMode.c_str(),
10
);
break;
}
case erase_step_timing:
ScreenPrompt::Prompt( SM_DoEraseStepTiming, CONFIRM_TIMING_ERASE , PROMPT_YES_NO, ANSWER_NO );
break;
}
}
+7
View File
@@ -499,6 +499,7 @@ public:
// speed,
speed_percent,
speed_wait,
speed_mode,
erase_step_timing,
NUM_TIMING_DATA_INFORMATION_CHOICES
};
@@ -532,6 +533,12 @@ public:
delete_change,
NUM_BGCHANGE_CHOICES
};
enum SpeedSegmentModes
{
SSMODE_Beats,
SSMODE_Seconds
};
/**
* @brief Take care of any background changes that the user wants.
+28 -6
View File
@@ -255,7 +255,7 @@ void TimingData::SetLabelAtRow( int iRow, const RString sLabel )
}
}
void TimingData::SetSpeedAtRow( int iRow, float fPercent, float fWait )
void TimingData::SetSpeedAtRow( int iRow, float fPercent, float fWait, unsigned short usMode )
{
unsigned i;
for( i = 0; i < m_SpeedSegments.size(); i++ )
@@ -268,31 +268,48 @@ void TimingData::SetSpeedAtRow( int iRow, float fPercent, float fWait )
{
if( i == 0 ||
( m_SpeedSegments[i-1].m_fPercent != fPercent
|| m_SpeedSegments[i-1].m_fWait != fWait ) )
AddSpeedSegment( SpeedSegment(iRow, fPercent, fWait) );
|| m_SpeedSegments[i-1].m_fWait != fWait
|| m_SpeedSegments[i-1].m_usMode != usMode ) )
AddSpeedSegment( SpeedSegment(iRow, fPercent, fWait, usMode) );
}
else
{
if( i > 0 && m_SpeedSegments[i-1].m_fPercent == fPercent
&& m_SpeedSegments[i-1].m_fWait == fWait )
&& m_SpeedSegments[i-1].m_fWait == fWait
&& m_SpeedSegments[i-1].m_usMode == usMode )
m_SpeedSegments.erase( m_SpeedSegments.begin()+i,
m_SpeedSegments.begin()+i+1 );
else
{
m_SpeedSegments[i].m_fPercent = fPercent;
m_SpeedSegments[i].m_fWait = fWait;
m_SpeedSegments[i].m_usMode = usMode;
}
}
}
void TimingData::SetSpeedPercentAtRow( int iRow, float fPercent )
{
SetSpeedAtRow( iRow, fPercent, GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).m_fWait );
SetSpeedAtRow( iRow,
fPercent,
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).m_fWait,
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).m_usMode);
}
void TimingData::SetSpeedWaitAtRow( int iRow, float fWait )
{
SetSpeedAtRow( iRow, GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).m_fPercent, fWait );
SetSpeedAtRow( iRow,
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).m_fPercent,
fWait,
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).m_usMode);
}
void TimingData::SetSpeedModeAtRow( int iRow, unsigned short usMode )
{
SetSpeedAtRow( iRow,
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).m_fPercent,
GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).m_fWait,
usMode );
}
@@ -351,6 +368,11 @@ float TimingData::GetSpeedWaitAtRow( int iRow )
return GetSpeedSegmentAtRow( iRow ).m_fWait;
}
unsigned short TimingData::GetSpeedModeAtRow( int iRow )
{
return GetSpeedSegmentAtRow( iRow ).m_usMode;
}
// Multiply the BPM in the range [fStartBeat,fEndBeat) by fFactor.
void TimingData::MultiplyBPMInBeatRange( int iStartIndex, int iEndIndex, float fFactor )
{
+63 -8
View File
@@ -660,20 +660,22 @@ struct LabelSegment
struct SpeedSegment
{
/** @brief Sets up the SpeedSegment with default values. */
SpeedSegment(): m_iStartRow(0), m_fPercent(1), m_fWait(0) {}
SpeedSegment(): m_iStartRow(0),
m_fPercent(1), m_fWait(0), m_usMode(0) {}
/**
* @brief Sets up the SpeedSegment with specified values.
* @param i The row this activates.
* @param p The percentage to use. */
SpeedSegment(int i, float p): m_iStartRow(0), m_fPercent(p), m_fWait(0) {}
SpeedSegment(int i, float p): m_iStartRow(0),
m_fPercent(p), m_fWait(0), m_usMode(0) {}
/**
* @brief Sets up the SpeedSegment with specified values.
* @param r The beat this activates.
* @param p The percentage to use. */
SpeedSegment(float r, float p): m_iStartRow(BeatToNoteRow(r)),
m_fPercent(p), m_fWait(0) {}
m_fPercent(p), m_fWait(0), m_usMode(0) {}
/**
* @brief Sets up the SpeedSegment with specified values.
@@ -681,7 +683,7 @@ struct SpeedSegment
* @param p The percentage to use.
* @param w The number of beats to wait. */
SpeedSegment(int i, float p, float w): m_iStartRow(i),
m_fPercent(p), m_fWait(w) {}
m_fPercent(p), m_fWait(w), m_usMode(0) {}
/**
* @brief Sets up the SpeedSegment with specified values.
@@ -689,17 +691,43 @@ struct SpeedSegment
* @param p The percentage to use.
* @param w The number of beats to wait. */
SpeedSegment(float r, float p, float w): m_iStartRow(BeatToNoteRow(r)),
m_fPercent(p), m_fWait(w) {}
m_fPercent(p), m_fWait(w), m_usMode(0) {}
/**
* @brief Sets up the SpeedSegment with specified values.
* @param i The row this activates.
* @param p The percentage to use.
* @param w The number of beats/seconds to wait.
* @param k The mode used for the wait variable. */
SpeedSegment(int i, float p, float w, unsigned short k): m_iStartRow(i),
m_fPercent(p), m_fWait(w), m_usMode(k) {}
/**
* @brief Sets up the SpeedSegment with specified values.
* @param r The beat this activates.
* @param p The percentage to use.
* @param w The number of beats/seconds to wait.
* @param k The mode used for the wait variable.*/
SpeedSegment(float r, float p, float w, unsigned short k): m_iStartRow(BeatToNoteRow(r)),
m_fPercent(p), m_fWait(w), m_usMode(k) {}
/** @brief The row in which the ComboSegment activates. */
int m_iStartRow;
/** @brief The percentage to use when multiplying the Player's BPM. */
float m_fPercent;
/**
* @brief The number of beats to wait for the change to take place.
* @brief The number of beats or seconds to wait for the change to take place.
*
* A value of 0 means this is immediate. */
float m_fWait;
/**
* @brief The mode that this segment uses for the math.
*
* 0: beats
* 1: seconds
* other
*/
unsigned short m_usMode;
/**
* @brief Compares two SpeedSegments to see if they are equal to each other.
@@ -710,6 +738,7 @@ struct SpeedSegment
{
COMPARE( m_iStartRow );
COMPARE( m_fPercent );
COMPARE( m_usMode );
COMPARE( m_fWait );
return true;
}
@@ -1364,20 +1393,34 @@ public:
* @return the wait.
*/
float GetSpeedWaitAtBeat( float fBeat ) { return GetSpeedWaitAtRow( BeatToNoteRow(fBeat) ); }
/**
* @brief Retrieve the Speed's mode at the given row.
* @param iNoteRow the row in question.
* @return the mode.
*/
unsigned short GetSpeedModeAtRow( int iNoteRow );
/**
* @brief Retrieve the Speed's mode at the given beat.
* @param fBeat the beat in question.
* @return the mode.
*/
unsigned short GetSpeedModeAtBeat( float fBeat ) { return GetSpeedModeAtRow( BeatToNoteRow(fBeat) ); }
/**
* @brief Set the row to have the new Speed.
* @param iNoteRow the row to have the new Speed.
* @param fPercent the percent.
* @param fWait the wait.
* @param usMode the mode.
*/
void SetSpeedAtRow( int iNoteRow, float fPercent, float fWait );
void SetSpeedAtRow( int iNoteRow, float fPercent, float fWait, unsigned short usMode );
/**
* @brief Set the beat to have the new Speed.
* @param fBeat the beat to have the new Speed.
* @param fPercent the percent.
* @param fWait the wait.
* @param usMode the mode.
*/
void SetSpeedAtBeat( float fBeat, float fPercent, float fWait ) { SetSpeedAtRow( BeatToNoteRow(fBeat), fPercent, fWait ); }
void SetSpeedAtBeat( float fBeat, float fPercent, float fWait, unsigned short usMode ) { SetSpeedAtRow( BeatToNoteRow(fBeat), fPercent, fWait, usMode ); }
/**
* @brief Set the row to have the new Speed percent.
* @param iNoteRow the row to have the new Speed percent.
@@ -1402,6 +1445,18 @@ public:
* @param fWait the wait.
*/
void SetSpeedWaitAtBeat( float fBeat, float fWait ) { SetSpeedWaitAtRow( BeatToNoteRow(fBeat), fWait); }
/**
* @brief Set the row to have the new Speed mode.
* @param iNoteRow the row to have the new Speed mode.
* @param usMode the mode.
*/
void SetSpeedModeAtRow( int iNoteRow, unsigned short usMode );
/**
* @brief Set the beat to have the new Speed mode.
* @param fBeat the beat to have the new Speed mode.
* @param usMode the mode.
*/
void SetSpeedModeAtBeat( float fBeat, unsigned short usMode ) { SetSpeedModeAtRow( BeatToNoteRow(fBeat), usMode); }
/**
* @brief Retrieve the SpeedSegment at the specified row.
* @param iNoteRow the row that has a SpeedSegment.