Files
UnrealEngineUWP/Engine/Source/Editor/WorldBrowser/Private/LevelCollectionModel.cpp
Jack Porter ae727f8dab Copying //UE4/Dev-Mobile to //UE4/Dev-Main (Source: //UE4/Dev-Mobile @ 3383462)
#lockdown Nick.Penwarden

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

Change 3292174 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: wasm and webgl2 support

	- Linux toolchain

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3292193 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: wasm and webgl2 support

	- ThirdParty libs compiled with new toolchain with wasm support

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3292215 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: wasm and wbegl2 support

	- emscripten toolchain

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3292222 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: wasm support

	- ENGINE changes (c# & cpp files)

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3292223 on 2017/02/08 by Nick.Shin

	HTML5 merge ThirdParty lib build scripts from Dev-Platform to Dev-Mobile

Change 3292228 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: webgl support

	- webgl patches
	- and a lot of UE4 patches to package HTML5 on LINUX
	- mostly from mozilla's jukka -- thx jukka!

	#jira  UEPLAT-828  (4.16)  Support ES3 / WebGL2 in HTML5

Change 3292285 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: wasm and webgl2 support

	- Windows toolchain

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3293994 on 2017/02/09 by Nick.Shin

	HTML5 emscripten: wasm and webgl2 support

	- OSX toolchain

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3294391 on 2017/02/09 by Nick.Shin

	HTML5 "black box issues" revisited

	- jukka rewrote the window resize handler -- much cleaner and more straightforward

	#jira UE-36341  HTML5 - View is incorrectly drawn
	#jira UE-32311  Templates on Firefox/Chrome on HTML5 are not full screen during Launch On

Change 3296421 on 2017/02/10 by Jack.Porter

	Fix landscape spline segment splitting placing when using streaming levels

Change 3296587 on 2017/02/10 by Jack.Porter

	Additional fix for landscape spline segment splitting when using streaming levels

Change 3301241 on 2017/02/14 by Mi.Wang

	Fixed DeviceProfileEditor bug for incorrect clamp the Texture Mip LOD size. #jira UE-36237 #rb jack.porter

Change 3301387 on 2017/02/14 by Nick.Shin

	HTML5 emscripten: webgl support

	- webgl patches from mozilla's jukka
	  + hardware instancing
	  + glBlitFramebuffer
	  + GL AlaphaBlendOperation

	#jira  UEPLAT-828  (4.16)  Support ES3 / WebGL2 in HTML5

Change 3301405 on 2017/02/14 by Nick.Shin

	HTML5 plugin fix when blueprint projects are promoted to code projects automatically.

	#jira UE-41710  HTML5 - Package Failure - Failed to Produce item ProjectName-OnlineSubsystemNull.bc

Change 3302278 on 2017/02/14 by Omar.Rodriguez

	UE-36651: Mac Vulkan Android Projects crash on launch.

	* Glslang library has been built for Mac but flag was not updated
	* Set GlslangAvailable to true for Mac when building an Android project with vulkan

	#jira UE-36651

Change 3302773 on 2017/02/14 by Chris.Babcock

	Add a dropdown with some common console commands on Android (contributed by rafortis)
	#jira UE-40834
	#PR #3143
	#ue4
	#android

Change 3305604 on 2017/02/16 by Nick.Shin

	HTML5 webgl2 shader- turn on: instance static mesh vertex factory

	#jira  UEPLAT-828  (4.16)  Support ES3 / WebGL2 in HTML5

Change 3308154 on 2017/02/16 by Nick.Shin

	HTML5 GitHub PR

	#jira UE-42019  GitHub 3258 : Added suport for emscripten --pre-js and --post-js option when building for HTML5

Change 3308510 on 2017/02/16 by Nick.Shin

	HTML5 webgl2 shader fixes

	#jria UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3308971 on 2017/02/17 by Jack.Porter

	Fix for landscape painting when height<0 in the Ortho viewports

Change 3309075 on 2017/02/17 by Allan.Bentham

	Include static subject meshes when masking out modulated shadow casters.

	#jira UE-41581

Change 3309531 on 2017/02/17 by Chris.Babcock

	Handle large OBB files in APK
	#jira UE-41443
	#ue4
	#android

Change 3311320 on 2017/02/19 by Dmitriy.Dyomin

	Fixed: Particle Cutout Crashes On Mobile Devices That Don't Support Hardware Instancing (Mali-400 GPU)
	#jira UE-41970

Change 3311347 on 2017/02/20 by Dmitriy.Dyomin

	Fixed: Engine Crashes When Previewing ES3_1 With Material Using World Position Offset (Need Custom Stencil)
	#jira UE-41976

Change 3311398 on 2017/02/20 by Dmitriy.Dyomin

	Fixed: Landscapes do not render on PowerVR device
	#jira UE-35530

Change 3311428 on 2017/02/20 by Dmitriy.Dyomin

	Fixed: Exposure Is More Extreme In High-End Mobile Preview Modes
	#jira UE-42036

Change 3311448 on 2017/02/20 by Dmitriy.Dyomin

	Fixed: Packaged game Crashes on android after entering "Help" command twice
	#jira UE-41956

Change 3311587 on 2017/02/20 by Allan.Bentham

	ES2 GLSL - Silently swap all uint to ints
	#jira UE-41548

Change 3313930 on 2017/02/21 by Allan.Bentham

	Print literal uints as ints when generating ES2 code.
	#jira UE-41548

Change 3317924 on 2017/02/22 by Nick.Shin

	HTML5 emscripten: wasm & webgl2 support - RC1

	- Linux toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3317929 on 2017/02/22 by Nick.Shin

	HTML5 emscripten: wasm & webgl2 support - RC1

	- ThirdParty libs compiled with new toolchain with wasm and webgl2 support

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3317951 on 2017/02/22 by Nick.Shin

	HTML5 emscripten: wasm & webgl2 support - RC1

	- emscripten toolchain

	WARNING: emscripten/incoming/source/include/libc/bit (the file) might need to be deleted first

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3318004 on 2017/02/22 by Nick.Shin

	HTML5 emscripten: wasm & webgl2 support - RC1

	- windows toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3318669 on 2017/02/23 by Nick.Shin

	HTML5 emscripten: wasm & webgl2 support - RC1

	- OSX toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3318672 on 2017/02/23 by Nick.Shin

	HTML5 webgl2 shader fixes

	#jria UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3318819 on 2017/02/23 by Dmitriy.Dyomin

	Fixed: Rendering artifacts with bloom on iPhone7 Metal
	#jira UE-40978

Change 3319702 on 2017/02/23 by Chris.Babcock

	Disable eglSwapInterval since it can cause issues with some drivers
	#ue4
	#android

Change 3320880 on 2017/02/24 by Dmitriy.Dyomin

	Added r.Mobile.TonemapperFilm cvar which can be used to enable/disable filmic tonemapper on mobile, independently from desktop (disabled by default)
	#jira UEMOB-195

Change 3321042 on 2017/02/24 by Jack.Porter

	Fixed incorrect sizeof in Vulkan pipleine cache
	pointed out here: http://coconutlizard.co.uk/blog/ue4/ue4-its-a-size-jim/

	#code_review: rolando.caloca

Change 3322383 on 2017/02/24 by Chris.Babcock

	Fix issue with ad banner on Android 7.0 devices
	#jira UE-42390
	#ue4
	#android

Change 3322479 on 2017/02/24 by Omar.Rodriguez

	UEMOB-199 - WEX: Improved virtual keyboard for Android

	* Calculating the area covered by the virtual keyboard
	* Calling OnVirtualKeyboardShown and OnVirtualKeyboardHidden events
	* Passing the Rect of the area covered by the virtual keyboard OnVirtualKeyboardShown event

	#jira UEMOB-199

Change 3323353 on 2017/02/27 by Allan.Bentham

	Fix broken mobile scene captures when !mobileHDR and RHINeedsToSwitchVerticalAxis
	#jira UE-42191

Change 3323431 on 2017/02/27 by Allan.Bentham

	CIS fix

Change 3323687 on 2017/02/27 by Allan.Bentham

	Disable GRHINeedsUnatlasedCSMDepthsWorkaround for mobile devices.
	#jira UE-42131

Change 3324652 on 2017/02/28 by Dmitriy.Dyomin

	Fixed: Canvas elements appear darker on iOS Metal

Change 3324885 on 2017/02/28 by Jack.Porter

	Fixed "Minimum iOS Version" setting display name

	#jira UE-42270

Change 3324899 on 2017/02/28 by Jack.Porter

	GitHub 3063 : removed duplicate gc.MaxObjectsInGame setting in IOSEngine.ini
	#jira UE-40018

	#3063

Change 3324932 on 2017/02/28 by Jack.Porter

	GitHub 3257 : iPhonePackager errors in output log when opening project settings on Windows

	#jira UE-41984
	#3257
	#codereview: Peter.Sauerbrei

Change 3324956 on 2017/02/28 by Jack.Porter

	FOpenGLFrontend::GetMaxSamplers incorrect for IOS
	#jira UE-42038
	#3264

Change 3325478 on 2017/02/28 by Allan.Bentham

	PR # 3188   : Fix far distance bug with cascaded shadows on mobile (Metal) and PC mobile preview  (Contributed by ufna)

	#jira UE-41442

Change 3327300 on 2017/03/01 by Allan.Bentham

	PR #3175   : Fixes high quality reflection blending seams  (Contributed by kallehamalainen)
	#jira UE-41257

Change 3328917 on 2017/03/02 by Nick.Shin

	HTML5 project settings

	expose ini settings to edtior HTML5 project settings panel

	#jira UE-42331  Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini
	#jira UE-41584  Editor locks up when adding an element for HTML5 devices on Mac
	#jira UE-41701  Editor freezes when setting browser filepath for inserted element in project settings

Change 3329169 on 2017/03/02 by Allan.Bentham

	increase render thread timeout to 1 minute for suntemple / android.
	Prevents low end devices timing out during load.
	#jira UE-40696

Change 3330849 on 2017/03/02 by Nick.Shin

	HTML5 project settings

	expose ini settings to edtior HTML5 project settings panel

	#jira UE-42331  Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini

Change 3331078 on 2017/03/03 by Dmitriy.Dyomin

	Fixed: Device output log partial lines

	integrated from WEX (3250488)

Change 3331112 on 2017/03/03 by Dmitriy.Dyomin

	Reduced state setup for slate draw calls (saves about 4ms RT time on mobile)

	integrated from WEX (3256584)

Change 3331117 on 2017/03/03 by Dmitriy.Dyomin

	Fixed redundant blend state changes in opengl

	integrated from WEX (3256586)

Change 3331173 on 2017/03/03 by Dmitriy.Dyomin

	Slate pixel shaders will use half precision where possible on mobile

	integrated from WEX (3256656)

Change 3332865 on 2017/03/06 by Dmitriy.Dyomin

	Better MobileContentScaleFactor defaults for iOS devices
	#jira UEMOB-330

Change 3333129 on 2017/03/06 by Peter.Sauerbrei

	move to Library/Caches instead of documents for saved files
	re-enable iterative deploy on TVOS
	#jira UEMOB-284

Change 3334692 on 2017/03/06 by Jack.Porter

	Allow r.MobileContentScaleFactor to be changed at runtime on Android

	#jira UEMOB-173

Change 3336255 on 2017/03/07 by Nick.Shin

	HTML5 project settings

	marking SIMD and multithreading as experimental - these do not play nice with WASM builds currently...

	#jira UE-42331  Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini

Change 3337094 on 2017/03/08 by Nick.Shin

	HTML5 project settings

	marking SIMD and multithreading as experimental - these do not play nice with WASM builds currently...

	#jira UE-42331  Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini

Change 3338800 on 2017/03/08 by Chris.Babcock

	Update AAR handling to deal with versioning, subproject dependencies for resources, and scope
	#jira UE-42677
	#ue4
	#android

Change 3338813 on 2017/03/08 by Chris.Babcock

	Pass build configuration to UPL for access during packaging as $S(Configuration)
	#jira UE-42678
	#ue4
	#android
	#ios

Change 3339401 on 2017/03/09 by Alicia.Cano

	Android runtime permissions
	- Fix for WRITE_EXTERNAL_STORAGE if it is not granted at time of onCreate for non-shipping builds
	- Fix for Location Services
	- Fix for if target sdk is not set to 23+
	#jira UE-38512
	#android
	#rb: chris.babcock

Change 3340736 on 2017/03/09 by Chris.Babcock

	Implement support for new controllers (Xbox Wireless, SteelSeries Stratus XL, PS4) (contributed by TRS-justing)
	#jira UE-41965
	#PR #3254
	#ue4
	#android

Change 3340744 on 2017/03/09 by Jack.Porter

	Expose Custom Depth to Foliage
	#jira UE-6061

Change 3340849 on 2017/03/09 by Dmitriy.Dyomin

	Fixed: iOS movie become laggy and crashes when played in iPhone 6/6s.
	#jira UE-42351

Change 3341268 on 2017/03/10 by Alicia.Cano

	PR #2894: Initial VoiceModuleAndroid support. (Contributed by devbm)
	#jira UE-37945
	#android
	#rb: chris.babcock, jack.porter

Change 3341303 on 2017/03/10 by Allan.Bentham

	Remove optimisation that prevents full specular occulsion on mobile.
	PR #3186  : Specular can't be blocked on high-end mobile.
	#jira UE-41393

Change 3342304 on 2017/03/10 by Alicia.Cano

	build fix
	#rb: chris.babcock

Change 3343344 on 2017/03/13 by Alicia.Cano

	build fix
	#rb: chris.babcock

Change 3343591 on 2017/03/13 by Brent.Pease

	iOS multiplayer fix part 1. Correct byte ordering.

	#jira UE-34875

Change 3343669 on 2017/03/13 by Chris.Babcock

	Update carefullyredist script version
	#jira UE-42832

Change 3344212 on 2017/03/13 by Will.Fissler

	Various compile fixes for Xcode 8.3.
	These fixes must also be added to //UE4/Release-4.15.
	#jira UE-41313

Change 3344396 on 2017/03/13 by Chris.Babcock

	Fix Java 1.5 obsolete warnings
	#jira UE-42851
	#ue4
	#android

Change 3345132 on 2017/03/14 by Will.Fissler

	Added ifdef wrapper to check clang version for presentDrawable.

Change 3345336 on 2017/03/14 by Will.Fissler

	Moved #if (__clang_major__ > 8) || (__clang_major__ == 8 && __clang_minor__ >= 1) check inside of the presentDrawable method.

Change 3345460 on 2017/03/14 by Will.Fissler

	ifdef changes for presentDrawable. The last submission duped the changes, instead of merging. #rb none

Change 3346046 on 2017/03/14 by Will.Fissler

	Fixed MetalCommandBuffer.cpp [again] after last submission duped changes instead of merging.

Change 3346367 on 2017/03/14 by Chris.Babcock

	Fix issue with GoogleVR ARMv7 libraries included for other architectures in link
	#ue4
	#android

Change 3347682 on 2017/03/15 by Allan.Bentham

	Enable HW sRGB correction with retainer widget's render target.
	Use slate's gamma correction for mobile (where no such support exists)
	Render retainer box RT content with gamma correction.
	#jira UE-40967

Change 3348712 on 2017/03/15 by Nick.Shin

	HTML5 - upload to S3

	updated to AWS "signature version 4" authentication

	#jira UE-42525  HTML5 Upload to Amazon S3 fails with Incorrect Configuration error

Change 3349254 on 2017/03/16 by Jack.Porter

	Fix for crash using the mobile previewer when the LQ lightmap shader permutation is disabled.
	#jira UE-42971

Change 3349739 on 2017/03/16 by Nick.Shin

	HTML5 - upload to S3

	better error message feedback on upload failures

	#jira UE-42525  HTML5 Upload to Amazon S3 fails with Incorrect Configuration error

Change 3349765 on 2017/03/16 by Alicia.Cano

	Disable mouseover events in Mobile Previewer

	#jira UE-19903
	#mobile
	#rb: Jack.Porter

Change 3350049 on 2017/03/16 by Nick.Shin

	HTML5 - upload to S3

	folder in bucket is optional

	#jira UE-42525  HTML5 Upload to Amazon S3 fails with Incorrect Configuration error

Change 3350153 on 2017/03/16 by Nick.Shin

	HTML5 - upload to S3

	updated S3 public link generator

	#jira UE-42525  HTML5 Upload to Amazon S3 fails with Incorrect Configuration error

Change 3351582 on 2017/03/17 by Will.Fissler

	Reverting the attempted fix for Xcode 8.3: Result += " -mcpu=cortex-a9";

	Currently we cannot build arm64 for iOS with this change.

Change 3352085 on 2017/03/17 by Alicia.Cano

	iOS doesn't honor request to close the virtual keyboard leading to a crash
	#jira UE-36447
	#ios
	#rb:Peter.Sauerbrei

Change 3353313 on 2017/03/19 by Ben.Marsh

	Always allow large *.js files in Github.

Change 3354444 on 2017/03/20 by Nick.Shin

	HTML5 - upload to S3

	to help make it obvious that "upload to S3" checkbox is set/or not -- disable S3 details if checkbox for "uploading to S3" is not set

	#jira UE-42525  HTML5 Upload to Amazon S3 fails with Incorrect Configuration error

Change 3355618 on 2017/03/20 by Nick.Shin

	HTML5 Save Game System

	- ripped out HTML5 code [from Engine's SaveGameSystem.h] and placed it in HTML5Platform.cpp
	- cleaned up HTML5PlatformFile.cpp (make it match as clost to linux's version)
	- created HTML5's own PlatformFeature & SaveGameSystem files -- and updated HTML5PlatformMisc to make use of the the new HTML5 SaveGame code

	#jira UE-42081 Remove heinous HTML5 code from engine

Change 3355621 on 2017/03/20 by Nick.Shin

	remove temp debugging code

	#jira UE-42081 Remove heinous HTML5 code from engine

Change 3356937 on 2017/03/21 by Chris.Babcock

	Add "stat vulkanrhi" to new console dropdown
	#jira UE-43149
	#ue4
	#android

Change 3357652 on 2017/03/21 by Nick.Shin

	HTML5 performance speed ups

	added "use fixed timestep" setting option for HTML5 builds (this has been separated from Engine - General Settings - Framerate)
	- this is slightly different to smooth framerate and fixed framerate - thus, the timestep option was put in the HTML5 specific panel

	this option is based on the suggestions by jukka's post:
	- https://answers.unrealengine.com/questions/409629/smooth-frame-rate-and-use-fixed-frame-rate-should.html

	however, using this option will make the player "run faster" on (for example) thirdperson blueprint template -- but, it has no effect on other (for example) zen garden...

	#jira UE-30214 - Implement a warning message for fps settings

Change 3360415 on 2017/03/23 by Allan.Bentham

	Fix crash that occurs when ES3.1 preview is used with r.MobileHDR32bppMode modes.

Change 3360418 on 2017/03/23 by Allan.Bentham

	Disable filmic tonemapper if r.MobileHDR32bppMode is in use.
	#jira UE-40913

Change 3360557 on 2017/03/23 by Allan.Bentham

	Better fix for mobile CSM shadow flickering (UE-42131), now works for PC OpenGL based mobile preview.
	#jira UE-42131

Change 3362258 on 2017/03/23 by Dmitriy.Dyomin

	Fixed: Canvas texture element gamma issues on iOS Metal

Change 3362321 on 2017/03/24 by Dmitriy.Dyomin

	GitHub 3173 : MaterialAO support for mobile rendering path (contributed by kallehamalainen)

	#3173

Change 3363550 on 2017/03/24 by Alicia.Cano

	build fix for devices < Android 5.0
	#jira UE-43299
	#android
	#rb: chris.babcock

Change 3363687 on 2017/03/24 by Chris.Babcock

	Fix Android password hiding in input dialog
	#jira WEX-5159
	#ue4
	#android

Change 3365280 on 2017/03/27 by Dmitriy.Dyomin

	Fix for GL_EXT_shader_framebuffer_fetch on Zenfone5. Use UE_EXT_shader_framebuffer_fetch define on all devices to enable extension

Change 3365291 on 2017/03/27 by Dmitriy.Dyomin

	Copied form WEX CL# 3308653
	Fixed: Enabling shader cache causes crash on NVIDIA Shield

	#jira UE-41639

Change 3365293 on 2017/03/27 by Dmitriy.Dyomin

	GitHub 3411 : Fix crash in patching utils mount method (contributed by nverenik)
	#jira UE-43247
	#3411

Change 3365340 on 2017/03/27 by Dmitriy.Dyomin

	Fixed: Moving sublevel in world composition browser does not appear in Undo History
	#jira UE-35535

Change 3365564 on 2017/03/27 by Allan.Bentham

	SkyLightComponent now serializes IrradianceMap SH values.
	clicking Recapture sky button in mobile preview switches back to SM4/5 to update captures.
	Skylights that are dirty from load will trigger reflection capture update once shaders are rebuilt.
	#jira UE-42436

Change 3366282 on 2017/03/27 by Nick.Shin

	remove dead links

	these files to not exist anywhere in the make-3.81 subfolders

	#UDN-354501
	#jira none

Change 3366306 on 2017/03/27 by Nick.Shin

	HTML5 - disable multi-threading for wasm

	#jira UE-43219 - HTML5 disable multi-threading for wasm

Change 3366307 on 2017/03/27 by Nick.Shin

	HTML5 packaging Shipping builds

	big cleanup / additions to *gz file support for amazon s3

	* both, uploading to s3
	* and allowing s3 to host the games there

	#jira UE-43002 HTML5 in Shipping fails downloading symbols files
	#jria UE-43001 HTML5 Shipping Projects fail looking for compressed files when "Compress files during shipping packaging" is not selected.

Change 3367385 on 2017/03/28 by Allan.Bentham

	Display skylight serialization warning only when cooking for mobile platforms.
	#jira UE-42436

Change 3368583 on 2017/03/28 by Chris.Babcock

	Expose JAVA_HOME setting in Android SDK project settings on Mac
	#jira UE-43418
	#ue4
	#android

Change 3368803 on 2017/03/28 by Chris.Babcock

	Fix features requested in manifest for "Daydream and Cardboard" mode
	#jira UE-43314
	#ue4
	#android

Change 3369087 on 2017/03/28 by Jack.Porter

	Changed tooltip and added supported devices in paretheses for Android Mobile Deferred / ES31+AEP
	#jira UE-42438

Change 3369372 on 2017/03/29 by Allan.Bentham

	Fix disappearing meshes when r.mobile.allowdistancefieldshadows is disabled.
	#jira UE-43366

Change 3369381 on 2017/03/29 by Jack.Porter

	Show warnings when mobile shader permutations required for rendering are disbaled
	Made FReadOnlyCVARCache a singleton and added mobile CVars, used for MobileBasePassRendering.
	#jira UE-43050

Change 3369430 on 2017/03/29 by Allan.Bentham

	fix CIS build

Change 3369740 on 2017/03/29 by Allan.Bentham

	Added Android option to enable builds with hidden symbol visbility by default. (bBuildWithHiddenSymbolVisibility)
	Android links with -gc-sections to remove unused code/data
	Add JNI_METHOD for java accessible native functions, fixed up existing JNI functions to use macro.
	Add support for map file generation with android.
	Add 'bBuildWithHiddenSymbolVisibility' to AndroidPlatform.HasDefaultBuildConfig()
	bBuildWithHiddenSymbolVisibility defaults to false in BaseEngine.ini

	#jira UEMOB-168

Change 3369975 on 2017/03/29 by Nick.Shin

	HTML5 - AWS S3 shareable link for shipping builds corrected

	#jira UE-43379 Amazon S3 Shareable link does not generate correct filepath.

Change 3369998 on 2017/03/29 by Nick.Shin

	HTML5 python build scripts

	PR:
	1cb836d43c

	#jira none

Change 3370214 on 2017/03/29 by Nick.Shin

	HTML5 - default bUseFixedTimeStep to false...

	#jira UE-43380 - Default HTML5 gamespeed is faster than equivalent platforms

Change 3370762 on 2017/03/29 by Chris.Babcock

	Fixes to new keyboard for Android
	- Ensure the local scope ScreenRect passed into OnVirtualKeyboardShown in AndroidJNI is captured by value instead of by reference.
	- Moved ShowVirtualKeyboardInput's bKeyboardShowing early-out checks into the UI thread task. This allows the keyboard to continue showing when changing focus between multiple EditableTextBox widgets.
	#ue4
	#android

Change 3371344 on 2017/03/30 by Jack.Porter

	Fixed issue where Vulkan screenshot R/B channels were reversed on Android
	#jira UE-43479

Change 3372926 on 2017/03/30 by Peter.Sauerbrei

	start the process of sunsetting 32-bit and GLES2 on iOS
	#jira UE-42266

Change 3372970 on 2017/03/30 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- windows toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rn

Change 3372989 on 2017/03/30 by Peter.Sauerbrei

	fix for Xcode 8.3 build with 32-bit

Change 3373007 on 2017/03/30 by Peter.Sauerbrei

	fix for crash when online subsystem is disabled on IOS

Change 3373108 on 2017/03/30 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- emscripten toolchain

	WARNING: emscripten/incoming/source/include/libc/bit (the file) might need to be deleted first

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rn

Change 3373163 on 2017/03/30 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- OSX toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rn

Change 3373169 on 2017/03/30 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	license file updated

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rnx

Change 3373287 on 2017/03/30 by Nick.Shin

	HTML5 - 1.36.11 emscripten - remove old SDK

	#jira none

	#rnx

Change 3373289 on 2017/03/30 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- Linux toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rn

Change 3373595 on 2017/03/30 by Chris.Babcock

	Reenable GooglePlay for ARM64 now that it doesn't crash
	#jira UE-36198
	#ue4
	#android

Change 3373606 on 2017/03/30 by Chris.Babcock

	Submitting Allan's shelved EXT_shader_framebuffer_fetch fix
	#ue4
	#android

Change 3375456 on 2017/03/31 by Chris.Babcock

	Add missing keycodes for Android keyboard (@ and #)
	#jira WEX-5777
	#ue4
	#android

Change 3376309 on 2017/04/03 by Allan.Bentham

	Fix overflow issues with mobile DoF.

Change 3377041 on 2017/04/03 by Will.Fissler

	Adding Testbed content for PlatformShowcase.

Change 3377582 on 2017/04/03 by Alicia.Cano

	adding back in GET_ACCOUNTS permission as it is required for Reset Achievements

	#jira: UE-43265
	#android
	#rb: Chris.Babcock

Change 3377643 on 2017/04/03 by Peter.Sauerbrei

	fix for memory leak in MallocBinned
	#jira UE-43008

Change 3378033 on 2017/04/04 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- ThirdParty libs compiled with new toolchain with wasm and webgl2 support

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rn

Change 3378034 on 2017/04/04 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- ThirdParty build scripts

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3378035 on 2017/04/04 by Nick.Shin

	HTML5 - Update GameX template to make it work with trunk Emscripten

	PR
	dc2b26f452 (commitcomment-21454978)

	#jira none

	#rn

Change 3378044 on 2017/04/04 by Nick.Shin

	HTML5 harfbuzz - double checking recompiled with NO multithreading

	wasm currently does not support pthreads

	*** THIS IS STILL WIP ***
	checking in to match 3rd party libs compiled configuration

	#jira UE-28588 - Build HarfBuzz for HTML5

	#rnx

Change 3378264 on 2017/04/04 by Allan.Bentham

	Fix crash when using consolas font on android sdk 24
	#jira UE-43464

Change 3379097 on 2017/04/04 by Nick.Shin

	CIS HTML5 build warning fix

	#jria none

	#rnx

Change 3379333 on 2017/04/04 by Chris.Babcock

	Prevent inserting extra permissions into manifest multiple times
	#jira UE-43583
	#ue4
	#android

Change 3380870 on 2017/04/05 by Chris.Babcock

	Fix merge issue

Change 3380898 on 2017/04/05 by Chris.Babcock

	Fixed again

Change 3381443 on 2017/04/05 by Chris.Babcock

	Fix for GearVR non-unity build
	#ue4
	#android

Change 3381941 on 2017/04/05 by Chris.Babcock

	Fix HTTPChunkInstaller texture format checks and missing #define warning
	#jira UE-43706
	#ue4
	#android

Change 3382056 on 2017/04/05 by Chris.Babcock

	Updates to Android AARs needed for Facebook plugin

Change 3382097 on 2017/04/05 by Chris.Babcock

	Disable java console cmd receiver only in shipping builds
	#jira UE-43710
	#ue4
	#android

Change 3382497 on 2017/04/06 by Allan.Bentham

	Fix Fortnite Cooked Server crashes when joining game from lobby.
	#jira UE-43695

Change 3383227 on 2017/04/06 by Will.Fissler

	Reverted case sensitive change, from yesterday, and implemented a pragma instead.

	#jira UE-41313

[CL 3383473 by Jack Porter in Main branch]
2017-04-06 16:13:17 -04:00

1994 lines
54 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "LevelCollectionModel.h"
#include "Misc/PackageName.h"
#include "AssetData.h"
#include "Misc/MessageDialog.h"
#include "Misc/ConfigCacheIni.h"
#include "Misc/FeedbackContext.h"
#include "Modules/ModuleManager.h"
#include "Framework/MultiBox/MultiBoxBuilder.h"
#include "ISourceControlOperation.h"
#include "SourceControlOperations.h"
#include "ISourceControlModule.h"
#include "Settings/EditorLoadingSavingSettings.h"
#include "Engine/Selection.h"
#include "EditorModeManager.h"
#include "EditorModes.h"
#include "FileHelpers.h"
#include "EditorModeInterpolation.h"
#include "ScopedTransaction.h"
#include "EditorLevelUtils.h"
#include "LevelCollectionCommands.h"
#include "SourceControlWindows.h"
#include "IAssetTools.h"
#include "IAssetTypeActions.h"
#include "AssetToolsModule.h"
#include "EditorSupportDelegates.h"
#include "Matinee/MatineeActor.h"
#include "GameFramework/WorldSettings.h"
#include "ShaderCompiler.h"
#define LOCTEXT_NAMESPACE "WorldBrowser"
FLevelCollectionModel::FLevelCollectionModel()
: bRequestedUpdateAllLevels(false)
, bRequestedRedrawAllLevels(false)
, bRequestedUpdateActorsCount(false)
, CommandList(MakeShareable(new FUICommandList))
, Filters(MakeShareable(new LevelFilterCollection))
, WorldSize(FIntPoint::ZeroValue)
, bDisplayPaths(false)
, bCanExecuteSCCCheckOut(false)
, bCanExecuteSCCOpenForAdd(false)
, bCanExecuteSCCCheckIn(false)
, bCanExecuteSCC(false)
, bSelectionHasChanged(true)
, bUpdatingLevelsSelection(false)
{
}
FLevelCollectionModel::~FLevelCollectionModel()
{
SaveSettings();
Filters->OnChanged().RemoveAll(this);
FWorldDelegates::LevelAddedToWorld.RemoveAll(this);
FWorldDelegates::LevelRemovedFromWorld.RemoveAll(this);
FEditorSupportDelegates::RedrawAllViewports.RemoveAll(this);
GEditor->OnLevelActorAdded().RemoveAll(this);
GEditor->OnLevelActorDeleted().RemoveAll(this);
if (CurrentWorld.IsValid())
{
CurrentWorld->OnSelectedLevelsChanged().RemoveAll(this);
}
}
void FLevelCollectionModel::Initialize(UWorld* InWorld)
{
LoadSettings();
CurrentWorld = InWorld;
Filters->OnChanged().AddSP(this, &FLevelCollectionModel::OnFilterChanged);
FWorldDelegates::LevelAddedToWorld.AddSP(this, &FLevelCollectionModel::OnLevelAddedToWorld);
FWorldDelegates::LevelRemovedFromWorld.AddSP(this, &FLevelCollectionModel::OnLevelRemovedFromWorld);
FEditorSupportDelegates::RedrawAllViewports.AddSP(this, &FLevelCollectionModel::OnRedrawAllViewports);
GEditor->OnLevelActorAdded().AddSP( this, &FLevelCollectionModel::OnLevelActorAdded);
GEditor->OnLevelActorDeleted().AddSP( this, &FLevelCollectionModel::OnLevelActorDeleted);
USelection::SelectionChangedEvent.AddSP(this, &FLevelCollectionModel::OnActorSelectionChanged);
SelectionChanged.AddSP(this, &FLevelCollectionModel::OnActorOrLevelSelectionChanged);
CurrentWorld->OnSelectedLevelsChanged().AddSP(this, &FLevelCollectionModel::OnLevelsSelectionChangedOutside);
PopulateLevelsList();
}
void FLevelCollectionModel::BindCommands()
{
const FLevelCollectionCommands& Commands = FLevelCollectionCommands::Get();
FUICommandList& ActionList = *CommandList;
ActionList.MapAction(Commands.RefreshBrowser,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::RefreshBrowser_Executed));
ActionList.MapAction(Commands.ExpandSelectedItems,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::ExpandSelectedItems_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::AreAnyLevelsSelected));
ActionList.MapAction(Commands.World_MakeLevelCurrent,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::MakeLevelCurrent_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::IsOneLevelSelected));
ActionList.MapAction(Commands.World_FindInContentBrowser,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::FindInContentBrowser_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::IsValidFindInContentBrowser));
ActionList.MapAction(Commands.MoveActorsToSelected,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::MoveActorsToSelected_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::IsValidMoveActorsToLevel));
ActionList.MapAction(Commands.MoveFoliageToSelected,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::MoveFoliageToSelected_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::IsValidMoveFoliageToLevel));
ActionList.MapAction(Commands.World_SaveSelectedLevels,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::SaveSelectedLevels_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::AreAnySelectedLevelsDirty));
ActionList.MapAction(Commands.World_SaveSelectedLevelAs,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::SaveSelectedLevelAs_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::IsSelectedLevelEditable));
ActionList.MapAction(Commands.World_LoadLevel,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::LoadSelectedLevels_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::AreAnySelectedLevelsUnloaded));
ActionList.MapAction(Commands.World_UnloadLevel,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::UnloadSelectedLevels_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::AreAnySelectedLevelsLoaded));
ActionList.MapAction( Commands.World_MigrateSelectedLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::MigrateSelectedLevels_Executed),
FCanExecuteAction::CreateSP( this, &FLevelCollectionModel::AreAllSelectedLevelsEditable));
//actors
ActionList.MapAction(Commands.AddsActors,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::SelectActors_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::AreAnySelectedLevelsEditable));
ActionList.MapAction(Commands.RemovesActors,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::DeselectActors_Executed),
FCanExecuteAction::CreateSP(this, &FLevelCollectionModel::AreAnySelectedLevelsEditable));
//visibility
ActionList.MapAction( Commands.World_ShowSelectedLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::ShowSelectedLevels_Executed ),
FCanExecuteAction::CreateSP( this, &FLevelCollectionModel::AreAnySelectedLevelsLoaded ) );
ActionList.MapAction( Commands.World_HideSelectedLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::HideSelectedLevels_Executed ),
FCanExecuteAction::CreateSP( this, &FLevelCollectionModel::AreAnySelectedLevelsLoaded ) );
ActionList.MapAction( Commands.World_ShowOnlySelectedLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::ShowOnlySelectedLevels_Executed ),
FCanExecuteAction::CreateSP( this, &FLevelCollectionModel::AreAnySelectedLevelsLoaded ) );
ActionList.MapAction(Commands.World_ShowAllLevels,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::ShowAllLevels_Executed));
ActionList.MapAction(Commands.World_HideAllLevels,
FExecuteAction::CreateSP(this, &FLevelCollectionModel::HideAllLevels_Executed));
//lock
ActionList.MapAction( Commands.World_LockSelectedLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::LockSelectedLevels_Executed ),
FCanExecuteAction::CreateSP( this, &FLevelCollectionModel::AreAnySelectedLevelsEditable ) );
ActionList.MapAction( Commands.World_UnockSelectedLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::UnlockSelectedLevels_Executed ),
FCanExecuteAction::CreateSP( this, &FLevelCollectionModel::AreAnySelectedLevelsEditable ) );
ActionList.MapAction( Commands.World_LockAllLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::LockAllLevels_Executed ) );
ActionList.MapAction( Commands.World_UnockAllLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::UnockAllLevels_Executed ) );
ActionList.MapAction( Commands.World_LockReadOnlyLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::ToggleReadOnlyLevels_Executed ) );
ActionList.MapAction( Commands.World_UnlockReadOnlyLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::ToggleReadOnlyLevels_Executed ) );
//level selection
ActionList.MapAction( Commands.SelectAllLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::SelectAllLevels_Executed ) );
ActionList.MapAction( Commands.DeselectAllLevels,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::DeselectAllLevels_Executed ) );
ActionList.MapAction( Commands.InvertLevelSelection,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::InvertSelection_Executed ) );
//source control
ActionList.MapAction( Commands.SCCCheckOut,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::OnSCCCheckOut ) );
ActionList.MapAction( Commands.SCCCheckIn,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::OnSCCCheckIn ) );
ActionList.MapAction( Commands.SCCOpenForAdd,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::OnSCCOpenForAdd ) );
ActionList.MapAction( Commands.SCCHistory,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::OnSCCHistory ) );
ActionList.MapAction( Commands.SCCRefresh,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::OnSCCRefresh ) );
ActionList.MapAction( Commands.SCCDiffAgainstDepot,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::OnSCCDiffAgainstDepot ) );
ActionList.MapAction( Commands.SCCConnect,
FExecuteAction::CreateSP( this, &FLevelCollectionModel::OnSCCConnect ) );
}
void FLevelCollectionModel::PopulateLevelsList()
{
RootLevelsList.Empty();
AllLevelsList.Empty();
FilteredLevelsList.Empty();
SelectedLevelsList.Empty();
AllLevelsMap.Empty();
OnLevelsCollectionChanged();
}
void FLevelCollectionModel::PopulateFilteredLevelsList()
{
FilteredLevelsList.Empty();
// Filter out our flat list
for (auto& LevelModel : AllLevelsList)
{
LevelModel->SetLevelFilteredOutFlag(true);
if (LevelModel->IsPersistent() || PassesAllFilters(*LevelModel))
{
FilteredLevelsList.Add(LevelModel);
LevelModel->SetLevelFilteredOutFlag(false);
}
}
// Walk through hierarchy and filter it out
for (auto It = RootLevelsList.CreateIterator(); It; ++It)
{
(*It)->OnFilterChanged();
}
}
void FLevelCollectionModel::Tick( float DeltaTime )
{
if (GEditor == nullptr)
{
// Could it be during hot-reloading?
return;
}
if (bRequestedUpdateAllLevels)
{
UpdateAllLevels();
}
if (bRequestedRedrawAllLevels)
{
RedrawAllLevels();
}
if (bRequestedUpdateActorsCount)
{
UpdateLevelActorsCount();
}
if (IsSimulating())
{
// Reset simulation status for all levels
for (TSharedPtr<FLevelModel>& LevelModel : AllLevelsList)
{
LevelModel->UpdateSimulationStatus(nullptr);
}
// Traverse streaming levels and update simulation status for corresponding level models
for (ULevelStreaming* StreamingLevel : GetSimulationWorld()->StreamingLevels)
{
// Rebuild the original NonPrefixedPackageName so we can find it
const FString PrefixedPackageName = StreamingLevel->GetWorldAssetPackageName();
const FString NonPrefixedPackageName = FPackageName::GetLongPackagePath(PrefixedPackageName) + "/"
+ FPackageName::GetLongPackageAssetName(PrefixedPackageName).RightChop(GetSimulationWorld()->StreamingLevelsPrefix.Len());
TSharedPtr<FLevelModel> LevelModel = FindLevelModel(FName(*NonPrefixedPackageName));
if (LevelModel.IsValid())
{
LevelModel->UpdateSimulationStatus(StreamingLevel);
}
}
}
}
TStatId FLevelCollectionModel::GetStatId() const
{
RETURN_QUICK_DECLARE_CYCLE_STAT(FLevelCollectionModel, STATGROUP_Tickables);
}
bool FLevelCollectionModel::IsReadOnly() const
{
// read only in PIE/SIE
return IsSimulating();
}
bool FLevelCollectionModel::IsSimulating() const
{
return (GEditor->bIsSimulatingInEditor || GEditor->PlayWorld != NULL);
}
UWorld* FLevelCollectionModel::GetSimulationWorld() const
{
return GEditor->PlayWorld;
}
bool FLevelCollectionModel::IsOriginRebasingEnabled() const
{
UWorld* ThisWorld = GetWorld();
return ThisWorld && ThisWorld->GetWorldSettings()->bEnableWorldOriginRebasing;
}
FLevelModelList& FLevelCollectionModel::GetRootLevelList()
{
return RootLevelsList;
}
const FLevelModelList& FLevelCollectionModel::GetAllLevels() const
{
return AllLevelsList;
}
const FLevelModelList& FLevelCollectionModel::GetFilteredLevels() const
{
return FilteredLevelsList;
}
const FLevelModelList& FLevelCollectionModel::GetSelectedLevels() const
{
return SelectedLevelsList;
}
void FLevelCollectionModel::AddFilter(const TSharedRef<LevelFilter>& InFilter)
{
Filters->Add(InFilter);
OnFilterChanged();
}
void FLevelCollectionModel::RemoveFilter(const TSharedRef<LevelFilter>& InFilter)
{
Filters->Remove(InFilter);
OnFilterChanged();
}
bool FLevelCollectionModel::IsFilterActive() const
{
return (AllLevelsList.Num() != FilteredLevelsList.Num());
}
void FLevelCollectionModel::SetSelectedLevels(const FLevelModelList& InList)
{
// Clear selection flag from currently selected levels
for (auto LevelModel : SelectedLevelsList)
{
LevelModel->SetLevelSelectionFlag(false);
}
SelectedLevelsList.Empty();
// Set selection flag to selected levels
for (auto& LevelModel : InList)
{
if (LevelModel.IsValid() && PassesAllFilters(*LevelModel))
{
LevelModel->SetLevelSelectionFlag(true);
SelectedLevelsList.Add(LevelModel);
}
}
OnLevelsSelectionChanged();
}
void FLevelCollectionModel::SetSelectedLevelsFromWorld()
{
TArray<ULevel*>& SelectedLevelObjects = CurrentWorld->GetSelectedLevels();
FLevelModelList LevelsToSelect;
for (ULevel* LevelObject : SelectedLevelObjects)
{
TSharedPtr<FLevelModel> LevelModel = FindLevelModel(LevelObject);
if (LevelModel.IsValid())
{
LevelsToSelect.Add(LevelModel);
}
}
SetSelectedLevels(LevelsToSelect);
}
TSharedPtr<FLevelModel> FLevelCollectionModel::FindLevelModel(ULevel* InLevel) const
{
if (InLevel)
{
for (auto It = AllLevelsList.CreateConstIterator(); It; ++It)
{
if ((*It)->GetLevelObject() == InLevel)
{
return (*It);
}
}
}
// not found
return TSharedPtr<FLevelModel>();
}
TSharedPtr<FLevelModel> FLevelCollectionModel::FindLevelModel(const FName& PackageName) const
{
const TSharedPtr<FLevelModel>* LevelModel = AllLevelsMap.Find(PackageName);
if (LevelModel != NULL)
{
return *LevelModel;
}
// not found
return TSharedPtr<FLevelModel>();
}
void FLevelCollectionModel::IterateHierarchy(FLevelModelVisitor& Visitor)
{
for (auto It = RootLevelsList.CreateIterator(); It; ++It)
{
(*It)->Accept(Visitor);
}
}
void FLevelCollectionModel::HideLevels(const FLevelModelList& InLevelList)
{
if (IsReadOnly())
{
return;
}
for (auto It = InLevelList.CreateConstIterator(); It; ++It)
{
(*It)->SetVisible(false);
}
RequestUpdateAllLevels();
}
void FLevelCollectionModel::ShowLevels(const FLevelModelList& InLevelList)
{
if (IsReadOnly())
{
return;
}
OnPreShowLevels(InLevelList);
for (auto It = InLevelList.CreateConstIterator(); It; ++It)
{
(*It)->SetVisible(true);
}
RequestUpdateAllLevels();
}
void FLevelCollectionModel::UnlockLevels(const FLevelModelList& InLevelList)
{
if (!IsReadOnly())
{
const FText UndoTransactionText = (InLevelList.Num() == 1) ?
LOCTEXT("UnlockLevel", "Unlock Level") :
LOCTEXT("UnlockMultipleLevels", "Unlock Multiple Levels");
const FScopedTransaction Transaction(UndoTransactionText);
for (auto It = InLevelList.CreateConstIterator(); It; ++It)
{
(*It)->SetLocked(false);
}
}
}
void FLevelCollectionModel::LockLevels(const FLevelModelList& InLevelList)
{
if (!IsReadOnly())
{
const FText UndoTransactionText = (InLevelList.Num() == 1) ?
LOCTEXT("LockLevel", "Lock Level") :
LOCTEXT("LockMultipleLevels", "Lock Multiple Levels");
const FScopedTransaction Transaction(UndoTransactionText);
for (auto It = InLevelList.CreateConstIterator(); It; ++It)
{
(*It)->SetLocked(true);
}
}
}
void FLevelCollectionModel::SaveLevels(const FLevelModelList& InLevelList)
{
if (IsReadOnly())
{
return;
}
FLevelModelList LevelModelsToSave;
TArray<ULevel*> LevelsToSave;
for (auto It = InLevelList.CreateConstIterator(); It; ++It)
{
if ((*It)->GetLevelObject())
{
if (!(*It)->IsVisible())
{
FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "UnableToSaveInvisibleLevels", "Save aborted. Levels must be made visible before they can be saved.") );
return;
}
else if ((*It)->IsLocked())
{
FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "UnableToSaveLockedLevels", "Save aborted. Level must be unlocked before it can be saved.") );
return;
}
LevelModelsToSave.Add(*It);
LevelsToSave.Add((*It)->GetLevelObject());
}
}
TArray< UPackage* > PackagesNotNeedingCheckout;
// Prompt the user to check out the levels from source control before saving
if (FEditorFileUtils::PromptToCheckoutLevels(false, LevelsToSave, &PackagesNotNeedingCheckout))
{
for (auto It = LevelsToSave.CreateIterator(); It; ++It)
{
FEditorFileUtils::SaveLevel(*It);
}
}
else if (PackagesNotNeedingCheckout.Num() > 0)
{
// The user canceled the checkout dialog but some packages didn't need to be checked out in order to save
// For each selected level if the package its in didn't need to be saved, save the level!
for (int32 LevelIdx = 0; LevelIdx < LevelsToSave.Num(); ++LevelIdx)
{
ULevel* Level = LevelsToSave[LevelIdx];
if (PackagesNotNeedingCheckout.Contains(Level->GetOutermost()))
{
FEditorFileUtils::SaveLevel(Level);
}
else
{
//remove it from the list, so that only successfully saved levels are highlighted when saving is complete
LevelModelsToSave.RemoveAt(LevelIdx);
LevelsToSave.RemoveAt(LevelIdx);
}
}
}
// Select tiles that were saved successfully
SetSelectedLevels(LevelModelsToSave);
}
void FLevelCollectionModel::LoadLevels(const FLevelModelList& InLevelList)
{
if (IsReadOnly())
{
return;
}
GWarn->BeginSlowTask(LOCTEXT("LoadWorldTiles", "Loading levels"), true);
OnPreLoadLevels(InLevelList);
int32 LevelIdx = 0;
for (TSharedPtr<FLevelModel> LevelModel : InLevelList)
{
GWarn->StatusUpdate(LevelIdx++, InLevelList.Num(),
FText::Format(LOCTEXT("LoadingWorldTiles", "Loading: {0}..." ), FText::FromString(LevelModel->GetLongPackageName().ToString()))
);
LevelModel->LoadLevel();
}
if (InLevelList.Num() > 0)
{
GEditor->ResetTransaction(LOCTEXT("LoadingWorldTilesTransReset", "Loading Levels"));
}
GWarn->EndSlowTask();
}
void FLevelCollectionModel::UnloadLevels(const FLevelModelList& InLevelList)
{
if (InLevelList.Num() == 0)
{
return;
}
UWorld* ThisWorld = GetWorld();
check(ThisWorld != nullptr);
// If matinee is opened, and if it belongs to the level being removed, close it
if (GLevelEditorModeTools().IsModeActive(FBuiltinEditorModes::EM_InterpEdit))
{
TArray<ULevel*> LevelsToRemove = GetLevelObjectList(InLevelList);
const FEdModeInterpEdit* InterpEditMode = (const FEdModeInterpEdit*)GLevelEditorModeTools().GetActiveMode(FBuiltinEditorModes::EM_InterpEdit);
if (InterpEditMode && InterpEditMode->MatineeActor && LevelsToRemove.Contains(InterpEditMode->MatineeActor->GetLevel()))
{
GLevelEditorModeTools().ActivateDefaultMode();
}
}
else if(GLevelEditorModeTools().IsModeActive(FBuiltinEditorModes::EM_Landscape))
{
GLevelEditorModeTools().ActivateDefaultMode();
}
// Take a copy of the list rather than using a reference to the selected levels list, as this will be modified in the loop below
const FLevelModelList LevelListCopy = InLevelList;
for (auto It = LevelListCopy.CreateConstIterator(); It; ++It)
{
TSharedPtr<FLevelModel> LevelModel = (*It);
ULevel* Level = LevelModel->GetLevelObject();
if (Level != nullptr && !LevelModel->IsPersistent())
{
// Unselect all actors before removing the level
// This avoids crashing in areas that rely on getting a selected actors level. The level will be invalid after its removed.
for (auto ActorIt = Level->Actors.CreateIterator(); ActorIt; ++ActorIt)
{
GEditor->SelectActor((*ActorIt), /*bInSelected=*/ false, /*bSelectEvenIfHidden=*/ false);
}
// In case we have created temporary streaming level object for this sub-level - remove it before unloading sub-level
{
FName LevelPackageName = LevelModel->GetLongPackageName();
auto Predicate = [&](ULevelStreaming* StreamingLevel)
{
return (StreamingLevel->GetWorldAssetPackageFName() == LevelPackageName && StreamingLevel->HasAnyFlags(RF_Transient));
};
int32 Index = ThisWorld->StreamingLevels.IndexOfByPredicate(Predicate);
if (Index != INDEX_NONE)
{
ThisWorld->StreamingLevels[Index]->MarkPendingKill();
ThisWorld->StreamingLevels.RemoveAt(Index);
}
}
// Unload sub-level
{
FUnmodifiableObject ImmuneWorld(CurrentWorld.Get());
EditorLevelUtils::RemoveLevelFromWorld(Level);
}
}
}
GEditor->ResetTransaction( LOCTEXT("RemoveLevelTransReset", "Removing Levels from World") );
// Collect garbage to clear out the destroyed level
CollectGarbage( GARBAGE_COLLECTION_KEEPFLAGS );
PopulateLevelsList();
}
void FLevelCollectionModel::TranslateLevels(const FLevelModelList& InLevels, FVector2D InDelta, bool bSnapDelta)
{
}
FVector2D FLevelCollectionModel::SnapTranslationDelta(const FLevelModelList& InLevelList, FVector2D InTranslationDelta, bool bBoundsSnapping, float InSnappingValue)
{
return InTranslationDelta;
}
void FLevelCollectionModel::UpdateTranslationDelta(const FLevelModelList& InLevelList, FVector2D InTranslationDelta, bool bBoundsSnapping, float InSnappingValue)
{
FLevelModelList EditableLevels;
// Only editable levels could be moved
for (auto It = InLevelList.CreateConstIterator(); It; ++It)
{
if ((*It)->IsEditable())
{
EditableLevels.Add(*It);
}
}
// Snap translation delta
if (InTranslationDelta != FVector2D::ZeroVector)
{
InTranslationDelta = SnapTranslationDelta(EditableLevels, InTranslationDelta, bBoundsSnapping, InSnappingValue);
}
for (auto It = EditableLevels.CreateIterator(); It; ++It)
{
(*It)->SetLevelTranslationDelta(InTranslationDelta);
}
}
void FLevelCollectionModel::AssignParent(const FLevelModelList& InLevels, TSharedPtr<FLevelModel> InParent)
{
// Attach levels to the new parent
for (auto It = InLevels.CreateConstIterator(); It; ++It)
{
(*It)->AttachTo(InParent);
}
OnLevelsHierarchyChanged();
}
void FLevelCollectionModel::AddExistingLevelsFromAssetData(const TArray<FAssetData>& WorldList)
{
}
TSharedPtr<FLevelDragDropOp> FLevelCollectionModel::CreateDragDropOp() const
{
return TSharedPtr<FLevelDragDropOp>();
}
bool FLevelCollectionModel::PassesAllFilters(const FLevelModel& Item) const
{
if (Item.IsPersistent() || Filters->PassesAllFilters(&Item))
{
return true;
}
return false;
}
void FLevelCollectionModel::BuildHierarchyMenu(FMenuBuilder& InMenuBuilder) const
{
}
void FLevelCollectionModel::CustomizeFileMainMenu(FMenuBuilder& InMenuBuilder) const
{
const FLevelCollectionCommands& Commands = FLevelCollectionCommands::Get();
// Cache SCC state
CacheCanExecuteSourceControlVars();
InMenuBuilder.AddSubMenu(
LOCTEXT("SourceControl", "Source Control"),
LOCTEXT("SourceControl_ToolTip", "Source Control Options"),
FNewMenuDelegate::CreateSP(this, &FLevelCollectionModel::FillSourceControlSubMenu));
if (AreAnyLevelsSelected())
{
InMenuBuilder.AddMenuEntry( Commands.World_SaveSelectedLevels );
InMenuBuilder.AddMenuEntry( Commands.World_SaveSelectedLevelAs );
InMenuBuilder.AddMenuEntry( Commands.World_MigrateSelectedLevels );
}
}
bool FLevelCollectionModel::GetPlayerView(FVector& Location, FRotator& Rotation) const
{
return false;
}
bool FLevelCollectionModel::GetObserverView(FVector& Location, FRotator& Rotation) const
{
return false;
}
bool FLevelCollectionModel::CompareLevelsZOrder(TSharedPtr<FLevelModel> InA, TSharedPtr<FLevelModel> InB) const
{
return false;
}
void FLevelCollectionModel::RegisterDetailsCustomization(FPropertyEditorModule& InPropertyModule,
TSharedPtr<IDetailsView> InDetailsView)
{
}
void FLevelCollectionModel::UnregisterDetailsCustomization(FPropertyEditorModule& InPropertyModule,
TSharedPtr<IDetailsView> InDetailsView)
{
}
void FLevelCollectionModel::RequestUpdateAllLevels()
{
bRequestedUpdateAllLevels = true;
}
void FLevelCollectionModel::RequestRedrawAllLevels()
{
bRequestedRedrawAllLevels = true;
}
void FLevelCollectionModel::UpdateAllLevels()
{
bRequestedUpdateAllLevels = false;
for (auto It = AllLevelsList.CreateConstIterator(); It; ++It)
{
(*It)->Update();
}
// Update world size
FBox WorldBounds = GetLevelsBoundingBox(AllLevelsList, false);
WorldSize.X = FMath::RoundToInt(WorldBounds.GetSize().X);
WorldSize.Y = FMath::RoundToInt(WorldBounds.GetSize().Y);
}
void FLevelCollectionModel::RedrawAllLevels()
{
bRequestedRedrawAllLevels = false;
for (auto It = AllLevelsList.CreateConstIterator(); It; ++It)
{
(*It)->UpdateVisuals();
}
}
void FLevelCollectionModel::UpdateLevelActorsCount()
{
for( auto It = AllLevelsList.CreateIterator(); It; ++It )
{
(*It)->UpdateLevelActorsCount();
}
bRequestedUpdateActorsCount = false;
}
bool FLevelCollectionModel::IsOneLevelSelected() const
{
return SelectedLevelsList.Num() == 1;
}
bool FLevelCollectionModel::AreAnyLevelsSelected() const
{
return SelectedLevelsList.Num() > 0;
}
bool FLevelCollectionModel::AreAllSelectedLevelsLoaded() const
{
for (int32 LevelIdx = 0; LevelIdx < SelectedLevelsList.Num(); LevelIdx++)
{
if (SelectedLevelsList[LevelIdx]->IsLoaded() == false)
{
return false;
}
}
return AreAnyLevelsSelected();
}
bool FLevelCollectionModel::AreAnySelectedLevelsLoaded() const
{
return !AreAllSelectedLevelsUnloaded();
}
bool FLevelCollectionModel::AreAllSelectedLevelsUnloaded() const
{
for (int32 LevelIdx = 0; LevelIdx < SelectedLevelsList.Num(); LevelIdx++)
{
if (SelectedLevelsList[LevelIdx]->IsLoaded() == true)
{
return false;
}
}
return true;
}
bool FLevelCollectionModel::AreAnySelectedLevelsUnloaded() const
{
return !AreAllSelectedLevelsLoaded();
}
bool FLevelCollectionModel::AreAllSelectedLevelsEditable() const
{
for (auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
if ((*It)->IsEditable() == false)
{
return false;
}
}
return AreAnyLevelsSelected();
}
bool FLevelCollectionModel::AreAllSelectedLevelsEditableAndNotPersistent() const
{
for (auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
if ((*It)->IsEditable() == false || (*It)->IsPersistent())
{
return false;
}
}
return AreAnyLevelsSelected();
}
bool FLevelCollectionModel::AreAllSelectedLevelsEditableAndVisible() const
{
for (auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
if ((*It)->IsEditable() == false ||
(*It)->IsVisible() == false)
{
return false;
}
}
return AreAnyLevelsSelected();
}
bool FLevelCollectionModel::AreAnySelectedLevelsEditable() const
{
for (auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
if ((*It)->IsEditable() == true)
{
return true;
}
}
return false;
}
bool FLevelCollectionModel::AreAnySelectedLevelsEditableAndVisible() const
{
for (auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
if ((*It)->IsEditable() == true &&
(*It)->IsVisible() == true)
{
return true;
}
}
return false;
}
bool FLevelCollectionModel::IsSelectedLevelEditable() const
{
if (SelectedLevelsList.Num() == 1)
{
return SelectedLevelsList[0]->IsEditable();
}
return false;
}
bool FLevelCollectionModel::IsNewLightingScenarioState(bool bExistingState) const
{
if (SelectedLevelsList.Num() == 1)
{
return SelectedLevelsList[0]->IsLightingScenario() != bExistingState;
}
return false;
}
void FLevelCollectionModel::SetIsLightingScenario(bool bNewLightingScenario)
{
if (SelectedLevelsList.Num() == 1)
{
SelectedLevelsList[0]->SetIsLightingScenario(bNewLightingScenario);
}
}
bool FLevelCollectionModel::AreAnySelectedLevelsDirty() const
{
for (auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
if ((*It)->IsLoaded() == true && (*It)->IsDirty() == true)
{
return true;
}
}
return false;
}
bool FLevelCollectionModel::AreActorsSelected() const
{
return GEditor->GetSelectedActorCount() > 0;
}
bool FLevelCollectionModel::GetDisplayPathsState() const
{
return bDisplayPaths;
}
void FLevelCollectionModel::SetDisplayPathsState(bool InDisplayPaths)
{
bDisplayPaths = InDisplayPaths;
for (auto It = AllLevelsList.CreateIterator(); It; ++It)
{
(*It)->UpdateDisplayName();
}
}
bool FLevelCollectionModel::GetDisplayActorsCountState() const
{
return bDisplayActorsCount;
}
void FLevelCollectionModel::SetDisplayActorsCountState(bool InDisplayActorsCount)
{
bDisplayActorsCount = InDisplayActorsCount;
for (auto It = AllLevelsList.CreateIterator(); It; ++It)
{
(*It)->UpdateDisplayName();
}
}
void FLevelCollectionModel::BroadcastSelectionChanged()
{
SelectionChanged.Broadcast();
}
void FLevelCollectionModel::BroadcastCollectionChanged()
{
CollectionChanged.Broadcast();
}
void FLevelCollectionModel::BroadcastHierarchyChanged()
{
HierarchyChanged.Broadcast();
}
float FLevelCollectionModel::EditableAxisLength()
{
return HALF_WORLD_MAX;
};
FBox FLevelCollectionModel::EditableWorldArea()
{
float AxisLength = EditableAxisLength();
return FBox(
FVector(-AxisLength, -AxisLength, -AxisLength),
FVector(+AxisLength, +AxisLength, +AxisLength)
);
}
void FLevelCollectionModel::SCCCheckOut(const FLevelModelList& InList)
{
TArray<FString> FilenamesToCheckOut = GetFilenamesList(InList);
// Update the source control status of all potentially relevant packages
ISourceControlModule::Get().GetProvider().Execute(
ISourceControlOperation::Create<FUpdateStatus>(), FilenamesToCheckOut
);
// Now check them out
FEditorFileUtils::CheckoutPackages(FilenamesToCheckOut);
}
void FLevelCollectionModel::SCCCheckIn(const FLevelModelList& InList)
{
TArray<UPackage*> PackagesToCheckIn = GetPackagesList(InList);
TArray<FString> FilenamesToCheckIn = GetFilenamesList(InList);
// Prompt the user to ask if they would like to first save any dirty packages they are trying to check-in
const auto UserResponse = FEditorFileUtils::PromptForCheckoutAndSave(PackagesToCheckIn, true, true);
// If the user elected to save dirty packages, but one or more of the packages failed to save properly OR if the user
// canceled out of the prompt, don't follow through on the check-in process
const bool bShouldProceed = UserResponse == FEditorFileUtils::EPromptReturnCode::PR_Success ||
UserResponse == FEditorFileUtils::EPromptReturnCode::PR_Declined;
if (bShouldProceed)
{
const bool bUseSourceControlStateCache = false;
FSourceControlWindows::PromptForCheckin(bUseSourceControlStateCache, FilenamesToCheckIn);
}
else
{
// If a failure occurred, alert the user that the check-in was aborted. This warning shouldn't be necessary if the user cancelled
// from the dialog, because they obviously intended to cancel the whole operation.
if (UserResponse == FEditorFileUtils::EPromptReturnCode::PR_Failure)
{
FMessageDialog::Open(EAppMsgType::Ok,
NSLOCTEXT("UnrealEd", "SCC_Checkin_Aborted", "Check-in aborted as a result of save failure.")
);
}
}
}
void FLevelCollectionModel::SCCOpenForAdd(const FLevelModelList& InList)
{
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
TArray<FString> FilenamesList = GetFilenamesList(InList);
TArray<FString> FilenamesToAdd;
TArray<UPackage*> PackagesToSave;
for (auto It = FilenamesList.CreateConstIterator(); It; ++It)
{
const FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(*It, EStateCacheUsage::Use);
if (SourceControlState.IsValid() && !SourceControlState->IsSourceControlled())
{
FilenamesToAdd.Add(*It);
// Make sure the file actually exists on disk before adding it
FString LongPackageName = FPackageName::FilenameToLongPackageName(*It);
if (!FPackageName::DoesPackageExist(LongPackageName))
{
UPackage* Package = FindPackage(NULL, *LongPackageName);
if (Package)
{
PackagesToSave.Add(Package);
}
}
}
}
if (FilenamesToAdd.Num() > 0)
{
// If any of the packages are new, save them now
if (PackagesToSave.Num() > 0)
{
const bool bCheckDirty = false;
const bool bPromptToSave = false;
const auto Return = FEditorFileUtils::PromptForCheckoutAndSave(PackagesToSave, bCheckDirty, bPromptToSave);
}
SourceControlProvider.Execute(ISourceControlOperation::Create<FMarkForAdd>(), FilenamesToAdd);
}
}
void FLevelCollectionModel::SCCHistory(const FLevelModelList& InList)
{
// This is odd, why SCC needs package names, instead of filenames?
TArray<FString> PackageNames;
for (auto It = InList.CreateConstIterator(); It; ++It)
{
if ((*It)->HasValidPackage())
{
PackageNames.Add((*It)->GetLongPackageName().ToString());
}
}
FSourceControlWindows::DisplayRevisionHistory(PackageNames);
}
void FLevelCollectionModel::SCCRefresh(const FLevelModelList& InList)
{
if(ISourceControlModule::Get().IsEnabled())
{
ISourceControlModule::Get().QueueStatusUpdate(GetFilenamesList(InList));
}
}
void FLevelCollectionModel::SCCDiffAgainstDepot(const FLevelModelList& InList, UEditorEngine* InEditor)
{
// Load the asset registry module
FAssetToolsModule& AssetToolsModule = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools");
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
// Iterate over each selected asset
for (auto It = InList.CreateConstIterator(); It; ++It)
{
ULevel* Level = (*It)->GetLevelObject();
if (Level == NULL)
{
return;
}
UPackage* OriginalPackage = Level->GetOutermost();
FString PackageName = OriginalPackage->GetName();
// Make sure our history is up to date
auto UpdateStatusOperation = ISourceControlOperation::Create<FUpdateStatus>();
UpdateStatusOperation->SetUpdateHistory(true);
SourceControlProvider.Execute(UpdateStatusOperation, OriginalPackage);
// Get the SCC state
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(
OriginalPackage, EStateCacheUsage::Use
);
// If the level is in SCC.
if (SourceControlState.IsValid() && SourceControlState->IsSourceControlled())
{
// Get the file name of package
FString RelativeFileName;
if(FPackageName::DoesPackageExist(PackageName, NULL, &RelativeFileName))
{
if (SourceControlState->GetHistorySize() > 0)
{
auto Revision = SourceControlState->GetHistoryItem(0);
check(Revision.IsValid());
// Get the head revision of this package from source control
FString AbsoluteFileName = FPaths::ConvertRelativePathToFull(RelativeFileName);
FString TempFileName;
if (Revision->Get(TempFileName))
{
// Forcibly disable compile on load in case we are loading old blueprints that might try to update/compile
TGuardValue<bool> DisableCompileOnLoad(GForceDisableBlueprintCompileOnLoad, true);
// Try and load that package
FText NotMapReason;
UPackage* OldPackage = LoadPackage(NULL, *TempFileName, LOAD_None);
if(OldPackage != NULL && InEditor->PackageIsAMapFile(*TempFileName, NotMapReason))
{
/* Set the revision information*/
UPackage* Package = OriginalPackage;
FRevisionInfo OldRevision;
OldRevision.Changelist = Revision->GetCheckInIdentifier();
OldRevision.Date = Revision->GetDate();
OldRevision.Revision = Revision->GetRevision();
FRevisionInfo NewRevision;
NewRevision.Revision = TEXT("");
// Dump assets to temp text files
FString OldTextFilename = AssetToolsModule.Get().DumpAssetToTempFile(OldPackage);
FString NewTextFilename = AssetToolsModule.Get().DumpAssetToTempFile(OriginalPackage);
FString DiffCommand = GetDefault<UEditorLoadingSavingSettings>()->TextDiffToolPath.FilePath;
AssetToolsModule.Get().CreateDiffProcess(DiffCommand, OldTextFilename, NewTextFilename);
AssetToolsModule.Get().DiffAssets(OldPackage, OriginalPackage, OldRevision, NewRevision);
}
}
}
}
}
}
}
TArray<FName> FLevelCollectionModel::GetPackageNamesList(const FLevelModelList& InList)
{
TArray<FName> ResultList;
for (auto It = InList.CreateConstIterator(); It; ++It)
{
if ((*It)->HasValidPackage())
{
ResultList.Add((*It)->GetLongPackageName());
}
}
return ResultList;
}
TArray<FString> FLevelCollectionModel::GetFilenamesList(const FLevelModelList& InList)
{
TArray<FString> ResultList;
for (auto It = InList.CreateConstIterator(); It; ++It)
{
if ((*It)->HasValidPackage())
{
ResultList.Add((*It)->GetPackageFileName());
}
}
return ResultList;
}
TArray<UPackage*> FLevelCollectionModel::GetPackagesList(const FLevelModelList& InList)
{
TArray<UPackage*> ResultList;
for (auto It = InList.CreateConstIterator(); It; ++It)
{
ULevel* Level = (*It)->GetLevelObject();
if (Level)
{
ResultList.Add(Level->GetOutermost());
}
}
return ResultList;
}
TArray<ULevel*> FLevelCollectionModel::GetLevelObjectList(const FLevelModelList& InList)
{
TArray<ULevel*> ResultList;
for (auto It = InList.CreateConstIterator(); It; ++It)
{
ULevel* Level = (*It)->GetLevelObject();
if (Level)
{
ResultList.Add(Level);
}
}
return ResultList;
}
FLevelModelList FLevelCollectionModel::GetLoadedLevels(const FLevelModelList& InList)
{
FLevelModelList ResultList;
for (auto It = InList.CreateConstIterator(); It; ++It)
{
if ((*It)->IsLoaded())
{
ResultList.Add(*It);
}
}
return ResultList;
}
FLevelModelList FLevelCollectionModel::GetLevelsHierarchy(const FLevelModelList& InList)
{
struct FHierarchyCollector : public FLevelModelVisitor
{
virtual void Visit(FLevelModel& Item) override
{
ResultList.AddUnique(Item.AsShared());
}
FLevelModelList ResultList;
};
FHierarchyCollector HierarchyCollector;
for (auto It = InList.CreateConstIterator(); It; ++It)
{
(*It)->Accept(HierarchyCollector);
}
return HierarchyCollector.ResultList;
}
FBox FLevelCollectionModel::GetLevelsBoundingBox(const FLevelModelList& InList, bool bIncludeChildren)
{
FBox TotalBounds(ForceInit);
for (auto It = InList.CreateConstIterator(); It; ++It)
{
if (bIncludeChildren)
{
TotalBounds+= GetVisibleLevelsBoundingBox((*It)->GetChildren(), bIncludeChildren);
}
TotalBounds+= (*It)->GetLevelBounds();
}
return TotalBounds;
}
FBox FLevelCollectionModel::GetVisibleLevelsBoundingBox(const FLevelModelList& InList, bool bIncludeChildren)
{
FBox TotalBounds(ForceInit);
for (auto It = InList.CreateConstIterator(); It; ++It)
{
if (bIncludeChildren)
{
TotalBounds+= GetVisibleLevelsBoundingBox((*It)->GetChildren(), bIncludeChildren);
}
if ((*It)->IsVisible())
{
TotalBounds+= (*It)->GetLevelBounds();
}
}
return TotalBounds;
}
const TSharedRef<const FUICommandList> FLevelCollectionModel::GetCommandList() const
{
return CommandList;
}
const FString ConfigIniSection = TEXT("WorldBrowser");
void FLevelCollectionModel::LoadSettings()
{
// Display paths
bool bDisplayPathsSetting = false;
GConfig->GetBool(*ConfigIniSection, TEXT("DisplayPaths"), bDisplayPathsSetting, GEditorPerProjectIni);
SetDisplayPathsState(bDisplayPathsSetting);
// Display actors count
bool bDisplayActorsCountSetting = false;
GConfig->GetBool(*ConfigIniSection, TEXT("DisplayActorsCount"), bDisplayActorsCountSetting, GEditorPerProjectIni);
SetDisplayActorsCountState(bDisplayActorsCountSetting);
}
void FLevelCollectionModel::SaveSettings()
{
// Display paths
GConfig->SetBool(*ConfigIniSection, TEXT("DisplayPaths"), GetDisplayPathsState(), GEditorPerProjectIni);
// Display actors count
GConfig->SetBool(*ConfigIniSection, TEXT("DisplayActorsCount"), GetDisplayActorsCountState(), GEditorPerProjectIni);
}
void FLevelCollectionModel::RefreshBrowser_Executed()
{
PopulateLevelsList();
}
void FLevelCollectionModel::LoadSelectedLevels_Executed()
{
LoadLevels(GetSelectedLevels());
}
void FLevelCollectionModel::UnloadSelectedLevels_Executed()
{
UnloadLevels(GetSelectedLevels());
}
void FLevelCollectionModel::OnSCCCheckOut()
{
SCCCheckOut(GetSelectedLevels());
}
void FLevelCollectionModel::OnSCCCheckIn()
{
SCCCheckIn(GetSelectedLevels());
}
void FLevelCollectionModel::OnSCCOpenForAdd()
{
SCCOpenForAdd(GetSelectedLevels());
}
void FLevelCollectionModel::OnSCCHistory()
{
SCCHistory(GetSelectedLevels());
}
void FLevelCollectionModel::OnSCCRefresh()
{
SCCRefresh(GetSelectedLevels());
}
void FLevelCollectionModel::OnSCCDiffAgainstDepot()
{
SCCDiffAgainstDepot(GetSelectedLevels(), GEditor);
}
void FLevelCollectionModel::OnSCCConnect() const
{
ISourceControlModule::Get().ShowLoginDialog(FSourceControlLoginClosed(), ELoginWindowMode::Modeless);
}
void FLevelCollectionModel::SaveSelectedLevels_Executed()
{
SaveLevels(GetSelectedLevels());
}
void FLevelCollectionModel::SaveSelectedLevelAs_Executed()
{
if (SelectedLevelsList.Num() > 0)
{
ULevel* Level = SelectedLevelsList[0]->GetLevelObject();
if (Level)
{
FEditorFileUtils::SaveLevelAs(Level);
}
}
}
void FLevelCollectionModel::MigrateSelectedLevels_Executed()
{
// Gather the package names for the levels
TArray<FName> PackageNames = GetPackageNamesList(GetSelectedLevels());
FAssetToolsModule& AssetToolsModule = FModuleManager::Get().LoadModuleChecked<FAssetToolsModule>("AssetTools");
AssetToolsModule.Get().MigratePackages(PackageNames);
}
void FLevelCollectionModel::SelectAllLevels_Executed()
{
SetSelectedLevels(FilteredLevelsList);
}
void FLevelCollectionModel::DeselectAllLevels_Executed()
{
FLevelModelList NoLevels;
SetSelectedLevels(NoLevels);
}
void FLevelCollectionModel::InvertSelection_Executed()
{
FLevelModelList InvertedLevels;
for (auto It = FilteredLevelsList.CreateIterator(); It; ++It)
{
if (!SelectedLevelsList.Contains(*It))
{
InvertedLevels.Add(*It);
}
}
SetSelectedLevels(InvertedLevels);
}
void FLevelCollectionModel::ShowSelectedLevels_Executed()
{
ShowLevels(GetSelectedLevels());
}
void FLevelCollectionModel::HideSelectedLevels_Executed()
{
HideLevels(GetSelectedLevels());
}
void FLevelCollectionModel::ShowOnlySelectedLevels_Executed()
{
//stash off a copy of the original array, as setting visibility can destroy the selection
FLevelModelList SelectedLevelsCopy = GetSelectedLevels();
InvertSelection_Executed();
HideSelectedLevels_Executed();
SetSelectedLevels(SelectedLevelsCopy);
ShowSelectedLevels_Executed();
}
void FLevelCollectionModel::ShowAllLevels_Executed()
{
ShowLevels(GetFilteredLevels());
}
void FLevelCollectionModel::HideAllLevels_Executed()
{
HideLevels(GetFilteredLevels());
}
void FLevelCollectionModel::LockSelectedLevels_Executed()
{
LockLevels(GetSelectedLevels());
}
void FLevelCollectionModel::UnlockSelectedLevels_Executed()
{
UnlockLevels(GetSelectedLevels());
}
void FLevelCollectionModel::LockAllLevels_Executed()
{
if (!IsReadOnly())
{
const FScopedTransaction Transaction(LOCTEXT("LockAllLevels", "Lock All Levels"));
LockLevels(GetFilteredLevels());
}
}
void FLevelCollectionModel::UnockAllLevels_Executed()
{
if (!IsReadOnly())
{
const FScopedTransaction Transaction(LOCTEXT("UnlockAllLevels", "Unlock All Levels"));
UnlockLevels(GetFilteredLevels());
}
}
void FLevelCollectionModel::ToggleReadOnlyLevels_Executed()
{
//We are about to lock some Levels, deselect all actor and surfaces from the read only levels
if (!GEditor->bLockReadOnlyLevels)
{
DeselectActorsInAllReadOnlyLevel(GetAllLevels());
DeselectSurfaceInAllReadOnlyLevel(GetAllLevels());
// Tell the editor selection status was changed.
GEditor->NoteSelectionChange();
}
GEditor->bLockReadOnlyLevels = !GEditor->bLockReadOnlyLevels;
}
void FLevelCollectionModel::MakeLevelCurrent_Executed()
{
check( SelectedLevelsList.Num() == 1 );
SelectedLevelsList[0]->MakeLevelCurrent();
}
void FLevelCollectionModel::FindInContentBrowser_Executed()
{
TArray<UObject*> Objects;
for (auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
ULevel* Level = (*It)->GetLevelObject();
if (Level)
{
UObject* LevelOuter = Level->GetOuter();
if (LevelOuter)
{
// Search for the level's outer (the UWorld) as this is the actual asset shown by the content browser
Objects.AddUnique(LevelOuter);
}
}
}
GEditor->SyncBrowserToObjects(Objects);
}
bool FLevelCollectionModel::IsValidFindInContentBrowser()
{
return true;
}
void FLevelCollectionModel::MoveActorsToSelected_Executed()
{
// If matinee is open, and if an actor being moved belongs to it, message the user
if (GLevelEditorModeTools().IsModeActive(FBuiltinEditorModes::EM_InterpEdit))
{
const FEdModeInterpEdit* InterpEditMode = (const FEdModeInterpEdit*)GLevelEditorModeTools().GetActiveMode(FBuiltinEditorModes::EM_InterpEdit);
if (InterpEditMode && InterpEditMode->MatineeActor)
{
TArray<AActor*> ControlledActors;
InterpEditMode->MatineeActor->GetControlledActors(ControlledActors);
// are any of the selected actors in the matinee
USelection* SelectedActors = GEditor->GetSelectedActors();
for (FSelectionIterator Iter(*SelectedActors); Iter; ++Iter)
{
AActor* Actor = CastChecked<AActor>(*Iter);
if (Actor != nullptr && (Actor == InterpEditMode->MatineeActor || ControlledActors.Contains(Actor)))
{
const bool ExitInterp = EAppReturnType::Yes == FMessageDialog::Open(EAppMsgType::YesNo, NSLOCTEXT("UnrealEd", "MatineeUnableToMove", "You must close Matinee before moving actors.\nDo you wish to do this now and continue?"));
if (!ExitInterp)
{
return;
}
GLevelEditorModeTools().DeactivateMode(FBuiltinEditorModes::EM_InterpEdit);
break;
}
}
}
}
MakeLevelCurrent_Executed();
const FScopedTransaction Transaction( LOCTEXT("MoveSelectedActorsToSelectedLevel", "Move Selected Actors to Level") );
GEditor->MoveSelectedActorsToLevel(GetWorld()->GetCurrentLevel());
RequestUpdateAllLevels();
}
void FLevelCollectionModel::MoveFoliageToSelected_Executed()
{
if (GetSelectedLevels().Num() == 1)
{
ULevel* TargetLevel = GetSelectedLevels()[0]->GetLevelObject();
GEditor->MoveSelectedFoliageToLevel(TargetLevel);
}
}
void FLevelCollectionModel::SelectActors_Executed()
{
//first clear any existing actor selection
const FScopedTransaction Transaction( LOCTEXT("SelectActors", "Select Actors in Level") );
GEditor->GetSelectedActors()->Modify();
GEditor->SelectNone( false, true );
for(auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
(*It)->SelectActors(/*bSelect*/ true, /*bNotify*/ true, /*bSelectEvenIfHidden*/ true);
}
}
void FLevelCollectionModel::DeselectActors_Executed()
{
const FScopedTransaction Transaction( LOCTEXT("DeselectActors", "Deselect Actors in Level") );
for(auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
(*It)->SelectActors(/*bSelect*/ false, /*bNotify*/ true, /*bSelectEvenIfHidden*/ true);
}
}
void FLevelCollectionModel::ExpandSelectedItems_Executed()
{
struct FExpandLevelVisitor : public FLevelModelVisitor
{
virtual void Visit(FLevelModel& Item) override { Item.SetLevelExpansionFlag(true); }
} Expander;
for (TSharedPtr<FLevelModel> LevelModel: SelectedLevelsList)
{
LevelModel->Accept(Expander);
}
BroadcastHierarchyChanged();
}
void FLevelCollectionModel::FillLockSubMenu(FMenuBuilder& InMenuBuilder)
{
const FLevelCollectionCommands& Commands = FLevelCollectionCommands::Get();
InMenuBuilder.AddMenuEntry( Commands.World_LockSelectedLevels );
InMenuBuilder.AddMenuEntry( Commands.World_UnockSelectedLevels );
InMenuBuilder.AddMenuEntry( Commands.World_LockAllLevels );
InMenuBuilder.AddMenuEntry( Commands.World_UnockAllLevels );
if (GEditor->bLockReadOnlyLevels)
{
InMenuBuilder.AddMenuEntry( Commands.World_UnlockReadOnlyLevels );
}
else
{
InMenuBuilder.AddMenuEntry( Commands.World_LockReadOnlyLevels );
}
}
void FLevelCollectionModel::FillVisibilitySubMenu(FMenuBuilder& InMenuBuilder)
{
const FLevelCollectionCommands& Commands = FLevelCollectionCommands::Get();
InMenuBuilder.AddMenuEntry( Commands.World_ShowSelectedLevels );
InMenuBuilder.AddMenuEntry( Commands.World_HideSelectedLevels );
InMenuBuilder.AddMenuEntry( Commands.World_ShowOnlySelectedLevels );
InMenuBuilder.AddMenuEntry( Commands.World_ShowAllLevels );
InMenuBuilder.AddMenuEntry( Commands.World_HideAllLevels );
}
void FLevelCollectionModel::FillSourceControlSubMenu(FMenuBuilder& InMenuBuilder)
{
const FLevelCollectionCommands& Commands = FLevelCollectionCommands::Get();
if (CanExecuteSCC())
{
if (CanExecuteSCCCheckOut())
{
InMenuBuilder.AddMenuEntry( Commands.SCCCheckOut );
}
if (CanExecuteSCCOpenForAdd())
{
InMenuBuilder.AddMenuEntry( Commands.SCCOpenForAdd );
}
if (CanExecuteSCCCheckIn())
{
InMenuBuilder.AddMenuEntry( Commands.SCCCheckIn );
}
InMenuBuilder.AddMenuEntry( Commands.SCCRefresh );
InMenuBuilder.AddMenuEntry( Commands.SCCHistory );
InMenuBuilder.AddMenuEntry( Commands.SCCDiffAgainstDepot );
}
else
{
InMenuBuilder.AddMenuEntry( Commands.SCCConnect );
}
}
void FLevelCollectionModel::DeselectActorsInAllReadOnlyLevel(const FLevelModelList& InLevelList)
{
const FScopedTransaction Transaction(LOCTEXT("DeselectActorsInReadOnlyLevel", "Deselect Actors in all read only Level"));
for (auto It = InLevelList.CreateConstIterator(); It; ++It)
{
if ((*It)->IsFileReadOnly())
{
(*It)->SelectActors(/*bSelect*/ false, /*bNotify*/ true, /*bSelectEvenIfHidden*/ true);
}
}
}
void FLevelCollectionModel::DeselectSurfaceInAllReadOnlyLevel(const FLevelModelList& InLevelList)
{
const FScopedTransaction Transaction(LOCTEXT("DeselectSurfacesInReadOnlyLevel", "Deselect Surfaces in all read only Level"));
for (auto It = InLevelList.CreateConstIterator(); It; ++It)
{
if ((*It)->IsFileReadOnly())
{
(*It)->DeselectAllSurfaces();
}
}
}
void FLevelCollectionModel::OnLevelsCollectionChanged()
{
UpdateAllLevels();
PopulateFilteredLevelsList();
BroadcastCollectionChanged();
}
void FLevelCollectionModel::OnLevelsSelectionChanged()
{
if (bUpdatingLevelsSelection)
{
return;
}
TGuardValue<bool> UpdateGuard(bUpdatingLevelsSelection, true);
// Pass the list we just created to the world to set the selection
CurrentWorld->SetSelectedLevels(
GetLevelObjectList(SelectedLevelsList)
);
// Request SC status update for selected levels
ISourceControlModule::Get().QueueStatusUpdate(
GetFilenamesList(SelectedLevelsList)
);
// Expand hierarchy to selected levels
for (auto It = SelectedLevelsList.CreateIterator(); It; ++It)
{
TSharedPtr<FLevelModel> ParentLevelModel = (*It)->GetParent();
while (ParentLevelModel.IsValid())
{
ParentLevelModel->SetLevelExpansionFlag(true);
ParentLevelModel = ParentLevelModel->GetParent();
}
}
BroadcastSelectionChanged();
}
void FLevelCollectionModel::OnLevelsSelectionChangedOutside()
{
if (!bUpdatingLevelsSelection)
{
SetSelectedLevelsFromWorld();
}
}
void FLevelCollectionModel::OnLevelsHierarchyChanged()
{
BroadcastHierarchyChanged();
}
void FLevelCollectionModel::OnLevelAddedToWorld(ULevel* InLevel, UWorld* InWorld)
{
if (InWorld == GetWorld())
{
TSharedPtr<FLevelModel> LevelModel = FindLevelModel(InLevel->GetOutermost()->GetFName());
if (LevelModel.IsValid())
{
LevelModel->OnLevelAddedToWorld(InLevel);
}
}
}
void FLevelCollectionModel::OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld)
{
if (InWorld == GetWorld())
{
TSharedPtr<FLevelModel> LevelModel = FindLevelModel(InLevel->GetOutermost()->GetFName());
if (LevelModel.IsValid())
{
LevelModel->OnLevelRemovedFromWorld();
}
}
}
void FLevelCollectionModel::OnRedrawAllViewports()
{
if (GShaderCompilingManager && GShaderCompilingManager->IsCompiling())
{
// Editor seems like still compiling shaders, do not request tiles redraw until all shaders complation is finished
// Basically redraw only on last event
return;
}
RequestRedrawAllLevels();
}
void FLevelCollectionModel::OnLevelActorAdded(AActor* InActor)
{
if (InActor &&
InActor->GetWorld() == CurrentWorld.Get()) // we care about our world only
{
bRequestedUpdateActorsCount = true;
}
}
void FLevelCollectionModel::OnLevelActorDeleted(AActor* InActor)
{
bRequestedUpdateActorsCount = true;
}
void FLevelCollectionModel::OnFilterChanged()
{
PopulateFilteredLevelsList();
BroadcastCollectionChanged();
}
void FLevelCollectionModel::CacheCanExecuteSourceControlVars() const
{
bCanExecuteSCCCheckOut = false;
bCanExecuteSCCOpenForAdd = false;
bCanExecuteSCCCheckIn = false;
bCanExecuteSCC = false;
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
for (auto It = SelectedLevelsList.CreateConstIterator(); It; ++It)
{
if (ISourceControlModule::Get().IsEnabled() && SourceControlProvider.IsAvailable())
{
bCanExecuteSCC = true;
ULevel* Level = (*It)->GetLevelObject();
if (Level)
{
// Check the SCC state for each package in the selected paths
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(Level->GetOutermost(), EStateCacheUsage::Use);
if (SourceControlState.IsValid())
{
if (SourceControlState->CanCheckout())
{
bCanExecuteSCCCheckOut = true;
}
else if (!SourceControlState->IsSourceControlled())
{
bCanExecuteSCCOpenForAdd = true;
}
else if (SourceControlState->IsCheckedOut() || SourceControlState->IsAdded())
{
bCanExecuteSCCCheckIn = true;
}
}
}
}
if (bCanExecuteSCCCheckOut &&
bCanExecuteSCCOpenForAdd &&
bCanExecuteSCCCheckIn)
{
// All options are available, no need to keep iterating
break;
}
}
}
bool FLevelCollectionModel::IsValidMoveActorsToLevel() const
{
static bool bCachedIsValidActorMoveResult = false;
if (bSelectionHasChanged)
{
bSelectionHasChanged = false;
bCachedIsValidActorMoveResult = false;
// We can only operate on a single selected level
if ( SelectedLevelsList.Num() == 1 )
{
ULevel* Level = SelectedLevelsList[0]->GetLevelObject();
if (Level)
{
// Allow the move if at least one actor is in another level
USelection* SelectedActors = GEditor->GetSelectedActors();
for (FSelectionIterator Iter(*SelectedActors); Iter; ++Iter)
{
AActor* Actor = CastChecked<AActor>(*Iter);
if (Actor != nullptr)
{
if (Actor->GetLevel() != Level)
{
bCachedIsValidActorMoveResult = true;
break;
}
}
}
}
}
}
// if non of the selected actors are in the level, just check the level is unlocked
return bCachedIsValidActorMoveResult && AreAllSelectedLevelsEditableAndVisible();
}
bool FLevelCollectionModel::IsValidMoveFoliageToLevel() const
{
if (IsOneLevelSelected() &&
AreAllSelectedLevelsEditableAndVisible() &&
GLevelEditorModeTools().IsModeActive(FBuiltinEditorModes::EM_Foliage))
{
return true;
}
return false;
}
void FLevelCollectionModel::OnActorSelectionChanged(UObject* obj)
{
OnActorOrLevelSelectionChanged();
}
void FLevelCollectionModel::OnActorOrLevelSelectionChanged()
{
bSelectionHasChanged = true;
}
#undef LOCTEXT_NAMESPACE