void CBaseEventPropertiesDialog::PopulateTagList( CEventParams *params )
{
	CChoreoScene *scene = params->m_pScene;
	if ( !scene )
		return;

	HWND control = GetControl( IDC_TAGS );
	if ( control )
	{
		SendMessage( control, CB_RESETCONTENT, 0, 0 ); 
		SendMessage( control, WM_SETTEXT , 0, (LPARAM)va( "\"%s\" \"%s\"", params->m_szTagName, params->m_szTagWav ) );

		for ( int i = 0; i < scene->GetNumActors(); i++ )
		{
			CChoreoActor *a = scene->GetActor( i );
			if ( !a )
				continue;

			for ( int j = 0; j < a->GetNumChannels(); j++ )
			{
				CChoreoChannel *c = a->GetChannel( j );
				if ( !c )
					continue;

				for ( int k = 0 ; k < c->GetNumEvents(); k++ )
				{
					CChoreoEvent *e = c->GetEvent( k );
					if ( !e )
						continue;

					if ( e->GetNumRelativeTags() <= 0 )
						continue;

					// add each tag to combo box
					for ( int t = 0; t < e->GetNumRelativeTags(); t++ )
					{
						CEventRelativeTag *tag = e->GetRelativeTag( t );
						if ( !tag )
							continue;

						SendMessage( control, CB_ADDSTRING, 0, (LPARAM)va( "\"%s\" \"%s\"", tag->GetName(), e->GetParameters() ) ); 
					}
				}
			}
		}
	}
}
void CheckForOverlappingFlexTracks( CChoreoScene *scene )
{
    for ( int a = 0; a < scene->GetNumActors(); ++a )
    {
        CChoreoActor *actor = scene->GetActor( a );

        CUtlRBTree< CChoreoEvent * >  actorFlexEvents( 0, 0, ChoreEventStartTimeLessFunc );

        for ( int c = 0; c < actor->GetNumChannels(); ++c )
        {
            CChoreoChannel *channel = actor->GetChannel( c );

            for ( int e = 0 ; e < channel->GetNumEvents(); ++e )
            {
                CChoreoEvent *event = channel->GetEvent( e );

                if ( event->GetType() != CChoreoEvent::FLEXANIMATION )
                    continue;

                actorFlexEvents.Insert( event );
            }
        }

        CUtlVector< CUtlLinkedList< CChoreoEvent*, int > >	rows;

        bool done = false;
        int i;
        // Now check for overlaps
        for ( i = actorFlexEvents.FirstInorder(); i != actorFlexEvents.InvalidIndex() && !done; i = actorFlexEvents.NextInorder( i ) )
        {
            CChoreoEvent *e = actorFlexEvents[ i ];
            if ( !rows.Count() )
            {
                rows.AddToTail();

                CUtlLinkedList< CChoreoEvent*, int >& list = rows[ 0 ];
                list.AddToHead( e );
                continue;
            }

            // Does it come totally after what's in rows[0]?
            int rowCount = rows.Count();
            bool addrow = true;

            for ( int j = 0; j < rowCount; j++ )
            {
                CUtlLinkedList< CChoreoEvent*, int >& list = rows[ j ];

                char offender[ 256 ];
                if ( !EventCollidesWithRows( list, e, offender, sizeof( offender ) ) )
                {
                    // Update row event list
                    list.AddToHead( e );
                    addrow = false;
                    break;
                }
                else
                {
                    Msg( "[%s] has overlapping events for actor [%s] [%s] [flex: %s]\n",
                         scene->GetFilename(), actor->GetName(), e->GetName(), offender );
                    done = true;
                }
            }

            if ( addrow )
            {
                // Add a new row
                int idx = rows.AddToTail();
                CUtlLinkedList< CChoreoEvent *, int >& list = rows[ idx ];
                list.AddToHead( e );
            }
        }

        // Assert( rows.Count() <= 1 );
    }
}