Files
UnrealEngineUWP/Engine/Source/Editor/PropertyEditor/Private/PropertyNode.cpp
Marc Audy 43eedbeffe Copying //UE4/Dev-Framework to //UE4/Dev-Main (Source: //UE4/Dev-Framework @ 3136612)
#lockdown Nick.Penwarden
#rb None

==========================
MAJOR FEATURES + CHANGES
==========================

Change 3108929 on 2016/08/31 by Jon.Nabozny

	PR #2745: Add FQuat version of SetWorldRotation functions (Contibuted by EverNewJoy)

	#jira UE-35260

Change 3108930 on 2016/08/31 by Jon.Nabozny

	Fix out of date URadialForceComponent::CollisionObjectQueryParams by adding a BeginPlay event callback.

	#jira UE-33880

Change 3108934 on 2016/08/31 by Jon.Nabozny

	Fix check in UCharacterMovement::StepUp to properly account for distance the component is above the floor.

	#jira UE-33051

Change 3108971 on 2016/08/31 by Jon.Nabozny

	Add missing URadialForceComponent.h changes from CR 3108930

Change 3109557 on 2016/09/01 by Thomas.Sarkanen

	Copying //Tasks/Dev-Framework/Dev-PersonaUpgrade to Dev-Framework (//UE4/Dev-Framework)

	Persona Upgrade

	Summary of changes:

	- Persona module is now a repository of re-usable components, rather than an asset editor in itself.
	- Multiple asset editors now exist for specific asset types (Animation, Skeleton, anim BP etc).
	- Skeleton editing is now performed via the new IEditableSkeleton interface. This wraps up all mutations that can be performed on a skeleton in a model-view type architecture.
	- Skeleton tree acts as the view of the editable skeleton's data. When an edit is made in one version of a skeleton tree, it is reflected in all of them.
	- Removed all 'PersonaPtr's. Communication is now performed via delegates and appropriate API bindings (preview scene, editable skeleton etc.)
	- Viewport reworked to use editor modes for its more specific inputs. Skeletal controls now use editor modes for their inputs.
	- Better control of 'focus on draw' in the viewport. We can now optionally interpolate in approriate circumstances.
	- Animation preview scene resurrected. Now we manage much of the underlying objects in the preview scene. It also acts as a messaging conduit for events related to the scene.
	- We can now add additional meshes to a skeleton for use as previews. This is perfomred via a new UPreviewMeshCollection asset type & edited in the viewport.
	- Removed old SAdditionalMeshesEditor as the new system replaces its functionality.
	- Added asset family shortcut bar (and IAssetFamily to support this).
	- Const corrected some engine functions.
	- Added the ability for a skel mesh component to function without a primary skeletal mesh. This is usually a transient state in-editor but now the engine will not crash.
	- Padding, layouts and appearance of all editors have been polished.
	- Moved recording controls to the viewport and recording code into the preview scene. Now anything that uses a Persona viewport can use recording.
	- Tweaked recording icon to always use some red (feedback was it was non-obvious that it was a recording button).
	- Improved anim BP preview editor. We now have a bubtton that copies values that have changed to the defaults so that preview edits can more easily be seen & transferred.
	- Removed sequence recorder from non-level editor windows.

Change 3109628 on 2016/09/01 by Thomas.Sarkanen

	Fix non-unity build

Change 3109639 on 2016/09/01 by Thomas.Sarkanen

	CIS fix: Monolithic non-editor builds

Change 3109648 on 2016/09/01 by Thomas.Sarkanen

	Properly fix monolithic CIS this time

Change 3109683 on 2016/09/01 by Thomas.Sarkanen

	Fix Mac editor CIS

Change 3109689 on 2016/09/01 by Benn.Gallagher

	Fix crash in when a client spawns a destructible in a world with multiple players, caused by assuming we have a scene when the insertion may be deferred.
	#jira UE-35353

Change 3109699 on 2016/09/01 by Thomas.Sarkanen

	More Mac Editor CIS fixes.

Change 3109727 on 2016/09/01 by Danny.Bouimad

	Fixing UE-34814, issue where a socket was not rendering correctly. Note: The old socket wasn't attached to a bone to fix the issue so it was attached to the root bone.

Change 3109758 on 2016/09/01 by Thomas.Sarkanen

	More Mac editor CIS fixes

	Somehow includes from engine and unrealed were still getting picked up outside of PCH on windows. Updated PCH's and other includes to cover the mssing types.

Change 3109829 on 2016/09/01 by Thomas.Sarkanen

	Fix crash when attaching slave components with differing bone counts

Change 3111672 on 2016/09/02 by Thomas.Sarkanen

	Populated UV channels correctly

	Delegate for preview mesh change was being fired early (when the preview scene was created), so UV channels were never populated. Added a call to populate on construction.

Change 3111924 on 2016/09/02 by Martin.Wilson

	Clean up references to GetBoneTree and deprecate

	#jira UE-35525

Change 3112086 on 2016/09/02 by Martin.Wilson

	Fix pose flickering on LOD change when using Layered Blend by Bone node

	#Jira UE-35471

Change 3112097 on 2016/09/02 by Aaron.McLeran

	UE-35533 StopQuietest concurrency not resulting in sounds returning to play

	- Issue is due to the fact that once an active sound was flagged as needing to stop due to max concurrency, it was never unflagging as needing to stop
	- Fix is to make sure to unflag active sounds in a concurrency group as bShouldStopDueToMaxConcurrency before flagging the ones that do.

Change 3112467 on 2016/09/02 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3112269

Change 3112604 on 2016/09/02 by Lina.Halper

	Fixed merge compile error

Change 3113524 on 2016/09/05 by Thomas.Sarkanen

	Prevent invalid assets from causing crashes with asset families

	Store asset references as weak object ptrs as assets can go away underneath us.
	Also dont preserve asset families when all referencing asset editors are shut down, use weak references instead.

	#jira UE-35572 - Crash when opening Child Montage after force deleting an older child montage with the same name from the same asset

Change 3114118 on 2016/09/06 by Marc.Audy

	Add boolean return to AGameMode::ClearPause to indicate whether pausing was cleared
	#jira UE-32852

Change 3114201 on 2016/09/06 by Lina.Halper

	#ANMI: Moving animation curves from asset to skeleton

	- Backward compatibility
	- AnimCurve Viewer contains the setting of changing curve type - only material or morph would display.
	- Morphtarget curves are automatically set on loading
	- Asset still contains curve type including editable or disabled and so on. I was going to make this to be editor only but I can't until we copy over all the data - because morphtarget/material deprecated flags are needed to be loaded in game

	- TODO: Moving cached UI to FBoneContainer, so that it can work with RequiredBones
	- TODO: Linking curve to joint
	- TODO: Allow Layer blending to use this data to blend curves

	#Code review:Martin.Wilson, James.Golding
	#jira: UEFW-179

Change 3114391 on 2016/09/06 by Lina.Halper

	Build warning fix

Change 3114399 on 2016/09/06 by Lina.Halper

	Fix build error.

Change 3114403 on 2016/09/06 by Lina.Halper

	Attempt to fix build error

Change 3114591 on 2016/09/06 by Lina.Halper

	Fix compile error

Change 3114963 on 2016/09/06 by Lina.Halper

	Fixed crash on deleting skeleton when placed in the level

	#jira: UE-35601

Change 3114985 on 2016/09/06 by Lina.Halper

	Fix crash with copy pose mesh node not checking registered or not.

	#jira: UE-35602

Change 3115933 on 2016/09/07 by James.Golding

	UE-33251 - add 'restart required' to bSupportUVFromHitResults option

Change 3116021 on 2016/09/07 by Marc.Audy

	Fix spelling
	de-auto
	NULL to nullptr
	minor optimization

Change 3116046 on 2016/09/07 by James.Golding

	Move AnimNode_LegIK.h to Public and .cpp for Private

Change 3116048 on 2016/09/07 by James.Golding

	UE-34640 Fix bogus tooltips for collision channels

Change 3116050 on 2016/09/07 by James.Golding

	PR #2728: UE-34953: Improved comments for Hit callbacks (Contributed by projectgheist)

Change 3116060 on 2016/09/07 by Lina.Halper

	#ANIM:

	- Fix crash of setting multiple times in the same menu
	- Make sure you can set to original animation, and not break

	#jira: UE-35580

Change 3116064 on 2016/09/07 by James.Golding

	Fix missing change for LegIK file move

Change 3116291 on 2016/09/07 by Marc.Audy

	FindObjectWithOuter once again allows ClassToLookFor to be null as comment indicates is allowed

Change 3116590 on 2016/09/07 by Dan.Reynolds

	Audio Test Map Content WIP

Change 3116649 on 2016/09/07 by mason.seay

	Updated map to test flying

Change 3116712 on 2016/09/07 by dan.reynolds

	Test Content Update EQTest Map WIP

Change 3117257 on 2016/09/08 by Benn.Gallagher

	Fixed skeletal mesh details not working in new standalone mesh editor. Duplicated the detail customization and reworked to handle the new host app (no longer FPersona).

Change 3117348 on 2016/09/08 by Benn.Gallagher

	Added "Post-Process" Animation Blueprints. These run after the main anim instance, and the class used is set on the mesh so that any instance of that mesh uses that class as a post process. If there is a sub-input node inside the post process graph then the pose at the end of the main instance will be passed through into that instance.
	#jira UEFW-180

Change 3117393 on 2016/09/08 by Benn.Gallagher

	Hid UDestructibleMesh properties that are unsupported on destructibles in the destrucitble mesh editor (shadow assets and post process blueprints are only for normal skeletal meshes)
	#jira UE-34508

Change 3117507 on 2016/09/08 by Jurre.deBaare

	Streamline Persona Asset Browser
	#added ability to set whether or not a column should generate widgets in STableViews
	#added filtering code to SAssetview to allow for hiding/showing columns related to the asset type
	#added an ini path for saving the column filter state in SAnimationSequenceBrowser
	#jira UEFW-148

Change 3118003 on 2016/09/08 by mason.seay

	Updating meshes to use complex collision

Change 3118020 on 2016/09/08 by Zak.Middleton

	#ue4 - Auto-register UpdatedComponent in MovementComponent in InitializeComponent() if not found during OnRegister(). This can occur for non-native (BP) root components.

Change 3118437 on 2016/09/08 by Lina.Halper

	Fix grammar error

	#jira: UE-35729, UE-35730, UE-35729

Change 3118456 on 2016/09/08 by Lina.Halper

	Removed space because slate showed long spaces. It's long line now but at least in UI, it looks cleaner.

Change 3118492 on 2016/09/08 by Aaron.McLeran

	Copying //UE4/Dev-Audio to Dev-Framework (//UE4/Dev-Framework)

Change 3118517 on 2016/09/08 by Lina.Halper

	Went back to original without spaces

Change 3118711 on 2016/09/08 by Aaron.McLeran

	Fixing build errors with CL 3118492

Change 3118712 on 2016/09/08 by Aaron.McLeran

	Fixing a build warning with CL 3118492

Change 3118745 on 2016/09/08 by Aaron.McLeran

	Fixing a build warning with CL 3118492

	- Fixed init order in FSoundSource

Change 3119201 on 2016/09/09 by Benn.Gallagher

	Fix static analysis warnings (Accessing nullptr), added check on the pointer
	#jira UE-35755

Change 3119338 on 2016/09/09 by Benn.Gallagher

	Fixed destructible import throwing out meshes where 1 or more submeshes are empty

Change 3119371 on 2016/09/09 by Lina.Halper

	fix texts

Change 3119453 on 2016/09/09 by Lina.Halper

	Change text style of the child montage instruction.

	#jira: UE-35144

Change 3119454 on 2016/09/09 by Lina.Halper

	Add option to open asset from context menu of the segment

	#jira: UE-35632

Change 3119457 on 2016/09/09 by mason.seay

	Updated maps and rebuilt lighting

Change 3119584 on 2016/09/09 by Marc.Audy

	Support for new metadata ShowInnerProperties (written by Matt K)

Change 3119667 on 2016/09/09 by Aaron.McLeran

	Fixing compile errors on Mac.

	- Commandlet can't run on Mac (or other desktop platforms) right now since audio mixer isn't yet supported there

Change 3119732 on 2016/09/09 by Aaron.McLeran

	Fixing clang compile error

	- Apparently clang didn't like my ascii art of the wavetable shapes. Switched to /* */ style comment.

Change 3119734 on 2016/09/09 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3119702

Change 3119787 on 2016/09/09 by Lina.Halper

	Move cached UID to required bone

	- removed skeleton cached UID list
	- removed skeletalmeshcomponent cached UID list
	- FBoneContainer will contain UID list and can be re-cached anytime bones are recalculated
	- added versioning to up-to-date skeleton curve list with skeletalmeshcomponent

	#code review:Benn.Gallagher, Martin.Wilson

Change 3119800 on 2016/09/09 by Aaron.McLeran

	Changing audio mixer's GetAudioClock to GetAudioTime to avoid conflicting with other GetAudioClock function merged into dev-framework.

Change 3120260 on 2016/09/09 by Marc.Audy

	Fix if statement

Change 3120790 on 2016/09/12 by Thomas.Sarkanen

	Reordered skeletal mesh and animations in asset shortcut bar

	#jira UE-35845 - Move anim asset shortcut bar ordering to Skeleton > Skeletal Mesh > Animation > AnimBP

Change 3120793 on 2016/09/12 by Thomas.Sarkanen

	Improved fix for missing mesh details customization

	Improves on CL 3117257.
	Removed extra RefreshViewports function. Communication should be done via the preview scene to accomodate future multiple viewports.
	Re-used generic asset properties tab with a callback delegate that allows post-construction customization. Removed older custom tab.
	Removed dependency between FSkeletalMeshDetails and FSkeletonEditor. Trying to avoid back-pointer dependencies to monolithic editors, as this was the main bulk of refactoring work when teasing Persona apart.

Change 3120867 on 2016/09/12 by Marc.Audy

	Fix incorrect condition in for causing static analysis warning

Change 3120900 on 2016/09/12 by mason.seay

	Actually build lighting this time

Change 3120904 on 2016/09/12 by Thomas.Sarkanen

	Skeletons can now be deleted once opened (once more)

	Editable skeleton manager now holds onto weak ptrs instread of shared ptrs.
	Added logic to compact if weak ptrs are invalid.

	#jira UE-35848 - Can't delete skeletons that have been opened in the new standalone editor

Change 3120927 on 2016/09/12 by Thomas.Sarkanen

	Details panel now shows selected items when re-opened

	Kept the underlying widget around so that any item selections can still correctly update the (hidden) UI.

	#jira UE-35445 - Details tab in persona dosn't populate with information when first opened

Change 3120979 on 2016/09/12 by Thomas.Sarkanen

	Re-added the ability to create pose assets

	This was added at a similar time to my final merges and didnt get merged over to the standalone animation editor.

	#jira UE-35740 - Create Pose asset missing from create animation dropdown

Change 3121208 on 2016/09/12 by Benn.Gallagher

	Added bulk reimport to the reimport manager that uses slow tasks to give users an idea how far they are through large operations.
	#jira UE-33216

Change 3121274 on 2016/09/12 by James.Golding

	PR #2264: Added functions that can change a UTimelineComponent's curve(s) via Blueprints. (Contributed by hgamiel)
	#jira UE-29346

Change 3121276 on 2016/09/12 by James.Golding

	UE-33242 : Add option to copy morph target names to clipboard

Change 3121278 on 2016/09/12 by James.Golding

	UE-33004 : Add proper commands for Curve Viewer

Change 3121472 on 2016/09/12 by Zak.Middleton

	#ue4 - Fix UGameplayStatics::SpawnEmitterAttached() using wrong scale when SnapToTarget (Keep World Scale) option is used. Improve comments for SpawnEmitterAttached().

	#jira UE-34482

Change 3121829 on 2016/09/12 by dan.reynolds

	Audio Blueprints Content Example WIP Update checked in to backlog by request of ZakB and Nick BB.

Change 3122218 on 2016/09/12 by Aaron.McLeran

	Minor cleanup in XAudio2Source.cpp

Change 3122823 on 2016/09/13 by Thomas.Sarkanen

	Fix incorrect camera offset when opening some skeletal meshes

	Skeletons that had no preview skeletal mesh set up gave incorrect bounds on first tick. This is fixed by updating the preview mesh in the scene desc so that bounds are correctly calculated on first viewport tick.

	#jira UE-35550 - Persona camera is far away from some skeletal meshes

Change 3122857 on 2016/09/13 by Lina.Halper

	Importing frame count issue with blendshapes
	- with this change when calculating sample rate, it checks blendshape curves.

	#jira: UE-27706

Change 3122992 on 2016/09/13 by Marc.Audy

	Child Actor Component now have an editable template
	* Template is stored as a child inside the child actor template
	* When gathering components for an actor, need to stop searching beyond any nested AActor
	#jira UEFW-125, UE-16474

Change 3123087 on 2016/09/13 by Marc.Audy

	Fix Child Actor Template being nulled out on template

Change 3123170 on 2016/09/13 by mason.seay

	Updated test map to test SpawnEmitterAttached SnapToTarget settings

	UEENGQA-9268

Change 3123203 on 2016/09/13 by Marc.Audy

	Multi-select of child actor components allows editing of template properties

Change 3123205 on 2016/09/13 by Marc.Audy

	Fix details panel constantly updating and not being interactable when multi-selected objects have ShowInnerProperty property
	#author Matt.Kuhlenschmidt

Change 3123422 on 2016/09/13 by Aaron.McLeran

	UE-35950 Fixing XboxOne spatialization

	- XBoxOne doesn't support device details, so we need to manually set it to the output channels and channel mask. Unfortunately, that was incorrectly set.

Change 3123484 on 2016/09/13 by Lina.Halper

	Fix animation frame UI issue
	- This now displays from [0, numframes -1]

	#jira: UE-33437

Change 3123500 on 2016/09/13 by Marc.Audy

	Undo/redo of mobility changes will also undo/redo the mobility changes on ancestors/descendants that were changed along with it
	#jira UE-35885

Change 3123549 on 2016/09/13 by Marc.Audy

	Fix warning message

Change 3123581 on 2016/09/13 by Marc.Audy

	PR #2751: Editor Only UActorComponents for Blueprints (Contributed by moritz-wundke)
	#jira UE-35424

Change 3123688 on 2016/09/13 by Ben.Zeigler

	Add logic to K2Node_Variable that updates the variable reference to the correct class, if the variable has moved up or down in the class hierarchy. This is similar to code in UK2Node_CallFunction::CreateSelfPin which already handled this case correctly

Change 3123768 on 2016/09/13 by Marc.Audy

	Go away auto
	NULL to nullptr
	Use ranged for instead of iterators

Change 3123906 on 2016/09/13 by Aaron.McLeran

	UE-34615 Supporting Pausing Sounds on Audio Components

Change 3123949 on 2016/09/13 by Aaron.McLeran

	UE-35965 Spatialization no longer occurs when Non-Spatialized Radius is set above 0

Change 3124109 on 2016/09/13 by Aaron.McLeran

	UE-33364 Making bSuppressSubtitles a UPROPERTY EditAnywhere, BlueprintReadWrite

Change 3124137 on 2016/09/13 by Aaron.McLeran

	PR #2601: made looping sound waves searchable by the asset registry

