Files
UnrealEngineUWP/Engine/Source/Editor/LevelEditor/Private/LevelEditorToolBar.cpp
Dan Oconnor e29126385f Copying //UE4/Dev-Framework to //UE4/Dev-Main (Source: //UE4/Dev-Framework @ 3380068)
#lockdown Nick.Penwarden

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

Change 3358702 on 2017/03/22 by Marc.Audy

	Always mark child actors pending kill when in PostLoad as often the World is too early to have a WorldContext which causes issues in DestroyActor
	#jira UE-42679

Change 3358737 on 2017/03/22 by Mieszko.Zielinski

	Exposed UBrainComponent::IsRunning() and UBrainComponent::IsPaused() to Blueprint #UE4

Change 3359062 on 2017/03/22 by Michael.Noland

	Blueprints: Show the Save and Find in CB buttons when working with level script blueprints (they will save/show the map package)

	#jira UE-30748

Change 3359066 on 2017/03/22 by Michael.Noland

	PR #3348: Make fields of FAttributeMetaData editable (Contributed by hoelzl)

	#jira UE-42620

Change 3359069 on 2017/03/22 by Michael.Noland

	PR #3288: InverseLerp Blueprint Tooltips Clarification (Contributed by wunawuna)

	#jira UE-42250

Change 3359108 on 2017/03/22 by Michael.Noland

	Blueprints: Fix an issue where running the editor in a different culture could break pins on nodes that have optional arrays of pins (e.g., animation graph nodes like blend by layer)
	#jira UE-36232

Change 3359235 on 2017/03/22 by Marc.Audy

	Expose bShouldPerformFullTickWhenPaused to blueprints and details panel
	#jira UE-17286

Change 3359324 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Disable collision on NavModifierVolumes. Previously they had an OverlapAll response and generated overlap events. They are only supposed to be used for preventing nav mesh generation, but overlap events could affect gameplay, and also are bad for performance.

	(Integrate CL 3249525 from Odin).

Change 3359326 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Optimization during attachment to check bool before expensive casts and body instance fetching.

	(Integrate CL 3261262 from Odin).

Change 3359327 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Make bSkipAgentHeightCheckWhenPickingNavData actually ignore height when picking data.

	(Integrate CL 3231908 from Odin)

Change 3359328 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Make a static FName in UMovementComponent::OverlapTest const and move it to a namespace.

	(Integrate CL 3259985 from Odin)

Change 3359329 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Fix ProjectileMovementComponent continuing to simulate (and generate hit events) after it is deactivated during simulation. HasStoppedSimulation() should check if bIsActive is false.

	(Integrate CL 3260001 from Odin)

Change 3359330 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Fix accumulated forces in CharacterMovement when movement mode or activation changes.

	- Added CharacterMovementComponent::ClearAccumulatedForces()
	- AddForce() and related functions now avoid adding the force if in MovementMode "None". When ticking in "None", forces are cleared so they don't pile up until the next valid movement mode. Forces are also cleared if the updated component changes or when the capsule simulates physics.
	- CharacterMovementComponent::Deactivate() implemented to stop movement and call ClearAccumulatedForces().
	- ClearAccumulatedForces() now also clears pending launch velocity.
	- Exposed ClearAccumulatedForces() to blueprints.
	- AddForce() and AddImpulse() now also check that character movement is active (not deactivated, able to tick).
	- ApplyAccumulatedForces() does not call ClearAccumulatedForces(), since that would prevent pending launch.
	- SimulateMovement() handles pending launch and clears forces regardless of whether it's simulated proxy. Added note to investigate using ApplyAccumulatedForces() in SimulateMovement().
	- Inlined ActorComponent::IsActive().

	(Integrate CLs 3259933, 3266018 from Odin)

Change 3359338 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) TickCharacterPose() and clear root motion before abandoning tick in UCharacterMovementComponent::PerformMovement() when movement mode is None. Prevents root motion building up until next valid movement mode.

	(Integrate CL 3271928 from Odin)

Change 3359345 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Fix characters sliding when landing on slanted surfaces or stairs, when aggressive "Perch" settings could cause a line trace (from the center of a capsule) instead of capsule trace and thereby screw up the floor distance checks.

	(Integrate CL 3273026 from Odin)

Change 3359381 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Performance tweak to ApplyRadialDamageWithFalloff(). Don't rebuild FRadialDamageEvent each loop over hit actors. Added stats for BreakHitResult()/MakeHitResult() under "stat game".

	(Integrate CLs 3275415, 3276810 from Odin).

Change 3359422 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Fix build (CollisionProfile included).

Change 3359442 on 2017/03/22 by Michael.Noland

	Blueprints: Prevent comment boxes from clipping the last letter of some words at the edge by increasing the padding on the wrap-at position

Change 3359445 on 2017/03/22 by Michael.Noland

	PR #2989: Improved BP comment nodes (Contributed by projectgheist)

	#jira UE-36788
	#jira UE-39118

Change 3359446 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Add support for FScopedMovementUpdate to be able to queue up overlaps that do not require reflexive bGenerateOverlapEvents. This allows custom inspection or processing of overlaps within a scoped move. Overlap events from the move will still only trigger in UpdateOverlaps() if bGenerateOverlapEvents is enabled on both components, as before.

	(Integrate CL 3278307 from Odin)

Change 3359494 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Make some data in FScopedMovementUpdate protected rather than private so it can easily be subclassed, and expose a new helper SetWorldLocationAndRotation().

	(Integrated CL 3280775 from Odin).

Change 3359506 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) MovementComponent::Deactivate() calls StopMovement() to clear cached velocity. It's silly that reactivation many seconds or frames later would restore that velocity. Some special handling in CharacterMovement to keep it acting as before (it cleared velocity, but did not clear the path request, leaving that alone).

	(Integrate CL 3287026 from Odin).

Change 3359514 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Collision.ListComponentsWithResponseToProfile command includes pending kill objects.

	(Integrate CL 3293322 from Odin)

Change 3359553 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Optimization in CharacterMovement tick to not extract transform values twice.

	(Integrate CL 3299098 from Odin).

Change 3359554 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Perf: optimize UKismetMathLibrary::GetForwardVector() (converts Rotator to forward direction). This way we avoid building a matrix, and avoids 1 more SinCos call.

	(Integrate CL 3296254 from Odin).

Change 3359555 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Add OnComponentCollisionSettingsChangedEvent delegate to PrimitiveComponent. Fixed SkeletalMeshComponent not calling Super implementation.

	(Integrate CL 3295744 from Odin)

Change 3359561 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Perf: AActor::GetComponents() with generic type should *not* assume the output array needs space for the entire contents of OwnedComponents. If OwnedComponents.Num() > the array reserve size, this forces an allocation, even if few or no components of the requested type are found.

	(Integrate CL 3299111 from Odin)

Change 3359573 on 2017/03/22 by dan.reynolds

	Added BP log to the Passive Mix Modifier test platform BP

Change 3359593 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Perf: avoid allocations during creation in AAIController::PostInitializeComponents() (in development builds).

	(Integrate CL 3299118 from Odin)

Change 3359595 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Perf: HasActiveCameraComponent() and HasActivePawnControlCameraComponent() don't need to fill in an array while searching for a certain component. Also see CL 3359561, which could cause each of these functions to always cause an allocation when filling in the array when num components > 24.

	(Integrate CL 3299116 from Odin)

Change 3359602 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Clean up some of the new fast overlap code in PrimitiveComponent. Mostly some variable renaming, and CVar access optimization.

	(Integrate CL 3340622 from Odin)

Change 3359616 on 2017/03/22 by Zak.Middleton

	#ue4 - (Merge) Added support for bIgnoreTouches to FCollisionQueryParams. MoveComponent uses this to avoid PhysX collision queries for overlaps in GeomSweepMulti when bGenerateOverlapEvents is off.

	(Integrate CL 3340635 from Odin)

Change 3359864 on 2017/03/23 by Mieszko.Zielinski

	Added a safeguard to prevent crashes resulting from people trying to name their BB keys things longer than 1024 characters #UE4

	#jira UE-43120

Change 3360884 on 2017/03/23 by Zak.Middleton

	#ue4 - (Merge) Audio: AUDIO_MIXER_ENABLE_DEBUG_MODE turned off in Test builds. Shipping already had it off.

	(Integrate CL 3310724 from Odin)

Change 3361045 on 2017/03/23 by Zak.Middleton

	#ue4 - (Merge) Audio: new cvars to help with optimization:

	- au.DisableReverbSubmix
	- au.DisableEQSubmix
	- au.DisableParallelSourceProcessing
	- au.SetAudioChannelCount

	Also checked in some code to cut down on the amount of parameter setting in EQ

	(Integrate of CL 3303165 in Odin by Aaron.Mcleran)

Change 3361172 on 2017/03/23 by Zak.Middleton

	#ue4 - (Merge) Audio: added stat for HRTF.

	(Integrate CL 3310728 from Odin)

Change 3361189 on 2017/03/23 by Zak.Middleton

	#ue4 - (Merge) CVar to toggle HRTF for perf settings. Default is on.

	(Integrate CL 3310926 from Odin).

Change 3361914 on 2017/03/23 by Aaron.McLeran

	UE-42649 Fixing crash in cleaning up active sound in sound concurrency

	-Handling edge case of an active sound not have a sound base ptr, which is possible.

Change 3361924 on 2017/03/23 by Aaron.McLeran

	UE-41378 Fixing passive mix modifier bug

Change 3361978 on 2017/03/23 by Aaron.McLeran

	UE-42627 Fix for when audio device is removed and getting a deadlock in computing audio clock

Change 3361989 on 2017/03/23 by Aaron.McLeran

	PR #3010: Check for null GEngine on sound processing

Change 3362053 on 2017/03/23 by Zak.Middleton

	#ue4 - (Merge) Audio: Perf: Avoid thousands of Array.Add() calls during processing, which on shipping still does checks to see if the allocator has to grow, and updates ArrayCount.

	(Integrate CL 3311120 from Odin)

Change 3362102 on 2017/03/23 by Aaron.McLeran

	PR #3182:  Enabled SwitchOnEnum nodes for EAttenuationShape and EAttenuationDistanceModel

Change 3362153 on 2017/03/23 by Aaron.McLeran

	UE-43286 Oculus audio plugin not working/available

Change 3362162 on 2017/03/23 by Aaron.McLeran

	UE-42252  Frequent ensure in FLevelEditorViewportClient::UpdateAudioListener

Change 3362206 on 2017/03/23 by Aaron.McLeran

	UE-43287 Fixing HRTF spatialization in editor viewport

	- Steam Audio doesn't support multiple audio devices at the moment
	- Instead of hard-coding all audio plugins to not work in main audio device (GDC temp fix), I allow audio plugins to specify if they should be used on main audio device

Change 3362775 on 2017/03/24 by mason.seay

	Replaced deprecated node

Change 3363024 on 2017/03/24 by Ben.Zeigler

	Fix regression in behavior of streamable manager where loading both a valid and null asset used to work but now fails. Instead added a warning for that case, but if only null are requested it still fails with an error

Change 3363030 on 2017/03/24 by Zak.Middleton

	#ue4 - Lower default max sendrate for clients to 60Hz from 90Hz when net speed is high and player count is low. Throttled rate remains at 45Hz. This value has been tested in Paragon with no ill effect, and saves on bandwidth and server CPU when clients run at high framerate.

Change 3363036 on 2017/03/24 by Zak.Middleton

	#ue4 - (Merge) Audio: Perf: turned a float divide into a multiply. It happens at least 32k times per audio update.

	(Integrate CL 3311158 from Odin)

Change 3363541 on 2017/03/24 by Zak.Middleton

	#ue4 - (Merge) Audio: Perf: remove pointer indirection, and successive TArray Add()s in GetChannelMap().

	(Integrate CL 3311169 from Odin)

Change 3363642 on 2017/03/24 by Zak.Middleton

	#ue4 - (Merge) Audio: Perf: Save ~5% total audio update time. Savings in "Source Output Buffers".

	- Removed function call overhead to updating channel map. 64,000 function calls...
	- Simplified FSourceParam::Update() to reduce branching and have 1 return site.
	- Added alternative to GetChannelMap() called UpdateChannelMap() that avoids copying out values to an array. The values can then be fetched from the channel data directly.

	(Integrate CL 3311235 from Odin)

Change 3364441 on 2017/03/24 by Ben.Zeigler

	Fix issue where calling LoadLocalIniFile on a plugin file would result in an empty file. It was assuming engine/game dirs, now it instead pulls it out of GConfig if available.
	This fixes issue where iterative cooking would fail on plugin config files
	Add FindConfigFileWithBaseName to GConfig

Change 3364652 on 2017/03/25 by Phillip.Kavan

	#jira UE-43210 - Fix a runtime VM crash upon removing an element from a set after consecutive add/remove iterations.

	Change summary:
	- Fixed FScriptSet::Add() to initialize the HashIndex member of the new element when the HashSize does not change.

Change 3365609 on 2017/03/27 by Richard.Hinckley

	#jira UEDOC-4720
	Fixed global enums being dropped from documentation after being extracted by Doxygen.

Change 3365737 on 2017/03/27 by Marc.Audy

	Move setting of the ParentComponent property on an actor to PostRepNotifies instead of having a separate OnRep function.

Change 3365795 on 2017/03/27 by Marc.Audy

	Fix compile error

Change 3365894 on 2017/03/27 by Phillip.Kavan

	#jira UE-35507 - Fix for a GLEO when choosing an LSBP class as the default value for a class input pin in a non-LSBP graph.

	Change summary:
	- Modified FGraphPinFilter::IsClassAllowed() to disallow a given class if the type is contained within a map package that does not match the current graph context.

Change 3366067 on 2017/03/27 by Marc.Audy

	Add UWorld* to PostLoadMap indicating which world has been loaded. Null if an error has occurred.
	#jira UE-40228

Change 3366097 on 2017/03/27 by Marc.Audy

	Fixed missed deprecation disable pairing for PostLadMap

Change 3366170 on 2017/03/27 by Aaron.McLeran

	Fixing div by zero

Change 3366221 on 2017/03/27 by Aaron.McLeran

	UE-43240 Removing dependency on component visualizers in runtime Phonon module.

Change 3366698 on 2017/03/27 by Marc.Audy

	Fix Orion compile errors

Change 3366782 on 2017/03/27 by Aaron.McLeran

	Bringing over optimizations from Odin to Dev-framework.

	Original CL 3311435

Change 3366818 on 2017/03/27 by Aaron.McLeran

	Bringing fix from Odin to Dev-Framework from CL 3304533

	Fix for rare condition that stomps memory during source recycling.

Change 3366984 on 2017/03/27 by Michael.Noland

	Blueprints: Downgraded a warning in the connection drawing policy to verbose to suppress it. It does no good to a typical user.
	#jira UE-41638

Change 3367085 on 2017/03/27 by Brent.Pease

	 - Improve AudioMixer buffering so that only two buffers are needed instead of three, buffer submission and buffer processing are ovelapped, and a warning is issued if the audio processing thread can not keep up.
	 - Added time critical thread priority so that audio processing is not starved which would produce clicks and popping
	 - Allow the audio thread to not be created if a platform implements its own BeginGeneratingAudio() call (as happens on Android)

Change 3367434 on 2017/03/28 by Marc.Audy

	Fix UT compile error

Change 3368587 on 2017/03/28 by Mike.Beach

	Adding a "CookedOnly" plugin type (now used by the nativized Blueprint plugin).

Change 3368724 on 2017/03/28 by Zak.Middleton

	#ue4 - MovementComponent does not ignore initial blocking overlaps when moving from SafeMoveUpdatedComponent(). Set "p.MoveIgnoreFirstBlockingOverlap" back to zero and add a new flag that prevents the depenetration test from generating hit events (to prevent the problem discovered in UE-39387).

	#jira UE-41613, UE-28610

Change 3368748 on 2017/03/28 by Dan.Oconnor

	Provide &FUObjectThreadContext::Get().ObjLoaded when using the compilation manager, add validation functions for finding REINST/TRASH references

Change 3368852 on 2017/03/28 by Mike.Beach

	Fixing a CIS error before it happens - wrapping implementation in preprocessor defines to match declaration in header.

Change 3368873 on 2017/03/28 by Dan.Oconnor

	Rather than collecting script object references, just use the ScriptObjectReferences array. This allows reference replacing archives to update ScriptObjectReferences.

Change 3368998 on 2017/03/28 by Dan.Oconnor

	Setting  CLASS_Interface early in the compilation process

Change 3369494 on 2017/03/29 by Marc.Audy

	Fix UAT compile error

Change 3369924 on 2017/03/29 by Zak.Middleton

	#ue4 - Allow CharacterMovement AdjustFloorHeight() to adjust using the line trace if in penetration. Force next floor check so it will check after it depenetrates.

	#jira UE-36973

