Files
UnrealEngineUWP/Engine/Source/Editor/ContentBrowser/Private/SAssetView.cpp
Ben Marsh bf66aaa497 Copying //UE4/Release-Staging-4.12 to //UE4/Dev-Main (Source: //UE4/Release-4.12 @ 2955635)
==========================
MAJOR FEATURES + CHANGES
==========================

Change 2955635 on 2016/04/26 by Max.Chen

	Sequencer: Fix filtering so that folders that contain filtered nodes will also appear.

	#jira UE-28213

Change 2955617 on 2016/04/25 by Dmitriy.Dyomin

	Better fix for: Post processing rendering artifacts Nexus 6
	this device on Android 5.0.1 does not support BGRA8888 texture as a color attachment
	#jira: UE-24067

Change 2955522 on 2016/04/25 by Max.Chen

	Sequencer: Fix crash when resolving object guid and context is null.

	#jira UE-29916

Change 2955504 on 2016/04/25 by Alexis.Matte

	#jira UE-29926
	Fix build error for SplineComponent. I just move variable under #if !UE_BUILD_SHIPPING instead #if WITH_EDITORONLY_DATA to fix all build flavor, please feel free to adjust according to what the initial fix was suppose to do.

Change 2955500 on 2016/04/25 by Dan.Oconnor

	Integration of 2955445 from Dev-BP
	#jira UE-29012

Change 2955234 on 2016/04/25 by Lina.Halper

	Fixed tool tip of twist node

	#jira : UE-29907

Change 2955211 on 2016/04/25 by Ben.Marsh

	Exclude all plugins which aren't required for a project (ie. don't have any content or modules for the current target) from its target receipt. Prevents dependencies on .uplugin files whose dependencies are otherwise compiled out. Re-enable PS4Media plugin by default.

	#jira UE-29842

Change 2955155 on 2016/04/25 by Jamie.Dale

	Fixed an issue where text committed via a focus loss might not display the correct text if it was changed during commit

	#jira UE-28756

Change 2955144 on 2016/04/25 by Jamie.Dale

	Fixed a case where editable text controls would fail to select their text when focused

	There was an order of operations issue between the options to select all text and move the cursor to the end of the document, which caused the cursor move to happen after the select all, and undo the selection. The order of these operations has now been flipped.

	#jira UE-29818
	#jira UE-29772

Change 2955136 on 2016/04/25 by Chad.Taylor

	Merging to 4.12:

	Morpheus latency fix. Late update tracking frame was getting unnecessarily buffered an extra frame on the RHI thread. Removed buffering and the issue is fixed.

	#jira UE-22581

Change 2955134 on 2016/04/25 by Lina.Halper

	Removed code that blocks moving actor when they don't have physics asset

	#jira : UE-29796
	#code review: Benn.Gallagher

Change 2955130 on 2016/04/25 by Zak.Middleton

	#ue4 - (4.12) Don't reject low distance MTD, it could cause us to not process some valid overlaps.
	(copy of 2955001 in Main)

	#jira UE-29531
	#lockdown Nick.Penwarden

Change 2955098 on 2016/04/25 by Marc.Audy

	Don't spawn a child actor on the client if the server is going to have created one and be replicating it to the client
	#jira UE-7539

Change 2955049 on 2016/04/25 by Richard.TalbotWatkin

	Changes to how SplineComponents debug render. Added a SetDrawDebug method to control whether a spline is rendered. Also extended the facility to non-editor builds.
	#jira UE-29753 - Add ability to display a SplineComponent in-game

Change 2955040 on 2016/04/25 by Chris.Gagnon

	Fixed Initializer Order Warning in hot reload ctor.

	#jira UE-28811, UE-28960

Change 2954995 on 2016/04/25 by Marc.Audy

	Make USceneComponent::Pre/PostNetReceive and PostRepNotifies protected instead of private so that subclasses can implement replication behaviors
	#jira UE-29909

Change 2954970 on 2016/04/25 by Peter.Sauerbrei

	fix for openwrite with O_APPEND flag
	#jira UE-28417

Change 2954917 on 2016/04/25 by Chris.Gagnon

	Moved a desired change from Main to 4.12

	Added input settings to:
	- control if the viewport locks the mouse on acquire capture.
	- control if the viewport acquires capture on the application launch (first window activate).

	#jira UE-28811, UE-28960
	parity with 4.11 (UE-28811, UE-28960 would be reintroduced without this)

Change 2954908 on 2016/04/25 by Alexis.Matte

	#jira UE-29478
	Prevent modal dialog to use 100% of a core

Change 2954888 on 2016/04/25 by Marcus.Wassmer

	Fix compile issue with chinese locale
	#jira UE-29708

Change 2954813 on 2016/04/25 by Lina.Halper

	Fix when not re-validating the correct asset

	#jira : UE-29789
	#code review: Martin.Wilson

Change 2954810 on 2016/04/25 by mason.seay

	Updated map to improve coverage

	#jira UE-29618

Change 2954785 on 2016/04/25 by Max.Chen

	Sequencer: Always spawn sequencer spawnables. Disregard collision settings.

	#jira UE-29825

Change 2954781 on 2016/04/25 by mason.seay

	Test map for Audio Occlusion trace channels

	#jira UE-29618

Change 2954684 on 2016/04/25 by Marc.Audy

	Add GetIsReplicated accessor to AActor
	Deprecate specific GameplayAbility class implementations that was exposing bReplicates
	#jira UE-29897

Change 2954675 on 2016/04/25 by Alexis.Matte

	#jira UE-25430
	Light Intensity value in FBX is a ratio. So I just multiply the default intensity value by the ratio to have something closer to the look in the DCCs

Change 2954669 on 2016/04/25 by Alexis.Matte

	#jira UE-29507
	Import of rigid mesh animation is broken

Change 2954579 on 2016/04/25 by Ben.Marsh

	Temporarily stop the PS4Media plugin being enabled by default, so the UE4Game built for the binary release doesn't depend on it. Will implement whitelist/blacklist for platforms later.

	#jira UE-29842

Change 2954556 on 2016/04/25 by Taizyd.Korambayil

	#jira UE-29877 Setup ThirdPersonCharacter based on correct Code Class

Change 2954552 on 2016/04/25 by Taizyd.Korambayil

	#jira UE-29877 Deleting BP class

Change 2954498 on 2016/04/25 by Ryan.Gerleve

	Fix for remote player controllers reporting that they're actually local player controllers after a seamless travel on the server.
	Transition actors to the new level in a second pass after non-transitioning actors are handled.

	#jira UE-29213

Change 2954446 on 2016/04/25 by Max.Chen

	Sequencer: Fixed spawning actors with instance or multiple owned components

	  - Also fixed issue where recorded actors were sometimes set as transient, meaning they didn't get saved

	#jira UE-29774, UE-29859

Change 2954430 on 2016/04/25 by Marc.Audy

	Don't schedule a tick function with a tick interval that was disabled while it was pending rescheduling
	#jira UE-29118
	#jira UE-29747

Change 2954292 on 2016/04/25 by Richard.TalbotWatkin

	Replicated from //UE4/Dev-Editor CL 2946363 (by Frank.Fella)

	CurveEditorViewportClient - Bounds check when box selecting.  Prevents crashing when the box is outside the viewport.
	#jira UE-29265 - Crash when drag selecting curve keys in matinee

Change 2954262 on 2016/04/25 by Graeme.Thornton

	Fixed a editor crash when destroying linkers half way through a package EndLoad

	#jira UE-29437

Change 2954239 on 2016/04/25 by Marc.Audy

	Fix error message
	#jira UE-00000

Change 2954177 on 2016/04/25 by Dmitriy.Dyomin

	Fixed: Hidden surface removal is not enabled on PowerVR Android devices
	#jira UE-29871

Change 2954026 on 2016/04/24 by Josh.Adams

	[Somehow most files got unchecked in my previous checkin, grr]
	- ProtoStar content/config updates (enabled TAA in the levels, disabled es2 shaders, hides the Unbuilt lighting warning on Android)
	#lockdown nick.penwarden
	#jira UE-29863

Change 2954025 on 2016/04/24 by Josh.Adams

	- ProtoStar content/config updates (enabled TAA in the levels, disabled es2 shaders, hides the Unbuilt lighting warning on Android)
	#lockdown nick.penwarden
	#jira UE-29863

Change 2953946 on 2016/04/24 by Max.Chen

	Sequencer: Fix crash on undo of a sub section.

	#jira UE-29856

Change 2953898 on 2016/04/23 by mitchell.wilson

	#jira UE-29618 Adding subscene_001 sequence for nonlinear workflow testing

Change 2953859 on 2016/04/23 by Maciej.Mroz

	Merged from Dev-Blueprints 2953858
	#jira UE-29790 Editor crashes when opening KiteDemo

Change 2953764 on 2016/04/23 by Max.Chen

	Sequencer: Remove "Experimental" tag on the Level Sequence Actor

	#jira UETOOl-625

Change 2953763 on 2016/04/23 by Max.Chen

	Cinematics: Change text to "Edit Existing Cinematics"

	#jira UE-29102

Change 2953762 on 2016/04/23 by Max.Chen

	Sequencer: Follow up time slider hit testing fix. Don't hit test the selection range if it's empty. This was causing false positives when hovering close to the ranges.

	#jira UE-29658

Change 2953652 on 2016/04/22 by Rolando.Caloca

	UE4.12 - vk - Workaround driver bugs wrt texture format caps
	#jira UE-28140

Change 2953596 on 2016/04/22 by Marcus.Wassmer

	#jira UE-20276
	Merging dual normal clearcoat shading model.
	2863683
	2871229
	2876362
	2876573
	2884007
	2901595

Change 2953594 on 2016/04/22 by Chris.Babcock

	Disable crash handler for VulkanRHI on Android to prevent sig11 on loading driver
	#jira UE-29851
	#ue4
	#android

Change 2953520 on 2016/04/22 by Rolando.Caloca

	UE4.12 - vk - Enable deferred resource deletion
	- Added one resource heap per memory type
	- Improved DumpMemory()
	- Added ensures for missing format features
	#jira UE-28140

Change 2953459 on 2016/04/22 by Taizyd.Korambayil

	#jira UE-29748 Resaved Maps to Fix EC Build Warnings
	#jira UE-29744

Change 2953448 on 2016/04/22 by Ryan.Gerleve

	Fix Mac/Linux compile.

	#jira UE-29545

Change 2953311 on 2016/04/22 by Ryan.Gerleve

	Fix for infinite hang when loading a replay from within an actor tick while demo.AsyncLoadWorld is false. LoadMap for the replay is now deferred using the existing PendingNetGame mechanism.
	Added virtual UPendingNetGame::LoadMapCompleted function so that the base PendingNetGame and DemoPendingNetGame can have different behavior.
	To keep things simpler, also parse all replay metadata and streaming levels after the LoadMap call.

	#jira UE-29545

Change 2953219 on 2016/04/22 by mason.seay

	Test map for show collision features

	#jira UE-29618

Change 2953199 on 2016/04/22 by Phillip.Kavan

	[UE-29449] Fix InitProperties() optimization for Blueprint class instances when array property values differ in size.

	change summary:
	- improved UBlueprintGeneratedClass::BuildCustomArrayPropertyListForPostConstruction() by continuing to emit only delta entries for array values that exceed the default array value's size; previously we emitted a NULL in this case to signal a need to initialize all remaining array values in InitProperties(), even if they didn't differ from the default value of the inner property (which in most cases would already have been set at construction time, and thus potentially incurred a redundant copy iteration for each entry)
	- modified FObjectInitializer::InitArrayPropertyFromCustomList() to no longer reset the array value on the instance prior to initialization
	    - added code to properly resize the array on the instance prior to initialization (if it differs in size from the default array value)
	    - removed code that handled a NULL property value in the custom property list stream (this is no longer necessary, see above)
	- modified FObjectInitializer::InitProperties() to restore the post-construction optimization for Blueprint class instances (back to being enabled by default)

	#jira UE-29449

Change 2953195 on 2016/04/22 by Max.Chen

	Sequencer: Fix crash in actor reference track in the cached guid to actor map.

	#jira UE-27523

Change 2953124 on 2016/04/22 by Rolando.Caloca

	UE4.12 - vk - Increase temp frame buffer
	#jira UE-28140

Change 2953121 on 2016/04/22 by Chris.Babcock

	Rebuilt lighting for all levels
	#jira UE-29809

Change 2953073 on 2016/04/22 by mason.seay

	Test assets for notifies in animation composites and montages

	#jira UE-29618

Change 2952960 on 2016/04/22 by Richard.TalbotWatkin

	Changed eye dropper operation so that LMB click selects a color, and pressing Esc cancels the selection and restores the old color.
	#jira UE-28410 - Eye dropper selects color without clicking

Change 2952934 on 2016/04/22 by Allan.Bentham

	Ensure pool's refractive index >= 1
	#jira UE-29777

Change 2952881 on 2016/04/22 by Jamie.Dale

	Better fix for UE-28560 that doesn't regress thumbnail rendering

	We now just silence the warning if dealing with an inactive world.

	#jira UE-28560

Change 2952867 on 2016/04/22 by Thomas.Sarkanen

	Fix issues with matinee-controlled anim instances

	Regression caused by us no longer saving off the anim sequence between updates.

	#jira UE-29812 - Protostar Neutrino spawns but does not Animate or move.

Change 2952826 on 2016/04/22 by Maciej.Mroz

	Merged from Dev-Blueprints 2952820

	#jira UE-28895 Nativizing a blueprint project causes the next non-nativizing package attempt to fail

Change 2952819 on 2016/04/22 by Josh.Adams

	- Fixed crash in a Vulkan shader printout
	#lockdown nick.penwarden
	#jira UE-29820

Change 2952817 on 2016/04/22 by Rolando.Caloca

	UE4.12 - vk - Revert back to simple layouts
	#jira UE-28140

Change 2952792 on 2016/04/22 by Jamie.Dale

	Removed some code that caused worlds loaded by the Content Browser to be initialized before they were ready

	Supposedly this code existed for world thumbnail rendering, however only the active editor world generates a thumbnail, so initializing other worlds wasn't having any effect and thumbnails look identical to before.

	#jira UE-28560

Change 2952783 on 2016/04/22 by Taizyd.Korambayil

	#jira UE-28477 Resaved Flying Template Map

Change 2952767 on 2016/04/22 by Taizyd.Korambayil

	#jira UE-29736 Resaved Map to Fix EC Warnings

Change 2952762 on 2016/04/22 by Allan.Bentham

	Update reflection capture to contain only room5 content.
	#jira UE-29777

Change 2952749 on 2016/04/22 by Taizyd.Korambayil

	#jira UE-29740 Resaved Material and Map to Fix Empty Engine Version Error

Change 2952688 on 2016/04/22 by Martin.Wilson

	Fix for BP notifies not displaying when they derive from an abstract base class

	#jira UE-28556

Change 2952685 on 2016/04/22 by Thomas.Sarkanen

	Fix CIS for non-editor builds

	#jira UE-29308 - Fix crash from GC-ed animation asset

Change 2952664 on 2016/04/22 by Thomas.Sarkanen

	Made up/down behaviour for console history consistent and reverted to old ordering by default

	Pressing up or down now brings up history.
	Sorting can now be optionally bottom-to-top or top-to-bottom. Default behaviour is preserved to what it was before the recent changes.

	#jira UE-29595 - Console autocomplete behavior is non-intuitive / frustrating

Change 2952655 on 2016/04/22 by Jamie.Dale

	Changed the class filter to use an expression evaluator

	This makes it consistent with the other filters in the editor

	#jira UE-29811

Change 2952647 on 2016/04/22 by Allan.Bentham

	Back out changelist 2951539
	#jira UE-29777

Change 2952618 on 2016/04/22 by Benn.Gallagher

	Fixed naming error in rotation multiplier node
	#jira UE-29583

Change 2952612 on 2016/04/22 by Thomas.Sarkanen

	Fix garbage collection and undo/redo issues with anim instance proxy

	UObject-based properties are now cached each update on the proxy and nulled-out outside of evaluate/update phases.
	Moved some initialization code for CurrentAsset/CurrentVertexAnim from the proxy back to the instance (as its is encapsulated there now).

	#jira UE-29308 - Fix crash from GC-ed animation asset

Change 2952608 on 2016/04/22 by Richard.TalbotWatkin

	Changed 'Recently Used Levels' and 'Favorite Levels' to hold long package names instead of absolute paths. This means they are now project-relative and will remain valid even if the project location changes.
	#jira UE-29731 - Editor map recent files are not project relative, leading to missing links when moving projects.

Change 2952599 on 2016/04/22 by Dmitriy.Dyomin

	Disabled vulkan pipeline cache as it causes rendering artifacts right now
	#jira UE-29807

Change 2952540 on 2016/04/22 by Maciej.Mroz

	#jira UE-29787 Obsolete nativized files are never removed
	merged from Dev-Blueprints 2952531

Change 2952372 on 2016/04/21 by Josh.Adams

	- Fixed Vk memory allocations when reusing free pages
	#lockdown nick.penwarden
	#jira ue-29802

Change 2952350 on 2016/04/21 by Eric.Newman

	Added support for UEReleaseTesting backends to Orion and Ocean
	#jira op-3640

Change 2952140 on 2016/04/21 by Dan.Oconnor

	Demoted back to warning to fix regressions in content examples, in main we've added the ability to elevate warnings to errors, but no reason to rush that feature into 4.12
	#jira UE-28971

Change 2952135 on 2016/04/21 by Jeff.Farris

	Fixed issue in PlayerCameraManager where the priority-based sorting of CameraModifiers wasn't sorting properly.
	Manual re-implementation of CL 2948123 in 4.12 branch.
	#jira UE-29634

Change 2952121 on 2016/04/21 by Lee.Clark

	PS4 - 4.12 - Fix staging and deploying of system prxs

	#jira UE-29801

Change 2952120 on 2016/04/21 by Rolando.Caloca

	UE4.12 - vk - Move descriptor allocation to BSS
	#jira UE-21840

Change 2952027 on 2016/04/21 by Rolando.Caloca

	UE4.12 - vk - Fix descriptor sets lifetimes
	- Fix crash with null texture
	#jira UE-28140

Change 2951890 on 2016/04/21 by Eric.Newman

	Updating locked common dependencies for OrionService
	#jira OP-3640

Change 2951863 on 2016/04/21 by Eric.Newman

	Updating locked dependencies for UE 4.12 OrionService
	#jira OP-3640

Change 2951852 on 2016/04/21 by Owen.Stupka

	Fixed meteors destruct location
	#jira UE-29714

Change 2951739 on 2016/04/21 by Max.Chen

	Sequencer: Follow up for integral keys.

	#jira UE-29791

Change 2951717 on 2016/04/21 by Rolando.Caloca

	UE4.12 - Fix shader platform names
	#jira UE-28140

Change 2951714 on 2016/04/21 by Max.Chen

	Sequencer: Fix setting a key if it already exists at the current time.

	#jira UE-29791

Change 2951708 on 2016/04/21 by Rolando.Caloca

	UE4.12 - vk - Separate upload cmd buffer
	#jira UE-28140

Change 2951653 on 2016/04/21 by Marc.Audy

	If a child actor component is destroyed during garbage collection, do not rename, instead clear the caching mechanisms so that a new name is chosen if a new child is created in the future
	Remove now unused bRenameRequired parameter
	#jira UE-29612

Change 2951619 on 2016/04/21 by Chris.Babcock

	Move bCreateRenderStateForHiddenComponents out of WITH_EDITOR
	#jira UE-29786
	#ue4

Change 2951603 on 2016/04/21 by Cody.Albert

	#jira UE-29785
	Revert Github readme page back to original

Change 2951599 on 2016/04/21 by Ryan.Gerleve

	Fix assert when attempting to record a replay when the map has a placed actor that writes replay external data (such as ACharacter)

	#jira UE-29778

Change 2951558 on 2016/04/21 by Chris.Babcock

	Always rename destroyed child actor
	#jira UE-29709
	#ue4

Change 2951552 on 2016/04/21 by James.Golding

	Remove old code for handling 'show collision' in game, uses same method as editor now, fixes hidden meshes showing up in game when doing 'show collision'
	#jira UE-29303

Change 2951539 on 2016/04/21 by Allan.Bentham

	Use screenuv for distortion with ES2/31.
	#jira UE-29777

Change 2951535 on 2016/04/21 by Max.Chen

	We need to test if the hmd is enabled if it exists. Otherwise, this will return true even if we aren't rendering in stereo if there's an hmd plugin loaded.

	#jira UE-29711

Change 2951521 on 2016/04/21 by Taizyd.Korambayil

	#jira UE-29746 Replaced Deprecated Time Handler node in GameLevel_GM

Change 2951492 on 2016/04/21 by Jeremiah.Waldron

	Fix for Android IAP information reporting back incorrectly.
	#jira UE-29776

Change 2951486 on 2016/04/21 by Taizyd.Korambayil

	#jira UE-29741 Updated Infiltrator Demo Project to open with the correct Map

Change 2951450 on 2016/04/21 by Gareth.Martin

	Fix non-editor build
	#jira UE-16525

Change 2951380 on 2016/04/21 by Gareth.Martin

	Fix Landscape layer blend nodes not updating connections correctly when an input is changed from weight/alpha (one input) to height blend (two inputs) or vice-versa
	#jira UE-16525

Change 2951357 on 2016/04/21 by Richard.TalbotWatkin

	Fixed a crash when pushing a new menu leads to a window activation change which would result in the old root menu being dismissed.
	#jira UE-27981 - [CrashReport] Crash When Attempting to Select Variable Type After Clearing the Name Field

Change 2951352 on 2016/04/21 by Richard.TalbotWatkin

	Added slider bar thickness as a new property in FSliderStyle.
	#jira UE-19173 - SSlider is not fully stylable

Change 2951344 on 2016/04/21 by Gareth.Martin

	Fix bounds calculation for landscape splines that was causing the first landscape spline point to be invisible and later points to flicker.
	- Also fixes landscape spline lines not showing up on a flat landscape
	#jira UE-25114

Change 2951326 on 2016/04/21 by Taizyd.Korambayil

	#jira UE-28477 Resaving Maps

Change 2951271 on 2016/04/21 by Jamie.Dale

	Fixed a crash when pasting a path containing a class into the asset view of the Content Browser

	#jira UE-29616

Change 2951237 on 2016/04/21 by Jack.Porter

	Fix black screen on PC due to planar reflections

	#jira UE-29664

Change 2951184 on 2016/04/21 by Jamie.Dale

	Fixed crash in FCurveStructCustomization when no objects were selected for editing

	#jira UE-29638

Change 2951177 on 2016/04/21 by Ben.Marsh

	Fix hot reload from IDE failing when project is up to date. UBT returns an exit code of 2, and any non-zero exit code is treated as an error by Visual Studio. Build.bat was not correctly forwarding on the exit code at all prior to CL 2790858.

	#jira UE-29757

Change 2951171 on 2016/04/21 by Matthew.Griffin

	Fixed issue with Rebuild not working when installed in Program Files (x86)
	The brackets seem to cause lots of problems in combination with the if/else ones
	#jira UE-29648

Change 2951163 on 2016/04/21 by Jamie.Dale

	Changed the text customization to use the property handle functions to get/set the text value

	That ensures that it both transacts and notifies correctly.

	Added new functions to deal with multiple objects selection efficiently with the existing IEditableTextProperty API:
	  - FPropertyHandleBase::SetPerObjectValue
	  - FPropertyHandleBase::GetPerObjectValue
	  - FPropertyHandleBase::GetNumPerObjectValues

	These replace the need to cache the raw pointers.

	#jira UE-20223

Change 2951103 on 2016/04/21 by Thomas.Sarkanen

	Un-deprecated blueprint functions for attachment/detachment

	Renamed functions to <FuncName> (Deprecated).
	Hid functions in the BP context menu so new ones cant be added.

	#jira UE-23216 - "Snap to Target, Keep World Scale" when attaching doesn't work properly if parent is scaled.

Change 2951101 on 2016/04/21 by Allan.Bentham

	Enable mobile HQ DoF
	#jira UE-29765

Change 2951097 on 2016/04/21 by Thomas.Sarkanen

	Standalone games now benefit from parallel anim update if possible

	We now simply use the fact we want root motion to determine if we need to run immediately.

	#jira UE-29431 - Parallel anim update does not work in non-multiplayer games

Change 2951036 on 2016/04/21 by Lee.Clark

	PS4 - Fix WinDualShock working with VS2015

	#jira UE-29088

Change 2951034 on 2016/04/21 by Jack.Porter

	ProtoStar: Removed content not needed by remaining maps, resaved all content to fix version 0 issues

	#jira UE-29666

Change 2950995 on 2016/04/21 by Jack.Porter

	ProtoStar - delete unneeded maps

	#jira UE-29665

Change 2950787 on 2016/04/20 by Nick.Darnell

	SuperSearch - Moving the settings object into a seperate plugin to avoid there needing to be a circular dependency between SuperSearch and UnrealEd.

	#jira UE-29749
	#codeview Ben.Marsh

Change 2950786 on 2016/04/20 by Nick.Darnell

	Back out changelist 2950769 - Going to re-enable super search - about to move the settings into a plugin to prevent the circular reference.

	#jira UE-29749

Change 2950769 on 2016/04/20 by Ben.Marsh

	Comment out editor integration for super search to fix problems with the circular dependencies breaking hot reload and compiling QAGame in binary release.

Change 2950724 on 2016/04/20 by Lina.Halper

	Support for negative scaling for mirroring

	- Merging CL 2950718 using //UE4/Dev-Framework_to_//UE4/Release-4.12

	#jira: UE-27453

