this is the only place that uses GetCopies; eliminate it
This commit is contained in:
@@ -56,13 +56,22 @@ ScreenTestSound::ScreenTestSound( CString sClassName ) : Screen( sClassName )
|
|||||||
UpdateText(i);
|
UpdateText(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenTestSound::~ScreenTestSound()
|
||||||
|
{
|
||||||
|
for( int i = 0; i < nsounds; ++i )
|
||||||
|
{
|
||||||
|
/* Delete copied sounds. */
|
||||||
|
vector<RageSound *> &snds = m_sSoundCopies[i];
|
||||||
|
for( unsigned j = 0; j < snds.size(); ++j )
|
||||||
|
delete snds[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenTestSound::UpdateText(int n)
|
void ScreenTestSound::UpdateText(int n)
|
||||||
{
|
{
|
||||||
CString fn = Basename( s[n].s.GetLoadedFilePath() );
|
CString fn = Basename( s[n].s.GetLoadedFilePath() );
|
||||||
|
|
||||||
vector<RageSound *> snds;
|
vector<RageSound *> &snds = m_sSoundCopies[n];
|
||||||
SOUNDMAN->GetCopies(s[n].s, snds);
|
|
||||||
|
|
||||||
CString pos;
|
CString pos;
|
||||||
for(unsigned p = 0; p < snds.size(); ++p)
|
for(unsigned p = 0; p < snds.size(); ++p)
|
||||||
@@ -92,8 +101,22 @@ void ScreenTestSound::UpdateText(int n)
|
|||||||
void ScreenTestSound::Update(float f)
|
void ScreenTestSound::Update(float f)
|
||||||
{
|
{
|
||||||
Screen::Update(f);
|
Screen::Update(f);
|
||||||
|
|
||||||
for(int i = 0; i < nsounds; ++i)
|
for(int i = 0; i < nsounds; ++i)
|
||||||
|
{
|
||||||
UpdateText(i);
|
UpdateText(i);
|
||||||
|
|
||||||
|
/* Delete copied sounds that have finished playing. */
|
||||||
|
vector<RageSound *> &snds = m_sSoundCopies[i];
|
||||||
|
for( unsigned j = 0; j < snds.size(); ++j )
|
||||||
|
{
|
||||||
|
if( snds[j]->IsPlaying() )
|
||||||
|
continue;
|
||||||
|
delete snds[j];
|
||||||
|
snds.erase( snds.begin()+j );
|
||||||
|
--j;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenTestSound::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
void ScreenTestSound::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
||||||
@@ -112,10 +135,23 @@ void ScreenTestSound::Input( const DeviceInput& DeviceI, const InputEventType ty
|
|||||||
case '4':
|
case '4':
|
||||||
case '5': selected = DeviceI.button - '0'-1; break;
|
case '5': selected = DeviceI.button - '0'-1; break;
|
||||||
case 'p':
|
case 'p':
|
||||||
s[selected].s.Play();
|
{
|
||||||
|
/* We want to be able to read the position of copied sounds; if we let
|
||||||
|
* RageSound copy itself, then the copy will be owned by RageSoundManager
|
||||||
|
* and we won't be allowed to touch it. Copy it ourself. */
|
||||||
|
RageSound *pCopy = new RageSound( s[selected].s );
|
||||||
|
m_sSoundCopies[selected].push_back( pCopy );
|
||||||
|
pCopy->Play();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 's':
|
case 's':
|
||||||
s[selected].s.Stop();
|
for( int i = 0; i < nsounds; ++i )
|
||||||
|
{
|
||||||
|
/* Stop copied sounds. */
|
||||||
|
vector<RageSound *> &snds = m_sSoundCopies[i];
|
||||||
|
for( unsigned j = 0; j < snds.size(); ++j )
|
||||||
|
snds[j]->Stop();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class ScreenTestSound : public Screen
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScreenTestSound( CString sName );
|
ScreenTestSound( CString sName );
|
||||||
|
~ScreenTestSound();
|
||||||
|
|
||||||
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
|
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
|
||||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||||
@@ -23,6 +24,7 @@ public:
|
|||||||
BitmapText txt;
|
BitmapText txt;
|
||||||
};
|
};
|
||||||
Sound s[nsounds];
|
Sound s[nsounds];
|
||||||
|
vector<RageSound *> m_sSoundCopies[nsounds];
|
||||||
BitmapText HEEEEEEEEELP;
|
BitmapText HEEEEEEEEELP;
|
||||||
|
|
||||||
int selected;
|
int selected;
|
||||||
|
|||||||
Reference in New Issue
Block a user