Code/Editor/TrackView/SequenceKeyUIControls.cpp
void CSequenceKeyUIControls::OnUIChange(IVariable* pVar, CTrackViewKeyBundle& selectedKeys)
{
    CTrackViewSequence* sequence = GetIEditor()->GetAnimation()->GetSequence();

    if (!sequence || !selectedKeys.AreAllKeysOfSameType() || m_skipOnUIChange)
    {
        return;
    }

    for (unsigned int keyIndex = 0; keyIndex < selectedKeys.GetKeyCount(); ++keyIndex)
    {
        CTrackViewKeyHandle keyHandle = selectedKeys.GetKey(keyIndex);

        CAnimParamType paramType = keyHandle.GetTrack()->GetParameterType();
        if (paramType == AnimParamType::Sequence)
        {
            ISequenceKey sequenceKey;
            keyHandle.GetKey(&sequenceKey);

            AZ::EntityId seqOwnerId;
            if (pVar == mv_sequence.GetVar())
            {
                QString entityIdString = mv_sequence;
                seqOwnerId = AZ::EntityId(static_cast<AZ::u64>(entityIdString.toULongLong()));

                sequenceKey.szSelection.clear();            // clear deprecated legacy data
                sequenceKey.sequenceEntityId = seqOwnerId;
            }

            SyncValue(mv_overrideTimes, sequenceKey.bOverrideTimes, false, pVar);

            IAnimSequence* pSequence = GetIEditor()->GetSystem()->GetIMovieSystem()->FindSequence(seqOwnerId);

            if (!sequenceKey.bOverrideTimes)
            {
                if (pSequence)
                {
                    sequenceKey.fStartTime = pSequence->GetTimeRange().start;
                    sequenceKey.fEndTime = pSequence->GetTimeRange().end;
                }
                else
                {
                    sequenceKey.fStartTime = 0.0f;
                    sequenceKey.fEndTime = 0.0f;
                }
            }
            else
            {
                SyncValue(mv_startTime, sequenceKey.fStartTime, false, pVar);
                SyncValue(mv_endTime, sequenceKey.fEndTime, false, pVar);
            }

            sequenceKey.fDuration = sequenceKey.fEndTime - sequenceKey.fStartTime > 0 ? sequenceKey.fEndTime - sequenceKey.fStartTime : 0.0f;

            IMovieSystem* pMovieSystem = GetIEditor()->GetSystem()->GetIMovieSystem();

            if (pMovieSystem != nullptr)
            {
                pMovieSystem->SetStartEndTime(pSequence, sequenceKey.fStartTime, sequenceKey.fEndTime);
            }

            bool isDuringUndo = false;
            AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(isDuringUndo, &AzToolsFramework::ToolsApplicationRequests::Bus::Events::IsDuringUndoRedo);

            if (isDuringUndo)
            {
                keyHandle.SetKey(&sequenceKey);
            }
            else
            {
                AzToolsFramework::ScopedUndoBatch undoBatch("Set Key Value");
                keyHandle.SetKey(&sequenceKey);
                undoBatch.MarkEntityDirty(sequence->GetSequenceComponentEntityId());
            }

        }
    }
}
// Called when UI variable changes.
Called when UI variable changes.
Called when UI variable changes .
void CSequenceKeyUIControls::OnUIChange(IVariable* pVar, CTrackViewKeyBundle& selectedKeys)
{
    CTrackViewSequence* sequence = GetIEditor()->GetAnimation()->GetSequence();
    if (!sequence || !selectedKeys.AreAllKeysOfSameType() || m_skipOnUIChange)
    {
        return;
    }
    for (unsigned int keyIndex = 0; keyIndex < selectedKeys.GetKeyCount(); ++keyIndex)
    {
        CTrackViewKeyHandle keyHandle = selectedKeys.GetKey(keyIndex);
        CAnimParamType paramType = keyHandle.GetTrack()->GetParameterType();
        if (paramType == AnimParamType::Sequence)
        {
            ISequenceKey sequenceKey;
            keyHandle.GetKey(&sequenceKey);
            AZ::EntityId seqOwnerId;
            if (pVar == mv_sequence.GetVar())
            {
                QString entityIdString = mv_sequence;
                seqOwnerId = AZ::EntityId(static_cast<AZ::u64>(entityIdString.toULongLong()));
                sequenceKey.szSelection.clear();            
                sequenceKey.sequenceEntityId = seqOwnerId;
            }
            SyncValue(mv_overrideTimes, sequenceKey.bOverrideTimes, false, pVar);
            IAnimSequence* pSequence = GetIEditor()->GetSystem()->GetIMovieSystem()->FindSequence(seqOwnerId);
            if (!sequenceKey.bOverrideTimes)
            {
                if (pSequence)
                {
                    sequenceKey.fStartTime = pSequence->GetTimeRange().start;
                    sequenceKey.fEndTime = pSequence->GetTimeRange().end;
                }
                else
                {
                    sequenceKey.fStartTime = 0.0f;
                    sequenceKey.fEndTime = 0.0f;
                }
            }
            else
            {
                SyncValue(mv_startTime, sequenceKey.fStartTime, false, pVar);
                SyncValue(mv_endTime, sequenceKey.fEndTime, false, pVar);
            }
            sequenceKey.fDuration = sequenceKey.fEndTime - sequenceKey.fStartTime > 0 ? sequenceKey.fEndTime - sequenceKey.fStartTime : 0.0f;
            IMovieSystem* pMovieSystem = GetIEditor()->GetSystem()->GetIMovieSystem();
            if (pMovieSystem != nullptr)
            {
                pMovieSystem->SetStartEndTime(pSequence, sequenceKey.fStartTime, sequenceKey.fEndTime);
            }
            bool isDuringUndo = false;
            AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(isDuringUndo, &AzToolsFramework::ToolsApplicationRequests::Bus::Events::IsDuringUndoRedo);
            if (isDuringUndo)
            {
                keyHandle.SetKey(&sequenceKey);
            }
            else
            {
                AzToolsFramework::ScopedUndoBatch undoBatch("Set Key Value");
                keyHandle.SetKey(&sequenceKey);
                undoBatch.MarkEntityDirty(sequence->GetSequenceComponentEntityId());
            }
        }
    }
}
void CSequenceKeyUIControls :: OnUIChange ( IVariable * pVar , CTrackViewKeyBundle & selectedKeys ) { CTrackViewSequence * sequence = GetIEditor ( ) -> GetAnimation ( ) -> GetSequence ( ) ; if ( ! sequence || ! selectedKeys . AreAllKeysOfSameType ( ) || m_skipOnUIChange ) { return ; } for ( unsigned int keyIndex = 0 ; keyIndex < selectedKeys . GetKeyCount ( ) ; ++ keyIndex ) { CTrackViewKeyHandle keyHandle = selectedKeys . GetKey ( keyIndex ) ; CAnimParamType paramType = keyHandle . GetTrack ( ) -> GetParameterType ( ) ; if ( paramType == AnimParamType :: Sequence ) { ISequenceKey sequenceKey ; keyHandle . GetKey ( & sequenceKey ) ; AZ :: EntityId seqOwnerId ; if ( pVar == mv_sequence . GetVar ( ) ) { QString entityIdString = mv_sequence ; seqOwnerId = AZ :: EntityId ( static_cast < AZ :: u64 > ( entityIdString . toULongLong ( ) ) ) ; sequenceKey . szSelection . clear ( ) ; sequenceKey . sequenceEntityId = seqOwnerId ; } SyncValue ( mv_overrideTimes , sequenceKey . bOverrideTimes , false , pVar ) ; IAnimSequence * pSequence = GetIEditor ( ) -> GetSystem ( ) -> GetIMovieSystem ( ) -> FindSequence ( seqOwnerId ) ; if ( ! sequenceKey . bOverrideTimes ) { if ( pSequence ) { sequenceKey . fStartTime = pSequence -> GetTimeRange ( ) . start ; sequenceKey . fEndTime = pSequence -> GetTimeRange ( ) . end ; } else { sequenceKey . fStartTime = 0.0f ; sequenceKey . fEndTime = 0.0f ; } } else { SyncValue ( mv_startTime , sequenceKey . fStartTime , false , pVar ) ; SyncValue ( mv_endTime , sequenceKey . fEndTime , false , pVar ) ; } sequenceKey . fDuration = sequenceKey . fEndTime - sequenceKey . fStartTime > 0 ? sequenceKey . fEndTime - sequenceKey . fStartTime : 0.0f ; IMovieSystem * pMovieSystem = GetIEditor ( ) -> GetSystem ( ) -> GetIMovieSystem ( ) ; if ( pMovieSystem != nullptr ) { pMovieSystem -> SetStartEndTime ( pSequence , sequenceKey . fStartTime , sequenceKey . fEndTime ) ; } bool isDuringUndo = false ; AzToolsFramework :: ToolsApplicationRequests :: Bus :: BroadcastResult ( isDuringUndo , & AzToolsFramework :: ToolsApplicationRequests :: Bus :: Events :: IsDuringUndoRedo ) ; if ( isDuringUndo ) { keyHandle . SetKey ( & sequenceKey ) ; } else { AzToolsFramework :: ScopedUndoBatch undoBatch ( " " ) ; keyHandle . SetKey ( & sequenceKey ) ; undoBatch . MarkEntityDirty ( sequence -> GetSequenceComponentEntityId ( ) ) ; } } } }
Called when UI variable changes.
Called when UI variable changes .
// clear deprecated legacy data