bool FMatineePerformanceCaptureCommand::Update()
{
	//for every matinee actor in the level
	for (TObjectIterator<AMatineeActor> It; It; ++It)
	{
		AMatineeActor* MatineeActor = *It;
		FString MatineeFOOName = MatineeActor->GetName();
		if (MatineeActor->GetName().Equals(MatineeName,ESearchCase::IgnoreCase))
		{	


			//add latent action to execute this matinee
			ADD_LATENT_AUTOMATION_COMMAND(FPlayMatineeLatentCommand(MatineeActor));

			//Run the Stat FPS Chart command
			ADD_LATENT_AUTOMATION_COMMAND(FExecWorldStringLatentCommand(TEXT("StartFPSChart")));

			//add action to wait until matinee is complete
			ADD_LATENT_AUTOMATION_COMMAND(FWaitForMatineeToCompleteLatentCommand(MatineeActor));

			//Stop the Stat FPS Chart command
			ADD_LATENT_AUTOMATION_COMMAND(FExecWorldStringLatentCommand(TEXT("StopFPSChart")));
		}
		else
		{
			UE_LOG(LogEngineAutomationLatentCommand, Log, TEXT("'%s' is not the matinee name that is being searched for."), *MatineeActor->GetName())
		}
	}

	return true;

}
void ANetworkController::ReceivedStartMatinee(msgpack_object* Data) {
	FString name = Unpack<FString>(Data);

	for (TActorIterator<AMatineeActor> ObjIt(GetWorld()); ObjIt; ++ObjIt) {
		AMatineeActor* Matinee = *ObjIt;
		if (Matinee->GetName() == name) {
			Matinee->Play();
			break;
		}
	}
}
FText FCinematicOptionsCustomization::GetCurrentMatineeName() const
{
	FText SettingName;
	Matinee->GetValueAsDisplayText(SettingName);
	for (TObjectIterator<AMatineeActor> It; It; ++It)
	{
		AMatineeActor* MatineeActor = *It;
		if (SettingName.EqualTo(FText::FromString(MatineeActor->GetName())))
		{
			return SettingName;
		}
	}

	Matinee->SetValueFromFormattedString(FString("None"));
	return FText::FromString("None");
}
TSharedRef<SWidget> FCinematicOptionsCustomization::OnGetMatineeList() const
{
	FMenuBuilder MenuBuilder(true, NULL);

	FUIAction ItemAction(FExecuteAction::CreateSP(this, &FCinematicOptionsCustomization::OnSettingMatineeChange, FString("None")));
	MenuBuilder.AddMenuEntry(FText::FromString(TEXT("None")), TAttribute<FText>(), FSlateIcon(), ItemAction);

	for (TObjectIterator<AMatineeActor> It; It; ++It)
	{
		AMatineeActor* MatineeActor = *It;
		FUIAction Action(FExecuteAction::CreateSP(this, &FCinematicOptionsCustomization::OnSettingMatineeChange, MatineeActor->GetName()));
		MenuBuilder.AddMenuEntry(FText::FromString(MatineeActor->GetName()), TAttribute<FText>(), FSlateIcon(), Action);
	}

	return MenuBuilder.MakeWidget();
}
bool FEnqueuePerformanceCaptureCommands::Update()
{
	//for every matinee actor in the level
	for (TObjectIterator<AMatineeActor> It; It; ++It)
	{
		AMatineeActor* MatineeActor = *It;
		if(MatineeActor && MatineeActor->GetName().Contains(TEXT("Automation")) )
		{
			//add latent action to execute this matinee
			ADD_LATENT_AUTOMATION_COMMAND(FPlayMatineeLatentCommand(MatineeActor));

			//add action to wait until matinee is complete
			ADD_LATENT_AUTOMATION_COMMAND(FWaitForMatineeToCompleteLatentCommand(MatineeActor));
		}
	}

	return true;
}
Beispiel #6
0
void UUnrealEdEngine::ConvertMatinees()
{
	FVector StartLocation= FVector::ZeroVector;
	UWorld* World = GWorld;
	if( World )
	{
		ULevel* Level = World->GetCurrentLevel();
		if( !Level )
		{
			Level = World->PersistentLevel;
		}
		check(Level);
		for( TObjectIterator<UInterpData> It; It; ++It )
		{
			UInterpData* InterpData = *It;
			if( InterpData->IsIn( Level ) ) 
			{
				// We dont care about renaming references or adding redirectors.  References to this will be old seqact_interps
				GEditor->RenameObject( InterpData, Level->GetOutermost(), *InterpData->GetName() );

				AMatineeActor* MatineeActor = Level->OwningWorld->SpawnActor<AMatineeActor>(StartLocation, FRotator::ZeroRotator);
				StartLocation.Y += 50;
								
				MatineeActor->MatineeData = InterpData;
				UProperty* MatineeDataProp = NULL;
				for( UProperty* Property = MatineeActor->GetClass()->PropertyLink; Property != NULL; Property = Property->PropertyLinkNext )
				{
					if( Property->GetName() == TEXT("MatineeData") )
					{
						MatineeDataProp = Property;
						break;
					}
				}

				FPropertyChangedEvent PropertyChangedEvent( MatineeDataProp ); 
				MatineeActor->PostEditChangeProperty( PropertyChangedEvent );
			}
		}
	}

}
void FLevelEditorContextMenuImpl::FillMatineeSelectActorMenu( FMenuBuilder& MenuBuilder )
{
	MenuBuilder.BeginSection("SelectMatinee", LOCTEXT("SelectMatineeHeading", "Matinee") );
	{
		// show list of Matinee Actors that controls this actor
		// this is ugly but we don't have good way of knowing which Matinee actor controls me
		// in the future this can be cached to TMap somewhere and use that list
		// for now we show only when 1 actor is selected
		if ( SelectionInfo.SharedLevel && SelectionInfo.NumSelected == 1 )
		{
			TArray<AMatineeActor*> MatineeActors;	
			// first collect all matinee actors
			for ( AActor* Actor : SelectionInfo.SharedLevel->Actors )
			{
				AMatineeActor * CurActor = Cast<AMatineeActor>(Actor);
				if ( CurActor )
				{
					MatineeActors.Add(CurActor);
				}
			}

			if ( MatineeActors.Num() > 0 )
			{
				FSelectionIterator ActorIter( GEditor->GetSelectedActorIterator() );
				AActor* SelectedActor = Cast<AActor>(*ActorIter);

				// now delete the matinee actors that don't control currently selected actor
				for (int32 MatineeActorIter=0; MatineeActorIter<MatineeActors.Num(); ++MatineeActorIter)
				{
					AMatineeActor * CurMatineeActor = MatineeActors[MatineeActorIter];
					TArray<AActor *> CutMatineeControlledActors;
					CurMatineeActor->GetControlledActors(CutMatineeControlledActors);
					bool bIsMatineeControlled=false;
					for ( AActor* ControlledActor : CutMatineeControlledActors )
					{
						if (ControlledActor == SelectedActor)
						{
							bIsMatineeControlled = true;
						}
					}

					// if not, remove it
					if (!bIsMatineeControlled)
					{
						MatineeActors.RemoveAt(MatineeActorIter);
						--MatineeActorIter;
					}
				}

				// if some matinee controls this, add to menu for direct selection
				if ( MatineeActors.Num() > 0 )
				{
					for (int32 MatineeActorIter=0; MatineeActorIter<MatineeActors.Num(); ++MatineeActorIter)
					{
						AMatineeActor * CurMatineeActor = MatineeActors[MatineeActorIter];
						const FText Text = FText::Format( LOCTEXT("SelectMatineeActor", "Select {0}"), FText::FromString( CurMatineeActor->GetName() ) );

						FUIAction CurMatineeActorAction( FExecuteAction::CreateStatic( &FLevelEditorActionCallbacks::OnSelectMatineeActor, CurMatineeActor ) );
						MenuBuilder.AddMenuEntry( Text, Text, FSlateIcon(), CurMatineeActorAction );

						// if matinee is opened, and if that is CurMatineeActor, show option to go to group
						if( GLevelEditorModeTools().IsModeActive( FBuiltinEditorModes::EM_InterpEdit ) )
						{
							const FEdModeInterpEdit* InterpEditMode = (const FEdModeInterpEdit*)GLevelEditorModeTools().GetActiveMode( FBuiltinEditorModes::EM_InterpEdit );

							if ( InterpEditMode && InterpEditMode->MatineeActor == CurMatineeActor )
							{
								FUIAction SelectedActorAction( FExecuteAction::CreateStatic( &FLevelEditorActionCallbacks::OnSelectMatineeGroup, SelectedActor ) );
								MenuBuilder.AddMenuEntry( LOCTEXT("SelectMatineeGroupForActorMenuTitle", "Select Matinee Group For This Actor"), LOCTEXT("SelectMatineeGroupForActorMenuTooltip", "Selects matinee group controlling this actor"), FSlateIcon(), SelectedActorAction );
							}
						}
					}
				}
			}
		}

		// if this class is Matinee Actor, add option to allow select all controlled actors
		if ( SelectionInfo.bHaveMatinee )
		{
			MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().SelectAllActorsControlledByMatinee );	
		}
	}
	MenuBuilder.EndSection();
}
void UFaceFXMatineeControl::DrawTrack( FCanvas* Canvas, UInterpGroup* Group, const FInterpTrackDrawParams& Params )
{
	static const FColor	KeySelectedColor(255,128,0);
	static const FColor KeyLabelColor(225,225,225);
	static const FColor KeyBackgroundColor(0,150,200);
	static const FColor KeyColorBlack(0,0,0);
	static const int32	KeyVertOffset = 3;

	const bool bHitTesting = Canvas->IsHitTesting();
	const bool bAllowBarSelection = bHitTesting && Params.bAllowKeyframeBarSelection;
	const bool bAllowTextSelection = bHitTesting && Params.bAllowKeyframeTextSelection;

	AMatineeActor* MatineeActor = CastChecked<AMatineeActor>(Group->GetOuter()->GetOuter());
	UInterpGroupInst* GroupInst = MatineeActor->FindFirstGroupInst(Group);
	const AActor* GroupActor = GroupInst ? GroupInst->GetGroupActor() : nullptr;

	//cached animation ids
	TArray<FFaceFXAnimId> AnimIds;
	AnimIds.AddUninitialized(Keys.Num());
	
	//Draw the tiles for each animation
	for (int32 i = 0; i < Keys.Num(); i++)
	{
		const FFaceFXTrackKey& AnimKey = Keys[i];

		FFaceFXAnimId AnimationId;
		if(AnimKey.AnimationId.IsValid())
		{
			AnimationId = AnimKey.AnimationId;
		}
		else if(const UFaceFXAnim* Animation = GetAnimation(AnimKey, this))
		{
			AnimationId = Animation->GetId();
		}

		AnimIds[i] = AnimationId;

		//determine animation duration
		const float AnimStartTime = AnimKey.Time;
		const float AnimEndTime = AnimStartTime + AnimKey.GetAnimationDuration(GroupActor);

		const int32 StartPixelPos = FMath::TruncToInt((AnimStartTime - Params.StartTime) * Params.PixelsPerSec);
		const int32 EndPixelPos = FMath::TruncToInt((AnimEndTime - Params.StartTime) * Params.PixelsPerSec);

		// Find if this sound is one of the selected ones.
		bool bKeySelected = false;
		for (const FInterpEdSelKey& SelectedKey : Params.SelectedKeys)
		{
			if(SelectedKey.Group == Group && SelectedKey.Track == this && SelectedKey.KeyIndex == i)
			{
				bKeySelected = true;
				break;
			}
		}

		const FColor& BorderColor = bKeySelected ? KeySelectedColor : KeyColorBlack;

		if(bAllowBarSelection) 
		{
			Canvas->SetHitProxy(new HInterpTrackKeypointProxy(Group, this, i));
		}
		Canvas->DrawTile(StartPixelPos, KeyVertOffset, EndPixelPos - StartPixelPos + 1, FMath::TruncToFloat(Params.TrackHeight - 2.f*KeyVertOffset), 0.f, 0.f, 1.f, 1.f, BorderColor);
		Canvas->DrawTile(StartPixelPos+1, KeyVertOffset+1, EndPixelPos - StartPixelPos - 1, FMath::TruncToFloat(Params.TrackHeight - 2.f*KeyVertOffset) - 2, 0.f, 0.f, 1.f, 1.f, KeyBackgroundColor);
		if(bAllowBarSelection)
		{
			Canvas->SetHitProxy(nullptr);
		}
	}
	
	// Use base-class to draw key triangles
	Super::DrawTrack( Canvas, Group, Params );

	//Draw animation names on top
	for (int32 i = 0; i < Keys.Num(); i++)
	{
		const FFaceFXTrackKey& AnimKey = Keys[i];
		
		//fetch the cached animation id for the key
		const FFaceFXAnimId& AnimId = AnimIds[i];

		FString AnimName(TEXT("Unknown"));
		if(AnimId.IsValid())
		{
			AnimName = AnimId.Group.IsNone() ? TEXT("") : AnimId.Group.ToString() + TEXT(" / ");
			AnimName += AnimId.Name.ToString();
		}

		if(AnimKey.bLoop)
		{
			AnimName += TEXT(" [Looping]");
		}

		int32 XL, YL;
		StringSize(GEngine->GetSmallFont(), XL, YL, *AnimName);

		if (bAllowTextSelection)
		{
			Canvas->SetHitProxy(new HInterpTrackKeypointProxy(Group, this, i));
		}

		const int32 PixelPos = FMath::TruncToInt((AnimKey.Time - Params.StartTime) * Params.PixelsPerSec);

		Canvas->DrawShadowedString((PixelPos + 2), Params.TrackHeight - YL - KeyVertOffset, *AnimName, GEngine->GetSmallFont(), KeyLabelColor);
		if (bAllowTextSelection)
		{
			Canvas->SetHitProxy(nullptr);
		}
	}
}