Change 3369932 on 2017/03/29 by Ben.Zeigler

	#jira UE-19494 Finish asset auditing work by allowing reading back a cooked asset registry in the editor
	Split off FAssetRegistryState as the struct to hold serialization and accessors, to allow loading multiple platform states at once.
	Optimized runtime asset registry serialization to be around 1/3 as large as before. Dependencies are disabled by default for the runtime registry, you can re-enable with bSerializeDependencies in Engine.ini
	Add FAssetPackageData which is explicitly per-package and only updated on save/load time. File size is stored in here and is computed for both editor and cooked data
	Add code to AssetManagerEditorModule to allow loading pre-cooked asset registry files and reading cooked sizes. The Asset Audit window now has a platform drop down that allows reading from cooked data
	Rename ChunkManifestGenerator to AssetRegistryGenerator and change it to directly hold an FAssetRegistryState internally
	Add new experimental AssetRegistry mode for iterative cooking. This mode is much faster as it does not need to do it's own internal dependency checking and it can be enabled with bUseAssetRegistryForIteration
	Change it so during cooking it doesn't directly load string asset references, but instead cues them for cook and uses the asset registry to find and add redirector mappings that are used during save time

Change 3370028 on 2017/03/29 by Ben.Zeigler

	CIS fix

Change 3370360 on 2017/03/29 by Mike.Beach

	Adding an extra field to FPlatformInfo; a 'UBTTarget' identifier intended to sync up with UBT's UnrealTargetPlatform enum (needed for programatically generating plugin platform whitelists).

Change 3370363 on 2017/03/29 by Ben.Zeigler

	Fix issue where loading out of date editor asset registry cache would throw pointless errors

Change 3370414 on 2017/03/29 by Marc.Audy

	Remove autos

Change 3370428 on 2017/03/29 by Ben.Zeigler

	Fix linux CIS issue, remove implicit conversion from FSavePackageResultStruct back to enum result as it was creating ambiguous operators

Change 3370453 on 2017/03/29 by Marc.Audy

	CIS fix

Change 3370548 on 2017/03/29 by Marc.Audy

	#rn Fix issues with seamless travel in PIE and shared sub levels between different parents.

Change 3370564 on 2017/03/29 by Mieszko.Zielinski

	PR #3429: fix comment typo (Contributed by kayama-shift)

Change 3370602 on 2017/03/29 by Mieszko.Zielinski

	Fixed FRecastTileGenerator::Modifiers being erroneously counted twice when stating memory #UE4

Change 3370615 on 2017/03/29 by Phillip.Kavan

	#jira UE-35515 - No longer crash when creating a new BP class from one or more selected Actors in which the root component is not Blueprint-spawnable.

	Change summary:
	- Modified FKismetEditorUtilities::AddComponentsToBlueprint() to handle deferred SceneComponent SCS node adds when the parent component was not also added (due to not being BP-spawnable).

Change 3370693 on 2017/03/29 by Michael.Noland

	Fixing some bad indentation
	#rnx

Change 3370740 on 2017/03/29 by Ben.Zeigler

	DLC/Mod Cooking fixes, the list of packages from release build as in uncooked filename format so fixed code and made this more obvious
	Fix Asset Registry to allow loading multiple source asset registries into the same state, by keeping a list of preallocated buffers

Change 3370792 on 2017/03/29 by Michael.Noland

	Blueprints: Deleted some unversioned backwards compat. code that would only matter for assets older than VER_UE4_OLDEST_LOADABLE_PACKAGE

Change 3370794 on 2017/03/29 by Michael.Noland

	PR #3190: Reduce some output logging
	- Reduced an Oculus log from Log to Verbose because it spams quite a bit
	- Corrected the spelling and the meaning of a blueprint warning when an invalid breakpoint is encountered
	- Treat UInputComponent::GetAxisValue(None) as not a warning
	- Switch FGenericSaveGameSystem::LoadGame to silently attempt to load the file, it returns success/failure and it isn't necessary to have a separate warning at the file i/o layer

	#jira UE-41446

Change 3370831 on 2017/03/29 by Dan.Oconnor

	Iteration on compilation manager
	 - Fix Skeleton class compilation order
	 - Pass ObjLoaded array to compilation manager to ensure all objects get PostLoaded
	 - Make sure data only classes get reinstanced, so that UpdateCustomPropertyListForPostConstruction is run correctly

Change 3370923 on 2017/03/29 by Michael.Noland

	Blueprints: Added an icon to indicate whether or not a macro contains latent actions
	- Note: The state of the icon is cached for performance reasons on request, with the cache being cleared when the BP containing the macro is modified or a macro graph is removed
	- This does mean that editing the inner macro of a nested macro to add/remove a latent action will not show up in visualization for the outer node until the editor is restarted or the outer macro is modified

Change 3371039 on 2017/03/29 by Dan.Oconnor

	Hacky fix for dropping return params when a function's return node is culled

Change 3371750 on 2017/03/30 by Richard.Hinckley

	Stencil write mask exposed. Adds nine new options (all bits, plus each bit individually - write on pass or depth fail). This allows stencil overlaps to be detected by mixing masks.

Change 3372513 on 2017/03/30 by Ben.Zeigler

	#jira UE-43475 Fix cooker issues with string asset references to null packages.
	Fix redirector detection to follow recursive chains, and correctly strip object class from redirected string asset references.

Change 3372565 on 2017/03/30 by Richard.Hinckley

	Rolling back stencil change, will be moved to Dev-Rendering.

Change 3372764 on 2017/03/30 by Marc.Audy

	Do not create a duplicate sub object that is not in the annotation if a sub object of the same name and class already exists.
	#jira UE-43328

	#rn Fixed cases where the blueprint of a class used as a child actor could be dirtied when compiling the owning blueprint.

Change 3372847 on 2017/03/30 by Marc.Audy

	Fix missing include

Change 3372994 on 2017/03/30 by Zak.Middleton

	#ue4 - Fix build in Debug (checkSlow using incorrect function params).