Change 3124396 on 2016/09/14 by James.Golding

	Allow anim node edit modes to work on all nodes, not just skel controls

Change 3124498 on 2016/09/14 by Benn.Gallagher

	Added method to get swing and twist quaternions from FQuat
	#jira UE-34054

Change 3124504 on 2016/09/14 by James.Golding

	Missed a few references to SkeletalControlEditMode

Change 3124508 on 2016/09/14 by James.Golding

	Fix function groupings in animnode editmode headers

Change 3124625 on 2016/09/14 by james.cobbett

	Rebuilding lighting.

Change 3124632 on 2016/09/14 by James.Golding

	UEFW-205 Adding support for PoseDriver to drive bones (based on PoseAsset)
	- Converted PoseDriver from SkelControl to AnimNode
	- Added PoseDriverEditMode
	- Added debug drawing to show target poses and current ref position
	- Aded support for PoseDriver using translation instead of rotation
	- Added AnimGraphNode_PoseHandler class, with code corresponding with AnimNode_PoseHandler

Change 3124636 on 2016/09/14 by James.Golding

	Missed file

Change 3124652 on 2016/09/14 by Marc.Audy

	Fix initialization order warning
	#jira UE-35980

Change 3124658 on 2016/09/14 by Marc.Audy

	Fix if statement
	#jira UE-35976

Change 3124685 on 2016/09/14 by James.Golding

	Move PoseDriver files from BoneControllers to AnimNodes folder
	Rename AnimNode_PosePriver.cpp to AnimNode_PoseDriver.cpp
	Move AnimGraphNode_AssetPlayerBase.cpp from Classes to Private

Change 3124690 on 2016/09/14 by James.Golding

	Missing header edit after file move

Change 3124707 on 2016/09/14 by Danny.Bouimad

	Fixing UE-34814, issue where a socket was not rendering correctly. Note: The old socket wasn't attached to a bone to fix the issue so it was attached to the root bone.
	Somehow this was undone.

Change 3124954 on 2016/09/14 by Jurre.deBaare

	Import Alembic file gets editor crash
	#fix double check if Alembic isn't lying and there are no actual normals
	#misc fixed type in function signature
	#jira UE-35702

Change 3124980 on 2016/09/14 by Lina.Halper

	Tweak UI of child anim montage
	- removed padding, changed font size

Change 3124981 on 2016/09/14 by Lina.Halper

	Changed text of keys to Frames

Change 3124998 on 2016/09/14 by Lina.Halper

	Fix curve issue when evaluting with # of frames.

	#jira: UE-35782

Change 3125034 on 2016/09/14 by Aaron.McLeran

	Changes to 3123906 based on feedback from Marc Audy

Change 3125109 on 2016/09/14 by Aaron.McLeran

	PR #2463: Support parsing .WAV files with a WAVE_FORMAT_EXTENSIBLE format chunk (Contributed by Mattiwatti)

Change 3125184 on 2016/09/14 by Lukasz.Furman

	vehicle RVO fixes
	#ue4

Change 3125191 on 2016/09/14 by Lukasz.Furman

	added blueprint interface for component's navigation influence control
	#ue4

Change 3125348 on 2016/09/14 by Mason.Seay

	Added GamepadFaceButtonRight as an input mapping for Crouch

Change 3125352 on 2016/09/14 by Lina.Halper

	#ANIM: Pose Asset - Insert pose support

	- made sure pose asset editor updates if the new pose is inserted.

	#jira: UE-32608

Change 3125413 on 2016/09/14 by Ben.Zeigler

	#jira UEFW-32 Game Mode Cleanup
	Add GameModeBase and GameStateBase classes that are parent classes of existing GameMode and GameState. The classes have been split in half so the base functionality needed by all games are in the Base classes, with legacy and match-specific code in the children
	Added BP access to several GameState and GameMode functions, and GetGameState/GetGameMode now return the base classes.
	World->GetAuthGameMode now returns GameModeBase, so direct accesses to the return value may not work. The casted template works as before.
	World->GameState is now private, and GetGameState returns GameStateBase. Code that accessed GameState should now call GetGameState<>.
	GameModeBase::StartNewPlayer has been deprecated, and split into InitializeHUDForPlayer and HandleStartingNewPlayer.
	Several Login functions on GameModeBase that take TSharedPtr<const FUniqueNetId> are now deprecated correctly, they previously stopped working correctly in 4.13
	The ShouldShowGore feature on GameState has been fully deprecated, along with hooks in Matinee

Change 3125414 on 2016/09/14 by Ben.Zeigler

	#jira UEFW-32 Game Mode Cleanup
	Convert all internal templates to use GameModeBase
	Convert most sample games, ShooterGame and several legacy projects are still using GameMode

Change 3125415 on 2016/09/14 by Ben.Zeigler

	#jira UEFW-32 Game Mode Cleanup
	Internal game compile fixes needed to support GameMode refactor
	Fixed a few places that overrode StartNewPlayer to override new functions instead

Change 3125438 on 2016/09/14 by Ben.Zeigler

	Log compile fix

Change 3125460 on 2016/09/14 by Ben.Zeigler

	Another try at log compile issues

Change 3125685 on 2016/09/14 by Aaron.McLeran

	Attempt to fix compile error

Change 3125700 on 2016/09/14 by Aaron.McLeran

	UE-35958 Undo in sound cue editor does not undo looping changes.

	Issue was sound cues were not being flagged as transactional and ignoring undo transactions

Change 3125857 on 2016/09/14 by Aaron.McLeran

	-Adding a RF_Transactional flag to postload for sound nodes so older sound nodes created incorrectly will work properly with the undo system.
	-Changed to setting flag directly in NewObject line instead of calling SetFlags

Change 3125888 on 2016/09/14 by Aaron.McLeran

	Adding call to super post load in USoundNode::PostLoad()

Change 3125964 on 2016/09/14 by Aaron.McLeran

	Fixing attenuation on 2D multichannel files (specifically 3, 7 and 8-channel files).

Change 3125974 on 2016/09/14 by Aaron.McLeran

	UE-35892 Not loading audio data when in -nosound mode

Change 3125983 on 2016/09/14 by Ben.Zeigler

	Better Nogore fix for lens effect

Change 3125985 on 2016/09/14 by Ben.Zeigler

	Fix fortnite compile failure on mac, it was inside non instantiated template

Change 3126409 on 2016/09/15 by Benn.Gallagher

	Fixed crash when adding a reroute node on a line with another reroute node in an anim graph. Becuase we use poselinks as an exec line we weren't killing the output links.
	#jira UE-35657

Change 3126507 on 2016/09/15 by Thomas.Sarkanen

	Prevent crash when calling SetAnimationMode on a component with no skeletal mesh

	Guard against the mesh being NULL, as with other calls to InitializeAnimScriptInstance.

	#jira UE-36003 - Crash playing Ocean

Change 3126539 on 2016/09/15 by Marc.Audy

	Fix Win32 compilation error
	#jira UE-36018

Change 3126575 on 2016/09/15 by Marc.Audy

	Properly fix compile

Change 3126635 on 2016/09/15 by Benn.Gallagher

	Fix for crash when setting collision responses on destructible components after they have been fractured.
	#jira UE-35604

Change 3126649 on 2016/09/15 by Lina.Halper

	- Fixed issue with updating cache UID List, so certain curves did not work.
	- Fixed issue with not finding meta data because the name has changed - converted to SmartName, and if it is going to look for by UID.

Change 3126816 on 2016/09/15 by Lukasz.Furman

	Back out changelist 3125191

Change 3126903 on 2016/09/15 by Marc.Audy

	Fix !WITH_APEX compile errors from CL# 3126635

Change 3126908 on 2016/09/15 by Mieszko.Zielinski

	Added initialization of FBlackboardEntry properties #UE4

Change 3127081 on 2016/09/15 by Ben.Zeigler

	#jira UEFW-32 Game Mode Cleanup
	Change the way that the GameMode is picked based on URL to be handled by GameInstance instead of World/GameMode.
	Add PreloadContentForURL, CreateGameModeForURL, and OverrideGameModeClass to GameInstance and deprecate GameMode versions.
	GameMode::GameModeClassAliases has moved to GameMapsSettings::GameModeClassAliases and WorldSettings::DefaultMapPrefixes has moved to GameMapsSettings::GameModeMapPrefixes and unified in format.
	Fixed internal game ini files and added example to BaseEngine.ini
	Removed some outdated seekfree preload code and replace with GameInstance::PreloadContentForURL

Change 3127102 on 2016/09/15 by Ben.Zeigler

	Crash fix if there is no deprecated config section

Change 3127103 on 2016/09/15 by Aaron.McLeran

	UE-34100 audio playback of an individual source

Change 3127109 on 2016/09/15 by Marc.Audy

	Remove inconsistently used AUDIO_DEVICE_HANDLE_INVALID and use INDEX_NONE everywhere instead

Change 3127143 on 2016/09/15 by Aaron.McLeran

	Missing file in CL 3127103

Change 3127218 on 2016/09/15 by Ori.Cohen

	PR #2766: More vehicle stats for profiler (Contributed by DenizPiri)

	#JIRA UE-35564

Change 3127264 on 2016/09/15 by Aaron.McLeran

	Switching to using USoundWave instead of USoundBase in notification delegate for play progress percent

Change 3127285 on 2016/09/15 by Marc.Audy

	Make it easier to create an audio component that will exist across level transitions
	Refactor FAudioDevice::CreateComponent to use a Params block instead of long parameter list
	UAudioComponent can now store which AudioDevice it is targetted at instead of being limited to its registered world or the main audio device (breaks in multi-PIE)
	#jira UE-16451

Change 3127360 on 2016/09/15 by Marc.Audy

	Consolidate a few GetWorld()s

Change 3127931 on 2016/09/16 by Benn.Gallagher

	Fixed holes appearing in clothing meshes after reskinning changes. Caused by mismatched triangle counts when applying the clothing mesh.
	#jira UE-36054

Change 3128001 on 2016/09/16 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3127918

Change 3128005 on 2016/09/16 by James.Cobbett

	#jira UE-29618 Submitting test assets

Change 3128022 on 2016/09/16 by Lina.Halper

	Allow re-merge all skeletalmeshes back to skeleton when recreating skeleton from scratch

	#jira: UE-27256

Change 3128044 on 2016/09/16 by James.Cobbett

	Submitting gamemode test asset

Change 3128169 on 2016/09/16 by Mieszko.Zielinski

	Fixed couple of static analysis warnings in AI code #UE4

Change 3128430 on 2016/09/16 by Marc.Audy

	Fix infinite loop when running a pause frame with tick interval functions (4.13.1)
	#jira UE-36096

Change 3128558 on 2016/09/16 by Mieszko.Zielinski

	Refactored FEnvQueryInstance::AddItemData to not require second template parameter (TypeValue) #UE4

	#jira UE-33036

Change 3128678 on 2016/09/16 by Jon.Nabozny

	#rn Added a delegate to GameViewportClient that notifies when the Game's platform specific window is being closed.
	#rn This can be used to prevent the game from being exited.

	#jira UE-34123

Change 3128693 on 2016/09/16 by Marc.Audy

	Add UnpausedTimeSeconds to UWorld to accumulate the dilated/clamped game time even when paused

Change 3128753 on 2016/09/16 by Mieszko.Zielinski

	Fixed aborting previous movements as part requesting a new one needlesly reseting move agent's current velocity #UE4

	#jira UE-35852

Change 3128791 on 2016/09/16 by Marc.Audy

	PR #2777: Accurate DeltaSeconds for objects with TickIntervals (Contributed by YossiMHWF)
	Tick Functions with a Tick Interval will now return the dilated/clamped game DeltaSeconds since the last time it ticked
	#jira UE-35719

Change 3128974 on 2016/09/16 by Mieszko.Zielinski

	Fixes to BB key synchronization #UE4

	syncing between two BBs associated by a common parent now works

Change 3128984 on 2016/09/16 by Jon.Nabozny

	Fix FConstraintBaseParams ContactDistance clamping.
	The value is intended to be in either degrees or cm units (depending on constraint type), so clamping max to 1 doesn't make sense.

Change 3129010 on 2016/09/16 by Dan.Reynolds

	Updating developer folder content for external referencing

Change 3129093 on 2016/09/16 by Ben.Zeigler

	#jira UE-35424
	Switch from using AlwaysLoadOnServer/Client to bIsEditorOnly for components that should be editor only. This works better with cooking and is clearer in usage
	Move MarkAsEditorOnlySubobject to ActorComponent so it works for all components and not just primitive ones

Change 3129103 on 2016/09/16 by Marc.Audy

	Fix initialization order CIS warning

Change 3129361 on 2016/09/16 by Dan.Reynolds

	Fixes to QASoundWaveProcedural.h

Change 3129994 on 2016/09/19 by Thomas.Sarkanen

	Skeletal mesh to Static mesh conversion

	Added feature to convert selected actors' meshes into static meshes.
	Supports static and skeletal meshes.
	Added extension points to all Persona-based editors so their toolbars can be overriden with context about the editor itself.
	Added IHasPersonaToolkit interface that all of these editors implement.
	Added toolbar button to each Persona-based editor.
	Added level editor right-click menu option.

	Added CPU skinning path for cloth sections (non-SIMD for now).
	Moved CPU skinning flag from UDebugSkelMeshComponent into USkinnedMeshComponent.
	Moved a few structures around so CPU skinned renderdata is more readily exposed.

	#jira UE-35549 - Convert skel mesh on specific anim frame to StaticMesh

Change 3130008 on 2016/09/19 by Benn.Gallagher

	Fixed crash when creating a destructible mesh from a speed tree mesh. The materials are incompatible - after discussion decided to report the error to the user and bail on making the destructible
	#jira UE-3687

Change 3130009 on 2016/09/19 by Thomas.Sarkanen

	Fixed static analysis warnings in Persona and AnimationBlueprintEditor

	Also moved a bool check inside (original line number for the warning led me to that code instead, but thought it was worth fixing anyways).

Change 3130012 on 2016/09/19 by Thomas.Sarkanen

	CIS fix (implcit use of copy constructor)

Change 3130016 on 2016/09/19 by Thomas.Sarkanen

	Mac CIS fix - forward declare some classes.

Change 3130027 on 2016/09/19 by Thomas.Sarkanen

	Fix shadow variables found with Clang

Change 3130044 on 2016/09/19 by Jurre.deBaare

	Improved Texture Merging using the Merge Actors Tool
	#feature added simple binning algorithm to be used with texture importance values
	#misc small array indexing copy-paste error
	#jira UE-33823

Change 3130068 on 2016/09/19 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3129803

Change 3130181 on 2016/09/19 by Jurre.deBaare

	G++ compile errors
	#fix array enum size requires cast to be valid

Change 3130182 on 2016/09/19 by Jurre.deBaare

	Remove FColor operator after feedback from Marc, assuming color order is indeed icky and can tackle the problem differently

Change 3130250 on 2016/09/19 by Marc.Audy

	Fix flag check indicated by static analysis

Change 3130256 on 2016/09/19 by Benn.Gallagher

	Changed "Create Physics Asset" context menu options to allow creation without assigning the physics asset to the selected mesh to make it easier to set up capsule shadows.
	#jira UE-34796

Change 3130267 on 2016/09/19 by Marc.Audy

	Post integration WEX fixups for GameMode and FAudioDevice::CreateComponent changes

Change 3130551 on 2016/09/19 by Ben.Zeigler

	Change WEX OnlineSubsystem plugin to exactly match Engine one with GameMode refactors, no functionaly change but this should make merging easier

Change 3130564 on 2016/09/19 by Jurre.deBaare

	More CIS fixes

Change 3130572 on 2016/09/19 by Ben.Zeigler

	#jira UE-36142 Fix 1v1 and 2v2 game mode references, they were always wrong but are now being cooked properly with the game mode changes

Change 3130586 on 2016/09/19 by Ben.Zeigler

	#jira UE-36124 Fix orion crash, the class layout of OrionGameState_MOBA differed between BlueprintContext and OrionGame modules because of the server perf define being different

Change 3130587 on 2016/09/19 by Martin.Wilson

	Add start time to Montage_Play and PlaySlotAnimationAsDynamicMontage

	#jira UE-34798

Change 3130694 on 2016/09/19 by Ben.Zeigler

	#jira UE-35424 Restore BrushComponent to the 4.13 behavior for computing editor only, as they set AlwaysLoadOnClient/Server to false even if they're not editor only unlike other primitive components

Change 3130700 on 2016/09/19 by Ben.Zeigler

	#jira UE-36141 Fix it so PlayerCanRestart is called before restarting player on initial login, to match behavior when requesting a restart or match starting. This is a bug fix in the core code that UT was working around originally

Change 3130778 on 2016/09/19 by Dan.Reynolds

	WIP Content update for external referencing

Change 3130812 on 2016/09/19 by Marc.Audy

	No longer use inconsistently applied bWantsBeginPlay
	#jira UE-21048

Change 3130876 on 2016/09/19 by Richard.Hinckley

	Fixing comments for documentation purposes.

Change 3131076 on 2016/09/19 by Marc.Audy

	PR #2775: Make WorldContextObj arguments const pointers (Contributed by jorgenpt)
	#jira UE-35625

Change 3131102 on 2016/09/19 by Richard.Hinckley

	Fixing typo that slipped through.

Change 3131254 on 2016/09/19 by Ben.Zeigler

	#jira UE-36162 Remove bad game mode reference

Change 3131396 on 2016/09/19 by Marc.Audy

	Undo CL# 3125974 to fix Fortnite crash until investigation can be done
	#jira -UE-36164

Change 3131846 on 2016/09/20 by Thomas.Sarkanen

	Recording now functional again in blendspace editor

	Blendspaces now use the anim editor base.
	Anim editor base now has the option of a scrollable or non-scrollable widget area. Blendspaces use the non-scrollable one as before.
	Scrub widget now seperates the concepts of frames and scrub cursor. This is to allow blendspaces to still use scrubbing when they use normalized time.
	Removed PURE_VIRTUAL from SAnimEditorBase as it is not a UObject class.

	#jira UE-35843 - Missing record option for Blendspaces

Change 3131921 on 2016/09/20 by Thomas.Sarkanen

	Re-added anim slot manager tab

	Anim slot manager was not added back into the standalone editors when they were split up.

	#jira UE-35954 - Anim Slot Manager opens up to unrecognized tab

Change 3131922 on 2016/09/20 by Thomas.Sarkanen

	Added 'dirty' indicator to asset shortcut bar

	#jira UE-36015 - No 'dirty' indicator in anim asset shortcut bar

Change 3131950 on 2016/09/20 by Thomas.Sarkanen

	Animation stepping now functions as it did previously

	Recent changes to deal with different frame counts left off an epsilon in the frame increment/decrement logic. Re-instating the epsilon fixes this.

	#jira UE-36172 - The To Next button in the Animation timeline doesn't work consistently

Change 3131953 on 2016/09/20 by james.cobbett

	Updating test assets.

Change 3132241 on 2016/09/20 by Martin.Wilson

	Fix crash when importing a pose to pose asset.

	#jira UE-36122

Change 3132417 on 2016/09/20 by Thomas.Sarkanen

	Fixed crash when anim instance is set to NULL when URO is turned on (and GC occurs)

	A dangling pointer to the UID array on the instance was hanging around. We now make sure to clear this when necessary.

	#jira UE-36182 - Fornite cooked crashed when hitting a husk near/on a chest - CurveToCopyFrom.IsValid()