Change 2950293 on 2016/04/20 by andrew.porter

	Correcting sequencer test content

	#jira UE-29618

Change 2950283 on 2016/04/20 by Marc.Audy

	Don't route FlushPressedKeys on PIE shut down
	#jira UE-28734

Change 2950071 on 2016/04/20 by mason.seay

	Adjusted translation retargeting on head bone of UE4_Mannequin

	-Needed for anim bp test.  Tested animations and did not see any fallout from change.  If there is, it can be reverted.

	#jira UE-29618

Change 2950049 on 2016/04/20 by Mark.Satterthwaite

	Undo CL #2949690 and instead on Mac where we want to be able to capture videos of gameplay we just insert an intermediate texture as the back-buffer and use a manual blit to the drawable prior to present. This also changes the code to enforce that the back-buffer render-target should never be nil as the code & Metal API itself assumes that this situation cannot occur but it would appear from continued crashes inside PrepareToDraw that it actually can in the field. This will address another potential cause of UE-29006.
	#jira UE-29006
	#jira UE-29140

Change 2949977 on 2016/04/20 by Max.Chen

	Sequencer: Add FieldOfView to default tracks for CameraActor. Add FieldOfView to exclusion list for CineCameraActor.

	#jira UE-29660

Change 2949836 on 2016/04/20 by Gareth.Martin

	Fix landscape components flickering when perfectly flat (bounds size is 0)
	- This often happens for newly created landscapes
	#jira UE-29262

Change 2949768 on 2016/04/20 by Thomas.Sarkanen

	Moving parent & grouped child actors now does not result in deltas being applied twice

	Grouping and attachment now interact correctly.
	Also fixed up according to coding standard.

	Discovered and proposed by David.Bliss2 (Rocksteady).

	#jira UE-29233 - Delta applied twice when moving parent and grouped child actors
	From UDN: https://udn.unrealengine.com/questions/286537/moving-parent-grouped-child-actors-results-in-delt.html

Change 2949759 on 2016/04/20 by Thomas.Sarkanen

	Fix split pins not working as anim graph node inputs

	Limit surface area of this change by only modifying the anim BP compiler. A better version might be to move the call in the general blueprint compiler but it is riskier.

	#jira UE-12326 - Splitting a struct in an Anim Blueprint does not work

Change 2949739 on 2016/04/20 by Thomas.Sarkanen

	Fix layered bone per blend accessed from a struct in the fast-path

	Made sure that the fallback event is always built (logic was still split so if PatchFunctionNamesAndCopyRecordsInto aborted because of some unhandled case if might not have an event to call).
	Covered struct source->array dest case.
	Indicator icon is now built from the copy record itself, ensuring it is accurate to actual runtime data.

	#jira UE-29389 - Fast-Path: Layered Blend per Bone node failing to grab updated values from struct.

Change 2949715 on 2016/04/20 by Max.Chen

	Sequencer: Fix mouse wheel zoom so it defaults to zooming in on the current time/frame. This is a toggleable option in the Editor Preferences (Zoom Position = Current Time or Mouse Position)

	#jira UE-29661

Change 2949712 on 2016/04/20 by Taizyd.Korambayil

	#jira UE-28544 adjusted Player crosshair to be centered

Change 2949710 on 2016/04/20 by Alexis.Matte

	#jira UE-29477
	Pixel Inspector, UI get polish and adding "scene color" inspect property

Change 2949706 on 2016/04/20 by Alexis.Matte

	#jira UE-29475
	#jira UE-29476
	Favorite allow all UProperty to be favorite (the FStruct is now supported)
	Favorite scrollig is auto adjust to avoid scrolling when adding/removing a favorite

Change 2949691 on 2016/04/20 by Mark.Satterthwaite

	Fix typo from previous commit - retain not release...
	#jira UE-29140

Change 2949690 on 2016/04/20 by Mark.Satterthwaite

	Double-buffer the Metal viewport's back-buffer so that we can access the contents of the back-buffer after EndDrawingViewport is called until BeginDrawingViewport is called again on this viewport, this makes it possible to capture movies on Metal.
	#jira UE-29140

Change 2949616 on 2016/04/20 by Marc.Audy

	'Merge' latest version of Vulkan from Dev-Rendering to Release-4.12
	#jira UE-00000

Change 2949572 on 2016/04/20 by Jamie.Dale

	Fixed crash undoing a text property changed caused by a null entry in the array

	#jira UE-20223

Change 2949562 on 2016/04/20 by Alexis.Matte

	#jira UE-29447
	Fix the batch fbx import "not show options" dialog where some option can be different.

Change 2949560 on 2016/04/20 by Alexis.Matte

	#jira UE-28898
	Avoid importing multiple static mesh in the same package

Change 2949547 on 2016/04/20 by Mark.Satterthwaite

	You must use STENCIL_COMPONENT_SWIZZLE  to access the stencil component of a texture - not all APIs can swizzle it into .g automatically.
	#jira UE-29672

Change 2949443 on 2016/04/20 by Allan.Bentham

	Disable sRGB textures when ES31 feature level is set.
	Only use vk's sRGB formats when feature level > ES3_1

	#jira UE-29623

Change 2949428 on 2016/04/20 by Allan.Bentham

	Back out changelist 2949405
	#jira UE-29623

Change 2949405 on 2016/04/20 by Allan.Bentham

	Disable sRGB textures when ES31 feature level is set.
	Only use vk's sRGB formats when feature level > ES3_1

	#jira UE-29623

	Merging using Dev-Mobile_->_Release-4.12

Change 2949391 on 2016/04/20 by Richard.TalbotWatkin

	PIE with multiple windows now starts focused on Client 1, or the server if not a dedicated server. Added a new virtual call UEditorEngine::OnLoginPIEAllComplete, called when all clients have been successfully logged in when starting PIE. The default behavior is to set focus to the first client.
	#jira UE-26037 - Cumbersome workflow when running PIE with 2 clients
	#jira UE-26905 - First client window does not gain focus or mouse control when launching two clients

Change 2949389 on 2016/04/20 by Richard.TalbotWatkin

	Fixed regression which was saving the viewport config settings incorrectly.  Viewports are keyed by their layout on the same key as the config key, hence we do not need to prepend the SpecificLayoutString when saving out the config data when iterating through a layout's viewports.
	#jira UE-29058 - Viewport settings are not saved after shutting down editor

Change 2949388 on 2016/04/20 by Richard.TalbotWatkin

	Change auto-reimport settings so that "Detect Changes on Startup" defaults to true. Also removed the warning of potential unwanted behaviour when working in conjunction with source control; this is no longer necessary now that there is a prompt prior to auto-reimport.
	#jira UE-29257 - Auto import does not import assets

Change 2949203 on 2016/04/19 by Max.Chen

	Sequencer: Fix spawnables not getting default tracks.

	#jira UE-29644

Change 2949202 on 2016/04/19 by Max.Chen

	Sequencer: Fix particles not firing on loop.

	#jira UE-27881

Change 2949201 on 2016/04/19 by Max.Chen

	Sequencer: Fix multiple labels support

	#jira UE-26812

Change 2949200 on 2016/04/19 by Max.Chen

	Sequencer: Expose settings sequencer settings in the Editor Preferences page. Note, UMG and Niagara have separate sequencer settings pages.

	#jira UE-29516

Change 2949197 on 2016/04/19 by Max.Chen

	Sequencer: Fix unwind rotation when keying rotation so that rotations are always set to the nearest.

	#jira UE-22228

Change 2949196 on 2016/04/19 by Max.Chen

	Sequencer: Disable selection range drawing if it's empty so that playback range dragging can take precedence when they overlap. This fixes a bug where you can't drag the starting playback range when sequencer starts up.

	#jira UE-29657

Change 2949195 on 2016/04/19 by Max.Chen

	MovieSceneCapture: Default image compression quality to 100 (rather than 75).

	#jira UE-29657

Change 2949194 on 2016/04/19 by Max.Chen

	Sequencer: Matinee to Level Sequence fix for mapping properties correctly. This fixes focus distance not getting set properly on the conversion.

	#jira UETOOL-467

Change 2949193 on 2016/04/19 by Max.Chen

	Sequencer - Fix issues with level visibility.
	+ Don't mark sub-levels as dirty when the track evaluates.
	+ Fix an issue where sequencer gets into a refresh loop because drawing thumbnails causes levels to be added which was rebuilding the tree, which was redrawing thumbnails.
	+ Null check for when an objects world is null but the track is still evaluating.
	+ Remove UnrealEd references.

	#jira UE-25668

Change 2948990 on 2016/04/19 by Aaron.McLeran

	#jira UE-29654 FadeIn invalidates Audio Components in 4.11

Change 2948890 on 2016/04/19 by Jamie.Dale

	Downgraded an assert in SPathView::LoadSettings to avoid a common crash when a saved path no longer exists

	#jira UE-28858

Change 2948860 on 2016/04/19 by Mike.Beach

	Mirroring CL 2940334 (from Dev-Blueprints):
	Bettering CreateEvent node errors, so users are able to recover from API changes (not clearing the function name field, calling out the function by name in the error, etc.)

	#jira UE-28911

Change 2948857 on 2016/04/19 by Jamie.Dale

	Added an Asset Localization context menu to the Content Browser

	This allows you to create, edit, and view localized assets from any source asset, as well as edit and view source assets from any localized asset.

	#jira UE-29493

Change 2948854 on 2016/04/19 by Jamie.Dale

	UAT now stages all project translation targets

	#jira UE-20248

Change 2948831 on 2016/04/19 by Mike.Beach

	Mirroring CL 2945994 (from Dev-Blueprints):
	Pasting EdGraphNodes will no longer query sub-nodes for compatibility if the root cannot be pasted (for things like collapsed graphs, and anim state-machine nodes).

	#jira UE-29035

Change 2948825 on 2016/04/19 by Jamie.Dale

	Fixed shadow warning

	#jira UE-29212

Change 2948812 on 2016/04/19 by Marc.Audy

	Gracefully handle failure to load configurable engine classes
	#jira UE-26527

Change 2948791 on 2016/04/19 by Jamie.Dale

	Fixed regression in SEditableText bIsCaretMovedWhenGainFocus when using auto-complete
	Fixed regression in FSlateEditableTextLayout::SetText that caused it to call OnTextChanged when nothing had changed

	#jira UE-29494
	#jira UE-28886

Change 2948761 on 2016/04/19 by Jamie.Dale

	Sub-fonts are now only used when they contain the character to be rendered

	#jira UE-29212

Change 2948718 on 2016/04/19 by Jamie.Dale

	Fixed an issue where FEnginePackageLocalizationCache could be initialized before CoreUObject was ready

	This is now done lazily, either when the first CDO tries to load an asset (which is after CoreUObject is ready), or after the first call to ProcessNewlyLoadedUObjects (if no CDO loads an asset).

	#jira UE-29649

Change 2948717 on 2016/04/19 by Jamie.Dale

	Removed the AssetRegistry's dependency on MessageLog

	It was only there to add a category that was only ever used by the AssetTools module.

	#jira UE-29649

Change 2948683 on 2016/04/19 by Phillip.Kavan

	[UE-18419] Fix GetClassDefaults nodes to update properly in response to structural BP class changes.

	change summary:
	- modified UK2Node_GetClassDefaults::CreateOutputPins() to bind/unbind delegate handlers for the OnChanged() & OnCompile() events for BP class types.

	#jira UE-18419

Change 2948681 on 2016/04/19 by Phillip.Kavan

	[UE-17794] The "Delete Unused Variable" feature now considers the GetClassDefaults node as well.

	change summary:
	- added external linkage to UK2Node_GetClassDefaults::FindClassPin().
	- added an include for the K2Node_GetClassDefaults header file to BlueprintGraphDefinitions.h.
	- added UK2Node_GetClassDefaults::GetInputClass() as a public API w/ external linkage; moved default 'nullptr' param logic into this impl.
	- modified FBlueprintEditorUtils::IsVariableUsed() to add an extra check for a GetClassDefaults node with a visible output pin for the variable that's also connected.
	- modified UK2Node_GetClassDefaults::GetInputClass() to return the generated skeleton class for Blueprint class types.

	#jira UE-17794

Change 2948638 on 2016/04/19 by Lee.Clark

	PS4 - Fix SDK compile warnings

	#jira UE-29647

Change 2948401 on 2016/04/19 by Taizyd.Korambayil

	#jira UE-29250 Revuilt Lighting for Landscapes Map

Change 2948398 on 2016/04/19 by Mark.Satterthwaite

	Add a Mac Metal ES2 shader platform to allow the various ES2 emulation modes to work in the Editor. Fix various issues with the shader code to ensure that Metal can run with ES2 shader code at least in my limited test cases in QAGame.
	#jira UE-29170

Change 2948366 on 2016/04/19 by Taizyd.Korambayil

	#jira UE-29109 Replaced Box Mesh with BSP Floor

Change 2948360 on 2016/04/19 by Maciej.Mroz

	merged from Dev-Blueprints 2947488

	#jira UE-29115 Nativized BulletTrain - cannot shoot targets in intro tutorial
	#jira UE-28965 Packaging Project with Nativize Blueprint Assets Prevents Overlap Events from Firing
	#jira UE-29559
	- fixed private enum access
	- fixed private bitfield access
	- removed forced PostLoad
	- add BodyInstance.FixupData call to fix ResponseChannels
	- ignored RelativeLocation and RelativeRotation in converted root component
	- fixed AttachToComponent (UE-29559)

Change 2948358 on 2016/04/19 by Maciej.Mroz

	merged from Dev-Blueprints 2947953

	#jira UE-29605 Wrong bullet trails in nativized ShowUp
	Fixed USimpleConstructionScript::GetSceneRootComponentTemplate.

Change 2948357 on 2016/04/19 by Maciej.Mroz

	merged from Dev-Blueprints 2947984

	#jira UE-29374 Crash when hovering over Create Widget node in blueprints

	Safe UK2Node_ConstructObjectFromClass::GetPinHoverText.

Change 2948353 on 2016/04/19 by Maciej.Mroz

	merged from Dev-Blueprints 2948095

	#jira UE-29246 ExpandEnumAsExecs + UMETA(Hidden) Crashes Blueprint Compile
	"Hidden" and "Spacer" elementa from an enum does not generated exec pins for "ExpandEnumAsExecs"

Change 2948332 on 2016/04/19 by Benn.Gallagher

	Fixed old pins being left as non-transactional
	#jira UE-13801

Change 2948203 on 2016/04/19 by Lee.Clark

	PS4 - Use SDK 3.508.031

	#jira UEPLAT-1225

Change 2948168 on 2016/04/19 by mason.seay

	Updating test content:

	-Added Husk AI to level to test placed AI

	-Updated Spawn Husk BP to destroy itself to prevent spawn spamming

	#jira UE-29618

Change 2948153 on 2016/04/19 by Benn.Gallagher

	Missed mesh update for Owen IK fix.

	#jira UE-22540

Change 2948130 on 2016/04/19 by Benn.Gallagher

	Fixed old Owen punch IK setup so it no longer jitters when placing the hands on the surface.

	#jira UE-22540

Change 2948117 on 2016/04/19 by Taizyd.Korambayil

	#jira UE-28477 Resaved Template Map's to fix Warning Toast on Templates

Change 2948063 on 2016/04/19 by Lina.Halper

	- Anim composite notify change for better
	 - Fixed all nested anim notify

	- Merging CL 2944396 using //UE4/Dev-Framework_to_//UE4/Release-4.12

	#jira : UE-29101

Change 2948060 on 2016/04/19 by Lina.Halper

	Fix for composite section metadata saving for montage

	Merging CL 2944397 using //UE4/Dev-Framework_to_//UE4/Release-4.12

	#jira : UE-29228

Change 2948029 on 2016/04/19 by Ben.Marsh

	EC: Prevent automatically pushing CIS builds to the launcher; the changelist might be run more than once.

Change 2947986 on 2016/04/19 by Benn.Gallagher

	Fixed BP callable functions that affect skeletal mesh component transforms not working when simulating physics.
	#jira UE-27783

Change 2947976 on 2016/04/19 by Mark.Satterthwaite

	Duplicate CL #2943702 from 4.11.2: Change the way Metal validates the render-target state so that in FMetalContext::PrepareToDraw it can issue a last-ditch attempt to restore the render-targets. This won't fix the cause of the Mac Metal crashes but it might mitigate some of them and provide more information about why they are occurring.
	#jira UE-29006

Change 2947975 on 2016/04/19 by Mark.Satterthwaite

	Duplicate CL #2945061 from UE4-UT: Address UT issue UE-29150 directly in the UT branch: users without a sufficiently up-to-date Xcode won't have the 'metal' offline shader compiler so will have to use the slower online compiled text shader format.
	#jira UE-29150

Change 2947679 on 2016/04/19 by Jack.Porter

	Fixed 4.12 branch not compiling with the 1.0.8 Vulkan SDK
	#jira UE-29601

Change 2947657 on 2016/04/18 by Jack.Porter

	Update protostar reflection capture contents

	#jira UE-29600

Change 2947301 on 2016/04/18 by Ben.Marsh

	EC: Fix trigger ready emails failing to send due to recipient list being a space-separated list of addresses rather than an array reference.

Change 2947263 on 2016/04/18 by Marc.Audy

	Merging CL# 2945921 //UE4/Release-4.11 to //UE4/Release-4.12

	Ensure that all OwnedComponents in an Actor are duplicated for PIE even if not referenced by a property, unless that component is explicitly transient
	#jira UE-29209

Change 2946984 on 2016/04/18 by Ben.Marsh

	GUBP: Allow Ocean cooks in the release branch (fixes build startup failures)

Change 2946870 on 2016/04/18 by Ben.Marsh

	Remaking CL 2946810 to fix compile error in ShooterGame editor.

Change 2946859 on 2016/04/18 by Ben.Marsh

	GUBP: Don't exclude Ocean from builds in the release branch.

Change 2946847 on 2016/04/18 by Ben.Marsh

	GUBP: Fix warning on every build step due to OrionGame_Win32_Mono no longer existing.

Change 2946771 on 2016/04/18 by Ben.Marsh

	EC: Correct initial agent type for release branches. Causing full branch syncs on all agents.

Change 2946641 on 2016/04/18 by Ben.Marsh

	EC: Remove rogue comma causing branch definition parsing to fail.

Change 2946592 on 2016/04/18 by Ben.Marsh

	EC: Adding branch definition for 4.12 release

#lockdown Nick.Penwarden

[CL 2962354 by Ben Marsh in Main branch]
2016-05-01 17:37:41 -04:00

