void UActorRecording::StartRecordingNewComponents(ULevelSequence* CurrentSequence, float CurrentSequenceTime) { if (GetActorToRecord() != nullptr) { // find the new component(s) TInlineComponentArray<USceneComponent*> NewComponents; TArray<USceneComponent*> SceneComponents; GetSceneComponents(SceneComponents); for(USceneComponent* SceneComponent : SceneComponents) { if(ValidComponent(SceneComponent)) { TWeakObjectPtr<USceneComponent> WeakSceneComponent(SceneComponent); int32 FoundIndex = TrackedComponents.Find(WeakSceneComponent); if(FoundIndex == INDEX_NONE) { // new component! NewComponents.Add(SceneComponent); } } } ProcessNewComponentArray(NewComponents); UMovieScene* MovieScene = CurrentSequence->GetMovieScene(); check(MovieScene); FAnimationRecordingSettings ComponentAnimationSettings = AnimationSettings; ComponentAnimationSettings.bRemoveRootAnimation = false; ComponentAnimationSettings.bRecordInWorldSpace = false; const USequenceRecorderSettings* Settings = GetDefault<USequenceRecorderSettings>(); if (!bRecordToPossessable) { FMovieSceneSpawnable* Spawnable = MovieScene->FindSpawnable(Guid); check(Spawnable); AActor* ObjectTemplate = CastChecked<AActor>(Spawnable->GetObjectTemplate()); for (USceneComponent* SceneComponent : NewComponents) { // new component, so we need to add this to our BP if it didn't come from SCS FName NewName; if (SceneComponent->CreationMethod != EComponentCreationMethod::SimpleConstructionScript) { // Give this component a unique name within its parent NewName = *FString::Printf(TEXT("Dynamic%s"), *SceneComponent->GetFName().GetPlainNameString()); NewName.SetNumber(1); while (FindObjectFast<UObject>(ObjectTemplate, NewName)) { NewName.SetNumber(NewName.GetNumber() + 1); } USceneComponent* TemplateRoot = ObjectTemplate->GetRootComponent(); USceneComponent* AttachToComponent = nullptr; // look for a similar attach parent in the current structure USceneComponent* AttachParent = SceneComponent->GetAttachParent(); if(AttachParent != nullptr) { // First off, check if we're attached to a component that has already been duplicated into this object // If so, the name lookup will fail, so we use a direct reference if (TWeakObjectPtr<USceneComponent>* DuplicatedComponent = DuplicatedDynamicComponents.Find(AttachParent)) { AttachToComponent = DuplicatedComponent->Get(); } // If we don't have an attachment parent duplicated already, perform a name lookup if (!AttachToComponent) { FName AttachName = SceneComponent->GetAttachParent()->GetFName(); TInlineComponentArray<USceneComponent*> AllChildren; ObjectTemplate->GetComponents(AllChildren); for (USceneComponent* Child : AllChildren) { CA_SUPPRESS(28182); // Dereferencing NULL pointer. 'Child' contains the same NULL value as 'AttachToComponent' did. if (Child->GetFName() == AttachName) { AttachToComponent = Child; break; } } } } if (!AttachToComponent) { AttachToComponent = ObjectTemplate->GetRootComponent(); } USceneComponent* NewTemplateComponent = Cast<USceneComponent>(StaticDuplicateObject(SceneComponent, ObjectTemplate, NewName, RF_AllFlags & ~RF_Transient)); NewTemplateComponent->AttachToComponent(AttachToComponent, FAttachmentTransformRules::KeepRelativeTransform, SceneComponent->GetAttachSocketName()); ObjectTemplate->AddInstanceComponent(NewTemplateComponent); DuplicatedDynamicComponents.Add(SceneComponent, NewTemplateComponent); } else { NewName = SceneComponent->GetFName(); } StartRecordingComponentProperties(NewName, SceneComponent, GetActorToRecord(), CurrentSequence, CurrentSequenceTime, ComponentAnimationSettings); bNewComponentAddedWhileRecording = true; } SyncTrackedComponents(); } else { for (USceneComponent* SceneComponent : NewComponents) { // new component, start recording StartRecordingComponentProperties(SceneComponent->GetFName(), SceneComponent, GetActorToRecord(), CurrentSequence, CurrentSequenceTime, ComponentAnimationSettings); } SyncTrackedComponents(); } } }
void FName::AutoTest() { const FName AutoTest_1("AutoTest_1"); const FName autoTest_1("autoTest_1"); const FName autoTeSt_1("autoTeSt_1"); const FName AutoTest1Find("autoTEST_1", EFindName::FNAME_Find); const FName AutoTest_2(TEXT("AutoTest_2")); const FName AutoTestB_2(TEXT("AutoTestB_2")); check(AutoTest_1 != AutoTest_2); check(AutoTest_1 == autoTest_1); check(AutoTest_1 == autoTeSt_1); #if WITH_CASE_PRESERVING_NAME check(!FCString::Strcmp(*AutoTest_1.ToString(), TEXT("AutoTest_1"))); check(!FCString::Strcmp(*autoTest_1.ToString(), TEXT("autoTest_1"))); check(!FCString::Strcmp(*autoTeSt_1.ToString(), TEXT("autoTeSt_1"))); check(!FCString::Strcmp(*AutoTestB_2.ToString(), TEXT("AutoTestB_2"))); #endif check(autoTest_1.GetComparisonIndex() == AutoTest_2.GetComparisonIndex()); check(autoTest_1.GetPlainNameString() == AutoTest_1.GetPlainNameString()); check(autoTest_1.GetPlainNameString() == AutoTest_2.GetPlainNameString()); check(*AutoTestB_2.GetPlainNameString() != *AutoTest_2.GetPlainNameString()); check(AutoTestB_2.GetNumber() == AutoTest_2.GetNumber()); check(autoTest_1.GetNumber() != AutoTest_2.GetNumber()); }
/** * Compares name to passed in one. Sort is alphabetical ascending. * * @param Other Name to compare this against * @return < 0 is this < Other, 0 if this == Other, > 0 if this > Other */ int32 FName::Compare( const FName& Other ) const { // Names match, check whether numbers match. if( GetComparisonIndexFast() == Other.GetComparisonIndexFast() ) { return GetNumber() - Other.GetNumber(); } // Names don't match. This means we don't even need to check numbers. else { TNameEntryArray& Names = GetNames(); const FNameEntry* const ThisEntry = GetComparisonNameEntry(); const FNameEntry* const OtherEntry = Other.GetComparisonNameEntry(); // Ansi/Wide mismatch, convert to wide if( ThisEntry->IsWide() != OtherEntry->IsWide() ) { return FCStringWide::Stricmp( ThisEntry->IsWide() ? ThisEntry->GetWideName() : StringCast<WIDECHAR>(ThisEntry->GetAnsiName()).Get(), OtherEntry->IsWide() ? OtherEntry->GetWideName() : StringCast<WIDECHAR>(OtherEntry->GetAnsiName()).Get() ); } // Both are wide. else if( ThisEntry->IsWide() ) { return FCStringWide::Stricmp( ThisEntry->GetWideName(), OtherEntry->GetWideName() ); } // Both are ansi. else { return FCStringAnsi::Stricmp( ThisEntry->GetAnsiName(), OtherEntry->GetAnsiName() ); } } }
bool UPackageMap::SerializeName(FArchive& Ar, FName& Name) { if (Ar.IsLoading()) { uint8 bHardcoded = 0; Ar.SerializeBits(&bHardcoded, 1); if (bHardcoded) { // replicated by hardcoded index uint32 NameIndex; Ar.SerializeInt(NameIndex, MAX_NETWORKED_HARDCODED_NAME + 1); Name = EName(NameIndex); // hardcoded names never have a Number } else { // replicated by string FString InString; int32 InNumber; Ar << InString << InNumber; Name = FName(*InString, InNumber); } } else if (Ar.IsSaving()) { uint8 bHardcoded = Name.GetIndex() <= MAX_NETWORKED_HARDCODED_NAME; Ar.SerializeBits(&bHardcoded, 1); if (bHardcoded) { // send by hardcoded index checkSlow(Name.GetNumber() <= 0); // hardcoded names should never have a Number uint32 NameIndex = uint32(Name.GetIndex()); Ar.SerializeInt(NameIndex, MAX_NETWORKED_HARDCODED_NAME + 1); } else { // send by string FString OutString = Name.GetPlainNameString(); int32 OutNumber = Name.GetNumber(); Ar << OutString << OutNumber; } } return true; }
void APlatformerHUD::NotifyHitBoxClick(FName BoxName) { Super::NotifyHitBoxClick(BoxName); if (BoxName.GetPlainNameString() == "Letter") { CurrentLetter = BoxName.GetNumber(); } if (BoxName == "Up") { if (HighScoreName[CurrentLetter] < 'Z') { HighScoreName[CurrentLetter]++; } } if (BoxName == "Down") { if (HighScoreName[CurrentLetter] > 'A') { HighScoreName[CurrentLetter]--; } } if (BoxName == "OK") { bEnterNamePromptActive = false; if (PlayerOwner) { PlayerOwner->bShowMouseCursor = bEnterNamePromptActive; } FString EnteredName = FString(); for (int32 i=0; i < HighScoreName.Num(); i++) { EnteredName.AppendChar(HighScoreName[i]); } OnHighscoreNameAccepted.Broadcast(EnteredName); } }