Change 3132790 on 2016/09/20 by Ori.Cohen

	Ensure that physics handle automatically wakes up any object it's grabbing on release. Also fix editor case where moving camera grabs component

	#JIRA UE-35257

Change 3132795 on 2016/09/20 by Ori.Cohen

	Fix typo where enable swing drive was used for both swing and twist.

	#JIRA UE-35634

Change 3132838 on 2016/09/20 by Ori.Cohen

	Move flush deferred actor to EndPhysics

	#JIRA UE-35899

Change 3133088 on 2016/09/20 by Ori.Cohen

	Back out defer flush change. This requires more thought.

Change 3133185 on 2016/09/20 by Wes.Hunt

	QoS Analytics providers now use the real final Data Router URL #jira UE-30655

Change 3133262 on 2016/09/20 by Wes.Hunt

	HttpServiceTracker now uses UserID fields that match what we expect for all other apps. Part of #jira UE-33354.

Change 3133266 on 2016/09/20 by Wes.Hunt

	Make anonymous analytics UserID match format expected by the backend to remove ambiguity. Part of #jira UE-33354.

Change 3133277 on 2016/09/20 by Chris.Evans

	!N Pose asset test

Change 3133504 on 2016/09/20 by dan.reynolds

	Updating WIP Test Content

Change 3133761 on 2016/09/21 by Thomas.Sarkanen

	Fixed 100% crash when killing a husk

	Interpolation was still getting performed when we had an invalid UID container. We now check this before kicking off a task.

	#jira UE-36203 - Fornite cooked crashed when killing a husk and jumping backwards

Change 3133766 on 2016/09/21 by Thomas.Sarkanen

	Fixed crash when compiling animation blueprint when a node outside of the tree evaluation is selected

	The OnNodeSelected callback was not getting called for deselection when the node could not be found (i.e. was NULL). Removed NULL check as it is valid to call. ALso added comment warning that the passed in runtime node can be NULL.

	#jira UE-35974 - Crash in FSkeletalControlEditMode when compiling an anim blueprint

Change 3133774 on 2016/09/21 by Danny.Bouimad

	Translation Pose  Driver test assets content/animation/posedrivertests

Change 3133796 on 2016/09/21 by Thomas.Sarkanen

	Added metadata to remove "reset to default" button for certain properties

	Allows removal of the reset button without a cumbersome details customization.
	Fixes crash where a parent struct of an editfixedsize array was reset.

	#jira UE-36109 - Crash when resetting shape properties on a BodySetup in PhAT

Change 3133831 on 2016/09/21 by Jurre.deBaare

	Vert Color Background not contained to Asset's Viewport
	#fix Added a way to directly set the visibility of the floor/environment in the static mesh editor
	#jira UE-35052

Change 3133832 on 2016/09/21 by Jurre.deBaare

	Geometry Cache asset will stop animating when Elapsed Time exceeds an excessively high number
	#fix set UI/clamp min/max for playback speed (-512 - 512x playback speed) and start offset (-14400 - 14400, 4 hours) and clamp at runtime as well
	#jira UE-34629

Change 3133833 on 2016/09/21 by Jurre.deBaare

	Geometry Cache asset will continue to loop when running in reverse when Loop is turned off and Elapsed Time is has reached 0
	#fix do not wrap around for non-looping negative sampling times :)
	#jira UE-34630

Change 3133834 on 2016/09/21 by Jurre.deBaare

	Merge Actors button is not enabled when selecting assets in the viewport if they are not visible in the Merge Actor window
	#fix moved selected mesh count functionality so that it is not dependent on the listview being rendered (this is an awesome bug)
	#jira UE-34303

	Static mesh does not show after using "Merge Actors" if the mesh is part of a child actor component that has been added to the blueprint
	#fix recursively add child actor components to include all static meshes
	#jira UE-25187

Change 3133835 on 2016/09/21 by Jurre.deBaare

	Mesh Preview Scene: Remove bottom quad from floor mesh to make viewing from below easier. (in loving memory of Tom Looman)
	#fix new mesh with removed bottom quad, allowing for see-through from below
	#jira UE-35022

Change 3133836 on 2016/09/21 by Jurre.deBaare

	It isn't clear when a profile is added to the Preview Scene Settings
	#fix selected profile now changes to newly added one
	#jira UE-33848

	Change preview scene profile naming to validate name input in UI instead of PostEditChange
	#fix added ui feedback for duplicate naming
	#misc extra checks for having a correct profile name when adding a new profile
	#jira UE-34078

	Adding Preview Scene Profile after Removing One duplicates the name of the last added profile
	#fix determine correct name by checking existing ones
	#jira UE-33898

Change 3133838 on 2016/09/21 by Jurre.deBaare

	Prevent preview scene assets being loaded in game (proper fix)
	#fix now saving direct FString path to the environment cube map and load them once we ::Get the assetviewer settings
	#jira UE-36082

Change 3133839 on 2016/09/21 by Jurre.deBaare

	Moving over UE-35254 from 4.13.1

Change 3133840 on 2016/09/21 by Jurre.deBaare

	Moving over UE-35639 from 4.13.1

Change 3133844 on 2016/09/21 by Jurre.deBaare

	Alembic import causing a crash

	#jira UE-35551
	#fix handle the case where there is not hierarchy found for a specific object, in that case just output the identity matrix as object matrix

	#jira UE-35451
	#fix handle case where we imported an empty object in the Geometry cache path

	#misc alembic importer signature change
	#misc typo in function signature

Change 3133951 on 2016/09/21 by Mieszko.Zielinski

	Fixed deprecation message on UAIPerceptionComponent::GetPerceivedActors #UE4

Change 3134014 on 2016/09/21 by Jon.Nabozny

	#rn Ensure the runaway loop counter gets reset when processing parallel animation.

	#jira UE-33946

Change 3134032 on 2016/09/21 by Jurre.deBaare

	Remove comments

Change 3134100 on 2016/09/21 by James.Golding

	UE-35300 Support UV traces for UV on BSP

Change 3134103 on 2016/09/21 by Lukasz.Furman

	fixed NavLinkProxy not working correctly in PIE
	#jira UE-36194

Change 3134104 on 2016/09/21 by James.Golding

	UE-33004 Use UI commands for PoseEditor, allow keyboard shortcuts

Change 3134106 on 2016/09/21 by James.Golding

	UE-36138 Fix crash in procmesh slicing, avoid creating, and skip processing, sections with no verts

Change 3134109 on 2016/09/21 by James.Golding

	UE-35813 Don't do srgb conversion for proc mesh vertex colors
	UE-35821 Procedural Mesh component not respecting 'Bound Scale' setting

Change 3134145 on 2016/09/21 by Mieszko.Zielinski

	Fixed persistent BB key changes not getting propagated to child BB assets #UE4

Change 3134296 on 2016/09/21 by Lukasz.Furman

	fixed navlink's "snap to cheapest area" mode not working correctly with dynamic navmesh
	copy of CL# 3133219

Change 3134390 on 2016/09/21 by mason.seay

	Blueprint for collision bug repro

Change 3134517 on 2016/09/21 by Mieszko.Zielinski

	CIS fix #UE4

Change 3134746 on 2016/09/21 by Ben.Zeigler

	Documentation and comment cleanup pass for GameMode changes, it's ready for a Doc team pass
	Change GameStateBase::GetDefaultGameMode to return a const * as it's a CDO that is not safe to modify, and remove Blueprint acessibility as there's no way to make that safe

Change 3134850 on 2016/09/21 by Ben.Zeigler

	Fix PlatformShowcase warnings

Change 3134852 on 2016/09/21 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3134107

Change 3134853 on 2016/09/21 by Marc.Audy

	Resolve of reimport portions

Change 3134857 on 2016/09/21 by Marc.Audy

	Fixes related to show inner properties for Map and Set now that Dev-Editor has made it to Dev-Framework

Change 3135002 on 2016/09/21 by Ori.Cohen

	Fix compiler errors

Change 3135147 on 2016/09/21 by dan.reynolds

	AEOverview Test WIP Update

Change 3135168 on 2016/09/21 by Wes.Hunt

	Edigrate of CL3135131: EngineAnalytics uses EngineVersion once again instead of BuildVersion, which doesn't contain major.minor.hotfix info.
	#jira UE-36211

Change 3135216 on 2016/09/21 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3135156

Change 3135238 on 2016/09/21 by Aaron.McLeran

	UE-36288 Fixing concurrency resolution stop quietest

Change 3135257 on 2016/09/21 by Ben.Zeigler

	Fix Orion version of OnlineGameFramework plugin

Change 3135258 on 2016/09/21 by Ben.Zeigler

	Other Orion GameMode fixes

Change 3135290 on 2016/09/21 by dan.reynolds

	AEOverview test map skeleton complete with comments per Nick BB request

Change 3135323 on 2016/09/21 by dan.reynolds

	Update to AEOverview test maps

Change 3135385 on 2016/09/21 by Marc.Audy

	Fix static analysis warnings in automation tests

Change 3135634 on 2016/09/22 by Thomas.Sarkanen

	Remove duplicated details customization

	Now we only have one customization that both 'old' Persona and the skeletal mesh editor can use.

Change 3135660 on 2016/09/22 by Thomas.Sarkanen

	CIS fix: Fixed deleted file still being included.

Change 3135949 on 2016/09/22 by Thomas.Sarkanen

	Fixed (another) crash with invalid curve data when an anim instance is GCed

	Invalidated cached curve as it can hold onto a reference to anim instance data. Also added a check for valididty in the non-parallel eval, non-interpolation case.

	#jira UE-36292 - Fortnite Editor Crashed when shooting a husk during defense phase - CurveToCopyFrom.IsValid()

[CL 3136620 by Marc Audy in Main branch]
2016-09-22 15:33:34 -04:00

