/** * Takes a large transport array and splits it into pieces of a desired size and returns the portion of this which is requested * * @param FullTransportArray - The whole series of data * @param CurrentChunkIndex - The The chunk we are requesting * @param NumToSend - The maximum number of bytes we should be splitting into. * * @return The section of the transport array which matches our index requested */ TArray< uint8 > GetTransportSection( const TArray< uint8 >& FullTransportArray, const int32 NumToSend, const int32 RequestedChunkIndex ) { TArray< uint8 > TransportArray = FullTransportArray; if( NumToSend > 0 ) { int32 NumToRemoveFromStart = RequestedChunkIndex * NumToSend; if( NumToRemoveFromStart > 0 ) { TransportArray.RemoveAt( 0, NumToRemoveFromStart ); } int32 NumToRemoveFromEnd = FullTransportArray.Num() - NumToRemoveFromStart - NumToSend; if( NumToRemoveFromEnd > 0 ) { TransportArray.RemoveAt( TransportArray.Num()-NumToRemoveFromEnd, NumToRemoveFromEnd ); } } else { TransportArray.Empty(); } return TransportArray; }
bool TickQueueTests(float DeltaTime) { check(bTicking); if (!GIsAutomationTesting && !bTestInPogress && Queue.Num()) { FJob& CurrentJob = Queue[0]; TArray<FAutomationTestInfo> TestInfo; FAutomationTestFramework::GetInstance().GetValidTestNames( TestInfo ); bool bRanIt = false; for ( int TestIndex = 0; TestIndex < TestInfo.Num(); ++TestIndex ) { FString TestCommand = TestInfo[TestIndex].GetTestName(); if (TestCommand == CurrentJob.Test) { CurrentJob.Ar->Logf(TEXT("Running: %s"), *CurrentJob.Test); IAutomationWorkerModule::FStopTestEvent Event; Event.BindRaw(this, &FQueueTests::ConsoleCommandTestComplete, CurrentJob.Ar); if (FModuleManager::Get().IsModuleLoaded(TEXT("AutomationWorker"))) { FModuleManager::GetModuleChecked<IAutomationWorkerModule>("AutomationWorker").RunTest(CurrentJob.Test, CurrentJob.RoleIndex, Event); bTestInPogress = true; bRanIt = true; } break; } } if (!bRanIt) { CurrentJob.Ar->Logf(TEXT("ERROR: Failed to find test %s"), *CurrentJob.Test); } Queue.RemoveAt(0); } bTicking = !!Queue.Num(); return bTicking; }
UAbsFilter* UFuncFactory::createFilter(const FString& _str) { FString paramStr = _str.ToLower(); TArray<FString> params; paramStr.ParseIntoArray(params, Split_Line, true); if (params.Num() > 0) { const FString clsName = params[0]; UAbsFilter** filter = mFilterMap.Find(clsName); if (filter == nullptr) { UE_LOG(SkillLogger, Error, TEXT("--- Error: UFuncFactory::createFilter, return null")); return nullptr; } *filter = (*filter)->Clone(); if (*filter == nullptr) { UE_LOG(SkillLogger, Error, TEXT("--- Error: UFuncFactory::createFilter, clone null")); return nullptr; } params.RemoveAt(0); //移除掉类名 (*filter)->Parser(params); return *filter; } return nullptr; }
void RemoveCollinearPoints(TArray<FIntPoint>& PointList) { if (PointList.Num() < 3) { return; } for (int32 VertexIndex = 1; VertexIndex < PointList.Num(); ) { const FVector2D A(PointList[VertexIndex-1]); const FVector2D B(PointList[VertexIndex]); const FVector2D C(PointList[(VertexIndex+1) % PointList.Num()]); // Determine if the area of the triangle ABC is zero (if so, they're collinear) const float AreaABC = (A.X * (B.Y - C.Y)) + (B.X * (C.Y - A.Y)) + (C.X * (A.Y - B.Y)); if (FMath::Abs(AreaABC) < KINDA_SMALL_NUMBER) { // Remove B PointList.RemoveAt(VertexIndex); } else { // Continue onwards ++VertexIndex; } } }
void AddQueuedWork(IQueuedWork* InQueuedWork) override { if (TimeToDie) { InQueuedWork->Abandon(); return; } check(InQueuedWork != nullptr); FQueuedThread* Thread = nullptr; // Check to see if a thread is available. Make sure no other threads // can manipulate the thread pool while we do this. check(SynchQueue); FScopeLock sl(SynchQueue); if (QueuedThreads.Num() > 0) { // Figure out which thread is available int32 Index = QueuedThreads.Num() - 1; // Grab that thread to use Thread = QueuedThreads[Index]; // Remove it from the list so no one else grabs it QueuedThreads.RemoveAt(Index); } // Was there a thread ready? if (Thread != nullptr) { // We have a thread, so tell it to do the work Thread->DoWork(InQueuedWork); } else { // There were no threads available, queue the work to be done // as soon as one does become available QueuedWork.Add(InQueuedWork); } }
TArray<uint8> UMasterServerFunctions::CompressBytes(FString UncompressedString) { TArray<uint8> UncompressedBinaryArray = FStringToBinaryArray(UncompressedString); TArray<uint8> CompressedBinaryArray; CompressedBinaryArray.SetNum(UncompressedBinaryArray.Num() * 1023, true); //int ret; z_stream strm; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.avail_in = UncompressedBinaryArray.Num(); strm.next_in = (Bytef *)UncompressedBinaryArray.GetData(); strm.avail_out = CompressedBinaryArray.Num(); strm.next_out = (Bytef *)CompressedBinaryArray.GetData(); // the actual compression work. deflateInit(&strm, Z_BEST_COMPRESSION); deflate(&strm, Z_FINISH); deflateEnd(&strm); // Shrink the array to minimum size CompressedBinaryArray.RemoveAt(strm.total_out, CompressedBinaryArray.Num() - strm.total_out, true); return CompressedBinaryArray; }
bool UPawnActionsComponent::HasActiveActionOfType(EAIRequestPriority::Type Priority, TSubclassOf<UPawnAction> PawnActionClass) const { TArray<UPawnAction*> ActionsToTest; ActionsToTest.Add(GetActiveAction(Priority)); while (ActionsToTest.Num() > 0) { UPawnAction* ActiveActionIter = ActionsToTest[0]; if (ActiveActionIter) { if (ActiveActionIter->GetClass()->IsChildOf(*PawnActionClass)) { return true; } else { UPawnAction_Sequence* PawnActionSequence = Cast<UPawnAction_Sequence>(ActiveActionIter); if (PawnActionSequence) { for (int32 PawnActionSequenceCount = 0; PawnActionSequenceCount < PawnActionSequence->ActionSequence.Num(); ++PawnActionSequenceCount) { ActionsToTest.Add(PawnActionSequence->ActionSequence[PawnActionSequenceCount]); } } } } ActionsToTest.RemoveAt(0); } // Didn't find one. return false; }
//------------------------------------------------------------------------------ void FGraphActionNode::AddChildRecursively(TArray<FString>& CategoryStack, TSharedPtr<FGraphActionNode> NodeToAdd) { if (CategoryStack.Num() > 0) { FString CategorySection = CategoryStack[0]; CategoryStack.RemoveAt(0, 1); // make sure we don't already have a child that this can nest under TSharedPtr<FGraphActionNode> ExistingNode = FindMatchingParent(CategorySection, NodeToAdd); if (ExistingNode.IsValid()) { ExistingNode->AddChildRecursively(CategoryStack, NodeToAdd); } else { TSharedPtr<FGraphActionNode> CategoryNode = NewCategoryNode(CategorySection, NodeToAdd->Grouping, NodeToAdd->SectionID); InsertChild(CategoryNode); CategoryNode->AddChildRecursively(CategoryStack, NodeToAdd); } } else { InsertChild(NodeToAdd); } }
void UEnvQuery::CollectQueryParams(TArray<FEnvNamedValue>& NamedValues) const { TArray<FName> RequiredParams; // collect all params for (int32 OptionIndex = 0; OptionIndex < Options.Num(); OptionIndex++) { const UEnvQueryOption* Option = Options[OptionIndex]; AddNamedValuesFromObject(Option->Generator, NamedValues, RequiredParams); for (int32 TestIndex = 0; TestIndex < Option->Tests.Num(); TestIndex++) { const UEnvQueryTest* TestOb = Option->Tests[TestIndex]; AddNamedValuesFromObject(TestOb, NamedValues, RequiredParams); } } // remove unnecessary params for (int32 ValueIndex = NamedValues.Num() - 1; ValueIndex >= 0; ValueIndex--) { if (!RequiredParams.Contains(NamedValues[ValueIndex].ParamName)) { NamedValues.RemoveAt(ValueIndex); } } }
void UJavascriptTestLibrary::PopFrameCounter() { #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) GFrameCounter = GFrameCounterStack[GFrameCounterStack.Num() - 1]; GFrameCounterStack.RemoveAt(GFrameCounterStack.Num() - 1, 1); #endif }
void FSourceControlSettings::LoadSettings() { // make sure we load the global ini first const FString& GlobalIniFile = SourceControlHelpers::GetGlobalSettingsIni(); GConfig->GetBool(*SourceControlSettingsConstants::SettingsSection, TEXT("UseGlobalSettings"), bUseGlobalSettings, GlobalIniFile); TArray<FString> Tokens; TArray<FString> Switches; FCommandLine::Parse( FCommandLine::Get(), Tokens, Switches ); TMap<FString, FString> SwitchPairs; for (int32 SwitchIdx = Switches.Num() - 1; SwitchIdx >= 0; --SwitchIdx) { FString& Switch = Switches[SwitchIdx]; TArray<FString> SplitSwitch; if (2 == Switch.ParseIntoArray(SplitSwitch, TEXT("="), true)) { SwitchPairs.Add(SplitSwitch[0], SplitSwitch[1].TrimQuotes()); Switches.RemoveAt(SwitchIdx); } } if( SwitchPairs.Contains( TEXT("SCCProvider") ) ) { Provider = SwitchPairs[TEXT("SCCProvider")]; } else { const FString& IniFile = SourceControlHelpers::GetSettingsIni(); GConfig->GetString(*SourceControlSettingsConstants::SettingsSection, TEXT("Provider"), Provider, IniFile); } }
void FArchiveObjectGraph::GenerateObjectGraph( TArray<UObject*>& Objects ) { const int32 LastRootObjectIndex = Objects.Num(); for ( int32 ObjIndex = 0; ObjIndex < Objects.Num(); ObjIndex++ ) { CurrentReferencer = Objects[ObjIndex]; CurrentReferencer->UnMark(OBJECTMARK_TagExp); // Serialize this object if ( CurrentReferencer->HasAnyFlags(RF_ClassDefaultObject) ) { CurrentReferencer->GetClass()->SerializeDefaultObject(CurrentReferencer, *this); } else { CurrentReferencer->Serialize( *this ); } // ObjectsToSerialize will contain only those objects which were encountered while serializing CurrentReferencer // that weren't already in the list of objects to be serialized. if ( ObjectsToSerialize.Num() > 0 ) { // add to objects, so that we make sure ObjectToSerialize are serialized Objects += ObjectsToSerialize; ObjectsToSerialize.Empty(); } } Objects.RemoveAt(LastRootObjectIndex, Objects.Num() - LastRootObjectIndex); }
virtual IQueuedWork* ReturnToPoolOrGetNextJob(FQueuedThread* InQueuedThread) override { check(InQueuedThread != nullptr); IQueuedWork* Work = nullptr; // Check to see if there is any work to be done FScopeLock sl(SynchQueue); if (TimeToDie) { check(!QueuedWork.Num()); // we better not have anything if we are dying } if (QueuedWork.Num() > 0) { // Grab the oldest work in the queue. This is slower than // getting the most recent but prevents work from being // queued and never done Work = QueuedWork[0]; // Remove it from the list so no one else grabs it QueuedWork.RemoveAt(0); } if (!Work) { // There was no work to be done, so add the thread to the pool QueuedThreads.Add(InQueuedThread); } return Work; }
void GetKeyablePropertyPaths(UClass* Class, UStruct* PropertySource, TArray<UProperty*>& PropertyPath, FSequencer& Sequencer, TArray<TArray<UProperty*>>& KeyablePropertyPaths) { //@todo need to resolve this between UMG and the level editor sequencer const bool bRecurseAllProperties = Sequencer.IsLevelEditorSequencer(); for (TFieldIterator<UProperty> PropertyIterator(PropertySource); PropertyIterator; ++PropertyIterator) { UProperty* Property = *PropertyIterator; if (Property && !Property->HasAnyPropertyFlags(CPF_Deprecated)) { PropertyPath.Add(Property); bool bIsPropertyKeyable = Sequencer.CanKeyProperty(FCanKeyPropertyParams(Class, PropertyPath)); if (bIsPropertyKeyable) { KeyablePropertyPaths.Add(PropertyPath); } if (!bIsPropertyKeyable || bRecurseAllProperties) { UStructProperty* StructProperty = Cast<UStructProperty>(Property); if (StructProperty != nullptr) { GetKeyablePropertyPaths(Class, StructProperty->Struct, PropertyPath, Sequencer, KeyablePropertyPaths); } } PropertyPath.RemoveAt(PropertyPath.Num() - 1); } } }
void NUTNet::CleanupUnitTestWorlds() { for (auto It=PendingUnitWorldCleanup.CreateIterator(); It; ++It) { UWorld* CurWorld = *It; // Remove the tick-hook, for this world int32 TickHookIdx = ActiveTickHooks.IndexOfByPredicate( [&CurWorld](const FWorldTickHook* CurTickHook) { return CurTickHook != NULL && CurTickHook->AttachedWorld == CurWorld; }); if (TickHookIdx != INDEX_NONE) { ActiveTickHooks.RemoveAt(TickHookIdx); } GEngine->DestroyWorldContext(CurWorld); CurWorld->DestroyWorld(false); } PendingUnitWorldCleanup.Empty(); // Immediately garbage collect remaining objects, to finish net driver cleanup CollectGarbage(GARBAGE_COLLECTION_KEEPFLAGS, true); }
void UAnimGraphNode_BlendListBase::RemovePinsFromOldPins(TArray<UEdGraphPin*>& OldPins, int32 RemovedArrayIndex) { TArray<FString> RemovedPropertyNames; TArray<FString> NewPinNames; // Store new pin names to compare with old pin names for (int32 NewPinIndx = 0; NewPinIndx < Pins.Num(); NewPinIndx++) { NewPinNames.Add(Pins[NewPinIndx]->PinName); } // don't know which pins are removed yet so find removed pins comparing NewPins and OldPins for (int32 OldPinIdx = 0; OldPinIdx < OldPins.Num(); OldPinIdx++) { FString& OldPinName = OldPins[OldPinIdx]->PinName; if (!NewPinNames.Contains(OldPinName)) { int32 UnderscoreIndex = OldPinName.Find(TEXT("_")); if (UnderscoreIndex != INDEX_NONE) { FString PropertyName = OldPinName.Left(UnderscoreIndex); RemovedPropertyNames.Add(PropertyName); } } } for (int32 PinIdx = 0; PinIdx < OldPins.Num(); PinIdx++) { // Separate the pin name into property name and index FString PropertyName; int32 ArrayIndex = -1; FString& OldPinName = OldPins[PinIdx]->PinName; int32 UnderscoreIndex = OldPinName.Find(TEXT("_")); if (UnderscoreIndex != INDEX_NONE) { PropertyName = OldPinName.Left(UnderscoreIndex); ArrayIndex = FCString::Atoi(*(OldPinName.Mid(UnderscoreIndex + 1))); if (RemovedPropertyNames.Contains(PropertyName)) { // if array index is matched, removes pins // and if array index is greater than removed index, decrease index if (ArrayIndex == RemovedArrayIndex) { OldPins.RemoveAt(PinIdx); --PinIdx; } else if (ArrayIndex > RemovedArrayIndex) { OldPinName = FString::Printf(TEXT("%s_%d"), *PropertyName, ArrayIndex - 1); } } } } }
bool UBlendSpaceBase::GetSamplesFromBlendInput(const FVector &BlendInput, TArray<FBlendSampleData> & OutSampleDataList) const { static TArray<FGridBlendSample, TInlineAllocator<4> > RawGridSamples; check(IsInGameThread() && !RawGridSamples.Num()); // this must be called non-recursively from the gamethread GetRawSamplesFromBlendInput(BlendInput, RawGridSamples); OutSampleDataList.Reset(); OutSampleDataList.Reserve(RawGridSamples.Num() * FEditorElement::MAX_VERTICES); // consolidate all samples for (int32 SampleNum=0; SampleNum<RawGridSamples.Num(); ++SampleNum) { FGridBlendSample& GridSample = RawGridSamples[SampleNum]; float GridWeight = GridSample.BlendWeight; FEditorElement& GridElement = GridSample.GridElement; for(int Ind = 0; Ind < GridElement.MAX_VERTICES; ++Ind) { if(GridElement.Indices[Ind] != INDEX_NONE) { int32 Index = OutSampleDataList.AddUnique(GridElement.Indices[Ind]); OutSampleDataList[Index].AddWeight(GridElement.Weights[Ind]*GridWeight); } } } /** Used to sort by Weight. */ struct FCompareFBlendSampleData { FORCEINLINE bool operator()( const FBlendSampleData& A, const FBlendSampleData& B ) const { return B.TotalWeight < A.TotalWeight; } }; OutSampleDataList.Sort( FCompareFBlendSampleData() ); // remove noisy ones int32 TotalSample = OutSampleDataList.Num(); float TotalWeight = 0.f; for (int32 I=0; I<TotalSample; ++I) { if (OutSampleDataList[I].TotalWeight < ZERO_ANIMWEIGHT_THRESH) { // cut anything in front of this OutSampleDataList.RemoveAt(I, TotalSample-I, false); // we won't shrink here, that might screw up alloc optimization at a higher level, if not this is temp anyway break; } TotalWeight += OutSampleDataList[I].TotalWeight; } for (int32 I=0; I<OutSampleDataList.Num(); ++I) { // normalize to all weights OutSampleDataList[I].TotalWeight /= TotalWeight; } RawGridSamples.Reset(); return (OutSampleDataList.Num()!=0); }
bool UBlendSpaceBase::GetSamplesFromBlendInput(const FVector &BlendInput, TArray<FBlendSampleData> & OutSampleDataList) const { TArray<FGridBlendSample> RawGridSamples; GetRawSamplesFromBlendInput(BlendInput, RawGridSamples); OutSampleDataList.Empty(); // consolidate all samples for (int32 SampleNum=0; SampleNum<RawGridSamples.Num(); ++SampleNum) { FGridBlendSample& GridSample = RawGridSamples[SampleNum]; float GridWeight = GridSample.BlendWeight; FEditorElement& GridElement = GridSample.GridElement; for(int Ind = 0; Ind < GridElement.MAX_VERTICES; ++Ind) { if(GridElement.Indices[Ind] != INDEX_NONE) { int32 Index = OutSampleDataList.AddUnique(GridElement.Indices[Ind]); OutSampleDataList[Index].AddWeight(GridElement.Weights[Ind]*GridWeight); } } } /** Used to sort by Weight. */ struct FCompareFBlendSampleData { FORCEINLINE bool operator()( const FBlendSampleData& A, const FBlendSampleData& B ) const { return B.TotalWeight < A.TotalWeight; } }; OutSampleDataList.Sort( FCompareFBlendSampleData() ); // remove noisy ones int32 TotalSample = OutSampleDataList.Num(); float TotalWeight = 0.f; for (int32 I=0; I<TotalSample; ++I) { if (OutSampleDataList[I].TotalWeight < ZERO_ANIMWEIGHT_THRESH) { // cut anything in front of this OutSampleDataList.RemoveAt(I, TotalSample-I); break; } TotalWeight += OutSampleDataList[I].TotalWeight; } for (int32 I=0; I<OutSampleDataList.Num(); ++I) { // normalize to all weights OutSampleDataList[I].TotalWeight /= TotalWeight; } return (OutSampleDataList.Num()!=0); }
FDataScannerPtr FManifestBuilderImpl::GetNextScanner() { FDataScannerPtr Result; DataScannersCS.Lock(); if (DataScanners.Num() > 0) { Result = DataScanners[0]; DataScanners.RemoveAt(0); } DataScannersCS.Unlock(); return Result; }
bool AMod::CanCharacterBuyThisMod(APlayerCharacter* buyer) { if (!IsValid(buyer)) return false; //get an array of mods that the character has TArray<AMod*> mods; for (int32 i = 0; i < buyer->GetMods().Num(); i++) mods.Add(buyer->GetMods()[i]); //get an array of classes for the mods TArray<TSubclassOf<AMod> > classList; GetRecipe(classList); //see if they have the correct recipe and enough credits int32 neededCredits = cost; int32 removeCount = 0; for (int32 i = 0; i < classList.Num(); i++) { for (int32 j = 0; j < mods.Num(); j++) { if (mods[j]->GetClass() == classList[i]) { neededCredits -= mods[j]->GetCost(false); mods.RemoveAt(j); classList.RemoveAt(i); removeCount++; } } } if ((buyer->GetModCount() - removeCount) + 1 > 5) return false; if (buyer->GetCredits() >= cost) return true; return buyer->GetCredits() >= neededCredits; }
bool FRawCurveTracks::DeleteCurveDataImpl(TArray<DataType> & Curves, USkeleton::AnimCurveUID Uid) { for(int32 Idx = 0; Idx < Curves.Num(); ++Idx) { if(Curves[Idx].CurveUid == Uid) { Curves.RemoveAt(Idx); return true; } } return false; }
/** * Applies settings to an object by finding UProperties by name and calling ImportText * * @param InObject - The object to search for matching properties * @param PropertyChain - The list UProperty names recursively to search through * @param Value - The value to import on the found property */ void ApplyCustomFactorySetting(UObject* InObject, TArray<FString>& PropertyChain, const FString& Value) { const FString PropertyName = PropertyChain[0]; PropertyChain.RemoveAt(0); UProperty* TargetProperty = FindField<UProperty>(InObject->GetClass(), *PropertyName); if (TargetProperty) { if (PropertyChain.Num() == 0) { TargetProperty->ImportText(*Value, TargetProperty->ContainerPtrToValuePtr<uint8>(InObject), 0, InObject); } else { UStructProperty* StructProperty = Cast<UStructProperty>(TargetProperty); UObjectProperty* ObjectProperty = Cast<UObjectProperty>(TargetProperty); UObject* SubObject = NULL; bool bValidPropertyType = true; if (StructProperty) { SubObject = StructProperty->Struct; } else if (ObjectProperty) { SubObject = ObjectProperty->GetObjectPropertyValue(ObjectProperty->ContainerPtrToValuePtr<UObject>(InObject)); } else { //Unknown nested object type bValidPropertyType = false; UE_LOG(LogAutomationEditorCommon, Error, TEXT("ERROR: Unknown nested object type for property: %s"), *PropertyName); } if (SubObject) { ApplyCustomFactorySetting(SubObject, PropertyChain, Value); } else if (bValidPropertyType) { UE_LOG(LogAutomationEditorCommon, Error, TEXT("Error accessing null property: %s"), *PropertyName); } } } else { UE_LOG(LogAutomationEditorCommon, Error, TEXT("ERROR: Could not find factory property: %s"), *PropertyName); } }
void FMRUList::MoveToTop(int32 InItem) { check( InItem > -1 && InItem < Items.Num() ); TArray<FString> WkArray; WkArray = Items; const FString Save = WkArray[InItem]; WkArray.RemoveAt( InItem ); Items.Empty(); new(Items)FString( *Save ); Items += WkArray; }
virtual void Tick(float DeltaSeconds) override { for (int32 Index = 0; Index < ActiveInstances.Num();) { if (auto* Player = ActiveInstances[Index].Get()) { Player->Update(DeltaSeconds); ++Index; } else { ActiveInstances.RemoveAt(Index, 1, false); } } }
void AMod::CharacterPurchasedMod(APlayerCharacter* buyer) { if (!IsValid(buyer)) return; buyer->ChangeCredits(-1 * GetCost(true, buyer)); TArray<TSubclassOf<AMod> > classList; GetRecipe(classList); TArray<AMod*> mods = buyer->GetMods(); for (int32 i = 0; i < classList.Num(); i++) { for (int32 j = 0; j < mods.Num(); j++) { if (mods[j]->GetClass() == classList[i]) { buyer->RemoveMod(j); mods.RemoveAt(j); classList.RemoveAt(i); } } } }
void UInventoryOptionsWidget::RemoveFirstButton() { TArray<UWidget*> buttonWidgetArray = FindAllWidgets(UCustomButtonWidget::StaticClass()); buttonWidgetArray[0]->RemoveFromParent(); buttonWidgetArray.RemoveAt(0); for (UWidget* aWidget : buttonWidgetArray) { UCustomButtonWidget* buttonWidget = Cast<UCustomButtonWidget>(aWidget); UPanelSlot* panelSlot = buttonWidget->Slot; UUniformGridSlot* gridSlot = Cast<UUniformGridSlot>(panelSlot); gridSlot->SetRow(FMath::Clamp(gridSlot->Row - 1, 0, 3)); } TArray<UWidget*> textWidgetArray = FindAllWidgets(UTextBlock::StaticClass()); textWidgetArray[0]->RemoveFromParent(); textWidgetArray.RemoveAt(0); for (UWidget* aWidget : textWidgetArray) { UTextBlock* textBlock = Cast<UTextBlock>(aWidget); UPanelSlot* panelSlot = textBlock->Slot; UUniformGridSlot* gridSlot = Cast<UUniformGridSlot>(panelSlot); gridSlot->SetRow(FMath::Clamp(gridSlot->Row - 1, 0, 3)); } UWidget* theWidget = FindFirstWidget(UUniformGridPanel::StaticClass()); UUniformGridPanel* thePanel = Cast<UUniformGridPanel>(theWidget); UCanvasPanelSlot* canvasSlot = Cast<UCanvasPanelSlot>(thePanel->Slot); SetDesiredSizeInViewport(FVector2D(canvasSlot->GetSize().X, canvasSlot->GetSize().Y * 0.5)); canvasSlot->SetSize(FVector2D(canvasSlot->GetSize().X, canvasSlot->GetSize().Y * 0.5)); FAnchors anchorData = FAnchors(); anchorData.Minimum = FVector2D(0.5, 1); anchorData.Maximum = FVector2D(0.5, 1); canvasSlot->SetAnchors(anchorData); }
void GetMaterialBrushPropertyPathsRecursive(void* DataObject, UStruct* PropertySource, TArray<UProperty*>& PropertyPath, TArray<TArray<UProperty*>>& MaterialBrushPropertyPaths ) { if ( DataObject != nullptr ) { for ( TFieldIterator<UProperty> PropertyIterator( PropertySource ); PropertyIterator; ++PropertyIterator ) { UProperty* Property = *PropertyIterator; if ( Property != nullptr && Property->HasAnyPropertyFlags( CPF_Deprecated ) == false ) { PropertyPath.Add( Property ); UStructProperty* StructProperty = Cast<UStructProperty>( Property ); if ( StructProperty != nullptr ) { const FName StructName = StructProperty->Struct->GetFName(); void* Data = Property->ContainerPtrToValuePtr<void>(DataObject); UMaterialInterface* MaterialInterface = nullptr; if(StructName == TMaterialStructType<FSlateFontInfo>::GetTypeName()) { MaterialInterface = TMaterialStructType<FSlateFontInfo>::GetMaterial(Data); } else if(StructName == TMaterialStructType<FSlateBrush>::GetTypeName()) { MaterialInterface =TMaterialStructType<FSlateBrush>::GetMaterial(Data); } else if(StructName == TMaterialStructType<FFontOutlineSettings>::GetTypeName()) { MaterialInterface =TMaterialStructType<FFontOutlineSettings>::GetMaterial(Data); } if(MaterialInterface) { MaterialBrushPropertyPaths.Add(PropertyPath); } else { GetMaterialBrushPropertyPathsRecursive( StructProperty->ContainerPtrToValuePtr<void>( DataObject ), StructProperty->Struct, PropertyPath, MaterialBrushPropertyPaths ); } } PropertyPath.RemoveAt( PropertyPath.Num() - 1 ); } } } }
// Compare last item of Data with other itest starting with FirstDataIndex, drop the data // if same data block found and return its index. If no matching data were found, return // index of that last data. int GetFinalIndexForLastBlock(int FirstDataIndex) { int LastIndex = Data.Num()-1; const BufferData& LastData = Data[LastIndex]; for (int index = FirstDataIndex; index < LastIndex; index++) { if (LastData.IsSameAs(Data[index])) { // Found matching data Data.RemoveAt(LastIndex); return index; } } // Not found return LastIndex; }
void RemoveIdenticalFiles( TArray<FPakInputPair>& FilesToPak, const FString& SourceDirectory ) { for ( int I = FilesToPak.Num()-1; I >= 0; --I ) { const auto& NewFile = FilesToPak[I]; FString SourceFilename = SourceDirectory / NewFile.Dest.Replace(TEXT("../../../"), TEXT("")); int64 SourceTotalSize = IFileManager::Get().FileSize(*SourceFilename); FString DestFilename = NewFile.Source; int64 DestTotalSize = IFileManager::Get().FileSize(*DestFilename); if ( SourceTotalSize != DestTotalSize ) { // file size doesn't match UE_LOG(LogPakFile, Display, TEXT("Source file size for %s %d bytes doesn't match %s %d bytes"), *SourceFilename, SourceTotalSize, *DestFilename, DestTotalSize); continue; } uint8 SourceFileHash[16]; if ( GenerateHashForFile(SourceFilename, SourceFileHash) == false ) { // file size doesn't match UE_LOG(LogPakFile, Display, TEXT("Source file size %s doesn't exist will be included in build"), *SourceFilename); continue; } uint8 DestFileHash[16]; if ( GenerateHashForFile( DestFilename, DestFileHash ) == false ) { // destination file was removed don't really care about it UE_LOG(LogPakFile, Display, TEXT("File was removed from destination cooked content %s not included in patch"), *DestFilename); continue; } int32 Diff = FMemory::Memcmp( SourceFileHash, DestFileHash, sizeof( DestFileHash ) ); if ( Diff != 0 ) { UE_LOG(LogPakFile, Display, TEXT("Source file hash for %s doesn't match dest file hash %s and will be included in patch"), *SourceFilename, *DestFilename); continue; } UE_LOG(LogPakFile, Display, TEXT("Source file %s matches dest file %s and will not be included in patch"), *SourceFilename, *DestFilename); // remove fromt eh files to pak list FilesToPak.RemoveAt(I); } }
TArray<FString> UKismetStringLibrary::GetCharacterArrayFromString(const FString& SourceString) { TArray<FString> SeparatedChars; if (!SourceString.IsEmpty()) { for (auto CharIt(SourceString.CreateConstIterator()); CharIt; ++CharIt) { TCHAR Char = *CharIt; SeparatedChars.Add(FString(1, &Char)); } // Remove the null terminator on the end SeparatedChars.RemoveAt(SeparatedChars.Num() - 1, 1); } return SeparatedChars; }