Example #1
0
	TArray<FChunkPart> FDataStructure::GetFinalDataStructure()
	{
		if (DataStructure.Top().PartSize == 0)
		{
			DataStructure.Pop(false);
		}
		return MoveTemp(DataStructure);
	}
Example #2
0
	void FDataStructure::CompleteCurrentChunk()
	{
		DataStructure.AddZeroed();
		FChunkPart& PreviousPart = DataStructure[DataStructure.Num() - 2];

		// Create next chunk
		NewChunkGuid = FGuid::NewGuid();
		DataStructure.Top().DataOffset = PreviousPart.DataOffset + PreviousPart.PartSize;
		DataStructure.Top().ChunkGuid = NewChunkGuid;
	}
	void STextPropertyWidget::Construct(const FArguments& Arguments, const TSharedRef<IPropertyHandle>& InPropertyHandle)
	{
		PropertyHandle = InPropertyHandle;

		const auto& GetTextValue = [this]() -> FText
		{
			FText TextValue;

			TArray<const void*> RawData;
			PropertyHandle->AccessRawData(RawData);
			if (RawData.Num() == 1)
			{
				const FText* RawDatum = reinterpret_cast<const FText*>(RawData.Top());
				if (RawDatum)
				{
					TextValue = *RawDatum;
				}
			}
			else if(RawData.Num() > 1)
			{
				TextValue = NSLOCTEXT("PropertyEditor", "MultipleValues", "Multiple Values");
			}
			else
			{
				TextValue = FText::GetEmpty();
			}

			return TextValue;
		};

		const auto& OnTextCommitted = [this](const FText& NewText, ETextCommit::Type CommitInfo)
		{
			PropertyHandle->NotifyPreChange();

			TArray<void*> RawData;
			PropertyHandle->AccessRawData(RawData);
			for (void* const RawDatum : RawData)
			{
				FText& PropertyValue = *(reinterpret_cast<FText* const>(RawDatum));

				// FText::FromString on the result of FText::ToString is intentional. For now, we want to nuke any namespace/key info and let it get regenerated from scratch,
				// rather than risk adopting whatever came through some chain of calls. This will be replaced when preserving of identity is implemented.
				PropertyValue = FText::FromString(NewText.ToString());
			}
			
			PropertyHandle->NotifyPostChange();
		};

		ChildSlot
			[
				SNew(SEditableTextBox)
				.Text_Lambda(GetTextValue)
				.OnTextCommitted_Lambda(OnTextCommitted)
			];
	}