3075 lines
97 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "PropertyEditorPrivatePCH.h"
#include "ObjectPropertyNode.h"
#include "CategoryPropertyNode.h"
#include "ScopedTransaction.h"
#include "PropertyRestriction.h"
#include "Editor/UnrealEd/Public/Kismet2/StructureEditorUtils.h"
#include "Editor/UnrealEd/Public/Kismet2/BlueprintEditorUtils.h"
#include "Engine/UserDefinedStruct.h"
#include "Misc/ScopeExit.h"
#include "PropertyHandleImpl.h"
#include "EditorSupportDelegates.h"
#include "SNotificationList.h"
#include "NotificationManager.h"
#define LOCTEXT_NAMESPACE "PropertyNode"
FPropertySettings& FPropertySettings::Get()
{
static FPropertySettings Settings;
return Settings;
}
FPropertySettings::FPropertySettings()
: bShowFriendlyPropertyNames( true )
, bExpandDistributions( false )
, bShowHiddenProperties(false)
{
GConfig->GetBool(TEXT("PropertySettings"), TEXT("ShowHiddenProperties"), bShowHiddenProperties, GEditorPerProjectIni);
GConfig->GetBool(TEXT("PropertySettings"), TEXT("ShowFriendlyPropertyNames"), bShowFriendlyPropertyNames, GEditorPerProjectIni);
GConfig->GetBool(TEXT("PropertySettings"), TEXT("ExpandDistributions"), bExpandDistributions, GEditorPerProjectIni);
}
DEFINE_LOG_CATEGORY(LogPropertyNode);
static FObjectPropertyNode* NotifyFindObjectItemParent(FPropertyNode* InNode)
{
FObjectPropertyNode* Result = NULL;
check(InNode);
FPropertyNode* ParentNode = InNode->GetParentNode();
if (ParentNode)
{
Result = ParentNode->FindObjectItemParent();
}
return Result;
}
FPropertyNode::FPropertyNode(void)
: ParentNode(NULL)
, Property(NULL)
, ArrayOffset(0)
, ArrayIndex(-1)
, MaxChildDepthAllowed(FPropertyNodeConstants::NoDepthRestrictions)
, PropertyNodeFlags (EPropertyNodeFlags::NoFlags)
, bRebuildChildrenRequested( false )
, PropertyPath(TEXT(""))
, bIsEditConst(false)
, bUpdateEditConstState(true)
, bDiffersFromDefault(false)
, bUpdateDiffersFromDefault(true)
{
}
FPropertyNode::~FPropertyNode(void)
{
DestroyTree();
}
void FPropertyNode::InitNode( const FPropertyNodeInitParams& InitParams )
{
//Dismantle the previous tree
DestroyTree();
//tree hierarchy
check(InitParams.ParentNode.Get() != this);
ParentNode = InitParams.ParentNode.Get();
ParentNodeWeakPtr = InitParams.ParentNode;
if (ParentNode)
{
//default to parents max child depth
MaxChildDepthAllowed = ParentNode->MaxChildDepthAllowed;
//if limitless or has hit the full limit
if (MaxChildDepthAllowed > 0)
{
--MaxChildDepthAllowed;
}
}
//Property Data
Property = InitParams.Property;
ArrayOffset = InitParams.ArrayOffset;
ArrayIndex = InitParams.ArrayIndex;
// Property is advanced if it is marked advanced or the entire class is advanced and the property not marked as simple
bool bAdvanced = Property.IsValid() ? ( Property->HasAnyPropertyFlags(CPF_AdvancedDisplay) || ( !Property->HasAnyPropertyFlags( CPF_SimpleDisplay ) && Property->GetOwnerClass() && Property->GetOwnerClass()->HasAnyClassFlags( CLASS_AdvancedDisplay ) ) ): false;
PropertyNodeFlags = EPropertyNodeFlags::NoFlags;
//default to copying from the parent
if (ParentNode)
{
SetNodeFlags(EPropertyNodeFlags::ShowCategories, !!ParentNode->HasNodeFlags(EPropertyNodeFlags::ShowCategories));
// We are advanced if our parent is advanced or our property is marked as advanced
SetNodeFlags(EPropertyNodeFlags::IsAdvanced, ParentNode->HasNodeFlags(EPropertyNodeFlags::IsAdvanced) || bAdvanced );
}
else
{
SetNodeFlags(EPropertyNodeFlags::ShowCategories, InitParams.bCreateCategoryNodes );
}
SetNodeFlags(EPropertyNodeFlags::ShouldShowHiddenProperties, InitParams.bForceHiddenPropertyVisibility);
SetNodeFlags(EPropertyNodeFlags::ShouldShowDisableEditOnInstance, InitParams.bCreateDisableEditOnInstanceNodes);
//Custom code run prior to setting property flags
//needs to happen after the above SetNodeFlags calls so that ObjectPropertyNode can properly respond to CollapseCategories
InitBeforeNodeFlags();
bool bIsEditInlineNew = false;
bool bShowInnerObjectProperties = false;
if ( !Property.IsValid() )
{
// Disable all flags if no property is bound.
SetNodeFlags(EPropertyNodeFlags::SingleSelectOnly | EPropertyNodeFlags::EditInlineNew | EPropertyNodeFlags::ShowInnerObjectProperties, false);
}
else
{
const bool GotReadAddresses = GetReadAddressUncached( *this, false, nullptr, false );
const bool bSingleSelectOnly = GetReadAddressUncached( *this, true, nullptr);
SetNodeFlags(EPropertyNodeFlags::SingleSelectOnly, bSingleSelectOnly);
UProperty* MyProperty = Property.Get();
const bool bIsObjectOrInterface = Cast<UObjectPropertyBase>(MyProperty) || Cast<UInterfaceProperty>(MyProperty);
// true if the property can be expanded into the property window; that is, instead of seeing
// a pointer to the object, you see the object's properties.
static const FName Name_EditInline("EditInline");
static const FName Name_ShowInnerProperties("ShowInnerProperties");
bIsEditInlineNew = bIsObjectOrInterface && GotReadAddresses && MyProperty->HasMetaData(Name_EditInline);
bShowInnerObjectProperties = bIsObjectOrInterface && GotReadAddresses && MyProperty->HasMetaData(Name_ShowInnerProperties);
if(bIsEditInlineNew)
{
SetNodeFlags(EPropertyNodeFlags::EditInlineNew, true);
}
else if(bShowInnerObjectProperties)
{
SetNodeFlags(EPropertyNodeFlags::ShowInnerObjectProperties, true);
}
//Get the property max child depth
static const FName Name_MaxPropertyDepth("MaxPropertyDepth");
if (Property->HasMetaData(Name_MaxPropertyDepth))
{
int32 NewMaxChildDepthAllowed = Property->GetINTMetaData(Name_MaxPropertyDepth);
//Ensure new depth is valid. Otherwise just let the parent specified value stand
if (NewMaxChildDepthAllowed > 0)
{
//if there is already a limit on the depth allowed, take the minimum of the allowable depths
if (MaxChildDepthAllowed >= 0)
{
MaxChildDepthAllowed = FMath::Min(MaxChildDepthAllowed, NewMaxChildDepthAllowed);
}
else
{
//no current limit, go ahead and take the new limit
MaxChildDepthAllowed = NewMaxChildDepthAllowed;
}
}
}
}
InitExpansionFlags();
UProperty* MyProperty = Property.Get();
bool bRequiresValidation = bIsEditInlineNew || bShowInnerObjectProperties || ( MyProperty && (MyProperty->IsA<UArrayProperty>() || MyProperty->IsA<USetProperty>() || MyProperty->IsA<UMapProperty>() ));
// We require validation if our parent also needs validation (if an array parent was resized all the addresses of children are invalid)
bRequiresValidation |= (GetParentNode() && GetParentNode()->HasNodeFlags( EPropertyNodeFlags::RequiresValidation ) != 0);
SetNodeFlags( EPropertyNodeFlags::RequiresValidation, bRequiresValidation );
if ( InitParams.bAllowChildren )
{
RebuildChildren();
}
PropertyPath = FPropertyNode::CreatePropertyPath(this->AsShared())->ToString();
}
/**
* Used for rebuilding a sub portion of the tree
*/
void FPropertyNode::RebuildChildren()
{
CachedReadAddresses.Reset();
bool bDestroySelf = false;
DestroyTree(bDestroySelf);
if (MaxChildDepthAllowed != 0)
{
//the case where we don't want init child nodes is when an Item has children that we don't want to display
//the other option would be to make each node "Read only" under that item.
//The example is a material assigned to a static mesh.
if (HasNodeFlags(EPropertyNodeFlags::CanBeExpanded) && (ChildNodes.Num() == 0))
{
InitChildNodes();
}
}
//see if they support some kind of edit condition
if (Property.IsValid() && Property->GetBoolMetaData(TEXT("FullyExpand")))
{
bool bExpand = true;
bool bRecurse = true;
}
// Children have been rebuilt, clear any pending rebuild requests
bRebuildChildrenRequested = false;
// Notify any listener that children have been rebuilt
OnRebuildChildren.ExecuteIfBound();
}
void FPropertyNode::AddChildNode(TSharedPtr<FPropertyNode> InNode)
{
ChildNodes.Add(InNode);
}
void FPropertyNode::ClearCachedReadAddresses( bool bRecursive )
{
CachedReadAddresses.Reset();
if( bRecursive )
{
for( int32 ChildIndex = 0; ChildIndex < ChildNodes.Num(); ++ChildIndex )
{
ChildNodes[ChildIndex]->ClearCachedReadAddresses( bRecursive );
}
}
}
// Follows the chain of items upwards until it finds the object window that houses this item.
FComplexPropertyNode* FPropertyNode::FindComplexParent()
{
FPropertyNode* Cur = this;
FComplexPropertyNode* Found = NULL;
while( true )
{
Found = Cur->AsComplexNode();
if( Found )
{
break;
}
Cur = Cur->GetParentNode();
if( !Cur )
{
// There is a break in the parent chain
break;
}
}
return Found;
}
// Follows the chain of items upwards until it finds the object window that houses this item.
const FComplexPropertyNode* FPropertyNode::FindComplexParent() const
{
const FPropertyNode* Cur = this;
const FComplexPropertyNode* Found = NULL;
while( true )
{
Found = Cur->AsComplexNode();
if( Found )
{
break;
}
Cur = Cur->GetParentNode();
if( !Cur )
{
// There is a break in the parent chain
break;
}
}
return Found;
}
class FObjectPropertyNode* FPropertyNode::FindObjectItemParent()
{
auto ComplexParent = FindComplexParent();
return ComplexParent ? ComplexParent->AsObjectNode() : NULL;
}
const class FObjectPropertyNode* FPropertyNode::FindObjectItemParent() const
{
const auto ComplexParent = FindComplexParent();
return ComplexParent ? ComplexParent->AsObjectNode() : NULL;
}
/**
* Follows the top-most object window that contains this property window item.
*/
FObjectPropertyNode* FPropertyNode::FindRootObjectItemParent()
{
// not every type of change to property values triggers a proper refresh of the hierarchy, so find the topmost container window and trigger a refresh manually.
FObjectPropertyNode* TopmostObjectItem=NULL;
FObjectPropertyNode* NextObjectItem = FindObjectItemParent();
while ( NextObjectItem != NULL )
{
TopmostObjectItem = NextObjectItem;
FPropertyNode* NextObjectParent = NextObjectItem->GetParentNode();
if ( NextObjectParent != NULL )
{
NextObjectItem = NextObjectParent->FindObjectItemParent();
}
else
{
break;
}
}
return TopmostObjectItem;
}
/**
* Used to see if any data has been destroyed from under the property tree. Should only be called by PropertyWindow::OnIdle
*/
EPropertyDataValidationResult FPropertyNode::EnsureDataIsValid()
{
bool bValidateChildren = !HasNodeFlags(EPropertyNodeFlags::SkipChildValidation);
// The root must always be validated
if( GetParentNode() == NULL || HasNodeFlags(EPropertyNodeFlags::RequiresValidation) != 0 )
{
CachedReadAddresses.Reset();
//Figure out if an array mismatch can be ignored
bool bIgnoreAllMismatch = false;
//make sure that force depth-limited trees don't cause a refresh
bIgnoreAllMismatch |= (MaxChildDepthAllowed==0);
//check my property
if (Property.IsValid())
{
UProperty* MyProperty = Property.Get();
//verify that the number of container children is correct
UArrayProperty* ArrayProperty = Cast<UArrayProperty>(MyProperty);
USetProperty* SetProperty = Cast<USetProperty>(MyProperty);
UMapProperty* MapProperty = Cast<UMapProperty>(MyProperty);
//default to unknown array length
int32 NumArrayChildren = -1;
//assume all arrays have the same length
bool bArraysHaveEqualNum = true;
//assume all arrays match the number of property window children
bool bArraysMatchChildNum = true;
bool bArrayHasNewItem = false;
if (ArrayProperty)
{
if (!ArrayProperty->Inner->IsA(UObjectProperty::StaticClass()) && !ArrayProperty->Inner->IsA(UStructProperty::StaticClass()))
{
bValidateChildren = false;
}
}
else if (SetProperty)
{
if (!SetProperty->ElementProp->IsA(UObjectProperty::StaticClass()) && !SetProperty->ElementProp->IsA(UStructProperty::StaticClass()))
{
bValidateChildren = false;
}
}
//verify that the number of object children are the same too
UObjectPropertyBase* ObjectProperty = Cast<UObjectPropertyBase>(MyProperty);
//check to see, if this an object property, whether the contents are NULL or not.
//This is the check to see if an object property was changed from NULL to non-NULL, or vice versa, from non-property window code.
bool bObjectPropertyNull = true;
//Edit inline properties can change underneath the window
bool bIgnoreChangingChildren = !(HasNodeFlags(EPropertyNodeFlags::EditInlineNew) || HasNodeFlags(EPropertyNodeFlags::ShowInnerObjectProperties)) ;
//ignore this node if the consistency check should happen for the children
bool bIgnoreStaticArray = (Property->ArrayDim > 1) && (ArrayIndex == -1);
//if this node can't possibly have children (or causes a circular reference loop) then ignore this as a object property
if (bIgnoreChangingChildren || bIgnoreStaticArray || HasNodeFlags(EPropertyNodeFlags::NoChildrenDueToCircularReference))
{
//this will bypass object property consistency checks
ObjectProperty = NULL;
}
FReadAddressList ReadAddresses;
const bool bSuccess = GetReadAddress( ReadAddresses );
//make sure we got the addresses correctly
if (!bSuccess)
{
UE_LOG( LogPropertyNode, Verbose, TEXT("Object is invalid %s"), *Property->GetName() );
return EPropertyDataValidationResult::ObjectInvalid;
}
// If an object property with ShowInnerProperties changed object values out from under the property
bool bShowInnerObjectPropertiesObjectChanged = false;
//check for null, if we find one, there is a problem.
for (int32 Scan = 0; Scan < ReadAddresses.Num(); ++Scan)
{
uint8* Addr = ReadAddresses.GetAddress(Scan);
//make sure the data still exists
if (Addr==NULL)
{
UE_LOG( LogPropertyNode, Verbose, TEXT("Object is invalid %s"), *Property->GetName() );
return EPropertyDataValidationResult::ObjectInvalid;
}
if( ArrayProperty && !bIgnoreAllMismatch)
{
//ensure that array structures have the proper number of children
int32 ArrayNum = FScriptArrayHelper::Num(Addr);
//if first child
if (NumArrayChildren == -1)
{
NumArrayChildren = ArrayNum;
}
bArrayHasNewItem = GetNumChildNodes() < ArrayNum;
//make sure multiple arrays match
bArraysHaveEqualNum = bArraysHaveEqualNum && (NumArrayChildren == ArrayNum);
//make sure the array matches the number of property node children
bArraysMatchChildNum = bArraysMatchChildNum && (GetNumChildNodes() == ArrayNum);
}
if (SetProperty && !bIgnoreAllMismatch)
{
// like arrays, ensure that set structures have the proper number of children
int32 SetNum = FScriptSetHelper::Num(Addr);
if (NumArrayChildren == -1)
{
NumArrayChildren = SetNum;
}
bArrayHasNewItem = GetNumChildNodes() < SetNum;
bArraysHaveEqualNum = bArraysHaveEqualNum && (NumArrayChildren == SetNum);
bArraysMatchChildNum = bArraysMatchChildNum && (GetNumChildNodes() == SetNum);
}
if (MapProperty && !bIgnoreAllMismatch)
{
int32 MapNum = FScriptMapHelper::Num(Addr);
if (NumArrayChildren == -1)
{
NumArrayChildren = MapNum;
}
bArrayHasNewItem = GetNumChildNodes() < MapNum;
bArraysHaveEqualNum = bArraysHaveEqualNum && (NumArrayChildren == MapNum);
bArraysMatchChildNum = bArraysMatchChildNum && (GetNumChildNodes() == MapNum);
}
if (ObjectProperty && !bIgnoreAllMismatch)
{
UObject* Obj = ObjectProperty->GetObjectPropertyValue(Addr);
if (!bShowInnerObjectPropertiesObjectChanged && HasNodeFlags(EPropertyNodeFlags::ShowInnerObjectProperties) && ChildNodes.Num() == 1)
{
bool bChildObjectFound = false;
// should never have more than one node (0 is ok if the object property is null)
check(ChildNodes.Num() == 1);
bool bNeedRebuild = false;
FObjectPropertyNode* ChildObjectNode = ChildNodes[0]->AsObjectNode();
for(int32 ObjectIndex = 0; ObjectIndex < ChildObjectNode->GetNumObjects(); ++ObjectIndex)
{
if(Obj == ChildObjectNode->GetUObject(ObjectIndex))
{
bChildObjectFound = true;
break;
}
}
bShowInnerObjectPropertiesObjectChanged = !bChildObjectFound;
}
if (Obj != NULL)
{
bObjectPropertyNull = false;
break;
}
}
}
//if all arrays match each other but they do NOT match the property structure, cause a rebuild
if (bArraysHaveEqualNum && !bArraysMatchChildNum)
{
RebuildChildren();
if( bArrayHasNewItem && ChildNodes.Num() )
{
TSharedPtr<FPropertyNode> LastChildNode = ChildNodes.Last();
// Don't expand huge children
if( LastChildNode->GetNumChildNodes() > 0 && LastChildNode->GetNumChildNodes() < 10 )
{
// Expand the last item for convenience since generally the user will want to edit the new value they added.
LastChildNode->SetNodeFlags(EPropertyNodeFlags::Expanded, true);
}
}
return EPropertyDataValidationResult::ArraySizeChanged;
}
if(bShowInnerObjectPropertiesObjectChanged)
{
RebuildChildren();
return EPropertyDataValidationResult::EditInlineNewValueChanged;
}
const bool bHasChildren = (GetNumChildNodes() != 0);
// If the object property is not null and has no children, its children need to be rebuilt
// If the object property is null and this node has children, the node needs to be rebuilt
if (ObjectProperty && ((!bObjectPropertyNull && !bHasChildren) || (bObjectPropertyNull && bHasChildren)))
{
RebuildChildren();
return EPropertyDataValidationResult::PropertiesChanged;
}
}
}
if( bRebuildChildrenRequested )
{
RebuildChildren();
// If this property is editinline and not edit const then its editinline new and we can optimize some of the refreshing in some cases. Otherwise we need to refresh all properties in the view
return HasNodeFlags(EPropertyNodeFlags::ShowInnerObjectProperties) || (HasNodeFlags(EPropertyNodeFlags::EditInlineNew) && !IsEditConst()) ? EPropertyDataValidationResult::EditInlineNewValueChanged : EPropertyDataValidationResult::PropertiesChanged;
}
EPropertyDataValidationResult FinalResult = EPropertyDataValidationResult::DataValid;
//go through my children
if (bValidateChildren)
{
for (int32 Scan = 0; Scan < ChildNodes.Num(); ++Scan)
{
TSharedPtr<FPropertyNode>& ChildNode = ChildNodes[Scan];
check(ChildNode.IsValid());
EPropertyDataValidationResult ChildDataResult = ChildNode->EnsureDataIsValid();
if (FinalResult == EPropertyDataValidationResult::DataValid && ChildDataResult != EPropertyDataValidationResult::DataValid)
{
FinalResult = ChildDataResult;
}
}
}
return FinalResult;
}
/**
* Sets the flags used by the window and the root node
* @param InFlags - flags to turn on or off
* @param InOnOff - whether to toggle the bits on or off
*/
void FPropertyNode::SetNodeFlags (const EPropertyNodeFlags::Type InFlags, const bool InOnOff)
{
if (InOnOff)
{
PropertyNodeFlags |= InFlags;
}
else
{
PropertyNodeFlags &= (~InFlags);
}
}
bool FPropertyNode::GetChildNode(const int32 ChildArrayIndex, TSharedPtr<FPropertyNode>& OutChildNode)
{
OutChildNode = nullptr;
for (auto Child = ChildNodes.CreateIterator(); Child; ++Child)
{
if (Child->IsValid() && (*Child)->ArrayIndex == ChildArrayIndex)
{
OutChildNode = *Child;
return true;
}
}
return false;
}
bool FPropertyNode::GetChildNode(const int32 ChildArrayIndex, TSharedPtr<FPropertyNode>& OutChildNode) const
{
OutChildNode = nullptr;
for (auto Child = ChildNodes.CreateConstIterator(); Child; ++Child)
{
if (Child->IsValid() && (*Child)->ArrayIndex == ChildArrayIndex)
{
OutChildNode = *Child;
return true;
}
}
return false;
}
TSharedPtr<FPropertyNode> FPropertyNode::FindChildPropertyNode( const FName InPropertyName, bool bRecurse )
{
// Search Children
for(int32 ChildIndex=0; ChildIndex<ChildNodes.Num(); ChildIndex++)
{
TSharedPtr<FPropertyNode>& ChildNode = ChildNodes[ChildIndex];
if( ChildNode->GetProperty() && ChildNode->GetProperty()->GetFName() == InPropertyName )
{
return ChildNode;
}
else if( bRecurse )
{
TSharedPtr<FPropertyNode> PropertyNode = ChildNode->FindChildPropertyNode(InPropertyName, bRecurse );
if( PropertyNode.IsValid() )
{
return PropertyNode;
}
}
}
// Return nullptr if not found...
return nullptr;
}
/** @return whether this window's property is constant (can't be edited by the user) */
bool FPropertyNode::IsEditConst() const
{
if( bUpdateEditConstState )
{
// Ask the objects whether this property can be changed
const FObjectPropertyNode* ObjectPropertyNode = FindObjectItemParent();
bIsEditConst = (HasNodeFlags(EPropertyNodeFlags::IsReadOnly) != 0);
if(!bIsEditConst && Property != nullptr && ObjectPropertyNode)
{
bIsEditConst = (Property->PropertyFlags & CPF_EditConst) ? true : false;
if(!bIsEditConst)
{
// travel up the chain to see if this property's owner struct is editconst - if it is, so is this property
FPropertyNode* NextParent = ParentNode;
while(NextParent != nullptr && Cast<UStructProperty>(NextParent->GetProperty()) != NULL)
{
if(NextParent->IsEditConst())
{
bIsEditConst = true;
break;
}
NextParent = NextParent->ParentNode;
}
}
if(!bIsEditConst)
{
for(TPropObjectConstIterator CurObjectIt(ObjectPropertyNode->ObjectConstIterator()); CurObjectIt; ++CurObjectIt)
{
const TWeakObjectPtr<UObject> CurObject = *CurObjectIt;
if(CurObject.IsValid())
{
if(!CurObject->CanEditChange(Property.Get()))
{
// At least one of the objects didn't like the idea of this property being changed.
bIsEditConst = true;
break;
}
}
}
}
}
bUpdateEditConstState = false;
}
return bIsEditConst;
}
/**
* Appends my path, including an array index (where appropriate)
*/
bool FPropertyNode::GetQualifiedName( FString& PathPlusIndex, const bool bWithArrayIndex, const FPropertyNode* StopParent, bool bIgnoreCategories ) const
{
bool bAddedAnything = false;
if( ParentNodeWeakPtr.IsValid() && StopParent != ParentNode )
{
bAddedAnything = ParentNode->GetQualifiedName(PathPlusIndex, bWithArrayIndex, StopParent, bIgnoreCategories);
if( bAddedAnything )
{
PathPlusIndex += TEXT(".");
}
}
if( Property.IsValid() )
{
bAddedAnything = true;
Property->AppendName(PathPlusIndex);
}
if ( bWithArrayIndex && (ArrayIndex != INDEX_NONE) )
{
bAddedAnything = true;
PathPlusIndex += TEXT("[");
PathPlusIndex.AppendInt(ArrayIndex);
PathPlusIndex += TEXT("]");
}
return bAddedAnything;
}
bool FPropertyNode::GetReadAddressUncached( FPropertyNode& InPropertyNode,
bool InRequiresSingleSelection,
FReadAddressListData* OutAddresses,
bool bComparePropertyContents,
bool bObjectForceCompare,
bool bArrayPropertiesCanDifferInSize ) const
{
if (ParentNodeWeakPtr.IsValid())
{
return ParentNode->GetReadAddressUncached( InPropertyNode, InRequiresSingleSelection, OutAddresses, bComparePropertyContents, bObjectForceCompare, bArrayPropertiesCanDifferInSize );
}
return false;
}
bool FPropertyNode::GetReadAddressUncached( FPropertyNode& InPropertyNode, FReadAddressListData& OutAddresses ) const
{
if (ParentNodeWeakPtr.IsValid())
{
return ParentNode->GetReadAddressUncached( InPropertyNode, OutAddresses );
}
return false;
}
bool FPropertyNode::GetReadAddress(bool InRequiresSingleSelection,
FReadAddressList& OutAddresses,
bool bComparePropertyContents,
bool bObjectForceCompare,
bool bArrayPropertiesCanDifferInSize)
{
// @todo PropertyEditor Nodes which require validation cannot be cached
if( CachedReadAddresses.Num() && !CachedReadAddresses.bRequiresCache && !HasNodeFlags(EPropertyNodeFlags::RequiresValidation) )
{
OutAddresses.ReadAddressListData = &CachedReadAddresses;
return CachedReadAddresses.bAllValuesTheSame;
}
CachedReadAddresses.Reset();
bool bAllValuesTheSame = false;
if (ParentNodeWeakPtr.IsValid())
{
bAllValuesTheSame = GetReadAddressUncached( *this, InRequiresSingleSelection, &CachedReadAddresses, bComparePropertyContents, bObjectForceCompare, bArrayPropertiesCanDifferInSize );
OutAddresses.ReadAddressListData = &CachedReadAddresses;
CachedReadAddresses.bAllValuesTheSame = bAllValuesTheSame;
CachedReadAddresses.bRequiresCache = false;
}
return bAllValuesTheSame;
}
/**
* fills in the OutAddresses array with the addresses of all of the available objects.
* @param InItem The property to get objects from.
* @param OutAddresses Storage array for all of the objects' addresses.
*/
bool FPropertyNode::GetReadAddress( FReadAddressList& OutAddresses )
{
// @todo PropertyEditor Nodes which require validation cannot be cached
if( CachedReadAddresses.Num() && !HasNodeFlags(EPropertyNodeFlags::RequiresValidation) )
{
OutAddresses.ReadAddressListData = &CachedReadAddresses;
return true;
}
CachedReadAddresses.Reset();
bool bSuccess = false;
if (ParentNodeWeakPtr.IsValid())
{
bSuccess = GetReadAddressUncached( *this, CachedReadAddresses );
if( bSuccess )
{
OutAddresses.ReadAddressListData = &CachedReadAddresses;
}
CachedReadAddresses.bRequiresCache = false;
}
return bSuccess;
}
/**
* Calculates the memory address for the data associated with this item's property. This is typically the value of a UProperty or a UObject address.
*
* @param StartAddress the location to use as the starting point for the calculation; typically the address of the object that contains this property.
*
* @return a pointer to a UProperty value or UObject. (For dynamic arrays, you'd cast this value to an FArray*)
*/
uint8* FPropertyNode::GetValueBaseAddress( uint8* StartAddress )
{
uint8* Result = NULL;
if ( ParentNodeWeakPtr.IsValid() )
{
Result = ParentNode->GetValueAddress(StartAddress);
}
return Result;
}
/**
* Calculates the memory address for the data associated with this item's value. For most properties, identical to GetValueBaseAddress. For items corresponding
* to dynamic array elements, the pointer returned will be the location for that element's data.
*
* @param StartAddress the location to use as the starting point for the calculation; typically the address of the object that contains this property.
*
* @return a pointer to a UProperty value or UObject. (For dynamic arrays, you'd cast this value to whatever type is the Inner for the dynamic array)
*/
uint8* FPropertyNode::GetValueAddress( uint8* StartAddress )
{
return GetValueBaseAddress( StartAddress );
}
/*-----------------------------------------------------------------------------
FPropertyItemValueDataTrackerSlate
-----------------------------------------------------------------------------*/
/**
* Calculates and stores the address for both the current and default value of
* the associated property and the owning object.
*/
class FPropertyItemValueDataTrackerSlate
{
public:
/**
* A union which allows a single address to be represented as a pointer to a uint8
* or a pointer to a UObject.
*/
union FPropertyValueRoot
{
UObject* OwnerObject;
uint8* ValueAddress;
};
void Reset(FPropertyNode* InPropertyNode, UObject* InOwnerObject)
{
OwnerObject = InOwnerObject;
PropertyNode = InPropertyNode;
bHasDefaultValue = false;
InnerInitialize();
}
void InnerInitialize()
{
{
PropertyValueRoot.OwnerObject = NULL;
PropertyDefaultValueRoot.OwnerObject = NULL;
PropertyValueAddress = NULL;
PropertyValueBaseAddress = NULL;
PropertyDefaultBaseAddress = NULL;
PropertyDefaultAddress = NULL;
}
PropertyValueRoot.OwnerObject = OwnerObject.Get();
check(PropertyNode);
UProperty* Property = PropertyNode->GetProperty();
check(Property);
check(PropertyValueRoot.OwnerObject);
FPropertyNode* ParentNode = PropertyNode->GetParentNode();
// if the object specified is a class object, transfer to the CDO instead
if ( Cast<UClass>(PropertyValueRoot.OwnerObject) != NULL )
{
PropertyValueRoot.OwnerObject = Cast<UClass>(PropertyValueRoot.OwnerObject)->GetDefaultObject();
}
UArrayProperty* ArrayProp = Cast<UArrayProperty>(Property);
UArrayProperty* OuterArrayProp = Cast<UArrayProperty>(Property->GetOuter());
USetProperty* SetProp = Cast<USetProperty>(Property);
USetProperty* OuterSetProp = Cast<USetProperty>(Property->GetOuter());
UMapProperty* MapProp = Cast<UMapProperty>(Property);
UMapProperty* OuterMapProp = Cast<UMapProperty>(Property->GetOuter());
// calculate the values for the current object
{
PropertyValueBaseAddress = (OuterArrayProp == NULL && OuterSetProp == NULL && OuterMapProp == NULL)
? PropertyNode->GetValueBaseAddress(PropertyValueRoot.ValueAddress)
: ParentNode->GetValueBaseAddress(PropertyValueRoot.ValueAddress);
PropertyValueAddress = PropertyNode->GetValueAddress(PropertyValueRoot.ValueAddress);
}
if( IsValidTracker() )
{
bHasDefaultValue = Private_HasDefaultValue();
// calculate the values for the default object
if ( bHasDefaultValue )
{
PropertyDefaultValueRoot.OwnerObject = PropertyValueRoot.OwnerObject ? PropertyValueRoot.OwnerObject->GetArchetype() : NULL;
PropertyDefaultBaseAddress = (OuterArrayProp == NULL && OuterSetProp == NULL && OuterMapProp == NULL)
? PropertyNode->GetValueBaseAddress(PropertyDefaultValueRoot.ValueAddress)
: ParentNode->GetValueBaseAddress(PropertyDefaultValueRoot.ValueAddress);
PropertyDefaultAddress = PropertyNode->GetValueAddress(PropertyDefaultValueRoot.ValueAddress);
//////////////////////////
// If this is a container property, we must take special measures to use the base address of the property's value; for instance,
// the array property's PropertyDefaultBaseAddress points to an FScriptArray*, while PropertyDefaultAddress points to the
// FScriptArray's Data pointer.
if ( ArrayProp != NULL || SetProp != NULL || MapProp != NULL )
{
PropertyValueAddress = PropertyValueBaseAddress;
PropertyDefaultAddress = PropertyDefaultBaseAddress;
}
}
}
}
/**
* Constructor
*
* @param InPropItem the property window item this struct will hold values for
* @param InOwnerObject the object which contains the property value
*/
FPropertyItemValueDataTrackerSlate( FPropertyNode* InPropertyNode, UObject* InOwnerObject )
: OwnerObject( InOwnerObject )
, PropertyNode(InPropertyNode)
, bHasDefaultValue(false)
{
InnerInitialize();
}
/**
* @return Whether or not this tracker has a valid address to a property and object
*/
bool IsValidTracker() const
{
return PropertyValueBaseAddress != 0 && OwnerObject.IsValid();
}
/**
* @return a pointer to the subobject root (outer-most non-subobject) of the owning object.
*/
UObject* GetTopLevelObject()
{
check(PropertyNode);
FObjectPropertyNode* RootNode = PropertyNode->FindRootObjectItemParent();
check(RootNode);
TArray<UObject*> RootObjects;
for ( TPropObjectIterator Itor( RootNode->ObjectIterator() ) ; Itor ; ++Itor )
{
TWeakObjectPtr<UObject> Object = *Itor;
if( Object.IsValid() )
{
RootObjects.Add(Object.Get());
}
}
UObject* Result;
for ( Result = PropertyValueRoot.OwnerObject; Result; Result = Result->GetOuter() )
{
if ( RootObjects.Contains(Result) )
{
break;
}
}
if( !Result )
{
// The result is not contained in the root so it is the top level object
Result = PropertyValueRoot.OwnerObject;
}
return Result;
}
/**
* Whether or not we have a default value
*/
bool HasDefaultValue() const { return bHasDefaultValue; }
/**
* @return The property node we are inspecting
*/
FPropertyNode* GetPropertyNode() const { return PropertyNode; }
/**
* @return The address of the property's value.
*/
uint8* GetPropertyValueAddress() const { return PropertyValueAddress; }
/**
* @return The base address of the property's default value.
*/
uint8* GetPropertyDefaultBaseAddress() const { return PropertyDefaultBaseAddress; }
/**
* @return The address of the property's default value.
*/
uint8* GetPropertyDefaultAddress() const { return PropertyDefaultAddress; }
/**
* @return The address of the owning object's archetype
*/
FPropertyValueRoot GetPropertyValueRoot() const { return PropertyValueRoot; }
private:
/**
* Determines whether the property bound to this struct exists in the owning object's archetype.
*
* @return true if this property exists in the owning object's archetype; false if the archetype is e.g. a
* CDO for a base class and this property is declared in the owning object's class.
*/
bool Private_HasDefaultValue() const
{
bool bResult = false;
if( IsValidTracker() )
{
check(PropertyValueBaseAddress);
check(PropertyValueRoot.OwnerObject);
UObject* ParentDefault = PropertyValueRoot.OwnerObject->GetArchetype();
check(ParentDefault);
if (PropertyValueRoot.OwnerObject->GetClass() == ParentDefault->GetClass())
{
// if the archetype is of the same class, then we must have a default
bResult = true;
}
else
{
// Find the member property which contains this item's property
FPropertyNode* MemberPropertyNode = PropertyNode;
for ( ;MemberPropertyNode != NULL; MemberPropertyNode = MemberPropertyNode->GetParentNode() )
{
UProperty* MemberProperty = MemberPropertyNode->GetProperty();
if ( MemberProperty != NULL )
{
if ( Cast<UClass>(MemberProperty->GetOuter()) != NULL )
{
break;
}
}
}
if ( MemberPropertyNode != NULL && MemberPropertyNode->GetProperty())
{
// we check to see that this property is in the defaults class
bResult = MemberPropertyNode->GetProperty()->IsInContainer(ParentDefault->GetClass());
}
}
}
return bResult;
}
private:
TWeakObjectPtr<UObject> OwnerObject;
/** The property node we are inspecting */
FPropertyNode* PropertyNode;
/** The address of the owning object */
FPropertyValueRoot PropertyValueRoot;
/**
* The address of the owning object's archetype
*/
FPropertyValueRoot PropertyDefaultValueRoot;
/**
* The address of this property's value.
*/
uint8* PropertyValueAddress;
/**
* The base address of this property's value. i.e. for dynamic arrays, the location of the FScriptArray which
* contains the array property's value
*/
uint8* PropertyValueBaseAddress;
/**
* The base address of this property's default value (see other comments for PropertyValueBaseAddress)
*/
uint8* PropertyDefaultBaseAddress;
/**
* The address of this property's default value.
*/
uint8* PropertyDefaultAddress;
/** Whether or not we have a default value */
bool bHasDefaultValue;
};
/* ==========================================================================================================
FPropertyItemComponentCollector
Given a property and the address for that property's data, searches for references to components and
keeps a list of any that are found.
========================================================================================================== */
/**
* Given a property and the address for that property's data, searches for references to components and keeps a list of any that are found.
*/
struct FPropertyItemComponentCollector
{
/** contains the property to search along with the value address to use */
const FPropertyItemValueDataTrackerSlate& ValueTracker;
/** holds the list of instanced objects found */
TArray<UObject*> Components;
/** Whether or not we have an edit inline new */
bool bContainsEditInlineNew;
/** Constructor */
FPropertyItemComponentCollector( const FPropertyItemValueDataTrackerSlate& InValueTracker )
: ValueTracker(InValueTracker)
, bContainsEditInlineNew( false )
{
check(ValueTracker.GetPropertyNode());
FPropertyNode* PropertyNode = ValueTracker.GetPropertyNode();
check(PropertyNode);
UProperty* Prop = PropertyNode->GetProperty();
if ( PropertyNode->GetArrayIndex() == INDEX_NONE )
{
// either the associated property is not an array property, or it's the header for the property (meaning the entire array)
for ( int32 ArrayIndex = 0; ArrayIndex < Prop->ArrayDim; ArrayIndex++ )
{
ProcessProperty(Prop, ValueTracker.GetPropertyValueAddress() + ArrayIndex * Prop->ElementSize);
}
}
else
{
// single element of either a dynamic or static array
ProcessProperty(Prop, ValueTracker.GetPropertyValueAddress());
}
}
/**
* Routes the processing to the appropriate method depending on the type of property.
*
* @param Property the property to process
* @param PropertyValueAddress the address of the property's value
*/
void ProcessProperty( UProperty* Property, uint8* PropertyValueAddress )
{
if ( Property != NULL )
{
bContainsEditInlineNew |= Property->HasMetaData(TEXT("EditInline")) && ((Property->PropertyFlags & CPF_EditConst) == 0);
if ( ProcessObjectProperty(Cast<UObjectPropertyBase>(Property), PropertyValueAddress) )
{
return;
}
if ( ProcessStructProperty(Cast<UStructProperty>(Property), PropertyValueAddress) )
{
return;
}
if ( ProcessInterfaceProperty(Cast<UInterfaceProperty>(Property), PropertyValueAddress) )
{
return;
}
if ( ProcessDelegateProperty(Cast<UDelegateProperty>(Property), PropertyValueAddress) )
{
return;
}
if ( ProcessMulticastDelegateProperty(Cast<UMulticastDelegateProperty>(Property), PropertyValueAddress) )
{
return;
}
if ( ProcessArrayProperty(Cast<UArrayProperty>(Property), PropertyValueAddress) )
{
return;
}
if ( ProcessSetProperty(Cast<USetProperty>(Property), PropertyValueAddress) )
{
return;
}
if ( ProcessMapProperty(Cast<UMapProperty>(Property), PropertyValueAddress) )
{
return;
}
}
}
private:
/**
* UArrayProperty version - invokes ProcessProperty on the array's Inner member for each element in the array.
*
* @param ArrayProp the property to process
* @param PropertyValueAddress the address of the property's value
*
* @return true if the property was handled by this method
*/
bool ProcessArrayProperty( UArrayProperty* ArrayProp, uint8* PropertyValueAddress )
{
bool bResult = false;
if ( ArrayProp != NULL )
{
FScriptArray* ArrayValuePtr = ArrayProp->GetPropertyValuePtr(PropertyValueAddress);
uint8* ArrayValue = (uint8*)ArrayValuePtr->GetData();
for ( int32 ArrayIndex = 0; ArrayIndex < ArrayValuePtr->Num(); ArrayIndex++ )
{
ProcessProperty(ArrayProp->Inner, ArrayValue + ArrayIndex * ArrayProp->Inner->ElementSize);
}
bResult = true;
}
return bResult;
}
/**
* USetProperty version - invokes ProcessProperty on the each item in the set
*
* @param SetProp the property to process
* @param PropertyValueAddress the address of the property's value
*
* @return true if the property was handled by this method
*/
bool ProcessSetProperty( USetProperty* SetProp, uint8* PropertyValueAddress )
{
bool bResult = false;
if (SetProp != NULL)
{
FScriptSet* SetValuePtr = SetProp->GetPropertyValuePtr(PropertyValueAddress);
FScriptSetLayout SetLayout = SetValuePtr->GetScriptLayout(SetProp->ElementProp->ElementSize, SetProp->ElementProp->GetMinAlignment());
int32 ItemsLeft = SetValuePtr->Num();
for (int32 Index = 0; ItemsLeft > 0; ++Index)
{
if (SetValuePtr->IsValidIndex(Index))
{
--ItemsLeft;
ProcessProperty(SetProp->ElementProp, (uint8*)SetValuePtr->GetData(Index, SetLayout));
}
}
bResult = true;
}
return bResult;
}
/**
* UMapProperty version - invokes ProcessProperty on each item in the map
*
* @param MapProp the property to process
* @param PropertyValueAddress the address of the property's value
*
* @return true if the property was handled by this method
*/
bool ProcessMapProperty( UMapProperty* MapProp, uint8* PropertyValueAddress )
{
bool bResult = false;
if (MapProp != NULL)
{
FScriptMap* MapValuePtr = MapProp->GetPropertyValuePtr(PropertyValueAddress);
FScriptMapLayout MapLayout = MapValuePtr->GetScriptLayout(MapProp->KeyProp->ElementSize, MapProp->KeyProp->GetMinAlignment(), MapProp->ValueProp->ElementSize, MapProp->ValueProp->GetMinAlignment());
int32 ItemsLeft = MapValuePtr->Num();
for (int32 Index = 0; ItemsLeft > 0; ++Index)
{
if (MapValuePtr->IsValidIndex(Index))
{
--ItemsLeft;
uint8* Data = (uint8*)MapValuePtr->GetData(Index, MapLayout);
ProcessProperty(MapProp->KeyProp, MapProp->KeyProp->ContainerPtrToValuePtr<uint8>(Data));
ProcessProperty(MapProp->ValueProp, MapProp->ValueProp->ContainerPtrToValuePtr<uint8>(Data));
}
}
bResult = true;
}
return bResult;
}
/**
* UStructProperty version - invokes ProcessProperty on each property in the struct
*
* @param StructProp the property to process
* @param PropertyValueAddress the address of the property's value
*
* @return true if the property was handled by this method
*/
bool ProcessStructProperty( UStructProperty* StructProp, uint8* PropertyValueAddress )
{
bool bResult = false;
if ( StructProp != NULL )
{
for ( UProperty* Prop = StructProp->Struct->PropertyLink; Prop; Prop = Prop->PropertyLinkNext )
{
for ( int32 ArrayIndex = 0; ArrayIndex < Prop->ArrayDim; ArrayIndex++ )
{
ProcessProperty(Prop, Prop->ContainerPtrToValuePtr<uint8>(PropertyValueAddress, ArrayIndex));
}
}
bResult = true;
}
return bResult;
}
/**
* UObjectProperty version - if the object located at the specified address is instanced, adds the component the list.
*
* @param ObjectProp the property to process
* @param PropertyValueAddress the address of the property's value
*
* @return true if the property was handled by this method
*/
bool ProcessObjectProperty( UObjectPropertyBase* ObjectProp, uint8* PropertyValueAddress )
{
bool bResult = false;
if ( ObjectProp != NULL )
{
UObject* ObjValue = ObjectProp->GetObjectPropertyValue(PropertyValueAddress);
if (ObjectProp->PropertyFlags & CPF_InstancedReference)
{
Components.AddUnique(ObjValue);
}
bResult = true;
}
return bResult;
}
/**
* UInterfaceProperty version - if the FScriptInterface located at the specified address contains a reference to an instance, add the component to the list.
*
* @param InterfaceProp the property to process
* @param PropertyValueAddress the address of the property's value
*
* @return true if the property was handled by this method
*/
bool ProcessInterfaceProperty( UInterfaceProperty* InterfaceProp, uint8* PropertyValueAddress )
{
bool bResult = false;
if ( InterfaceProp != NULL )
{
FScriptInterface* InterfaceValue = InterfaceProp->GetPropertyValuePtr(PropertyValueAddress);
UObject* InterfaceObj = InterfaceValue->GetObject();
if (InterfaceObj && InterfaceObj->IsDefaultSubobject())
{
Components.AddUnique(InterfaceValue->GetObject());
}
bResult = true;
}
return bResult;
}
/**
* UDelegateProperty version - if the FScriptDelegate located at the specified address contains a reference to an instance, add the component to the list.
*
* @param DelegateProp the property to process
* @param PropertyValueAddress the address of the property's value
*
* @return true if the property was handled by this method
*/
bool ProcessDelegateProperty( UDelegateProperty* DelegateProp, uint8* PropertyValueAddress )
{
bool bResult = false;
if ( DelegateProp != NULL )
{
FScriptDelegate* DelegateValue = DelegateProp->GetPropertyValuePtr(PropertyValueAddress);
if (DelegateValue->GetUObject() && DelegateValue->GetUObject()->IsDefaultSubobject())
{
Components.AddUnique(DelegateValue->GetUObject());
}
bResult = true;
}
return bResult;
}
/**
* UMulticastDelegateProperty version - if the FMulticastScriptDelegate located at the specified address contains a reference to an instance, add the component to the list.
*
* @param MulticastDelegateProp the property to process
* @param PropertyValueAddress the address of the property's value
*
* @return true if the property was handled by this method
*/
bool ProcessMulticastDelegateProperty( UMulticastDelegateProperty* MulticastDelegateProp, uint8* PropertyValueAddress )
{
bool bResult = false;
if ( MulticastDelegateProp != NULL )
{
FMulticastScriptDelegate* MulticastDelegateValue = MulticastDelegateProp->GetPropertyValuePtr(PropertyValueAddress);
TArray<UObject*> AllObjects = MulticastDelegateValue->GetAllObjects();
for( TArray<UObject*>::TConstIterator CurObjectIt( AllObjects ); CurObjectIt; ++CurObjectIt )
{
if ((*CurObjectIt)->IsDefaultSubobject())
{
Components.AddUnique((*CurObjectIt));
}
}
bResult = true;
}
return bResult;
}
};
bool FPropertyNode::GetDiffersFromDefaultForObject( FPropertyItemValueDataTrackerSlate& ValueTracker, UProperty* InProperty )
{
check( InProperty );
bool bDiffersFromDefaultForObject = false;
if ( ValueTracker.IsValidTracker() && ValueTracker.HasDefaultValue() && GetParentNode() != NULL )
{
//////////////////////////
// Check the property against its default.
// If the property is an object property, we have to take special measures.
UArrayProperty* OuterArrayProperty = Cast<UArrayProperty>(InProperty->GetOuter());
USetProperty* OuterSetProperty = Cast<USetProperty>(InProperty->GetOuter());
UMapProperty* OuterMapProperty = Cast<UMapProperty>(InProperty->GetOuter());
if ( OuterArrayProperty != NULL )
{
// make sure we're not trying to compare against an element that doesn't exist
if ( ValueTracker.GetPropertyDefaultBaseAddress() != NULL && GetArrayIndex() >= FScriptArrayHelper::Num(ValueTracker.GetPropertyDefaultBaseAddress()) )
{
bDiffersFromDefaultForObject = true;
}
}
else if (OuterSetProperty != NULL)
{
FScriptSetHelper SetHelper(OuterSetProperty, ValueTracker.GetPropertyDefaultBaseAddress());
if ( ValueTracker.GetPropertyDefaultBaseAddress() != NULL && !SetHelper.IsValidIndex(GetArrayIndex()) )
{
bDiffersFromDefaultForObject = true;
}
}
else if (OuterMapProperty != NULL)
{
FScriptMapHelper MapHelper(OuterMapProperty, ValueTracker.GetPropertyDefaultBaseAddress());
if ( ValueTracker.GetPropertyDefaultBaseAddress() != NULL && !MapHelper.IsValidIndex(GetArrayIndex()) )
{
bDiffersFromDefaultForObject = true;
}
}
// The property is a simple field. Compare it against the enclosing object's default for that property.
if ( !bDiffersFromDefaultForObject)
{
uint32 PortFlags = 0;
UObjectPropertyBase* ObjectProperty = Cast<UObjectPropertyBase>(InProperty);
if (InProperty->ContainsInstancedObjectProperty())
{
// Use PPF_DeepCompareInstances for component objects
if (ObjectProperty)
{
PortFlags |= PPF_DeepCompareInstances;
}
// Use PPF_DeltaComparison for instanced objects
else
{
PortFlags |= PPF_DeltaComparison;
}
}
if ( ValueTracker.GetPropertyValueAddress() == NULL || ValueTracker.GetPropertyDefaultAddress() == NULL )
{
// if either are NULL, we had a dynamic array somewhere in our parent chain and the array doesn't
// have enough elements in either the default or the object
bDiffersFromDefaultForObject = true;
}
else if ( GetArrayIndex() == INDEX_NONE && InProperty->ArrayDim > 1 )
{
for ( int32 Idx = 0; !bDiffersFromDefaultForObject && Idx < InProperty->ArrayDim; Idx++ )
{
bDiffersFromDefaultForObject = !InProperty->Identical(
ValueTracker.GetPropertyValueAddress() + Idx * InProperty->ElementSize,
ValueTracker.GetPropertyDefaultAddress() + Idx * InProperty->ElementSize,
PortFlags
);
}
}
else
{
uint8* PropertyValueAddr = ValueTracker.GetPropertyValueAddress();
uint8* DefaultPropertyValueAddr = ValueTracker.GetPropertyDefaultAddress();
if( PropertyValueAddr != NULL && DefaultPropertyValueAddr != NULL )
{
bDiffersFromDefaultForObject = !InProperty->Identical(
PropertyValueAddr,
DefaultPropertyValueAddr,
PortFlags
);
}
}
}
}
return bDiffersFromDefaultForObject;
}
/**
* If there is a property, sees if it matches. Otherwise sees if the entire parent structure matches
*/
bool FPropertyNode::GetDiffersFromDefault()
{
if( bUpdateDiffersFromDefault )
{
bUpdateDiffersFromDefault = false;
bDiffersFromDefault = false;
FObjectPropertyNode* ObjectNode = FindObjectItemParent();
if(ObjectNode && Property.IsValid() && !IsEditConst())
{
// Get an iterator for the enclosing objects.
for(int32 ObjIndex = 0; ObjIndex < ObjectNode->GetNumObjects(); ++ObjIndex)
{
UObject* Object = ObjectNode->GetUObject(ObjIndex);
TSharedPtr<FPropertyItemValueDataTrackerSlate> ValueTracker = GetValueTracker(Object, ObjIndex);
if(ValueTracker.IsValid() && Object && GetDiffersFromDefaultForObject(*ValueTracker, Property.Get()))
{
// If any object being observed differs from the result then there is no need to keep searching
bDiffersFromDefault = true;
break;
}
}
}
}
return bDiffersFromDefault;
}
FString FPropertyNode::GetDefaultValueAsStringForObject( FPropertyItemValueDataTrackerSlate& ValueTracker, UObject* InObject, UProperty* InProperty )
{
check( InObject );
check( InProperty );
bool bDiffersFromDefaultForObject = false;
FString DefaultValue;
// special case for Object class - no defaults to compare against
if ( InObject != UObject::StaticClass() && InObject != UObject::StaticClass()->GetDefaultObject() )
{
if ( ValueTracker.IsValidTracker() && ValueTracker.HasDefaultValue() )
{
//////////////////////////
// Check the property against its default.
// If the property is an object property, we have to take special measures.
UArrayProperty* OuterArrayProperty = Cast<UArrayProperty>(InProperty->GetOuter());
USetProperty* OuterSetProperty = Cast<USetProperty>(InProperty->GetOuter());
UMapProperty* OuterMapProperty = Cast<UMapProperty>(InProperty->GetOuter());
if ( OuterArrayProperty != NULL )
{
// make sure we're not trying to compare against an element that doesn't exist
if ( ValueTracker.GetPropertyDefaultBaseAddress() != NULL && GetArrayIndex() >= FScriptArrayHelper::Num(ValueTracker.GetPropertyDefaultBaseAddress()) )
{
bDiffersFromDefaultForObject = true;
DefaultValue = NSLOCTEXT("PropertyEditor", "ArrayLongerThanDefault", "Array is longer than the default.").ToString();
}
}
// The property is a simple field. Compare it against the enclosing object's default for that property.
if ( !bDiffersFromDefaultForObject)
{
uint32 PortFlags = 0;
UObjectPropertyBase* ObjectProperty = Cast<UObjectPropertyBase>(InProperty);
if (InProperty->ContainsInstancedObjectProperty())
{
// Use PPF_DeepCompareInstances for component objects
if (ObjectProperty)
{
PortFlags |= PPF_DeepCompareInstances;
}
// Use PPF_DeltaComparison for instanced objects
else
{
PortFlags |= PPF_DeltaComparison;
}
}
if ( ValueTracker.GetPropertyValueAddress() == NULL || ValueTracker.GetPropertyDefaultAddress() == NULL )
{
if ( !OuterSetProperty && !OuterMapProperty )
{
// if either are NULL, we had a dynamic array somewhere in our parent chain and the array doesn't
// have enough elements in either the default or the object
DefaultValue = NSLOCTEXT("PropertyEditor", "DifferentArrayLength", "Array has different length than the default.").ToString();
}
}
else if ( GetArrayIndex() == INDEX_NONE && InProperty->ArrayDim > 1 )
{
for ( int32 Idx = 0; !bDiffersFromDefaultForObject && Idx < InProperty->ArrayDim; Idx++ )
{
uint8* DefaultAddress = ValueTracker.GetPropertyDefaultAddress() + Idx * InProperty->ElementSize;
FString DefaultItem;
InProperty->ExportTextItem( DefaultItem, DefaultAddress, DefaultAddress, InObject, PortFlags, NULL );
if ( DefaultValue.Len() > 0 && DefaultItem.Len() > 0 )
{
DefaultValue += TEXT( ", " );
}
DefaultValue += DefaultItem;
}
}
else
{
InProperty->ExportTextItem( DefaultValue, ValueTracker.GetPropertyDefaultAddress(), ValueTracker.GetPropertyDefaultAddress(), InObject, PortFlags, NULL );
UByteProperty* ByteProperty = Cast<UByteProperty>(InProperty);
if ( ByteProperty != NULL && ByteProperty->Enum != NULL )
{
AdjustEnumPropDisplayName(ByteProperty->Enum, DefaultValue);
}
}
}
}
}
return DefaultValue;
}
FString FPropertyNode::GetDefaultValueAsString()
{
FObjectPropertyNode* ObjectNode = FindObjectItemParent();
FString DefaultValue;
if ( ObjectNode && Property.IsValid() )
{
// Get an iterator for the enclosing objects.
for ( int32 ObjIndex = 0; ObjIndex < ObjectNode->GetNumObjects(); ++ObjIndex )
{
UObject* Object = ObjectNode->GetUObject( ObjIndex );
TSharedPtr<FPropertyItemValueDataTrackerSlate> ValueTracker = GetValueTracker(Object, ObjIndex);
if( Object && ValueTracker.IsValid() )
{
FString NodeDefaultValue = GetDefaultValueAsStringForObject( *ValueTracker, Object, Property.Get() );
if ( DefaultValue.Len() > 0 && NodeDefaultValue.Len() > 0)
{
DefaultValue += TEXT(", ");
}
DefaultValue += NodeDefaultValue;
}
}
}
return DefaultValue;
}
FText FPropertyNode::GetResetToDefaultLabel()
{
FString DefaultValue = GetDefaultValueAsString();
FText OutLabel = GetDisplayName();
if ( DefaultValue.Len() )
{
const int32 MaxValueLen = 60;
if ( DefaultValue.Len() > MaxValueLen )
{
DefaultValue = DefaultValue.Left( MaxValueLen );
DefaultValue += TEXT( "..." );
}
return FText::Format(NSLOCTEXT("FPropertyNode", "ResetToDefaultLabelFmt", "{0}: {1}"), OutLabel, FText::FromString(DefaultValue));
}
return OutLabel;
}
void FPropertyNode::ResetToDefault( FNotifyHook* InNotifyHook )
{
UProperty* TheProperty = GetProperty();
check(TheProperty);
// Get an iterator for the enclosing objects.
FObjectPropertyNode* ObjectNode = FindObjectItemParent();
if( ObjectNode )
{
// The property is a simple field. Compare it against the enclosing object's default for that property.
////////////////
FScopedTransaction Transaction( NSLOCTEXT("UnrealEd", "PropertyWindowEditProperties", "Edit Properties") );
// Whether or not we've process prechange already
bool bNotifiedPreChange = false;
// Whether or not an edit inline new was reset as a result of this reset to default
bool bEditInlineNewWasReset = false;
TArray< TMap<FString, int32> > ArrayIndicesPerObject;
for( int32 ObjIndex = 0; ObjIndex < ObjectNode->GetNumObjects(); ++ObjIndex )
{
TWeakObjectPtr<UObject> ObjectWeakPtr = ObjectNode->GetUObject( ObjIndex );
UObject* Object = ObjectWeakPtr.Get();
// special case for UObject class - it has no defaults
if( Object && Object != UObject::StaticClass() && Object != UObject::StaticClass()->GetDefaultObject() )
{
TSharedPtr<FPropertyItemValueDataTrackerSlate> ValueTrackerPtr = GetValueTracker(Object, ObjIndex);
if( ValueTrackerPtr.IsValid() && ValueTrackerPtr->IsValidTracker() && ValueTrackerPtr->HasDefaultValue() )
{
FPropertyItemValueDataTrackerSlate& ValueTracker = *ValueTrackerPtr;
bool bIsGameWorld = false;
// If the object we are modifying is in the PIE world, than make the PIE world the active
// GWorld. Assumes all objects managed by this property window belong to the same world.
UWorld* OldGWorld = NULL;
if ( GUnrealEd && GUnrealEd->PlayWorld && !GUnrealEd->bIsSimulatingInEditor && Object->IsIn(GUnrealEd->PlayWorld))
{
OldGWorld = SetPlayInEditorWorld(GUnrealEd->PlayWorld);
bIsGameWorld = true;
}
FPropertyNode* ParentPropertyNode = GetParentNode();
UProperty* ParentProperty = ParentPropertyNode != nullptr ? ParentPropertyNode->GetProperty() : nullptr;
// If we're about to modify an element in a set, check to ensure that we're not duplicating a default value
if (Cast<USetProperty>(ParentProperty) != nullptr)
{
FScriptSetHelper SetHelper(Cast<USetProperty>(ParentProperty), ParentPropertyNode->GetValueBaseAddress((uint8*)Object));
FDefaultConstructedPropertyElement DefaultElementValue(SetHelper.ElementProp);
int32 ThisElementIndex = SetHelper.FindElementIndex(TheProperty->ContainerPtrToValuePtr<uint8>(ValueTrackerPtr->GetPropertyValueAddress()));
int32 DefaultIndex = SetHelper.FindElementIndex(DefaultElementValue.GetObjAddress());
if (DefaultIndex != INDEX_NONE && ThisElementIndex != DefaultIndex)
{
FNotificationInfo ResetToDefaultErrorInfo = LOCTEXT("SetElementResetToDefault_Duplicate", "Cannot reset the element back to its default value because the default already exists in the set");
ResetToDefaultErrorInfo.ExpireDuration = 3.0f;
FSlateNotificationManager::Get().AddNotification(ResetToDefaultErrorInfo);
return;
}
}
// If we're about to modify a map, ensure that the default key value is not duplicated
if (Cast<UMapProperty>(ParentProperty) != nullptr)
{
if (PropertyKeyNode.IsValid())
{
// This is the value node; it should always be reset to default. The key node should be checked separately.
PropertyKeyNode->ResetToDefault( InNotifyHook );
}
else
{
// Key node, so perform the default check here
FScriptMapHelper MapHelper(Cast<UMapProperty>(ParentProperty), ParentPropertyNode->GetValueBaseAddress((uint8*)Object));
FDefaultConstructedPropertyElement DefaultKeyValue(MapHelper.KeyProp);
uint8* PairPtr = MapHelper.GetPairPtr(ArrayIndex);
int32 ThisKeyIndex = MapHelper.FindMapIndexWithKey(TheProperty->ContainerPtrToValuePtr<uint8>(ValueTrackerPtr->GetPropertyValueAddress()));
int32 DefaultIndex = MapHelper.FindMapIndexWithKey(DefaultKeyValue.GetObjAddress());
if (DefaultIndex != INDEX_NONE && ThisKeyIndex != DefaultIndex)
{
FNotificationInfo ResetToDefaultErrorInfo = LOCTEXT("MapKeyResetToDefault_Duplicate", "Cannot reset the key back to its default value because the default already exists in the map");
ResetToDefaultErrorInfo.ExpireDuration = 3.0f;
FSlateNotificationManager::Get().AddNotification(ResetToDefaultErrorInfo);
return;
}
}
}
if( !bNotifiedPreChange )
{
// Call preedit change on all the objects
NotifyPreChange( GetProperty(), InNotifyHook );
bNotifiedPreChange = true;
}
// Cache the value of the property before modifying it.
FString PreviousValue;
TheProperty->ExportText_Direct(PreviousValue, ValueTracker.GetPropertyValueAddress(), ValueTracker.GetPropertyValueAddress(), NULL, 0);
FString PreviousArrayValue;
if( ValueTracker.GetPropertyDefaultAddress() != NULL )
{
UObject* RootObject = ValueTracker.GetTopLevelObject();
FPropertyItemComponentCollector ComponentCollector(ValueTracker);
// dynamic arrays are the only property type that do not support CopySingleValue correctly due to the fact that they cannot
// be used in a static array
if(Cast<UArrayProperty>(ParentProperty) != nullptr)
{
UArrayProperty* ArrayProp = Cast<UArrayProperty>(ParentProperty);
if(ArrayProp->Inner == TheProperty)
{
uint8* Addr = ParentPropertyNode->GetValueBaseAddress((uint8*)Object);
ArrayProp->ExportText_Direct(PreviousArrayValue, Addr, Addr, NULL, 0);
}
}
UArrayProperty* ArrayProp = Cast<UArrayProperty>(TheProperty);
if( ArrayProp != NULL )
{
TheProperty->CopyCompleteValue(ValueTracker.GetPropertyValueAddress(), ValueTracker.GetPropertyDefaultAddress());
}
else
{
if( GetArrayIndex() == INDEX_NONE && TheProperty->ArrayDim > 1 )
{
TheProperty->CopyCompleteValue(ValueTracker.GetPropertyValueAddress(), ValueTracker.GetPropertyDefaultAddress());
}
else
{
TheProperty->CopySingleValue(ValueTracker.GetPropertyValueAddress(), ValueTracker.GetPropertyDefaultAddress());
}
}
if( ComponentCollector.Components.Num() > 0 )
{
TMap<UObject*,UObject*> ReplaceMap;
FPropertyItemComponentCollector DefaultComponentCollector(ValueTracker);
for ( int32 CompIndex = 0; CompIndex < ComponentCollector.Components.Num(); CompIndex++ )
{
UObject* Component = ComponentCollector.Components[CompIndex];
if (Component != NULL)
{
if ( DefaultComponentCollector.Components.Contains(Component->GetArchetype()) )
{
ReplaceMap.Add(Component, Component->GetArchetype());
}
else if( DefaultComponentCollector.Components.IsValidIndex(CompIndex) )
{
ReplaceMap.Add(Component, DefaultComponentCollector.Components[CompIndex]);
}
}
}
FArchiveReplaceObjectRef<UObject> ReplaceAr(RootObject, ReplaceMap, false, true, true);
FObjectInstancingGraph InstanceGraph(RootObject);
TArray<UObject*> Subobjects;
FReferenceFinder Collector(
Subobjects, // InObjectArray
RootObject, // LimitOuter
false, // bRequireDirectOuter
true, // bIgnoreArchetypes
true, // bSerializeRecursively
false // bShouldIgnoreTransient
);
Collector.FindReferences( RootObject );
for( UObject* SubObj : Subobjects )
{
InstanceGraph.AddNewInstance(SubObj);
}
RootObject->InstanceSubobjectTemplates(&InstanceGraph);
}
bEditInlineNewWasReset = ComponentCollector.bContainsEditInlineNew;
}
else
{
TheProperty->ClearValue(ValueTracker.GetPropertyValueAddress());
}
// Cache the value of the property after having modified it.
FString ValueAfterImport;
Property->ExportText_Direct(ValueAfterImport, ValueTracker.GetPropertyValueAddress(), ValueTracker.GetPropertyValueAddress(), NULL, 0);
if((Object->HasAnyFlags(RF_ClassDefaultObject | RF_ArchetypeObject) ||
(Object->HasAnyFlags(RF_DefaultSubObject) && Object->GetOuter()->HasAnyFlags(RF_ClassDefaultObject | RF_ArchetypeObject))) &&
!bIsGameWorld)
{
PropagatePropertyChange(Object, *ValueAfterImport, PreviousArrayValue.IsEmpty() ? PreviousValue : PreviousArrayValue);
}
if(OldGWorld)
{
// restore the original (editor) GWorld
RestoreEditorWorld( OldGWorld );
}
ArrayIndicesPerObject.Add(TMap<FString, int32>());
FPropertyValueImpl::GenerateArrayIndexMapToObjectNode(ArrayIndicesPerObject[ObjIndex], this);
}
}
}
if( bNotifiedPreChange )
{
// Call PostEditchange on all the objects
// Assume reset to default, can change topology
FPropertyChangedEvent ChangeEvent( TheProperty, EPropertyChangeType::ValueSet );
ChangeEvent.SetArrayIndexPerObject(ArrayIndicesPerObject);
NotifyPostChange( ChangeEvent, InNotifyHook );
}
if( bEditInlineNewWasReset )
{
RequestRebuildChildren();
}
}
}
/**
* Helper function to obtain the display name for an enum property
* @param InEnum The enum whose metadata to pull from
* @param DisplayName The name of the enum value to adjust
*
* @return true if the DisplayName has been changed
*/
bool FPropertyNode::AdjustEnumPropDisplayName( UEnum *InEnum, FString& DisplayName ) const
{
// see if we have alternate text to use for displaying the value
UMetaData* PackageMetaData = InEnum->GetOutermost()->GetMetaData();
if ( PackageMetaData )
{
FName AltDisplayName = FName(*(DisplayName+TEXT(".DisplayName")));
FString ValueText = PackageMetaData->GetValue(InEnum, AltDisplayName);
if ( ValueText.Len() > 0 )
{
// use the alternate text for this enum value
DisplayName = ValueText;
return true;
}
}
//DisplayName has been unmodified
return false;
}
/**Walks up the hierachy and return true if any parent node is a favorite*/
bool FPropertyNode::IsChildOfFavorite (void) const
{
for (const FPropertyNode* TestParentNode = GetParentNode(); TestParentNode != NULL; TestParentNode = TestParentNode->GetParentNode())
{
if (TestParentNode->HasNodeFlags(EPropertyNodeFlags::IsFavorite))
{
return true;
}
}
return false;
}
/**
* Destroys all node within the hierarchy
*/
void FPropertyNode::DestroyTree(const bool bInDestroySelf)
{
ChildNodes.Empty();
}
/**
* Marks windows as visible based on the filter strings (EVEN IF normally NOT EXPANDED)
*/
void FPropertyNode::FilterNodes( const TArray<FString>& InFilterStrings, const bool bParentSeenDueToFiltering )
{
//clear flags first. Default to hidden
SetNodeFlags(EPropertyNodeFlags::IsSeenDueToFiltering | EPropertyNodeFlags::IsSeenDueToChildFiltering | EPropertyNodeFlags::IsParentSeenDueToFiltering, false);
SetNodeFlags(EPropertyNodeFlags::IsBeingFiltered, InFilterStrings.Num() > 0 );
//FObjectPropertyNode* ParentPropertyNode = FindObjectItemParent();
//@todo slate property window
bool bMultiObjectOnlyShowDiffering = false;/*TopPropertyWindow->HasFlags(EPropertyWindowFlags::ShowOnlyDifferingItems) && (ParentPropertyNode->GetNumObjects()>1)*/;
if (InFilterStrings.Num() > 0 /*|| (TopPropertyWindow->HasFlags(EPropertyWindowFlags::ShowOnlyModifiedItems)*/ || bMultiObjectOnlyShowDiffering)
{
//if filtering, default to NOT-seen
bool bPassedFilter = false; //assuming that we aren't filtered
//see if this is a filter-able primitive
FText DisplayName = GetDisplayName();
const FString& DisplayNameStr = DisplayName.ToString();
TArray <FString> AcceptableNames;
AcceptableNames.Add(DisplayNameStr);
//get the basic name as well of the property
UProperty* TheProperty = GetProperty();
if (TheProperty && (TheProperty->GetName() != DisplayNameStr))
{
AcceptableNames.Add(TheProperty->GetName());
}
bPassedFilter = IsFilterAcceptable(AcceptableNames, InFilterStrings);
if (bPassedFilter)
{
SetNodeFlags(EPropertyNodeFlags::IsSeenDueToFiltering, true);
}
SetNodeFlags(EPropertyNodeFlags::IsParentSeenDueToFiltering, bParentSeenDueToFiltering);
}
else
{
//indicating that this node should not be force displayed, but opened normally
SetNodeFlags(EPropertyNodeFlags::IsParentSeenDueToFiltering, true);
}
//default to doing only one pass
//bool bCategoryOrObject = (GetObjectNode()) || (GetCategoryNode()!=NULL);
int32 StartRecusionPass = HasNodeFlags(EPropertyNodeFlags::IsSeenDueToFiltering) ? 1 : 0;
//Pass 1, if a pass 1 exists (object or category), is to see if there are any children that pass the filter, if any do, trim the tree to the leaves.
// This will stop categories from showing ALL properties if they pass the filter AND a child passes the filter
//Pass 0, if no child exists that passes the filter OR this node didn't pass the filter
for (int32 RecursionPass = StartRecusionPass; RecursionPass >= 0; --RecursionPass)
{
for (int32 scan = 0; scan < ChildNodes.Num(); ++scan)
{
TSharedPtr<FPropertyNode>& ScanNode = ChildNodes[scan];
check(ScanNode.IsValid());
//default to telling the children this node is NOT visible, therefore if not in the base pass, only filtered nodes will survive the filtering process.
bool bChildParamParentVisible = false;
//if we're at the base pass, tell the children the truth about visibility
if (RecursionPass == 0)
{
bChildParamParentVisible = bParentSeenDueToFiltering || HasNodeFlags(EPropertyNodeFlags::IsSeenDueToFiltering);
}
ScanNode->FilterNodes(InFilterStrings, bChildParamParentVisible);
if (ScanNode->HasNodeFlags(EPropertyNodeFlags::IsSeenDueToFiltering | EPropertyNodeFlags::IsSeenDueToChildFiltering))
{
SetNodeFlags(EPropertyNodeFlags::IsSeenDueToChildFiltering, true);
}
}
//now that we've tried a pass at our children, if any of them have been successfully seen due to filtering, just quit now
if (HasNodeFlags(EPropertyNodeFlags::IsSeenDueToChildFiltering))
{
break;
}
}
}
void FPropertyNode::ProcessSeenFlags(const bool bParentAllowsVisible )
{
// Set initial state first
SetNodeFlags(EPropertyNodeFlags::IsSeen, false);
SetNodeFlags(EPropertyNodeFlags::IsSeenDueToChildFavorite, false );
bool bAllowChildrenVisible;
if ( AsObjectNode() )
{
bAllowChildrenVisible = true;
}
else
{
//can't show children unless they are seen due to child filtering
bAllowChildrenVisible = !!HasNodeFlags(EPropertyNodeFlags::IsSeenDueToChildFiltering);
}
//process children
for (int32 scan = 0; scan < ChildNodes.Num(); ++scan)
{
TSharedPtr<FPropertyNode>& ScanNode = ChildNodes[scan];
check(ScanNode.IsValid());
ScanNode->ProcessSeenFlags(bParentAllowsVisible && bAllowChildrenVisible ); //both parent AND myself have to allow children
}
if (HasNodeFlags(EPropertyNodeFlags::IsSeenDueToFiltering | EPropertyNodeFlags::IsSeenDueToChildFiltering))
{
SetNodeFlags(EPropertyNodeFlags::IsSeen, true);
}
else
{
//Finally, apply the REAL IsSeen
SetNodeFlags(EPropertyNodeFlags::IsSeen, bParentAllowsVisible && HasNodeFlags(EPropertyNodeFlags::IsParentSeenDueToFiltering));
}
}
/**
* Marks windows as visible based their favorites status
*/
void FPropertyNode::ProcessSeenFlagsForFavorites(void)
{
if( !HasNodeFlags(EPropertyNodeFlags::IsFavorite) )
{
bool bAnyChildFavorites = false;
//process children
for (int32 scan = 0; scan < ChildNodes.Num(); ++scan)
{
TSharedPtr<FPropertyNode>& ScanNode = ChildNodes[scan];
check(ScanNode.IsValid());
ScanNode->ProcessSeenFlagsForFavorites();
bAnyChildFavorites = bAnyChildFavorites || ScanNode->HasNodeFlags(EPropertyNodeFlags::IsFavorite | EPropertyNodeFlags::IsSeenDueToChildFavorite);
}
if (bAnyChildFavorites)
{
SetNodeFlags(EPropertyNodeFlags::IsSeenDueToChildFavorite, true);
}
}
}
void FPropertyNode::NotifyPreChange( UProperty* PropertyAboutToChange, FNotifyHook* InNotifyHook )
{
TSharedRef<FEditPropertyChain> PropertyChain = BuildPropertyChain( PropertyAboutToChange );
// Call through to the property window's notify hook.
if( InNotifyHook )
{
if ( PropertyChain->Num() == 0 )
{
InNotifyHook->NotifyPreChange( PropertyAboutToChange );
}
else
{
InNotifyHook->NotifyPreChange( &PropertyChain.Get() );
}
}
FObjectPropertyNode* ObjectNode = FindObjectItemParent();
if( ObjectNode )
{
UProperty* CurProperty = PropertyAboutToChange;
// Call PreEditChange on the object chain.
while ( true )
{
for( TPropObjectIterator Itor( ObjectNode->ObjectIterator() ) ; Itor ; ++Itor )
{
UObject* Object = Itor->Get();
if ( ensure( Object ) && PropertyChain->Num() == 0 )
{
Object->PreEditChange( Property.Get() );
}
else if( ensure( Object ) )
{
Object->PreEditChange( *PropertyChain );
}
}
// Pass this property to the parent's PreEditChange call.
CurProperty = ObjectNode->GetStoredProperty();
FObjectPropertyNode* PreviousObjectNode = ObjectNode;
// Traverse up a level in the nested object tree.
ObjectNode = NotifyFindObjectItemParent( ObjectNode );
if ( !ObjectNode )
{
// We've hit the root -- break.
break;
}
else if ( PropertyChain->Num() > 0 )
{
PropertyChain->SetActivePropertyNode( CurProperty->GetOwnerProperty() );
for ( FPropertyNode* BaseItem = PreviousObjectNode; BaseItem && BaseItem != ObjectNode; BaseItem = BaseItem->GetParentNode())
{
UProperty* ItemProperty = BaseItem->GetProperty();
if ( ItemProperty == NULL )
{
// if this property item doesn't have a Property, skip it...it may be a category item or the virtual
// item used as the root for an inline object
continue;
}
// skip over property window items that correspond to a single element in a static array, or
// the inner property of another UProperty (e.g. UArrayProperty->Inner)
if ( BaseItem->ArrayIndex == INDEX_NONE && ItemProperty->GetOwnerProperty() == ItemProperty )
{
PropertyChain->SetActiveMemberPropertyNode(ItemProperty);
}
}
}
}
}
}
void FPropertyNode::NotifyPostChange( FPropertyChangedEvent& InPropertyChangedEvent, class FNotifyHook* InNotifyHook )
{
TSharedRef<FEditPropertyChain> PropertyChain = BuildPropertyChain( InPropertyChangedEvent.Property );
// remember the property that was the chain's original active property; this will correspond to the outermost property of struct/array that was modified
UProperty* const OriginalActiveProperty = PropertyChain->GetActiveMemberNode()->GetValue();
FObjectPropertyNode* ObjectNode = FindObjectItemParent();
if( ObjectNode )
{
ObjectNode->InvalidateCachedState();
UProperty* CurProperty = InPropertyChangedEvent.Property;
// Fire ULevel::LevelDirtiedEvent when falling out of scope.
FScopedLevelDirtied LevelDirtyCallback;
// Call PostEditChange on the object chain.
while ( true )
{
int32 CurrentObjectIndex = 0;
for( TPropObjectIterator Itor( ObjectNode->ObjectIterator() ) ; Itor ; ++Itor )
{
UObject* Object = Itor->Get();
if ( PropertyChain->Num() == 0 )
{
//copy
FPropertyChangedEvent ChangedEvent = InPropertyChangedEvent;
if (CurProperty != InPropertyChangedEvent.Property)
{
//parent object node property. Reset other internals and leave the event type as unspecified
ChangedEvent = FPropertyChangedEvent(CurProperty, InPropertyChangedEvent.ChangeType);
}
ChangedEvent.ObjectIteratorIndex = CurrentObjectIndex;
if( Object )
{
Object->PostEditChangeProperty( ChangedEvent );
}
}
else
{
FPropertyChangedEvent ChangedEvent = InPropertyChangedEvent;
if (CurProperty != InPropertyChangedEvent.Property)
{
//parent object node property. Reset other internals and leave the event type as unspecified
ChangedEvent = FPropertyChangedEvent(CurProperty, InPropertyChangedEvent.ChangeType);
}
FPropertyChangedChainEvent ChainEvent(*PropertyChain, ChangedEvent);
ChainEvent.ObjectIteratorIndex = CurrentObjectIndex;
if( Object )
{
Object->PostEditChangeChainProperty(ChainEvent);
}
}
LevelDirtyCallback.Request();
++CurrentObjectIndex;
}
// Pass this property to the parent's PostEditChange call.
CurProperty = ObjectNode->GetStoredProperty();
FObjectPropertyNode* PreviousObjectNode = ObjectNode;
// Traverse up a level in the nested object tree.
ObjectNode = NotifyFindObjectItemParent( ObjectNode );
if ( !ObjectNode )
{
// We've hit the root -- break.
break;
}
else if ( PropertyChain->Num() > 0 )
{
PropertyChain->SetActivePropertyNode(CurProperty->GetOwnerProperty());
for ( FPropertyNode* BaseItem = PreviousObjectNode; BaseItem && BaseItem != ObjectNode; BaseItem = BaseItem->GetParentNode())
{
UProperty* ItemProperty = BaseItem->GetProperty();
if ( ItemProperty == NULL )
{
// if this property item doesn't have a Property, skip it...it may be a category item or the virtual
// item used as the root for an inline object
continue;
}
// skip over property window items that correspond to a single element in a static array, or
// the inner property of another UProperty (e.g. UArrayProperty->Inner)
if ( BaseItem->GetArrayIndex() == INDEX_NONE && ItemProperty->GetOwnerProperty() == ItemProperty )
{
PropertyChain->SetActiveMemberPropertyNode(ItemProperty);
}
}
}
}
}
// Broadcast the change to any listeners
BroadcastPropertyChangedDelegates();
// Call through to the property window's notify hook.
if( InNotifyHook )
{
if ( PropertyChain->Num() == 0 )
{
InNotifyHook->NotifyPostChange( InPropertyChangedEvent, InPropertyChangedEvent.Property );
}
else
{
PropertyChain->SetActiveMemberPropertyNode( OriginalActiveProperty );
PropertyChain->SetActivePropertyNode( InPropertyChangedEvent.Property);
InNotifyHook->NotifyPostChange( InPropertyChangedEvent, &PropertyChain.Get() );
}
}
if( ObjectNode && OriginalActiveProperty )
{
//if i have metadata forcing other property windows to rebuild
FString MetaData = OriginalActiveProperty->GetMetaData(TEXT("ForceRebuildProperty"));
if( MetaData.Len() > 0 )
{
// We need to find the property node beginning at the root/parent, not at our own node.
ObjectNode = FindObjectItemParent();
check(ObjectNode != NULL);
TSharedPtr<FPropertyNode> ForceRebuildNode = ObjectNode->FindChildPropertyNode( FName(*MetaData), true );
if( ForceRebuildNode.IsValid() )
{
ForceRebuildNode->RequestRebuildChildren();
}
}
}
// The value has changed so the cached value could be invalid
// Need to recurse here as we might be editing a struct with child properties that need re-caching
ClearCachedReadAddresses(true);
// Redraw viewports
FEditorSupportDelegates::RedrawAllViewports.Broadcast();
}
void FPropertyNode::BroadcastPropertyChangedDelegates()
{
PropertyValueChangedEvent.Broadcast();
// Walk through the parents and broadcast
FPropertyNode* LocalParentNode = GetParentNode();
while( LocalParentNode )
{
if( LocalParentNode->OnChildPropertyValueChanged().IsBound() )
{
LocalParentNode->OnChildPropertyValueChanged().Broadcast();
}
LocalParentNode = LocalParentNode->GetParentNode();
}
}
void FPropertyNode::SetOnRebuildChildren( FSimpleDelegate InOnRebuildChildren )
{
OnRebuildChildren = InOnRebuildChildren;
}
TSharedPtr< FPropertyItemValueDataTrackerSlate > FPropertyNode::GetValueTracker( UObject* Object, uint32 ObjIndex )
{
ensure( AsItemPropertyNode() );
TSharedPtr< FPropertyItemValueDataTrackerSlate > RetVal;
if( Object && Object != UObject::StaticClass() && Object != UObject::StaticClass()->GetDefaultObject() )
{
if( !ObjectDefaultValueTrackers.IsValidIndex(ObjIndex) )
{
uint32 NumToAdd = (ObjIndex - ObjectDefaultValueTrackers.Num()) + 1;
while( NumToAdd > 0 )
{
ObjectDefaultValueTrackers.Add( TSharedPtr<FPropertyItemValueDataTrackerSlate> () );
--NumToAdd;
}
}
TSharedPtr<FPropertyItemValueDataTrackerSlate>& ValueTracker = ObjectDefaultValueTrackers[ObjIndex];
if( !ValueTracker.IsValid() )
{
ValueTracker = MakeShareable( new FPropertyItemValueDataTrackerSlate( this, Object ) );
}
else
{
ValueTracker->Reset(this, Object);
}
RetVal = ValueTracker;
}
return RetVal;
}
TSharedRef<FEditPropertyChain> FPropertyNode::BuildPropertyChain( UProperty* InProperty )
{
TSharedRef<FEditPropertyChain> PropertyChain( MakeShareable( new FEditPropertyChain ) );
FPropertyNode* ItemNode = this;
FComplexPropertyNode* ComplexNode = FindComplexParent();
UProperty* MemberProperty = InProperty;
do
{
if (ItemNode == ComplexNode)
{
MemberProperty = PropertyChain->GetHead()->GetValue();
}
UProperty* TheProperty = ItemNode->GetProperty();
if ( TheProperty )
{
// Skip over property window items that correspond to a single element in a static array,
// or the inner property of another UProperty (e.g. UArrayProperty->Inner).
if ( ItemNode->GetArrayIndex() == INDEX_NONE && TheProperty->GetOwnerProperty() == TheProperty )
{
PropertyChain->AddHead( TheProperty );
}
}
ItemNode = ItemNode->GetParentNode();
}
while( ItemNode != NULL );
// If the modified property was a property of the object at the root of this property window, the member property will not have been set correctly
if (ItemNode == ComplexNode)
{
MemberProperty = PropertyChain->GetHead()->GetValue();
}
PropertyChain->SetActivePropertyNode( InProperty );
PropertyChain->SetActiveMemberPropertyNode( MemberProperty );
return PropertyChain;
}
FPropertyChangedEvent& FPropertyNode::FixPropertiesInEvent(FPropertyChangedEvent& Event)
{
ensure(Event.Property);
auto PropertyChain = BuildPropertyChain(Event.Property);
auto MemberProperty = PropertyChain->GetActiveMemberNode() ? PropertyChain->GetActiveMemberNode()->GetValue() : NULL;
if (ensure(MemberProperty))
{
Event.SetActiveMemberProperty(MemberProperty);
}
return Event;
}
void FPropertyNode::SetInstanceMetaData(const FName& Key, const FString& Value)
{
InstanceMetaData.Add(Key, Value);
}
const FString* FPropertyNode::GetInstanceMetaData(const FName& Key) const
{
return InstanceMetaData.Find(Key);
}
bool FPropertyNode::ParentOrSelfHasMetaData(const FName& MetaDataKey) const
{
return (Property.IsValid() && Property->HasMetaData(MetaDataKey)) || (ParentNode && ParentNode->ParentOrSelfHasMetaData(MetaDataKey));
}
void FPropertyNode::InvalidateCachedState()
{
bUpdateDiffersFromDefault = true;
bUpdateEditConstState = true;
for( TSharedPtr<FPropertyNode>& ChildNode : ChildNodes )
{
ChildNode->InvalidateCachedState();
}
}
/**
* Does the string compares to ensure this Name is acceptable to the filter that is passed in
* @return Return True if this property should be displayed. False if it should be culled
*/
bool FPropertyNode::IsFilterAcceptable(const TArray<FString>& InAcceptableNames, const TArray<FString>& InFilterStrings)
{
bool bCompleteMatchFound = true;
if (InFilterStrings.Num())
{
//we have to make sure one name matches all criteria
for (int32 TestNameIndex = 0; TestNameIndex < InAcceptableNames.Num(); ++TestNameIndex)
{
bCompleteMatchFound = true;
FString TestName = InAcceptableNames[TestNameIndex];
for (int32 scan = 0; scan < InFilterStrings.Num(); scan++)
{
if (!TestName.Contains(InFilterStrings[scan]))
{
bCompleteMatchFound = false;
break;
}
}
if (bCompleteMatchFound)
{
break;
}
}
}
return bCompleteMatchFound;
}
void FPropertyNode::AdditionalInitializationUDS(UProperty* Property, uint8* RawPtr)
{
if (const UStructProperty* StructProperty = Cast<const UStructProperty>(Property))
{
if (!FStructureEditorUtils::Fill_MakeStructureDefaultValue(Cast<const UUserDefinedStruct>(StructProperty->Struct), RawPtr))
{
UE_LOG(LogPropertyNode, Warning, TEXT("MakeStructureDefaultValue parsing error. Property: %s "), *StructProperty->GetPathName());
}
}
}
void FPropertyNode::PropagateContainerPropertyChange( UObject* ModifiedObject, const FString& OriginalContainerContent, EPropertyArrayChangeType::Type ChangeType, int32 Index )
{
UProperty* NodeProperty = GetProperty();
UArrayProperty* ArrayProperty = NULL;
USetProperty* SetProperty = NULL;
UMapProperty* MapProperty = NULL;
FPropertyNode* ParentPropertyNode = GetParentNode();
UProperty* ConvertedProperty = NULL;
if (ChangeType == EPropertyArrayChangeType::Add || ChangeType == EPropertyArrayChangeType::Clear)
{
ConvertedProperty = NodeProperty;
}
else
{
ConvertedProperty = Cast<UProperty>(NodeProperty->GetOuter());
}
ArrayProperty = Cast<UArrayProperty>(ConvertedProperty);
SetProperty = Cast<USetProperty>(ConvertedProperty);
MapProperty = Cast<UMapProperty>(ConvertedProperty);
check(ArrayProperty || SetProperty || MapProperty);
TArray<UObject*> ArchetypeInstances, ObjectsToChange;
FPropertyNode* SubobjectPropertyNode = NULL;
UObject* Object = ModifiedObject;
if (Object->HasAnyFlags(RF_ClassDefaultObject|RF_ArchetypeObject))
{
// Object is a default suobject, collect all instances.
Object->GetArchetypeInstances(ArchetypeInstances);
}
else if (Object->HasAnyFlags(RF_DefaultSubObject) && Object->GetOuter()->HasAnyFlags(RF_ClassDefaultObject|RF_ArchetypeObject))
{
// Object is a default subobject of a default object. Get the subobject property node and use its owner instead.
for (SubobjectPropertyNode = FindObjectItemParent(); SubobjectPropertyNode && !SubobjectPropertyNode->GetProperty(); SubobjectPropertyNode = SubobjectPropertyNode->GetParentNode());
if (SubobjectPropertyNode != NULL)
{
// Switch the object to the owner default object and collect its instances.
Object = Object->GetOuter();
Object->GetArchetypeInstances(ArchetypeInstances);
}
}
ObjectsToChange.Push(Object);
while (ObjectsToChange.Num() > 0)
{
check(ObjectsToChange.Num() > 0);
// Pop the first object to change
UObject* ObjToChange = ObjectsToChange[0];
UObject* ActualObjToChange = NULL;
ObjectsToChange.RemoveAt(0);
if (SubobjectPropertyNode)
{
// If the original object is a subobject, get the current object's subobject too.
// In this case we're not going to modify ObjToChange but its default subobject.
ActualObjToChange = *(UObject**)SubobjectPropertyNode->GetValueBaseAddress((uint8*)ObjToChange);
}
else
{
ActualObjToChange = ObjToChange;
}
if (ActualObjToChange != ModifiedObject)
{
uint8* Addr = NULL;
if (ChangeType == EPropertyArrayChangeType::Add || ChangeType == EPropertyArrayChangeType::Clear)
{
Addr = GetValueBaseAddress((uint8*)ActualObjToChange);
}
else
{
Addr = ParentPropertyNode->GetValueBaseAddress((uint8*)ActualObjToChange);
}
FString OriginalContent;
ConvertedProperty->ExportText_Direct(OriginalContent, Addr, Addr, NULL, PPF_Localized);
bool bIsDefaultContainerContent = OriginalContent == OriginalContainerContent;
if (Addr != NULL && ArrayProperty)
{
FScriptArrayHelper ArrayHelper(ArrayProperty, Addr);
// Check if the original value was the default value and change it only then
if (bIsDefaultContainerContent)
{
int32 ElementToInitialize = -1;
switch (ChangeType)
{
case EPropertyArrayChangeType::Add:
ElementToInitialize = ArrayHelper.AddValue();
break;
case EPropertyArrayChangeType::Clear:
ArrayHelper.EmptyValues();
break;
case EPropertyArrayChangeType::Insert:
ArrayHelper.InsertValues(ArrayIndex, 1);
ElementToInitialize = ArrayIndex;
break;
case EPropertyArrayChangeType::Delete:
ArrayHelper.RemoveValues(ArrayIndex, 1);
break;
case EPropertyArrayChangeType::Duplicate:
ArrayHelper.InsertValues(ArrayIndex, 1);
// Copy the selected item's value to the new item.
NodeProperty->CopyCompleteValue(ArrayHelper.GetRawPtr(ArrayIndex), ArrayHelper.GetRawPtr(ArrayIndex + 1));
Object->InstanceSubobjectTemplates();
break;
}
if (ElementToInitialize >= 0)
{
AdditionalInitializationUDS(ArrayProperty->Inner, ArrayHelper.GetRawPtr(ElementToInitialize));
}
}
} // End Array
else if ( Addr != NULL && SetProperty )
{
FScriptSetHelper SetHelper(SetProperty, Addr);
// Check if the original value was the default value and change it only then
if (bIsDefaultContainerContent)
{
int32 ElementToInitialize = -1;
switch (ChangeType)
{
case EPropertyArrayChangeType::Add:
ElementToInitialize = SetHelper.AddDefaultValue_Invalid_NeedsRehash();
SetHelper.Rehash();
break;
case EPropertyArrayChangeType::Clear:
SetHelper.EmptyElements();
break;
case EPropertyArrayChangeType::Insert:
check(false); // Insert is not supported for sets
break;
case EPropertyArrayChangeType::Delete:
SetHelper.RemoveAt_NeedsRehash(ArrayIndex);
SetHelper.Rehash();
break;
case EPropertyArrayChangeType::Duplicate:
check(false); // Duplicate not supported on sets
break;
}
if (ElementToInitialize >= 0)
{
AdditionalInitializationUDS(SetProperty->ElementProp, SetHelper.GetElementPtr(ElementToInitialize));
}
}
} // End Set
else if (Addr != NULL && MapProperty)
{
FScriptMapHelper MapHelper(MapProperty, Addr);
// Check if the original value was the default value and change it only then
if (bIsDefaultContainerContent)
{
int32 ElementToInitialize = -1;
switch (ChangeType)
{
case EPropertyArrayChangeType::Add:
ElementToInitialize = MapHelper.AddDefaultValue_Invalid_NeedsRehash();
MapHelper.Rehash();
break;
case EPropertyArrayChangeType::Clear:
MapHelper.EmptyValues();
break;
case EPropertyArrayChangeType::Insert:
check(false); // Insert is not supported for maps
break;
case EPropertyArrayChangeType::Delete:
MapHelper.RemoveAt_NeedsRehash(ArrayIndex);
MapHelper.Rehash();
break;
case EPropertyArrayChangeType::Duplicate:
check(false); // Duplicate is not supported for maps
break;
}
if (ElementToInitialize >= 0)
{
uint8* PairPtr = MapHelper.GetPairPtr(ElementToInitialize);
AdditionalInitializationUDS(MapProperty->KeyProp, MapProperty->KeyProp->ContainerPtrToValuePtr<uint8>(PairPtr));
AdditionalInitializationUDS(MapProperty->ValueProp, MapProperty->ValueProp->ContainerPtrToValuePtr<uint8>(PairPtr));
}
}
} // End Map
}
for (int32 i=0; i < ArchetypeInstances.Num(); ++i)
{
UObject* Obj = ArchetypeInstances[i];
if (Obj->GetArchetype() == ObjToChange)
{
ObjectsToChange.Push(Obj);
ArchetypeInstances.RemoveAt(i--);
}
}
}
}
void FPropertyNode::PropagatePropertyChange( UObject* ModifiedObject, const TCHAR* NewValue, const FString& PreviousValue )
{
TArray<UObject*> ArchetypeInstances, ObjectsToChange;
FPropertyNode* SubobjectPropertyNode = NULL;
UObject* Object = ModifiedObject;
if (Object->HasAnyFlags(RF_ClassDefaultObject|RF_ArchetypeObject))
{
// Object is a default subobject, collect all instances.
Object->GetArchetypeInstances(ArchetypeInstances);
}
else if (Object->HasAnyFlags(RF_DefaultSubObject) && Object->GetOuter()->HasAnyFlags(RF_ClassDefaultObject|RF_ArchetypeObject))
{
// Object is a default subobject of a default object. Get the subobject property node and use its owner instead.
for (SubobjectPropertyNode = FindObjectItemParent(); SubobjectPropertyNode && !SubobjectPropertyNode->GetProperty(); SubobjectPropertyNode = SubobjectPropertyNode->GetParentNode());
if (SubobjectPropertyNode != NULL)
{
// Switch the object to the owner default object and collect its instances.
Object = Object->GetOuter();
Object->GetArchetypeInstances(ArchetypeInstances);
}
}
static FName FNAME_EditableWhenInherited = GET_MEMBER_NAME_CHECKED(UActorComponent,bEditableWhenInherited);
if (GetProperty()->GetFName() == FNAME_EditableWhenInherited && ModifiedObject->IsA<UActorComponent>() && FString(TEXT("False")) == NewValue)
{
FBlueprintEditorUtils::HandleDisableEditableWhenInherited(ModifiedObject, ArchetypeInstances);
}
FPropertyNode* Parent = GetParentNode();
UProperty* ParentProp = Parent->GetProperty();
UArrayProperty* ParentArrayProp = Cast<UArrayProperty>(ParentProp);
UProperty* Prop = GetProperty();
UMapProperty* MapProp = Cast<UMapProperty>(Prop);
USetProperty* SetProp = Cast<USetProperty>(Prop);
if (ParentArrayProp != nullptr && ParentArrayProp->Inner != Prop)
{
ParentArrayProp = nullptr;
}
ObjectsToChange.Push(Object);
while (ObjectsToChange.Num() > 0)
{
check(ObjectsToChange.Num() > 0);
// Pop the first object to change
UObject* ObjToChange = ObjectsToChange[0];
UObject* ActualObjToChange = NULL;
ObjectsToChange.RemoveAt(0);
if (SubobjectPropertyNode)
{
// If the original object is a subobject, get the current object's subobject too.
// In this case we're not going to modify ObjToChange but its default subobject.
ActualObjToChange = *(UObject**)SubobjectPropertyNode->GetValueBaseAddress((uint8*)ObjToChange);
}
else
{
ActualObjToChange = ObjToChange;
}
if (ActualObjToChange != ModifiedObject)
{
FString OrgValue;
uint8* Addr = GetValueBaseAddress( (uint8*)ActualObjToChange );
if (Addr != nullptr)
{
class FMemoryWriterWithObjects : public FArchive
{
public:
explicit FMemoryWriterWithObjects(TArray<uint8>& InArray)
: Array(InArray)
, Offset(0)
{
ArIsSaving = true;
}
virtual FArchive& operator<<(FName& Val) override { this->Serialize(&Val, sizeof(Val)); return *this; }
virtual FArchive& operator<<(UObject*& Val) override { this->Serialize(&Val, sizeof(Val)); return *this; }
virtual FArchive& operator<<(FLazyObjectPtr& Val) override { this->Serialize(&Val, sizeof(Val)); return *this; }
virtual FArchive& operator<<(FAssetPtr& Val) override { this->Serialize(&Val, sizeof(Val)); return *this; }
virtual FArchive& operator<<(FStringAssetReference& Val) override { this->Serialize(&Val, sizeof(Val)); return *this; }
void Serialize(void* Data, int64 Num)
{
const int64 NumBytesToAdd = Offset + Num - Array.Num();
if( NumBytesToAdd > 0 )
{
const int64 NewArrayCount = Array.Num() + NumBytesToAdd;
if( NewArrayCount >= MAX_int32 )
{
UE_LOG( LogSerialization, Fatal, TEXT( "FMemoryWriterWithObjects does not support data larger than 2GB." ));
}
Array.AddUninitialized( (int32)NumBytesToAdd );
}
check((Offset + Num) <= Array.Num());
if( Num )
{
FMemory::Memcpy( &Array[Offset], Data, Num );
Offset+=Num;
}
}
protected:
TArray<uint8>& Array;
int64 Offset;
};
class FMemoryReaderWithObjects : public FArchive
{
public:
explicit FMemoryReaderWithObjects(const TArray<uint8>& InArray)
: Array(InArray)
, Offset(0)
{
ArIsLoading = true;
}
virtual FArchive& operator<<(FName& Val) override { this->Serialize(&Val, sizeof(Val)); return *this; }
virtual FArchive& operator<<(UObject*& Val) override { this->Serialize(&Val, sizeof(Val)); return *this; }
virtual FArchive& operator<<(FLazyObjectPtr& Val) override { this->Serialize(&Val, sizeof(Val)); return *this; }
virtual FArchive& operator<<(FAssetPtr& Val) override { this->Serialize(&Val, sizeof(Val)); return *this; }
virtual FArchive& operator<<(FStringAssetReference& Val) override { this->Serialize(&Val, sizeof(Val)); return *this; }
void Serialize(void* Data, int64 Num)
{
if (Num && !ArIsError)
{
// Only serialize if we have the requested amount of data
if (Offset + Num <= TotalSize())
{
FMemory::Memcpy( Data, &Array[Offset], Num );
Offset += Num;
}
else
{
ArIsError = true;
}
}
}
protected:
const TArray<uint8>& Array;
int64 Offset;
};
if (MapProp != nullptr)
{
// Read previous value back into object
uint8* PreviousMap = (uint8*)FMemory::Malloc(MapProp->GetSize(), MapProp->GetMinAlignment());
ON_SCOPE_EXIT
{
FMemory::Free(PreviousMap);
};
MapProp->InitializeValue(PreviousMap);
ON_SCOPE_EXIT
{
MapProp->DestroyValue(PreviousMap);
};
MapProp->ImportText(*PreviousValue, PreviousMap, PPF_Localized, ModifiedObject);
uint8* ModifiedObjectAddr = GetValueBaseAddress( (uint8*)ModifiedObject );
// Serialize differences from the 'default' (the old object)
TArray<uint8> Data;
{
FMemoryWriterWithObjects Ar(Data);
MapProp->SerializeItem(Ar, Addr, PreviousMap);
}
// Deserialize differences back over the new object
{
FMemoryReaderWithObjects Ar(Data);
MapProp->SerializeItem(Ar, Addr, ModifiedObjectAddr);
}
}
else if (SetProp != nullptr)
{
// Read previous value back into object
uint8* PreviousSet = (uint8*)FMemory::Malloc(SetProp->GetSize(), SetProp->GetMinAlignment());
ON_SCOPE_EXIT
{
FMemory::Free(PreviousSet);
};
SetProp->InitializeValue(PreviousSet);
ON_SCOPE_EXIT
{
SetProp->DestroyValue(PreviousSet);
};
SetProp->ImportText(*PreviousValue, PreviousSet, PPF_Localized, ModifiedObject);
uint8* ModifiedObjectAddr = GetValueBaseAddress( (uint8*)ModifiedObject );
// Serialize differences from the 'default' (the old object)
TArray<uint8> Data;
{
FMemoryWriterWithObjects Ar(Data);
SetProp->SerializeItem(Ar, Addr, PreviousSet);
}
// Deserialize differences back over the new object
{
FMemoryReaderWithObjects Ar(Data);
SetProp->SerializeItem(Ar, Addr, ModifiedObjectAddr);
}
}
else
{
if (ParentArrayProp != nullptr)
{
uint8* ArrayAddr = ParentNode->GetValueBaseAddress( (uint8*)ActualObjToChange );
ParentArrayProp->ExportText_Direct(OrgValue, ArrayAddr, ArrayAddr, nullptr, PPF_Localized );
}
else
{
Prop->ExportText_Direct(OrgValue, Addr, Addr, nullptr, PPF_Localized );
}
// Check if the original value was the default value and change it only then
if (OrgValue == PreviousValue)
{
Prop->ImportText( NewValue, Addr, PPF_Localized, ActualObjToChange );
}
}
}
}
for (int32 InstanceIndex = 0; InstanceIndex < ArchetypeInstances.Num(); ++InstanceIndex)
{
UObject* Obj = ArchetypeInstances[InstanceIndex];
if (Obj->GetArchetype() == ObjToChange)
{
ObjectsToChange.Push(Obj);
ArchetypeInstances.RemoveAt(InstanceIndex--);
}
}
}
}
void FPropertyNode::AddRestriction( TSharedRef<const class FPropertyRestriction> Restriction )
{
Restrictions.AddUnique(Restriction);
}
bool FPropertyNode::IsRestricted(const FString& Value) const
{
for( auto It = Restrictions.CreateConstIterator() ; It ; ++It )
{
TSharedRef<const FPropertyRestriction> Restriction = (*It);
if( Restriction->IsValueRestricted(Value) )
{
return true;
}
}
return false;
}
bool FPropertyNode::IsRestricted(const FString& Value, TArray<FText>& OutReasons) const
{
for( auto It = Restrictions.CreateConstIterator() ; It ; ++It )
{
TSharedRef<const FPropertyRestriction> Restriction = (*It);
if( Restriction->IsValueRestricted(Value) )
{
OutReasons.Add(Restriction->GetReason());
}
}
return OutReasons.Num() > 0;
}
bool FPropertyNode::GenerateRestrictionToolTip(const FString& Value, FText& OutTooltip)const
{
static FText ToolTipFormat = NSLOCTEXT("PropertyRestriction", "TooltipFormat ", "{0}{1}");
static FText MultipleRestrictionsToolTopAdditionFormat = NSLOCTEXT("PropertyRestriction", "MultipleRestrictionToolTipAdditionFormat ", "({0} restrictions...)");
TArray<FText> Reasons;
bool bRestricted = IsRestricted(Value,Reasons);
FText Ret;
if( bRestricted && Reasons.Num() > 0 )
{
if( Reasons.Num() > 1 )
{
FText NumberOfRestrictions = FText::AsNumber(Reasons.Num());
OutTooltip = FText::Format(ToolTipFormat, Reasons[0], FText::Format(MultipleRestrictionsToolTopAdditionFormat,NumberOfRestrictions));
}
else
{
OutTooltip = FText::Format(ToolTipFormat, Reasons[0], FText());
}
}
return bRestricted;
}
#undef LOCTEXT_NAMESPACE