4249 lines
137 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "ContentBrowserPCH.h"
#include "SScrollBorder.h"
#include "EditorWidgets.h"
#include "AssetViewTypes.h"
#include "DragAndDrop/AssetDragDropOp.h"
#include "DragAndDrop/AssetPathDragDropOp.h"
#include "DragDropHandler.h"
#include "AssetThumbnail.h"
#include "AssetViewWidgets.h"
#include "FileHelpers.h"
#include "ContentBrowserModule.h"
#include "ObjectTools.h"
#include "KismetEditorUtilities.h"
#include "IPluginManager.h"
#include "NativeClassHierarchy.h"
#include "MessageLog.h"
#include "SNotificationList.h"
#include "NotificationManager.h"
#define LOCTEXT_NAMESPACE "ContentBrowser"
namespace
{
/** Time delay between recently added items being added to the filtered asset items list */
const double TimeBetweenAddingNewAssets = 4.0;
/** Time delay between performing the last jump, and the jump term being reset */
const double JumpDelaySeconds = 2.0;
}
#define MAX_THUMBNAIL_SIZE 4096
SAssetView::~SAssetView()
{
// Load the asset registry module to unregister delegates
if ( FModuleManager::Get().IsModuleLoaded("AssetRegistry") )
{
FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
AssetRegistryModule.Get().OnAssetAdded().RemoveAll( this );
AssetRegistryModule.Get().OnAssetRemoved().RemoveAll( this );
AssetRegistryModule.Get().OnAssetRenamed().RemoveAll( this );
AssetRegistryModule.Get().OnPathAdded().RemoveAll( this );
AssetRegistryModule.Get().OnPathRemoved().RemoveAll( this );
}
// Unregister listener for asset loading and object property changes
FCoreUObjectDelegates::OnAssetLoaded.RemoveAll(this);
FCoreUObjectDelegates::OnObjectPropertyChanged.RemoveAll(this);
// Unsubscribe from class events
if ( bCanShowClasses )
{
TSharedRef<FNativeClassHierarchy> NativeClassHierarchy = FContentBrowserSingleton::Get().GetNativeClassHierarchy();
NativeClassHierarchy->OnClassHierarchyUpdated().RemoveAll( this );
}
// Remove the listener for when view settings are changed
UContentBrowserSettings::OnSettingChanged().RemoveAll(this);
if ( FrontendFilters.IsValid() )
{
// Clear the frontend filter changed delegate
FrontendFilters->OnChanged().RemoveAll( this );
}
// Release all rendering resources being held onto
AssetThumbnailPool->ReleaseResources();
}
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SAssetView::Construct( const FArguments& InArgs )
{
bIsWorking = false;
TotalAmortizeTime = 0;
AmortizeStartTime = 0;
MaxSecondsPerFrame = 0.015;
bFillEmptySpaceInTileView = InArgs._FillEmptySpaceInTileView;
FillScale = 1.0f;
ThumbnailHintFadeInSequence.JumpToStart();
ThumbnailHintFadeInSequence.AddCurve(0, 0.5f, ECurveEaseFunction::Linear);
// Load the asset registry module to listen for updates
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
AssetRegistryModule.Get().OnAssetAdded().AddSP( this, &SAssetView::OnAssetAdded );
AssetRegistryModule.Get().OnAssetRemoved().AddSP( this, &SAssetView::OnAssetRemoved );
AssetRegistryModule.Get().OnAssetRenamed().AddSP( this, &SAssetView::OnAssetRenamed );
AssetRegistryModule.Get().OnPathAdded().AddSP( this, &SAssetView::OnAssetRegistryPathAdded );
AssetRegistryModule.Get().OnPathRemoved().AddSP( this, &SAssetView::OnAssetRegistryPathRemoved );
FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
CollectionManagerModule.Get().OnAssetsAdded().AddSP( this, &SAssetView::OnAssetsAddedToCollection );
CollectionManagerModule.Get().OnAssetsRemoved().AddSP( this, &SAssetView::OnAssetsRemovedFromCollection );
CollectionManagerModule.Get().OnCollectionRenamed().AddSP( this, &SAssetView::OnCollectionRenamed );
CollectionManagerModule.Get().OnCollectionUpdated().AddSP( this, &SAssetView::OnCollectionUpdated );
// Listen for when assets are loaded or changed to update item data
FCoreUObjectDelegates::OnAssetLoaded.AddSP(this, &SAssetView::OnAssetLoaded);
FCoreUObjectDelegates::OnObjectPropertyChanged.AddSP(this, &SAssetView::OnObjectPropertyChanged);
// Listen to find out when the available classes are changed, so that we can refresh our paths
if ( bCanShowClasses )
{
TSharedRef<FNativeClassHierarchy> NativeClassHierarchy = FContentBrowserSingleton::Get().GetNativeClassHierarchy();
NativeClassHierarchy->OnClassHierarchyUpdated().AddSP( this, &SAssetView::OnClassHierarchyUpdated );
}
// Listen for when view settings are changed
UContentBrowserSettings::OnSettingChanged().AddSP(this, &SAssetView::HandleSettingChanged);
// Get desktop metrics
FDisplayMetrics DisplayMetrics;
FSlateApplication::Get().GetDisplayMetrics( DisplayMetrics );
const FVector2D DisplaySize(
DisplayMetrics.PrimaryDisplayWorkAreaRect.Right - DisplayMetrics.PrimaryDisplayWorkAreaRect.Left,
DisplayMetrics.PrimaryDisplayWorkAreaRect.Bottom - DisplayMetrics.PrimaryDisplayWorkAreaRect.Top );
const float ThumbnailScaleRangeScalar = ( DisplaySize.Y / 1080 );
// Create a thumbnail pool for rendering thumbnails
AssetThumbnailPool = MakeShareable( new FAssetThumbnailPool(1024, InArgs._AreRealTimeThumbnailsAllowed) );
NumOffscreenThumbnails = 64;
ListViewThumbnailResolution = 128;
ListViewThumbnailSize = 64;
ListViewThumbnailPadding = 4;
TileViewThumbnailResolution = 256;
TileViewThumbnailSize = 128;
TileViewThumbnailPadding = 5;
const bool bIsVREditorDemo = FParse::Param( FCommandLine::Get(), TEXT( "VREditorDemo" ) ); // @todo vreditor: Remove this when no longer needed
if( bIsVREditorDemo )
{
TileViewThumbnailPadding = 0;
}
TileViewNameHeight = 36;
ThumbnailScaleSliderValue = InArgs._ThumbnailScale;
if ( !ThumbnailScaleSliderValue.IsBound() )
{
ThumbnailScaleSliderValue = FMath::Clamp<float>(ThumbnailScaleSliderValue.Get(), 0.0f, 1.0f);
}
MinThumbnailScale = 0.2f * ThumbnailScaleRangeScalar;
MaxThumbnailScale = 2.0f * ThumbnailScaleRangeScalar;
bCanShowClasses = InArgs._CanShowClasses;
bCanShowFolders = InArgs._CanShowFolders;
bFilterRecursivelyWithBackendFilter = InArgs._FilterRecursivelyWithBackendFilter;
bCanShowRealTimeThumbnails = InArgs._CanShowRealTimeThumbnails;
bCanShowDevelopersFolder = InArgs._CanShowDevelopersFolder;
bCanShowCollections = InArgs._CanShowCollections;
bPreloadAssetsForContextMenu = InArgs._PreloadAssetsForContextMenu;
SelectionMode = InArgs._SelectionMode;
bShowPathInColumnView = InArgs._ShowPathInColumnView;
bShowTypeInColumnView = InArgs._ShowTypeInColumnView;
bSortByPathInColumnView = bShowPathInColumnView & InArgs._SortByPathInColumnView;
bPendingUpdateThumbnails = false;
CurrentThumbnailSize = TileViewThumbnailSize;
SourcesData = InArgs._InitialSourcesData;
BackendFilter = InArgs._InitialBackendFilter;
FrontendFilters = InArgs._FrontendFilters;
if ( FrontendFilters.IsValid() )
{
FrontendFilters->OnChanged().AddSP( this, &SAssetView::OnFrontendFiltersChanged );
}
OnShouldFilterAsset = InArgs._OnShouldFilterAsset;
OnAssetSelected = InArgs._OnAssetSelected;
OnAssetsActivated = InArgs._OnAssetsActivated;
OnGetAssetContextMenu = InArgs._OnGetAssetContextMenu;
OnGetFolderContextMenu = InArgs._OnGetFolderContextMenu;
OnGetPathContextMenuExtender = InArgs._OnGetPathContextMenuExtender;
OnFindInAssetTreeRequested = InArgs._OnFindInAssetTreeRequested;
OnAssetRenameCommitted = InArgs._OnAssetRenameCommitted;
OnAssetTagWantsToBeDisplayed = InArgs._OnAssetTagWantsToBeDisplayed;
OnGetCustomAssetToolTip = InArgs._OnGetCustomAssetToolTip;
OnVisualizeAssetToolTip = InArgs._OnVisualizeAssetToolTip;
OnAssetToolTipClosing = InArgs._OnAssetToolTipClosing;
HighlightedText = InArgs._HighlightedText;
ThumbnailLabel = InArgs._ThumbnailLabel;
AllowThumbnailHintLabel = InArgs._AllowThumbnailHintLabel;
AssetShowWarningText = InArgs._AssetShowWarningText;
bAllowDragging = InArgs._AllowDragging;
bAllowFocusOnSync = InArgs._AllowFocusOnSync;
OnPathSelected = InArgs._OnPathSelected;
if ( InArgs._InitialViewType >= 0 && InArgs._InitialViewType < EAssetViewType::MAX )
{
CurrentViewType = InArgs._InitialViewType;
}
else
{
CurrentViewType = EAssetViewType::Tile;
}
bPendingSortFilteredItems = false;
bQuickFrontendListRefreshRequested = false;
bSlowFullListRefreshRequested = false;
LastSortTime = 0;
SortDelaySeconds = 8;
LastProcessAddsTime = 0;
bBulkSelecting = false;
bAllowThumbnailEditMode = InArgs._AllowThumbnailEditMode;
bThumbnailEditMode = false;
bUserSearching = false;
bPendingFocusOnSync = false;
bWereItemsRecursivelyFiltered = false;
FEditorWidgetsModule& EditorWidgetsModule = FModuleManager::LoadModuleChecked<FEditorWidgetsModule>("EditorWidgets");
TSharedRef<SWidget> AssetDiscoveryIndicator = EditorWidgetsModule.CreateAssetDiscoveryIndicator(EAssetDiscoveryIndicatorScaleMode::Scale_Vertical);
TSharedRef<SVerticalBox> VerticalBox = SNew(SVerticalBox);
ChildSlot
[
VerticalBox
];
// Assets area
VerticalBox->AddSlot()
.FillHeight(1.f)
[
SNew( SVerticalBox )
+SVerticalBox::Slot()
.AutoHeight()
.Padding( 0, 0, 0, 0 )
[
SNew( SBox )
.HeightOverride( 2 )
[
SNew( SProgressBar )
.Percent( this, &SAssetView::GetIsWorkingProgressBarState )
.Style( FEditorStyle::Get(), "WorkingBar" )
.BorderPadding( FVector2D(0,0) )
]
]
+SVerticalBox::Slot()
.FillHeight(1.f)
.Padding( 0, 0, 0, 0 )
[
SNew(SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
// Container for the view types
SAssignNew(ViewContainer, SBorder)
.Padding(0)
.BorderImage(FEditorStyle::GetBrush("NoBorder"))
]
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Center)
.Padding(FMargin(0, 14, 0, 0))
[
// A warning to display when there are no assets to show
SNew( STextBlock )
.Justification( ETextJustify::Center )
.Text( this, &SAssetView::GetAssetShowWarningText )
.Visibility( this, &SAssetView::IsAssetShowWarningTextVisible )
.AutoWrapText( true )
]
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Bottom)
.Padding(FMargin(24, 0, 24, 0))
[
// Asset discovery indicator
AssetDiscoveryIndicator
]
+ SOverlay::Slot()
.HAlign(HAlign_Right)
.VAlign(VAlign_Bottom)
.Padding(FMargin(8, 0))
[
SNew(SBorder)
.BorderImage(FEditorStyle::GetBrush("ErrorReporting.EmptyBox"))
.BorderBackgroundColor(this, &SAssetView::GetQuickJumpColor)
.Visibility(this, &SAssetView::IsQuickJumpVisible)
[
SNew(STextBlock)
.Text(this, &SAssetView::GetQuickJumpTerm)
]
]
]
];
// Thumbnail edit mode banner
VerticalBox->AddSlot()
.AutoHeight()
.Padding(0, 4)
[
SNew(SBorder)
.Visibility( this, &SAssetView::GetEditModeLabelVisibility )
.BorderImage( FEditorStyle::GetBrush("ContentBrowser.EditModeLabelBorder") )
.Content()
[
SNew( SHorizontalBox )
+SHorizontalBox::Slot()
.VAlign(VAlign_Center)
.Padding(4, 0, 0, 0)
.FillWidth(1.f)
[
SNew(STextBlock)
.Text(LOCTEXT("ThumbnailEditModeLabel", "Editing Thumbnails. Drag a thumbnail to rotate it if there is a 3D environment."))
.TextStyle( FEditorStyle::Get(), "ContentBrowser.EditModeLabelFont" )
]
+SHorizontalBox::Slot()
.AutoWidth()
.VAlign(VAlign_Center)
[
SNew(SButton)
.Text( LOCTEXT("EndThumbnailEditModeButton", "Done Editing") )
.OnClicked( this, &SAssetView::EndThumbnailEditModeClicked )
]
]
];
if (InArgs._ShowBottomToolbar)
{
//// Separator
//VerticalBox->AddSlot()
//.AutoHeight()
//.Padding(0, 0, 0, 1)
//[
// SNew(SSeparator)
//];
// Bottom panel
VerticalBox->AddSlot()
.AutoHeight()
[
SNew(SHorizontalBox)
// Asset count
+SHorizontalBox::Slot()
.FillWidth(1.f)
.VAlign(VAlign_Center)
.Padding(8, 0)
[
SNew(STextBlock) .Text(this, &SAssetView::GetAssetCountText)
]
// View mode combo button
+SHorizontalBox::Slot()
.AutoWidth()
[
SAssignNew( ViewOptionsComboButton, SComboButton )
.ContentPadding(0)
.ForegroundColor( this, &SAssetView::GetViewButtonForegroundColor )
.ButtonStyle( FEditorStyle::Get(), "ToggleButton" ) // Use the tool bar item style for this button
.OnGetMenuContent( this, &SAssetView::GetViewButtonContent )
.ButtonContent()
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.AutoWidth()
.VAlign(VAlign_Center)
[
SNew(SImage).Image( FEditorStyle::GetBrush("GenericViewButton") )
]
+SHorizontalBox::Slot()
.AutoWidth()
.Padding(2, 0, 0, 0)
.VAlign(VAlign_Center)
[
SNew(STextBlock).Text( LOCTEXT("ViewButton", "View Options") )
]
]
]
];
}
CreateCurrentView();
if( InArgs._InitialAssetSelection.IsValid() )
{
// sync to the initial item without notifying of selection
TArray<FAssetData> AssetsToSync;
AssetsToSync.Add( InArgs._InitialAssetSelection );
SyncToAssets( AssetsToSync );
}
// If currently looking at column, and you could choose to sort by path in column first and then name
// Generalizing this is a bit difficult because the column ID is not accessible or is not known
// Currently I assume this won't work, if this view mode is not column. Otherwise, I don't think sorting by path
// is a good idea.
if (CurrentViewType == EAssetViewType::Column && bSortByPathInColumnView)
{
SortManager.SetSortColumnId(EColumnSortPriority::Primary, SortManager.PathColumnId);
SortManager.SetSortColumnId(EColumnSortPriority::Secondary, SortManager.NameColumnId);
SortManager.SetSortMode(EColumnSortPriority::Primary, EColumnSortMode::Ascending);
SortManager.SetSortMode(EColumnSortPriority::Secondary, EColumnSortMode::Ascending);
SortList();
}
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
TOptional< float > SAssetView::GetIsWorkingProgressBarState() const
{
return bIsWorking ? TOptional< float >() : 0.0f;
}
void SAssetView::SetSourcesData(const FSourcesData& InSourcesData)
{
// Update the path and collection lists
SourcesData = InSourcesData;
RequestSlowFullListRefresh();
ClearSelection();
}
const FSourcesData& SAssetView::GetSourcesData() const
{
return SourcesData;
}
bool SAssetView::IsAssetPathSelected() const
{
int32 NumAssetPaths, NumClassPaths;
ContentBrowserUtils::CountPathTypes(SourcesData.PackagePaths, NumAssetPaths, NumClassPaths);
// Check that only asset paths are selected
return NumAssetPaths > 0 && NumClassPaths == 0;
}
void SAssetView::SetBackendFilter(const FARFilter& InBackendFilter)
{
// Update the path and collection lists
BackendFilter = InBackendFilter;
RequestSlowFullListRefresh();
}
void SAssetView::OnCreateNewFolder(const FString& FolderName, const FString& FolderPath)
{
// we should only be creating one deferred folder per tick
check(!DeferredFolderToCreate.IsValid());
// Make sure we are showing the location of the new folder (we may have created it in a folder)
OnPathSelected.Execute(FolderPath);
DeferredFolderToCreate = MakeShareable(new FCreateDeferredFolderData());
DeferredFolderToCreate->FolderName = FolderName;
DeferredFolderToCreate->FolderPath = FolderPath;
}
void SAssetView::DeferredCreateNewFolder()
{
if(DeferredFolderToCreate.IsValid())
{
TSharedPtr<FAssetViewFolder> NewItem = MakeShareable(new FAssetViewFolder(DeferredFolderToCreate->FolderPath / DeferredFolderToCreate->FolderName));
NewItem->bNewFolder = true;
NewItem->bRenameWhenScrolledIntoview = true;
FilteredAssetItems.Insert( NewItem, 0 );
SetSelection(NewItem);
RequestScrollIntoView(NewItem);
DeferredFolderToCreate.Reset();
}
}
void SAssetView::CreateNewAsset(const FString& DefaultAssetName, const FString& PackagePath, UClass* AssetClass, UFactory* Factory)
{
if ( !ensure(AssetClass || Factory) )
{
return;
}
if ( AssetClass && Factory && !ensure(AssetClass->IsChildOf(Factory->GetSupportedClass())) )
{
return;
}
// we should only be creating one deferred asset per tick
check(!DeferredAssetToCreate.IsValid());
// Make sure we are showing the location of the new asset (we may have created it in a folder)
OnPathSelected.Execute(PackagePath);
// Defer asset creation until next tick, so we get a chance to refresh the view
DeferredAssetToCreate = MakeShareable(new FCreateDeferredAssetData());
DeferredAssetToCreate->DefaultAssetName = DefaultAssetName;
DeferredAssetToCreate->PackagePath = PackagePath;
DeferredAssetToCreate->AssetClass = AssetClass;
DeferredAssetToCreate->Factory = Factory;
}
void SAssetView::DeferredCreateNewAsset()
{
if(DeferredAssetToCreate.IsValid())
{
FString PackageNameStr = DeferredAssetToCreate->PackagePath + "/" + DeferredAssetToCreate->DefaultAssetName;
FName PackageName = FName(*PackageNameStr);
FName PackagePathFName = FName(*DeferredAssetToCreate->PackagePath);
FName AssetName = FName(*DeferredAssetToCreate->DefaultAssetName);
FName AssetClassName = DeferredAssetToCreate->AssetClass->GetFName();
TMap<FName, FString> EmptyTags;
TArray<int32> EmptyChunkIDs;
const uint32 EmptyPackageFlags = 0;
FAssetData NewAssetData(PackageName, PackagePathFName, NAME_None, AssetName, AssetClassName, EmptyTags, EmptyChunkIDs, EmptyPackageFlags);
TSharedPtr<FAssetViewItem> NewItem = MakeShareable(new FAssetViewCreation(NewAssetData, DeferredAssetToCreate->AssetClass, DeferredAssetToCreate->Factory));
NewItem->bRenameWhenScrolledIntoview = true;
FilteredAssetItems.Insert( NewItem, 0 );
SortManager.SortList(FilteredAssetItems, MajorityAssetType);
SetSelection(NewItem);
RequestScrollIntoView(NewItem);
FEditorDelegates::OnNewAssetCreated.Broadcast(DeferredAssetToCreate->Factory);
DeferredAssetToCreate.Reset();
}
}
void SAssetView::DuplicateAsset(const FString& PackagePath, const TWeakObjectPtr<UObject>& OriginalObject)
{
if ( !ensure(OriginalObject.IsValid()) )
{
return;
}
FString AssetNameStr;
FString PackageNameStr;
// Find a unique default name for the duplicated asset
static FName AssetToolsModuleName = FName("AssetTools");
FAssetToolsModule& AssetToolsModule = FModuleManager::GetModuleChecked<FAssetToolsModule>(AssetToolsModuleName);
AssetToolsModule.Get().CreateUniqueAssetName(PackagePath + TEXT("/") + OriginalObject->GetName(), TEXT(""), PackageNameStr, AssetNameStr);
FName PackageName = FName(*PackageNameStr);
FName PackagePathFName = FName(*PackagePath);
FName AssetName = FName(*AssetNameStr);
FName AssetClass = OriginalObject->GetClass()->GetFName();
TMap<FName, FString> EmptyTags;
TArray<int32> EmptyChunkIDs;
const uint32 EmptyPackageFlags = 0;
FAssetData NewAssetData(PackageName, PackagePathFName, NAME_None, AssetName, AssetClass, EmptyTags, EmptyChunkIDs, EmptyPackageFlags);
TSharedPtr<FAssetViewItem> NewItem = MakeShareable(new FAssetViewDuplication(NewAssetData, OriginalObject));
NewItem->bRenameWhenScrolledIntoview = true;
// Insert into the list and sort
FilteredAssetItems.Insert( NewItem, 0 );
SortManager.SortList(FilteredAssetItems, MajorityAssetType);
SetSelection(NewItem);
RequestScrollIntoView(NewItem);
}
void SAssetView::RenameAsset(const FAssetData& ItemToRename)
{
for ( auto ItemIt = FilteredAssetItems.CreateConstIterator(); ItemIt; ++ItemIt )
{
const TSharedPtr<FAssetViewItem>& Item = *ItemIt;
if ( Item.IsValid() && Item->GetType() != EAssetItemType::Folder )
{
const TSharedPtr<FAssetViewAsset>& ItemAsAsset = StaticCastSharedPtr<FAssetViewAsset>(Item);
if ( ItemAsAsset->Data.ObjectPath == ItemToRename.ObjectPath )
{
ItemAsAsset->bRenameWhenScrolledIntoview = true;
SetSelection(Item);
RequestScrollIntoView(Item);
break;
}
}
}
}
void SAssetView::RenameFolder(const FString& FolderToRename)
{
for ( auto ItemIt = FilteredAssetItems.CreateConstIterator(); ItemIt; ++ItemIt )
{
const TSharedPtr<FAssetViewItem>& Item = *ItemIt;
if ( Item.IsValid() && Item->GetType() == EAssetItemType::Folder )
{
const TSharedPtr<FAssetViewFolder>& ItemAsFolder = StaticCastSharedPtr<FAssetViewFolder>(Item);
if ( ItemAsFolder->FolderPath == FolderToRename )
{
ItemAsFolder->bRenameWhenScrolledIntoview = true;
SetSelection(Item);
RequestScrollIntoView(Item);
break;
}
}
}
}
void SAssetView::SyncToAssets( const TArray<FAssetData>& AssetDataList, const bool bFocusOnSync )
{
PendingSyncAssets.Empty();
for ( auto AssetIt = AssetDataList.CreateConstIterator(); AssetIt; ++AssetIt )
{
PendingSyncAssets.Add(AssetIt->ObjectPath);
}
bPendingFocusOnSync = bFocusOnSync;
}
void SAssetView::ApplyHistoryData ( const FHistoryData& History )
{
SetSourcesData(History.SourcesData);
PendingSyncAssets = History.SelectedAssets;
bPendingFocusOnSync = true;
}
TArray<TSharedPtr<FAssetViewItem>> SAssetView::GetSelectedItems() const
{
switch ( GetCurrentViewType() )
{
case EAssetViewType::List: return ListView->GetSelectedItems();
case EAssetViewType::Tile: return TileView->GetSelectedItems();
case EAssetViewType::Column: return ColumnView->GetSelectedItems();
default:
ensure(0); // Unknown list type
return TArray<TSharedPtr<FAssetViewItem>>();
}
}
TArray<FAssetData> SAssetView::GetSelectedAssets() const
{
TArray<TSharedPtr<FAssetViewItem>> SelectedItems = GetSelectedItems();
TArray<FAssetData> SelectedAssets;
for ( auto ItemIt = SelectedItems.CreateConstIterator(); ItemIt; ++ItemIt )
{
const TSharedPtr<FAssetViewItem>& Item = *ItemIt;
// Only report non-temporary & non-folder items
if ( Item.IsValid() && !Item->IsTemporaryItem() && Item->GetType() != EAssetItemType::Folder )
{
SelectedAssets.Add(StaticCastSharedPtr<FAssetViewAsset>(Item)->Data);
}
}
return SelectedAssets;
}
TArray<FString> SAssetView::GetSelectedFolders() const
{
TArray<TSharedPtr<FAssetViewItem>> SelectedItems = GetSelectedItems();
TArray<FString> SelectedFolders;
for ( auto ItemIt = SelectedItems.CreateConstIterator(); ItemIt; ++ItemIt )
{
const TSharedPtr<FAssetViewItem>& Item = *ItemIt;
if ( Item.IsValid() && Item->GetType() == EAssetItemType::Folder )
{
SelectedFolders.Add(StaticCastSharedPtr<FAssetViewFolder>(Item)->FolderPath);
}
}
return SelectedFolders;
}
void SAssetView::RequestSlowFullListRefresh()
{
bSlowFullListRefreshRequested = true;
}
void SAssetView::RequestQuickFrontendListRefresh()
{
bQuickFrontendListRefreshRequested = true;
}
void SAssetView::RequestAddNewAssetsNextFrame()
{
LastProcessAddsTime = FPlatformTime::Seconds() - TimeBetweenAddingNewAssets;
}
FString SAssetView::GetThumbnailScaleSettingPath(const FString& SettingsString) const
{
return SettingsString + TEXT(".ThumbnailSizeScale");
}
FString SAssetView::GetCurrentViewTypeSettingPath(const FString& SettingsString) const
{
return SettingsString + TEXT(".CurrentViewType");
}
void SAssetView::SaveSettings(const FString& IniFilename, const FString& IniSection, const FString& SettingsString) const
{
GConfig->SetFloat(*IniSection, *GetThumbnailScaleSettingPath(SettingsString), ThumbnailScaleSliderValue.Get(), IniFilename);
GConfig->SetInt(*IniSection, *GetCurrentViewTypeSettingPath(SettingsString), CurrentViewType, IniFilename);
}
void SAssetView::LoadSettings(const FString& IniFilename, const FString& IniSection, const FString& SettingsString)
{
float Scale = 0.f;
if ( GConfig->GetFloat(*IniSection, *GetThumbnailScaleSettingPath(SettingsString), Scale, IniFilename) )
{
// Clamp value to normal range and update state
Scale = FMath::Clamp<float>(Scale, 0.f, 1.f);
SetThumbnailScale(Scale);
}
int32 ViewType = EAssetViewType::Tile;
if ( GConfig->GetInt(*IniSection, *GetCurrentViewTypeSettingPath(SettingsString), ViewType, IniFilename) )
{
// Clamp value to normal range and update state
if ( ViewType < 0 || ViewType >= EAssetViewType::MAX)
{
ViewType = EAssetViewType::Tile;
}
SetCurrentViewType( (EAssetViewType::Type)ViewType );
}
}
// Adjusts the selected asset by the selection delta, which should be +1 or -1)
void SAssetView::AdjustActiveSelection(int32 SelectionDelta)
{
// Find the index of the first selected item
TArray<TSharedPtr<FAssetViewItem>> SelectionSet = GetSelectedItems();
int32 SelectedSuggestion = INDEX_NONE;
if (SelectionSet.Num() > 0)
{
if (!FilteredAssetItems.Find(SelectionSet[0], /*out*/ SelectedSuggestion))
{
// Should never happen
ensureMsgf(false, TEXT("SAssetView has a selected item that wasn't in the filtered list"));
return;
}
}
else
{
SelectedSuggestion = 0;
SelectionDelta = 0;
}
if (FilteredAssetItems.Num() > 0)
{
// Move up or down one, wrapping around
SelectedSuggestion = (SelectedSuggestion + SelectionDelta + FilteredAssetItems.Num()) % FilteredAssetItems.Num();
// Pick the new asset
const TSharedPtr<FAssetViewItem>& NewSelection = FilteredAssetItems[SelectedSuggestion];
RequestScrollIntoView(NewSelection);
SetSelection(NewSelection);
}
else
{
ClearSelection();
}
}
void SAssetView::ProcessRecentlyLoadedOrChangedAssets()
{
if ( RecentlyLoadedOrChangedAssets.Num() > 0 )
{
TMap< FName, TWeakObjectPtr<UObject> > NextRecentlyLoadedOrChangedMap = RecentlyLoadedOrChangedAssets;
for (int32 AssetIdx = FilteredAssetItems.Num() - 1; AssetIdx >= 0; --AssetIdx)
{
if(FilteredAssetItems[AssetIdx]->GetType() != EAssetItemType::Folder)
{
const TSharedPtr<FAssetViewAsset>& ItemAsAsset = StaticCastSharedPtr<FAssetViewAsset>(FilteredAssetItems[AssetIdx]);
const FName ObjectPath = ItemAsAsset->Data.ObjectPath;
const TWeakObjectPtr<UObject>* WeakAssetPtr = RecentlyLoadedOrChangedAssets.Find( ObjectPath );
if ( WeakAssetPtr && (*WeakAssetPtr).IsValid() )
{
NextRecentlyLoadedOrChangedMap.Remove(ObjectPath);
// Found the asset in the filtered items list, update it
const UObject* Asset = (*WeakAssetPtr).Get();
FAssetData AssetData(Asset);
bool bShouldRemoveAsset = false;
TArray<FAssetData> AssetDataThatPassesFilter;
AssetDataThatPassesFilter.Add(AssetData);
RunAssetsThroughBackendFilter(AssetDataThatPassesFilter);
if ( AssetDataThatPassesFilter.Num() == 0 )
{
bShouldRemoveAsset = true;
}
if ( !bShouldRemoveAsset && OnShouldFilterAsset.IsBound() && OnShouldFilterAsset.Execute(AssetData) )
{
bShouldRemoveAsset = true;
}
if ( !bShouldRemoveAsset && (IsFrontendFilterActive() && !PassesCurrentFrontendFilter(AssetData)) )
{
bShouldRemoveAsset = true;
}
if ( bShouldRemoveAsset )
{
FilteredAssetItems.RemoveAt(AssetIdx);
}
else
{
// Update the asset data on the item
ItemAsAsset->SetAssetData( AssetData );
}
RefreshList();
}
}
}
if( FilteredRecentlyAddedAssets.Num() > 0 || RecentlyAddedAssets.Num() > 0 )
{
//Keep unprocessed items as we are still processing assets
RecentlyLoadedOrChangedAssets = NextRecentlyLoadedOrChangedMap;
}
else
{
//No more assets coming in so if we haven't found them now we aren't going to
RecentlyLoadedOrChangedAssets.Empty();
}
}
}
void SAssetView::Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
{
CalculateFillScale( AllottedGeometry );
CurrentTime = InCurrentTime;
// If there were any assets that were recently added via the asset registry, process them now
ProcessRecentlyAddedAssets();
// If there were any assets loaded since last frame that we are currently displaying thumbnails for, push them on the render stack now.
ProcessRecentlyLoadedOrChangedAssets();
CalculateThumbnailHintColorAndOpacity();
if ( bPendingUpdateThumbnails )
{
UpdateThumbnails();
bPendingUpdateThumbnails = false;
}
if ( bSlowFullListRefreshRequested || bQuickFrontendListRefreshRequested )
{
ResetQuickJump();
if ( bSlowFullListRefreshRequested )
{
RefreshSourceItems();
}
RefreshFilteredItems();
RefreshFolders();
// Don't sync to selection if we are just going to do it below
SortList(!PendingSyncAssets.Num());
bSlowFullListRefreshRequested = false;
bQuickFrontendListRefreshRequested = false;
}
if ( QueriedAssetItems.Num() > 0 )
{
check( OnShouldFilterAsset.IsBound() );
double TickStartTime = FPlatformTime::Seconds();
// Mark the first amortize time
if ( AmortizeStartTime == 0 )
{
AmortizeStartTime = FPlatformTime::Seconds();
bIsWorking = true;
}
ProcessQueriedItems( TickStartTime );
if ( QueriedAssetItems.Num() == 0 )
{
TotalAmortizeTime += FPlatformTime::Seconds() - AmortizeStartTime;
AmortizeStartTime = 0;
bIsWorking = false;
}
}
if ( PendingSyncAssets.Num() )
{
if (bPendingSortFilteredItems)
{
// Don't sync to selection because we are just going to do it below
SortList(/*bSyncToSelection=*/false);
}
bBulkSelecting = true;
ClearSelection();
bool bFoundScrollIntoViewTarget = false;
for ( auto ItemIt = FilteredAssetItems.CreateConstIterator(); ItemIt; ++ItemIt )
{
const auto& Item = *ItemIt;
if(Item.IsValid() && Item->GetType() != EAssetItemType::Folder)
{
const TSharedPtr<FAssetViewAsset>& ItemAsAsset = StaticCastSharedPtr<FAssetViewAsset>(Item);
if ( PendingSyncAssets.Contains(ItemAsAsset->Data.ObjectPath) )
{
SetItemSelection(*ItemIt, true, ESelectInfo::OnNavigation);
// Scroll the first item in the list that can be shown into view
if ( !bFoundScrollIntoViewTarget )
{
RequestScrollIntoView(Item);
bFoundScrollIntoViewTarget = true;
}
}
}
}
bBulkSelecting = false;
PendingSyncAssets.Empty();
if (bAllowFocusOnSync && bPendingFocusOnSync)
{
FocusList();
}
}
if ( IsHovered() )
{
// This prevents us from sorting the view immediately after the cursor leaves it
LastSortTime = CurrentTime;
}
else if ( bPendingSortFilteredItems && InCurrentTime > LastSortTime + SortDelaySeconds )
{
SortList();
}
// create any assets & folders we need to now
DeferredCreateNewAsset();
DeferredCreateNewFolder();
// Do quick-jump last as the Tick function might have canceled it
if(QuickJumpData.bHasChangedSinceLastTick)
{
QuickJumpData.bHasChangedSinceLastTick = false;
const bool bWasJumping = QuickJumpData.bIsJumping;
QuickJumpData.bIsJumping = true;
QuickJumpData.LastJumpTime = InCurrentTime;
QuickJumpData.bHasValidMatch = PerformQuickJump(bWasJumping);
}
else if(QuickJumpData.bIsJumping && InCurrentTime > QuickJumpData.LastJumpTime + JumpDelaySeconds)
{
ResetQuickJump();
}
TSharedPtr<FAssetViewItem> AssetAwaitingRename = AwaitingRename.Pin();
if (AssetAwaitingRename.IsValid())
{
TSharedPtr<SWindow> OwnerWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
if (!OwnerWindow.IsValid())
{
AssetAwaitingRename->bRenameWhenScrolledIntoview = false;
AwaitingRename = nullptr;
}
else if (OwnerWindow->HasAnyUserFocusOrFocusedDescendants())
{
AssetAwaitingRename->RenamedRequestEvent.ExecuteIfBound();
AssetAwaitingRename->bRenameWhenScrolledIntoview = false;
AwaitingRename = nullptr;
}
}
}
void SAssetView::CalculateFillScale( const FGeometry& AllottedGeometry )
{
if ( bFillEmptySpaceInTileView && CurrentViewType == EAssetViewType::Tile )
{
float ItemWidth = GetTileViewItemBaseWidth();
const bool bIsVREditorDemo = FParse::Param( FCommandLine::Get(), TEXT( "VREditorDemo" ) ); // @todo vreditor: Remove this when no longer needed
if( bIsVREditorDemo )
{
ItemWidth /= AllottedGeometry.Scale;
}
// Scrollbars are 16, but we add 1 to deal with half pixels.
const float ScrollbarWidth = 16 + 1;
float TotalWidth = AllottedGeometry.Size.X - ( ScrollbarWidth / AllottedGeometry.Scale );
float Coverage = TotalWidth / ItemWidth;
int32 Items = (int)( TotalWidth / ItemWidth );
// If there isn't enough room to support even a single item, don't apply a fill scale.
if ( Items > 0 )
{
float GapSpace = ItemWidth * ( Coverage - Items );
float ExpandAmount = GapSpace / (float)Items;
FillScale = ( ItemWidth + ExpandAmount ) / ItemWidth;
FillScale = FMath::Max( 1.0f, FillScale );
}
else
{
FillScale = 1.0f;
}
}
else
{
FillScale = 1.0f;
}
}
void SAssetView::CalculateThumbnailHintColorAndOpacity()
{
if ( HighlightedText.Get().IsEmpty() )
{
if ( ThumbnailHintFadeInSequence.IsPlaying() )
{
if ( ThumbnailHintFadeInSequence.IsForward() )
{
ThumbnailHintFadeInSequence.Reverse();
}
}
else if ( ThumbnailHintFadeInSequence.IsAtEnd() )
{
ThumbnailHintFadeInSequence.PlayReverse(this->AsShared());
}
}
else
{
if ( ThumbnailHintFadeInSequence.IsPlaying() )
{
if ( ThumbnailHintFadeInSequence.IsInReverse() )
{
ThumbnailHintFadeInSequence.Reverse();
}
}
else if ( ThumbnailHintFadeInSequence.IsAtStart() )
{
ThumbnailHintFadeInSequence.Play(this->AsShared());
}
}
const float Opacity = ThumbnailHintFadeInSequence.GetLerp();
ThumbnailHintColorAndOpacity = FLinearColor( 1.0, 1.0, 1.0, Opacity );
}
void SAssetView::ProcessQueriedItems( const double TickStartTime )
{
const bool bFlushFullBuffer = TickStartTime < 0;
bool ListNeedsRefresh = false;
int32 AssetIndex = 0;
for ( AssetIndex = QueriedAssetItems.Num() - 1; AssetIndex >= 0 ; AssetIndex--)
{
if ( !OnShouldFilterAsset.Execute( QueriedAssetItems[AssetIndex] ) )
{
AssetItems.Add( QueriedAssetItems[AssetIndex] );
if ( !IsFrontendFilterActive() )
{
const FAssetData& AssetData = QueriedAssetItems[AssetIndex];
FilteredAssetItems.Add(MakeShareable(new FAssetViewAsset(AssetData)));
ListNeedsRefresh = true;
bPendingSortFilteredItems = true;
}
else if ( PassesCurrentFrontendFilter( QueriedAssetItems[AssetIndex] ) )
{
const FAssetData& AssetData = QueriedAssetItems[AssetIndex];
FilteredAssetItems.Add(MakeShareable(new FAssetViewAsset(AssetData)));
ListNeedsRefresh = true;
bPendingSortFilteredItems = true;
}
}
// Check to see if we have run out of time in this tick
if ( !bFlushFullBuffer && (FPlatformTime::Seconds() - TickStartTime) > MaxSecondsPerFrame)
{
break;
}
}
// Trim the results array
if (AssetIndex > 0)
{
QueriedAssetItems.RemoveAt( AssetIndex, QueriedAssetItems.Num() - AssetIndex );
}
else
{
QueriedAssetItems.Empty();
}
if ( ListNeedsRefresh )
{
RefreshList();
}
}
void SAssetView::OnDragLeave( const FDragDropEvent& DragDropEvent )
{
TSharedPtr< FAssetDragDropOp > AssetDragDropOp = DragDropEvent.GetOperationAs< FAssetDragDropOp >();
if( AssetDragDropOp.IsValid() )
{
AssetDragDropOp->ResetToDefaultToolTip();
return;
}
TSharedPtr<FDragDropOperation> DragDropOp = DragDropEvent.GetOperation();
if (DragDropOp.IsValid())
{
// Do we have a custom handler for this drag event?
FContentBrowserModule& ContentBrowserModule = FModuleManager::GetModuleChecked<FContentBrowserModule>("ContentBrowser");
const TArray<FAssetViewDragAndDropExtender>& AssetViewDragAndDropExtenders = ContentBrowserModule.GetAssetViewDragAndDropExtenders();
for (const auto& AssetViewDragAndDropExtender : AssetViewDragAndDropExtenders)
{
if (AssetViewDragAndDropExtender.OnDragLeaveDelegate.IsBound() && AssetViewDragAndDropExtender.OnDragLeaveDelegate.Execute(FAssetViewDragAndDropExtender::FPayload(DragDropOp, SourcesData.PackagePaths, SourcesData.Collections)))
{
return;
}
}
}
}
FReply SAssetView::OnDragOver( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
{
TSharedPtr< FExternalDragOperation > ExternalDragDropOp = DragDropEvent.GetOperationAs< FExternalDragOperation >();
if ( ExternalDragDropOp.IsValid() )
{
if ( ExternalDragDropOp->HasFiles() )
{
return FReply::Handled();
}
}
else if ( HasSingleCollectionSource() )
{
TArray< FAssetData > AssetDatas = AssetUtil::ExtractAssetDataFromDrag( DragDropEvent );
if ( AssetDatas.Num() > 0 )
{
TSharedPtr< FAssetDragDropOp > AssetDragDropOp = DragDropEvent.GetOperationAs< FAssetDragDropOp >();
if( AssetDragDropOp.IsValid() )
{
TArray< FName > ObjectPaths;
FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
const FCollectionNameType& Collection = SourcesData.Collections[0];
CollectionManagerModule.Get().GetObjectsInCollection( Collection.Name, Collection.Type, ObjectPaths );
bool IsValidDrop = false;
for (const auto& AssetData : AssetDatas)
{
if (AssetData.GetClass()->IsChildOf(UClass::StaticClass()))
{
continue;
}
if ( !ObjectPaths.Contains( AssetData.ObjectPath ) )
{
IsValidDrop = true;
break;
}
}
if ( IsValidDrop )
{
AssetDragDropOp->SetToolTip( NSLOCTEXT( "AssetView", "OnDragOverCollection", "Add to Collection" ), FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.OK"))) ;
}
}
return FReply::Handled();
}
}
TSharedPtr<FDragDropOperation> DragDropOp = DragDropEvent.GetOperation();
if (DragDropOp.IsValid())
{
// Do we have a custom handler for this drag event?
FContentBrowserModule& ContentBrowserModule = FModuleManager::GetModuleChecked<FContentBrowserModule>("ContentBrowser");
const TArray<FAssetViewDragAndDropExtender>& AssetViewDragAndDropExtenders = ContentBrowserModule.GetAssetViewDragAndDropExtenders();
for (const auto& AssetViewDragAndDropExtender : AssetViewDragAndDropExtenders)
{
if (AssetViewDragAndDropExtender.OnDragOverDelegate.IsBound() && AssetViewDragAndDropExtender.OnDragOverDelegate.Execute(FAssetViewDragAndDropExtender::FPayload(DragDropOp, SourcesData.PackagePaths, SourcesData.Collections)))
{
return FReply::Handled();
}
}
}
return FReply::Unhandled();
}
FReply SAssetView::OnDrop( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
{
// Handle drag drop for import
if ( IsAssetPathSelected() )
{
TSharedPtr<FExternalDragOperation> ExternalDragDropOp = DragDropEvent.GetOperationAs<FExternalDragOperation>();
if (ExternalDragDropOp.IsValid())
{
if ( ExternalDragDropOp->HasFiles() )
{
TArray<FString> ImportFiles;
TMap<FString, UObject*> ReimportFiles;
FAssetToolsModule& AssetToolsModule = FModuleManager::Get().LoadModuleChecked<FAssetToolsModule>("AssetTools");
FString RootDestinationPath = SourcesData.PackagePaths[0].ToString();
TArray<TPair<FString, FString>> FilesAndDestinations;
const TArray<FString>& DragFiles = ExternalDragDropOp->GetFiles();
AssetToolsModule.Get().ExpandDirectories(DragFiles, RootDestinationPath, FilesAndDestinations);
for (int32 FileIdx = 0; FileIdx < FilesAndDestinations.Num(); ++FileIdx)
{
const FString& Filename = FilesAndDestinations[FileIdx].Key;
const FString& DestinationPath = FilesAndDestinations[FileIdx].Value;
FString Name = ObjectTools::SanitizeObjectName(FPaths::GetBaseFilename(Filename));
FString PackageName = DestinationPath + TEXT("/") + Name;
// We can not create assets that share the name of a map file in the same location
if (FEditorFileUtils::IsMapPackageAsset(PackageName))
{
//The error message will be log in the import process
ImportFiles.Add(Filename);
continue;
}
//Check if package exist in memory
UPackage* Pkg = FindPackage(nullptr, *PackageName);
bool IsPkgExist = Pkg != nullptr;
//check if package exist on file
if (!IsPkgExist && !FPackageName::DoesPackageExist(PackageName))
{
ImportFiles.Add(Filename);
continue;
}
if (Pkg == nullptr)
{
Pkg = CreatePackage(nullptr, *PackageName);
if (Pkg == nullptr)
{
//Cannot create a package that don't exist on disk or in memory!!!
//The error message will be log in the import process
ImportFiles.Add(Filename);
continue;
}
}
// Make sure the destination package is loaded
Pkg->FullyLoad();
// Check for an existing object
UObject* ExistingObject = StaticFindObject(UObject::StaticClass(), Pkg, *Name);
if (ExistingObject != nullptr)
{
ReimportFiles.Add(Filename, ExistingObject);
}
else
{
ImportFiles.Add(Filename);
}
}
//Reimport
for (auto kvp : ReimportFiles)
{
FReimportManager::Instance()->Reimport(kvp.Value, false, true, kvp.Key);
}
//Import
if (ImportFiles.Num() > 0)
{
AssetToolsModule.Get().ImportAssets(ImportFiles, SourcesData.PackagePaths[0].ToString());
}
}
return FReply::Handled();
}
}
else if ( HasSingleCollectionSource() )
{
TArray< FAssetData > SelectedAssetDatas = AssetUtil::ExtractAssetDataFromDrag( DragDropEvent );
if ( SelectedAssetDatas.Num() > 0 )
{
TArray< FName > ObjectPaths;
for (const auto& AssetData : SelectedAssetDatas)
{
if (!AssetData.GetClass()->IsChildOf(UClass::StaticClass()))
{
ObjectPaths.Add(AssetData.ObjectPath);
}
}
if (ObjectPaths.Num() > 0)
{
FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
const FCollectionNameType& Collection = SourcesData.Collections[0];
CollectionManagerModule.Get().AddToCollection(Collection.Name, Collection.Type, ObjectPaths);
}
return FReply::Handled();
}
}
TSharedPtr<FDragDropOperation> DragDropOp = DragDropEvent.GetOperation();
if (DragDropOp.IsValid())
{
// Do we have a custom handler for this drag event?
FContentBrowserModule& ContentBrowserModule = FModuleManager::GetModuleChecked<FContentBrowserModule>("ContentBrowser");
const TArray<FAssetViewDragAndDropExtender>& AssetViewDragAndDropExtenders = ContentBrowserModule.GetAssetViewDragAndDropExtenders();
for (const auto& AssetViewDragAndDropExtender : AssetViewDragAndDropExtenders)
{
if (AssetViewDragAndDropExtender.OnDropDelegate.IsBound() && AssetViewDragAndDropExtender.OnDropDelegate.Execute(FAssetViewDragAndDropExtender::FPayload(DragDropOp, SourcesData.PackagePaths, SourcesData.Collections)))
{
return FReply::Handled();
}
}
}
return FReply::Unhandled();
}
FReply SAssetView::OnKeyChar( const FGeometry& MyGeometry,const FCharacterEvent& InCharacterEvent )
{
const bool bTestOnly = false;
if(HandleQuickJumpKeyDown(InCharacterEvent.GetCharacter(), InCharacterEvent.IsControlDown(), InCharacterEvent.IsAltDown(), bTestOnly).IsEventHandled())
{
return FReply::Handled();
}
// If the user pressed a key we couldn't handle, reset the quick-jump search
ResetQuickJump();
return FReply::Unhandled();
}
static bool IsValidObjectPath(const FString& Path)
{
int32 NameStartIndex = INDEX_NONE;
Path.FindChar(TCHAR('\''), NameStartIndex);
if (NameStartIndex != INDEX_NONE)
{
int32 NameEndIndex = INDEX_NONE;
Path.FindLastChar(TCHAR('\''), NameEndIndex);
if (NameEndIndex > NameStartIndex)
{
const FString ClassName = Path.Left(NameStartIndex);
const FString PathName = Path.Mid(NameStartIndex + 1, NameEndIndex - NameStartIndex - 1);
UClass* Class = FindObject<UClass>(ANY_PACKAGE, *ClassName, true);
if (Class)
{
return FPackageName::IsValidLongPackageName(FPackageName::ObjectPathToPackageName(PathName));
}
}
}
return false;
}
FReply SAssetView::OnKeyDown( const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent )
{
if (InKeyEvent.IsControlDown() && InKeyEvent.GetCharacter() == 'V' && IsAssetPathSelected())
{
FString AssetPaths;
TArray<FString> AssetPathsSplit;
// Get the copied asset paths
FPlatformMisc::ClipboardPaste(AssetPaths);
AssetPaths.ParseIntoArrayLines(AssetPathsSplit);
// Get assets and copy them
TArray<UObject*> AssetsToCopy;
for (const FString& AssetPath : AssetPathsSplit)
{
// Validate string
if (IsValidObjectPath(AssetPath))
{
UObject* ObjectToCopy = LoadObject<UObject>(nullptr, *AssetPath);
if (ObjectToCopy && !ObjectToCopy->IsA(UClass::StaticClass()))
{
AssetsToCopy.Add(ObjectToCopy);
}
}
}
if (AssetsToCopy.Num())
{
ContentBrowserUtils::CopyAssets(AssetsToCopy, SourcesData.PackagePaths[0].ToString());
}
return FReply::Handled();
}
// Swallow the key-presses used by the quick-jump in OnKeyChar to avoid other things (such as the viewport commands) getting them instead
// eg) Pressing "W" without this would set the viewport to "translate" mode
else if(HandleQuickJumpKeyDown(InKeyEvent.GetCharacter(), InKeyEvent.IsControlDown(), InKeyEvent.IsAltDown(), /*bTestOnly*/true).IsEventHandled())
{
return FReply::Handled();
}
return FReply::Unhandled();
}
FReply SAssetView::OnMouseWheel( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
if( MouseEvent.IsControlDown() )
{
const float DesiredScale = FMath::Clamp<float>(GetThumbnailScale() + ( MouseEvent.GetWheelDelta() * 0.05f ), 0.0f, 1.0f);
if ( DesiredScale != GetThumbnailScale() )
{
SetThumbnailScale( DesiredScale );
}
return FReply::Handled();
}
return FReply::Unhandled();
}
void SAssetView::OnFocusChanging( const FWeakWidgetPath& PreviousFocusPath, const FWidgetPath& NewWidgetPath )
{
ResetQuickJump();
}
TSharedRef<SAssetTileView> SAssetView::CreateTileView()
{
return SNew(SAssetTileView)
.SelectionMode( SelectionMode )
.ListItemsSource(&FilteredAssetItems)
.OnGenerateTile(this, &SAssetView::MakeTileViewWidget)
.OnItemScrolledIntoView(this, &SAssetView::ItemScrolledIntoView)
.OnContextMenuOpening(this, &SAssetView::OnGetContextMenuContent)
.OnMouseButtonDoubleClick(this, &SAssetView::OnListMouseButtonDoubleClick)
.OnSelectionChanged(this, &SAssetView::AssetSelectionChanged)
.ItemHeight(this, &SAssetView::GetTileViewItemHeight)
.ItemWidth(this, &SAssetView::GetTileViewItemWidth);
}
TSharedRef<SAssetListView> SAssetView::CreateListView()
{
return SNew(SAssetListView)
.SelectionMode( SelectionMode )
.ListItemsSource(&FilteredAssetItems)
.OnGenerateRow(this, &SAssetView::MakeListViewWidget)
.OnItemScrolledIntoView(this, &SAssetView::ItemScrolledIntoView)
.OnContextMenuOpening(this, &SAssetView::OnGetContextMenuContent)
.OnMouseButtonDoubleClick(this, &SAssetView::OnListMouseButtonDoubleClick)
.OnSelectionChanged(this, &SAssetView::AssetSelectionChanged)
.ItemHeight(this, &SAssetView::GetListViewItemHeight);
}
TSharedRef<SAssetColumnView> SAssetView::CreateColumnView()
{
TSharedPtr<SAssetColumnView> NewColumnView = SNew(SAssetColumnView)
.SelectionMode( SelectionMode )
.ListItemsSource(&FilteredAssetItems)
.OnGenerateRow(this, &SAssetView::MakeColumnViewWidget)
.OnItemScrolledIntoView(this, &SAssetView::ItemScrolledIntoView)
.OnContextMenuOpening(this, &SAssetView::OnGetContextMenuContent)
.OnMouseButtonDoubleClick(this, &SAssetView::OnListMouseButtonDoubleClick)
.OnSelectionChanged(this, &SAssetView::AssetSelectionChanged)
.Visibility(this, &SAssetView::GetColumnViewVisibility)
.HeaderRow
(
SNew(SHeaderRow)
+ SHeaderRow::Column(SortManager.NameColumnId)
.FillWidth(300)
.SortMode( TAttribute< EColumnSortMode::Type >::Create( TAttribute< EColumnSortMode::Type >::FGetter::CreateSP( this, &SAssetView::GetColumnSortMode, SortManager.NameColumnId ) ) )
.SortPriority(TAttribute< EColumnSortPriority::Type >::Create(TAttribute< EColumnSortPriority::Type >::FGetter::CreateSP(this, &SAssetView::GetColumnSortPriority, SortManager.NameColumnId)))
.OnSort( FOnSortModeChanged::CreateSP( this, &SAssetView::OnSortColumnHeader ) )
.DefaultLabel( LOCTEXT("Column_Name", "Name") )
);
if(bShowTypeInColumnView)
{
NewColumnView->GetHeaderRow()->AddColumn(
SHeaderRow::Column(SortManager.ClassColumnId)
.FillWidth(160)
.SortMode(TAttribute< EColumnSortMode::Type >::Create(TAttribute< EColumnSortMode::Type >::FGetter::CreateSP(this, &SAssetView::GetColumnSortMode, SortManager.ClassColumnId)))
.SortPriority(TAttribute< EColumnSortPriority::Type >::Create(TAttribute< EColumnSortPriority::Type >::FGetter::CreateSP(this, &SAssetView::GetColumnSortPriority, SortManager.ClassColumnId)))
.OnSort(FOnSortModeChanged::CreateSP(this, &SAssetView::OnSortColumnHeader))
.DefaultLabel(LOCTEXT("Column_Class", "Type"))
);
}
if (bShowPathInColumnView)
{
NewColumnView->GetHeaderRow()->AddColumn(
SHeaderRow::Column(SortManager.PathColumnId)
.FillWidth(160)
.SortMode(TAttribute< EColumnSortMode::Type >::Create(TAttribute< EColumnSortMode::Type >::FGetter::CreateSP(this, &SAssetView::GetColumnSortMode, SortManager.PathColumnId)))
.SortPriority(TAttribute< EColumnSortPriority::Type >::Create(TAttribute< EColumnSortPriority::Type >::FGetter::CreateSP(this, &SAssetView::GetColumnSortPriority, SortManager.PathColumnId)))
.OnSort(FOnSortModeChanged::CreateSP(this, &SAssetView::OnSortColumnHeader))
.DefaultLabel(LOCTEXT("Column_Path", "Path"))
);
}
return NewColumnView.ToSharedRef();
}
bool SAssetView::IsValidSearchToken(const FString& Token) const
{
if ( Token.Len() == 0 )
{
return false;
}
// A token may not be only apostrophe only, or it will match every asset because the text filter compares against the pattern Class'ObjectPath'
if ( Token.Len() == 1 && Token[0] == '\'' )
{
return false;
}
return true;
}
void SAssetView::RefreshSourceItems()
{
// Load the asset registry module
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
RecentlyLoadedOrChangedAssets.Empty();
RecentlyAddedAssets.Empty();
FilteredRecentlyAddedAssets.Empty();
QueriedAssetItems.Empty();
AssetItems.Empty();
FilteredAssetItems.Empty();
VisibleItems.Empty();
RelevantThumbnails.Empty();
Folders.Empty();
TArray<FAssetData>& Items = OnShouldFilterAsset.IsBound() ? QueriedAssetItems : AssetItems;
const bool bShowAll = SourcesData.IsEmpty() && BackendFilter.IsEmpty();
bool bShowClasses = false;
TArray<FName> ClassPathsToShow;
if ( bShowAll )
{
AssetRegistryModule.Get().GetAllAssets(Items);
bShowClasses = true;
bWereItemsRecursivelyFiltered = true;
}
else
{
// Assemble the filter using the current sources
// force recursion when the user is searching
const bool bRecurse = ShouldFilterRecursively();
const bool bUsingFolders = IsShowingFolders();
const bool bIsDynamicCollection = SourcesData.IsDynamicCollection();
FARFilter Filter = SourcesData.MakeFilter(bRecurse, bUsingFolders);
// Add the backend filters from the filter list
Filter.Append(BackendFilter);
bWereItemsRecursivelyFiltered = bRecurse;
// Move any class paths into their own array
Filter.PackagePaths.RemoveAll([&ClassPathsToShow](const FName& PackagePath) -> bool
{
if(ContentBrowserUtils::IsClassPath(PackagePath.ToString()))
{
ClassPathsToShow.Add(PackagePath);
return true;
}
return false;
});
// Only show classes if we have class paths, and the filter allows classes to be shown
const bool bFilterAllowsClasses = Filter.ClassNames.Num() == 0 || Filter.ClassNames.Contains(NAME_Class);
bShowClasses = (ClassPathsToShow.Num() > 0 || bIsDynamicCollection) && bFilterAllowsClasses;
if ( SourcesData.HasCollections() && Filter.ObjectPaths.Num() == 0 && !bIsDynamicCollection )
{
// This is an empty collection, no asset will pass the check
}
else if ( ClassPathsToShow.Num() > 0 && Filter.PackagePaths.Num() == 0 )
{
// Only class paths are selected, no asset will pass the check
}
else
{
// Add assets found in the asset registry
AssetRegistryModule.Get().GetAssets(Filter, Items);
}
if ( bFilterAllowsClasses )
{
FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
// Include objects from child collections if we're recursing
const ECollectionRecursionFlags::Flags CollectionRecursionMode = (Filter.bRecursivePaths) ? ECollectionRecursionFlags::SelfAndChildren : ECollectionRecursionFlags::Self;
TArray< FName > ClassPaths;
for (const FCollectionNameType& Collection : SourcesData.Collections)
{
CollectionManagerModule.Get().GetClassesInCollection( Collection.Name, Collection.Type, ClassPaths, CollectionRecursionMode );
}
for (const FName& ClassPath : ClassPaths)
{
UClass* Class = FindObject<UClass>(ANY_PACKAGE, *ClassPath.ToString());
if ( Class != NULL )
{
Items.Add( Class );
}
}
}
}
// If we are showing classes in the asset list...
if (bShowClasses && bCanShowClasses)
{
// Load the native class hierarchy
TSharedRef<FNativeClassHierarchy> NativeClassHierarchy = FContentBrowserSingleton::Get().GetNativeClassHierarchy();
FNativeClassHierarchyFilter ClassFilter;
ClassFilter.ClassPaths = ClassPathsToShow;
ClassFilter.bRecursivePaths = ShouldFilterRecursively() || !IsShowingFolders() || !ClassPathsToShow.Num();
// Find all the classes that match the current criteria
TArray<UClass*> MatchingClasses;
NativeClassHierarchy->GetMatchingClasses(ClassFilter, MatchingClasses);
for(UClass* CurrentClass : MatchingClasses)
{
Items.Add(FAssetData(CurrentClass));
}
}
// Remove any assets that should be filtered out any redirectors and non-assets
const bool bDisplayEngine = GetDefault<UContentBrowserSettings>()->GetDisplayEngineFolder();
const bool bDisplayPlugins = GetDefault<UContentBrowserSettings>()->GetDisplayPluginFolders();
const bool bDisplayL10N = GetDefault<UContentBrowserSettings>()->GetDisplayL10NFolder();
for (int32 AssetIdx = Items.Num() - 1; AssetIdx >= 0; --AssetIdx)
{
const FAssetData& Item = Items[AssetIdx];
// Do not show redirectors if they are not the main asset in the uasset file.
const bool IsMainlyARedirector = Item.AssetClass == UObjectRedirector::StaticClass()->GetFName() && !Item.IsUAsset();
// If this is an engine folder, and we don't want to show them, remove
const bool IsHiddenEngineFolder = !bDisplayEngine && ContentBrowserUtils::IsEngineFolder(Item.PackagePath.ToString());
// If this is a plugin folder, and we don't want to show them, remove
const bool IsAHiddenPluginFolder = !bDisplayPlugins && ContentBrowserUtils::IsPluginFolder(Item.PackagePath.ToString());
// Do not show localized content folders.
const bool IsTheHiddenLocalizedContentFolder = !bDisplayL10N && ContentBrowserUtils::IsLocalizationFolder(Item.PackagePath.ToString());
const bool ShouldFilterOut = IsMainlyARedirector || IsHiddenEngineFolder || IsAHiddenPluginFolder || IsTheHiddenLocalizedContentFolder;
if (ShouldFilterOut)
{
Items.RemoveAtSwap(AssetIdx);
}
}
}
bool SAssetView::ShouldFilterRecursively() const
{
// Quick check for conditions which force recursive filtering
if (bUserSearching)
{
return true;
}
// In some cases we want to not filter recursively even if we have a backend filter (e.g. the open level window)
// Most of the time, bFilterRecursivelyWithBackendFilter is true
if ( bFilterRecursivelyWithBackendFilter && !BackendFilter.IsEmpty() )
{
return true;
}
// Otherwise, check if there are any non-inverse frontend filters selected
if (FrontendFilters.IsValid())
{
for (int32 FilterIndex = 0; FilterIndex < FrontendFilters->Num(); ++FilterIndex)
{
const auto* Filter = static_cast<FFrontendFilter*>(FrontendFilters->GetFilterAtIndex(FilterIndex).Get());
if (Filter)
{
if (!Filter->IsInverseFilter())
{
return true;
}
}
}
}
// No filters, do not override folder view with recursive filtering
return false;
}
void SAssetView::RefreshFilteredItems()
{
//Build up a map of the existing AssetItems so we can preserve them while filtering
TMap< FName, TSharedPtr< FAssetViewAsset > > ItemToObjectPath;
for (int Index = 0; Index < FilteredAssetItems.Num(); Index++)
{
if(FilteredAssetItems[Index].IsValid() && FilteredAssetItems[Index]->GetType() != EAssetItemType::Folder)
{
TSharedPtr<FAssetViewAsset> Item = StaticCastSharedPtr<FAssetViewAsset>(FilteredAssetItems[Index]);
ItemToObjectPath.Add( Item->Data.ObjectPath, Item );
}
}
// Empty all the filtered lists
FilteredAssetItems.Empty();
VisibleItems.Empty();
RelevantThumbnails.Empty();
Folders.Empty();
// true if the results from the asset registry query are filtered further by the content browser
const bool bIsFrontendFilterActive = IsFrontendFilterActive();
// true if we are looking at columns so we need to determine the majority asset type
const bool bGatherAssetTypeCount = CurrentViewType == EAssetViewType::Column;
TMap<FName, int32> AssetTypeCount;
if ( bIsFrontendFilterActive && FrontendFilters.IsValid() )
{
const bool bRecurse = ShouldFilterRecursively();
const bool bUsingFolders = IsShowingFolders();
FARFilter CombinedFilter = SourcesData.MakeFilter(bRecurse, bUsingFolders);
CombinedFilter.Append(BackendFilter);
// Let the frontend filters know the currently used filter in case it is necessary to conditionally filter based on path or class filters
for ( int32 FilterIdx = 0; FilterIdx < FrontendFilters->Num(); ++FilterIdx )
{
// There are only FFrontendFilters in this collection
const TSharedPtr<FFrontendFilter>& Filter = StaticCastSharedPtr<FFrontendFilter>( FrontendFilters->GetFilterAtIndex(FilterIdx) );
if ( Filter.IsValid() )
{
Filter->SetCurrentFilter(CombinedFilter);
}
}
}
if ( bIsFrontendFilterActive && bGatherAssetTypeCount )
{
// Check the frontend filter for every asset and keep track of how many assets were found of each type
for (int32 AssetIdx = 0; AssetIdx < AssetItems.Num(); ++AssetIdx)
{
const FAssetData& AssetData = AssetItems[AssetIdx];
if ( PassesCurrentFrontendFilter(AssetData) )
{
const TSharedPtr< FAssetViewAsset >* AssetItem = ItemToObjectPath.Find( AssetData.ObjectPath );
if ( AssetItem != NULL )
{
FilteredAssetItems.Add(*AssetItem);
}
else
{
FilteredAssetItems.Add(MakeShareable(new FAssetViewAsset(AssetData)));
}
int32* TypeCount = AssetTypeCount.Find(AssetData.AssetClass);
if ( TypeCount )
{
(*TypeCount)++;
}
else
{
AssetTypeCount.Add(AssetData.AssetClass, 1);
}
}
}
}
else if ( bIsFrontendFilterActive && !bGatherAssetTypeCount )
{
// Check the frontend filter for every asset and don't worry about asset type counts
for (int32 AssetIdx = 0; AssetIdx < AssetItems.Num(); ++AssetIdx)
{
const FAssetData& AssetData = AssetItems[AssetIdx];
if ( PassesCurrentFrontendFilter(AssetData) )
{
const TSharedPtr< FAssetViewAsset >* AssetItem = ItemToObjectPath.Find( AssetData.ObjectPath );
if ( AssetItem != NULL )
{
FilteredAssetItems.Add(*AssetItem);
}
else
{
FilteredAssetItems.Add(MakeShareable(new FAssetViewAsset(AssetData)));
}
}
}
}
else if ( !bIsFrontendFilterActive && bGatherAssetTypeCount )
{
// Don't need to check the frontend filter for every asset but keep track of how many assets were found of each type
for (int32 AssetIdx = 0; AssetIdx < AssetItems.Num(); ++AssetIdx)
{
const FAssetData& AssetData = AssetItems[AssetIdx];
const TSharedPtr< FAssetViewAsset >* AssetItem = ItemToObjectPath.Find( AssetData.ObjectPath );
if ( AssetItem != NULL )
{
FilteredAssetItems.Add(*AssetItem);
}
else
{
FilteredAssetItems.Add(MakeShareable(new FAssetViewAsset(AssetData)));
}
int32* TypeCount = AssetTypeCount.Find(AssetData.AssetClass);
if ( TypeCount )
{
(*TypeCount)++;
}
else
{
AssetTypeCount.Add(AssetData.AssetClass, 1);
}
}
}
else if ( !bIsFrontendFilterActive && !bGatherAssetTypeCount )
{
// Don't check the frontend filter and don't count the number of assets of each type. Just add all assets.
for (int32 AssetIdx = 0; AssetIdx < AssetItems.Num(); ++AssetIdx)
{
const FAssetData& AssetData = AssetItems[AssetIdx];
const TSharedPtr< FAssetViewAsset >* AssetItem = ItemToObjectPath.Find( AssetData.ObjectPath );
if ( AssetItem != NULL )
{
FilteredAssetItems.Add(*AssetItem);
}
else
{
FilteredAssetItems.Add(MakeShareable(new FAssetViewAsset(AssetData)));
}
}
}
else
{
// The above cases should handle all combinations of bIsFrontendFilterActive and bGatherAssetTypeCount
ensure(0);
}
if ( bGatherAssetTypeCount )
{
int32 HighestCount = 0;
FName HighestType;
for ( auto TypeIt = AssetTypeCount.CreateConstIterator(); TypeIt; ++TypeIt )
{
if ( TypeIt.Value() > HighestCount )
{
HighestType = TypeIt.Key();
HighestCount = TypeIt.Value();
}
}
SetMajorityAssetType(HighestType);
}
}
void SAssetView::RefreshFolders()
{
if(!IsShowingFolders() || ShouldFilterRecursively())
{
return;
}
// Split the selected paths into asset and class paths
TArray<FName> AssetPathsToShow;
TArray<FName> ClassPathsToShow;
for(const FName& PackagePath : SourcesData.PackagePaths)
{
if(ContentBrowserUtils::IsClassPath(PackagePath.ToString()))
{
ClassPathsToShow.Add(PackagePath);
}
else
{
AssetPathsToShow.Add(PackagePath);
}
}
TArray<FString> FoldersToAdd;
const bool bDisplayDev = GetDefault<UContentBrowserSettings>()->GetDisplayDevelopersFolder();
const bool bDisplayL10N = GetDefault<UContentBrowserSettings>()->GetDisplayL10NFolder();
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
{
TArray<FString> SubPaths;
for(const FName& PackagePath : AssetPathsToShow)
{
SubPaths.Reset();
AssetRegistryModule.Get().GetSubPaths(PackagePath.ToString(), SubPaths, false);
for(const FString& SubPath : SubPaths)
{
// If this is a developer folder, and we don't want to show them try the next path
if(!bDisplayDev && ContentBrowserUtils::IsDevelopersFolder(SubPath))
{
continue;
}
if (!bDisplayL10N && ContentBrowserUtils::IsLocalizationFolder(SubPath))
{
continue;
}
if(!Folders.Contains(SubPath))
{
FoldersToAdd.Add(SubPath);
}
}
}
}
// If we are showing classes in the asset list then we need to show their folders too
if(bCanShowClasses && ClassPathsToShow.Num() > 0)
{
// Load the native class hierarchy
TSharedRef<FNativeClassHierarchy> NativeClassHierarchy = FContentBrowserSingleton::Get().GetNativeClassHierarchy();
FNativeClassHierarchyFilter ClassFilter;
ClassFilter.ClassPaths = ClassPathsToShow;
ClassFilter.bRecursivePaths = false;
// Find all the classes that match the current criteria
TArray<FString> MatchingFolders;
NativeClassHierarchy->GetMatchingFolders(ClassFilter, MatchingFolders);
FoldersToAdd.Append(MatchingFolders);
}
// Add folders for any child collections of the currently selected collections
if(SourcesData.HasCollections())
{
FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
TArray<FCollectionNameType> ChildCollections;
for(const FCollectionNameType& Collection : SourcesData.Collections)
{
ChildCollections.Reset();
CollectionManagerModule.Get().GetChildCollections(Collection.Name, Collection.Type, ChildCollections);
for(const FCollectionNameType& ChildCollection : ChildCollections)
{
// Use "Collections" as the root of the path to avoid this being confused with other asset view folders - see ContentBrowserUtils::IsCollectionPath
FoldersToAdd.Add(FString::Printf(TEXT("/Collections/%s/%s"), ECollectionShareType::ToString(ChildCollection.Type), *ChildCollection.Name.ToString()));
}
}
}
if(FoldersToAdd.Num() > 0)
{
for(const FString& FolderPath : FoldersToAdd)
{
FilteredAssetItems.Add(MakeShareable(new FAssetViewFolder(FolderPath)));
Folders.Add(FolderPath);
}
RefreshList();
bPendingSortFilteredItems = true;
}
}
void SAssetView::SetMajorityAssetType(FName NewMajorityAssetType)
{
if ( NewMajorityAssetType != MajorityAssetType )
{
UE_LOG(LogContentBrowser, Verbose, TEXT("The majority of assets in the view are of type: %s"), *NewMajorityAssetType.ToString());
MajorityAssetType = NewMajorityAssetType;
// Since the asset type has changed, remove all columns except name and class
const TIndirectArray<SHeaderRow::FColumn>& Columns = ColumnView->GetHeaderRow()->GetColumns();
for ( int32 ColumnIdx = Columns.Num() - 1; ColumnIdx >= 0; --ColumnIdx )
{
const FName ColumnId = Columns[ColumnIdx].ColumnId;
const bool bIsFixedNameColumn = ColumnId == SortManager.NameColumnId;
const bool bIsFixedClassColumn = bShowTypeInColumnView && ColumnId == SortManager.ClassColumnId;
const bool bIsFixedPathColumn = bShowPathInColumnView && ColumnId == SortManager.PathColumnId;
if ( ColumnId != NAME_None && !(bIsFixedNameColumn || bIsFixedClassColumn || bIsFixedPathColumn) )
{
ColumnView->GetHeaderRow()->RemoveColumn(ColumnId);
}
}
// Keep track of the current column name to see if we need to change it now that columns are being removed
// Name, Class, and Path are always relevant
struct FSortOrder
{
bool bSortRelevant;
FName SortColumn;
FSortOrder(bool bInSortRelevant, const FName& InSortColumn) : bSortRelevant(bInSortRelevant), SortColumn(InSortColumn) {}
};
TArray<FSortOrder> CurrentSortOrder;
for (int32 PriorityIdx = 0; PriorityIdx < EColumnSortPriority::Max; PriorityIdx++)
{
const FName SortColumn = SortManager.GetSortColumnId(static_cast<EColumnSortPriority::Type>(PriorityIdx));
if (SortColumn != NAME_None)
{
const bool bSortRelevant = SortColumn == FAssetViewSortManager::NameColumnId
|| SortColumn == FAssetViewSortManager::ClassColumnId
|| SortColumn == FAssetViewSortManager::PathColumnId;
CurrentSortOrder.Add(FSortOrder(bSortRelevant, SortColumn));
}
}
// If we have a new majority type, add the new type's columns
if ( NewMajorityAssetType != NAME_None )
{
// Determine the columns by querying the CDO for the tag map
UClass* TypeClass = FindObject<UClass>(ANY_PACKAGE, *NewMajorityAssetType.ToString());
if ( TypeClass )
{
UObject* CDO = TypeClass->GetDefaultObject();
if ( CDO )
{
TArray<UObject::FAssetRegistryTag> AssetRegistryTags;
CDO->GetAssetRegistryTags(AssetRegistryTags);
// Add a column for every tag that isn't hidden
for ( auto TagIt = AssetRegistryTags.CreateConstIterator(); TagIt; ++TagIt )
{
if ( TagIt->Type != UObject::FAssetRegistryTag::TT_Hidden )
{
const FName& Tag = TagIt->Name;
if ( !OnAssetTagWantsToBeDisplayed.IsBound() || OnAssetTagWantsToBeDisplayed.Execute(NewMajorityAssetType, Tag) )
{
// Get tag metadata
TMap<FName, UObject::FAssetRegistryTagMetadata> MetadataMap;
CDO->GetAssetRegistryTagMetadata(MetadataMap);
const UObject::FAssetRegistryTagMetadata* Metadata = MetadataMap.Find(Tag);
FText DisplayName;
if (Metadata != nullptr && !Metadata->DisplayName.IsEmpty())
{
DisplayName = Metadata->DisplayName;
}
else
{
DisplayName = FText::FromName(Tag);
}
FText TooltipText;
if (Metadata != nullptr && !Metadata->TooltipText.IsEmpty())
{
TooltipText = Metadata->TooltipText;
}
else
{
// If the tag name corresponds to a property name, use the property tooltip
UProperty* Property = FindField<UProperty>(TypeClass, Tag);
TooltipText = (Property != nullptr) ? Property->GetToolTipText() : FText::FromString(FName::NameToDisplayString(Tag.ToString(), false));
}
ColumnView->GetHeaderRow()->AddColumn(
SHeaderRow::Column(Tag)
.SortMode( TAttribute< EColumnSortMode::Type >::Create( TAttribute< EColumnSortMode::Type >::FGetter::CreateSP( this, &SAssetView::GetColumnSortMode, Tag ) ) )
.SortPriority(TAttribute< EColumnSortPriority::Type >::Create(TAttribute< EColumnSortPriority::Type >::FGetter::CreateSP(this, &SAssetView::GetColumnSortPriority, Tag)))
.OnSort( FOnSortModeChanged::CreateSP( this, &SAssetView::OnSortColumnHeader ) )
.DefaultLabel( DisplayName )
.DefaultTooltip( TooltipText )
.HAlignCell( (TagIt->Type == UObject::FAssetRegistryTag::TT_Numerical) ? HAlign_Right : HAlign_Left )
.FillWidth(180)
);
// If we found a tag the matches the column we are currently sorting on, there will be no need to change the column
for (int32 SortIdx = 0; SortIdx < CurrentSortOrder.Num(); SortIdx++)
{
if (Tag == CurrentSortOrder[SortIdx].SortColumn)
{
CurrentSortOrder[SortIdx].bSortRelevant = true;
}
}
}
}
}
}
}
}
// Are any of the sort columns irrelevant now, if so remove them from the list
bool CurrentSortChanged = false;
for (int32 SortIdx = CurrentSortOrder.Num() - 1; SortIdx >= 0; SortIdx--)
{
if (!CurrentSortOrder[SortIdx].bSortRelevant)
{
CurrentSortOrder.RemoveAt(SortIdx);
CurrentSortChanged = true;
}
}
if (CurrentSortOrder.Num() > 0 && CurrentSortChanged)
{
// Sort order has changed, update the columns keeping those that are relevant
int32 PriorityNum = EColumnSortPriority::Primary;
for (int32 SortIdx = 0; SortIdx < CurrentSortOrder.Num(); SortIdx++)
{
check(CurrentSortOrder[SortIdx].bSortRelevant);
if (!SortManager.SetOrToggleSortColumn(static_cast<EColumnSortPriority::Type>(PriorityNum), CurrentSortOrder[SortIdx].SortColumn))
{
// Toggle twice so mode is preserved if this isn't a new column assignation
SortManager.SetOrToggleSortColumn(static_cast<EColumnSortPriority::Type>(PriorityNum), CurrentSortOrder[SortIdx].SortColumn);
}
bPendingSortFilteredItems = true;
PriorityNum++;
}
}
else if (CurrentSortOrder.Num() == 0)
{
// If the current sort column is no longer relevant, revert to "Name" and resort when convenient
SortManager.ResetSort();
bPendingSortFilteredItems = true;
}
}
}
void SAssetView::OnAssetsAddedToCollection( const FCollectionNameType& Collection, const TArray< FName >& ObjectPaths )
{
if ( !SourcesData.Collections.Contains( Collection ) )
{
return;
}
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
for (int Index = 0; Index < ObjectPaths.Num(); Index++)
{
OnAssetAdded( AssetRegistryModule.Get().GetAssetByObjectPath( ObjectPaths[Index] ) );
}
}
void SAssetView::OnAssetAdded(const FAssetData& AssetData)
{
RecentlyAddedAssets.Add(AssetData);
}
void SAssetView::ProcessRecentlyAddedAssets()
{
if (
(RecentlyAddedAssets.Num() > 2048) ||
(RecentlyAddedAssets.Num() > 0 && FPlatformTime::Seconds() - LastProcessAddsTime >= TimeBetweenAddingNewAssets)
)
{
RunAssetsThroughBackendFilter(RecentlyAddedAssets);
FilteredRecentlyAddedAssets.Append(RecentlyAddedAssets);
RecentlyAddedAssets.Empty();
LastProcessAddsTime = FPlatformTime::Seconds();
}
if (FilteredRecentlyAddedAssets.Num() > 0)
{
const static float MaxSecondsPerFrame = 0.015;
double TickStartTime = FPlatformTime::Seconds();
bool bNeedsRefresh = false;
TSet<FName> ExistingObjectPaths;
for ( auto AssetIt = AssetItems.CreateConstIterator(); AssetIt; ++AssetIt )
{
ExistingObjectPaths.Add((*AssetIt).ObjectPath);
}
for ( auto AssetIt = QueriedAssetItems.CreateConstIterator(); AssetIt; ++AssetIt )
{
ExistingObjectPaths.Add((*AssetIt).ObjectPath);
}
int32 AssetIdx = 0;
for ( ; AssetIdx < FilteredRecentlyAddedAssets.Num(); ++AssetIdx )
{
const FAssetData& AssetData = FilteredRecentlyAddedAssets[AssetIdx];
if ( !ExistingObjectPaths.Contains(AssetData.ObjectPath) )
{
if ( AssetData.AssetClass != UObjectRedirector::StaticClass()->GetFName() || AssetData.IsUAsset() )
{
if ( !OnShouldFilterAsset.IsBound() || !OnShouldFilterAsset.Execute(AssetData) )
{
// Add the asset to the list
int32 AddedAssetIdx = AssetItems.Add(AssetData);
ExistingObjectPaths.Add(AssetData.ObjectPath);
if (!IsFrontendFilterActive() || PassesCurrentFrontendFilter(AssetData))
{
FilteredAssetItems.Add(MakeShareable(new FAssetViewAsset(AssetData)));
bNeedsRefresh = true;
bPendingSortFilteredItems = true;
}
}
}
}
if ( (FPlatformTime::Seconds() - TickStartTime) > MaxSecondsPerFrame)
{
// Increment the index to properly trim the buffer below
++AssetIdx;
break;
}
}
// Trim the results array
if (AssetIdx > 0)
{
FilteredRecentlyAddedAssets.RemoveAt(0, AssetIdx);
}
if (bNeedsRefresh)
{
RefreshList();
}
}
}
void SAssetView::OnAssetsRemovedFromCollection( const FCollectionNameType& Collection, const TArray< FName >& ObjectPaths )
{
if ( !SourcesData.Collections.Contains( Collection ) )
{
return;
}
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
for (int Index = 0; Index < ObjectPaths.Num(); Index++)
{
OnAssetRemoved( AssetRegistryModule.Get().GetAssetByObjectPath( ObjectPaths[Index] ) );
}
}
void SAssetView::OnAssetRemoved(const FAssetData& AssetData)
{
RemoveAssetByPath( AssetData.ObjectPath );
RecentlyAddedAssets.RemoveSingleSwap(AssetData);
}
void SAssetView::OnAssetRegistryPathAdded(const FString& Path)
{
if(IsShowingFolders() && !ShouldFilterRecursively())
{
// If this isn't a developer folder or we want to show them, continue
const bool bDisplayDev = GetDefault<UContentBrowserSettings>()->GetDisplayDevelopersFolder();
if ( bDisplayDev || !ContentBrowserUtils::IsDevelopersFolder(Path) )
{
for (const FName& SourcePathName : SourcesData.PackagePaths)
{
const FString SourcePath = SourcePathName.ToString();
if(Path.StartsWith(SourcePath))
{
const FString SubPath = Path.RightChop(SourcePath.Len());
TArray<FString> SubPathItemList;
SubPath.ParseIntoArray(SubPathItemList, TEXT("/"), /*InCullEmpty=*/true);
if(SubPathItemList.Num() > 0)
{
const FString NewSubFolder = SourcePath / SubPathItemList[0];
if(!Folders.Contains(NewSubFolder))
{
FilteredAssetItems.Add(MakeShareable(new FAssetViewFolder(NewSubFolder)));
RefreshList();
Folders.Add(NewSubFolder);
bPendingSortFilteredItems = true;
}
}
}
}
}
}
}
void SAssetView::OnAssetRegistryPathRemoved(const FString& Path)
{
FString* Folder = Folders.Find(Path);
if(Folder != NULL)
{
Folders.Remove(Path);
for (int32 AssetIdx = 0; AssetIdx < FilteredAssetItems.Num(); ++AssetIdx)
{
if(FilteredAssetItems[AssetIdx]->GetType() == EAssetItemType::Folder)
{
if ( StaticCastSharedPtr<FAssetViewFolder>(FilteredAssetItems[AssetIdx])->FolderPath == Path )
{
// Found the folder in the filtered items list, remove it
FilteredAssetItems.RemoveAt(AssetIdx);
RefreshList();
break;
}
}
}
}
}
void SAssetView::RemoveAssetByPath( const FName& ObjectPath )
{
bool bFoundAsset = false;
for (int32 AssetIdx = 0; AssetIdx < AssetItems.Num(); ++AssetIdx)
{
if ( AssetItems[AssetIdx].ObjectPath == ObjectPath )
{
// Found the asset in the cached list, remove it
AssetItems.RemoveAt(AssetIdx);
bFoundAsset = true;
break;
}
}
if ( bFoundAsset )
{
// If it was in the AssetItems list, see if it is also in the FilteredAssetItems list
for (int32 AssetIdx = 0; AssetIdx < FilteredAssetItems.Num(); ++AssetIdx)
{
if(FilteredAssetItems[AssetIdx].IsValid() && FilteredAssetItems[AssetIdx]->GetType() != EAssetItemType::Folder)
{
if ( StaticCastSharedPtr<FAssetViewAsset>(FilteredAssetItems[AssetIdx])->Data.ObjectPath == ObjectPath && !FilteredAssetItems[AssetIdx]->IsTemporaryItem() )
{
// Found the asset in the filtered items list, remove it
FilteredAssetItems.RemoveAt(AssetIdx);
RefreshList();
break;
}
}
}
}
else
{
//Make sure we don't have the item still queued up for processing
for (int32 AssetIdx = 0; AssetIdx < QueriedAssetItems.Num(); ++AssetIdx)
{
if ( QueriedAssetItems[AssetIdx].ObjectPath == ObjectPath )
{
// Found the asset in the cached list, remove it
QueriedAssetItems.RemoveAt(AssetIdx);
bFoundAsset = true;
break;
}
}
}
}
void SAssetView::OnCollectionRenamed( const FCollectionNameType& OriginalCollection, const FCollectionNameType& NewCollection )
{
int32 FoundIndex = INDEX_NONE;
if ( SourcesData.Collections.Find( OriginalCollection, FoundIndex ) )
{
SourcesData.Collections[ FoundIndex ] = NewCollection;
}
}
void SAssetView::OnCollectionUpdated( const FCollectionNameType& Collection )
{
// A collection has changed in some way, so we need to refresh our backend list
RequestSlowFullListRefresh();
}
void SAssetView::OnAssetRenamed(const FAssetData& AssetData, const FString& OldObjectPath)
{
// Remove the old asset, if it exists
RemoveAssetByPath( FName( *OldObjectPath ) );
// Add the new asset, if it should be in the cached list
OnAssetAdded( AssetData );
// Force an update of the recently added asset next frame
RequestAddNewAssetsNextFrame();
}
void SAssetView::OnAssetLoaded(UObject* Asset)
{
if ( Asset != NULL )
{
RecentlyLoadedOrChangedAssets.Add( FName(*Asset->GetPathName()), Asset );
}
}
void SAssetView::OnObjectPropertyChanged(UObject* Asset, FPropertyChangedEvent& PropertyChangedEvent)
{
if ( Asset != NULL )
{
RecentlyLoadedOrChangedAssets.Add( FName(*Asset->GetPathName()), Asset );
}
}
void SAssetView::OnClassHierarchyUpdated()
{
// The class hierarchy has changed in some way, so we need to refresh our backend list
RequestSlowFullListRefresh();
}
void SAssetView::OnFrontendFiltersChanged()
{
RequestQuickFrontendListRefresh();
// If we're not operating on recursively filtered data, we need to ensure a full slow
// refresh is performed.
if ( ShouldFilterRecursively() && !bWereItemsRecursivelyFiltered )
{
RequestSlowFullListRefresh();
}
}
bool SAssetView::IsFrontendFilterActive() const
{
return ( FrontendFilters.IsValid() && FrontendFilters->Num() > 0 );
}
bool SAssetView::PassesCurrentFrontendFilter(const FAssetData& Item) const
{
// Check the frontend filters list
if ( FrontendFilters.IsValid() && !FrontendFilters->PassesAllFilters(Item) )
{
return false;
}
return true;
}
void SAssetView::RunAssetsThroughBackendFilter(TArray<FAssetData>& InOutAssetDataList) const
{
const bool bRecurse = ShouldFilterRecursively();
const bool bUsingFolders = IsShowingFolders();
const bool bIsDynamicCollection = SourcesData.IsDynamicCollection();
FARFilter Filter = SourcesData.MakeFilter(bRecurse, bUsingFolders);
if ( SourcesData.HasCollections() && Filter.ObjectPaths.Num() == 0 && !bIsDynamicCollection )
{
// This is an empty collection, no asset will pass the check
InOutAssetDataList.Empty();
}
else
{
// Actually append the backend filter
Filter.Append(BackendFilter);
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
AssetRegistryModule.Get().RunAssetsThroughFilter(InOutAssetDataList, Filter);
if ( SourcesData.HasCollections() && !bIsDynamicCollection )
{
// Include objects from child collections if we're recursing
const ECollectionRecursionFlags::Flags CollectionRecursionMode = (Filter.bRecursivePaths) ? ECollectionRecursionFlags::SelfAndChildren : ECollectionRecursionFlags::Self;
FCollectionManagerModule& CollectionManagerModule = FCollectionManagerModule::GetModule();
TArray< FName > CollectionObjectPaths;
for (const FCollectionNameType& Collection : SourcesData.Collections)
{
CollectionManagerModule.Get().GetObjectsInCollection(Collection.Name, Collection.Type, CollectionObjectPaths, CollectionRecursionMode);
}
for ( int32 AssetDataIdx = InOutAssetDataList.Num() - 1; AssetDataIdx >= 0; --AssetDataIdx )
{
const FAssetData& AssetData = InOutAssetDataList[AssetDataIdx];
if ( !CollectionObjectPaths.Contains( AssetData.ObjectPath ) )
{
InOutAssetDataList.RemoveAtSwap(AssetDataIdx);
}
}
}
}
}
void SAssetView::SortList(bool bSyncToSelection)
{
if ( !IsRenamingAsset() )
{
SortManager.SortList(FilteredAssetItems, MajorityAssetType);
// Update the thumbnails we were using since the order has changed
bPendingUpdateThumbnails = true;
if ( bSyncToSelection )
{
// Make sure the selection is in view
TArray<FAssetData> SelectedAssets = GetSelectedAssets();
if ( SelectedAssets.Num() > 0 )
{
const bool bFocusOnSync = false;
SyncToAssets(SelectedAssets, bFocusOnSync);
}
}
RefreshList();
bPendingSortFilteredItems = false;
LastSortTime = CurrentTime;
}
else
{
bPendingSortFilteredItems = true;
}
}
FLinearColor SAssetView::GetThumbnailHintColorAndOpacity() const
{
//We update this color in tick instead of here as an optimization
return ThumbnailHintColorAndOpacity;
}
FSlateColor SAssetView::GetViewButtonForegroundColor() const
{
static const FName InvertedForegroundName("InvertedForeground");
static const FName DefaultForegroundName("DefaultForeground");
return ViewOptionsComboButton->IsHovered() ? FEditorStyle::GetSlateColor(InvertedForegroundName) : FEditorStyle::GetSlateColor(DefaultForegroundName);
}
TSharedRef<SWidget> SAssetView::GetViewButtonContent()
{
// Get all menu extenders for this context menu from the content browser module
FContentBrowserModule& ContentBrowserModule = FModuleManager::GetModuleChecked<FContentBrowserModule>( TEXT("ContentBrowser") );
TArray<FContentBrowserMenuExtender> MenuExtenderDelegates = ContentBrowserModule.GetAllAssetViewViewMenuExtenders();
TArray<TSharedPtr<FExtender>> Extenders;
for (int32 i = 0; i < MenuExtenderDelegates.Num(); ++i)
{
if (MenuExtenderDelegates[i].IsBound())
{
Extenders.Add(MenuExtenderDelegates[i].Execute());
}
}
TSharedPtr<FExtender> MenuExtender = FExtender::Combine(Extenders);
FMenuBuilder MenuBuilder(/*bInShouldCloseWindowAfterMenuSelection=*/true, NULL, MenuExtender, /*bCloseSelfOnly=*/ true);
MenuBuilder.BeginSection("AssetViewType", LOCTEXT("ViewTypeHeading", "View Type"));
{
MenuBuilder.AddMenuEntry(
LOCTEXT("TileViewOption", "Tiles"),
LOCTEXT("TileViewOptionToolTip", "View assets as tiles in a grid."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SAssetView::SetCurrentViewType, EAssetViewType::Tile ),
FCanExecuteAction(),
FIsActionChecked::CreateSP( this, &SAssetView::IsCurrentViewType, EAssetViewType::Tile )
),
NAME_None,
EUserInterfaceActionType::RadioButton
);
MenuBuilder.AddMenuEntry(
LOCTEXT("ListViewOption", "List"),
LOCTEXT("ListViewOptionToolTip", "View assets in a list with thumbnails."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SAssetView::SetCurrentViewType, EAssetViewType::List ),
FCanExecuteAction(),
FIsActionChecked::CreateSP( this, &SAssetView::IsCurrentViewType, EAssetViewType::List )
),
NAME_None,
EUserInterfaceActionType::RadioButton
);
MenuBuilder.AddMenuEntry(
LOCTEXT("ColumnViewOption", "Columns"),
LOCTEXT("ColumnViewOptionToolTip", "View assets in a list with columns of details."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SAssetView::SetCurrentViewType, EAssetViewType::Column ),
FCanExecuteAction(),
FIsActionChecked::CreateSP( this, &SAssetView::IsCurrentViewType, EAssetViewType::Column )
),
NAME_None,
EUserInterfaceActionType::RadioButton
);
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("Folders", LOCTEXT("FoldersHeading", "Folders"));
{
MenuBuilder.AddMenuEntry(
LOCTEXT("ShowFoldersOption", "Show Folders"),
LOCTEXT("ShowFoldersOptionToolTip", "Show folders in the view as well as assets."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SAssetView::ToggleShowFolders ),
FCanExecuteAction::CreateSP( this, &SAssetView::IsToggleShowFoldersAllowed ),
FIsActionChecked::CreateSP( this, &SAssetView::IsShowingFolders )
),
NAME_None,
EUserInterfaceActionType::ToggleButton
);
MenuBuilder.AddMenuEntry(
LOCTEXT("ShowL10NFolderOption", "Show Localized Assets"),
LOCTEXT("ShowL10NFolderOptionToolTip", "Show assets within the localized asset directory."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP(this, &SAssetView::ToggleShowL10NFolder),
FCanExecuteAction::CreateSP(this, &SAssetView::IsToggleShowL10NFolderAllowed),
FIsActionChecked::CreateSP(this, &SAssetView::IsShowingL10NFolder)
),
NAME_None,
EUserInterfaceActionType::ToggleButton
);
MenuBuilder.AddMenuEntry(
LOCTEXT("ShowDevelopersFolderOption", "Show Developers Folder"),
LOCTEXT("ShowDevelopersFolderOptionToolTip", "Show the developers folder in the view."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SAssetView::ToggleShowDevelopersFolder ),
FCanExecuteAction::CreateSP( this, &SAssetView::IsToggleShowDevelopersFolderAllowed ),
FIsActionChecked::CreateSP( this, &SAssetView::IsShowingDevelopersFolder )
),
NAME_None,
EUserInterfaceActionType::ToggleButton
);
MenuBuilder.AddMenuEntry(
LOCTEXT("ShowPluginFolderOption", "Show Plugin Content"),
LOCTEXT("ShowPluginFolderOptionToolTip", "Shows plugin content in the view."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SAssetView::ToggleShowPluginFolders ),
FCanExecuteAction(),
FIsActionChecked::CreateSP( this, &SAssetView::IsShowingPluginFolders )
),
NAME_None,
EUserInterfaceActionType::ToggleButton
);
MenuBuilder.AddMenuEntry(
LOCTEXT("ShowEngineFolderOption", "Show Engine Content"),
LOCTEXT("ShowEngineFolderOptionToolTip", "Show the engine content in the view."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SAssetView::ToggleShowEngineFolder ),
FCanExecuteAction(),
FIsActionChecked::CreateSP( this, &SAssetView::IsShowingEngineFolder )
),
NAME_None,
EUserInterfaceActionType::ToggleButton
);
MenuBuilder.AddMenuEntry(
LOCTEXT("ShowCollectionOption", "Show Collections"),
LOCTEXT("ShowCollectionOptionToolTip", "Show the collections list in the view."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SAssetView::ToggleShowCollections ),
FCanExecuteAction::CreateSP( this, &SAssetView::IsToggleShowCollectionsAllowed ),
FIsActionChecked::CreateSP( this, &SAssetView::IsShowingCollections )
),
NAME_None,
EUserInterfaceActionType::ToggleButton
);
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("AssetThumbnails", LOCTEXT("ThumbnailsHeading", "Thumbnails"));
{
MenuBuilder.AddWidget(
SNew(SSlider)
.ToolTipText( LOCTEXT("ThumbnailScaleToolTip", "Adjust the size of thumbnails.") )
.Value( this, &SAssetView::GetThumbnailScale )
.OnValueChanged( this, &SAssetView::SetThumbnailScale )
.Locked( this, &SAssetView::IsThumbnailScalingLocked ),
LOCTEXT("ThumbnailScaleLabel", "Scale"),
/*bNoIndent=*/true
);
MenuBuilder.AddMenuEntry(
LOCTEXT("ThumbnailEditModeOption", "Thumbnail Edit Mode"),
LOCTEXT("ThumbnailEditModeOptionToolTip", "Toggle thumbnail editing mode. When in this mode you can rotate the camera on 3D thumbnails by dragging them."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SAssetView::ToggleThumbnailEditMode ),
FCanExecuteAction::CreateSP( this, &SAssetView::IsThumbnailEditModeAllowed ),
FIsActionChecked::CreateSP( this, &SAssetView::IsThumbnailEditMode )
),
NAME_None,
EUserInterfaceActionType::ToggleButton
);
MenuBuilder.AddMenuEntry(
LOCTEXT("RealTimeThumbnailsOption", "Real-Time Thumbnails"),
LOCTEXT("RealTimeThumbnailsOptionToolTip", "Renders the assets thumbnails in real-time"),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SAssetView::ToggleRealTimeThumbnails ),
FCanExecuteAction::CreateSP( this, &SAssetView::CanShowRealTimeThumbnails ),
FIsActionChecked::CreateSP( this, &SAssetView::IsShowingRealTimeThumbnails )
),
NAME_None,
EUserInterfaceActionType::ToggleButton
);
}
MenuBuilder.EndSection();
return MenuBuilder.MakeWidget();
}
void SAssetView::ToggleShowFolders()
{
check( IsToggleShowFoldersAllowed() );
GetMutableDefault<UContentBrowserSettings>()->DisplayFolders = !GetDefault<UContentBrowserSettings>()->DisplayFolders;
GetMutableDefault<UContentBrowserSettings>()->PostEditChange();
}
bool SAssetView::IsToggleShowFoldersAllowed() const
{
return bCanShowFolders;
}
bool SAssetView::IsShowingFolders() const
{
return IsToggleShowFoldersAllowed() ? GetDefault<UContentBrowserSettings>()->DisplayFolders : false;
}
void SAssetView::ToggleRealTimeThumbnails()
{
check( CanShowRealTimeThumbnails() );
GetMutableDefault<UContentBrowserSettings>()->RealTimeThumbnails = !GetDefault<UContentBrowserSettings>()->RealTimeThumbnails;
GetMutableDefault<UContentBrowserSettings>()->PostEditChange();
}
bool SAssetView::CanShowRealTimeThumbnails() const
{
return bCanShowRealTimeThumbnails;
}
bool SAssetView::IsShowingRealTimeThumbnails() const
{
return CanShowRealTimeThumbnails() ? GetDefault<UContentBrowserSettings>()->RealTimeThumbnails : false;
}
void SAssetView::ToggleShowPluginFolders()
{
bool bDisplayPlugins = GetDefault<UContentBrowserSettings>()->GetDisplayPluginFolders();
bool bRawDisplayPlugins = GetDefault<UContentBrowserSettings>()->GetDisplayPluginFolders( true );
// Only if both these flags are false when toggling we want to enable the flag, otherwise we're toggling off
if ( !bDisplayPlugins && !bRawDisplayPlugins )
{
GetMutableDefault<UContentBrowserSettings>()->SetDisplayPluginFolders( true );
}
else
{
GetMutableDefault<UContentBrowserSettings>()->SetDisplayPluginFolders( false );
GetMutableDefault<UContentBrowserSettings>()->SetDisplayPluginFolders( false, true );
}
GetMutableDefault<UContentBrowserSettings>()->PostEditChange();
}
bool SAssetView::IsShowingPluginFolders() const
{
return GetDefault<UContentBrowserSettings>()->GetDisplayPluginFolders();
}
void SAssetView::ToggleShowEngineFolder()
{
bool bDisplayEngine = GetDefault<UContentBrowserSettings>()->GetDisplayEngineFolder();
bool bRawDisplayEngine = GetDefault<UContentBrowserSettings>()->GetDisplayEngineFolder( true );
// Only if both these flags are false when toggling we want to enable the flag, otherwise we're toggling off
if ( !bDisplayEngine && !bRawDisplayEngine )
{
GetMutableDefault<UContentBrowserSettings>()->SetDisplayEngineFolder( true );
}
else
{
GetMutableDefault<UContentBrowserSettings>()->SetDisplayEngineFolder( false );
GetMutableDefault<UContentBrowserSettings>()->SetDisplayEngineFolder( false, true );
}
GetMutableDefault<UContentBrowserSettings>()->PostEditChange();
}
bool SAssetView::IsShowingEngineFolder() const
{
return GetDefault<UContentBrowserSettings>()->GetDisplayEngineFolder();
}
void SAssetView::ToggleShowDevelopersFolder()
{
bool bDisplayDev = GetDefault<UContentBrowserSettings>()->GetDisplayDevelopersFolder();
bool bRawDisplayDev = GetDefault<UContentBrowserSettings>()->GetDisplayDevelopersFolder( true );
// Only if both these flags are false when toggling we want to enable the flag, otherwise we're toggling off
if ( !bDisplayDev && !bRawDisplayDev )
{
GetMutableDefault<UContentBrowserSettings>()->SetDisplayDevelopersFolder( true );
}
else
{
GetMutableDefault<UContentBrowserSettings>()->SetDisplayDevelopersFolder( false );
GetMutableDefault<UContentBrowserSettings>()->SetDisplayDevelopersFolder( false, true );
}
GetMutableDefault<UContentBrowserSettings>()->PostEditChange();
}
bool SAssetView::IsToggleShowDevelopersFolderAllowed() const
{
return bCanShowDevelopersFolder;
}
bool SAssetView::IsShowingDevelopersFolder() const
{
return GetDefault<UContentBrowserSettings>()->GetDisplayDevelopersFolder();
}
void SAssetView::ToggleShowL10NFolder()
{
check(IsToggleShowFoldersAllowed());
GetMutableDefault<UContentBrowserSettings>()->SetDisplayL10NFolder(!GetDefault<UContentBrowserSettings>()->GetDisplayL10NFolder());
GetMutableDefault<UContentBrowserSettings>()->PostEditChange();
}
bool SAssetView::IsToggleShowL10NFolderAllowed() const
{
return true;
}
bool SAssetView::IsShowingL10NFolder() const
{
return GetDefault<UContentBrowserSettings>()->GetDisplayL10NFolder();
}
void SAssetView::ToggleShowCollections()
{
const bool bDisplayCollections = GetDefault<UContentBrowserSettings>()->GetDisplayCollections();
GetMutableDefault<UContentBrowserSettings>()->SetDisplayCollections( !bDisplayCollections );
GetMutableDefault<UContentBrowserSettings>()->PostEditChange();
}
bool SAssetView::IsToggleShowCollectionsAllowed() const
{
return bCanShowCollections;
}
bool SAssetView::IsShowingCollections() const
{
return GetDefault<UContentBrowserSettings>()->GetDisplayCollections();
}
void SAssetView::SetCurrentViewType(EAssetViewType::Type NewType)
{
if ( ensure(NewType != EAssetViewType::MAX) && NewType != CurrentViewType )
{
TArray<FAssetData> SelectedAssets = GetSelectedAssets();
ResetQuickJump();
CurrentViewType = NewType;
CreateCurrentView();
SyncToAssets(SelectedAssets);
// Clear relevant thumbnails to render fresh ones in the new view if needed
RelevantThumbnails.Empty();
VisibleItems.Empty();
if ( NewType == EAssetViewType::Tile )
{
CurrentThumbnailSize = TileViewThumbnailSize;
bPendingUpdateThumbnails = true;
}
else if ( NewType == EAssetViewType::List )
{
CurrentThumbnailSize = ListViewThumbnailSize;
bPendingUpdateThumbnails = true;
}
else if ( NewType == EAssetViewType::Column )
{
// No thumbnails, but we do need to refresh filtered items to determine a majority asset type
MajorityAssetType = NAME_None;
RefreshFilteredItems();
RefreshFolders();
SortList();
}
}
}
void SAssetView::CreateCurrentView()
{
TileView.Reset();
ListView.Reset();
ColumnView.Reset();
TSharedRef<SWidget> NewView = SNullWidget::NullWidget;
switch (CurrentViewType)
{
case EAssetViewType::Tile:
TileView = CreateTileView();
NewView = CreateShadowOverlay(TileView.ToSharedRef());
break;
case EAssetViewType::List:
ListView = CreateListView();
NewView = CreateShadowOverlay(ListView.ToSharedRef());
break;
case EAssetViewType::Column:
ColumnView = CreateColumnView();
NewView = CreateShadowOverlay(ColumnView.ToSharedRef());
break;
}
ViewContainer->SetContent( NewView );
}
TSharedRef<SWidget> SAssetView::CreateShadowOverlay( TSharedRef<STableViewBase> Table )
{
return SNew(SScrollBorder, Table)
[
Table
];
}
EAssetViewType::Type SAssetView::GetCurrentViewType() const
{
return CurrentViewType;
}
bool SAssetView::IsCurrentViewType(EAssetViewType::Type ViewType) const
{
return GetCurrentViewType() == ViewType;
}
void SAssetView::FocusList() const
{
switch ( GetCurrentViewType() )
{
case EAssetViewType::List: FSlateApplication::Get().SetKeyboardFocus(ListView, EFocusCause::SetDirectly); break;
case EAssetViewType::Tile: FSlateApplication::Get().SetKeyboardFocus(TileView, EFocusCause::SetDirectly); break;
case EAssetViewType::Column: FSlateApplication::Get().SetKeyboardFocus(ColumnView, EFocusCause::SetDirectly); break;
}
}
void SAssetView::RefreshList()
{
switch ( GetCurrentViewType() )
{
case EAssetViewType::List: ListView->RequestListRefresh(); break;
case EAssetViewType::Tile: TileView->RequestListRefresh(); break;
case EAssetViewType::Column: ColumnView->RequestListRefresh(); break;
}
}
void SAssetView::SetSelection(const TSharedPtr<FAssetViewItem>& Item)
{
switch ( GetCurrentViewType() )
{
case EAssetViewType::List: ListView->SetSelection(Item); break;
case EAssetViewType::Tile: TileView->SetSelection(Item); break;
case EAssetViewType::Column: ColumnView->SetSelection(Item); break;
}
}
void SAssetView::SetItemSelection(const TSharedPtr<FAssetViewItem>& Item, bool bSelected, const ESelectInfo::Type SelectInfo)
{
switch ( GetCurrentViewType() )
{
case EAssetViewType::List: ListView->SetItemSelection(Item, bSelected, SelectInfo); break;
case EAssetViewType::Tile: TileView->SetItemSelection(Item, bSelected, SelectInfo); break;
case EAssetViewType::Column: ColumnView->SetItemSelection(Item, bSelected, SelectInfo); break;
}
}
void SAssetView::RequestScrollIntoView(const TSharedPtr<FAssetViewItem>& Item)
{
switch ( GetCurrentViewType() )
{
case EAssetViewType::List: ListView->RequestScrollIntoView(Item); break;
case EAssetViewType::Tile: TileView->RequestScrollIntoView(Item); break;
case EAssetViewType::Column: ColumnView->RequestScrollIntoView(Item); break;
}
}
void SAssetView::OnOpenAssetsOrFolders()
{
TArray<FAssetData> SelectedAssets = GetSelectedAssets();
TArray<FString> SelectedFolders = GetSelectedFolders();
if (SelectedAssets.Num() > 0 && SelectedFolders.Num() == 0)
{
OnAssetsActivated.ExecuteIfBound(SelectedAssets, EAssetTypeActivationMethod::Opened);
}
else if (SelectedAssets.Num() == 0 && SelectedFolders.Num() > 0)
{
OnPathSelected.ExecuteIfBound(SelectedFolders[0]);
}
}
void SAssetView::OnPreviewAssets()
{
OnAssetsActivated.ExecuteIfBound(GetSelectedAssets(), EAssetTypeActivationMethod::Previewed);
}
void SAssetView::ClearSelection(bool bForceSilent)
{
const bool bTempBulkSelectingValue = bForceSilent ? true : bBulkSelecting;
TGuardValue<bool>(bBulkSelecting, bTempBulkSelectingValue);
switch ( GetCurrentViewType() )
{
case EAssetViewType::List: ListView->ClearSelection(); break;
case EAssetViewType::Tile: TileView->ClearSelection(); break;
case EAssetViewType::Column: ColumnView->ClearSelection(); break;
}
}
TSharedRef<ITableRow> SAssetView::MakeListViewWidget(TSharedPtr<FAssetViewItem> AssetItem, const TSharedRef<STableViewBase>& OwnerTable)
{
if ( !ensure(AssetItem.IsValid()) )
{
return SNew( STableRow<TSharedPtr<FAssetViewAsset>>, OwnerTable );
}
VisibleItems.Add(AssetItem);
bPendingUpdateThumbnails = true;
if(AssetItem->GetType() == EAssetItemType::Folder)
{
TSharedPtr< STableRow<TSharedPtr<FAssetViewItem>> > TableRowWidget;
SAssignNew( TableRowWidget, STableRow<TSharedPtr<FAssetViewItem>>, OwnerTable )
.Style(FEditorStyle::Get(), "ContentBrowser.AssetListView.TableRow")
.Cursor( bAllowDragging ? EMouseCursor::GrabHand : EMouseCursor::Default )
.OnDragDetected( this, &SAssetView::OnDraggingAssetItem );
TSharedRef<SAssetListItem> Item =
SNew(SAssetListItem)
.AssetItem(AssetItem)
.ItemHeight(this, &SAssetView::GetListViewItemHeight)
.OnRenameBegin(this, &SAssetView::AssetRenameBegin)
.OnRenameCommit(this, &SAssetView::AssetRenameCommit)
.OnVerifyRenameCommit(this, &SAssetView::AssetVerifyRenameCommit)
.OnItemDestroyed(this, &SAssetView::AssetItemWidgetDestroyed)
.ShouldAllowToolTip(this, &SAssetView::ShouldAllowToolTips)
.HighlightText(HighlightedText)
.IsSelected( FIsSelected::CreateSP(TableRowWidget.Get(), &STableRow<TSharedPtr<FAssetViewItem>>::IsSelectedExclusively) )
.OnAssetsDragDropped(this, &SAssetView::OnAssetsDragDropped)
.OnPathsDragDropped(this, &SAssetView::OnPathsDragDropped)
.OnFilesDragDropped(this, &SAssetView::OnFilesDragDropped);
TableRowWidget->SetContent(Item);
return TableRowWidget.ToSharedRef();
}
else
{
TSharedPtr<FAssetViewAsset> AssetItemAsAsset = StaticCastSharedPtr<FAssetViewAsset>(AssetItem);
TSharedPtr<FAssetThumbnail>* AssetThumbnailPtr = RelevantThumbnails.Find(AssetItemAsAsset);
TSharedPtr<FAssetThumbnail> AssetThumbnail;
if ( AssetThumbnailPtr )
{
AssetThumbnail = *AssetThumbnailPtr;
}
else
{
const float ThumbnailResolution = ListViewThumbnailResolution;
AssetThumbnail = MakeShareable( new FAssetThumbnail( AssetItemAsAsset->Data, ThumbnailResolution, ThumbnailResolution, AssetThumbnailPool ) );
RelevantThumbnails.Add( AssetItemAsAsset, AssetThumbnail );
AssetThumbnail->GetViewportRenderTargetTexture(); // Access the texture once to trigger it to render
}
TSharedPtr< STableRow<TSharedPtr<FAssetViewItem>> > TableRowWidget;
SAssignNew( TableRowWidget, STableRow<TSharedPtr<FAssetViewItem>>, OwnerTable )
.Style(FEditorStyle::Get(), "ContentBrowser.AssetListView.TableRow")
.Cursor( bAllowDragging ? EMouseCursor::GrabHand : EMouseCursor::Default )
.OnDragDetected( this, &SAssetView::OnDraggingAssetItem );
TSharedRef<SAssetListItem> Item =
SNew(SAssetListItem)
.AssetThumbnail(AssetThumbnail)
.AssetItem(AssetItem)
.ThumbnailPadding(ListViewThumbnailPadding)
.ItemHeight(this, &SAssetView::GetListViewItemHeight)
.OnRenameBegin(this, &SAssetView::AssetRenameBegin)
.OnRenameCommit(this, &SAssetView::AssetRenameCommit)
.OnVerifyRenameCommit(this, &SAssetView::AssetVerifyRenameCommit)
.OnItemDestroyed(this, &SAssetView::AssetItemWidgetDestroyed)
.ShouldAllowToolTip(this, &SAssetView::ShouldAllowToolTips)
.HighlightText(HighlightedText)
.ThumbnailEditMode(this, &SAssetView::IsThumbnailEditMode)
.ThumbnailLabel( ThumbnailLabel )
.ThumbnailHintColorAndOpacity( this, &SAssetView::GetThumbnailHintColorAndOpacity )
.AllowThumbnailHintLabel( AllowThumbnailHintLabel )
.IsSelected( FIsSelected::CreateSP(TableRowWidget.Get(), &STableRow<TSharedPtr<FAssetViewItem>>::IsSelectedExclusively) )
.OnGetCustomAssetToolTip(OnGetCustomAssetToolTip)
.OnVisualizeAssetToolTip(OnVisualizeAssetToolTip)
.OnAssetToolTipClosing(OnAssetToolTipClosing);
TableRowWidget->SetContent(Item);
return TableRowWidget.ToSharedRef();
}
}
TSharedRef<ITableRow> SAssetView::MakeTileViewWidget(TSharedPtr<FAssetViewItem> AssetItem, const TSharedRef<STableViewBase>& OwnerTable)
{
if ( !ensure(AssetItem.IsValid()) )
{
return SNew( STableRow<TSharedPtr<FAssetViewAsset>>, OwnerTable );
}
VisibleItems.Add(AssetItem);
bPendingUpdateThumbnails = true;
if(AssetItem->GetType() == EAssetItemType::Folder)
{
TSharedPtr< STableRow<TSharedPtr<FAssetViewItem>> > TableRowWidget;
SAssignNew( TableRowWidget, STableRow<TSharedPtr<FAssetViewItem>>, OwnerTable )
.Style( FEditorStyle::Get(), "ContentBrowser.AssetListView.TableRow" )
.Cursor( bAllowDragging ? EMouseCursor::GrabHand : EMouseCursor::Default )
.OnDragDetected( this, &SAssetView::OnDraggingAssetItem );
TSharedRef<SAssetTileItem> Item =
SNew(SAssetTileItem)
.AssetItem(AssetItem)
.ItemWidth(this, &SAssetView::GetTileViewItemWidth)
.OnRenameBegin(this, &SAssetView::AssetRenameBegin)
.OnRenameCommit(this, &SAssetView::AssetRenameCommit)
.OnVerifyRenameCommit(this, &SAssetView::AssetVerifyRenameCommit)
.OnItemDestroyed(this, &SAssetView::AssetItemWidgetDestroyed)
.ShouldAllowToolTip(this, &SAssetView::ShouldAllowToolTips)
.HighlightText( HighlightedText )
.IsSelected( FIsSelected::CreateSP(TableRowWidget.Get(), &STableRow<TSharedPtr<FAssetViewItem>>::IsSelectedExclusively) )
.OnAssetsDragDropped(this, &SAssetView::OnAssetsDragDropped)
.OnPathsDragDropped(this, &SAssetView::OnPathsDragDropped)
.OnFilesDragDropped(this, &SAssetView::OnFilesDragDropped);
TableRowWidget->SetContent(Item);
return TableRowWidget.ToSharedRef();
}
else
{
TSharedPtr<FAssetViewAsset> AssetItemAsAsset = StaticCastSharedPtr<FAssetViewAsset>(AssetItem);
TSharedPtr<FAssetThumbnail>* AssetThumbnailPtr = RelevantThumbnails.Find(AssetItemAsAsset);
TSharedPtr<FAssetThumbnail> AssetThumbnail;
if ( AssetThumbnailPtr )
{
AssetThumbnail = *AssetThumbnailPtr;
}
else
{
const float ThumbnailResolution = TileViewThumbnailResolution;
AssetThumbnail = MakeShareable( new FAssetThumbnail( AssetItemAsAsset->Data, ThumbnailResolution, ThumbnailResolution, AssetThumbnailPool ) );
RelevantThumbnails.Add( AssetItemAsAsset, AssetThumbnail );
AssetThumbnail->GetViewportRenderTargetTexture(); // Access the texture once to trigger it to render
}
TSharedPtr< STableRow<TSharedPtr<FAssetViewItem>> > TableRowWidget;
SAssignNew( TableRowWidget, STableRow<TSharedPtr<FAssetViewItem>>, OwnerTable )
.Style(FEditorStyle::Get(), "ContentBrowser.AssetListView.TableRow")
.Cursor( bAllowDragging ? EMouseCursor::GrabHand : EMouseCursor::Default )
.OnDragDetected( this, &SAssetView::OnDraggingAssetItem );
TSharedRef<SAssetTileItem> Item =
SNew(SAssetTileItem)
.AssetThumbnail(AssetThumbnail)
.AssetItem(AssetItem)
.ThumbnailPadding(TileViewThumbnailPadding)
.ItemWidth(this, &SAssetView::GetTileViewItemWidth)
.OnRenameBegin(this, &SAssetView::AssetRenameBegin)
.OnRenameCommit(this, &SAssetView::AssetRenameCommit)
.OnVerifyRenameCommit(this, &SAssetView::AssetVerifyRenameCommit)
.OnItemDestroyed(this, &SAssetView::AssetItemWidgetDestroyed)
.ShouldAllowToolTip(this, &SAssetView::ShouldAllowToolTips)
.HighlightText( HighlightedText )
.ThumbnailEditMode(this, &SAssetView::IsThumbnailEditMode)
.ThumbnailLabel( ThumbnailLabel )
.ThumbnailHintColorAndOpacity( this, &SAssetView::GetThumbnailHintColorAndOpacity )
.AllowThumbnailHintLabel( AllowThumbnailHintLabel )
.IsSelected( FIsSelected::CreateSP(TableRowWidget.Get(), &STableRow<TSharedPtr<FAssetViewItem>>::IsSelectedExclusively) )
.OnGetCustomAssetToolTip(OnGetCustomAssetToolTip)
.OnVisualizeAssetToolTip( OnVisualizeAssetToolTip )
.OnAssetToolTipClosing( OnAssetToolTipClosing );
TableRowWidget->SetContent(Item);
return TableRowWidget.ToSharedRef();
}
}
TSharedRef<ITableRow> SAssetView::MakeColumnViewWidget(TSharedPtr<FAssetViewItem> AssetItem, const TSharedRef<STableViewBase>& OwnerTable)
{
if ( !ensure(AssetItem.IsValid()) )
{
return SNew( STableRow<TSharedPtr<FAssetViewItem>>, OwnerTable )
.Style(FEditorStyle::Get(), "ContentBrowser.AssetListView.TableRow");
}
return
SNew( SAssetColumnViewRow, OwnerTable )
.OnDragDetected( this, &SAssetView::OnDraggingAssetItem )
.Cursor( bAllowDragging ? EMouseCursor::GrabHand : EMouseCursor::Default )
.AssetColumnItem(
SNew(SAssetColumnItem)
.AssetItem(AssetItem)
.OnRenameBegin(this, &SAssetView::AssetRenameBegin)
.OnRenameCommit(this, &SAssetView::AssetRenameCommit)
.OnVerifyRenameCommit(this, &SAssetView::AssetVerifyRenameCommit)
.OnItemDestroyed(this, &SAssetView::AssetItemWidgetDestroyed)
.HighlightText( HighlightedText )
.OnAssetsDragDropped(this, &SAssetView::OnAssetsDragDropped)
.OnPathsDragDropped(this, &SAssetView::OnPathsDragDropped)
.OnFilesDragDropped(this, &SAssetView::OnFilesDragDropped)
.OnGetCustomAssetToolTip(OnGetCustomAssetToolTip)
.OnVisualizeAssetToolTip( OnVisualizeAssetToolTip )
.OnAssetToolTipClosing( OnAssetToolTipClosing )
);
}
UObject* SAssetView::CreateAssetFromTemporary(FString InName, const TSharedPtr<FAssetViewAsset>& InItem, FText& OutErrorText)
{
UObject* Asset = NULL;
const EAssetItemType::Type ItemType = InItem->GetType();
if ( ItemType == EAssetItemType::Creation )
{
// Committed creation
TSharedPtr<FAssetViewCreation> CreationItem = StaticCastSharedPtr<FAssetViewCreation>(InItem);
UFactory* Factory = CreationItem->Factory;
UClass* AssetClass = CreationItem->AssetClass;
FString PackagePath = CreationItem->Data.PackagePath.ToString();
// Remove the temporary item before we do any work to ensure the new item creation is not prevented.
FilteredAssetItems.Remove(InItem);
RefreshList();
if ( AssetClass || Factory )
{
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
Asset = AssetToolsModule.Get().CreateAsset(InName, PackagePath, AssetClass, Factory, FName("ContentBrowserNewAsset"));
}
if ( Asset == NULL )
{
OutErrorText = LOCTEXT("AssetCreationFailed", "Failed to create asset.");
}
}
else if ( ItemType == EAssetItemType::Duplication )
{
// Committed duplication
TSharedPtr<FAssetViewDuplication> DuplicationItem = StaticCastSharedPtr<FAssetViewDuplication>(InItem);
UObject* SourceObject = DuplicationItem->SourceObject.Get();
FString PackagePath = DuplicationItem->Data.PackagePath.ToString();
// Remove the temporary item before we do any work to ensure the new item creation is not prevented.
FilteredAssetItems.Remove(InItem);
RefreshList();
if ( SourceObject )
{
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
Asset = AssetToolsModule.Get().DuplicateAsset(InName, PackagePath, SourceObject);
}
if ( Asset == NULL )
{
OutErrorText = LOCTEXT("AssetCreationFailed", "Failed to create asset.");
}
}
return Asset;
}
void SAssetView::AssetItemWidgetDestroyed(const TSharedPtr<FAssetViewItem>& Item)
{
if(RenamingAsset.Pin().Get() == Item.Get())
{
/* Check if the item is in a temp state and if it is, commit using the default name so that it does not entirely vanish on the user.
This keeps the functionality consistent for content to never be in a temporary state */
if ( Item.IsValid() && Item->IsTemporaryItem() && Item->GetType() != EAssetItemType::Folder )
{
FText OutErrorText;
const TSharedPtr<FAssetViewAsset>& ItemAsAsset = StaticCastSharedPtr<FAssetViewAsset>(Item);
CreateAssetFromTemporary(ItemAsAsset->Data.AssetName.ToString(), ItemAsAsset, OutErrorText);
// Remove the temporary item.
FilteredAssetItems.Remove(Item);
RefreshList();
}
RenamingAsset.Reset();
}
if ( VisibleItems.Remove(Item) != INDEX_NONE )
{
bPendingUpdateThumbnails = true;
}
}
void SAssetView::UpdateThumbnails()
{
int32 MinItemIdx = INDEX_NONE;
int32 MaxItemIdx = INDEX_NONE;
int32 MinVisibleItemIdx = INDEX_NONE;
int32 MaxVisibleItemIdx = INDEX_NONE;
const int32 HalfNumOffscreenThumbnails = NumOffscreenThumbnails * 0.5;
for ( auto ItemIt = VisibleItems.CreateConstIterator(); ItemIt; ++ItemIt )
{
int32 ItemIdx = FilteredAssetItems.Find(*ItemIt);
if ( ItemIdx != INDEX_NONE )
{
const int32 ItemIdxLow = FMath::Max<int32>(0, ItemIdx - HalfNumOffscreenThumbnails);
const int32 ItemIdxHigh = FMath::Min<int32>(FilteredAssetItems.Num() - 1, ItemIdx + HalfNumOffscreenThumbnails);
if ( MinItemIdx == INDEX_NONE || ItemIdxLow < MinItemIdx )
{
MinItemIdx = ItemIdxLow;
}
if ( MaxItemIdx == INDEX_NONE || ItemIdxHigh > MaxItemIdx )
{
MaxItemIdx = ItemIdxHigh;
}
if ( MinVisibleItemIdx == INDEX_NONE || ItemIdx < MinVisibleItemIdx )
{
MinVisibleItemIdx = ItemIdx;
}
if ( MaxVisibleItemIdx == INDEX_NONE || ItemIdx > MaxVisibleItemIdx )
{
MaxVisibleItemIdx = ItemIdx;
}
}
}
if ( MinItemIdx != INDEX_NONE && MaxItemIdx != INDEX_NONE && MinVisibleItemIdx != INDEX_NONE && MaxVisibleItemIdx != INDEX_NONE )
{
// We have a new min and a new max, compare it to the old min and max so we can create new thumbnails
// when appropriate and remove old thumbnails that are far away from the view area.
TMap< TSharedPtr<FAssetViewAsset>, TSharedPtr<FAssetThumbnail> > NewRelevantThumbnails;
// Operate on offscreen items that are furthest away from the visible items first since the thumbnail pool processes render requests in a LIFO order.
while (MinItemIdx < MinVisibleItemIdx || MaxItemIdx > MaxVisibleItemIdx)
{
const int32 LowEndDistance = MinVisibleItemIdx - MinItemIdx;
const int32 HighEndDistance = MaxItemIdx - MaxVisibleItemIdx;
if ( HighEndDistance > LowEndDistance )
{
if(FilteredAssetItems.IsValidIndex(MaxItemIdx) && FilteredAssetItems[MaxItemIdx]->GetType() != EAssetItemType::Folder)
{
AddItemToNewThumbnailRelevancyMap( StaticCastSharedPtr<FAssetViewAsset>(FilteredAssetItems[MaxItemIdx]), NewRelevantThumbnails );
}
MaxItemIdx--;
}
else
{
if(FilteredAssetItems.IsValidIndex(MinItemIdx) && FilteredAssetItems[MinItemIdx]->GetType() != EAssetItemType::Folder)
{
AddItemToNewThumbnailRelevancyMap( StaticCastSharedPtr<FAssetViewAsset>(FilteredAssetItems[MinItemIdx]), NewRelevantThumbnails );
}
MinItemIdx++;
}
}
// Now operate on VISIBLE items then prioritize them so they are rendered first
TArray< TSharedPtr<FAssetThumbnail> > ThumbnailsToPrioritize;
for ( int32 ItemIdx = MinVisibleItemIdx; ItemIdx <= MaxVisibleItemIdx; ++ItemIdx )
{
if(FilteredAssetItems.IsValidIndex(ItemIdx) && FilteredAssetItems[ItemIdx]->GetType() != EAssetItemType::Folder)
{
TSharedPtr<FAssetThumbnail> Thumbnail = AddItemToNewThumbnailRelevancyMap( StaticCastSharedPtr<FAssetViewAsset>(FilteredAssetItems[ItemIdx]), NewRelevantThumbnails );
if ( Thumbnail.IsValid() )
{
ThumbnailsToPrioritize.Add(Thumbnail);
}
}
}
// Now prioritize all thumbnails there were in the visible range
if ( ThumbnailsToPrioritize.Num() > 0 )
{
AssetThumbnailPool->PrioritizeThumbnails(ThumbnailsToPrioritize, CurrentThumbnailSize, CurrentThumbnailSize);
}
// Assign the new map of relevant thumbnails. This will remove any entries that were no longer relevant.
RelevantThumbnails = NewRelevantThumbnails;
}
}
TSharedPtr<FAssetThumbnail> SAssetView::AddItemToNewThumbnailRelevancyMap(const TSharedPtr<FAssetViewAsset>& Item, TMap< TSharedPtr<FAssetViewAsset>, TSharedPtr<FAssetThumbnail> >& NewRelevantThumbnails)
{
const TSharedPtr<FAssetThumbnail>* Thumbnail = RelevantThumbnails.Find(Item);
if ( Thumbnail )
{
// The thumbnail is still relevant, add it to the new list
NewRelevantThumbnails.Add(Item, *Thumbnail);
return *Thumbnail;
}
else
{
if ( !ensure(CurrentThumbnailSize > 0 && CurrentThumbnailSize <= MAX_THUMBNAIL_SIZE) )
{
// Thumbnail size must be in a sane range
CurrentThumbnailSize = 64;
}
// The thumbnail newly relevant, create a new thumbnail
const float ThumbnailResolution = CurrentThumbnailSize * MaxThumbnailScale;
TSharedPtr<FAssetThumbnail> NewThumbnail = MakeShareable( new FAssetThumbnail( Item->Data, ThumbnailResolution, ThumbnailResolution, AssetThumbnailPool ) );
NewRelevantThumbnails.Add( Item, NewThumbnail );
NewThumbnail->GetViewportRenderTargetTexture(); // Access the texture once to trigger it to render
return NewThumbnail;
}
}
void SAssetView::AssetSelectionChanged( TSharedPtr< struct FAssetViewItem > AssetItem, ESelectInfo::Type SelectInfo )
{
if ( !bBulkSelecting )
{
if ( AssetItem.IsValid() && AssetItem->GetType() != EAssetItemType::Folder )
{
OnAssetSelected.ExecuteIfBound(StaticCastSharedPtr<FAssetViewAsset>(AssetItem)->Data);
}
else
{
OnAssetSelected.ExecuteIfBound(FAssetData());
}
}
}
void SAssetView::ItemScrolledIntoView(TSharedPtr<struct FAssetViewItem> AssetItem, const TSharedPtr<ITableRow>& Widget )
{
if ( AssetItem->bRenameWhenScrolledIntoview )
{
// Make sure we have window focus to avoid the inline text editor from canceling itself if we try to click on it
// This can happen if creating an asset opens an intermediary window which steals our focus,
// eg, the blueprint and slate widget style class windows (TTP# 314240)
TSharedPtr<SWindow> OwnerWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
if(OwnerWindow.IsValid())
{
OwnerWindow->BringToFront();
}
AwaitingRename = AssetItem;
}
}
TSharedPtr<SWidget> SAssetView::OnGetContextMenuContent()
{
if ( CanOpenContextMenu() )
{
const TArray<FString> SelectedFolders = GetSelectedFolders();
if(SelectedFolders.Num() > 0)
{
return OnGetFolderContextMenu.Execute(SelectedFolders, OnGetPathContextMenuExtender, FOnCreateNewFolder::CreateSP(this, &SAssetView::OnCreateNewFolder));
}
else
{
return OnGetAssetContextMenu.Execute(GetSelectedAssets());
}
}
return NULL;
}
bool SAssetView::CanOpenContextMenu() const
{
if ( !OnGetAssetContextMenu.IsBound() )
{
// You can only a summon a context menu if one is set up
return false;
}
if ( IsThumbnailEditMode() )
{
// You can not summon a context menu for assets when in thumbnail edit mode because right clicking may happen inadvertently while adjusting thumbnails.
return false;
}
TArray<FAssetData> SelectedAssets = GetSelectedAssets();
// Detect if at least one temporary item was selected. If there were no valid assets selected and a temporary one was, then deny the context menu.
TArray<TSharedPtr<FAssetViewItem>> SelectedItems = GetSelectedItems();
bool bAtLeastOneTemporaryItemFound = false;
for ( auto ItemIt = SelectedItems.CreateConstIterator(); ItemIt; ++ItemIt )
{
const TSharedPtr<FAssetViewItem>& Item = *ItemIt;
if ( Item->IsTemporaryItem() )
{
bAtLeastOneTemporaryItemFound = true;
}
}
// If there were no valid assets found, but some invalid assets were found, deny the context menu
if ( SelectedAssets.Num() == 0 && bAtLeastOneTemporaryItemFound )
{
return false;
}
if ( SelectedAssets.Num() == 0 && SourcesData.HasCollections() )
{
// Don't allow a context menu when we're viewing a collection and have no assets selected
return false;
}
// Build a list of selected object paths
TArray<FString> ObjectPaths;
for(auto AssetIt = SelectedAssets.CreateConstIterator(); AssetIt; ++AssetIt)
{
ObjectPaths.Add( AssetIt->ObjectPath.ToString() );
}
bool bLoadSuccessful = true;
if ( bPreloadAssetsForContextMenu )
{
// Get and load assets that are unloaded
TArray<FString> UnloadedObjects;
ContentBrowserUtils::GetUnloadedAssets(ObjectPaths, UnloadedObjects);
TArray<UObject*> LoadedObjects;
const bool bAllowedToPrompt = false;
bLoadSuccessful = ContentBrowserUtils::LoadAssetsIfNeeded(ObjectPaths, LoadedObjects, bAllowedToPrompt);
}
// Do not show the context menu if the load failed
return bLoadSuccessful;
}
void SAssetView::OnListMouseButtonDoubleClick(TSharedPtr<FAssetViewItem> AssetItem)
{
if ( !ensure(AssetItem.IsValid()) )
{
return;
}
if ( IsThumbnailEditMode() )
{
// You can not activate assets when in thumbnail edit mode because double clicking may happen inadvertently while adjusting thumbnails.
return;
}
if ( AssetItem->GetType() == EAssetItemType::Folder )
{
OnPathSelected.ExecuteIfBound(StaticCastSharedPtr<FAssetViewFolder>(AssetItem)->FolderPath);
return;
}
if ( AssetItem->IsTemporaryItem() )
{
// You may not activate temporary items, they are just for display.
return;
}
TArray<FAssetData> ActivatedAssets;
ActivatedAssets.Add(StaticCastSharedPtr<FAssetViewAsset>(AssetItem)->Data);
OnAssetsActivated.ExecuteIfBound( ActivatedAssets, EAssetTypeActivationMethod::DoubleClicked );
}
FReply SAssetView::OnDraggingAssetItem( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
{
if ( bAllowDragging )
{
TArray<FAssetData> AssetDataList = GetSelectedAssets();
if (AssetDataList.Num())
{
// We have some items selected, start a drag-drop
TArray<FAssetData> InAssetData;
for (int32 AssetIdx = 0; AssetIdx < AssetDataList.Num(); ++AssetIdx)
{
const FAssetData& AssetData = AssetDataList[AssetIdx];
if ( !AssetData.IsValid() || AssetData.AssetClass == UObjectRedirector::StaticClass()->GetFName() )
{
// Skip invalid assets and redirectors
continue;
}
// If dragging a class, send though an FAssetData whose name is null and class is this class' name
InAssetData.Add(AssetData);
}
if( InAssetData.Num() > 0 )
{
UActorFactory* FactoryToUse = nullptr;
FEditorDelegates::OnAssetDragStarted.Broadcast( InAssetData, FactoryToUse );
if( MouseEvent.IsMouseButtonDown( EKeys::LeftMouseButton ) )
{
return FReply::Handled().BeginDragDrop( FAssetDragDropOp::New( InAssetData ) );
}
else
{
return FReply::Handled();
}
}
}
else
{
// are we dragging some folders?
TArray<FString> SelectedFolders = GetSelectedFolders();
if(SelectedFolders.Num() > 0 && !SourcesData.HasCollections())
{
return FReply::Handled().BeginDragDrop(FAssetPathDragDropOp::New(SelectedFolders));
}
}
}
return FReply::Unhandled();
}
bool SAssetView::AssetVerifyRenameCommit(const TSharedPtr<FAssetViewItem>& Item, const FText& NewName, const FSlateRect& MessageAnchor, FText& OutErrorMessage)
{
// Everything other than a folder is considered an asset, including "Creation" and "Duplication"
// See FAssetViewCreation and FAssetViewDuplication
const bool bIsAssetType = Item->GetType() != EAssetItemType::Folder;
FString NewNameString = NewName.ToString();
if ( bIsAssetType )
{
const TSharedPtr<FAssetViewAsset>& ItemAsAsset = StaticCastSharedPtr<FAssetViewAsset>(Item);
if ( !Item->IsTemporaryItem() && NewNameString == ItemAsAsset->Data.AssetName.ToString() )
{
return true;
}
}
else
{
const TSharedPtr<FAssetViewFolder>& ItemAsFolder = StaticCastSharedPtr<FAssetViewFolder>(Item);
if (NewNameString == ItemAsFolder->FolderName.ToString())
{
return true;
}
}
if ( bIsAssetType )
{
const TSharedPtr<FAssetViewAsset>& ItemAsAsset = StaticCastSharedPtr<FAssetViewAsset>(Item);
const FString NewObjectPath = ItemAsAsset->Data.PackagePath.ToString() / NewNameString + TEXT(".") + NewNameString;
return ContentBrowserUtils::IsValidObjectPathForCreate(NewObjectPath, OutErrorMessage);
}
else
{
const TSharedPtr<FAssetViewFolder>& ItemAsFolder = StaticCastSharedPtr<FAssetViewFolder>(Item);
const FString FolderPath = FPaths::GetPath(ItemAsFolder->FolderPath);
return ContentBrowserUtils::IsValidFolderPathForCreate(FolderPath, NewNameString, OutErrorMessage);
}
return true;
}
void SAssetView::AssetRenameBegin(const TSharedPtr<FAssetViewItem>& Item, const FString& NewName, const FSlateRect& MessageAnchor)
{
check(!RenamingAsset.IsValid());
RenamingAsset = Item;
}
void SAssetView::AssetRenameCommit(const TSharedPtr<FAssetViewItem>& Item, const FString& NewName, const FSlateRect& MessageAnchor, const ETextCommit::Type CommitType)
{
const EAssetItemType::Type ItemType = Item->GetType();
// If the item had a factory, create a new object, otherwise rename
bool bSuccess = false;
UObject* Asset = NULL;
FText ErrorMessage;
if ( ItemType == EAssetItemType::Normal )
{
const TSharedPtr<FAssetViewAsset>& ItemAsAsset = StaticCastSharedPtr<FAssetViewAsset>(Item);
// Check if the name is different
if( NewName.Equals(ItemAsAsset->Data.AssetName.ToString(), ESearchCase::CaseSensitive) )
{
RenamingAsset.Reset();
return;
}
// Committed rename
Asset = ItemAsAsset->Data.GetAsset();
if(Asset == NULL)
{
//put back the original name
RenamingAsset.Reset();
//Notify the user rename fail and link the output log
FNotificationInfo Info(LOCTEXT("RenameAssetsFailed", "Failed to rename assets"));
Info.ExpireDuration = 5.0f;
Info.Hyperlink = FSimpleDelegate::CreateStatic([](){ FGlobalTabmanager::Get()->InvokeTab(FName("OutputLog")); });
Info.HyperlinkText = LOCTEXT("ShowOutputLogHyperlink", "Show Output Log");
FSlateNotificationManager::Get().AddNotification(Info);
//Set the content browser error message
ErrorMessage = LOCTEXT("RenameAssetsFailed", "Failed to rename assets");
}
else
{
ContentBrowserUtils::RenameAsset(Asset, NewName, ErrorMessage);
bSuccess = true;
}
}
else if ( ItemType == EAssetItemType::Creation || ItemType == EAssetItemType::Duplication )
{
if (CommitType == ETextCommit::OnCleared)
{
// Clearing the rename box on a newly created asset cancels the entire creation process
FilteredAssetItems.Remove(Item);
RefreshList();
}
else
{
Asset = CreateAssetFromTemporary(NewName, StaticCastSharedPtr<FAssetViewAsset>(Item), ErrorMessage);
bSuccess = Asset != NULL;
}
}
else if( ItemType == EAssetItemType::Folder )
{
const TSharedPtr<FAssetViewFolder>& ItemAsFolder = StaticCastSharedPtr<FAssetViewFolder>(Item);
if(ItemAsFolder->bNewFolder)
{
ItemAsFolder->bNewFolder = false;
const FString NewPath = FPaths::GetPath(ItemAsFolder->FolderPath) / NewName;
FText ErrorText;
if( ContentBrowserUtils::IsValidFolderName(NewName, ErrorText) &&
!ContentBrowserUtils::DoesFolderExist(NewPath))
{
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
bSuccess = AssetRegistryModule.Get().AddPath(NewPath);
}
// remove this temp item - a new one will have been added by the asset registry callback
FilteredAssetItems.Remove(Item);
RefreshList();
if(!bSuccess)
{
ErrorMessage = LOCTEXT("CreateFolderFailed", "Failed to create folder.");
}
}
else if(NewName != ItemAsFolder->FolderName.ToString())
{
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
// first create the new folder
const FString NewPath = FPaths::GetPath(ItemAsFolder->FolderPath) / NewName;
FText ErrorText;
if( ContentBrowserUtils::IsValidFolderName(NewName, ErrorText) &&
!ContentBrowserUtils::DoesFolderExist(NewPath))
{
bSuccess = AssetRegistryModule.Get().AddPath(NewPath);
}
if(bSuccess)
{
// move any assets in our folder
TArray<FAssetData> AssetsInFolder;
AssetRegistryModule.Get().GetAssetsByPath(*ItemAsFolder->FolderPath, AssetsInFolder, true);
TArray<UObject*> ObjectsInFolder;
ContentBrowserUtils::GetObjectsInAssetData(AssetsInFolder, ObjectsInFolder);
ContentBrowserUtils::MoveAssets(ObjectsInFolder, NewPath, ItemAsFolder->FolderPath);
// Now check to see if the original folder is empty, if so we can delete it
TArray<FAssetData> AssetsInOriginalFolder;
AssetRegistryModule.Get().GetAssetsByPath(*ItemAsFolder->FolderPath, AssetsInOriginalFolder, true);
if(AssetsInOriginalFolder.Num() == 0)
{
TArray<FString> FoldersToDelete;
FoldersToDelete.Add(ItemAsFolder->FolderPath);
ContentBrowserUtils::DeleteFolders(FoldersToDelete);
}
}
RequestQuickFrontendListRefresh();
}
}
else
{
// Unknown AssetItemType
ensure(0);
}
if ( bSuccess && ItemType != EAssetItemType::Folder )
{
if ( ensure(Asset != NULL) )
{
// Sort in the new item
bPendingSortFilteredItems = true;
RequestQuickFrontendListRefresh();
// Refresh the thumbnail
const TSharedPtr<FAssetThumbnail>* AssetThumbnail = RelevantThumbnails.Find(StaticCastSharedPtr<FAssetViewAsset>(Item));
if ( AssetThumbnail )
{
AssetThumbnailPool->RefreshThumbnail(*AssetThumbnail);
}
// Sync to its location
TArray<FAssetData> AssetDataList;
new(AssetDataList) FAssetData(Asset);
if ( OnAssetRenameCommitted.IsBound() )
{
// If our parent wants to potentially handle the sync, let it
OnAssetRenameCommitted.Execute(AssetDataList);
}
else
{
// Otherwise, sync just the view
SyncToAssets(AssetDataList);
}
}
}
else if ( !ErrorMessage.IsEmpty() )
{
// Prompt the user with the reason the rename/creation failed
ContentBrowserUtils::DisplayMessage(ErrorMessage, MessageAnchor, SharedThis(this));
}
RenamingAsset.Reset();
}
bool SAssetView::IsRenamingAsset() const
{
return RenamingAsset.IsValid();
}
bool SAssetView::ShouldAllowToolTips() const
{
bool bIsRightClickScrolling = false;
switch( CurrentViewType )
{
case EAssetViewType::List:
bIsRightClickScrolling = ListView->IsRightClickScrolling();
break;
case EAssetViewType::Tile:
bIsRightClickScrolling = TileView->IsRightClickScrolling();
break;
case EAssetViewType::Column:
bIsRightClickScrolling = ColumnView->IsRightClickScrolling();
break;
default:
bIsRightClickScrolling = false;
break;
}
return !bIsRightClickScrolling && !IsThumbnailEditMode() && !IsRenamingAsset();
}
bool SAssetView::IsThumbnailEditMode() const
{
return IsThumbnailEditModeAllowed() && bThumbnailEditMode;
}
bool SAssetView::IsThumbnailEditModeAllowed() const
{
return bAllowThumbnailEditMode && GetCurrentViewType() != EAssetViewType::Column;
}
FReply SAssetView::EndThumbnailEditModeClicked()
{
bThumbnailEditMode = false;
return FReply::Handled();
}
FText SAssetView::GetAssetCountText() const
{
const int32 NumAssets = FilteredAssetItems.Num();
const int32 NumSelectedAssets = GetSelectedItems().Num();
FText AssetCount = FText::GetEmpty();
if ( NumSelectedAssets == 0 )
{
if ( NumAssets == 1 )
{
AssetCount = LOCTEXT("AssetCountLabelSingular", "1 item");
}
else
{
AssetCount = FText::Format( LOCTEXT("AssetCountLabelPlural", "{0} items"), FText::AsNumber(NumAssets) );
}
}
else
{
if ( NumAssets == 1 )
{
AssetCount = FText::Format( LOCTEXT("AssetCountLabelSingularPlusSelection", "1 item ({0} selected)"), FText::AsNumber(NumSelectedAssets) );
}
else
{
AssetCount = FText::Format( LOCTEXT("AssetCountLabelPluralPlusSelection", "{0} items ({1} selected)"), FText::AsNumber(NumAssets), FText::AsNumber(NumSelectedAssets) );
}
}
return AssetCount;
}
EVisibility SAssetView::GetEditModeLabelVisibility() const
{
return IsThumbnailEditMode() ? EVisibility::Visible : EVisibility::Collapsed;
}
EVisibility SAssetView::GetListViewVisibility() const
{
return GetCurrentViewType() == EAssetViewType::List ? EVisibility::Visible : EVisibility::Collapsed;
}
EVisibility SAssetView::GetTileViewVisibility() const
{
return GetCurrentViewType() == EAssetViewType::Tile ? EVisibility::Visible : EVisibility::Collapsed;
}
EVisibility SAssetView::GetColumnViewVisibility() const
{
return GetCurrentViewType() == EAssetViewType::Column ? EVisibility::Visible : EVisibility::Collapsed;
}
void SAssetView::ToggleThumbnailEditMode()
{
bThumbnailEditMode = !bThumbnailEditMode;
}
float SAssetView::GetThumbnailScale() const
{
return ThumbnailScaleSliderValue.Get();
}
void SAssetView::SetThumbnailScale( float NewValue )
{
ThumbnailScaleSliderValue = NewValue;
RefreshList();
}
bool SAssetView::IsThumbnailScalingLocked() const
{
return GetCurrentViewType() == EAssetViewType::Column;
}
float SAssetView::GetListViewItemHeight() const
{
return (ListViewThumbnailSize + ListViewThumbnailPadding * 2) * FMath::Lerp(MinThumbnailScale, MaxThumbnailScale, GetThumbnailScale());
}
float SAssetView::GetTileViewItemHeight() const
{
return TileViewNameHeight + GetTileViewItemBaseHeight() * FillScale;
}
float SAssetView::GetTileViewItemBaseHeight() const
{
return (TileViewThumbnailSize + TileViewThumbnailPadding * 2) * FMath::Lerp(MinThumbnailScale, MaxThumbnailScale, GetThumbnailScale());
}
float SAssetView::GetTileViewItemWidth() const
{
return GetTileViewItemBaseWidth() * FillScale;
}
float SAssetView::GetTileViewItemBaseWidth() const //-V524
{
return ( TileViewThumbnailSize + TileViewThumbnailPadding * 2 ) * FMath::Lerp( MinThumbnailScale, MaxThumbnailScale, GetThumbnailScale() );
}
EColumnSortMode::Type SAssetView::GetColumnSortMode(const FName ColumnId) const
{
for (int32 PriorityIdx = 0; PriorityIdx < EColumnSortPriority::Max; PriorityIdx++)
{
const EColumnSortPriority::Type SortPriority = static_cast<EColumnSortPriority::Type>(PriorityIdx);
if (ColumnId == SortManager.GetSortColumnId(SortPriority))
{
return SortManager.GetSortMode(SortPriority);
}
}
return EColumnSortMode::None;
}
EColumnSortPriority::Type SAssetView::GetColumnSortPriority(const FName ColumnId) const
{
for (int32 PriorityIdx = 0; PriorityIdx < EColumnSortPriority::Max; PriorityIdx++)
{
const EColumnSortPriority::Type SortPriority = static_cast<EColumnSortPriority::Type>(PriorityIdx);
if (ColumnId == SortManager.GetSortColumnId(SortPriority))
{
return SortPriority;
}
}
return EColumnSortPriority::Primary;
}
void SAssetView::OnSortColumnHeader(const EColumnSortPriority::Type SortPriority, const FName& ColumnId, const EColumnSortMode::Type NewSortMode)
{
SortManager.SetSortColumnId(SortPriority, ColumnId);
SortManager.SetSortMode(SortPriority, NewSortMode);
SortList();
}
EVisibility SAssetView::IsAssetShowWarningTextVisible() const
{
return FilteredAssetItems.Num() > 0 ? EVisibility::Collapsed : EVisibility::HitTestInvisible;
}
FText SAssetView::GetAssetShowWarningText() const
{
if (AssetShowWarningText.IsBound())
{
return AssetShowWarningText.Get();
}
FText NothingToShowText, DropText;
if (ShouldFilterRecursively())
{
NothingToShowText = LOCTEXT( "NothingToShowCheckFilter", "No results, check your filter." );
}
if ( SourcesData.HasCollections() && !SourcesData.IsDynamicCollection() )
{
DropText = LOCTEXT( "DragAssetsHere", "Drag and drop assets here to add them to the collection." );
}
else if ( OnGetAssetContextMenu.IsBound() )
{
DropText = LOCTEXT( "DropFilesOrRightClick", "Drop files here or right click to create content." );
}
return NothingToShowText.IsEmpty() ? DropText : FText::Format(LOCTEXT("NothingToShowPattern", "{0}\n\n{1}"), NothingToShowText, DropText);
}
bool SAssetView::HasSingleCollectionSource() const
{
return ( SourcesData.Collections.Num() == 1 && SourcesData.PackagePaths.Num() == 0 );
}
void SAssetView::OnAssetsDragDropped(const TArray<FAssetData>& AssetList, const FString& DestinationPath)
{
DragDropHandler::HandleAssetsDroppedOnAssetFolder(
SharedThis(this),
AssetList,
DestinationPath,
FText::FromString(FPaths::GetCleanFilename(DestinationPath)),
DragDropHandler::FExecuteCopyOrMoveAssets::CreateSP(this, &SAssetView::ExecuteDropCopy),
DragDropHandler::FExecuteCopyOrMoveAssets::CreateSP(this, &SAssetView::ExecuteDropMove)
);
}
void SAssetView::OnPathsDragDropped(const TArray<FString>& PathNames, const FString& DestinationPath)
{
DragDropHandler::HandleFoldersDroppedOnAssetFolder(
SharedThis(this),
PathNames,
DestinationPath,
FText::FromString(FPaths::GetCleanFilename(DestinationPath)),
DragDropHandler::FExecuteCopyOrMoveFolders::CreateSP(this, &SAssetView::ExecuteDropCopyFolder),
DragDropHandler::FExecuteCopyOrMoveFolders::CreateSP(this, &SAssetView::ExecuteDropMoveFolder)
);
}
void SAssetView::OnFilesDragDropped(const TArray<FString>& AssetList, const FString& DestinationPath)
{
FAssetToolsModule& AssetToolsModule = FModuleManager::Get().LoadModuleChecked<FAssetToolsModule>("AssetTools");
AssetToolsModule.Get().ImportAssets( AssetList, DestinationPath );
}
void SAssetView::ExecuteDropCopy(TArray<FAssetData> AssetList, FString DestinationPath)
{
TArray<UObject*> DroppedObjects;
ContentBrowserUtils::GetObjectsInAssetData(AssetList, DroppedObjects);
TArray<UObject*> NewObjects;
ObjectTools::DuplicateObjects(DroppedObjects, TEXT(""), DestinationPath, /*bOpenDialog=*/false, &NewObjects);
// If any objects were duplicated, report the success
if ( NewObjects.Num() )
{
FFormatNamedArguments Args;
Args.Add( TEXT("Number"), NewObjects.Num() );
const FText Message = FText::Format( LOCTEXT("AssetsDroppedCopy", "{Number} asset(s) copied"), Args );
const FVector2D& CursorPos = FSlateApplication::Get().GetCursorPos();
FSlateRect MessageAnchor(CursorPos.X, CursorPos.Y, CursorPos.X, CursorPos.Y);
ContentBrowserUtils::DisplayMessage(Message, MessageAnchor, SharedThis(this));
}
}
void SAssetView::ExecuteDropMove(TArray<FAssetData> AssetList, FString DestinationPath)
{
TArray<UObject*> DroppedObjects;
ContentBrowserUtils::GetObjectsInAssetData(AssetList, DroppedObjects);
ContentBrowserUtils::MoveAssets(DroppedObjects, DestinationPath);
}
void SAssetView::ExecuteDropCopyFolder(TArray<FString> PathNames, FString DestinationPath)
{
ContentBrowserUtils::CopyFolders(PathNames, DestinationPath);
}
void SAssetView::ExecuteDropMoveFolder(TArray<FString> PathNames, FString DestinationPath)
{
ContentBrowserUtils::MoveFolders(PathNames, DestinationPath);
}
void SAssetView::SetUserSearching(bool bInSearching)
{
if(bUserSearching != bInSearching)
{
RequestSlowFullListRefresh();
}
bUserSearching = bInSearching;
}
void SAssetView::HandleSettingChanged(FName PropertyName)
{
if ((PropertyName == "DisplayFolders") ||
(PropertyName == "DisplayDevelopersFolder") ||
(PropertyName == "DisplayEngineFolder") ||
(PropertyName == NAME_None)) // @todo: Needed if PostEditChange was called manually, for now
{
RequestSlowFullListRefresh();
}
}
FText SAssetView::GetQuickJumpTerm() const
{
return FText::FromString(QuickJumpData.JumpTerm);
}
EVisibility SAssetView::IsQuickJumpVisible() const
{
return (QuickJumpData.JumpTerm.IsEmpty()) ? EVisibility::Collapsed : EVisibility::HitTestInvisible;
}
FSlateColor SAssetView::GetQuickJumpColor() const
{
return FEditorStyle::GetColor((QuickJumpData.bHasValidMatch) ? "InfoReporting.BackgroundColor" : "ErrorReporting.BackgroundColor");
}
void SAssetView::ResetQuickJump()
{
QuickJumpData.JumpTerm.Empty();
QuickJumpData.bIsJumping = false;
QuickJumpData.bHasChangedSinceLastTick = false;
QuickJumpData.bHasValidMatch = false;
}
FReply SAssetView::HandleQuickJumpKeyDown(const TCHAR InCharacter, const bool bIsControlDown, const bool bIsAltDown, const bool bTestOnly)
{
// Check for special characters
if(bIsControlDown || bIsAltDown)
{
return FReply::Unhandled();
}
// Check for invalid characters
for(int InvalidCharIndex = 0; InvalidCharIndex < ARRAY_COUNT(INVALID_OBJECTNAME_CHARACTERS) - 1; ++InvalidCharIndex)
{
if(InCharacter == INVALID_OBJECTNAME_CHARACTERS[InvalidCharIndex])
{
return FReply::Unhandled();
}
}
switch(InCharacter)
{
// Ignore some other special characters that we don't want to be entered into the buffer
case 0: // Any non-character key press, e.g. f1-f12, Delete, Pause/Break, etc.
// These should be explicitly not handled so that their input bindings are handled higher up the chain.
case 8: // Backspace
case 13: // Enter
case 27: // Esc
return FReply::Unhandled();
default:
break;
}
// Any other character!
if(!bTestOnly)
{
QuickJumpData.JumpTerm.AppendChar(InCharacter);
QuickJumpData.bHasChangedSinceLastTick = true;
}
return FReply::Handled();
}
bool SAssetView::PerformQuickJump(const bool bWasJumping)
{
auto GetAssetViewItemName = [](const TSharedPtr<FAssetViewItem> &Item) -> FString
{
switch(Item->GetType())
{
case EAssetItemType::Normal:
{
const TSharedPtr<FAssetViewAsset>& ItemAsAsset = StaticCastSharedPtr<FAssetViewAsset>(Item);
return ItemAsAsset->Data.AssetName.ToString();
}
case EAssetItemType::Folder:
{
const TSharedPtr<FAssetViewFolder>& ItemAsFolder = StaticCastSharedPtr<FAssetViewFolder>(Item);
return ItemAsFolder->FolderName.ToString();
}
default:
return FString();
}
};
auto JumpToNextMatch = [this, &GetAssetViewItemName](const int StartIndex, const int EndIndex) -> bool
{
check(StartIndex >= 0);
check(EndIndex <= FilteredAssetItems.Num());
for(int NewSelectedItemIndex = StartIndex; NewSelectedItemIndex < EndIndex; ++NewSelectedItemIndex)
{
TSharedPtr<FAssetViewItem>& NewSelectedItem = FilteredAssetItems[NewSelectedItemIndex];
const FString NewSelectedItemName = GetAssetViewItemName(NewSelectedItem);
if(NewSelectedItemName.StartsWith(QuickJumpData.JumpTerm, ESearchCase::IgnoreCase))
{
SetSelection(NewSelectedItem);
RequestScrollIntoView(NewSelectedItem);
return true;
}
}
return false;
};
TArray<TSharedPtr<FAssetViewItem>> SelectedItems = GetSelectedItems();
TSharedPtr<FAssetViewItem> SelectedItem = (SelectedItems.Num()) ? SelectedItems[0] : nullptr;
// If we have a selection, and we were already jumping, first check to see whether
// the current selection still matches the quick-jump term; if it does, we do nothing
if(bWasJumping && SelectedItem.IsValid())
{
const FString SelectedItemName = GetAssetViewItemName(SelectedItem);
if(SelectedItemName.StartsWith(QuickJumpData.JumpTerm, ESearchCase::IgnoreCase))
{
return true;
}
}
// We need to move on to the next match in FilteredAssetItems that starts with the given quick-jump term
const int SelectedItemIndex = (SelectedItem.IsValid()) ? FilteredAssetItems.Find(SelectedItem) : INDEX_NONE;
const int StartIndex = (SelectedItemIndex == INDEX_NONE) ? 0 : SelectedItemIndex + 1;
bool ValidMatch = JumpToNextMatch(StartIndex, FilteredAssetItems.Num());
if(!ValidMatch && StartIndex > 0)
{
// If we didn't find a match, we need to loop around and look again from the start (assuming we weren't already)
return JumpToNextMatch(0, StartIndex);
}
return ValidMatch;
}
#undef LOCTEXT_NAMESPACE