Example #4
0
	void FDataStructure::PushKnownChunk(const FGuid& PotentialMatch, uint32 NumDataInWindow)
	{
		if (DataStructure.Top().PartSize > 0)
		{
			// Add for matched
			DataStructure.AddUninitialized();
			// Add for next
			DataStructure.AddUninitialized();

			// Fill out info
			FChunkPart& PreviousChunkPart = DataStructure[DataStructure.Num() - 3];
			FChunkPart& MatchedChunkPart = DataStructure[DataStructure.Num() - 2];
			FChunkPart& NextChunkPart = DataStructure[DataStructure.Num() - 1];

			MatchedChunkPart.DataOffset = PreviousChunkPart.DataOffset + PreviousChunkPart.PartSize;
			MatchedChunkPart.PartSize = NumDataInWindow;
			MatchedChunkPart.ChunkOffset = 0;
			MatchedChunkPart.ChunkGuid = PotentialMatch;

			NextChunkPart.DataOffset = MatchedChunkPart.DataOffset + MatchedChunkPart.PartSize;
			NextChunkPart.ChunkGuid = PreviousChunkPart.ChunkGuid;
			NextChunkPart.ChunkOffset = PreviousChunkPart.ChunkOffset + PreviousChunkPart.PartSize;
			NextChunkPart.PartSize = 0;
		}
		else
		{
			// Add for next
			DataStructure.AddZeroed();

			// Fill out info
			FChunkPart& MatchedChunkPart = DataStructure[DataStructure.Num() - 2];
			FChunkPart& NextChunkPart = DataStructure[DataStructure.Num() - 1];

			NextChunkPart.ChunkOffset = MatchedChunkPart.ChunkOffset;
			NextChunkPart.ChunkGuid = NewChunkGuid;
			NextChunkPart.DataOffset = MatchedChunkPart.DataOffset + NumDataInWindow;

			MatchedChunkPart.PartSize = NumDataInWindow;
			MatchedChunkPart.ChunkOffset = 0;
			MatchedChunkPart.ChunkGuid = PotentialMatch;
		}
	}
	void STextPropertyWidget::Construct(const FArguments& InArgs, const TSharedRef<IPropertyHandle>& InPropertyHandle, const TSharedPtr<IPropertyUtilities>& InPropertyUtilities)
	{
		PropertyHandle = InPropertyHandle;
		PropertyUtilities = InPropertyUtilities;

		const auto& GetTextValue = [this]() -> FText
		{
			FText TextValue;

			TArray<const void*> RawData;
			PropertyHandle->AccessRawData(RawData);
			if (RawData.Num() == 1)
			{
				const FText* RawDatum = reinterpret_cast<const FText*>(RawData.Top());
				if (RawDatum)
				{
					TextValue = *RawDatum;
				}
			}
			else if(RawData.Num() > 1)
			{
				TextValue = MultipleValuesText;
			}
			else
			{
				TextValue = FText::GetEmpty();
			}

			return TextValue;
		};

		const auto& OnTextCommitted = [this](const FText& NewText, ETextCommit::Type CommitInfo)
		{
			TArray<void*> RawData;
			PropertyHandle->AccessRawData(RawData);

			// Don't commit the Multiple Values text if there are multiple properties being set
			if (RawData.Num() > 0 && (RawData.Num() == 1 || NewText.ToString() != MultipleValuesText.ToString()))
			{
				PropertyHandle->NotifyPreChange();

				for (void* const RawDatum : RawData)
				{
					FText& PropertyValue = *(reinterpret_cast<FText* const>(RawDatum));

					// FText::FromString on the result of FText::ToString is intentional. For now, we want to nuke any namespace/key info and let it get regenerated from scratch,
					// rather than risk adopting whatever came through some chain of calls. This will be replaced when preserving of identity is implemented.
					PropertyValue = FText::FromString(NewText.ToString());
				}

				PropertyHandle->NotifyPostChange();
				PropertyHandle->NotifyFinishedChangingProperties();
			}
		};

		TSharedPtr<SHorizontalBox> HorizontalBox;

		bool bIsPassword = PropertyHandle->GetBoolMetaData("PasswordField");
		bIsMultiLine = PropertyHandle->GetBoolMetaData("MultiLine");
		if(bIsMultiLine)
		{
			ChildSlot
				[
					SAssignNew(HorizontalBox, SHorizontalBox)
					+SHorizontalBox::Slot()
					.FillWidth(1.0f)
					[
						SNew( SBox )
						.MaxDesiredHeight(300.f)
						[
							SAssignNew(MultiLineWidget, SMultiLineEditableTextBox)
							.Text_Lambda(GetTextValue)
							.Font(InArgs._Font)
							.SelectAllTextWhenFocused(false)
							.ClearKeyboardFocusOnCommit(false)
							.OnTextCommitted_Lambda(OnTextCommitted)
							.SelectAllTextOnCommit(false)
							.IsReadOnly(this, &STextPropertyWidget::IsReadOnly)
							.AutoWrapText(true)
							.ModiferKeyForNewLine(EModifierKey::Shift)
							.IsPassword(bIsPassword)
						]
					]
				];

			PrimaryWidget = MultiLineWidget;
		}
		else
		{
			ChildSlot
				[
					SAssignNew(HorizontalBox, SHorizontalBox)
					+SHorizontalBox::Slot()
					.FillWidth(1.0f)
					[
						SAssignNew( SingleLineWidget, SEditableTextBox )
						.Text_Lambda(GetTextValue)
						.Font( InArgs._Font )
						.SelectAllTextWhenFocused( true )
						.ClearKeyboardFocusOnCommit(false)
						.OnTextCommitted_Lambda(OnTextCommitted)
						.SelectAllTextOnCommit( true )
						.IsReadOnly(this, &STextPropertyWidget::IsReadOnly)
						.IsPassword(bIsPassword)

					]
				];

			PrimaryWidget = SingleLineWidget;
		}

		SetEnabled( TAttribute<bool>( this, &STextPropertyWidget::CanEdit ) );
	}
Example #6
0
	void FDataStructure::PushUnknownByte()
	{
		DataStructure.Top().PartSize++;
	}