You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb None ========================== MAJOR FEATURES + CHANGES ========================== Change 3108929 on 2016/08/31 by Jon.Nabozny PR #2745: Add FQuat version of SetWorldRotation functions (Contibuted by EverNewJoy) #jira UE-35260 Change 3108930 on 2016/08/31 by Jon.Nabozny Fix out of date URadialForceComponent::CollisionObjectQueryParams by adding a BeginPlay event callback. #jira UE-33880 Change 3108934 on 2016/08/31 by Jon.Nabozny Fix check in UCharacterMovement::StepUp to properly account for distance the component is above the floor. #jira UE-33051 Change3108971on 2016/08/31 by Jon.Nabozny Add missing URadialForceComponent.h changes from CR 3108930 Change 3109557 on 2016/09/01 by Thomas.Sarkanen Copying //Tasks/Dev-Framework/Dev-PersonaUpgrade to Dev-Framework (//UE4/Dev-Framework) Persona Upgrade Summary of changes: - Persona module is now a repository of re-usable components, rather than an asset editor in itself. - Multiple asset editors now exist for specific asset types (Animation, Skeleton, anim BP etc). - Skeleton editing is now performed via the new IEditableSkeleton interface. This wraps up all mutations that can be performed on a skeleton in a model-view type architecture. - Skeleton tree acts as the view of the editable skeleton's data. When an edit is made in one version of a skeleton tree, it is reflected in all of them. - Removed all 'PersonaPtr's. Communication is now performed via delegates and appropriate API bindings (preview scene, editable skeleton etc.) - Viewport reworked to use editor modes for its more specific inputs. Skeletal controls now use editor modes for their inputs. - Better control of 'focus on draw' in the viewport. We can now optionally interpolate in approriate circumstances. - Animation preview scene resurrected. Now we manage much of the underlying objects in the preview scene. It also acts as a messaging conduit for events related to the scene. - We can now add additional meshes to a skeleton for use as previews. This is perfomred via a new UPreviewMeshCollection asset type & edited in the viewport. - Removed old SAdditionalMeshesEditor as the new system replaces its functionality. - Added asset family shortcut bar (and IAssetFamily to support this). - Const corrected some engine functions. - Added the ability for a skel mesh component to function without a primary skeletal mesh. This is usually a transient state in-editor but now the engine will not crash. - Padding, layouts and appearance of all editors have been polished. - Moved recording controls to the viewport and recording code into the preview scene. Now anything that uses a Persona viewport can use recording. - Tweaked recording icon to always use some red (feedback was it was non-obvious that it was a recording button). - Improved anim BP preview editor. We now have a bubtton that copies values that have changed to the defaults so that preview edits can more easily be seen & transferred. - Removed sequence recorder from non-level editor windows. Change 3109628 on 2016/09/01 by Thomas.Sarkanen Fix non-unity build Change 3109639 on 2016/09/01 by Thomas.Sarkanen CIS fix: Monolithic non-editor builds Change 3109648 on 2016/09/01 by Thomas.Sarkanen Properly fix monolithic CIS this time Change 3109683 on 2016/09/01 by Thomas.Sarkanen Fix Mac editor CIS Change 3109689 on 2016/09/01 by Benn.Gallagher Fix crash in when a client spawns a destructible in a world with multiple players, caused by assuming we have a scene when the insertion may be deferred. #jira UE-35353 Change 3109699 on 2016/09/01 by Thomas.Sarkanen More Mac Editor CIS fixes. Change 3109727 on 2016/09/01 by Danny.Bouimad Fixing UE-34814, issue where a socket was not rendering correctly. Note: The old socket wasn't attached to a bone to fix the issue so it was attached to the root bone. Change 3109758 on 2016/09/01 by Thomas.Sarkanen More Mac editor CIS fixes Somehow includes from engine and unrealed were still getting picked up outside of PCH on windows. Updated PCH's and other includes to cover the mssing types. Change 3109829 on 2016/09/01 by Thomas.Sarkanen Fix crash when attaching slave components with differing bone counts Change 3111672 on 2016/09/02 by Thomas.Sarkanen Populated UV channels correctly Delegate for preview mesh change was being fired early (when the preview scene was created), so UV channels were never populated. Added a call to populate on construction. Change 3111924 on 2016/09/02 by Martin.Wilson Clean up references to GetBoneTree and deprecate #jira UE-35525 Change 3112086 on 2016/09/02 by Martin.Wilson Fix pose flickering on LOD change when using Layered Blend by Bone node #Jira UE-35471 Change 3112097 on 2016/09/02 by Aaron.McLeran UE-35533 StopQuietest concurrency not resulting in sounds returning to play - Issue is due to the fact that once an active sound was flagged as needing to stop due to max concurrency, it was never unflagging as needing to stop - Fix is to make sure to unflag active sounds in a concurrency group as bShouldStopDueToMaxConcurrency before flagging the ones that do. Change 3112467 on 2016/09/02 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3112269 Change 3112604 on 2016/09/02 by Lina.Halper Fixed merge compile error Change 3113524 on 2016/09/05 by Thomas.Sarkanen Prevent invalid assets from causing crashes with asset families Store asset references as weak object ptrs as assets can go away underneath us. Also dont preserve asset families when all referencing asset editors are shut down, use weak references instead. #jira UE-35572 - Crash when opening Child Montage after force deleting an older child montage with the same name from the same asset Change 3114118 on 2016/09/06 by Marc.Audy Add boolean return to AGameMode::ClearPause to indicate whether pausing was cleared #jira UE-32852 Change 3114201 on 2016/09/06 by Lina.Halper #ANMI: Moving animation curves from asset to skeleton - Backward compatibility - AnimCurve Viewer contains the setting of changing curve type - only material or morph would display. - Morphtarget curves are automatically set on loading - Asset still contains curve type including editable or disabled and so on. I was going to make this to be editor only but I can't until we copy over all the data - because morphtarget/material deprecated flags are needed to be loaded in game - TODO: Moving cached UI to FBoneContainer, so that it can work with RequiredBones - TODO: Linking curve to joint - TODO: Allow Layer blending to use this data to blend curves #Code review:Martin.Wilson, James.Golding #jira: UEFW-179 Change 3114391 on 2016/09/06 by Lina.Halper Build warning fix Change 3114399 on 2016/09/06 by Lina.Halper Fix build error. Change 3114403 on 2016/09/06 by Lina.Halper Attempt to fix build error Change 3114591 on 2016/09/06 by Lina.Halper Fix compile error Change 3114963 on 2016/09/06 by Lina.Halper Fixed crash on deleting skeleton when placed in the level #jira: UE-35601 Change 3114985 on 2016/09/06 by Lina.Halper Fix crash with copy pose mesh node not checking registered or not. #jira: UE-35602 Change 3115933 on 2016/09/07 by James.Golding UE-33251 - add 'restart required' to bSupportUVFromHitResults option Change 3116021 on 2016/09/07 by Marc.Audy Fix spelling de-auto NULL to nullptr minor optimization Change 3116046 on 2016/09/07 by James.Golding Move AnimNode_LegIK.h to Public and .cpp for Private Change3116048on 2016/09/07 by James.Golding UE-34640 Fix bogus tooltips for collision channels Change 3116050 on 2016/09/07 by James.Golding PR #2728: UE-34953: Improved comments for Hit callbacks (Contributed by projectgheist) Change 3116060 on 2016/09/07 by Lina.Halper #ANIM: - Fix crash of setting multiple times in the same menu - Make sure you can set to original animation, and not break #jira: UE-35580 Change 3116064 on 2016/09/07 by James.Golding Fix missing change for LegIK file move Change 3116291 on 2016/09/07 by Marc.Audy FindObjectWithOuter once again allows ClassToLookFor to be null as comment indicates is allowed Change 3116590 on 2016/09/07 by Dan.Reynolds Audio Test Map Content WIP Change 3116649 on 2016/09/07 by mason.seay Updated map to test flying Change 3116712 on 2016/09/07 by dan.reynolds Test Content Update EQTest Map WIP Change 3117257 on 2016/09/08 by Benn.Gallagher Fixed skeletal mesh details not working in new standalone mesh editor. Duplicated the detail customization and reworked to handle the new host app (no longer FPersona). Change 3117348 on 2016/09/08 by Benn.Gallagher Added "Post-Process" Animation Blueprints. These run after the main anim instance, and the class used is set on the mesh so that any instance of that mesh uses that class as a post process. If there is a sub-input node inside the post process graph then the pose at the end of the main instance will be passed through into that instance. #jira UEFW-180 Change 3117393 on 2016/09/08 by Benn.Gallagher Hid UDestructibleMesh properties that are unsupported on destructibles in the destrucitble mesh editor (shadow assets and post process blueprints are only for normal skeletal meshes) #jira UE-34508 Change 3117507 on 2016/09/08 by Jurre.deBaare Streamline Persona Asset Browser #added ability to set whether or not a column should generate widgets in STableViews #added filtering code to SAssetview to allow for hiding/showing columns related to the asset type #added an ini path for saving the column filter state in SAnimationSequenceBrowser #jira UEFW-148 Change 3118003 on 2016/09/08 by mason.seay Updating meshes to use complex collision Change 3118020 on 2016/09/08 by Zak.Middleton #ue4 - Auto-register UpdatedComponent in MovementComponent in InitializeComponent() if not found during OnRegister(). This can occur for non-native (BP) root components. Change 3118437 on 2016/09/08 by Lina.Halper Fix grammar error #jira: UE-35729, UE-35730, UE-35729 Change 3118456 on 2016/09/08 by Lina.Halper Removed space because slate showed long spaces. It's long line now but at least in UI, it looks cleaner. Change 3118492 on 2016/09/08 by Aaron.McLeran Copying //UE4/Dev-Audio to Dev-Framework (//UE4/Dev-Framework) Change 3118517 on 2016/09/08 by Lina.Halper Went back to original without spaces Change 3118711 on 2016/09/08 by Aaron.McLeran Fixing build errors with CL 3118492 Change 3118712 on 2016/09/08 by Aaron.McLeran Fixing a build warning with CL 3118492 Change 3118745 on 2016/09/08 by Aaron.McLeran Fixing a build warning with CL 3118492 - Fixed init order in FSoundSource Change 3119201 on 2016/09/09 by Benn.Gallagher Fix static analysis warnings (Accessing nullptr), added check on the pointer #jira UE-35755 Change 3119338 on 2016/09/09 by Benn.Gallagher Fixed destructible import throwing out meshes where 1 or more submeshes are empty Change 3119371 on 2016/09/09 by Lina.Halper fix texts Change 3119453 on 2016/09/09 by Lina.Halper Change text style of the child montage instruction. #jira: UE-35144 Change 3119454 on 2016/09/09 by Lina.Halper Add option to open asset from context menu of the segment #jira: UE-35632 Change 3119457 on 2016/09/09 by mason.seay Updated maps and rebuilt lighting Change 3119584 on 2016/09/09 by Marc.Audy Support for new metadata ShowInnerProperties (written by Matt K) Change 3119667 on 2016/09/09 by Aaron.McLeran Fixing compile errors on Mac. - Commandlet can't run on Mac (or other desktop platforms) right now since audio mixer isn't yet supported there Change 3119732 on 2016/09/09 by Aaron.McLeran Fixing clang compile error - Apparently clang didn't like my ascii art of the wavetable shapes. Switched to /* */ style comment. Change 3119734 on 2016/09/09 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3119702 Change 3119787 on 2016/09/09 by Lina.Halper Move cached UID to required bone - removed skeleton cached UID list - removed skeletalmeshcomponent cached UID list - FBoneContainer will contain UID list and can be re-cached anytime bones are recalculated - added versioning to up-to-date skeleton curve list with skeletalmeshcomponent #code review:Benn.Gallagher, Martin.Wilson Change 3119800 on 2016/09/09 by Aaron.McLeran Changing audio mixer's GetAudioClock to GetAudioTime to avoid conflicting with other GetAudioClock function merged into dev-framework. Change 3120260 on 2016/09/09 by Marc.Audy Fix if statement Change 3120790 on 2016/09/12 by Thomas.Sarkanen Reordered skeletal mesh and animations in asset shortcut bar #jira UE-35845 - Move anim asset shortcut bar ordering to Skeleton > Skeletal Mesh > Animation > AnimBP Change 3120793 on 2016/09/12 by Thomas.Sarkanen Improved fix for missing mesh details customization Improves on CL 3117257. Removed extra RefreshViewports function. Communication should be done via the preview scene to accomodate future multiple viewports. Re-used generic asset properties tab with a callback delegate that allows post-construction customization. Removed older custom tab. Removed dependency between FSkeletalMeshDetails and FSkeletonEditor. Trying to avoid back-pointer dependencies to monolithic editors, as this was the main bulk of refactoring work when teasing Persona apart. Change 3120867 on 2016/09/12 by Marc.Audy Fix incorrect condition in for causing static analysis warning Change 3120900 on 2016/09/12 by mason.seay Actually build lighting this time Change 3120904 on 2016/09/12 by Thomas.Sarkanen Skeletons can now be deleted once opened (once more) Editable skeleton manager now holds onto weak ptrs instread of shared ptrs. Added logic to compact if weak ptrs are invalid. #jira UE-35848 - Can't delete skeletons that have been opened in the new standalone editor Change 3120927 on 2016/09/12 by Thomas.Sarkanen Details panel now shows selected items when re-opened Kept the underlying widget around so that any item selections can still correctly update the (hidden) UI. #jira UE-35445 - Details tab in persona dosn't populate with information when first opened Change 3120979 on 2016/09/12 by Thomas.Sarkanen Re-added the ability to create pose assets This was added at a similar time to my final merges and didnt get merged over to the standalone animation editor. #jira UE-35740 - Create Pose asset missing from create animation dropdown Change 3121208 on 2016/09/12 by Benn.Gallagher Added bulk reimport to the reimport manager that uses slow tasks to give users an idea how far they are through large operations. #jira UE-33216 Change 3121274 on 2016/09/12 by James.Golding PR #2264: Added functions that can change a UTimelineComponent's curve(s) via Blueprints. (Contributed by hgamiel) #jira UE-29346 Change 3121276 on 2016/09/12 by James.Golding UE-33242 : Add option to copy morph target names to clipboard Change 3121278 on 2016/09/12 by James.Golding UE-33004 : Add proper commands for Curve Viewer Change 3121472 on 2016/09/12 by Zak.Middleton #ue4 - Fix UGameplayStatics::SpawnEmitterAttached() using wrong scale when SnapToTarget (Keep World Scale) option is used. Improve comments for SpawnEmitterAttached(). #jira UE-34482 Change 3121829 on 2016/09/12 by dan.reynolds Audio Blueprints Content Example WIP Update checked in to backlog by request of ZakB and Nick BB. Change 3122218 on 2016/09/12 by Aaron.McLeran Minor cleanup in XAudio2Source.cpp Change 3122823 on 2016/09/13 by Thomas.Sarkanen Fix incorrect camera offset when opening some skeletal meshes Skeletons that had no preview skeletal mesh set up gave incorrect bounds on first tick. This is fixed by updating the preview mesh in the scene desc so that bounds are correctly calculated on first viewport tick. #jira UE-35550 - Persona camera is far away from some skeletal meshes Change 3122857 on 2016/09/13 by Lina.Halper Importing frame count issue with blendshapes - with this change when calculating sample rate, it checks blendshape curves. #jira: UE-27706 Change 3122992 on 2016/09/13 by Marc.Audy Child Actor Component now have an editable template * Template is stored as a child inside the child actor template * When gathering components for an actor, need to stop searching beyond any nested AActor #jira UEFW-125, UE-16474 Change 3123087 on 2016/09/13 by Marc.Audy Fix Child Actor Template being nulled out on template Change 3123170 on 2016/09/13 by mason.seay Updated test map to test SpawnEmitterAttached SnapToTarget settings UEENGQA-9268 Change 3123203 on 2016/09/13 by Marc.Audy Multi-select of child actor components allows editing of template properties Change 3123205 on 2016/09/13 by Marc.Audy Fix details panel constantly updating and not being interactable when multi-selected objects have ShowInnerProperty property #author Matt.Kuhlenschmidt Change 3123422 on 2016/09/13 by Aaron.McLeran UE-35950 Fixing XboxOne spatialization - XBoxOne doesn't support device details, so we need to manually set it to the output channels and channel mask. Unfortunately, that was incorrectly set. Change 3123484 on 2016/09/13 by Lina.Halper Fix animation frame UI issue - This now displays from [0, numframes -1] #jira: UE-33437 Change 3123500 on 2016/09/13 by Marc.Audy Undo/redo of mobility changes will also undo/redo the mobility changes on ancestors/descendants that were changed along with it #jira UE-35885 Change 3123549 on 2016/09/13 by Marc.Audy Fix warning message Change 3123581 on 2016/09/13 by Marc.Audy PR #2751: Editor Only UActorComponents for Blueprints (Contributed by moritz-wundke) #jira UE-35424 Change 3123688 on 2016/09/13 by Ben.Zeigler Add logic to K2Node_Variable that updates the variable reference to the correct class, if the variable has moved up or down in the class hierarchy. This is similar to code in UK2Node_CallFunction::CreateSelfPin which already handled this case correctly Change 3123768 on 2016/09/13 by Marc.Audy Go away auto NULL to nullptr Use ranged for instead of iterators Change 3123906 on 2016/09/13 by Aaron.McLeran UE-34615 Supporting Pausing Sounds on Audio Components Change 3123949 on 2016/09/13 by Aaron.McLeran UE-35965 Spatialization no longer occurs when Non-Spatialized Radius is set above 0 Change 3124109 on 2016/09/13 by Aaron.McLeran UE-33364 Making bSuppressSubtitles a UPROPERTY EditAnywhere, BlueprintReadWrite Change 3124137 on 2016/09/13 by Aaron.McLeran PR #2601: made looping sound waves searchable by the asset registry Change 3124396 on 2016/09/14 by James.Golding Allow anim node edit modes to work on all nodes, not just skel controls Change 3124498 on 2016/09/14 by Benn.Gallagher Added method to get swing and twist quaternions from FQuat #jira UE-34054 Change 3124504 on 2016/09/14 by James.Golding Missed a few references to SkeletalControlEditMode Change 3124508 on 2016/09/14 by James.Golding Fix function groupings in animnode editmode headers Change 3124625 on 2016/09/14 by james.cobbett Rebuilding lighting. Change 3124632 on 2016/09/14 by James.Golding UEFW-205 Adding support for PoseDriver to drive bones (based on PoseAsset) - Converted PoseDriver from SkelControl to AnimNode - Added PoseDriverEditMode - Added debug drawing to show target poses and current ref position - Aded support for PoseDriver using translation instead of rotation - Added AnimGraphNode_PoseHandler class, with code corresponding with AnimNode_PoseHandler Change 3124636 on 2016/09/14 by James.Golding Missed file Change 3124652 on 2016/09/14 by Marc.Audy Fix initialization order warning #jira UE-35980 Change 3124658 on 2016/09/14 by Marc.Audy Fix if statement #jira UE-35976 Change 3124685 on 2016/09/14 by James.Golding Move PoseDriver files from BoneControllers to AnimNodes folder Rename AnimNode_PosePriver.cpp to AnimNode_PoseDriver.cpp Move AnimGraphNode_AssetPlayerBase.cpp from Classes to Private Change 3124690 on 2016/09/14 by James.Golding Missing header edit after file move Change 3124707 on 2016/09/14 by Danny.Bouimad Fixing UE-34814, issue where a socket was not rendering correctly. Note: The old socket wasn't attached to a bone to fix the issue so it was attached to the root bone. Somehow this was undone. Change 3124954 on 2016/09/14 by Jurre.deBaare Import Alembic file gets editor crash #fix double check if Alembic isn't lying and there are no actual normals #misc fixed type in function signature #jira UE-35702 Change 3124980 on 2016/09/14 by Lina.Halper Tweak UI of child anim montage - removed padding, changed font size Change 3124981 on 2016/09/14 by Lina.Halper Changed text of keys to Frames Change 3124998 on 2016/09/14 by Lina.Halper Fix curve issue when evaluting with # of frames. #jira: UE-35782 Change 3125034 on 2016/09/14 by Aaron.McLeran Changes to 3123906 based on feedback from Marc Audy Change 3125109 on 2016/09/14 by Aaron.McLeran PR #2463: Support parsing .WAV files with a WAVE_FORMAT_EXTENSIBLE format chunk (Contributed by Mattiwatti) Change 3125184 on 2016/09/14 by Lukasz.Furman vehicle RVO fixes #ue4 Change 3125191 on 2016/09/14 by Lukasz.Furman added blueprint interface for component's navigation influence control #ue4 Change 3125348 on 2016/09/14 by Mason.Seay Added GamepadFaceButtonRight as an input mapping for Crouch Change 3125352 on 2016/09/14 by Lina.Halper #ANIM: Pose Asset - Insert pose support - made sure pose asset editor updates if the new pose is inserted. #jira: UE-32608 Change 3125413 on 2016/09/14 by Ben.Zeigler #jira UEFW-32 Game Mode Cleanup Add GameModeBase and GameStateBase classes that are parent classes of existing GameMode and GameState. The classes have been split in half so the base functionality needed by all games are in the Base classes, with legacy and match-specific code in the children Added BP access to several GameState and GameMode functions, and GetGameState/GetGameMode now return the base classes. World->GetAuthGameMode now returns GameModeBase, so direct accesses to the return value may not work. The casted template works as before. World->GameState is now private, and GetGameState returns GameStateBase. Code that accessed GameState should now call GetGameState<>. GameModeBase::StartNewPlayer has been deprecated, and split into InitializeHUDForPlayer and HandleStartingNewPlayer. Several Login functions on GameModeBase that take TSharedPtr<const FUniqueNetId> are now deprecated correctly, they previously stopped working correctly in 4.13 The ShouldShowGore feature on GameState has been fully deprecated, along with hooks in Matinee Change 3125414 on 2016/09/14 by Ben.Zeigler #jira UEFW-32 Game Mode Cleanup Convert all internal templates to use GameModeBase Convert most sample games, ShooterGame and several legacy projects are still using GameMode Change 3125415 on 2016/09/14 by Ben.Zeigler #jira UEFW-32 Game Mode Cleanup Internal game compile fixes needed to support GameMode refactor Fixed a few places that overrode StartNewPlayer to override new functions instead Change 3125438 on 2016/09/14 by Ben.Zeigler Log compile fix Change 3125460 on 2016/09/14 by Ben.Zeigler Another try at log compile issues Change 3125685 on 2016/09/14 by Aaron.McLeran Attempt to fix compile error Change 3125700 on 2016/09/14 by Aaron.McLeran UE-35958 Undo in sound cue editor does not undo looping changes. Issue was sound cues were not being flagged as transactional and ignoring undo transactions Change 3125857 on 2016/09/14 by Aaron.McLeran -Adding a RF_Transactional flag to postload for sound nodes so older sound nodes created incorrectly will work properly with the undo system. -Changed to setting flag directly in NewObject line instead of calling SetFlags Change 3125888 on 2016/09/14 by Aaron.McLeran Adding call to super post load in USoundNode::PostLoad() Change 3125964 on 2016/09/14 by Aaron.McLeran Fixing attenuation on 2D multichannel files (specifically 3, 7 and 8-channel files). Change 3125974 on 2016/09/14 by Aaron.McLeran UE-35892 Not loading audio data when in -nosound mode Change 3125983 on 2016/09/14 by Ben.Zeigler Better Nogore fix for lens effect Change 3125985 on 2016/09/14 by Ben.Zeigler Fix fortnite compile failure on mac, it was inside non instantiated template Change 3126409 on 2016/09/15 by Benn.Gallagher Fixed crash when adding a reroute node on a line with another reroute node in an anim graph. Becuase we use poselinks as an exec line we weren't killing the output links. #jira UE-35657 Change 3126507 on 2016/09/15 by Thomas.Sarkanen Prevent crash when calling SetAnimationMode on a component with no skeletal mesh Guard against the mesh being NULL, as with other calls to InitializeAnimScriptInstance. #jira UE-36003 - Crash playing Ocean Change 3126539 on 2016/09/15 by Marc.Audy Fix Win32 compilation error #jira UE-36018 Change 3126575 on 2016/09/15 by Marc.Audy Properly fix compile Change 3126635 on 2016/09/15 by Benn.Gallagher Fix for crash when setting collision responses on destructible components after they have been fractured. #jira UE-35604 Change 3126649 on 2016/09/15 by Lina.Halper - Fixed issue with updating cache UID List, so certain curves did not work. - Fixed issue with not finding meta data because the name has changed - converted to SmartName, and if it is going to look for by UID. Change 3126816 on 2016/09/15 by Lukasz.Furman Back out changelist 3125191 Change 3126903 on 2016/09/15 by Marc.Audy Fix !WITH_APEX compile errors from CL# 3126635 Change 3126908 on 2016/09/15 by Mieszko.Zielinski Added initialization of FBlackboardEntry properties #UE4 Change 3127081 on 2016/09/15 by Ben.Zeigler #jira UEFW-32 Game Mode Cleanup Change the way that the GameMode is picked based on URL to be handled by GameInstance instead of World/GameMode. Add PreloadContentForURL, CreateGameModeForURL, and OverrideGameModeClass to GameInstance and deprecate GameMode versions. GameMode::GameModeClassAliases has moved to GameMapsSettings::GameModeClassAliases and WorldSettings::DefaultMapPrefixes has moved to GameMapsSettings::GameModeMapPrefixes and unified in format. Fixed internal game ini files and added example to BaseEngine.ini Removed some outdated seekfree preload code and replace with GameInstance::PreloadContentForURL Change 3127102 on 2016/09/15 by Ben.Zeigler Crash fix if there is no deprecated config section Change 3127103 on 2016/09/15 by Aaron.McLeran UE-34100 audio playback of an individual source Change 3127109 on 2016/09/15 by Marc.Audy Remove inconsistently used AUDIO_DEVICE_HANDLE_INVALID and use INDEX_NONE everywhere instead Change 3127143 on 2016/09/15 by Aaron.McLeran Missing file in CL 3127103 Change 3127218 on 2016/09/15 by Ori.Cohen PR #2766: More vehicle stats for profiler (Contributed by DenizPiri) #JIRA UE-35564 Change 3127264 on 2016/09/15 by Aaron.McLeran Switching to using USoundWave instead of USoundBase in notification delegate for play progress percent Change 3127285 on 2016/09/15 by Marc.Audy Make it easier to create an audio component that will exist across level transitions Refactor FAudioDevice::CreateComponent to use a Params block instead of long parameter list UAudioComponent can now store which AudioDevice it is targetted at instead of being limited to its registered world or the main audio device (breaks in multi-PIE) #jira UE-16451 Change 3127360 on 2016/09/15 by Marc.Audy Consolidate a few GetWorld()s Change 3127931 on 2016/09/16 by Benn.Gallagher Fixed holes appearing in clothing meshes after reskinning changes. Caused by mismatched triangle counts when applying the clothing mesh. #jira UE-36054 Change 3128001 on 2016/09/16 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3127918 Change 3128005 on 2016/09/16 by James.Cobbett #jira UE-29618 Submitting test assets Change 3128022 on 2016/09/16 by Lina.Halper Allow re-merge all skeletalmeshes back to skeleton when recreating skeleton from scratch #jira: UE-27256 Change 3128044 on 2016/09/16 by James.Cobbett Submitting gamemode test asset Change 3128169 on 2016/09/16 by Mieszko.Zielinski Fixed couple of static analysis warnings in AI code #UE4 Change 3128430 on 2016/09/16 by Marc.Audy Fix infinite loop when running a pause frame with tick interval functions (4.13.1) #jira UE-36096 Change 3128558 on 2016/09/16 by Mieszko.Zielinski Refactored FEnvQueryInstance::AddItemData to not require second template parameter (TypeValue) #UE4 #jira UE-33036 Change 3128678 on 2016/09/16 by Jon.Nabozny #rn Added a delegate to GameViewportClient that notifies when the Game's platform specific window is being closed. #rn This can be used to prevent the game from being exited. #jira UE-34123 Change 3128693 on 2016/09/16 by Marc.Audy Add UnpausedTimeSeconds to UWorld to accumulate the dilated/clamped game time even when paused Change 3128753 on 2016/09/16 by Mieszko.Zielinski Fixed aborting previous movements as part requesting a new one needlesly reseting move agent's current velocity #UE4 #jira UE-35852 Change 3128791 on 2016/09/16 by Marc.Audy PR #2777: Accurate DeltaSeconds for objects with TickIntervals (Contributed by YossiMHWF) Tick Functions with a Tick Interval will now return the dilated/clamped game DeltaSeconds since the last time it ticked #jira UE-35719 Change 3128974 on 2016/09/16 by Mieszko.Zielinski Fixes to BB key synchronization #UE4 syncing between two BBs associated by a common parent now works Change 3128984 on 2016/09/16 by Jon.Nabozny Fix FConstraintBaseParams ContactDistance clamping. The value is intended to be in either degrees or cm units (depending on constraint type), so clamping max to 1 doesn't make sense. Change 3129010 on 2016/09/16 by Dan.Reynolds Updating developer folder content for external referencing Change3129093on 2016/09/16 by Ben.Zeigler #jira UE-35424 Switch from using AlwaysLoadOnServer/Client to bIsEditorOnly for components that should be editor only. This works better with cooking and is clearer in usage Move MarkAsEditorOnlySubobject to ActorComponent so it works for all components and not just primitive ones Change 3129103 on 2016/09/16 by Marc.Audy Fix initialization order CIS warning Change 3129361 on 2016/09/16 by Dan.Reynolds Fixes to QASoundWaveProcedural.h Change 3129994 on 2016/09/19 by Thomas.Sarkanen Skeletal mesh to Static mesh conversion Added feature to convert selected actors' meshes into static meshes. Supports static and skeletal meshes. Added extension points to all Persona-based editors so their toolbars can be overriden with context about the editor itself. Added IHasPersonaToolkit interface that all of these editors implement. Added toolbar button to each Persona-based editor. Added level editor right-click menu option. Added CPU skinning path for cloth sections (non-SIMD for now). Moved CPU skinning flag from UDebugSkelMeshComponent into USkinnedMeshComponent. Moved a few structures around so CPU skinned renderdata is more readily exposed. #jira UE-35549 - Convert skel mesh on specific anim frame to StaticMesh Change 3130008 on 2016/09/19 by Benn.Gallagher Fixed crash when creating a destructible mesh from a speed tree mesh. The materials are incompatible - after discussion decided to report the error to the user and bail on making the destructible #jira UE-3687 Change 3130009 on 2016/09/19 by Thomas.Sarkanen Fixed static analysis warnings in Persona and AnimationBlueprintEditor Also moved a bool check inside (original line number for the warning led me to that code instead, but thought it was worth fixing anyways). Change 3130012 on 2016/09/19 by Thomas.Sarkanen CIS fix (implcit use of copy constructor) Change3130016on 2016/09/19 by Thomas.Sarkanen Mac CIS fix - forward declare some classes. Change 3130027 on 2016/09/19 by Thomas.Sarkanen Fix shadow variables found with Clang Change 3130044 on 2016/09/19 by Jurre.deBaare Improved Texture Merging using the Merge Actors Tool #feature added simple binning algorithm to be used with texture importance values #misc small array indexing copy-paste error #jira UE-33823 Change 3130068 on 2016/09/19 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3129803 Change 3130181 on 2016/09/19 by Jurre.deBaare G++ compile errors #fix array enum size requires cast to be valid Change 3130182 on 2016/09/19 by Jurre.deBaare Remove FColor operator after feedback from Marc, assuming color order is indeed icky and can tackle the problem differently Change 3130250 on 2016/09/19 by Marc.Audy Fix flag check indicated by static analysis Change 3130256 on 2016/09/19 by Benn.Gallagher Changed "Create Physics Asset" context menu options to allow creation without assigning the physics asset to the selected mesh to make it easier to set up capsule shadows. #jira UE-34796 Change 3130267 on 2016/09/19 by Marc.Audy Post integration WEX fixups for GameMode and FAudioDevice::CreateComponent changes Change 3130551 on 2016/09/19 by Ben.Zeigler Change WEX OnlineSubsystem plugin to exactly match Engine one with GameMode refactors, no functionaly change but this should make merging easier Change 3130564 on 2016/09/19 by Jurre.deBaare More CIS fixes Change 3130572 on 2016/09/19 by Ben.Zeigler #jira UE-36142 Fix 1v1 and 2v2 game mode references, they were always wrong but are now being cooked properly with the game mode changes Change 3130586 on 2016/09/19 by Ben.Zeigler #jira UE-36124 Fix orion crash, the class layout of OrionGameState_MOBA differed between BlueprintContext and OrionGame modules because of the server perf define being different Change 3130587 on 2016/09/19 by Martin.Wilson Add start time to Montage_Play and PlaySlotAnimationAsDynamicMontage #jira UE-34798 Change 3130694 on 2016/09/19 by Ben.Zeigler #jira UE-35424 Restore BrushComponent to the 4.13 behavior for computing editor only, as they set AlwaysLoadOnClient/Server to false even if they're not editor only unlike other primitive components Change 3130700 on 2016/09/19 by Ben.Zeigler #jira UE-36141 Fix it so PlayerCanRestart is called before restarting player on initial login, to match behavior when requesting a restart or match starting. This is a bug fix in the core code that UT was working around originally Change 3130778 on 2016/09/19 by Dan.Reynolds WIP Content update for external referencing Change 3130812 on 2016/09/19 by Marc.Audy No longer use inconsistently applied bWantsBeginPlay #jira UE-21048 Change 3130876 on 2016/09/19 by Richard.Hinckley Fixing comments for documentation purposes. Change 3131076 on 2016/09/19 by Marc.Audy PR #2775: Make WorldContextObj arguments const pointers (Contributed by jorgenpt) #jira UE-35625 Change 3131102 on 2016/09/19 by Richard.Hinckley Fixing typo that slipped through. Change 3131254 on 2016/09/19 by Ben.Zeigler #jira UE-36162 Remove bad game mode reference Change 3131396 on 2016/09/19 by Marc.Audy Undo CL# 3125974 to fix Fortnite crash until investigation can be done #jira -UE-36164 Change 3131846 on 2016/09/20 by Thomas.Sarkanen Recording now functional again in blendspace editor Blendspaces now use the anim editor base. Anim editor base now has the option of a scrollable or non-scrollable widget area. Blendspaces use the non-scrollable one as before. Scrub widget now seperates the concepts of frames and scrub cursor. This is to allow blendspaces to still use scrubbing when they use normalized time. Removed PURE_VIRTUAL from SAnimEditorBase as it is not a UObject class. #jira UE-35843 - Missing record option for Blendspaces Change 3131921 on 2016/09/20 by Thomas.Sarkanen Re-added anim slot manager tab Anim slot manager was not added back into the standalone editors when they were split up. #jira UE-35954 - Anim Slot Manager opens up to unrecognized tab Change 3131922 on 2016/09/20 by Thomas.Sarkanen Added 'dirty' indicator to asset shortcut bar #jira UE-36015 - No 'dirty' indicator in anim asset shortcut bar Change 3131950 on 2016/09/20 by Thomas.Sarkanen Animation stepping now functions as it did previously Recent changes to deal with different frame counts left off an epsilon in the frame increment/decrement logic. Re-instating the epsilon fixes this. #jira UE-36172 - The To Next button in the Animation timeline doesn't work consistently Change 3131953 on 2016/09/20 by james.cobbett Updating test assets. Change 3132241 on 2016/09/20 by Martin.Wilson Fix crash when importing a pose to pose asset. #jira UE-36122 Change 3132417 on 2016/09/20 by Thomas.Sarkanen Fixed crash when anim instance is set to NULL when URO is turned on (and GC occurs) A dangling pointer to the UID array on the instance was hanging around. We now make sure to clear this when necessary. #jira UE-36182 - Fornite cooked crashed when hitting a husk near/on a chest - CurveToCopyFrom.IsValid() Change 3132790 on 2016/09/20 by Ori.Cohen Ensure that physics handle automatically wakes up any object it's grabbing on release. Also fix editor case where moving camera grabs component #JIRA UE-35257 Change 3132795 on 2016/09/20 by Ori.Cohen Fix typo where enable swing drive was used for both swing and twist. #JIRA UE-35634 Change 3132838 on 2016/09/20 by Ori.Cohen Move flush deferred actor to EndPhysics #JIRA UE-35899 Change 3133088 on 2016/09/20 by Ori.Cohen Back out defer flush change. This requires more thought. Change 3133185 on 2016/09/20 by Wes.Hunt QoS Analytics providers now use the real final Data Router URL #jira UE-30655 Change 3133262 on 2016/09/20 by Wes.Hunt HttpServiceTracker now uses UserID fields that match what we expect for all other apps. Part of #jira UE-33354. Change 3133266 on 2016/09/20 by Wes.Hunt Make anonymous analytics UserID match format expected by the backend to remove ambiguity. Part of #jira UE-33354. Change 3133277 on 2016/09/20 by Chris.Evans !N Pose asset test Change3133504on 2016/09/20 by dan.reynolds Updating WIP Test Content Change3133761on 2016/09/21 by Thomas.Sarkanen Fixed 100% crash when killing a husk Interpolation was still getting performed when we had an invalid UID container. We now check this before kicking off a task. #jira UE-36203 - Fornite cooked crashed when killing a husk and jumping backwards Change 3133766 on 2016/09/21 by Thomas.Sarkanen Fixed crash when compiling animation blueprint when a node outside of the tree evaluation is selected The OnNodeSelected callback was not getting called for deselection when the node could not be found (i.e. was NULL). Removed NULL check as it is valid to call. ALso added comment warning that the passed in runtime node can be NULL. #jira UE-35974 - Crash in FSkeletalControlEditMode when compiling an anim blueprint Change 3133774 on 2016/09/21 by Danny.Bouimad Translation Pose Driver test assets content/animation/posedrivertests Change 3133796 on 2016/09/21 by Thomas.Sarkanen Added metadata to remove "reset to default" button for certain properties Allows removal of the reset button without a cumbersome details customization. Fixes crash where a parent struct of an editfixedsize array was reset. #jira UE-36109 - Crash when resetting shape properties on a BodySetup in PhAT Change 3133831 on 2016/09/21 by Jurre.deBaare Vert Color Background not contained to Asset's Viewport #fix Added a way to directly set the visibility of the floor/environment in the static mesh editor #jira UE-35052 Change 3133832 on 2016/09/21 by Jurre.deBaare Geometry Cache asset will stop animating when Elapsed Time exceeds an excessively high number #fix set UI/clamp min/max for playback speed (-512 - 512x playback speed) and start offset (-14400 - 14400, 4 hours) and clamp at runtime as well #jira UE-34629 Change 3133833 on 2016/09/21 by Jurre.deBaare Geometry Cache asset will continue to loop when running in reverse when Loop is turned off and Elapsed Time is has reached 0 #fix do not wrap around for non-looping negative sampling times :) #jira UE-34630 Change 3133834 on 2016/09/21 by Jurre.deBaare Merge Actors button is not enabled when selecting assets in the viewport if they are not visible in the Merge Actor window #fix moved selected mesh count functionality so that it is not dependent on the listview being rendered (this is an awesome bug) #jira UE-34303 Static mesh does not show after using "Merge Actors" if the mesh is part of a child actor component that has been added to the blueprint #fix recursively add child actor components to include all static meshes #jira UE-25187 Change 3133835 on 2016/09/21 by Jurre.deBaare Mesh Preview Scene: Remove bottom quad from floor mesh to make viewing from below easier. (in loving memory of Tom Looman) #fix new mesh with removed bottom quad, allowing for see-through from below #jira UE-35022 Change 3133836 on 2016/09/21 by Jurre.deBaare It isn't clear when a profile is added to the Preview Scene Settings #fix selected profile now changes to newly added one #jira UE-33848 Change preview scene profile naming to validate name input in UI instead of PostEditChange #fix added ui feedback for duplicate naming #misc extra checks for having a correct profile name when adding a new profile #jira UE-34078 Adding Preview Scene Profile after Removing One duplicates the name of the last added profile #fix determine correct name by checking existing ones #jira UE-33898 Change 3133838 on 2016/09/21 by Jurre.deBaare Prevent preview scene assets being loaded in game (proper fix) #fix now saving direct FString path to the environment cube map and load them once we ::Get the assetviewer settings #jira UE-36082 Change 3133839 on 2016/09/21 by Jurre.deBaare Moving over UE-35254 from 4.13.1 Change 3133840 on 2016/09/21 by Jurre.deBaare Moving over UE-35639 from 4.13.1 Change 3133844 on 2016/09/21 by Jurre.deBaare Alembic import causing a crash #jira UE-35551 #fix handle the case where there is not hierarchy found for a specific object, in that case just output the identity matrix as object matrix #jira UE-35451 #fix handle case where we imported an empty object in the Geometry cache path #misc alembic importer signature change #misc typo in function signature Change 3133951 on 2016/09/21 by Mieszko.Zielinski Fixed deprecation message on UAIPerceptionComponent::GetPerceivedActors #UE4 Change 3134014 on 2016/09/21 by Jon.Nabozny #rn Ensure the runaway loop counter gets reset when processing parallel animation. #jira UE-33946 Change 3134032 on 2016/09/21 by Jurre.deBaare Remove comments Change 3134100 on 2016/09/21 by James.Golding UE-35300 Support UV traces for UV on BSP Change 3134103 on 2016/09/21 by Lukasz.Furman fixed NavLinkProxy not working correctly in PIE #jira UE-36194 Change 3134104 on 2016/09/21 by James.Golding UE-33004 Use UI commands for PoseEditor, allow keyboard shortcuts Change 3134106 on 2016/09/21 by James.Golding UE-36138 Fix crash in procmesh slicing, avoid creating, and skip processing, sections with no verts Change 3134109 on 2016/09/21 by James.Golding UE-35813 Don't do srgb conversion for proc mesh vertex colors UE-35821 Procedural Mesh component not respecting 'Bound Scale' setting Change 3134145 on 2016/09/21 by Mieszko.Zielinski Fixed persistent BB key changes not getting propagated to child BB assets #UE4 Change 3134296 on 2016/09/21 by Lukasz.Furman fixed navlink's "snap to cheapest area" mode not working correctly with dynamic navmesh copy of CL#3133219Change 3134390 on 2016/09/21 by mason.seay Blueprint for collision bug repro Change 3134517 on 2016/09/21 by Mieszko.Zielinski CIS fix #UE4 Change 3134746 on 2016/09/21 by Ben.Zeigler Documentation and comment cleanup pass for GameMode changes, it's ready for a Doc team pass Change GameStateBase::GetDefaultGameMode to return a const * as it's a CDO that is not safe to modify, and remove Blueprint acessibility as there's no way to make that safe Change 3134850 on 2016/09/21 by Ben.Zeigler Fix PlatformShowcase warnings Change 3134852 on 2016/09/21 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3134107 Change 3134853 on 2016/09/21 by Marc.Audy Resolve of reimport portions Change 3134857 on 2016/09/21 by Marc.Audy Fixes related to show inner properties for Map and Set now that Dev-Editor has made it to Dev-Framework Change 3135002 on 2016/09/21 by Ori.Cohen Fix compiler errors Change 3135147 on 2016/09/21 by dan.reynolds AEOverview Test WIP Update Change 3135168 on 2016/09/21 by Wes.Hunt Edigrate of CL3135131: EngineAnalytics uses EngineVersion once again instead of BuildVersion, which doesn't contain major.minor.hotfix info. #jira UE-36211 Change 3135216 on 2016/09/21 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3135156 Change 3135238 on 2016/09/21 by Aaron.McLeran UE-36288 Fixing concurrency resolution stop quietest Change 3135257 on 2016/09/21 by Ben.Zeigler Fix Orion version of OnlineGameFramework plugin Change 3135258 on 2016/09/21 by Ben.Zeigler Other Orion GameMode fixes Change 3135290 on 2016/09/21 by dan.reynolds AEOverview test map skeleton complete with comments per Nick BB request Change 3135323 on 2016/09/21 by dan.reynolds Update to AEOverview test maps Change 3135385 on 2016/09/21 by Marc.Audy Fix static analysis warnings in automation tests Change 3135634 on 2016/09/22 by Thomas.Sarkanen Remove duplicated details customization Now we only have one customization that both 'old' Persona and the skeletal mesh editor can use. Change 3135660 on 2016/09/22 by Thomas.Sarkanen CIS fix: Fixed deleted file still being included. Change 3135949 on 2016/09/22 by Thomas.Sarkanen Fixed (another) crash with invalid curve data when an anim instance is GCed Invalidated cached curve as it can hold onto a reference to anim instance data. Also added a check for valididty in the non-parallel eval, non-interpolation case. #jira UE-36292 - Fortnite Editor Crashed when shooting a husk during defense phase - CurveToCopyFrom.IsValid() [CL 3136620 by Marc Audy in Main branch]
4424 lines
143 KiB
C++
4424 lines
143 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;
|
|
|
|
NumVisibleColumns = 0;
|
|
|
|
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);
|
|
|
|
GConfig->SetArray(*IniSection, *(SettingsString + TEXT(".HiddenColumns")), HiddenColumnNames, 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 );
|
|
}
|
|
|
|
GConfig->GetArray(*IniSection, *(SettingsString + TEXT(".HiddenColumns")), HiddenColumnNames, IniFilename);
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
|
|
static bool ContainsT3D(const FString& ClipboardText)
|
|
{
|
|
return (ClipboardText.StartsWith(TEXT("Begin Object")) && ClipboardText.EndsWith(TEXT("End Object")))
|
|
|| (ClipboardText.StartsWith(TEXT("Begin Map")) && ClipboardText.EndsWith(TEXT("End Map")));
|
|
}
|
|
|
|
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);
|
|
|
|
// Make sure the clipboard does not contain T3D
|
|
if (!ContainsT3D(AssetPaths.TrimTrailing()))
|
|
{
|
|
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, const FFocusEvent& InFocusEvent)
|
|
{
|
|
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") )
|
|
.ShouldGenerateWidget(TAttribute<bool>::Create(TAttribute<bool>::FGetter::CreateSP(this, &SAssetView::ShouldColumnGenerateWidget, SortManager.NameColumnId.ToString())))
|
|
.MenuContent()
|
|
[
|
|
CreateRowHeaderMenuContent(SortManager.NameColumnId.ToString())
|
|
]
|
|
);
|
|
|
|
NumVisibleColumns = HiddenColumnNames.Contains(SortManager.NameColumnId.ToString()) ? 0 : 1;
|
|
|
|
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"))
|
|
.ShouldGenerateWidget(TAttribute<bool>::Create(TAttribute<bool>::FGetter::CreateSP(this, &SAssetView::ShouldColumnGenerateWidget, SortManager.ClassColumnId.ToString())))
|
|
.MenuContent()
|
|
[
|
|
CreateRowHeaderMenuContent(SortManager.ClassColumnId.ToString())
|
|
]
|
|
);
|
|
|
|
NumVisibleColumns += HiddenColumnNames.Contains(SortManager.ClassColumnId.ToString()) ? 0 : 1;
|
|
}
|
|
|
|
|
|
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"))
|
|
.ShouldGenerateWidget(TAttribute<bool>::Create(TAttribute<bool>::FGetter::CreateSP(this, &SAssetView::ShouldColumnGenerateWidget, SortManager.PathColumnId.ToString())))
|
|
.MenuContent()
|
|
[
|
|
CreateRowHeaderMenuContent(SortManager.PathColumnId.ToString())
|
|
]
|
|
);
|
|
|
|
|
|
NumVisibleColumns += HiddenColumnNames.Contains(SortManager.PathColumnId.ToString()) ? 0 : 1;
|
|
}
|
|
|
|
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 TagName = TagIt->Name;
|
|
|
|
if ( !OnAssetTagWantsToBeDisplayed.IsBound() || OnAssetTagWantsToBeDisplayed.Execute(NewMajorityAssetType, TagName) )
|
|
{
|
|
// Get tag metadata
|
|
TMap<FName, UObject::FAssetRegistryTagMetadata> MetadataMap;
|
|
CDO->GetAssetRegistryTagMetadata(MetadataMap);
|
|
const UObject::FAssetRegistryTagMetadata* Metadata = MetadataMap.Find(TagName);
|
|
|
|
FText DisplayName;
|
|
if (Metadata != nullptr && !Metadata->DisplayName.IsEmpty())
|
|
{
|
|
DisplayName = Metadata->DisplayName;
|
|
}
|
|
else
|
|
{
|
|
DisplayName = FText::FromName(TagName);
|
|
}
|
|
|
|
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, TagName);
|
|
TooltipText = (Property != nullptr) ? Property->GetToolTipText() : FText::FromString(FName::NameToDisplayString(TagName.ToString(), false));
|
|
}
|
|
|
|
ColumnView->GetHeaderRow()->AddColumn(
|
|
SHeaderRow::Column(TagName)
|
|
.SortMode(TAttribute< EColumnSortMode::Type >::Create(TAttribute< EColumnSortMode::Type >::FGetter::CreateSP(this, &SAssetView::GetColumnSortMode, TagName)))
|
|
.SortPriority(TAttribute< EColumnSortPriority::Type >::Create(TAttribute< EColumnSortPriority::Type >::FGetter::CreateSP(this, &SAssetView::GetColumnSortPriority, TagName)))
|
|
.OnSort(FOnSortModeChanged::CreateSP(this, &SAssetView::OnSortColumnHeader))
|
|
.DefaultLabel(DisplayName)
|
|
.DefaultTooltip(TooltipText)
|
|
.HAlignCell((TagIt->Type == UObject::FAssetRegistryTag::TT_Numerical) ? HAlign_Right : HAlign_Left)
|
|
.FillWidth(180)
|
|
.ShouldGenerateWidget(TAttribute<bool>::Create(TAttribute<bool>::FGetter::CreateSP(this, &SAssetView::ShouldColumnGenerateWidget, TagName.ToString())))
|
|
.MenuContent()
|
|
[
|
|
CreateRowHeaderMenuContent(TagName.ToString())
|
|
]);
|
|
|
|
NumVisibleColumns += HiddenColumnNames.Contains(TagName.ToString()) ? 0 : 1;
|
|
|
|
// 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 (TagName == 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)
|
|
{
|
|
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* Object, FPropertyChangedEvent& PropertyChangedEvent)
|
|
{
|
|
if (Object != nullptr && Object->IsAsset())
|
|
{
|
|
RecentlyLoadedOrChangedAssets.Add( FName(*Object->GetPathName()), Object);
|
|
}
|
|
}
|
|
|
|
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.AddMenuEntry(
|
|
LOCTEXT("ShowCppClassesOption", "Show C++ Classes"),
|
|
LOCTEXT("ShowCppClassesOptionToolTip", "Shows C++ Class folders in the folder browser."),
|
|
FSlateIcon(),
|
|
FUIAction(
|
|
FExecuteAction::CreateSP( this, &SAssetView::ToggleShowCppFolders ),
|
|
FCanExecuteAction(),
|
|
FIsActionChecked::CreateSP( this, &SAssetView::IsShowingCppFolders )
|
|
),
|
|
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();
|
|
|
|
if (GetColumnViewVisibility() == EVisibility::Visible)
|
|
{
|
|
MenuBuilder.BeginSection("AssetColumns", LOCTEXT("ToggleColumnsHeading", "Columns"));
|
|
{
|
|
MenuBuilder.AddSubMenu(
|
|
LOCTEXT("ToggleColumnsMenu", "Toggle columns"),
|
|
LOCTEXT("ToggleColumnsMenuTooltip", "Show or hide specific columns."),
|
|
FNewMenuDelegate::CreateSP(this, &SAssetView::FillToggleColumnsMenu)
|
|
);
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
LOCTEXT("ResetColumns", "Reset Columns"),
|
|
LOCTEXT("ResetColumnsToolTip", "Reset all columns to be visible again."),
|
|
FSlateIcon(),
|
|
FUIAction(FExecuteAction::CreateSP(this, &SAssetView::ResetColumns)),
|
|
NAME_None,
|
|
EUserInterfaceActionType::Button
|
|
);
|
|
}
|
|
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()
|
|
{
|
|
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::ToggleShowCppFolders()
|
|
{
|
|
const bool bDisplayCppFolders = GetDefault<UContentBrowserSettings>()->GetDisplayCppFolders();
|
|
GetMutableDefault<UContentBrowserSettings>()->SetDisplayCppFolders(!bDisplayCppFolders);
|
|
GetMutableDefault<UContentBrowserSettings>()->PostEditChange();
|
|
}
|
|
|
|
bool SAssetView::IsShowingCppFolders() const
|
|
{
|
|
return GetDefault<UContentBrowserSettings>()->GetDisplayCppFolders();
|
|
}
|
|
|
|
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.IsSet())
|
|
{
|
|
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;
|
|
}
|
|
|
|
void SAssetView::FillToggleColumnsMenu(FMenuBuilder& MenuBuilder)
|
|
{
|
|
const TIndirectArray<SHeaderRow::FColumn> Columns = ColumnView->GetHeaderRow()->GetColumns();
|
|
|
|
for (int32 ColumnIndex = 0; ColumnIndex < Columns.Num(); ++ColumnIndex)
|
|
{
|
|
const FString ColumnName = Columns[ColumnIndex].ColumnId.ToString();
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
Columns[ColumnIndex].DefaultText,
|
|
LOCTEXT("ShowHideColumnTooltip", "Show or hide column"),
|
|
FSlateIcon(),
|
|
FUIAction(
|
|
FExecuteAction::CreateSP(this, &SAssetView::ToggleColumn, ColumnName),
|
|
FCanExecuteAction::CreateSP(this, &SAssetView::CanToggleColumn, ColumnName),
|
|
FIsActionChecked::CreateSP(this, &SAssetView::IsColumnVisible, ColumnName),
|
|
EUIActionRepeatMode::RepeatEnabled
|
|
),
|
|
NAME_None,
|
|
EUserInterfaceActionType::Check
|
|
);
|
|
}
|
|
}
|
|
|
|
void SAssetView::ResetColumns()
|
|
{
|
|
HiddenColumnNames.Empty();
|
|
NumVisibleColumns = ColumnView->GetHeaderRow()->GetColumns().Num();
|
|
ColumnView->GetHeaderRow()->RefreshColumns();
|
|
ColumnView->RebuildList();
|
|
}
|
|
|
|
void SAssetView::ToggleColumn(const FString ColumnName)
|
|
{
|
|
SetColumnVisibility(ColumnName, HiddenColumnNames.Contains(ColumnName));
|
|
}
|
|
|
|
void SAssetView::SetColumnVisibility(const FString ColumnName, const bool bShow)
|
|
{
|
|
if (!bShow)
|
|
{
|
|
--NumVisibleColumns;
|
|
HiddenColumnNames.Add(ColumnName);
|
|
}
|
|
else
|
|
{
|
|
++NumVisibleColumns;
|
|
check(HiddenColumnNames.Contains(ColumnName));
|
|
HiddenColumnNames.Remove(ColumnName);
|
|
}
|
|
|
|
ColumnView->GetHeaderRow()->RefreshColumns();
|
|
ColumnView->RebuildList();
|
|
}
|
|
|
|
bool SAssetView::CanToggleColumn(const FString ColumnName) const
|
|
{
|
|
return (HiddenColumnNames.Contains(ColumnName) || NumVisibleColumns > 1);
|
|
}
|
|
|
|
bool SAssetView::IsColumnVisible(const FString ColumnName) const
|
|
{
|
|
return !HiddenColumnNames.Contains(ColumnName);
|
|
}
|
|
|
|
bool SAssetView::ShouldColumnGenerateWidget(const FString ColumnName) const
|
|
{
|
|
return !HiddenColumnNames.Contains(ColumnName);
|
|
}
|
|
|
|
TSharedRef<SWidget> SAssetView::CreateRowHeaderMenuContent(const FString ColumnName)
|
|
{
|
|
FMenuBuilder MenuBuilder(true, NULL);
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
LOCTEXT("HideColumn", "Hide Column"),
|
|
LOCTEXT("HideColumnToolTip", "Hides this column."),
|
|
FSlateIcon(),
|
|
FUIAction(FExecuteAction::CreateSP(this, &SAssetView::SetColumnVisibility, ColumnName, false), FCanExecuteAction::CreateSP(this, &SAssetView::CanToggleColumn, ColumnName)),
|
|
NAME_None,
|
|
EUserInterfaceActionType::Button);
|
|
|
|
return MenuBuilder.MakeWidget();
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|