Change 3373195 on 2017/03/30 by Mike.Beach

	For nativization, changing it so we key off of the target platform-info struct instead of the platform (in preparation for defining the nativized plugin's platform whitelist).

Change 3373320 on 2017/03/30 by mason.seay

	Basic for TM-Gameplay map (WIP)

Change 3373448 on 2017/03/30 by Ben.Zeigler

	Fix recursive size display in audit window
	Improve asset manager comments

Change 3373576 on 2017/03/30 by dan.reynolds

	AEOverview Update:

	Updated Passive Mix Modifier Test based on recent changes in behavior

	Also added Initial Delay Time timer to test

Change 3373589 on 2017/03/30 by dan.reynolds

	AEOverview Passive Mix Mod Test Map update

Change 3373624 on 2017/03/30 by Zak.Middleton

	#ue4 - Increase Pawn location replication precision to 2 decimal places from 0. Prevents replicated pawns from being inside geometry by a large amount. Removed CVars controlling CharacterMovement proxy shrink amount and made those instanced properties on the component.

	#jira UE-40420

Change 3374271 on 2017/03/31 by Marc.Audy

	Fix deprecation warning in new UT code

Change 3374320 on 2017/03/31 by Marc.Audy

	Fix HTML5 compile.

Change 3374413 on 2017/03/31 by Jeff.Farris

	Added ENGINE_API to 2 functions in PlanarReflection, so projects can subclass it.

	(Copied CL 3276454 from Robo Recall to Dev-Framework)

Change 3374414 on 2017/03/31 by Jeff.Farris

	Added support for setting UNavigationSystem::bUpdateNavOctreeOnComponentChange

	(Copied CL 3267903 from RoboRecall to Dev-Framework)

Change 3374616 on 2017/03/31 by Ben.Zeigler

	Copy of Fortnite CL #3312058 to add a missing redirector. I do not understand why this is not erroring on Main, I guess my minor cook changes somehow exposed this

Change 3374664 on 2017/03/31 by Jeff.Farris

	Consted AIController::GetBrainComponent()

	(Copied 3239101 from Robo Recall to Dev-Framework)

Change 3374665 on 2017/03/31 by Jeff.Farris

	PrimitiveComponent bIgnoreRadialImpulse and bIgnoreRadialForce are now exposed to BPs. bIgnoreRadialImpulse now respected when applying impulse to relevant movement components.

	(Coped CL 3242355 from Robo Recall to Dev-Framework)

Change 3374779 on 2017/03/31 by Jeff.Farris

	Exposed SetAllPhysicsAngularVelocity to blueprints

	(Copied CL 3228390 from Robo Recall to Dev-Framework)

Change 3374792 on 2017/03/31 by Ben.Zeigler

	#jira UE-42618
	PR #3347: Improve support for FGameplayAttributeData properties in attribute sets (Contributed by hoelzl)

Change 3374844 on 2017/03/31 by Ben.Zeigler

	#jira UE-42587 Fix issue where supressed gameplay effects that granted abilities would only work the first time, it now clears out of date ability handles

Change 3374925 on 2017/03/31 by Marc.Audy

	Don't throw warning about missing world context for inactive worlds.
	#jira UE-42679

Change 3374927 on 2017/03/31 by Michael.Noland

	Editor: Added options for configuring the editor window background color and texture, which can be useful to visually distinguish the editor when switching between different branches or projects

Change 3374995 on 2017/03/31 by Michael.Noland

	Editor: Rewrote CallInEditor support and promoted it so it can be used on functions in any class, not just blueprints derived from AActor:
	- CallInEditor used on native UFUNCTION() declarations will now show up without having to make a BP subclass
	- CallInEditor can now be used as a top-level keyword in the UFUNCTION() declaration (e.g., UFUNCTION(Category=CoolCommands, CallInEditor))
	- Now shows each function as a separate button, placed in the category associated with the function
	- The button strip entry is now searchable by function name or tooltip
	- Prevented operating on functions that have parameters or return values, which would crash before
	- Removed the duplicate copies of properties placed in the Blutility section
	- Added a scoped transaction around CallInEditor execution
	- Allowed functions to be marked as CallInEditor in addition to custom events (currently we don't allow editing category or tooltip on custom events...)

	Editor: Moved Experimental/EarlyAccessPreview details customizations up to UObject so it can be used on any class, not just actors/components

	Upgrade Note: Behavior has changed so that CallInEditor can be called on CDOs as well, this will probably be walked back in a subsequent update, at least for actors and components.

Change 3375005 on 2017/03/31 by Michael.Noland

	Fixing incremental compilation error due to missing include
	#rnx

Change 3375015 on 2017/03/31 by Michael.Noland

	Fixing incremental compilation error due to missing include (for real)
	#rnx

Change 3375045 on 2017/03/31 by Marc.Audy

	Only calculate the streaming levels prefix during seamless travel if it is a PIE world
	#jira UE-43485

Change 3375053 on 2017/03/31 by Ben.Zeigler

	#jira UE-41988 Fix it so leaving PIE while gameplay debugger is active will disable HUD extensions properly, restoring ability to print messages to screen

Change 3375057 on 2017/03/31 by Ben.Zeigler

	#jira UE-39226 Don't add to DrawDebug list for player controllers with no local player

Change 3375121 on 2017/03/31 by Michael.Noland

	Added missing include for FScopedTransaction
	#rnx

Change 3375222 on 2017/03/31 by mason.seay

	Submitting work done to TM-Gameplay.  Still WIP

Change 3375308 on 2017/03/31 by Michael.Noland

	Editor: Added back CDO filtering to CallInEditor, it's too easy to explode in the BP editor.  May consider allowing opt-in behavior when we revisit Blutilities

Change 3375321 on 2017/03/31 by Ben.Zeigler

	#jira UE-39062 Fix issue where using the level editor toolbar to modify blueprints was not properly marking the blueprints as modified, so the constructor links weren't being updated until manually compiling or resaving
	Always recompute post constructor links when calling MarkBlueprintAsModified, as it can be called from native and other places where we modified CDOs but don't have a property changed event

Change 3375372 on 2017/03/31 by Ben.Zeigler

	#jira UE-39568 Change Components to specifically update LatentActions the same as Actors do, so they update properly if bUpdateWhilePaused is set

Change 3375380 on 2017/03/31 by Marc.Audy

	Modify IsMainAudioDevice to deal with the case where no audio device has been created.

Change 3375402 on 2017/03/31 by Marc.Audy

	Fix DuplicateWorldForPIE in the case that the OwningWorld is null.

Change 3376037 on 2017/04/02 by Phillip.Kavan

	#jira UE-35332 - Preserve the least common ancestor pin type on object array function node inputs after a node refresh.

	Change summary:
	- Added UK2Node_CallArrayFunction::GetDynamicallyTypedPins() to consolidate the code that retrieves type-dependent parameter pins.
	- Added FBlueprintEditorUtils::FindLinkedPinWithAuthoritativePinType() to consolidate the code that considers other linked pins when choosing which type to propagate to type-dependent parameter pins.
	- Added FBlueprintEditorUtils::PropagatePinTypeInfo() to consolidate the common code from UK2Node_CallArrayFunction::PropagateArrayTypeInfo(); this eliminated a redundant retrieval of the target pin set.
	- Refactored UK2Node_CallArrayFunction::PropagateArrayTypeInfo() to now call FBlueprintEditorUtils::PropagatePinTypeInfo() after retrieving the set of dynamically-typed pins.
	- Refactored UK2Node_CallArrayFunction::NotifyPinConnectionListChanged() to remove some unnecessary iteration passes and to ensure that we propagate the authoritative (least common ancestor) pin type for object- and struct-based types.

Change 3376364 on 2017/04/03 by Richard.Hinckley

	UE-40920 Fix to Paper2D flipbook timeline editor. Previously, the timeline shown was one frame shorter than the animation. Now, the timeline shows the correct frame count.

Change 3376366 on 2017/04/03 by Richard.Hinckley

	UE-40920 Bugfix to Paper2D flipbook editor. The red line indicating the current frame now adjusts properly if the timeline is longer than the editor window and the scroll bar is moved to the right.

Change 3376517 on 2017/04/03 by Marc.Audy

	PR #3195: Added support for GamePad on RawInput Plugin (Contributed by katze7514)
	#jira UE-41499

Change 3376708 on 2017/04/03 by Mike.Beach

	Moving nativized plugins into a centralized folder (so we can use it as an additional plugin lookup dir) - this is so we can ultimately keep the generated code around for debugging purposes.

	Summary of changes:
	- nativized plugins now moved to ...\Intermediate\Plugins\<PLATFORM>\NativizedAssets
	- corresponding manifest files get saved inside the module and named to match the platform
	- nativized modules now whitelisted only for the platform they were generated for
	- cleanup on how we generate paths (now piping in platform name) and pass multi-cook process ids (for building manifest filenames)
	- extending the 'NativizeAssets' command line, so you can use it to specify the target plugin path (utilized by UAT to coordinate the plugin path between cook & build - was previously hardcoded in multiple places).

Change 3376826 on 2017/04/03 by Phillip.Kavan

	#jira UE-43330 - Fix a crash when adding an input parameter to a Custom Event node after deleting a Function Graph containing a Create Event node.

	Change summary:
	- Modified UK2Node_CreateDelegate::HandleAnyChangeWithoutNotifying() to check for a valid blueprint before accessing it (since the accessor is now a checked operation).
	- Modified UK2Node_CreateDelegate::GetScopeClass() to also check for a valid blueprint before accessing it.
	- Switched 'NULL' to 'nullptr' in a few spots.

Change 3376831 on 2017/04/03 by Ben.Zeigler

	#jira UE-43500, clean up UPackage when EDL/async loading fails. This restores EDL LoadPackage to work the same as non EDL and return NULL instead of an invalid empty package

Change 3376846 on 2017/04/03 by Ben.Zeigler

	#jira UE-38760 Properly refresh exec pins when removing pin from a Switch on Int node

Change 3376850 on 2017/04/03 by Dan.Oconnor

	Use authoritative class to mitigate compilation order issues

Change 3376961 on 2017/04/03 by Ben.Zeigler

	#jira UE-43127 Add struct ops implementations for FIntVector and FBox2d, any blueprint type needs struct ops to avoid crashes
	Fix Box2d variable name in NoExportTypes

Change 3376985 on 2017/04/03 by Ben.Zeigler

	#jira UE-43582 Remove Xbox-specific code from AssetRegistry because it won't work after my refactor. The serialization is much faster now and neither Bob nor I can conceive of a way this would take long enough to stall the main thread. If it it is somehow a problem, it should be wrapped in a slow task instead

Change 3377009 on 2017/04/03 by Ben.Zeigler

	#jira UE-43036 Fix crash when right clicking blueprint with no parent class. Ensures are fine but crashes should be avoided so people can try to copy data out of them

Change 3377054 on 2017/04/03 by Zak.Middleton

	#ue4 - Fix CharacterMovementComponent updated with very high delta time on server when initially joining. Make sure the ServerTimeStamp is initialized to current world time rather than zero to prevent large delta.

	#jira UE-40344
	#udn https://udn.unrealengine.com/questions/310497/large-delta-time-for-first-player-movement-update.html

Change 3377061 on 2017/04/03 by Dan.Oconnor

	Fixes for issues exposed by cooking with compilation manager. When cooking we end up with more blueprints compiling at a single time, which highlighted issues reading from generated classes while they were actively regenerating.

	Note that EInternalCompilerFlags::PostponeLocalsGenerationUntilPhaseTwo has only been added to mitigate risk - there is no known reason that existing compilation flows can't postpone generatation of local variables.

Change 3377073 on 2017/04/03 by Mike.Beach

	CIS fix - proper initialization ordering.

Change 3377371 on 2017/04/03 by Ben.Zeigler

	#jira UE-43144 Disallow creating map of FText, like bool it is not hashable

Change 3377395 on 2017/04/03 by Dan.Oconnor

	Build fix - make order in source match initialization order in artifact

Change 3377417 on 2017/04/03 by Dan.Oconnor

	Speculative SA fix

Change 3377496 on 2017/04/03 by Aaron.McLeran

	#jira UE-43558 Cleaning up shutdown code with audio plugins.

Change 3377608 on 2017/04/03 by Zak.Middleton

	#ue4 - Added function ACharacter::CacheInitialMeshOffset() to cache initial mesh offset, used as the target for network smoothing. Added a call to this function from BeginPlay() in addition to the existing call from PostInitializeComponents(), and exposed this to blueprints as well. This fixes the case of people moving the mesh in BeginPlay rather than in the editor or construction script and not having the mesh offset reflected correctly in network games.

	#jira UE-38966

Change 3377880 on 2017/04/03 by Aaron.McLeran

	Audio bug fixes

	#jira UE-43600  Fixing sounds played by playsoundatlocation for audio volume calculations
	#jira UE-43601 Fixing listener volume interpolation
	#jida UE-43602 Fixing reverb/eq interpolation

Change 3377908 on 2017/04/03 by Phillip.Kavan

	#jira UE-43565 - Fix a regression on type-dependent array function node pins that have more than one link.

	Change summary:
	- Added FBlueprintEditorUtils::FindLinkedPinWithMostDerivedPinType()
	- Modified FBlueprintEditorUtils::FindLinkedPinWithAuthoritativePinType() to properly handle pins that have multiple links.

Change 3377912 on 2017/04/03 by Dan.Oconnor

	Fix for missing SUBINSTANCE variables on anim BP skeletons. I elected to force SUBINSTANCE variable creation for the compilation manager codepath

Change 3377946 on 2017/04/03 by Ben.Zeigler

	#jira UE-43594 Fix issue with streamable manager where a failed load would leave bAsyncLoadRequestOutstanding, which would confuse later calls to stream the same asset
	Lower some error verbosity now that I believe I have tracked down the issue

Change 3377950 on 2017/04/03 by Michael.Noland

	Blueprints: Prevent merge tool from crashing in SVN when looking at a file with gaps in the revision history
	(May still not work correctly, but it won't crash; full fix covered by UE-43603)
	#jira UE-22428

Change 3377981 on 2017/04/03 by Michael.Noland

	PR #3416: UE-43005: Prevent crash due to too long name (Contributed by projectgheist)

	#jira UE-43291
	#jira UE-43005

Change 3378039 on 2017/04/04 by Michael.Noland

	PhysX: Allowed the editor to compile when bRuntimePhysicsCooking is disabled (WITH_EDITOR is used in every place in C++ to force it in already)

Change 3378041 on 2017/04/04 by Michael.Noland

	Paper2D: Adjusted under what circumstances CreatePhysicsMeshes is called on various Paper2D types to match UProceduralMeshComponent

Change 3378081 on 2017/04/04 by Dan.Oconnor

	Fix Blueprint Context nodes so that they don't rely on Ar.IsBeingSaved() call before compilation
	3x because of copy/paste

Change 3378094 on 2017/04/04 by Dan.Oconnor

	Add missing preload call for compilation manager

Change 3378917 on 2017/04/04 by Marc.Audy

	Fix static analysis (which is very dumb)

Change 3378986 on 2017/04/04 by Dan.Oconnor

	Fix bad merge

Change 3379100 on 2017/04/04 by Dan.Oconnor

	Fix missing CPF_ConstParm/CPF_ReferenceParm/CPF_OutParm logic in 'fast' skeleton path
	#jira UE-43629

Change 3379102 on 2017/04/04 by Ben.Zeigler

	Actually fix StreamableManager issues with cancelling a request messing up things in the future. We now always queue a request, even if it failed before or there is one in progress. This has to be done to avoid issues with cancelling the existing request or mounting new files after it's failed once
	Now that StreamableManager will retry missing files, add failed load packages to the known missing list so it won't spam errors over and over

Change 3379147 on 2017/04/04 by Zak.Middleton

	#ue4 - Improve on CL 3377608: Made Character::CacheInitialMeshOffset() take location and rotation params so you can be explicit on the values, in case you try to change these during network smoothing, where reading the relative offsets would have been skewed.

Change 3379254 on 2017/04/04 by Aaron.McLeran

	Fixing sounds in audio mixer when no EQ has been set.

Change 3379760 on 2017/04/04 by Ben.Zeigler

	#jira UE-43647 Don't delete failed async packages that are rooted

[CL 3380073 by Dan Oconnor in Main branch]
2017-04-04 20:49:52 -04:00

2239 lines
93 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "LevelEditorToolBar.h"
#include "Misc/MessageDialog.h"
#include "HAL/FileManager.h"
#include "Modules/ModuleManager.h"
#include "Framework/Application/SlateApplication.h"
#include "Widgets/Layout/SBorder.h"
#include "Widgets/Text/STextBlock.h"
#include "Widgets/Layout/SBox.h"
#include "Framework/MultiBox/MultiBoxDefs.h"
#include "Framework/MultiBox/MultiBoxExtender.h"
#include "Framework/MultiBox/MultiBoxBuilder.h"
#include "Widgets/Input/SCheckBox.h"
#include "Widgets/Input/SSpinBox.h"
#include "Widgets/Input/SSlider.h"
#include "EditorStyleSet.h"
#include "ISourceControlOperation.h"
#include "SourceControlOperations.h"
#include "ISourceControlProvider.h"
#include "ISourceControlModule.h"
#include "Settings/EditorExperimentalSettings.h"
#include "GameMapsSettings.h"
#include "GameFramework/PlayerController.h"
#include "GameFramework/GameModeBase.h"
#include "GameFramework/HUD.h"
#include "GameFramework/GameStateBase.h"
#include "Engine/TextureStreamingTypes.h"
#include "Toolkits/AssetEditorManager.h"
#include "LevelEditor.h"
#include "LevelEditorActions.h"
#include "SourceCodeNavigation.h"
#include "Kismet2/DebuggerCommands.h"
#include "SceneOutlinerPublicTypes.h"
#include "SceneOutlinerModule.h"
#include "SScalabilitySettings.h"
#include "IContentBrowserSingleton.h"
#include "ContentBrowserModule.h"
#include "Matinee/MatineeActor.h"
#include "LevelSequenceActor.h"
#include "Engine/LevelScriptBlueprint.h"
#include "ISettingsCategory.h"
#include "ISettingsContainer.h"
#include "ISettingsModule.h"
#include "ISettingsSection.h"
#include "DesktopPlatformModule.h"
#include "ClassViewerModule.h"
#include "ClassViewerFilter.h"
#include "Kismet2/KismetEditorUtilities.h"
#include "Kismet2/BlueprintEditorUtils.h"
#include "Widgets/Input/SVolumeControl.h"
#include "Features/IModularFeatures.h"
#include "EngineUtils.h"
#include "ScopedTransaction.h"
#include "Features/EditorFeatures.h"
#include "ConfigCacheIni.h"
namespace LevelEditorActionHelpers
{
/** Filters out any classes for the Class Picker when creating or selecting classes in the Blueprints dropdown */
class FBlueprintParentFilter_MapModeSettings : public IClassViewerFilter
{
public:
/** Classes to not allow any children of into the Class Viewer/Picker. */
TSet< const UClass* > AllowedChildrenOfClasses;
virtual bool IsClassAllowed(const FClassViewerInitializationOptions& InInitOptions, const UClass* InClass, TSharedRef< FClassViewerFilterFuncs > InFilterFuncs ) override
{
return InFilterFuncs->IfInChildOfClassesSet(AllowedChildrenOfClasses, InClass) == EFilterReturn::Passed;
}
virtual bool IsUnloadedClassAllowed(const FClassViewerInitializationOptions& InInitOptions, const TSharedRef< const IUnloadedBlueprintData > InUnloadedClassData, TSharedRef< FClassViewerFilterFuncs > InFilterFuncs) override
{
return InFilterFuncs->IfInChildOfClassesSet(AllowedChildrenOfClasses, InUnloadedClassData) == EFilterReturn::Passed;
}
};
/**
* Retrieves the GameMode class
*
* @param InLevelEditor The editor to extract the world from
* @param bInIsProjectSettings TRUE if retrieving the game mode from the project settings
* @return The GameMode class in the Project Settings or World Settings
*/
static UClass* GetGameModeClass(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback for the label to display for the GameMode menu selection */
static FText GetOpenGameModeBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback when selecting a GameMode class, assigns it to the world */
static void OnSelectGameModeClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback when creating a new GameMode class, creates the Blueprint and assigns it to the world */
static void OnCreateGameModeClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/**
* Retrieves the active GameState class from
*
* @param InLevelEditor The editor to extract the world from
* @param bInIsProjectSettings TRUE if retrieving the game mode from the project settings
* @return The active GameState class in the World Settings
*/
static UClass* GetGameStateClass(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback for the label to display for the GameState menu selection */
static FText GetOpenGameStateBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback when selecting a GameState class, assigns it to the world */
static void OnSelectGameStateClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback when creating a new GameState class, creates the Blueprint and assigns it to the world */
static void OnCreateGameStateClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/**
* Retrieves the active Pawn class from
*
* @param InLevelEditor The editor to extract the world from
* @return The active Pawn class in the World Settings
*/
static UClass* GetPawnClass(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback for the label to display for the Pawn menu selection */
static FText GetOpenPawnBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback for the tooltip to display for the Pawn menu selection */
static FText GetOpenPawnBlueprintTooltip(TWeakPtr< SLevelEditor > InLevelEditor);
/** Callback when selecting a Pawn class, assigns it to the world */
static void OnSelectPawnClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback when creating a new Pawn class, creates the Blueprint and assigns it to the world */
static void OnCreatePawnClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/**
* Retrieves the active HUD class from
*
* @param InLevelEditor The editor to extract the world from
* @param bInIsProjectSettings TRUE if retrieving the game mode from the project settings
* @return The active HUD class in the World Settings
*/
static UClass* GetHUDClass(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback for the label to display for the HUD menu selection */
static FText GetOpenHUDBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback when selecting a HUD class, assigns it to the world */
static void OnSelectHUDClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback when creating a new HUD class, creates the Blueprint and assigns it to the world */
static void OnCreateHUDClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/**
* Retrieves the active PlayerController class from
*
* @param InLevelEditor The editor to extract the world from
* @param bInIsProjectSettings TRUE if retrieving the game mode from the project settings
* @return The active PlayerController class in the World Settings
*/
static UClass* GetPlayerControllerClass(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback for the label to display for the PlayerController menu selection */
static FText GetOpenPlayerControllerBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback when selecting a PlayerController class, assigns it to the world */
static void OnSelectPlayerControllerClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Callback when creating a new PlayerController class, creates the Blueprint and assigns it to the world */
static void OnCreatePlayerControllerClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings);
/** Opens a native class's header file if the compiler is available. */
static void OpenNativeClass(UClass* InClass)
{
if(InClass->HasAllClassFlags(CLASS_Native) && FSourceCodeNavigation::IsCompilerAvailable())
{
FString NativeParentClassHeaderPath;
const bool bFileFound = FSourceCodeNavigation::FindClassHeaderPath(InClass, NativeParentClassHeaderPath)
&& (IFileManager::Get().FileSize(*NativeParentClassHeaderPath) != INDEX_NONE);
if (bFileFound)
{
const FString AbsoluteHeaderPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*NativeParentClassHeaderPath);
FSourceCodeNavigation::OpenSourceFile( AbsoluteHeaderPath );
}
}
}
/** Open the game mode blueprint, in the project settings or world settings */
static void OpenGameModeBlueprint( TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings )
{
if(UClass* GameModeClass = GetGameModeClass(InLevelEditor, bInIsProjectSettings))
{
if(UBlueprint* BlueprintClass = Cast<UBlueprint>(GameModeClass->ClassGeneratedBy))
{
// @todo Re-enable once world centric works
const bool bOpenWorldCentric = false;
FAssetEditorManager::Get().OpenEditorForAsset(
BlueprintClass,
bOpenWorldCentric ? EToolkitMode::WorldCentric : EToolkitMode::Standalone,
InLevelEditor.Pin() );
}
else
{
OpenNativeClass(GameModeClass);
}
}
}
/** Open the game state blueprint, in the project settings or world settings */
static void OpenGameStateBlueprint( TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings )
{
if(UClass* GameStateClass = GetGameStateClass(InLevelEditor, bInIsProjectSettings))
{
if(UBlueprint* BlueprintClass = Cast<UBlueprint>(GameStateClass->ClassGeneratedBy))
{
// @todo Re-enable once world centric works
const bool bOpenWorldCentric = false;
FAssetEditorManager::Get().OpenEditorForAsset(
BlueprintClass,
bOpenWorldCentric ? EToolkitMode::WorldCentric : EToolkitMode::Standalone,
InLevelEditor.Pin() );
}
else
{
OpenNativeClass(GameStateClass);
}
}
}
/** Open the default pawn blueprint, in the project settings or world settings */
static void OpenDefaultPawnBlueprint( TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings )
{
if(UClass* DefaultPawnClass = GetPawnClass(InLevelEditor, bInIsProjectSettings))
{
if(UBlueprint* BlueprintClass = Cast<UBlueprint>(DefaultPawnClass->ClassGeneratedBy))
{
// @todo Re-enable once world centric works
const bool bOpenWorldCentric = false;
FAssetEditorManager::Get().OpenEditorForAsset(
BlueprintClass,
bOpenWorldCentric ? EToolkitMode::WorldCentric : EToolkitMode::Standalone,
InLevelEditor.Pin() );
}
else
{
OpenNativeClass(DefaultPawnClass);
}
}
}
/** Open the HUD blueprint, in the project settings or world settings */
static void OpenHUDBlueprint( TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings )
{
if(UClass* DefaultHUDClass = GetHUDClass(InLevelEditor, bInIsProjectSettings))
{
if(UBlueprint* BlueprintClass = Cast<UBlueprint>(DefaultHUDClass->ClassGeneratedBy))
{
// @todo Re-enable once world centric works
const bool bOpenWorldCentric = false;
FAssetEditorManager::Get().OpenEditorForAsset(
BlueprintClass,
bOpenWorldCentric ? EToolkitMode::WorldCentric : EToolkitMode::Standalone,
InLevelEditor.Pin() );
}
else
{
OpenNativeClass(DefaultHUDClass);
}
}
}
/** Open the player controller blueprint, in the project settings or world settings */
static void OpenPlayerControllerBlueprint( TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings )
{
if(UClass* PlayerControllerClass = GetPlayerControllerClass(InLevelEditor, bInIsProjectSettings))
{
if(UBlueprint* BlueprintClass = Cast<UBlueprint>(PlayerControllerClass->ClassGeneratedBy))
{
// @todo Re-enable once world centric works
const bool bOpenWorldCentric = false;
FAssetEditorManager::Get().OpenEditorForAsset(
BlueprintClass,
bOpenWorldCentric ? EToolkitMode::WorldCentric : EToolkitMode::Standalone,
InLevelEditor.Pin() );
}
else
{
OpenNativeClass(PlayerControllerClass);
}
}
}
/**
* Builds a sub-menu for selecting a class
*
* @param InMenuBuilder Object to append menu items/widgets to
* @param InRootClass The root class to filter the Class Viewer by to only show children of
* @param InOnClassPicked Callback delegate to fire when a class is picked
*/
void GetSelectSettingsClassSubMenu(FMenuBuilder& InMenuBuilder, UClass* InRootClass, FOnClassPicked InOnClassPicked)
{
FClassViewerInitializationOptions Options;
Options.Mode = EClassViewerMode::ClassPicker;
Options.DisplayMode = EClassViewerDisplayMode::ListView;
Options.bShowObjectRootClass = true;
Options.bShowNoneOption = true;
// Only want blueprint actor base classes.
Options.bIsBlueprintBaseOnly = true;
// This will allow unloaded blueprints to be shown.
Options.bShowUnloadedBlueprints = true;
TSharedPtr< FBlueprintParentFilter_MapModeSettings > Filter = MakeShareable(new FBlueprintParentFilter_MapModeSettings);
Filter->AllowedChildrenOfClasses.Add(InRootClass);
Options.ClassFilter = Filter;
FText RootClassName = FText::FromString(InRootClass->GetName());
TSharedRef<SWidget> ClassViewer = FModuleManager::LoadModuleChecked<FClassViewerModule>("ClassViewer").CreateClassViewer(Options, InOnClassPicked);
FFormatNamedArguments FormatArgs;
FormatArgs.Add(TEXT("RootClass"), RootClassName);
InMenuBuilder.BeginSection(NAME_None, FText::Format( NSLOCTEXT("LevelToolBarViewMenu", "SelectGameModeLabel", "Select {RootClass} class"), FormatArgs ));
InMenuBuilder.AddWidget(ClassViewer, FText::GetEmpty(), true);
InMenuBuilder.EndSection();
}
/**
* Builds a sub-menu for creating a class
*
* @param InMenuBuilder Object to append menu items/widgets to
* @param InRootClass The root class to filter the Class Viewer by to only show children of
* @param InOnClassPicked Callback delegate to fire when a class is picked
*/
void GetCreateSettingsClassSubMenu(FMenuBuilder& InMenuBuilder, UClass* InRootClass, FOnClassPicked InOnClassPicked)
{
FClassViewerInitializationOptions Options;
Options.Mode = EClassViewerMode::ClassPicker;
Options.DisplayMode = EClassViewerDisplayMode::ListView;
Options.bShowObjectRootClass = true;
// Only want blueprint actor base classes.
Options.bIsBlueprintBaseOnly = true;
// This will allow unloaded blueprints to be shown.
Options.bShowUnloadedBlueprints = true;
TSharedPtr< FBlueprintParentFilter_MapModeSettings > Filter = MakeShareable(new FBlueprintParentFilter_MapModeSettings);
Filter->AllowedChildrenOfClasses.Add(InRootClass);
Options.ClassFilter = Filter;
FText RootClassName = FText::FromString(InRootClass->GetName());
TSharedRef<SWidget> ClassViewer = FModuleManager::LoadModuleChecked<FClassViewerModule>("ClassViewer").CreateClassViewer(Options, InOnClassPicked);
FFormatNamedArguments FormatArgs;
FormatArgs.Add(TEXT("RootClass"), RootClassName);
InMenuBuilder.BeginSection(NAME_None, FText::Format( NSLOCTEXT("LevelToolBarViewMenu", "CreateGameModeLabel", "Select {RootClass} parent class"), FormatArgs ));
InMenuBuilder.AddWidget(ClassViewer, FText::GetEmpty(), true);
InMenuBuilder.EndSection();
}
/** Helper struct for passing all required data to the GetBlueprintSettingsSubMenu function */
struct FBlueprintMenuSettings
{
/** The UI command for editing the Blueprint class associated with the menu */
FUIAction EditCommand;
/** Current class associated with the menu */
UClass* CurrentClass;
/** Root class that defines what class children can be set through the menu */
UClass* RootClass;
/** Callback when a class is picked, to assign the new class */
FOnClassPicked OnSelectClassPicked;
/** Callback when a class is picked, to create a new child class of and assign */
FOnClassPicked OnCreateClassPicked;
/** Level Editor these menu settings are for */
TWeakPtr< SLevelEditor > LevelEditor;
/** TRUE if these represent Project Settings, FALSE if they represent World Settings */
bool bIsProjectSettings;
};
/** Returns the label of the "Check Out" option based on if source control is present or not */
FText GetCheckOutLabel()
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
if(ISourceControlModule::Get().IsEnabled())
{
return LOCTEXT("CheckoutMenuLabel", "Check Out");
}
else
{
return LOCTEXT("MakeWritableLabel", "Make Writable");
}
#undef LOCTEXT_NAMESPACE
}
/** Returns the tooltip of the "Check Out" option based on if source control is present or not */
FText GetCheckOutTooltip()
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
if(ISourceControlModule::Get().IsEnabled())
{
return LOCTEXT("CheckoutMenuTooltip", "Checks out the project settings config file so the game mode can be set.");
}
else
{
return LOCTEXT("MakeWritableTooltip", "Forces the project settings config file to be writable so the game mode can be set.");
}
#undef LOCTEXT_NAMESPACE
}
/**
* A sub-menu for the Blueprints dropdown, facilitates all the sub-menu actions such as creating, editing, and selecting classes for the world settings game mode.
*
* @param InMenuBuilder Object to append menu items/widgets to
* @param InCommandList Commandlist for menu items
* @param InSettingsData All the data needed to create the menu actions
*/
void GetBlueprintSettingsSubMenu(FMenuBuilder& InMenuBuilder, const TSharedRef<FUICommandList> InCommandList, FBlueprintMenuSettings InSettingsData);
/** Returns TRUE if the class can be edited, always TRUE for Blueprints and for native classes a compiler must be present */
bool CanEditClass(UClass* InClass)
{
// For native classes, we can only edit them if a compiler is available
if(InClass && InClass->HasAllClassFlags(CLASS_Native))
{
return FSourceCodeNavigation::IsCompilerAvailable();
}
return true;
}
/** Returns TRUE if the GameMode's sub-class can be created or selected */
bool CanCreateSelectSubClass(UClass* InGameModeClass, bool bInIsProjectSettings)
{
// Can never create or select project settings sub-classes if the config file is not checked out
if(bInIsProjectSettings && !FLevelEditorActionCallbacks::CanSelectGameModeBlueprint())
{
return false;
}
// If the game mode class is native, we cannot set the sub class
if(!InGameModeClass || InGameModeClass->HasAllClassFlags(CLASS_Native))
{
return false;
}
return true;
}
/** Creates a tooltip for a submenu */
FText GetSubMenuTooltip(UClass* InClass, UClass* InRootClass, bool bInIsProjectSettings)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
FFormatNamedArguments Args;
Args.Add(TEXT("Class"), FText::FromString(InRootClass->GetName()));
Args.Add(TEXT("TargetLocation"), bInIsProjectSettings? LOCTEXT("Project", "project") : LOCTEXT("World", "world"));
return FText::Format(LOCTEXT("ClassSubmenu_Tooltip", "Select, edit, or create a new {Class} blueprint for the {TargetLocation}"), Args);
#undef LOCTEXT_NAMESPACE
}
/** Creates a tooltip for the create class submenu */
FText GetCreateMenuTooltip(UClass* InGameModeClass, UClass* InRootClass, bool bInIsProjectSettings)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
FText ResultText;
// Game modes can always be created and selected (providing the config is checked out, handled separately)
if(InRootClass != AGameModeBase::StaticClass() && InGameModeClass->HasAllClassFlags(CLASS_Native))
{
ResultText = LOCTEXT("CannotCreateClasses", "Cannot create classes when the game mode is a native class!");
}
else if(bInIsProjectSettings && !FLevelEditorActionCallbacks::CanSelectGameModeBlueprint())
{
ResultText = LOCTEXT("CannotCreateClasses_NeedsCheckOut", "Cannot create classes when the config file is not writable!");
}
else
{
FFormatNamedArguments Args;
Args.Add(TEXT("RootClass"), FText::FromString(InRootClass->GetName()));
Args.Add(TEXT("TargetLocation"), bInIsProjectSettings? LOCTEXT("Project", "project") : LOCTEXT("World", "world"));
ResultText = FText::Format( LOCTEXT("CreateClass_Tooltip", "Create a new {RootClass} based on a selected class and auto-assign it to the {TargetLocation}"), Args );
}
return ResultText;
#undef LOCTEXT_NAMESPACE
}
/** Creates a tooltip for the select class submenu */
FText GetSelectMenuTooltip(UClass* InGameModeClass, UClass* InRootClass, bool bInIsProjectSettings)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
FText ResultText;
// Game modes can always be created and selected (providing the config is checked out, handled separately)
if(InRootClass != AGameModeBase::StaticClass() && InGameModeClass->HasAllClassFlags(CLASS_Native))
{
ResultText = LOCTEXT("CannotSelectClasses", "Cannot select classes when the game mode is a native class!");
}
else if(bInIsProjectSettings && !FLevelEditorActionCallbacks::CanSelectGameModeBlueprint())
{
ResultText = LOCTEXT("CannotSelectClasses_NeedsCheckOut", "Cannot select classes when the config file is not writable!");
}
else
{
FFormatNamedArguments Args;
Args.Add(TEXT("RootClass"), FText::FromString(InRootClass->GetName()));
Args.Add(TEXT("TargetLocation"), bInIsProjectSettings? LOCTEXT("Project", "project") : LOCTEXT("World", "world"));
ResultText = FText::Format( LOCTEXT("SelectClass_Tooltip", "Select a new {RootClass} based on a selected class and auto-assign it to the {TargetLocation}"), Args );
}
return ResultText;
#undef LOCTEXT_NAMESPACE
}
void CreateGameModeSubMenu(FMenuBuilder& InMenuBuilder, TSharedRef<FUICommandList> InCommandList, TWeakPtr< SLevelEditor > InLevelEditor, bool bInProjectSettings)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
LevelEditorActionHelpers::FBlueprintMenuSettings GameModeMenuSettings;
GameModeMenuSettings.EditCommand =
FUIAction(
FExecuteAction::CreateStatic< TWeakPtr< SLevelEditor > >( &OpenGameModeBlueprint, InLevelEditor, bInProjectSettings )
);
GameModeMenuSettings.OnCreateClassPicked = FOnClassPicked::CreateStatic( &LevelEditorActionHelpers::OnCreateGameModeClassPicked, InLevelEditor, bInProjectSettings );
GameModeMenuSettings.OnSelectClassPicked = FOnClassPicked::CreateStatic( &LevelEditorActionHelpers::OnSelectGameModeClassPicked, InLevelEditor, bInProjectSettings );
GameModeMenuSettings.CurrentClass = LevelEditorActionHelpers::GetGameModeClass(InLevelEditor, bInProjectSettings);
GameModeMenuSettings.RootClass = AGameModeBase::StaticClass();
GameModeMenuSettings.LevelEditor = InLevelEditor;
GameModeMenuSettings.bIsProjectSettings = bInProjectSettings;
auto IsGameModeActive = [](TWeakPtr< SLevelEditor > InLevelEditorPtr, bool bInProjSettings)->bool
{
UClass* WorldSettingsGameMode = LevelEditorActionHelpers::GetGameModeClass(InLevelEditorPtr, false);
if((WorldSettingsGameMode == nullptr) ^ bInProjSettings ) //(WorldSettingsGameMode && !bInProjectSettings) || (!WorldSettingsGameMode && bInProjectSettings) )
{
return false;
}
return true;
};
InMenuBuilder.AddSubMenu( LevelEditorActionHelpers::GetOpenGameModeBlueprintLabel(InLevelEditor, bInProjectSettings),
GetSubMenuTooltip(GameModeMenuSettings.CurrentClass, GameModeMenuSettings.RootClass, bInProjectSettings),
FNewMenuDelegate::CreateStatic( &LevelEditorActionHelpers::GetBlueprintSettingsSubMenu, InCommandList, GameModeMenuSettings),
FUIAction(FExecuteAction(), FCanExecuteAction(), FIsActionChecked::CreateStatic(IsGameModeActive, InLevelEditor, bInProjectSettings)),
NAME_None, EUserInterfaceActionType::RadioButton );
#undef LOCTEXT_NAMESPACE
}
/**
* Builds the game mode's sub menu objects
*
* @param InMenuBuilder Object to append menu items/widgets to
* @param InCommandList Commandlist for menu items
* @param InSettingsData All the data needed to create the menu actions
*/
void GetGameModeSubMenu(FMenuBuilder& InMenuBuilder, const TSharedRef<FUICommandList> InCommandList, const FBlueprintMenuSettings& InSettingsData)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
// Game State
LevelEditorActionHelpers::FBlueprintMenuSettings GameStateMenuSettings;
GameStateMenuSettings.EditCommand =
FUIAction(
FExecuteAction::CreateStatic< TWeakPtr< SLevelEditor > >( &OpenGameStateBlueprint, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings )
);
GameStateMenuSettings.OnCreateClassPicked = FOnClassPicked::CreateStatic( &LevelEditorActionHelpers::OnCreateGameStateClassPicked, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings );
GameStateMenuSettings.OnSelectClassPicked = FOnClassPicked::CreateStatic( &LevelEditorActionHelpers::OnSelectGameStateClassPicked, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings );
GameStateMenuSettings.CurrentClass = LevelEditorActionHelpers::GetGameStateClass(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings);
GameStateMenuSettings.RootClass = AGameStateBase::StaticClass();
GameStateMenuSettings.LevelEditor = InSettingsData.LevelEditor;
GameStateMenuSettings.bIsProjectSettings = InSettingsData.bIsProjectSettings;
InMenuBuilder.AddSubMenu( LevelEditorActionHelpers::GetOpenGameStateBlueprintLabel(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings),
GetSubMenuTooltip(GameStateMenuSettings.CurrentClass, GameStateMenuSettings.RootClass, InSettingsData.bIsProjectSettings),
FNewMenuDelegate::CreateStatic( &LevelEditorActionHelpers::GetBlueprintSettingsSubMenu, InCommandList, GameStateMenuSettings )
);
// Pawn
LevelEditorActionHelpers::FBlueprintMenuSettings PawnMenuSettings;
PawnMenuSettings.EditCommand =
FUIAction(
FExecuteAction::CreateStatic< TWeakPtr< SLevelEditor > >( &OpenDefaultPawnBlueprint, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings )
);
PawnMenuSettings.OnCreateClassPicked = FOnClassPicked::CreateStatic( &LevelEditorActionHelpers::OnCreatePawnClassPicked, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings );
PawnMenuSettings.OnSelectClassPicked = FOnClassPicked::CreateStatic( &LevelEditorActionHelpers::OnSelectPawnClassPicked, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings );
PawnMenuSettings.CurrentClass = LevelEditorActionHelpers::GetPawnClass(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings);
PawnMenuSettings.RootClass = APawn::StaticClass();
PawnMenuSettings.LevelEditor = InSettingsData.LevelEditor;
PawnMenuSettings.bIsProjectSettings = InSettingsData.bIsProjectSettings;
InMenuBuilder.AddSubMenu( LevelEditorActionHelpers::GetOpenPawnBlueprintLabel(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings),
GetSubMenuTooltip(PawnMenuSettings.CurrentClass, PawnMenuSettings.RootClass, InSettingsData.bIsProjectSettings),
FNewMenuDelegate::CreateStatic( &LevelEditorActionHelpers::GetBlueprintSettingsSubMenu, InCommandList, PawnMenuSettings )
);
// HUD
LevelEditorActionHelpers::FBlueprintMenuSettings HUDMenuSettings;
HUDMenuSettings.EditCommand =
FUIAction(
FExecuteAction::CreateStatic< TWeakPtr< SLevelEditor > >( &OpenHUDBlueprint, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings )
);
HUDMenuSettings.OnCreateClassPicked = FOnClassPicked::CreateStatic( &LevelEditorActionHelpers::OnCreateHUDClassPicked, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings );
HUDMenuSettings.OnSelectClassPicked = FOnClassPicked::CreateStatic( &LevelEditorActionHelpers::OnSelectHUDClassPicked, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings );
HUDMenuSettings.CurrentClass = LevelEditorActionHelpers::GetHUDClass(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings);
HUDMenuSettings.RootClass = AHUD::StaticClass();
HUDMenuSettings.LevelEditor = InSettingsData.LevelEditor;
HUDMenuSettings.bIsProjectSettings = InSettingsData.bIsProjectSettings;
InMenuBuilder.AddSubMenu( LevelEditorActionHelpers::GetOpenHUDBlueprintLabel(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings),
GetSubMenuTooltip(HUDMenuSettings.CurrentClass, HUDMenuSettings.RootClass, InSettingsData.bIsProjectSettings),
FNewMenuDelegate::CreateStatic( &LevelEditorActionHelpers::GetBlueprintSettingsSubMenu, InCommandList, HUDMenuSettings )
);
// Player Controller
LevelEditorActionHelpers::FBlueprintMenuSettings PlayerControllerMenuSettings;
PlayerControllerMenuSettings.EditCommand =
FUIAction(
FExecuteAction::CreateStatic< TWeakPtr< SLevelEditor > >( &OpenPlayerControllerBlueprint, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings )
);
PlayerControllerMenuSettings.OnCreateClassPicked = FOnClassPicked::CreateStatic( &LevelEditorActionHelpers::OnCreatePlayerControllerClassPicked, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings );
PlayerControllerMenuSettings.OnSelectClassPicked = FOnClassPicked::CreateStatic( &LevelEditorActionHelpers::OnSelectPlayerControllerClassPicked, InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings );
PlayerControllerMenuSettings.CurrentClass = LevelEditorActionHelpers::GetPlayerControllerClass(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings);
PlayerControllerMenuSettings.RootClass = APlayerController::StaticClass();
PlayerControllerMenuSettings.LevelEditor = InSettingsData.LevelEditor;
PlayerControllerMenuSettings.bIsProjectSettings = InSettingsData.bIsProjectSettings;
InMenuBuilder.AddSubMenu( LevelEditorActionHelpers::GetOpenPlayerControllerBlueprintLabel(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings),
GetSubMenuTooltip(PlayerControllerMenuSettings.CurrentClass, PlayerControllerMenuSettings.RootClass, InSettingsData.bIsProjectSettings),
FNewMenuDelegate::CreateStatic( &LevelEditorActionHelpers::GetBlueprintSettingsSubMenu, InCommandList, PlayerControllerMenuSettings )
);
#undef LOCTEXT_NAMESPACE
}
}
void LevelEditorActionHelpers::GetBlueprintSettingsSubMenu(FMenuBuilder& InMenuBuilder, const TSharedRef<FUICommandList> InCommandList, FBlueprintMenuSettings InSettingsData)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
InMenuBuilder.PushCommandList(InCommandList);
FSlateIcon EditBPIcon(FEditorStyle::Get().GetStyleSetName(), TEXT("PropertyWindow.Button_Edit"));
FSlateIcon NewBPIcon(FEditorStyle::Get().GetStyleSetName(), TEXT("PropertyWindow.Button_AddToArray"));
FText RootClassName = FText::FromString(InSettingsData.RootClass->GetName());
// If there is currently a valid GameMode Blueprint, offer to edit the Blueprint
if(InSettingsData.CurrentClass)
{
FFormatNamedArguments Args;
Args.Add(TEXT("RootClass"), RootClassName);
Args.Add(TEXT("TargetLocation"), InSettingsData.bIsProjectSettings? LOCTEXT("Project", "project") : LOCTEXT("World", "world"));
if(InSettingsData.CurrentClass->ClassGeneratedBy)
{
FText BlueprintName = FText::FromString(InSettingsData.CurrentClass->ClassGeneratedBy->GetName());
Args.Add(TEXT("Blueprint"), BlueprintName);
InMenuBuilder.AddMenuEntry( FText::Format( LOCTEXT("EditBlueprint", "Edit {Blueprint}"), Args), FText::Format( LOCTEXT("EditBlueprint_Tooltip", "Open the {TargetLocation}'s assigned {RootClass} blueprint"), Args), EditBPIcon, InSettingsData.EditCommand );
}
else
{
FText ClassName = FText::FromString(InSettingsData.CurrentClass->GetName());
Args.Add(TEXT("Class"), ClassName);
FText MenuDescription = FText::Format( LOCTEXT("EditNativeClass", "Edit {Class}.h"), Args);
if(FSourceCodeNavigation::IsCompilerAvailable())
{
InMenuBuilder.AddMenuEntry( MenuDescription, FText::Format( LOCTEXT("EditNativeClass_Tooltip", "Open the {TargetLocation}'s assigned {RootClass} header"), Args), EditBPIcon, InSettingsData.EditCommand );
}
else
{
auto CannotEditClass = []() -> bool
{
return false;
};
// There is no compiler present, this is always disabled with a tooltip to explain why
InMenuBuilder.AddMenuEntry( MenuDescription, FText::Format( LOCTEXT("CannotEditNativeClass_Tooltip", "Cannot edit the {TargetLocation}'s assigned {RootClass} header because no compiler is present!"), Args), EditBPIcon, FUIAction(FExecuteAction(), FCanExecuteAction::CreateStatic(CannotEditClass)) );
}
}
}
if(InSettingsData.bIsProjectSettings && InSettingsData.CurrentClass && InSettingsData.CurrentClass->IsChildOf(AGameModeBase::StaticClass()) && !FLevelEditorActionCallbacks::CanSelectGameModeBlueprint())
{
InMenuBuilder.BeginSection("CheckoutSection", LOCTEXT("CheckoutSection","Check Out Project Settings") );
TAttribute<FText> CheckOutLabel;
CheckOutLabel.BindStatic(&GetCheckOutLabel);
TAttribute<FText> CheckOutTooltip;
CheckOutTooltip.BindStatic(&GetCheckOutTooltip);
InMenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().CheckOutProjectSettingsConfig, NAME_None, CheckOutLabel, CheckOutTooltip, FSlateIcon(FEditorStyle::Get().GetStyleSetName(), TEXT("Icons.Error")));
InMenuBuilder.EndSection();
}
auto CannotCreateSelectNativeProjectGameMode = [](bool bInIsProjectSettings) -> bool
{
// For the project settings, we can only create/select the game mode class if the config is writable
if(bInIsProjectSettings)
{
return FLevelEditorActionCallbacks::CanSelectGameModeBlueprint();
}
return true;
};
// Create a new GameMode, this is always available so the user can easily create a new one
InMenuBuilder.AddSubMenu( LOCTEXT("CreateBlueprint", "Create..."),
GetCreateMenuTooltip(GetGameModeClass(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings), InSettingsData.RootClass, InSettingsData.bIsProjectSettings),
FNewMenuDelegate::CreateStatic( &LevelEditorActionHelpers::GetCreateSettingsClassSubMenu, InSettingsData.RootClass, InSettingsData.OnCreateClassPicked ),
FUIAction(
FExecuteAction(),
InSettingsData.RootClass == AGameModeBase::StaticClass()?
FCanExecuteAction::CreateStatic(CannotCreateSelectNativeProjectGameMode, InSettingsData.bIsProjectSettings)
: FCanExecuteAction::CreateStatic( &CanCreateSelectSubClass, GetGameModeClass(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings), InSettingsData.bIsProjectSettings )
),
NAME_None, EUserInterfaceActionType::Button, false, NewBPIcon
);
// Select a game mode, this is always available so the user can switch his selection
FFormatNamedArguments Args;
Args.Add(TEXT("RootClass"),RootClassName);
InMenuBuilder.AddSubMenu( FText::Format( LOCTEXT("SelectGameModeClass", "Select {RootClass} Class"), Args ),
GetSelectMenuTooltip(GetGameModeClass(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings), InSettingsData.RootClass, InSettingsData.bIsProjectSettings),
FNewMenuDelegate::CreateStatic( &LevelEditorActionHelpers::GetSelectSettingsClassSubMenu, InSettingsData.RootClass, InSettingsData.OnSelectClassPicked ),
FUIAction(
FExecuteAction(),
InSettingsData.RootClass == AGameModeBase::StaticClass()?
FCanExecuteAction::CreateStatic(CannotCreateSelectNativeProjectGameMode, InSettingsData.bIsProjectSettings)
: FCanExecuteAction::CreateStatic( &CanCreateSelectSubClass, GetGameModeClass(InSettingsData.LevelEditor, InSettingsData.bIsProjectSettings), InSettingsData.bIsProjectSettings )
),
NAME_None, EUserInterfaceActionType::Button
);
// For GameMode classes only, there are some sub-classes we need to add to the menu
if(InSettingsData.RootClass == AGameModeBase::StaticClass())
{
InMenuBuilder.BeginSection(NAME_None, LOCTEXT("GameModeClasses", "Game Mode Classes"));
if(InSettingsData.CurrentClass)
{
GetGameModeSubMenu(InMenuBuilder, InCommandList, InSettingsData);
}
InMenuBuilder.EndSection();
}
InMenuBuilder.PopCommandList();
#undef LOCTEXT_NAMESPACE
}
UClass* LevelEditorActionHelpers::GetGameModeClass(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
UClass* GameModeClass = nullptr;
if(bInIsProjectSettings)
{
UObject* GameModeObject = LoadObject<UObject>(nullptr, *UGameMapsSettings::GetGlobalDefaultGameMode());
if(UBlueprint* GameModeAsBlueprint = Cast<UBlueprint>(GameModeObject))
{
GameModeClass = GameModeAsBlueprint->GeneratedClass;
}
else
{
GameModeClass = FindObject<UClass>(nullptr, *UGameMapsSettings::GetGlobalDefaultGameMode());
}
}
else
{
AWorldSettings* WorldSettings = InLevelEditor.Pin()->GetWorld()->GetWorldSettings();
if(WorldSettings->DefaultGameMode)
{
GameModeClass = WorldSettings->DefaultGameMode;
}
}
return GameModeClass;
}
FText LevelEditorActionHelpers::GetOpenGameModeBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
if(UClass* GameModeClass = GetGameModeClass(InLevelEditor, bInIsProjectSettings))
{
if(GameModeClass->ClassGeneratedBy)
{
return FText::Format( LOCTEXT("GameModeEditBlueprint", "GameMode: Edit {0}"), FText::FromString(GameModeClass->ClassGeneratedBy->GetName()));
}
return FText::Format( LOCTEXT("GameModeBlueprint", "GameMode: {0}"), FText::FromString(GameModeClass->GetName()));
}
if(bInIsProjectSettings)
{
return LOCTEXT("GameModeCreateBlueprint", "GameMode: New...");
}
// For World Settings, we want to inform the user that they are not overridding the Project Settings
return LOCTEXT("GameModeNotOverridden", "GameMode: Not overridden!");
#undef LOCTEXT_NAMESPACE
}
void LevelEditorActionHelpers::OnCreateGameModeClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(InChosenClass)
{
const FString NewBPName(TEXT("NewGameMode"));
UBlueprint* Blueprint = FKismetEditorUtilities::CreateBlueprintFromClass(NSLOCTEXT("LevelEditorCommands", "CreateGameModeBlueprint_Title", "Create GameMode Blueprint"), InChosenClass, NewBPName);
if(Blueprint)
{
// @todo Re-enable once world centric works
const bool bOpenWorldCentric = false;
FAssetEditorManager::Get().OpenEditorForAsset(
Blueprint,
bOpenWorldCentric ? EToolkitMode::WorldCentric : EToolkitMode::Standalone,
InLevelEditor.Pin() );
OnSelectGameModeClassPicked(Blueprint->GeneratedClass, InLevelEditor, bInIsProjectSettings);
}
}
FSlateApplication::Get().DismissAllMenus();
}
void LevelEditorActionHelpers::OnSelectGameModeClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(bInIsProjectSettings)
{
UGameMapsSettings::SetGlobalDefaultGameMode(InChosenClass? InChosenClass->GetPathName() : FString());
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
if (SettingsModule != nullptr)
{
ISettingsContainerPtr SettingsContainer = SettingsModule->GetContainer("Project");
if (SettingsContainer.IsValid())
{
ISettingsCategoryPtr SettingsCategory = SettingsContainer->GetCategory("Project");
if(SettingsCategory.IsValid())
{
SettingsCategory->GetSection("Maps")->Save();
}
}
}
}
else
{
const FScopedTransaction Transaction( NSLOCTEXT("LevelEditorCommands", "SelectGameModeClassAction", "Set Override Game Mode Class") );
AWorldSettings* WorldSettings = InLevelEditor.Pin()->GetWorld()->GetWorldSettings();
WorldSettings->Modify();
WorldSettings->DefaultGameMode = InChosenClass;
}
FSlateApplication::Get().DismissAllMenus();
}
UClass* LevelEditorActionHelpers::GetGameStateClass(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(UClass* GameModeClass = GetGameModeClass(InLevelEditor, bInIsProjectSettings))
{
AGameModeBase* ActiveGameMode = Cast<AGameModeBase>(GameModeClass->GetDefaultObject());
if(ActiveGameMode)
{
return ActiveGameMode->GameStateClass;
}
}
return NULL;
}
FText LevelEditorActionHelpers::GetOpenGameStateBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
if(UClass* GameStateClass = GetGameStateClass(InLevelEditor, bInIsProjectSettings))
{
FFormatNamedArguments FormatArgs;
if(GameStateClass->ClassGeneratedBy)
{
FormatArgs.Add(TEXT("GameStateName"), FText::FromString(GameStateClass->ClassGeneratedBy->GetName()));
return FText::Format( LOCTEXT("GameStateEditBlueprint", "GameState: Edit {GameStateName}"), FormatArgs);
}
FormatArgs.Add(TEXT("GameStateName"), FText::FromString(GameStateClass->GetName()));
return FText::Format( LOCTEXT("GameStateBlueprint", "GameState: {GameStateName}"), FormatArgs);
}
return LOCTEXT("GameStateCreateBlueprint", "GameState: New...");
#undef LOCTEXT_NAMESPACE
}
void LevelEditorActionHelpers::OnCreateGameStateClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(InChosenClass)
{
const FString NewBPName(TEXT("NewGameState"));
UBlueprint* Blueprint = FKismetEditorUtilities::CreateBlueprintFromClass(NSLOCTEXT("LevelEditorCommands", "CreateGameStateBlueprint_Title", "Create GameState Blueprint"), InChosenClass, NewBPName);
if(Blueprint)
{
// @todo Re-enable once world centric works
const bool bOpenWorldCentric = false;
FAssetEditorManager::Get().OpenEditorForAsset(
Blueprint,
bOpenWorldCentric ? EToolkitMode::WorldCentric : EToolkitMode::Standalone,
InLevelEditor.Pin() );
OnSelectGameStateClassPicked(Blueprint->GeneratedClass, InLevelEditor, bInIsProjectSettings);
}
}
FSlateApplication::Get().DismissAllMenus();
}
void LevelEditorActionHelpers::OnSelectGameStateClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(UClass* GameModeClass = GetGameModeClass(InLevelEditor, bInIsProjectSettings))
{
const FScopedTransaction Transaction( NSLOCTEXT("LevelEditorCommands", "SelectGameStateClassAction", "Set Game State Class") );
AGameModeBase* ActiveGameMode = Cast<AGameModeBase>(GameModeClass->GetDefaultObject());
ActiveGameMode->GameStateClass = InChosenClass;
UBlueprint* Blueprint = Cast<UBlueprint>(GameModeClass->ClassGeneratedBy);
if (ensure(Blueprint))
{
FBlueprintEditorUtils::MarkBlueprintAsModified(Blueprint);
}
}
FSlateApplication::Get().DismissAllMenus();
}
UClass* LevelEditorActionHelpers::GetPawnClass(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(UClass* GameModeClass = GetGameModeClass(InLevelEditor, bInIsProjectSettings))
{
AGameModeBase* ActiveGameMode = Cast<AGameModeBase>(GameModeClass->GetDefaultObject());
if(ActiveGameMode)
{
return ActiveGameMode->DefaultPawnClass;
}
}
return NULL;
}
FText LevelEditorActionHelpers::GetOpenPawnBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
if(UClass* PawnClass = GetPawnClass(InLevelEditor, bInIsProjectSettings))
{
FFormatNamedArguments FormatArgs;
if(PawnClass->ClassGeneratedBy)
{
FormatArgs.Add(TEXT("PawnName"), FText::FromString(PawnClass->ClassGeneratedBy->GetName()));
return FText::Format( LOCTEXT("PawnEditBlueprint", "Pawn: Edit {PawnName}"), FormatArgs);
}
FormatArgs.Add(TEXT("PawnName"), FText::FromString(PawnClass->GetName()));
return FText::Format( LOCTEXT("PawnBlueprint", "Pawn: {PawnName}"), FormatArgs);
}
return LOCTEXT("PawnCreateBlueprint", "Pawn: New...");
#undef LOCTEXT_NAMESPACE
}
void LevelEditorActionHelpers::OnCreatePawnClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(InChosenClass)
{
const FString NewBPName(TEXT("NewPawn"));
UBlueprint* Blueprint = FKismetEditorUtilities::CreateBlueprintFromClass(NSLOCTEXT("LevelEditorCommands", "CreatePawnBlueprint_Title", "Create Pawn Blueprint"), InChosenClass, NewBPName);
if(Blueprint)
{
// @todo Re-enable once world centric works
const bool bOpenWorldCentric = false;
FAssetEditorManager::Get().OpenEditorForAsset(
Blueprint,
bOpenWorldCentric ? EToolkitMode::WorldCentric : EToolkitMode::Standalone,
InLevelEditor.Pin() );
OnSelectPawnClassPicked(Blueprint->GeneratedClass, InLevelEditor, bInIsProjectSettings);
}
}
FSlateApplication::Get().DismissAllMenus();
}
void LevelEditorActionHelpers::OnSelectPawnClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(UClass* GameModeClass = GetGameModeClass(InLevelEditor, bInIsProjectSettings))
{
const FScopedTransaction Transaction( NSLOCTEXT("LevelEditorCommands", "SelectPawnClassAction", "Set Pawn Class") );
AGameModeBase* ActiveGameMode = Cast<AGameModeBase>(GameModeClass->GetDefaultObject());
ActiveGameMode->DefaultPawnClass = InChosenClass;
UBlueprint* Blueprint = Cast<UBlueprint>(GameModeClass->ClassGeneratedBy);
if (ensure(Blueprint))
{
FBlueprintEditorUtils::MarkBlueprintAsModified(Blueprint);
}
}
FSlateApplication::Get().DismissAllMenus();
}
UClass* LevelEditorActionHelpers::GetHUDClass(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(UClass* GameModeClass = GetGameModeClass(InLevelEditor, bInIsProjectSettings))
{
AGameModeBase* ActiveGameMode = Cast<AGameModeBase>(GameModeClass->GetDefaultObject());
if(ActiveGameMode)
{
return ActiveGameMode->HUDClass;
}
}
return NULL;
}
FText LevelEditorActionHelpers::GetOpenHUDBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
if(UClass* HUDClass = GetHUDClass(InLevelEditor, bInIsProjectSettings))
{
FFormatNamedArguments FormatArgs;
if(HUDClass->ClassGeneratedBy)
{
FormatArgs.Add(TEXT("HUDName"), FText::FromString(HUDClass->ClassGeneratedBy->GetName()));
return FText::Format( LOCTEXT("HUDEditBlueprint", "HUD: Edit {HUDName}"), FormatArgs);
}
FormatArgs.Add(TEXT("HUDName"), FText::FromString(HUDClass->GetName()));
return FText::Format( LOCTEXT("HUDBlueprint", "HUD: {HUDName}"), FormatArgs);
}
return LOCTEXT("HUDCreateBlueprint", "HUD: New...");
#undef LOCTEXT_NAMESPACE
}
void LevelEditorActionHelpers::OnCreateHUDClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(InChosenClass)
{
const FString NewBPName(TEXT("NewHUD"));
UBlueprint* Blueprint = FKismetEditorUtilities::CreateBlueprintFromClass(NSLOCTEXT("LevelEditorCommands", "CreateHUDBlueprint_Title", "Create HUD Blueprint"), InChosenClass, NewBPName);
if(Blueprint)
{
// @todo Re-enable once world centric works
const bool bOpenWorldCentric = false;
FAssetEditorManager::Get().OpenEditorForAsset(
Blueprint,
bOpenWorldCentric ? EToolkitMode::WorldCentric : EToolkitMode::Standalone,
InLevelEditor.Pin() );
OnSelectHUDClassPicked(Blueprint->GeneratedClass, InLevelEditor, bInIsProjectSettings);
}
}
FSlateApplication::Get().DismissAllMenus();
}
void LevelEditorActionHelpers::OnSelectHUDClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(UClass* GameModeClass = GetGameModeClass(InLevelEditor, bInIsProjectSettings))
{
const FScopedTransaction Transaction( NSLOCTEXT("LevelEditorCommands", "SelectHUDClassAction", "Set HUD Class") );
AGameModeBase* ActiveGameMode = Cast<AGameModeBase>(GameModeClass->GetDefaultObject());
ActiveGameMode->HUDClass = InChosenClass;
UBlueprint* Blueprint = Cast<UBlueprint>(GameModeClass->ClassGeneratedBy);
if (ensure(Blueprint))
{
FBlueprintEditorUtils::MarkBlueprintAsModified(Blueprint);
}
}
FSlateApplication::Get().DismissAllMenus();
}
UClass* LevelEditorActionHelpers::GetPlayerControllerClass(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(UClass* GameModeClass = GetGameModeClass(InLevelEditor, bInIsProjectSettings))
{
AGameModeBase* ActiveGameMode = Cast<AGameModeBase>(GameModeClass->GetDefaultObject());
if(ActiveGameMode)
{
return ActiveGameMode->PlayerControllerClass;
}
}
return NULL;
}
FText LevelEditorActionHelpers::GetOpenPlayerControllerBlueprintLabel(TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
if(UClass* PlayerControllerClass = GetPlayerControllerClass(InLevelEditor, bInIsProjectSettings))
{
FFormatNamedArguments FormatArgs;
if(PlayerControllerClass->ClassGeneratedBy)
{
FormatArgs.Add(TEXT("PlayerControllerName"), FText::FromString(PlayerControllerClass->ClassGeneratedBy->GetName()));
return FText::Format( LOCTEXT("PlayerControllerEditBlueprint", "PlayerController: Edit {PlayerControllerName}"), FormatArgs);
}
FormatArgs.Add(TEXT("PlayerControllerName"), FText::FromString(PlayerControllerClass->GetName()));
return FText::Format( LOCTEXT("PlayerControllerBlueprint", "PlayerController: {PlayerControllerName}"), FormatArgs);
}
return LOCTEXT("PlayerControllerCreateBlueprint", "PlayerController: New...");
#undef LOCTEXT_NAMESPACE
}
void LevelEditorActionHelpers::OnCreatePlayerControllerClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(InChosenClass)
{
const FString NewBPName(TEXT("NewPlayerController"));
UBlueprint* Blueprint = FKismetEditorUtilities::CreateBlueprintFromClass(NSLOCTEXT("LevelEditorCommands", "CreatePlayerControllerBlueprint_Title", "Create PlayerController Blueprint"), InChosenClass, NewBPName);
if(Blueprint)
{
// @todo Re-enable once world centric works
const bool bOpenWorldCentric = false;
FAssetEditorManager::Get().OpenEditorForAsset(
Blueprint,
bOpenWorldCentric ? EToolkitMode::WorldCentric : EToolkitMode::Standalone,
InLevelEditor.Pin() );
OnSelectPlayerControllerClassPicked(Blueprint->GeneratedClass, InLevelEditor, bInIsProjectSettings);
}
}
FSlateApplication::Get().DismissAllMenus();
}
void LevelEditorActionHelpers::OnSelectPlayerControllerClassPicked(UClass* InChosenClass, TWeakPtr< SLevelEditor > InLevelEditor, bool bInIsProjectSettings)
{
if(UClass* GameModeClass = GetGameModeClass(InLevelEditor, bInIsProjectSettings))
{
const FScopedTransaction Transaction( NSLOCTEXT("LevelEditorCommands", "SelectPlayerControllerClassAction", "Set Player Controller Class") );
AGameModeBase* ActiveGameMode = Cast<AGameModeBase>(GameModeClass->GetDefaultObject());
ActiveGameMode->PlayerControllerClass = InChosenClass;
UBlueprint* Blueprint = Cast<UBlueprint>(GameModeClass->ClassGeneratedBy);
if (ensure(Blueprint))
{
FBlueprintEditorUtils::MarkBlueprintAsModified(Blueprint);
}
}
FSlateApplication::Get().DismissAllMenus();
}
/**
* Static: Creates a widget for the level editor tool bar
*
* @return New widget
*/
TSharedRef< SWidget > FLevelEditorToolBar::MakeLevelEditorToolBar( const TSharedRef<FUICommandList>& InCommandList, const TSharedRef<SLevelEditor> InLevelEditor )
{
#define LOCTEXT_NAMESPACE "LevelEditorToolBar"
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
TSharedPtr<FExtender> Extenders = LevelEditorModule.GetToolBarExtensibilityManager()->GetAllExtenders();
static const FName LevelEditorToolBarName = "LevelEditorToolBar";
FToolBarBuilder ToolbarBuilder( InCommandList, FMultiBoxCustomization::AllowCustomization( LevelEditorToolBarName ), Extenders );
ToolbarBuilder.BeginSection("File");
{
// Save All Levels
ToolbarBuilder.AddToolBarButton( FLevelEditorCommands::Get().Save, NAME_None, TAttribute<FText>(), TAttribute<FText>(), FSlateIcon(FEditorStyle::GetStyleSetName(), "AssetEditor.SaveAsset") );
// Source control buttons
{
enum EQueryState
{
NotQueried,
Querying,
Queried,
};
static EQueryState QueryState = EQueryState::NotQueried;
struct FSourceControlStatus
{
static void CheckSourceControlStatus()
{
ISourceControlModule& SourceControlModule = ISourceControlModule::Get();
if (SourceControlModule.IsEnabled())
{
SourceControlModule.GetProvider().Execute(ISourceControlOperation::Create<FConnect>(),
EConcurrency::Asynchronous,
FSourceControlOperationComplete::CreateStatic(&FSourceControlStatus::OnSourceControlOperationComplete));
QueryState = EQueryState::Querying;
}
}
static void OnSourceControlOperationComplete(const FSourceControlOperationRef& InOperation, ECommandResult::Type InResult)
{
QueryState = EQueryState::Queried;
}
static FText GetSourceControlTooltip()
{
if (QueryState == EQueryState::Querying)
{
return LOCTEXT("SourceControlUnknown", "Source control status is unknown");
}
else
{
return ISourceControlModule::Get().GetProvider().GetStatusText();
}
}
static FSlateIcon GetSourceControlIcon()
{
if (QueryState == EQueryState::Querying)
{
return FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.SourceControl.Unknown");
}
else
{
ISourceControlModule& SourceControlModule = ISourceControlModule::Get();
if (SourceControlModule.IsEnabled())
{
if (!SourceControlModule.GetProvider().IsAvailable())
{
return FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.SourceControl.Error");
}
else
{
return FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.SourceControl.On");
}
}
else
{
return FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.SourceControl.Off");
}
}
}
};
FSourceControlStatus::CheckSourceControlStatus();
ToolbarBuilder.AddComboButton(
FUIAction(),
FOnGetContent::CreateStatic(&FLevelEditorToolBar::GenerateSourceControlMenu, InCommandList),
LOCTEXT("SourceControl_Label", "Source Control"),
TAttribute<FText>::Create(&FSourceControlStatus::GetSourceControlTooltip),
TAttribute<FSlateIcon>::Create(&FSourceControlStatus::GetSourceControlIcon),
false
);
}
}
ToolbarBuilder.EndSection();
ToolbarBuilder.BeginSection("Content");
{
ToolbarBuilder.AddToolBarButton( FLevelEditorCommands::Get().OpenContentBrowser, NAME_None, LOCTEXT( "ContentBrowser_Override", "Content" ), TAttribute<FText>(), TAttribute<FSlateIcon>(), "LevelToolbarContent" );
if (FDesktopPlatformModule::Get()->CanOpenLauncher(true))
{
ToolbarBuilder.AddToolBarButton(FLevelEditorCommands::Get().OpenMarketplace, NAME_None, LOCTEXT("Marketplace_Override", "Marketplace"), TAttribute<FText>(), TAttribute<FSlateIcon>(), "LevelToolbarMarketplace");
}
}
ToolbarBuilder.EndSection();
ToolbarBuilder.BeginSection("Settings");
{
ToolbarBuilder.AddComboButton(
FUIAction(),
FOnGetContent::CreateStatic(&FLevelEditorToolBar::GenerateQuickSettingsMenu, InCommandList),
LOCTEXT("QuickSettingsCombo", "Settings"),
LOCTEXT("QuickSettingsCombo_ToolTip", "Project and Editor settings"),
FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.GameSettings"),
false,
"LevelToolbarQuickSettings"
);
}
ToolbarBuilder.EndSection();
ToolbarBuilder.BeginSection( NAME_None );
{
ToolbarBuilder.AddComboButton(
FUIAction(),
FOnGetContent::CreateStatic( &FLevelEditorToolBar::GenerateOpenBlueprintMenuContent, InCommandList, TWeakPtr<SLevelEditor>( InLevelEditor ) ),
LOCTEXT( "OpenBlueprint_Label", "Blueprints" ),
LOCTEXT( "OpenBlueprint_ToolTip", "List of world Blueprints available to the user for editing or creation." ),
FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.OpenLevelBlueprint")
);
ToolbarBuilder.AddComboButton(
FUIAction(),
FOnGetContent::CreateStatic( &FLevelEditorToolBar::GenerateCinematicsMenuContent, InCommandList, TWeakPtr<SLevelEditor>( InLevelEditor ) ),
LOCTEXT( "EditCinematics_Label", "Cinematics" ),
LOCTEXT( "EditCinematics_Tooltip", "Displays a list of Matinee and Level Sequence objects to open in their respective editors"),
FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.EditMatinee")
);
ToolbarBuilder.AddToolBarButton( FLevelEditorCommands::Get().ToggleVR, NAME_None, LOCTEXT("ToggleVR", "VR Mode") );
}
ToolbarBuilder.EndSection();
ToolbarBuilder.BeginSection("Compile");
{
// Build
ToolbarBuilder.AddToolBarButton( FLevelEditorCommands::Get().Build, NAME_None, LOCTEXT("BuildAll", "Build") );
// Build menu drop down
ToolbarBuilder.AddComboButton(
FUIAction(),
FOnGetContent::CreateStatic( &FLevelEditorToolBar::GenerateBuildMenuContent, InCommandList ),
LOCTEXT( "BuildCombo_Label", "Build Options" ),
LOCTEXT( "BuildComboToolTip", "Build options menu" ),
FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Build"),
true);
// Only show the compile options on machines with the solution (assuming they can build it)
if ( FSourceCodeNavigation::IsCompilerAvailable() )
{
// Since we can always add new code to the project, only hide these buttons if we haven't done so yet
ToolbarBuilder.AddToolBarButton(
FUIAction(
FExecuteAction::CreateStatic(&FLevelEditorActionCallbacks::RecompileGameCode_Clicked),
FCanExecuteAction::CreateStatic(&FLevelEditorActionCallbacks::Recompile_CanExecute),
FIsActionChecked(),
FIsActionButtonVisible::CreateStatic(FLevelEditorActionCallbacks::CanShowSourceCodeActions)),
NAME_None,
LOCTEXT( "CompileMenuButton", "Compile" ),
FLevelEditorCommands::Get().RecompileGameCode->GetDescription(),
FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Recompile")
);
}
}
ToolbarBuilder.EndSection();
ToolbarBuilder.BeginSection("Game");
{
// Add the shared play-world commands that will be shown on the Kismet toolbar as well
FPlayWorldCommands::BuildToolbar(ToolbarBuilder, true);
}
ToolbarBuilder.EndSection();
// Create the tool bar!
return
SNew( SBorder )
.Padding(0)
.BorderImage( FEditorStyle::GetBrush("NoBorder") )
.IsEnabled( FSlateApplication::Get().GetNormalExecutionAttribute() )
[
ToolbarBuilder.MakeWidget()
];
#undef LOCTEXT_NAMESPACE
}
TSharedRef< SWidget > FLevelEditorToolBar::GenerateBuildMenuContent( TSharedRef<FUICommandList> InCommandList )
{
#define LOCTEXT_NAMESPACE "LevelToolBarBuildMenu"
// Get all menu extenders for this context menu from the level editor module
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>( TEXT("LevelEditor") );
TArray<FLevelEditorModule::FLevelEditorMenuExtender> MenuExtenderDelegates = LevelEditorModule.GetAllLevelEditorToolbarBuildMenuExtenders();
TArray<TSharedPtr<FExtender>> Extenders;
for (int32 i = 0; i < MenuExtenderDelegates.Num(); ++i)
{
if (MenuExtenderDelegates[i].IsBound())
{
Extenders.Add(MenuExtenderDelegates[i].Execute(InCommandList));
}
}
TSharedPtr<FExtender> MenuExtender = FExtender::Combine(Extenders);
const bool bShouldCloseWindowAfterMenuSelection = true;
FMenuBuilder MenuBuilder( bShouldCloseWindowAfterMenuSelection, InCommandList, MenuExtender );
struct FLightingMenus
{
/** Generates a lighting quality sub-menu */
static void MakeLightingQualityMenu( FMenuBuilder& InMenuBuilder )
{
InMenuBuilder.BeginSection("LevelEditorBuildLightingQuality", LOCTEXT( "LightingQualityHeading", "Quality Level" ) );
{
InMenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingQuality_Production );
InMenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingQuality_High );
InMenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingQuality_Medium );
InMenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingQuality_Preview );
}
InMenuBuilder.EndSection();
}
/** Generates a lighting density sub-menu */
static void MakeLightingDensityMenu( FMenuBuilder& InMenuBuilder )
{
InMenuBuilder.BeginSection("LevelEditorBuildLightingDensity", LOCTEXT( "LightingDensityHeading", "Density Rendering" ) );
{
TSharedRef<SWidget> Ideal = SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.Padding( FMargin( 27.0f, 0.0f, 0.0f, 0.0f ) )
.FillWidth(1.0f)
[
SNew(SSpinBox<float>)
.MinValue(0.f)
.MaxValue(100.f)
.Value(FLevelEditorActionCallbacks::GetLightingDensityIdeal())
.OnValueChanged_Static(&FLevelEditorActionCallbacks::SetLightingDensityIdeal)
];
InMenuBuilder.AddWidget(Ideal, LOCTEXT("LightingDensity_Ideal","Ideal Density"));
TSharedRef<SWidget> Maximum = SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.FillWidth(1.0f)
[
SNew(SSpinBox<float>)
.MinValue(0.01f)
.MaxValue(100.01f)
.Value(FLevelEditorActionCallbacks::GetLightingDensityMaximum())
.OnValueChanged_Static(&FLevelEditorActionCallbacks::SetLightingDensityMaximum)
];
InMenuBuilder.AddWidget(Maximum, LOCTEXT("LightingDensity_Maximum","Maximum Density"));
TSharedRef<SWidget> ClrScale = SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.Padding( FMargin( 35.0f, 0.0f, 0.0f, 0.0f ) )
.FillWidth(1.0f)
[
SNew(SSpinBox<float>)
.MinValue(0.f)
.MaxValue(10.f)
.Value(FLevelEditorActionCallbacks::GetLightingDensityColorScale())
.OnValueChanged_Static(&FLevelEditorActionCallbacks::SetLightingDensityColorScale)
];
InMenuBuilder.AddWidget(ClrScale, LOCTEXT("LightingDensity_ColorScale","Color Scale"));
TSharedRef<SWidget> GrayScale = SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.Padding( FMargin( 11.0f, 0.0f, 0.0f, 0.0f ) )
.FillWidth(1.0f)
[
SNew(SSpinBox<float>)
.MinValue(0.f)
.MaxValue(10.f)
.Value(FLevelEditorActionCallbacks::GetLightingDensityGrayscaleScale())
.OnValueChanged_Static(&FLevelEditorActionCallbacks::SetLightingDensityGrayscaleScale)
];
InMenuBuilder.AddWidget(GrayScale, LOCTEXT("LightingDensity_GrayscaleScale","Grayscale Scale"));
InMenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingDensity_RenderGrayscale );
}
InMenuBuilder.EndSection();
}
/** Generates a lighting resolution sub-menu */
static void MakeLightingResolutionMenu( FMenuBuilder& InMenuBuilder )
{
InMenuBuilder.BeginSection("LevelEditorBuildLightingResolution1", LOCTEXT( "LightingResolutionHeading1", "Primitive Types" ) );
{
TSharedRef<SWidget> Meshes = SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.AutoWidth()
[
SNew( SCheckBox )
.Style( FEditorStyle::Get(), "Menu.CheckBox" )
.ToolTipText(LOCTEXT( "StaticMeshesToolTip", "Static Meshes will be adjusted if checked." ))
.IsChecked_Static(&FLevelEditorActionCallbacks::IsLightingResolutionStaticMeshesChecked)
.OnCheckStateChanged_Static(&FLevelEditorActionCallbacks::SetLightingResolutionStaticMeshes)
.Content()
[
SNew( STextBlock )
.Text( LOCTEXT("StaticMeshes", "Static Meshes") )
]
]
+SHorizontalBox::Slot()
.AutoWidth()
.Padding( FMargin( 4.0f, 0.0f, 11.0f, 0.0f ) )
[
SNew(SSpinBox<float>)
.MinValue(4.f)
.MaxValue(4096.f)
.ToolTipText(LOCTEXT( "LightingResolutionStaticMeshesMinToolTip", "The minimum lightmap resolution for static mesh adjustments. Anything outside of Min/Max range will not be touched when adjusting." ))
.Value(FLevelEditorActionCallbacks::GetLightingResolutionMinSMs())
.OnValueChanged_Static(&FLevelEditorActionCallbacks::SetLightingResolutionMinSMs)
]
+SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SSpinBox<float>)
.MinValue(4.f)
.MaxValue(4096.f)
.ToolTipText(LOCTEXT( "LightingResolutionStaticMeshesMaxToolTip", "The maximum lightmap resolution for static mesh adjustments. Anything outside of Min/Max range will not be touched when adjusting." ))
.Value(FLevelEditorActionCallbacks::GetLightingResolutionMaxSMs())
.OnValueChanged_Static(&FLevelEditorActionCallbacks::SetLightingResolutionMaxSMs)
];
InMenuBuilder.AddWidget(Meshes, FText::GetEmpty(), true);
TSharedRef<SWidget> BSPs = SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.AutoWidth()
[
SNew( SCheckBox )
.Style(FEditorStyle::Get(), "Menu.CheckBox")
.ToolTipText(LOCTEXT( "BSPSurfacesToolTip", "BSP Surfaces will be adjusted if checked." ))
.IsChecked_Static(&FLevelEditorActionCallbacks::IsLightingResolutionBSPSurfacesChecked)
.OnCheckStateChanged_Static(&FLevelEditorActionCallbacks::SetLightingResolutionBSPSurfaces)
.Content()
[
SNew( STextBlock )
.Text( LOCTEXT("BSPSurfaces", "BSP Surfaces") )
]
]
+SHorizontalBox::Slot()
.AutoWidth()
.Padding( FMargin( 6.0f, 0.0f, 4.0f, 0.0f ) )
[
SNew(SSpinBox<float>)
.MinValue(1.f)
.MaxValue(63556.f)
.ToolTipText(LOCTEXT( "LightingResolutionBSPsMinToolTip", "The minimum lightmap resolution of a BSP surface to adjust. When outside of the Min/Max range, the BSP surface will no be altered." ))
.Value(FLevelEditorActionCallbacks::GetLightingResolutionMinBSPs())
.OnValueChanged_Static(&FLevelEditorActionCallbacks::SetLightingResolutionMinBSPs)
]
+SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SSpinBox<float>)
.MinValue(1.f)
.MaxValue(63556.f)
.ToolTipText(LOCTEXT( "LightingResolutionBSPsMaxToolTip", "The maximum lightmap resolution of a BSP surface to adjust. When outside of the Min/Max range, the BSP surface will no be altered." ))
.Value(FLevelEditorActionCallbacks::GetLightingResolutionMaxBSPs())
.OnValueChanged_Static(&FLevelEditorActionCallbacks::SetLightingResolutionMaxBSPs)
];
InMenuBuilder.AddWidget(BSPs, FText::GetEmpty(), true);
}
InMenuBuilder.EndSection(); //LevelEditorBuildLightingResolution1
InMenuBuilder.BeginSection("LevelEditorBuildLightingResolution2", LOCTEXT( "LightingResolutionHeading2", "Select Options" ) );
{
InMenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingResolution_CurrentLevel );
InMenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingResolution_SelectedLevels );
InMenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingResolution_AllLoadedLevels );
InMenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingResolution_SelectedObjectsOnly );
}
InMenuBuilder.EndSection();
InMenuBuilder.BeginSection("LevelEditorBuildLightingResolution3", LOCTEXT( "LightingResolutionHeading3", "Ratio" ) );
{
TSharedRef<SWidget> Ratio = SNew(SSpinBox<int32>)
.MinValue(0)
.MaxValue(400)
.ToolTipText(LOCTEXT( "LightingResolutionRatioToolTip", "Ratio to apply (New Resolution = Ratio / 100.0f * CurrentResolution)." ))
.Value(FLevelEditorActionCallbacks::GetLightingResolutionRatio())
.OnEndSliderMovement_Static(&FLevelEditorActionCallbacks::SetLightingResolutionRatio)
.OnValueCommitted_Static(&FLevelEditorActionCallbacks::SetLightingResolutionRatioCommit);
InMenuBuilder.AddWidget(Ratio, LOCTEXT( "LightingResolutionRatio", "Ratio" ));
}
InMenuBuilder.EndSection();
}
/** Generates a lighting info dialogs sub-menu */
static void MakeLightingInfoMenu( FMenuBuilder& InMenuBuilder )
{
InMenuBuilder.BeginSection("LevelEditorBuildLightingInfo", LOCTEXT( "LightingInfoHeading", "Lighting Info Dialogs" ) );
{
InMenuBuilder.AddSubMenu(
LOCTEXT( "LightingDensityRenderingSubMenu", "LightMap Density Rendering Options" ),
LOCTEXT( "LightingDensityRenderingSubMenu_ToolTip", "Shows the LightMap Density Rendering viewmode options." ),
FNewMenuDelegate::CreateStatic( &FLightingMenus::MakeLightingDensityMenu ) );
InMenuBuilder.AddSubMenu(
LOCTEXT( "LightingResolutionAdjustmentSubMenu", "LightMap Resolution Adjustment" ),
LOCTEXT( "LightingResolutionAdjustmentSubMenu_ToolTip", "Shows the LightMap Resolution Adjustment options." ),
FNewMenuDelegate::CreateStatic( &FLightingMenus::MakeLightingResolutionMenu ) );
InMenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingStaticMeshInfo, NAME_None, LOCTEXT( "BuildLightingInfo_LightingStaticMeshInfo", "Lighting StaticMesh Info..." ) );
}
InMenuBuilder.EndSection();
}
};
MenuBuilder.BeginSection("LevelEditorLighting", LOCTEXT( "LightingHeading", "Lighting" ) );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().BuildLightingOnly, NAME_None, LOCTEXT( "BuildLightingOnlyHeading", "Build Lighting Only" ) );
MenuBuilder.AddSubMenu(
LOCTEXT( "LightingQualitySubMenu", "Lighting Quality" ),
LOCTEXT( "LightingQualitySubMenu_ToolTip", "Allows you to select the quality level for precomputed lighting" ),
FNewMenuDelegate::CreateStatic( &FLightingMenus::MakeLightingQualityMenu ) );
MenuBuilder.AddSubMenu(
LOCTEXT( "BuildLightingInfoSubMenu", "Lighting Info" ),
LOCTEXT( "BuildLightingInfoSubMenu_ToolTip", "Access the lighting info dialogs" ),
FNewMenuDelegate::CreateStatic( &FLightingMenus::MakeLightingInfoMenu ) );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingBuildOptions_UseErrorColoring );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LightingBuildOptions_ShowLightingStats );
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorReflections", LOCTEXT( "ReflectionHeading", "Reflections" ) );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().BuildReflectionCapturesOnly );
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorVisibility", LOCTEXT( "VisibilityHeading", "Visibility" ) );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().BuildLightingOnly_VisibilityOnly );
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorGeometry", LOCTEXT( "GeometryHeading", "Geometry" ) );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().BuildGeometryOnly );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().BuildGeometryOnly_OnlyCurrentLevel );
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorNavigation", LOCTEXT( "NavigationHeading", "Navigation" ) );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().BuildPathsOnly );
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorLOD", LOCTEXT("LODHeading", "Hierarchical LOD"));
{
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().BuildLODsOnly);
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorTextureStreaming", LOCTEXT("TextureStreamingHeading", "Texture Streaming"));
if (CVarStreamingUseNewMetrics.GetValueOnAnyThread() != 0) // There is not point of in building texture streaming data with the old system.
{
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().BuildTextureStreamingOnly);
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorAutomation", LOCTEXT( "AutomationHeading", "Automation" ) );
{
MenuBuilder.AddMenuEntry(
FLevelEditorCommands::Get().BuildAndSubmitToSourceControl,
NAME_None,
TAttribute<FText>(),
TAttribute<FText>(),
FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Tabs.BuildAndSubmit")
);
}
MenuBuilder.EndSection();
// Map Check
MenuBuilder.BeginSection("LevelEditorVerification", LOCTEXT( "VerificationHeading", "Verification" ) );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().MapCheck, NAME_None, LOCTEXT("OpenMapCheck", "Map Check") );
}
MenuBuilder.EndSection();
#undef LOCTEXT_NAMESPACE
return MenuBuilder.MakeWidget();
}
static void MakeES2PreviewPlatformOverrideMenu(FMenuBuilder& MenuBuilder)
{
MenuBuilder.BeginSection("LevelEditorShaderModelPreview", NSLOCTEXT("LevelToolBarViewMenu", "ES2PreviewPlatformOverrideHeading", "Preview Platform"));
{
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().PreviewPlatformOverride_DefaultES2);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().PreviewPlatformOverride_AndroidGLES2);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().PreviewPlatformOverride_IOSGLES2);
}
MenuBuilder.EndSection();
}
static void MakeES31PreviewPlatformOverrideMenu(FMenuBuilder& MenuBuilder)
{
MenuBuilder.BeginSection("LevelEditorShaderModelPreview", NSLOCTEXT("LevelToolBarViewMenu", "ES31PreviewPlatformOverrideHeading", "Preview Platform"));
{
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().PreviewPlatformOverride_DefaultES31);
bool bAndroidBuildForES31 = false;
bool bAndroidSupportsVulkan = false;
bool bIOSSupportsMetal = false;
GConfig->GetBool(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("bBuildForES31"), bAndroidBuildForES31, GEngineIni);
GConfig->GetBool(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("bSupportsVulkan"), bAndroidSupportsVulkan, GEngineIni);
GConfig->GetBool(TEXT("/Script/IOSRuntimeSettings.IOSRuntimeSettings"), TEXT("bSupportsMetal"), bIOSSupportsMetal, GEngineIni);
if(bAndroidBuildForES31)
{
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().PreviewPlatformOverride_AndroidGLES31);
}
if(bAndroidSupportsVulkan)
{
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().PreviewPlatformOverride_AndroidVulkanES31);
}
if(bIOSSupportsMetal)
{
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().PreviewPlatformOverride_IOSMetalES31);
}
}
MenuBuilder.EndSection();
}
static void MakeMaterialQualityLevelMenu( FMenuBuilder& MenuBuilder )
{
MenuBuilder.BeginSection("LevelEditorMaterialQualityLevel", NSLOCTEXT( "LevelToolBarViewMenu", "MaterialQualityLevelHeading", "Material Quality Level" ) );
{
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().MaterialQualityLevel_Low);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().MaterialQualityLevel_Medium);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().MaterialQualityLevel_High);
}
MenuBuilder.EndSection();
}
static void MakeShaderModelPreviewMenu(FMenuBuilder& MenuBuilder)
{
MenuBuilder.BeginSection("LevelEditorShaderModelPreview", NSLOCTEXT("LevelToolBarViewMenu", "FeatureLevelPreviewHeading", "Preview Rendering Level"));
{
for (int32 i = GMaxRHIFeatureLevel; i >= 0; --i)
{
switch (i)
{
case ERHIFeatureLevel::ES2:
MenuBuilder.AddSubMenu(
FLevelEditorCommands::Get().FeatureLevelPreview[i]->GetLabel(),
FLevelEditorCommands::Get().FeatureLevelPreview[i]->GetDescription(),
FNewMenuDelegate::CreateStatic(&MakeES2PreviewPlatformOverrideMenu));
break;
case ERHIFeatureLevel::ES3_1:
MenuBuilder.AddSubMenu(
FLevelEditorCommands::Get().FeatureLevelPreview[i]->GetLabel(),
FLevelEditorCommands::Get().FeatureLevelPreview[i]->GetDescription(),
FNewMenuDelegate::CreateStatic(&MakeES31PreviewPlatformOverrideMenu));
break;
default:
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().FeatureLevelPreview[i]);
}
}
}
MenuBuilder.EndSection();
}
static void MakeScalabilityMenu( FMenuBuilder& MenuBuilder )
{
MenuBuilder.AddWidget(SNew(SScalabilitySettings), FText(), true);
}
static void MakePreviewSettingsMenu( FMenuBuilder& MenuBuilder )
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
MenuBuilder.BeginSection("LevelEditorPreview", LOCTEXT("PreviewHeading", "Previewing"));
{
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().DrawBrushMarkerPolys);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().OnlyLoadVisibleInPIE);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().ToggleParticleSystemLOD);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().ToggleParticleSystemHelpers);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().ToggleFreezeParticleSimulation);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().ToggleLODViewLocking);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().LevelStreamingVolumePrevis);
}
MenuBuilder.EndSection();
#undef LOCTEXT_NAMESPACE
}
TSharedRef< SWidget > FLevelEditorToolBar::GenerateQuickSettingsMenu( TSharedRef<FUICommandList> InCommandList )
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
// Get all menu extenders for this context menu from the level editor module
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>( TEXT("LevelEditor") );
TArray<FLevelEditorModule::FLevelEditorMenuExtender> MenuExtenderDelegates = LevelEditorModule.GetAllLevelEditorToolbarViewMenuExtenders();
TArray<TSharedPtr<FExtender>> Extenders;
for (int32 i = 0; i < MenuExtenderDelegates.Num(); ++i)
{
if (MenuExtenderDelegates[i].IsBound())
{
Extenders.Add(MenuExtenderDelegates[i].Execute(InCommandList));
}
}
TSharedPtr<FExtender> MenuExtender = FExtender::Combine(Extenders);
const bool bShouldCloseWindowAfterMenuSelection = true;
FMenuBuilder MenuBuilder( bShouldCloseWindowAfterMenuSelection, InCommandList, MenuExtender );
struct Local
{
static void OpenSettings(FName ContainerName, FName CategoryName, FName SectionName)
{
FModuleManager::LoadModuleChecked<ISettingsModule>("Settings").ShowViewer(ContainerName, CategoryName, SectionName);
}
};
MenuBuilder.BeginSection("ProjectSettingsSection", LOCTEXT("ProjectSettings","Game Specific Settings") );
{
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().WorldProperties);
MenuBuilder.AddMenuEntry(
LOCTEXT("ProjectSettingsMenuLabel", "Project Settings..."),
LOCTEXT("ProjectSettingsMenuToolTip", "Change the settings of the currently loaded project"),
FSlateIcon(FEditorStyle::GetStyleSetName(), "ProjectSettings.TabIcon"),
FUIAction(FExecuteAction::CreateStatic(&Local::OpenSettings, FName("Project"), FName("Project"), FName("General")))
);
if (IModularFeatures::Get().IsModularFeatureAvailable(EditorFeatures::PluginsEditor))
{
FGlobalTabmanager::Get()->PopulateTabSpawnerMenu(MenuBuilder, "PluginsEditor");
}
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorSelection", LOCTEXT("SelectionHeading","Selection") );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().AllowTranslucentSelection );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().AllowGroupSelection );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().StrictBoxSelect );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().TransparentBoxSelect );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().ShowTransformWidget );
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorScalability", LOCTEXT("ScalabilityHeading", "Scalability") );
{
MenuBuilder.AddSubMenu(
LOCTEXT( "ScalabilitySubMenu", "Engine Scalability Settings" ),
LOCTEXT( "ScalabilitySubMenu_ToolTip", "Open the engine scalability settings" ),
FNewMenuDelegate::CreateStatic( &MakeScalabilityMenu ) );
MenuBuilder.AddSubMenu(
LOCTEXT( "MaterialQualityLevelSubMenu", "Material Quality Level" ),
LOCTEXT( "MaterialQualityLevelSubMenu_ToolTip", "Sets the value of the CVar \"r.MaterialQualityLevel\" (low=0, high=1, medium=2). This affects materials via the QualitySwitch material expression." ),
FNewMenuDelegate::CreateStatic( &MakeMaterialQualityLevelMenu ) );
MenuBuilder.AddSubMenu(
LOCTEXT("FeatureLevelPreviewSubMenu", "Preview Rendering Level"),
LOCTEXT("FeatureLevelPreviewSubMenu_ToolTip", "Sets the rendering level used by the main editor"),
FNewMenuDelegate::CreateStatic(&MakeShaderModelPreviewMenu));
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorAudio", LOCTEXT("AudioHeading", "Real Time Audio") );
{
TSharedRef<SWidget> VolumeItem = SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.FillWidth(0.9f)
.Padding( FMargin(2.0f, 0.0f, 0.0f, 0.0f) )
[
SNew(SVolumeControl)
.ToolTipText_Static(&FLevelEditorActionCallbacks::GetAudioVolumeToolTip)
.Volume_Static(&FLevelEditorActionCallbacks::GetAudioVolume)
.OnVolumeChanged_Static(&FLevelEditorActionCallbacks::OnAudioVolumeChanged)
.Muted_Static(&FLevelEditorActionCallbacks::GetAudioMuted)
.OnMuteChanged_Static(&FLevelEditorActionCallbacks::OnAudioMutedChanged)
]
+SHorizontalBox::Slot()
.FillWidth(0.1f);
MenuBuilder.AddWidget(VolumeItem, LOCTEXT("VolumeControlLabel","Volume"));
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection( "Snapping", LOCTEXT("SnappingHeading","Snapping") );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().EnableActorSnap );
TSharedRef<SWidget> SnapItem =
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.FillWidth(0.9f)
[
SNew(SSlider)
.ToolTipText_Static(&FLevelEditorActionCallbacks::GetActorSnapTooltip)
.Value_Static(&FLevelEditorActionCallbacks::GetActorSnapSetting)
.OnValueChanged_Static(&FLevelEditorActionCallbacks::SetActorSnapSetting)
]
+SHorizontalBox::Slot()
.FillWidth(0.1f);
MenuBuilder.AddWidget(SnapItem, LOCTEXT("ActorSnapLabel","Distance"));
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().ToggleSocketSnapping );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().EnableVertexSnap );
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorViewport", LOCTEXT("ViewportHeading", "Viewport") );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().ToggleHideViewportUI );
MenuBuilder.AddSubMenu( LOCTEXT("PreviewMenu", "Previewing"), LOCTEXT("PreviewMenuTooltip","Game Preview Settings"), FNewMenuDelegate::CreateStatic( &MakePreviewSettingsMenu ) );
}
MenuBuilder.EndSection();
#undef LOCTEXT_NAMESPACE
return MenuBuilder.MakeWidget();
}
TSharedRef< SWidget > FLevelEditorToolBar::GenerateSourceControlMenu(TSharedRef<FUICommandList> InCommandList)
{
#define LOCTEXT_NAMESPACE "LevelToolBarSourceControlMenu"
// Get all menu extenders for this context menu from the level editor module
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
TArray<FLevelEditorModule::FLevelEditorMenuExtender> MenuExtenderDelegates = LevelEditorModule.GetAllLevelEditorToolbarSourceControlMenuExtenders();
TArray<TSharedPtr<FExtender>> Extenders;
for (int32 i = 0; i < MenuExtenderDelegates.Num(); ++i)
{
if (MenuExtenderDelegates[i].IsBound())
{
Extenders.Add(MenuExtenderDelegates[i].Execute(InCommandList));
}
}
TSharedPtr<FExtender> MenuExtender = FExtender::Combine(Extenders);
const bool bShouldCloseWindowAfterMenuSelection = true;
FMenuBuilder MenuBuilder(bShouldCloseWindowAfterMenuSelection, InCommandList, MenuExtender);
MenuBuilder.BeginSection("SourceControlActions", LOCTEXT("SourceControlMenuHeadingActions", "Actions"));
ISourceControlModule& SourceControlModule = ISourceControlModule::Get();
if (ISourceControlModule::Get().IsEnabled() && ISourceControlModule::Get().GetProvider().IsAvailable())
{
MenuBuilder.AddMenuEntry(
FLevelEditorCommands::Get().ChangeSourceControlSettings,
NAME_None,
TAttribute<FText>(),
TAttribute<FText>(),
FSlateIcon(FEditorStyle::GetStyleSetName(), "SourceControl.Actions.ChangeSettings")
);
}
else
{
MenuBuilder.AddMenuEntry(
FLevelEditorCommands::Get().ConnectToSourceControl,
NAME_None,
TAttribute<FText>(),
TAttribute<FText>(),
FSlateIcon(FEditorStyle::GetStyleSetName(), "SourceControl.Actions.Connect")
);
}
MenuBuilder.AddMenuEntry(
FLevelEditorCommands::Get().CheckOutModifiedFiles,
NAME_None,
TAttribute<FText>(),
TAttribute<FText>(),
FSlateIcon(FEditorStyle::GetStyleSetName(), "SourceControl.Actions.CheckOut")
);
MenuBuilder.AddMenuEntry(
FLevelEditorCommands::Get().SubmitToSourceControl,
NAME_None,
TAttribute<FText>(),
TAttribute<FText>(),
FSlateIcon(FEditorStyle::GetStyleSetName(), "SourceControl.Actions.Submit")
);
MenuBuilder.EndSection();
#undef LOCTEXT_NAMESPACE
return MenuBuilder.MakeWidget();
}
TSharedRef< SWidget > FLevelEditorToolBar::GenerateOpenBlueprintMenuContent( TSharedRef<FUICommandList> InCommandList, TWeakPtr< SLevelEditor > InLevelEditor )
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
struct FBlueprintMenus
{
/** Generates a sub-level Blueprints sub-menu */
static void MakeSubLevelsMenu(FMenuBuilder& InMenuBuilder, TWeakPtr< SLevelEditor > InLvlEditor)
{
FSlateIcon EditBP(FEditorStyle::Get().GetStyleSetName(), TEXT("LevelEditor.OpenLevelBlueprint"));
InMenuBuilder.BeginSection(NAME_None, LOCTEXT("SubLevelsHeading", "Sub-Level Blueprints"));
{
UWorld* World = InLvlEditor.Pin()->GetWorld();
for (int32 iLevel = 0; iLevel < World->GetNumLevels(); iLevel++)
{
ULevel* Level = World->GetLevel(iLevel);
if (Level != NULL && Level->GetOutermost() != NULL)
{
if (!Level->IsPersistentLevel())
{
FUIAction UIAction
(
FExecuteAction::CreateStatic(&FLevelEditorToolBar::OnOpenSubLevelBlueprint, Level)
);
FText DisplayName = FText::Format(LOCTEXT("SubLevelBlueprintItem", "Edit {0}"), FText::FromString(FPaths::GetCleanFilename(Level->GetOutermost()->GetName())));
InMenuBuilder.AddMenuEntry(DisplayName, FText::GetEmpty(), EditBP, UIAction);
}
}
}
}
InMenuBuilder.EndSection();
}
/** Handle BP being selected from popup picker */
static void OnBPSelected(const class FAssetData& AssetData)
{
UBlueprint* SelectedBP = Cast<UBlueprint>(AssetData.GetAsset());
if(SelectedBP)
{
FAssetEditorManager::Get().OpenEditorForAsset(SelectedBP);
}
}
/** Generates 'open blueprint' sub-menu */
static void MakeOpenBPClassMenu(FMenuBuilder& InMenuBuilder)
{
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>(TEXT("ContentBrowser"));
// Configure filter for asset picker
FAssetPickerConfig Config;
Config.Filter.ClassNames.Add(UBlueprint::StaticClass()->GetFName());
Config.InitialAssetViewType = EAssetViewType::List;
Config.OnAssetSelected = FOnAssetSelected::CreateStatic(&FBlueprintMenus::OnBPSelected);
Config.bAllowDragging = false;
// Don't show stuff in Engine
Config.Filter.PackagePaths.Add("/Game");
Config.Filter.bRecursivePaths = true;
TSharedRef<SWidget> Widget =
SNew(SBox)
.WidthOverride(300.f)
.HeightOverride(300.f)
[
ContentBrowserModule.Get().CreateAssetPicker(Config)
];
InMenuBuilder.BeginSection(NAME_None, LOCTEXT("BrowseHeader", "Browse"));
{
InMenuBuilder.AddWidget(Widget, FText::GetEmpty());
}
InMenuBuilder.EndSection();
}
};
const bool bShouldCloseWindowAfterMenuSelection = true;
FMenuBuilder MenuBuilder( bShouldCloseWindowAfterMenuSelection, InCommandList );
MenuBuilder.BeginSection(NAME_None, LOCTEXT("BlueprintClass", "Blueprint Class"));
{
// Create a blank BP
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().CreateBlankBlueprintClass);
// Convert selection to BP
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().ConvertSelectionToBlueprintViaHarvest);
MenuBuilder.AddMenuEntry(FLevelEditorCommands::Get().ConvertSelectionToBlueprintViaSubclass);
// Open an existing Blueprint Class...
FSlateIcon OpenBPIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.OpenClassBlueprint");
MenuBuilder.AddSubMenu(
LOCTEXT("OpenBlueprintClassSubMenu", "Open Blueprint Class..."),
LOCTEXT("OpenBlueprintClassSubMenu_ToolTip", "Open an existing Blueprint Class in this project"),
FNewMenuDelegate::CreateStatic(&FBlueprintMenus::MakeOpenBPClassMenu),
false,
OpenBPIcon);
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection(NAME_None, LOCTEXT("LevelScriptBlueprints", "Level Blueprints"));
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().OpenLevelBlueprint );
// If there are any sub-levels, display the sub-menu. A single level means there is only the persistent level
UWorld* World = InLevelEditor.Pin()->GetWorld();
if(World->GetNumLevels() > 1)
{
MenuBuilder.AddSubMenu(
LOCTEXT( "SubLevelsSubMenu", "Sub-Levels" ),
LOCTEXT( "SubLevelsSubMenu_ToolTip", "Shows available sub-level Blueprints that can be edited." ),
FNewMenuDelegate::CreateStatic( &FBlueprintMenus::MakeSubLevelsMenu, InLevelEditor ),
FUIAction(), NAME_None, EUserInterfaceActionType::Button, false, FSlateIcon(FEditorStyle::Get().GetStyleSetName(), TEXT("LevelEditor.OpenLevelBlueprint")) );
}
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection(NAME_None, LOCTEXT("ProjectSettingsClasses", "Project Settings"));
{
// If source control is enabled, queue up a query to the status of the config file so it is (hopefully) ready before we get to the sub-menu
if(ISourceControlModule::Get().IsEnabled())
{
FString ConfigFilePath = FPaths::ConvertRelativePathToFull(FString::Printf(TEXT("%sDefaultEngine.ini"), *FPaths::SourceConfigDir()));
// note: calling QueueStatusUpdate often does not spam status updates as an internal timer prevents this
ISourceControlModule::Get().QueueStatusUpdate(ConfigFilePath);
}
LevelEditorActionHelpers::CreateGameModeSubMenu(MenuBuilder, InCommandList, InLevelEditor, true);
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection(NAME_None, LOCTEXT("WorldSettingsClasses", "World Override"));
{
LevelEditorActionHelpers::CreateGameModeSubMenu(MenuBuilder, InCommandList, InLevelEditor, false);
}
MenuBuilder.EndSection();
#undef LOCTEXT_NAMESPACE
return MenuBuilder.MakeWidget();
}
void FLevelEditorToolBar::OnOpenSubLevelBlueprint( ULevel* InLevel )
{
ULevelScriptBlueprint* LevelScriptBlueprint = InLevel->GetLevelScriptBlueprint();
if( LevelScriptBlueprint )
{
FAssetEditorManager::Get().OpenEditorForAsset(LevelScriptBlueprint);
}
else
{
FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "UnableToCreateLevelScript", "Unable to find or create a level blueprint for this level.") );
}
}
TSharedRef< SWidget > FLevelEditorToolBar::GenerateCinematicsMenuContent( TSharedRef<FUICommandList> InCommandList, TWeakPtr<SLevelEditor> LevelEditorWeakPtr )
{
#define LOCTEXT_NAMESPACE "LevelToolBarCinematicsMenu"
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
TSharedPtr<FExtender> Extender = FExtender::Combine(LevelEditorModule.GetAllLevelEditorToolbarCinematicsMenuExtenders());
const bool bShouldCloseWindowAfterMenuSelection = true;
FMenuBuilder MenuBuilder( bShouldCloseWindowAfterMenuSelection, InCommandList, Extender );
// We can't build a list of Matinees and LevelSequenceActors while the current World is a PIE world.
SceneOutliner::FInitializationOptions InitOptions;
{
InitOptions.Mode = ESceneOutlinerMode::ActorPicker;
// We hide the header row to keep the UI compact.
// @todo: Might be useful to have this sometimes, actually. Ideally the user could summon it.
InitOptions.bShowHeaderRow = false;
InitOptions.bShowSearchBox = false;
InitOptions.bShowCreateNewFolder = false;
// Only display Matinee and MovieScene actors
auto ActorFilter = [](const AActor* Actor){
return Actor->IsA( AMatineeActor::StaticClass() ) || Actor->IsA( ALevelSequenceActor::StaticClass() );
};
InitOptions.Filters->AddFilterPredicate( SceneOutliner::FActorFilterPredicate::CreateLambda( ActorFilter ) );
}
// actor selector to allow the user to choose an actor
FSceneOutlinerModule& SceneOutlinerModule = FModuleManager::LoadModuleChecked<FSceneOutlinerModule>( "SceneOutliner" );
TSharedRef< SWidget > MiniSceneOutliner =
SNew( SVerticalBox )
+SVerticalBox::Slot()
.AutoHeight()
.MaxHeight(400.0f)
[
SceneOutlinerModule.CreateSceneOutliner(
InitOptions,
FOnActorPicked::CreateStatic( &FLevelEditorToolBar::OnCinematicsActorPicked ) )
];
static const FName DefaultForegroundName("DefaultForeground");
// Give the scene outliner a border and background
const FSlateBrush* BackgroundBrush = FEditorStyle::GetBrush( "Menu.Background" );
TSharedRef< SBorder > RootBorder =
SNew( SBorder )
.Padding(3)
.BorderImage( BackgroundBrush )
.ForegroundColor( FEditorStyle::GetSlateColor(DefaultForegroundName) )
// Assign the box panel as the child
[
SNew( SVerticalBox )
+SVerticalBox::Slot()
.AutoHeight()
.Padding( 5 )
.HAlign( HAlign_Center )
[
SNew( STextBlock )
.Text( LOCTEXT( "SelectCinematicsActorToEdit", "Select an actor" ) )
]
+SVerticalBox::Slot()
.AutoHeight()
.Padding( 2 )
[
MiniSceneOutliner
]
]
;
MenuBuilder.BeginSection("LevelEditorNewMatinee", LOCTEXT("MatineeMenuCombo_NewHeading", "New"));
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().AddMatinee, NAME_None, TAttribute<FText>(), TAttribute<FText>(), FSlateIcon(FEditorStyle::GetStyleSetName(), "ClassIcon.MatineeActor") );
}
MenuBuilder.EndSection();
UWorld* World = LevelEditorWeakPtr.Pin()->GetWorld();
const bool bHasAnyCinematicsActors = !!TActorIterator<AMatineeActor>(World) || !!TActorIterator<ALevelSequenceActor>(World);
//Add a heading to separate the existing cinematics from the 'Add New Cinematic Actor' button
MenuBuilder.BeginSection("LevelEditorExistingCinematic", LOCTEXT( "CinematicMenuCombo_ExistingHeading", "Edit Existing Cinematic" ) );
{
if( bHasAnyCinematicsActors )
{
MenuBuilder.AddWidget(MiniSceneOutliner, FText::GetEmpty(), true);
}
}
MenuBuilder.EndSection();
#undef LOCTEXT_NAMESPACE
return MenuBuilder.MakeWidget();
}
void FLevelEditorToolBar::OnCinematicsActorPicked( AActor* Actor )
{
//The matinee editor will not tick unless the editor viewport is in realtime mode.
//the scene outliner eats input, so we must close any popups manually.
FSlateApplication::Get().DismissAllMenus();
// Make sure we dismiss the menus before we open this
if (AMatineeActor* MatineeActor = Cast<AMatineeActor>(Actor))
{
// Open Matinee for editing!
GEditor->OpenMatinee( MatineeActor );
}
else if (ALevelSequenceActor* LevelSequenceActor = Cast<ALevelSequenceActor>(Actor))
{
UObject* Asset = LevelSequenceActor->LevelSequence.TryLoad();
if (Asset != nullptr)
{
FAssetEditorManager::Get().OpenEditorForAsset(Asset);
}
}
}