-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
758 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Source/PCGExtendedToolkit/Private/Misc/Filters/PCGExStringSelfCompareFilter.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright Timothé Lapetite 2024 | ||
// Released under the MIT license https://opensource.org/license/MIT/ | ||
|
||
#include "Misc/Filters/PCGExStringSelfCompareFilter.h" | ||
|
||
#define LOCTEXT_NAMESPACE "PCGExCompareFilterDefinition" | ||
#define PCGEX_NAMESPACE CompareFilterDefinition | ||
|
||
PCGExPointFilter::TFilter* UPCGExStringSelfCompareFilterFactory::CreateFilter() const | ||
{ | ||
return new PCGExPointsFilter::TStringSelfComparisonFilter(this); | ||
} | ||
|
||
bool PCGExPointsFilter::TStringSelfComparisonFilter::Init(const FPCGContext* InContext, PCGExData::FFacade* InPointDataFacade) | ||
{ | ||
if (!TFilter::Init(InContext, InPointDataFacade)) { return false; } | ||
|
||
bOffset = TypedFilterFactory->Config.IndexMode == EPCGExIndexMode::Offset; | ||
MaxIndex = PointDataFacade->Source->GetNum() - 1; | ||
|
||
if (MaxIndex < 0) { return false; } | ||
|
||
OperandA = new PCGEx::FLocalToStringGetter(); | ||
OperandA->Capture(TypedFilterFactory->Config.OperandA); | ||
|
||
if (!OperandA->SoftGrab(PointDataFacade->Source)) | ||
{ | ||
PCGE_LOG_C(Error, GraphAndLog, InContext, FText::Format(FTEXT("Invalid Operand A attribute: \"{0}\"."), FText::FromName(TypedFilterFactory->Config.OperandA))); | ||
return false; | ||
} | ||
|
||
if (TypedFilterFactory->Config.CompareAgainst == EPCGExFetchType::Attribute) | ||
{ | ||
Index = PointDataFacade->GetScopedBroadcaster<int32>(TypedFilterFactory->Config.IndexAttribute); | ||
|
||
if (!Index) | ||
{ | ||
PCGE_LOG_C(Error, GraphAndLog, InContext, FText::Format(FTEXT("Invalid Index attribute: \"{0}\"."), FText::FromName(TypedFilterFactory->Config.IndexAttribute.GetName()))); | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
PCGEX_CREATE_FILTER_FACTORY(StringSelfCompare) | ||
|
||
#if WITH_EDITOR | ||
FString UPCGExStringSelfCompareFilterProviderSettings::GetDisplayName() const | ||
{ | ||
FString DisplayName = Config.OperandA.ToString() + PCGExCompare::ToString(Config.Comparison); | ||
|
||
if (Config.IndexMode == EPCGExIndexMode::Pick) { DisplayName += TEXT(" @ "); } | ||
else { DisplayName += TEXT(" i+ "); } | ||
|
||
if (Config.CompareAgainst == EPCGExFetchType::Attribute) { DisplayName += Config.IndexAttribute.GetName().ToString(); } | ||
else { DisplayName += FString::Printf(TEXT("%d"), Config.IndexConstant); } | ||
|
||
return DisplayName; | ||
} | ||
#endif | ||
|
||
#undef LOCTEXT_NAMESPACE | ||
#undef PCGEX_NAMESPACE |
Oops, something went wrong.