Files
UnrealEngineUWP/Engine/Source/Editor/SourceControlWindows/Private/SSourceControlHistory.cpp
Marc Audy d5628cd986 Copying //UE4/Dev-Framework to //UE4/Dev-Main (Source: //UE4/Dev-Framework @ 3967517)
#rb none
#lockdown Nick.Penwarden
#rnx

============================
  MAJOR FEATURES & CHANGES
============================

Change 3804281 by Fred.Kimberley

	Improve contrast on watches in blueprints.

Change 3804322 by Fred.Kimberley

	First pass at adding a watch window for blueprint debugging.

Change 3804737 by mason.seay

	Added some Descriptions to tests that didn't have any, and fixed some typos

Change 3806103 by mason.seay

	Moved and Renamed Timers test map and content appropriately

Change 3806164 by Fred.Kimberley

	Add missing property types to GetDebugInfoInternal.

	#jira UE-53355

Change 3806617 by Dan.Oconnor

	Function Terminator (and derived types) now use FMemberReference instead of a UClass/FName pair. This fixes various bugs when resolving the UFunction referenced by the function terminator

	#jira UE-31754, UE-42431, UE-53315, UE-53172

Change 3808541 by Fred.Kimberley

	Add support for redirecting user defined enums.
	This is in response to the following UDN thread: https://udn.unrealengine.com/questions/404141/is-is-possible-to-create-a-redirector-from-a-bluep.html

Change 3808565 by mason.seay

	Added a few more struct tests

Change 3809840 by mason.seay

	Renamed CharacterMovement.umap to CharacterCollision.  Fixed up content to reflect this change.

Change 3809847 by mason.seay

	Added Object Timer tests.  Fixed up existing timer test to remove delay dependency

Change 3811704 by Ben.Zeigler

	Fix issue where identical enum redirects registered to different initial names would throw an incorrect error, it's fine if the value change maps are identical

Change 3811946 by Ben.Zeigler

	#jira UE-53511 Fix it so it is possible to set a user defined struct value back to it's default. The UDS hack in PropertyValueToString is no longer needed, but this could affect some other user struct editor operations

Change 3812061 by Dan.Oconnor

	Stepping over or in to nodes that are expanded at compile time (e.g. event nodes, spawn actor nodes) no longer requires multiple 'steps'

	#jira UE-52854

Change 3812259 by Dan.Oconnor

	Fix asset broken by removal of an unkown enum

	#jira UE-51419

Change 3812904 by Ben.Zeigler

	Make ResolveRedirects on StreamableManager public as it can be used to validate things

Change 3812958 by Ben.Zeigler

	#jira UE-52977 Fix crashes when binding blueprint editor commands to keys and using from invalid contexts

Change 3812975 by Mieszko.Zielinski

	Added contraptions to catch a rare eidtor-time EQS crash #UE4

	#jira UE-53468

Change 3818530 by Phillip.Kavan

	Fix incorrect access to nested instanced subobjects in nativized Blueprint ctor codegen.

	Change summary:
	- Modified FEmitDefaultValueHelper::HandleInstancedSubobject() to properly reference the outer and check ptr validity when creating/obtaining nested default subobjects.
	- Modified FEmitDefaultValueHelper::HandleClassSubobject() to better guard against code generation based on an invalid local variable name.

	#jira UE-52167

Change 3819733 by Mieszko.Zielinski

	Marked UAISenseConfig_Blueprint and UAISense_Blueprint as hidedropdown #UE4

	#jira UE-15089

Change 3821776 by Marc.Audy

	Remove redundent code in SpawnActorFromClass that already exists in ConstructObjectFromClass parent class

Change 3823851 by mason.seay

	Moved and renamed blueprints used for Object Reference testing

Change 3824165 by Phillip.Kavan

	Ensure that subobject class types are constructed prior to accessing a subobject CDO in a nativized Blueprint class's generated ctor at runtime.

	Change summary:
	- Modified FFakeImportTableHelper to tag subobject class types as a preload dependency of the outer converted Blueprint class type and not of the CDO.

	#jira UE-53111

Change 3830309 by mason.seay

	Created Literal Gameplay Tag Container test

Change 3830562 by Phillip.Kavan

	Blueprint nativization bug fixes (reviewed/taken from PR).

	Change summary:
	- Modified FSafeContextScopedEmitter::ValidationChain() to ensure that generated code calls the global IsValid() utility function on objects.
	- Modified FBlueprintCompilerCppBackend::EmitCreateArrayStatement() to generate a proper cast on MakeArray node inputs for enum class types.
	- Modified FBlueprintCompilerCppBackend::EnimCallStatementInner() to more correctly identify an interface function call site.
	- Modified FEmitHelper::GenerateAutomaticCast() to properly handle automatic casts of enum arrays.
	- (Modified from PR source) Added new FComponentDataUtils statics to consolidate custom init code generation for converted special-case component types (e.g. BodyInstance). Ties native component DSOs to the same pre/post as converted non-native component templates around the OuterGenerate() loop.
	- Modified FExposeOnSpawnValidator::IsSupported() to include CPT_SoftObjectReference property types.
	- Modified UBlueprintGeneratedClass::CheckAndApplyComponentTemplateOverrides() to no longer break out of the loop before finding additional ICH override record matches.

	#4202

	#jira UE-52188

Change 3830579 by Fred.Kimberley

	Add support for turning off multiple watches at once in the watch window.

	#jira UE-53852

Change 3836047 by Zak.Middleton

	#ue4 - Dev test maps for overlaps perf tests.

Change 3836768 by Phillip.Kavan

	Fix for a build failure that could occur with Blueprint nativization enabled and EDL disabled. This was a regression introduced in 4.18.

	Change summary:
	- Modified FEmitDefaultValueHelper::AddStaticFunctionsForDependencies() to emit the correct signature for constructing FBlueprintDependencyData elements when the EDL boot time optimization is disabled.

	#jira UE-53908

Change 3838085 by mason.seay

	Functional tests around basic blueprint functions

Change 3840489 by Ben.Zeigler

	#jira UE-31662 Fix regression with renaming parent inherited function. It was not correctly searching the parent's skeleton class during the child's recompile so it was erroneously detecting the parent function as missing

Change 3840648 by mason.seay

	Updated Descriptions on tests

Change 3842914 by Ben.Zeigler

	Improve comments around stremable handle cancel/release

Change 3850413 by Ben.Zeigler

	Fix asset registry memory reporting, track some newer fields and correctly report the state size instead of static size twice
	Copy of CL #3849610

Change 3850426 by Ben.Zeigler

	Reduce asset registry memory in cooked build by stripping out searchable names and empty dependency nodes by default
	Add option to strip dependency data for asset data with no tags, this was always true before but isn't necessarily safe
	Copy of CL #3850389

Change 3853449 by Phillip.Kavan

	Fix a scoping issue for local instanced subobject references in nativized Blueprint C++ code. Also, don't emit redundant assignment statements for instanced subobject reference properties.

	Change summary:
	- Consolidated FComponentDataUtils into FDefaultSubobjectData and extended FNonativeComponentData from it in order to handle both native & non-native DSO initialization codegen through a more common interface.
	- Exposed FEmitDefaultValueHelper::HandleInstancedSubobject() as a public API and added a 'SubobjectData' parameter to allow initialization codegen to be deferred until after all default subobjects have been mapped to local variables within the current scope.
	- Modified FEmitDefaultValueHelper::GenerateConstructor() to first map all default subobjects to local variables and then emit any delta initialization code for property values.
	- Modified FEmitDefaultValueHelper::HandleSpecialTypes() to return an empty string for an instanced reference to a default subobject. This allows us to avoid emitting initialization statements to unnecessarily reassign instances back to the same property.
	- Modified FEmitDefaultValueHelper::InnerGenerate() to better handle instanced references to default subobjects, ensuring that we don't emit unnecessary assignment statements and array initialization code to the converted class constructor in C++.
	- Fixed a few typos.

	#jira UE-53960

Change 3853465 by Phillip.Kavan

	Fix plugin module C++ source template to conform to recent public include path changes.

Change 3857599 by Marc.Audy

	PR #4438: UE-54281: Make None a valid default value to select (Contributed by projectgheist)
	#jira UE-54281
	#jira UE-54399

Change 3863259 by Zak.Middleton

	#ue4 - Save bandwidth for replicated characters by only replicating 4 byte timestamp value to clients if it's actually needed for Linear smoothing. Added option to always replicate the timestamp ("bNetworkAlwaysReplicateTransformUpdateTimestamp", default off), in case users still want this timestamp for some reason, or if smoothing mode changes dynamically and the server won't know.

	#jira UE-46293

Change 3863491 by Zak.Middleton

	#ue4 - Reduce network RPC overhead for players that are not moving. Added ClientNetSendMoveDeltaTimeStationary (default 12Hz) to supplement existing ClientNetSendMoveDeltaTime and ClientNetSendMoveDeltaTimeThrottled. UCharacterMovementComponent::GetClientNetSendDeltaTime() now uses this time if Acceleration and Velocity are zero, and the control rotation matches the last ack'd control rotation from the server.

	Also fixed up code default for ClientNetSendMoveDeltaTime to match default INI value.

	#jira UE-21264

Change 3865325 by Zak.Middleton

	#ue4 - Fix static analysis warning about possible null PC pointer.

	#jira none

Change 3869828 by Ben.Zeigler

	#jira UE-54786 Fix it so -cookonthefly cooperates with -iterate by writing out a development asset registry

Change 3869969 by mason.seay

	Character Movement Functional Tests

Change 3870099 by Mason.Seay

	Submitted asset deletes

Change 3870105 by mason.seay

	Removed link to anim blueprint to fix errors

Change 3870238 by mason.seay

	Test map for Async Loading in a Loop

Change 3870479 by Ben.Zeigler

	Add code to check CoreRedirects for SoftObjectPaths when saving or resolving in the editor. This is a bit slow so we don't want to do it on load
	We don't have any good way to know the type of a path so I check both Object and Class redirectors, which will also pickup Module renames

Change 3875224 by mason.seay

	Functional tests for Event BeginPlay execution order

Change 3875409 by mason.seay

	Optimized and fixed up character movement tests (because a potential bug in FunctionalTestActor is always passing a test when it can fail)

Change 3878947 by Mieszko.Zielinski

	CIS fixes #UE4

Change 3879000 by Mieszko.Zielinski

	More CIS fixes #UE4

Change 3879139 by Mieszko.Zielinski

	Even moar CIS fixes #UE4

Change 3879742 by mason.seay

	Added animation to Nativization Widget asset

Change 3880198 by Zak.Middleton

	#ue4 - CanCrouchInCurrentState() returns false when character capsule is simulating physics.

	#jira UE-54875
	github #4479

Change 3880266 by Zak.Middleton

	#ue4 - Optimize UpdateCharacterStateBeforeMovement() to do cheaper tests earlier (avoid CanCrouchInCurrentState() unless necessary, now that it tests IsSimulatingPhysics() which is not trivial).

	#jira UE-54875

Change 3881546 by Mieszko.Zielinski

	*.Build.cs files clean up - removed redundant dependencies from NavigationSystem and AIModule #UE4

Change 3881547 by Mieszko.Zielinski

	Removed a bunch of DEPRECATED functions from the new NavigationSystem module #UE4

	Removed all deprecates prior 4.15 (picked this one because I do know some licencees are still using it).

Change 3881742 by mason.seay

	Additional crouch test to cover UE-54875

Change 3881794 by Mieszko.Zielinski

	Fixed a bug in FVisualLoggerHelpers::GetCategories resulting in losing verbosity information #UE4

Change 3884503 by Mieszko.Zielinski

	Fixed TopDown code template to make it compile after navsys refactor #UE4

	#jira UE-55039

Change 3884507 by Mieszko.Zielinski

	Switched ensures in UNavigationSystemV1:SimpleMoveToX to error-level logs #UE4

	It's an error rather than a warning because the functions no longer do anything. Making it work would require a cyclic dependency between NavigationSystem and AIModule.

	#jira UE-55033

Change 3884594 by Mieszko.Zielinski

	Added a const FNavigationSystem::GetCurrent version #UE4

	lack of it was causing KiteDemo to not compile.

Change 3884602 by Mieszko.Zielinski

	Mac editor compilation fix #UE4

Change 3884615 by Mieszko.Zielinski

	Fixed FAIDataProviderValue::GetRawValuePtr not being accessible from outside of AIModule #UE4

Change 3885254 by Mieszko.Zielinski

	Guessfix for UE-55030 #UE4

	The name of NavigationSystem module was put in wrong in the IMPLEMENT_MODULE macro

	#jira 55030

Change 3885286 by Mieszko.Zielinski

	Changed how NavigationSystem module includes DerivedDataCache module #UE4

	#jira UE-55035

Change 3885492 by mason.seay

	Minor tweaks to animation

Change 3885773 by mason.seay

	Resaving assets to clear out warning

Change 3886433 by Mieszko.Zielinski

	Fixed TP_TopDownBP's player controller BP to not use deprecated nav functions #UE4

	#jira UE-55108

Change 3886783 by Mieszko.Zielinski

	Removed silly inclusion of NavigationSystemTypes.h from NavigationSystemTypes.h #UE4

Change 3887019 by Mieszko.Zielinski

	Fixed accessing unchecked pointer in ANavigationData::OnNavAreaAdded #UE4

Change 3891031 by Mieszko.Zielinski

	Fixed missing includes in NavigationSystem.cpp #UE4

Change 3891037 by Mieszko.Zielinski

	ContentEample's navigation fix #UE4

	#jira UE-55109

Change 3891044 by Mieszko.Zielinski

	PR #4456: Fix bug in UAISense_Sight::OnListenerForgetsActor (Contributed by maxtunel)

	#UE4

Change 3891598 by mason.seay

	Resaving assets to clear out "empty engine version" spam

Change 3891612 by mason.seay

	Fixed deprecated Set Text warnings

Change 3893334 by Mieszko.Zielinski

	Fixed a bug in navmesh generation resulting in not removing layers that ended up empty after rebuilding #UE4

	#jira UE-55041

Change 3893394 by Mieszko.Zielinski

	Fixed navmesh debug drawing to properly display octree elements with "per instance transforms" (like instanced SMs) #UE4

	Also, added a more detailed debug drawing of navoctree contents (optional, but on by default).

Change 3893395 by Mieszko.Zielinski

	Added a bit of code to navigation system's initialization that checks the enegine ini for sections refering to the moved navigation classes, and complain about it #UE4

	The message is printed as an error-level log line and it says what should the offending section be renamed to.

Change 3895563 by Dan.Oconnor

	Mirror 3895535
	Append history from previous branches in source control history view

	#jira none

Change 3896930 by Mieszko.Zielinski

	Added an option to tick navigation system while the game is paused #UE4

	Controlled via NavigationSystemV1.bTickWhilePaused, ini- and ProjectSettings-configurable.

	#jira UE-39275

Change 3897554 by Mieszko.Zielinski

	Unified how NavMeshRenderingComponent draws navmesh and octree collision's polys #UE4

Change 3897556 by Mieszko.Zielinski

	Fixed what kind of nav tile bounds we're sending to nav-colliding elements when calling 'per-instance transform' delegate #UE4

	#jira UE-45261

Change 3898064 by Mieszko.Zielinski

	Made SM Editor display AI-navigation-related whenever bHasNavigationData is set to true #UE4

	#jira UE-50436

Change 3899004 by Mieszko.Zielinski

	Fixed UEnvQueryItemType_Actor::GetItemLocation and UEnvQueryItemType_Actor::GetItemRotation to return FAISystem::InvalidLocation and FAISystem::InvalidRotation respectively instead of '0' when hosted Actor ptr is null #UE4

	Note for programmers: this changes the default behavior of this edge case. You might want to go through your code and check if you're comparing UEnvQueryItemType_Actor::GetItem*'s results to 0.

Change 3901733 by Mieszko.Zielinski

	Made FEnvQueryInstance::PrepareContext implementations returning vectors and rotators ignore InvalidLocation and InvalidRotation (respectively) #UE4

Change 3901925 by Ben.Zeigler

	#jira UE-55395 Fix issue where the cooker could load asset registry caches made in -game that do not have dependency data, leading to broken cooks

Change 3902166 by Marc.Audy

	Make ULevel::GetWorld final

Change 3902749 by Ben.Zeigler

	Fix it so pressing refresh button in asset audit window actually refreshes the asset management database

Change 3902763 by Ben.Zeigler

	#jira UE-55407 Fix it so editor tutorials are not cooked unless referenced, by correctly marking soft object paths imported from editor project settings as editor-only

Change 3905578 by Phillip.Kavan

	The UX to add a new parameter on a Blueprint delegate is now at parity with Blueprint functions.

	#4392

	#jira UE-53779

Change 3905848 by Phillip.Kavan

	First pass of the experimental Blueprint graph bookmarks feature.

	#jira UE-10052

Change 3906025 by Phillip.Kavan

	CIS fix.

Change 3906195 by Phillip.Kavan

	Add missing icon file.

Change 3906356 by Phillip.Kavan

	Moved Blueprint bookmarks enable flag into EditorExperimentalSettings for consistency with other options.

Change 3910628 by Ben.Zeigler

	Partial fix for UE-55363, this allows references to ObjectRedirectors to be switched from parent class to a child class on load as this should always be safe
	This does not actually fix UE-55363 because that case is changing from UMaterial to UMaterialInstanceConstant, and those are siblings instead of parent/child

Change 3912470 by Ben.Zeigler

	#jira UE-55586 Fix issue with saving redirected soft object paths where the export sort could accidentally cause the parent CDO to get modified between name tagging and writing exports, which is unsafe because due to delta serialization it would try to write names that were not previously tagged

Change 3913045 by Marc.Audy

	Fix issues where recursion in to child actors wasn't being handled correctly

Change 3913398 by Fred.Kimberley

	Fixes a misspelled name for one of the classes in the ability system.

	PR #4430: Fixed spelling of FGameplayAbilityInputBinds. (Contributed by IntegralLee)
	#github

	#jira UE-54327

Change 3918016 by Fred.Kimberley

	Ensure AllocGameplayEffectContext is being used in all cases where FGameplayeEffectContext is being created.

	#jira UE-52668

	PR #4250: Only create FGameplayEffectContext via AbilitySystemGlobals::.AllocGameplayEffectContext (Contributed by slonopotamus)
	#github

Change 3924653 by Mieszko.Zielinski

	Fixed LoadEngineClass local to UnrealEngine.cpp to check class redirects before falling back to default class instance #UE4

	#jira UE-55378

Change 3925614 by Phillip.Kavan

	Fix ForEachEnum node to skip over hidden enum values in new placements by default.

	Change summary:
	- Added FKismetNodeHelperLibrary::ShouldHideEnumeratorIndex() as an internal-only Blueprint node support API.
	- Modified FForExpandNodeHelper::AllocateDefaultPins() to add a "Skip Hidden" input pin (advanced). Pin default value is false.
	- Added a UK2Node_ForEachElementInEnum::PostPlacedNewNode() override to set the default value of the "Skip Hidden" input pin to 'true' for all new node placements.
	- Modified UK2Node_ForEachElementInEnum::ExpandNode() to include additional expansion logic based on the "Skip Hidden" input pin. For new placements (i.e. when the pin defaults to 'true'), an intermediate branch node will now be inserted into the compiled execution sequence to test for "hidden" metadata on the value before executing the loop body. If the input pin is linked, another intermediate branch will be inserted into the execution sequence prior to the "hidden" metadata test. All existing placements of the node will remain as-is after compilation (i.e. no additional intermediate branch nodes will be included in the expansion).

	#jira UE-34563

Change 3925649 by Marc.Audy

	Fix up issue post merge from Main with navigation system refactor

Change 3926293 by Phillip.Kavan

	Temp fix to unblock CIS.

	#jira UE-34563

Change 3926523 by Marc.Audy

	Ensure that a renamed Actor is in the correct Actors array

	#jira UE-46718

Change 3928732 by Fred.Kimberley

	Unshelved from pending changelist '3793298':

	#jira UE-53136

	PR #4287: virtual additions for AttributeSet extendability (Contributed by TWIDan)
	#github

Change 3928780 by Marc.Audy

	PR #4309: The display names of the functions. (Contributed by SertacOgan)
	#jira UE-53334

Change 3929730 by Joseph.Wysosky

	Submitting test assets for the new Blueprint Structure test cases

Change 3931919 by Joseph.Wysosky

	Deleting BasicStructure asset to rest MemberVariables back to default settings

Change 3931922 by Joseph.Wysosky

	Adding BasicStructure test asset back with default members

Change 3932083 by Phillip.Kavan

	Fix Compositing plugin source files to conform to updated relative include path specifications.

	- Encountered while testing Blueprint nativization of assets with dependencies on Composure/LensDistortion APIs.

Change 3932196 by Dan.Oconnor

	Resetting a property to default now uses the same codepath as assigning the value from the slate control

	#jira UE-55909

Change 3932408 by Lukasz.Furman

	fixed behavior tree services attached to task nodes being sometimes recognized as root level
	#jira nope

Change 3932808 by Marc.Audy

	PR #4083: Change to UK2Node_BaseAsyncTask to have pin tooltips on latent nodes (Contributed by dwrpayne)
	#jira UE-50871

Change 3934101 by Phillip.Kavan

	Revise ForEachEnum node expansion logic to exclude hidden values at compile time.

	Change summary:
	- Removed UKismetNodeHelperLibrary::ShouldHideEnumeratorIndex() (no longer in use).
	- Modified UK2Node_ForEachElementInEnum::ExpandNode() to include an enum switch node in the expansion, which will exclude hidden values when constructed. The additional expansion will occur if the enum type contains at least one hidden value.

	#jira UE-34563

Change 3934106 by Phillip.Kavan

	Mirrored 4.19 fixes to allow for EngineTest iteration w/ nativization enabled.

	Change summary:
	- Mirrored CLs 3876918, 3878968, 3883257, 3885566, 3912161 and 3920519.

Change 3934116 by Phillip.Kavan

	UBT: Explicitly define the DEPRECATED_FORGAME macro only for non-engine modules.

	Change summary:
	- Modified UEBuildModule.SetupPrivateCompileEnvironment() to check the 'bTreatAsEngineModule' flag from the rules assembly rather than testing the module's build type.

Change 3934382 by Phillip.Kavan

	Avoid inclusion of monolothic engine header files in nativized Blueprint codegen.

Change 3936387 by Mieszko.Zielinski

	Added a flag to NavModifierComponent to control whether agent's height is being used while expadning modifier's bounds during navmesh generation #UE4

Change 3936905 by Ben.Marsh

	Disable IncludeTool warning for DEPRECATED_FORGAME macro; we expect this to be different for game modules.

Change 3940537 by Marc.Audy

	Don't allow maps, sets, or arrays with an actor inner type in user defined structs to select an actor from the currently open level as default value.
	#jira UE-55938

Change 3940901 by Marc.Audy

	Properly name CVar global to reflect what it is for

Change 3943043 by Marc.Audy

	Fix world context functions not being able to be used in CheatManager derived blueprints
	#jira UE-55787

Change 3943075 by Mieszko.Zielinski

	Moved path-following related delegats' interface from NavigationSystemBase over to a new IPathFollowingManagerInterface #UE4

Change 3943089 by Mieszko.Zielinski

	Fixed how WorldSettings.NavigationSystemConfig gets created #UE4

	Made it so that there's always a NavigationSystemConfig instance present, but added a 'Null' config - this was required due to issues with creation/serialization of instanced subobjects.
	The change required adding copying constructors to FNavAgentProperties and FNavDataConfig.
	Also, fixed FNavAgentProperties.IsEquivalent to be symetrical.

Change 3943225 by Marc.Audy

	Fix spelling of Implements

Change 3950813 by Marc.Audy

	Include owner in attachment mismatch ensure
	#jira UE-56148

Change 3950996 by Marc.Audy

	Fix cases where bit packed properties used the entire byte not just the bit when interacting with boolean arrays

	#jira UE-55482

Change 3952086 by Marc.Audy

	PR #4483: Add Missing Radial Damage Multicast Delegate (Contributed by error454)
	#jira UE-54974

Change 3952720 by Marc.Audy

	PR #4575: Check if *Pawn* is a null Pointer (Contributed by dani9bma)
	#jira UE-56248

Change 3952804 by Richard.Hinckley

	Changes to BP API export commandlet to support better plugin exporting. Contributed by Harry Wang of Google.

Change 3952962 by Marc.Audy

	UHT now validates that ExpandEnumAsExecs references a valid parameter to the function.
	#jira UE-49610

Change 3952977 by Phillip.Kavan

	Fix EDL cycle at load time in nativized cooked builds when a circular dependency exists between converted and unconverted assets.

	Change summary:
	- Added FGatherConvertedClassDependencies::MarkUnconvertedClassAsNecessary().
	- Modified FFindAssetsToInclude::MaybeIncludeObjectAsDependency() to mark unconverted BPGCs (e.g. DOBPs) as necessary for conversion when the potential for a circular dependency exists so that we generate stub wrappers rather than depend on them directly.
	- Fixed a few typos in existing API names.

	#jira UE-48233

Change 3953658 by Marc.Audy

	(4.19.1) Fix inserting a reroute node causing connections to break on a GetClassDefaults node
	#jira UE-56270

Change 3954727 by Marc.Audy

	Add friendly name to custom version mismatch message

Change 3954906 by Marc.Audy

	(4.19.1) Fix crash when undoing changes related to reroute nodes connected to a GetClassDefaults node
	#jira UE-56313

Change 3954997 by Marc.Audy

	Ensure and return null if GetOuter<WithinClass> is called on a CDO for uclasses declared as within another so we don't get a UPackage c-style cast to the expected outer type

Change 3955091 by Marc.Audy

	Do not register subcomponents that are not auto register
	#jira UE-52878

Change 3955943 by Marc.Audy

	Make AbilitySystemComponent pass parameters by const& instead of ref as no state is being changed

Change 3956185 by Zak.Middleton

	#ue4 - Fix Characters using scoped movement updates (the default) not visually rotating when rotated at small rates at high framerate.

	This was caused by FScopedMovementUpdate::IsTransformDirty() using a larger FTransform comparison tolerance than USceneComponent::UpdateComponentToWorldWithParent().

	#jira none

Change 3958102 by Marc.Audy

	Clean out dead code path from k2node_select
	Select node now resets pins to wildcard if none of the pins are in use

Change 3958113 by Lukasz.Furman

	added OnSearchStart call to root level behavior tree services
	#jira UE-56257

Change 3958361 by Marc.Audy

	Fix literal input pins on select being set to wildcard during compilation

Change 3961148 by Dan.Oconnor

	Mirror 3961139 from Release 4.19
	Fix for placeholder objects being left behind when loading certain UMG assets - this could causea crash when loading UMG assets
	#jira UE-55742

Change 3961640 by Marc.Audy

	Select node now displays Add Pin button
	Undo of changing select node index type now works correctly.
	Connections to option pins now maintained across change of index pin type
	#jira UE-20742

Change 3962262 by Marc.Audy

	Display "Object Reference" instead of "Object Object Reference" and "Soft Object Reference" instead of "Object Soft Object Reference"

Change 3962795 by Phillip.Kavan

	Fix for a crash when cooking with Blueprint nativization enabled after encountering a nested instanced editor-only default subobject inherited from a native C++ base class.

	- Mirrored from //UE4/Release-4.19 (3962782)

	#jira UE-56316

Change 3962991 by Marc.Audy

	Modify Negate/Increment/Decrement Int/Float so that the output is always the desired result even if a non-mutable pin is passed in.
	Note that this can mean the result being returned and the value of the pin passed in if queried again will not be the same (in the case of pure nodes).
	#jira UE-54807

Change 3963114 by Marc.Audy

	Fix ensures/crash as a result of UClass expecting to be able to access the UPackage of CDOs via the GetOuterUPackage call.

Change 3963427 by Marc.Audy

	Fix initialization order
	Initialize bUseBackwardsCompatForEmptyAutogeneratedValue

Change 3963781 by Marc.Audy

	Fix without editor compiles

Change 3964576 by Marc.Audy

	PR #4599: : Working category for timelines (Contributed by projectgheist)
	#jira UE-56460
	#jira UE-26053

Change 3964782 by Dan.Oconnor

	Mirror 3964772 from Release 4.19

	Fix crash when force deleting certain blueprints, we can only check for authoritativeness while reinstancing

	#jira UE-56447

Change 3965156 by Mieszko.Zielinski

	PR #4592: Visual Logger optimization to fix rapid FPS drop when many items are hidden (Contributed by tstaples)

	#jira UE-56435

Change 3965173 by Marc.Audy

	(4.19.1) Fix incorrectly switching a cooling down tick to be an enabled tick when marking it enabled.
	#jira UE-56431

Change 3966117 by Marc.Audy

	Fix select nodes inside macros using wildcard array inputs having issues resolving type.
	#jira UE-56484

Change 3878901 by Mieszko.Zielinski

	NavigationSystem's code refactored out of the engine and into a new separate module #UE4

	The CL contains required changes to all of our internal projects. Fortnite and Paragon have been tested, while the rest have been only compiled.

Change 3879409 by Mieszko.Zielinski

	Further fallout fixes after ripping out NavigationSystem out of the engine #UE4

	- Fixed bad ini redirects (had NavigationSystem.NavigationSystem instead of NavigationSystem.NavigationSystemV1)
	- Added missing FNavigationSystem::GetDefaultNavDataClass binding (resulting in QAGame's func tests failing)

Change 3897655 by Ben.Zeigler

	#jira UE-55211 Fix it so literal soft object pins on blueprint nodes get correctly cooked/referenced
	It now sets the thread context to skip internal serialize and calls the archive's serialize function instead of bypassing it, which allows it to pick up references

	Change 3962780 by Marc.Audy

	When preventing a split pin from being orphaned, all sub pins must also be prevented.
	#jira UE-56328
	Repack members of UEdGraphPin to avoid wasted space (saves 16bytes)

[CL 3967553 by Marc Audy in Main branch]
2018-03-27 14:27:07 -04:00

1493 lines
49 KiB
C++

// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
#include "CoreMinimal.h"
#include "Misc/MessageDialog.h"
#include "Misc/Paths.h"
#include "ISourceControlOperation.h"
#include "SourceControlOperations.h"
#include "ISourceControlRevision.h"
#include "SourceControlWindows.h"
#include "Modules/ModuleManager.h"
#include "UObject/Object.h"
#include "UObject/Package.h"
#include "Misc/PackageName.h"
#include "InputCoreTypes.h"
#include "Layout/Visibility.h"
#include "Layout/Geometry.h"
#include "Widgets/SNullWidget.h"
#include "Styling/SlateBrush.h"
#include "Input/Events.h"
#include "Input/DragAndDrop.h"
#include "Input/Reply.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/SWidget.h"
#include "Widgets/SCompoundWidget.h"
#include "Widgets/SBoxPanel.h"
#include "Widgets/SWindow.h"
#include "SlateOptMacros.h"
#include "Framework/Application/SlateApplication.h"
#include "Textures/SlateIcon.h"
#include "Framework/Commands/UIAction.h"
#include "Widgets/Layout/SBorder.h"
#include "Widgets/Images/SImage.h"
#include "Widgets/Text/STextBlock.h"
#include "Widgets/Layout/SBox.h"
#include "Framework/MultiBox/MultiBoxBuilder.h"
#include "Widgets/Layout/SSplitter.h"
#include "Widgets/Views/SExpanderArrow.h"
#include "Widgets/Views/SHeaderRow.h"
#include "Widgets/Views/STableViewBase.h"
#include "Widgets/Views/STableRow.h"
#include "Widgets/Views/STreeView.h"
#include "Framework/Docking/TabManager.h"
#include "EditorStyleSet.h"
#include "ISourceControlModule.h"
#include "IAssetTools.h"
#include "IAssetTypeActions.h"
#include "AssetToolsModule.h"
/**
* Wrapper around data from ISourceControlRevision
*/
class FHistoryRevisionListViewItem
{
public:
/** Changelist description */
FString Description;
/** User name of submitter */
FString UserName;
/** Clientspec/workspace of submitter */
FString ClientSpec;
/** File action for this revision (branch, delete, edit, etc.) */
FString Action;
/** Source path of branch, if any */
FString BranchSource;
/** Date of this revision */
FDateTime Date;
/** Number of this revision */
FString Revision;
/** Changelist number */
int32 ChangelistNumber;
/** Filesize for this revision (0 in the event of a deletion) */
int32 FileSize;
/**
* Constructor
*
* @param InRevision File revision info. to populate this wrapper with
*/
FHistoryRevisionListViewItem( const TSharedRef<ISourceControlRevision, ESPMode::ThreadSafe>& InRevision )
{
Description = InRevision->GetDescription();
UserName = InRevision->GetUserName();
ClientSpec = InRevision->GetClientSpec();
Action = InRevision->GetAction();
BranchSource = InRevision->GetBranchSource().IsValid() ? InRevision->GetBranchSource()->GetFilename() : TEXT("");
Date = InRevision->GetDate();
Revision = InRevision->GetRevision();
ChangelistNumber = InRevision->GetCheckInIdentifier();
FileSize = InRevision->GetFileSize();
}
};
/**
* Managed mirror of FSourceControlFileHistoryInfo. Designed to represent the history of a file in
* a listview.
*/
class FHistoryFileListViewItem
{
public:
/** Depot name of the file */
FString FileName;
/**
* Constructor
*
* @param InFileName File name of the list item
*/
FHistoryFileListViewItem( const FString& InFileName )
: FileName(InFileName)
{
}
};
/**
* A container class to use the tree view to represent a dynamically expandable nested list
*/
struct FHistoryTreeItem
{
// Only one of FileListItem or RevisionListItem should be set
/** Pointer to file info */
TSharedPtr<FHistoryFileListViewItem> FileListItem;
/** Pointer to revision info */
TSharedPtr<FHistoryRevisionListViewItem> RevisionListItem;
/** If we are a revision entry, pointer to file entry that owns us */
TWeakPtr<FHistoryTreeItem> Parent;
/** List of revisions if we are file entry */
TArray< TSharedPtr<FHistoryTreeItem> > Children;
};
/**
* Attempts to get a file list-item that represents the file that specified
* history-tree entry belongs to.
*
* @param HistoryTreeItemIn The history-tree entry that you want a file item for.
* @return The file list-item that the specified entry conceptually belongs to (invalid if HistoryTreeItemIn was invalid).
*/
static TSharedPtr<FHistoryFileListViewItem> GetFileListItem(TSharedPtr<FHistoryTreeItem> HistoryTreeItemIn)
{
TSharedPtr<FHistoryFileListViewItem> FileListItem;
if (HistoryTreeItemIn.IsValid())
{
FileListItem = HistoryTreeItemIn->FileListItem;
// if this isn't a file list-item itself
if (!FileListItem.IsValid())
{
// then it should have a parent that is one
TSharedPtr<FHistoryTreeItem> ParentFileItem = HistoryTreeItemIn->Parent.Pin();
check(ParentFileItem.IsValid());
check(ParentFileItem->FileListItem.IsValid());
FileListItem = ParentFileItem->FileListItem;
}
}
return FileListItem;
}
/**
* Takes a history-tree entry and attempts to find a corresponding asset object
* for the specified revision. If the specified history item doesn't have a valid
* RevisionListItem (it's a file list-item), we take that to represent the current
* working version of the asset.
*
* @param HistoryTreeItemIn The history-tree entry that you want a corresponding object for.
* @return A UObject that represents the asset at the specified revision (NULL if we failed to find/create one).
*/
static UObject* GetAssetRevisionObject(TSharedPtr<FHistoryTreeItem> HistoryTreeItemIn)
{
UObject* AssetObject = NULL;
if (HistoryTreeItemIn.IsValid())
{
UPackage* AssetPackage = NULL; // need a package to find the asset in
TSharedPtr<FHistoryFileListViewItem> FileListItem = GetFileListItem(HistoryTreeItemIn);
check(FileListItem.IsValid());
TSharedPtr<FHistoryRevisionListViewItem> RevisionListItem = HistoryTreeItemIn->RevisionListItem;
// if this item is referencing a specific revision (and not the current working version of the asset)
if (RevisionListItem.IsValid()) // else,
{
// grab details on this file's state in source control (history, etc.)
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
FSourceControlStatePtr FileSourceControlState = SourceControlProvider.GetState(FileListItem->FileName, EStateCacheUsage::Use);
if (FileSourceControlState.IsValid())
{
// lookup the specific revision we want
TSharedPtr<ISourceControlRevision, ESPMode::ThreadSafe> FileRevision = FileSourceControlState->FindHistoryRevision(RevisionListItem->Revision);
FString TempPackageName;
if (FileRevision.IsValid() && FileRevision->Get(TempPackageName)) // grab the path to a temporary package (where the revision item will be stored)
{
// try and load the temporary package
AssetPackage = LoadPackage(NULL, *TempPackageName, LOAD_DisableCompileOnLoad);
}
} // if FileSourceControlState.IsValid()
}
else // if we want the current working version of this asset
{
FString AssetPackageName = FPackageName::FilenameToLongPackageName(FileListItem->FileName);
AssetPackage = FindObject<UPackage>(NULL, *AssetPackageName);
}
// grab the asset from the package - we assume asset name matches file name
FString AssetName = FPaths::GetBaseFilename(FileListItem->FileName);
AssetObject = FindObject<UObject>(AssetPackage, *AssetName);
} // if HistoryTreeItemIn.IsValid()
return AssetObject;
}
/**
* Constructs revision info for the specified history-tree entry.
*
* @param HistoryTreeItemIn The history-tree entry that you want revision info for.
* @param RevisionInfoOut The resulting revision info (out).
*/
static void GetRevisionInfo(TSharedPtr<FHistoryTreeItem> HistoryTreeItemIn, FRevisionInfo& RevisionInfoOut)
{
RevisionInfoOut.Revision = TEXT(""); // clear the revision info (empty string is used signify the current working version)
// if this is a specific revision item
if (HistoryTreeItemIn.IsValid() && HistoryTreeItemIn->RevisionListItem.IsValid())
{
TSharedPtr<FHistoryRevisionListViewItem> RevisionListItem = HistoryTreeItemIn->RevisionListItem;
// fill out the revision info
RevisionInfoOut.Revision = RevisionListItem->Revision;
RevisionInfoOut.Changelist = RevisionListItem->ChangelistNumber;
RevisionInfoOut.Date = RevisionListItem->Date;
}
}
/**
* Takes a array of FHistoryTreeItems and determines if the entries can all be diffed against each other.
*
* @param SelectedItems A array of FHistoryTreeItems that you want to diff against each other.
* @param ErrorTextOut Text explaining why the selected items cannot be diffed (only valid if the return value was false).
* @return True if the selected items could be diffed against each other, false if not.
*/
static bool CanDiffSelectedItems(TArray< TSharedPtr<FHistoryTreeItem> > const& SelectedItems, FText& ErrorTextOut)
{
bool bCanDiffSelected = false;
if (SelectedItems.Num() > 2)
{
ErrorTextOut = NSLOCTEXT("SourceControlHistory", "TooManyToDiff", "Cannot diff more than two revisions.");
}
else if (SelectedItems.Num() < 2)
{
ErrorTextOut = NSLOCTEXT("SourceControlHistory", "NotEnoughToDiff", "Need to select two revisions in order to compare one against the other.");
}
else
{
TSharedPtr<FHistoryTreeItem> FirstSelection = SelectedItems[0];
TSharedPtr<FHistoryTreeItem> SecondSelection = SelectedItems[1];
if (!FirstSelection.IsValid() || !SecondSelection.IsValid())
{
ErrorTextOut = NSLOCTEXT("SourceControlHistory", "InvalidSelection", "Invalid revisions selected.");
}
else if (FirstSelection == SecondSelection)
{
ErrorTextOut = NSLOCTEXT("SourceControlHistory", "CannotDiffWithSelf", "You cannot diff a revision against itself.");
}
else
{
// @TODO make sure the two selections match type (calling GetAssetRevisionObject() to compare class types is too slow)
bCanDiffSelected = true;
}
}
return bCanDiffSelected;
};
/**
* Takes two FHistoryTreeItems and attempts to diff them against each other (bringing up the diff window).
*
* @param FirstSelection The first item you want to diff.
* @param SecondSelection The second item you want to diff.
* @return True if a diff was performed, false if not.
*/
static bool DiffHistoryItems(TSharedPtr<FHistoryTreeItem> const FirstSelection, TSharedPtr<FHistoryTreeItem> const SecondSelection)
{
bool bDiffPerformed = false;
if (FirstSelection.IsValid() && SecondSelection.IsValid())
{
TSharedPtr<FHistoryFileListViewItem> FirstSelectionFileItem = GetFileListItem(FirstSelection);
TSharedPtr<FHistoryFileListViewItem> SecondSelectionFileItem = GetFileListItem(SecondSelection);
// we want to make sure the two selections are presented in a sensible order
UObject* LeftDiffAsset = NULL;
FRevisionInfo LeftVersionInfo;
UObject* RightDiffAsset = NULL;
FRevisionInfo RightVersionInfo;
bool bIsForSingleAsset = (FirstSelectionFileItem == SecondSelectionFileItem);
// if we're comparing two revisions for one asset
if (bIsForSingleAsset)
{
bool bFirstSelectionIsCurrentVersion = FirstSelection->FileListItem.IsValid();
bool bSecondSelectionIsCurrentVersion = SecondSelection->FileListItem.IsValid();
// the second selection is the newer revision iff the first isn't the current working version, and
// it's either the current working version itself, or a newer revision
bool bSecondSelectionIsNewer = !bFirstSelectionIsCurrentVersion &&
(bSecondSelectionIsCurrentVersion ||(SecondSelection->RevisionListItem->Date > FirstSelection->RevisionListItem->Date));
if (bSecondSelectionIsNewer)
{
RightDiffAsset = GetAssetRevisionObject(SecondSelection);
GetRevisionInfo(SecondSelection, RightVersionInfo);
LeftDiffAsset = GetAssetRevisionObject(FirstSelection);
GetRevisionInfo(FirstSelection, LeftVersionInfo);
}
else
{
LeftDiffAsset = GetAssetRevisionObject(SecondSelection);
GetRevisionInfo(SecondSelection, LeftVersionInfo);
RightDiffAsset = GetAssetRevisionObject(FirstSelection);
GetRevisionInfo(FirstSelection, RightVersionInfo);
}
}
else // else, we're comparing revisions from two separate assets
{
// keep them in selection order (left to right)
LeftDiffAsset = GetAssetRevisionObject(FirstSelection);
GetRevisionInfo(FirstSelection, LeftVersionInfo);
RightDiffAsset = GetAssetRevisionObject(SecondSelection);
GetRevisionInfo(SecondSelection, RightVersionInfo);
}
// if we have an asset object for both selections
if ((LeftDiffAsset != NULL) && (RightDiffAsset != NULL))
{
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
AssetToolsModule.Get().DiffAssets(LeftDiffAsset, RightDiffAsset, LeftVersionInfo, RightVersionInfo);
bDiffPerformed = true;
}
}
return bDiffPerformed;
}
/**
* A FDragDropOperation that represents dragging a source-control history tree item around.
*/
class FSourceControlHistoryRowDragDropOp : public FDragDropOperation
{
private:
/**
* Stubbed private constructor (in order to force use of the static New() method).
*/
FSourceControlHistoryRowDragDropOp()
: PendingDropAction(EDropAction::None)
{
}
public:
/**
* Allocates and registers a new FSourceControlHistoryRowDragDropOp for use.
*
* @return The newly allocated (and registered) instance.
*/
static TSharedRef<FSourceControlHistoryRowDragDropOp> New()
{
TSharedPtr<FSourceControlHistoryRowDragDropOp> NewOperation = MakeShareable(new FSourceControlHistoryRowDragDropOp);
NewOperation->Construct();
return NewOperation.ToSharedRef();
}
DRAG_DROP_OPERATOR_TYPE(FSourceControlHistoryRowDragDropOp, FDragDropOperation)
struct EDropAction
{
enum Type
{
None,
Diff,
};
};
/** An enum value detailing what operation is queued to happen (if this item is dropped) */
EDropAction::Type PendingDropAction;
/** The items that this operation is conceptually dragging around */
TArray< TSharedPtr<FHistoryTreeItem> > SelectedItems;
/** Text to display with the widget being dragged around */
FText HoverText;
/**
* Creates the visual widget that you drag around (to help visualize the drag/drop operation.
*
* @return A new slate widget representing the dragged item
*/
virtual TSharedPtr<SWidget> GetDefaultDecorator() const override
{
return SNew(SBorder)
.BorderImage(FEditorStyle::GetBrush("Graph.ConnectorFeedback.Border"))
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.AutoWidth()
.Padding(0,0,3,0)
[
SNew(SImage)
.Image(this, &FSourceControlHistoryRowDragDropOp::GetIcon)
]
+SHorizontalBox::Slot()
.AutoWidth()
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(this, &FSourceControlHistoryRowDragDropOp::GetHoverText)
]
];
}
/**
* Easy accessor function for getting at the HoverText variable (provides a
* default one if HoverText is empty).
*
* @return HoverText if it's not empty, otherwise: a default string describing that dropping would result in nothing.
*/
FText GetHoverText() const
{
return !HoverText.IsEmpty()
? HoverText
: NSLOCTEXT("SourceControlHistory", "DropActionToolTip_InvalidDropTarget", "Cannot drop here.");
}
/**
* Returns a icon brush corresponding to this operation's pending drop action.
*
* @return An 'error' icon if there is no pending action, otherwise an 'OK' icon.
*/
FSlateBrush const* GetIcon() const
{
return PendingDropAction != EDropAction::None
? FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.OK"))
: FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.Error"));
}
};
/**
* Class used to construct the ordered row content for revision data
*/
class SHistoryRevisionListRowContent : public SMultiColumnTableRow< TSharedPtr<FHistoryTreeItem> >
{
public:
SLATE_BEGIN_ARGS( SHistoryRevisionListRowContent )
: _RevisionListItem()
{}
SLATE_EVENT( FOnDragDetected, OnDragDetected )
SLATE_EVENT( FOnTableRowDragEnter, OnDragEnter )
SLATE_EVENT( FOnTableRowDragLeave, OnDragLeave )
SLATE_EVENT( FOnTableRowDrop, OnDrop )
SLATE_ARGUMENT( TSharedPtr<FHistoryRevisionListViewItem>, RevisionListItem )
/** Whether we should display the expander for this item as it has children */
SLATE_ARGUMENT( bool, HasChildren )
SLATE_END_ARGS()
/**
* Construct the widget
*
* @param InArgs A declaration from which to construct the widget
*/
void Construct( const FArguments& InArgs, const TSharedRef<STableViewBase>& InOwnerTableView )
{
RevisionListItem = InArgs._RevisionListItem;
check(RevisionListItem.IsValid());
bHasChildren = InArgs._HasChildren;
SMultiColumnTableRow< TSharedPtr<FHistoryTreeItem> >::Construct(
FSuperRowType::FArguments()
.OnDragDetected(InArgs._OnDragDetected)
.OnDragEnter(InArgs._OnDragEnter)
.OnDragLeave(InArgs._OnDragLeave)
.OnDrop(InArgs._OnDrop),
InOwnerTableView
);
}
virtual TSharedRef<SWidget> GenerateWidgetForColumn( const FName& ColumnName ) override
{
check(RevisionListItem.IsValid());
if ( ColumnName == TEXT("Revision") )
{
FString SCCAction = RevisionListItem->Action;
FName ResourceKey;
if (SCCAction == FString(TEXT("add")))
{
ResourceKey = TEXT("SourceControl.Add");
}
else if (SCCAction == FString(TEXT("edit")))
{
ResourceKey = TEXT("SourceControl.Edit");
}
else if (SCCAction == FString(TEXT("delete")))
{
ResourceKey = TEXT("SourceControl.Delete");
}
else if (SCCAction == FString(TEXT("branch")))
{
ResourceKey = TEXT("SourceControl.Branch");
}
else if (SCCAction == FString(TEXT("integrate")))
{
ResourceKey = TEXT("SourceControl.Integrate");
}
else
{
ResourceKey = TEXT("SourceControl.Edit");
}
// Rows in a tree need to show an SExpanderArrow (it also indents!) to give the appearance of being a tree.
return
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.AutoWidth()
.HAlign(HAlign_Right)
.VAlign(VAlign_Fill)
[
SNew(SExpanderArrow, SharedThis(this) )
.Visibility(this, &SHistoryRevisionListRowContent::GetExpanderVisibility)
]
+SHorizontalBox::Slot()
.AutoWidth()
.Padding(10,0,10,0)
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(SImage)
.Image(FEditorStyle::GetBrush(ResourceKey))
]
+SHorizontalBox::Slot()
.AutoWidth()
[
SNew(STextBlock)
.Text( FText::FromString(RevisionListItem->Revision) )
];
}
else if (ColumnName == TEXT("Changelist"))
{
return
SNew(STextBlock)
.Text( FText::AsNumber( RevisionListItem->ChangelistNumber, NULL, FInternationalization::Get().GetInvariantCulture() ) ) ;
}
else if (ColumnName == TEXT("Date"))
{
return
SNew(STextBlock)
.Text( RevisionListItem->Date > FDateTime::MinValue() == 0 ? FText() : FText::AsDateTime( RevisionListItem->Date ) );
}
else if (ColumnName == TEXT("UserName"))
{
return
SNew(STextBlock)
.Text( FText::FromString( RevisionListItem->UserName ) );
}
else if (ColumnName == TEXT("Description"))
{
// Cut down the description to a single line for the list view
FString SingleLineDescription = RevisionListItem->Description;
int32 NewLinePos;
if (SingleLineDescription.FindChar(TCHAR('\n'), NewLinePos))
{
SingleLineDescription = SingleLineDescription.Left(NewLinePos);
}
// Trim any trailing new-line characters from the description for the tooltip
FString TooltipDescription = RevisionListItem->Description;
while(TooltipDescription.Len() && FChar::IsLinebreak(TooltipDescription[TooltipDescription.Len() - 1]))
{
TooltipDescription.RemoveAt(TooltipDescription.Len() - 1, 1, false);
}
return
SNew(STextBlock)
.Text(FText::FromString(SingleLineDescription))
.ToolTipText(FText::FromString(TooltipDescription));
}
else
{
return
SNew(STextBlock)
. Text( FText::Format( NSLOCTEXT("SourceControlHistory", "UnsupportedColumn", "Unsupported Column: {0}"), FText::FromName( ColumnName ) ) );
}
}
EVisibility GetExpanderVisibility() const
{
return bHasChildren ? EVisibility::Visible : EVisibility::Collapsed;
}
private:
TSharedPtr<FHistoryRevisionListViewItem> RevisionListItem;
/** Whether we should display the expander for this item as it has children */
bool bHasChildren;
};
/** Panel designed to display the revision history of a package */
class SSourceControlHistoryWidget : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS( SSourceControlHistoryWidget )
: _ParentWindow()
, _SourceControlStates()
{}
SLATE_ATTRIBUTE( TSharedPtr<SWindow>, ParentWindow )
SLATE_ATTRIBUTE( TArray< FSourceControlStateRef >, SourceControlStates)
SLATE_END_ARGS()
SSourceControlHistoryWidget()
{
}
void Construct( const FArguments& InArgs )
{
AddHistoryInfo(InArgs._SourceControlStates.Get());
TSharedRef<SHeaderRow> HeaderRow = SNew(SHeaderRow);
const bool bUsesChangelists = ISourceControlModule::Get().GetProvider().UsesChangelists();
HeaderRow->AddColumn(SHeaderRow::FColumn::FArguments().ColumnId("Revision") .DefaultLabel(NSLOCTEXT("SourceControl.HistoryPanel.Header", "Revision", "Revision")) .FillWidth(bUsesChangelists ? 100 : 250));
if(bUsesChangelists)
{
HeaderRow->AddColumn(SHeaderRow::FColumn::FArguments().ColumnId("Changelist") .DefaultLabel(NSLOCTEXT("SourceControl.HistoryPanel.Header", "Changelist", "ChangeList")) .FillWidth(150));
}
HeaderRow->AddColumn(SHeaderRow::FColumn::FArguments().ColumnId("Date") .DefaultLabel(NSLOCTEXT("SourceControl.HistoryPanel.Header", "Date", "Date Submitted")) .FillWidth(250));
HeaderRow->AddColumn(SHeaderRow::FColumn::FArguments().ColumnId("UserName") .DefaultLabel(NSLOCTEXT("SourceControl.HistoryPanel.Header", "UserName", "Submitted By")) .FillWidth(200));
HeaderRow->AddColumn(SHeaderRow::FColumn::FArguments().ColumnId("Description") .DefaultLabel(NSLOCTEXT("SourceControl.HistoryPanel.Header", "Description", "Description")) .FillWidth(300));
ChildSlot
[
SNew(SBorder)
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
.BorderBackgroundColor(FLinearColor(0.5f,0.5f,0.5f,1.f))
[
SNew(SSplitter)
.Orientation(Orient_Vertical)
+SSplitter::Slot()
.Value(0.5f)
[
SNew(SBorder)
[
SNew(SBox)
.WidthOverride(600)
[
SAssignNew( MainHistoryListView, SHistoryFileListType)
.TreeItemsSource( &HistoryCollection )
.ItemHeight(25.f)
.SelectionMode(ESelectionMode::Multi)
.OnSelectionChanged(this, &SSourceControlHistoryWidget::OnRevisionPropertyChanged)
.OnGenerateRow( this, &SSourceControlHistoryWidget::OnGenerateRowForHistoryFileList )
.OnGetChildren( this, &SSourceControlHistoryWidget::OnGetChildrenForHistoryFileList )
.OnContextMenuOpening(this, &SSourceControlHistoryWidget::OnCreateContextMenu )
.HeaderRow
(
HeaderRow
)
]
]
]
+SSplitter::Slot()
.Value(0.5f)
[
SAssignNew(AdditionalInfoItemsControl,SBorder)
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
[
GetAdditionalInfoItemsControlContent()
]
]
]
];
//expand the top level nodes...
for (int32 i=0; i<HistoryCollection.Num(); i++)
{
MainHistoryListView->SetItemExpansion(HistoryCollection[i],true);
}
}
private:
/**
* Constructs the "Additional Info" panel that displays specific revision info
*/
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
TSharedRef<SWidget> GetAdditionalInfoItemsControlContent()
{
const float Padding = 2.f;
return
SNew(SVerticalBox)
+SVerticalBox::Slot()
.AutoHeight()
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.FillWidth(0.25f)
[
//Text Column
SNew(SVerticalBox)
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(NSLOCTEXT("SourceControl.HistoryPanel.Info", "Revision", "Revision:"))
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(NSLOCTEXT("SourceControl.HistoryPanel.Info", "Date", "Date Submitted:"))
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(NSLOCTEXT("SourceControl.HistoryPanel.Info", "SubmittedBy", "Submitted By:"))
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(NSLOCTEXT("SourceControl.HistoryPanel.Info", "Action", "Action:"))
]
]
+SHorizontalBox::Slot()
.FillWidth(0.25f)
.Padding(20,0)
[
//Data column
SNew(SVerticalBox)
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(this, &SSourceControlHistoryWidget::GetRevisionNumber)
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(this, &SSourceControlHistoryWidget::GetDate)
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(this, &SSourceControlHistoryWidget::GetUserName)
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(this, &SSourceControlHistoryWidget::GetAction)
]
]
+SHorizontalBox::Slot()
.FillWidth(0.25f)
.Padding(50,0)
[
//Text Column
SNew(SVerticalBox)
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
//empty for spacing
SNullWidget::NullWidget
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(NSLOCTEXT("SourceControl.HistoryPanel.Info", "Changelist", "Changelist:"))
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(NSLOCTEXT("SourceControl.HistoryPanel.Info", "Workspace", "Workspace:"))
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(NSLOCTEXT("SourceControl.HistoryPanel.Info", "FileSize", "File Size:"))
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(NSLOCTEXT("SourceControl.HistoryPanel.Info", "BranchedFrom", "Branched From:"))
]
]
+SHorizontalBox::Slot()
.FillWidth(0.25f)
.Padding(20,0)
[
//Data column
SNew(SVerticalBox)
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
//empty for spacing
SNullWidget::NullWidget
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(this, &SSourceControlHistoryWidget::GetChangelistNumber)
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(this, &SSourceControlHistoryWidget::GetClientSpec)
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(this, &SSourceControlHistoryWidget::GetFileSize)
]
+SVerticalBox::Slot()
.FillHeight(0.25f)
.Padding(Padding)
[
SNew(STextBlock)
.Text(this, &SSourceControlHistoryWidget::GetBranchedFrom)
]
]
]
+SVerticalBox::Slot()
.AutoHeight()
.Padding(Padding, 10, Padding, 5)
[
SNew(STextBlock)
.Text(NSLOCTEXT("SourceControl.HistoryPanel.Info", "Description", "Description:"))
]
+SVerticalBox::Slot()
.FillHeight(1.0f)
[
SNew(SBorder)
[
SNew(SVerticalBox)
+SVerticalBox::Slot()
.AutoHeight()
.Padding(5)
[
SNew(STextBlock)
.Text(this, &SSourceControlHistoryWidget::GetDescription)
]
]
]
;
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
/** Get the last selected revision's revision number */
FText GetRevisionNumber() const
{
if(LastSelectedRevisionItem.IsValid())
{
return FText::FromString(LastSelectedRevisionItem.Pin()->Revision);
}
return FText::GetEmpty();
}
/** Get the last selected revision's date */
FText GetDate() const
{
if(LastSelectedRevisionItem.IsValid() && LastSelectedRevisionItem.Pin()->Date != 0)
{
return FText::AsDateTime(LastSelectedRevisionItem.Pin()->Date);
}
return FText::GetEmpty();
}
/** Get the last selected revision's username */
FText GetUserName() const
{
if(LastSelectedRevisionItem.IsValid())
{
return FText::FromString(LastSelectedRevisionItem.Pin()->UserName);
}
return FText::GetEmpty();
}
/** Get the last selected revision's revision number */
FText GetAction() const
{
if(LastSelectedRevisionItem.IsValid())
{
return FText::FromString(LastSelectedRevisionItem.Pin()->Action);
}
return FText::GetEmpty();
}
/** Get the last selected revision's changelist number */
FText GetChangelistNumber() const
{
static const bool bUsesChangelists = ISourceControlModule::Get().GetProvider().UsesChangelists();
if(LastSelectedRevisionItem.IsValid() && bUsesChangelists)
{
// don't group the CL# as Perforce doesn't display it that way
return FText::AsNumber(LastSelectedRevisionItem.Pin()->ChangelistNumber, &FNumberFormattingOptions::DefaultNoGrouping());
}
return FText::GetEmpty();
}
/** Get the last selected revision's client spec */
FText GetClientSpec() const
{
if(LastSelectedRevisionItem.IsValid())
{
return FText::FromString(LastSelectedRevisionItem.Pin()->ClientSpec);
}
return FText::GetEmpty();
}
/** Get the last selected revision's file size */
FText GetFileSize() const
{
if(LastSelectedRevisionItem.IsValid())
{
static const FNumberFormattingOptions FileSizeFormatOptions = FNumberFormattingOptions()
.SetMinimumFractionalDigits(1)
.SetMaximumFractionalDigits(1);
return FText::Format(
NSLOCTEXT("SourceControlHistory", "FileSizeInMBFmt", "{0} MB"),
FText::AsNumber(((float)LastSelectedRevisionItem.Pin()->FileSize) / (1024.f * 1024.f), &FileSizeFormatOptions)
);
}
return FText::GetEmpty();
}
/** Get the last selected revision's description */
FText GetDescription() const
{
if(LastSelectedRevisionItem.IsValid())
{
return FText::FromString(LastSelectedRevisionItem.Pin()->Description);
}
return FText::GetEmpty();
}
/** Get the last selected revision's description */
FText GetBranchedFrom() const
{
if(LastSelectedRevisionItem.IsValid())
{
return FText::FromString(LastSelectedRevisionItem.Pin()->BranchSource);
}
return FText::GetEmpty();
}
/**
* Generates the content of each row, displaying a the File or Revision data for its corresponding type
*/
TSharedRef<ITableRow> OnGenerateRowForHistoryFileList( TSharedPtr<FHistoryTreeItem> TreeItemPtr, const TSharedRef<STableViewBase>& OwnerTable )
{
TSharedPtr<SWidget> RowContent;
if (TreeItemPtr->FileListItem.IsValid())
{
TSharedPtr<FHistoryFileListViewItem> FileListItem = TreeItemPtr->FileListItem;
return
SNew(STableRow< TSharedPtr<FName> >, OwnerTable)
[
SNew(SVerticalBox)
+SVerticalBox::Slot()
.AutoHeight()
.Padding(5)
[
SNew( STextBlock )
.Font( FEditorStyle::GetFontStyle( TEXT("BoldFont") ))
.Text( FText::FromString(FileListItem->FileName) )
]
]
.OnDragDetected(this, &SSourceControlHistoryWidget::OnRowDragDetected)
.OnDragEnter(this, &SSourceControlHistoryWidget::OnRowDragEnter, TreeItemPtr)
.OnDragLeave(this, &SSourceControlHistoryWidget::OnRowDragLeave)
.OnDrop(this, &SSourceControlHistoryWidget::OnRowDrop, TreeItemPtr);
}
else if (TreeItemPtr->RevisionListItem.IsValid())
{
TSharedPtr<FHistoryRevisionListViewItem> RevisionListItem = TreeItemPtr->RevisionListItem;
return
SNew(SHistoryRevisionListRowContent, OwnerTable)
.RevisionListItem(RevisionListItem)
.OnDragDetected(this, &SSourceControlHistoryWidget::OnRowDragDetected)
.OnDragEnter(this, &SSourceControlHistoryWidget::OnRowDragEnter, TreeItemPtr)
.OnDragLeave(this, &SSourceControlHistoryWidget::OnRowDragLeave)
.OnDrop(this, &SSourceControlHistoryWidget::OnRowDrop, TreeItemPtr)
.HasChildren(TreeItemPtr->Children.Num() > 0);
}
//we should never get here...
return
SNew(STableRow< TSharedPtr<FName> >, OwnerTable)
[
SNew( STextBlock )
.Text( NSLOCTEXT("SourceControlHistory", "ErrorMessage", "---ERROR---") )
];
}
/**
* Fill out the tree structure with the SSC data
*/
void AddHistoryInfo( const TArray< FSourceControlStateRef >& InStates )
{
// Construct a new observable collection to serve as the items source for the main list view. It will contain each history file item.
for( TArray< FSourceControlStateRef >::TConstIterator Iter(InStates); Iter; Iter++)
{
FSourceControlStateRef SourceControlState = *Iter;
TSharedPtr<FHistoryTreeItem> FileItem = MakeShareable(new FHistoryTreeItem());
FileItem->FileListItem = MakeShareable(new FHistoryFileListViewItem( SourceControlState->GetFilename() ));
// Add each file revision
for ( int HistoryIndex = 0; HistoryIndex < SourceControlState->GetHistorySize(); HistoryIndex++ )
{
TSharedPtr<ISourceControlRevision, ESPMode::ThreadSafe> Revision = SourceControlState->GetHistoryItem(HistoryIndex);
check(Revision.IsValid());
TSharedPtr<FHistoryTreeItem> RevisionItem = MakeShareable(new FHistoryTreeItem());
RevisionItem->RevisionListItem = MakeShareable(new FHistoryRevisionListViewItem( Revision.ToSharedRef() ));
FileItem->Children.Add(RevisionItem);
RevisionItem->Parent = FileItem;
// add branch items if we have one
if(Revision->GetBranchSource().IsValid())
{
TSharedPtr<FHistoryTreeItem> BranchFileItem = MakeShareable(new FHistoryTreeItem());
const FString BranchRevisionName = FString::Printf(TEXT("%s #%d"), *Revision->GetBranchSource()->GetFilename(), Revision->GetBranchSource()->GetRevisionNumber());
BranchFileItem->FileListItem = MakeShareable(new FHistoryFileListViewItem( BranchRevisionName ));
RevisionItem->Children.Add(BranchFileItem);
BranchFileItem->Parent = RevisionItem;
}
}
HistoryCollection.Add(FileItem);
}
}
/**
* Callback returns the revision history (Children) nodes for the file (InItem) node
*/
void OnGetChildrenForHistoryFileList( TSharedPtr< FHistoryTreeItem > InItem, TArray< TSharedPtr<FHistoryTreeItem> >& OutChildren )
{
OutChildren = InItem->Children;
}
/**
* Called whenever the IsSelected property on a MHistoryRevisionListViewItem changes. Used to specify the last selected revision item.
*
* @param Owner Object which triggered the event
* @param Args Event arguments for the property change
*/
void OnRevisionPropertyChanged(TSharedPtr<FHistoryTreeItem> Item, ESelectInfo::Type SelectInfo)
{
LastSelectedRevisionItem.Reset();
if (Item.IsValid())
{
if (Item->RevisionListItem.IsValid())
{
LastSelectedRevisionItem = Item->RevisionListItem;
}
else if (Item->Children.Num() > 0 && Item->Children[0]->RevisionListItem.IsValid())
{
LastSelectedRevisionItem = Item->Children[0]->RevisionListItem;
}
}
AdditionalInfoItemsControl->SetContent(GetAdditionalInfoItemsControlContent());
}
/** Called to create a context menu when right-clicking on a history item */
TSharedPtr< SWidget > OnCreateContextMenu()
{
FMenuBuilder MenuBuilder( true, NULL );
MenuBuilder.AddMenuEntry(
NSLOCTEXT("SourceControl.HistoryWindow.Menu", "DiffAgainstPrev", "Diff Against Previous Revision"),
NSLOCTEXT("SourceControl.HistoryWindow.Menu", "DiffAgainstPrevTooltip", "See changes between this revision and the previous one."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP( this, &SSourceControlHistoryWidget::OnDiffAgainstPreviousRev ),
FCanExecuteAction::CreateSP(this, &SSourceControlHistoryWidget::CanDiffAgainstPreviousRev)
)
);
if (CanDiffSelected())
{
MenuBuilder.AddMenuEntry(
NSLOCTEXT("SourceControl.HistoryWindow.Menu", "DiffSelected", "Diff Selected"),
NSLOCTEXT("SourceControl.HistoryWindow.Menu", "DiffSelectedTooltip", "Diff the two assets that you have selected."),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateSP(this, &SSourceControlHistoryWidget::OnDiffSelected)
)
);
}
return MenuBuilder.MakeWidget();
}
/** See if we should enabled the 'diff against previous' option */
bool CanDiffAgainstPreviousRev() const
{
// Only allow option if we selected one item and it was a revision, not a file entry
TArray< TSharedPtr<FHistoryTreeItem> > SelectedRevs = MainHistoryListView->GetSelectedItems();
return( SelectedRevs.Num() == 1 && SelectedRevs[0].IsValid() );
}
/** Try and perfom a diff between the selected revision and the previous one */
void OnDiffAgainstPreviousRev()
{
TArray< TSharedPtr<FHistoryTreeItem> > SelectedRevs = MainHistoryListView->GetSelectedItems();
if(SelectedRevs.Num() > 0 && SelectedRevs[0].IsValid())
{
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
TSharedPtr<FHistoryTreeItem> SelectedItem = SelectedRevs[0];
UObject* SelectedAsset = GetAssetRevisionObject(SelectedItem);
if (SelectedItem->RevisionListItem.IsValid())
{
TSharedPtr<FHistoryTreeItem> FileItem = SelectedItem->Parent.Pin();
check(FileItem.IsValid());
// Now we need to find previous revision
TSharedPtr<FHistoryTreeItem> PreRevisionItem;
// First, find index of selected revision in its parent file item
// NB. 0 is newest, increasing index means older
int32 RevIndex = FileItem->Children.Find(SelectedItem);
check(RevIndex != INDEX_NONE);
if(RevIndex == FileItem->Children.Num()-1) // If oldest revision of this file
{
// .. see if we have an older file
int32 FileIndex = HistoryCollection.Find(FileItem);
check(FileIndex != INDEX_NONE);
// Do nothing if we selected the newest revision of the newest file...
if(FileIndex < HistoryCollection.Num()-1)
{
// Previous revision is a different file, so get the newest revision of the older file
TSharedPtr<FHistoryTreeItem> PrevFileItem = HistoryCollection[FileIndex+1];
check(PrevFileItem.IsValid());
if(PrevFileItem->Children.Num() > 0)
{
PreRevisionItem = PrevFileItem->Children[0];
}
}
}
else
{
// Not the oldest revision of this file, grab the older entry and get revision number
PreRevisionItem = FileItem->Children[RevIndex+1];
}
UObject* PreviousAsset = GetAssetRevisionObject(PreRevisionItem);
if ((SelectedAsset != NULL) && (PreviousAsset != NULL))
{
FRevisionInfo OldRevisionInfo;
GetRevisionInfo(PreRevisionItem, OldRevisionInfo);
FRevisionInfo NewRevisionInfo;
GetRevisionInfo(SelectedItem, NewRevisionInfo);
AssetToolsModule.Get().DiffAssets(PreviousAsset, SelectedAsset, OldRevisionInfo, NewRevisionInfo);
}
else
{
FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("SourceControl.HistoryWindow", "UnableToLoadAssets", "Unable to load assets to diff. Content may no longer be supported?"));
}
}
else if (SelectedAsset != NULL)
{
// this should be a file list-item (representing the current working version)
check(SelectedItem->FileListItem.IsValid());
FString const AssetName = SelectedAsset->GetName();
FString const PackageName = FPackageName::FilenameToLongPackageName(SelectedItem->FileListItem->FileName);
AssetToolsModule.Get().DiffAgainstDepot(SelectedAsset, PackageName, AssetName);
}
}
}
/**
* Checks to see if the selected history-tree items can be diffed against each other.
*
* @return True if the selected items can be diffed, false if not.
*/
bool CanDiffSelected() const
{
// throw away text so we can utilize a shared utility method
FText ThrowAwayErrorText;
TArray< TSharedPtr<FHistoryTreeItem> > SelectedRevs = MainHistoryListView->GetSelectedItems();
return CanDiffSelectedItems(SelectedRevs, ThrowAwayErrorText);
}
/**
* Takes the two selected history items and finds a UObject asset for each,
* then attempts to open a diff window to compare them.
*/
void OnDiffSelected() const
{
TArray< TSharedPtr<FHistoryTreeItem> > SelectedRevs = MainHistoryListView->GetSelectedItems();
if (SelectedRevs.Num() >= 2)
{
if (!DiffHistoryItems(SelectedRevs[0], SelectedRevs[1]))
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("SourceControl.HistoryWindow", "UnableToLoadAssets", "Unable to load assets to diff. Content may no longer be supported?"));
}
}
}
/**
* An event handler for mouse drag detection events. Intended to be used as a delegate for
* history tree rows. Creates a FSourceControlHistoryRowDragDropOp (if the drag was with
* the left mouse-button) and assumes that all the selected items are the objects being dragged.
*
* @param MyGeometry The geometry for the dragged widget.
* @param MouseEvent Describes the mouse drag action (from when the drag was detected).
* @return A reply detailing how this event was handled ("Unhandled" if the click was not a left-click).
*/
FReply OnRowDragDetected(FGeometry const& MyGeometry, FPointerEvent const& MouseEvent) const
{
if (MouseEvent.IsMouseButtonDown(EKeys::LeftMouseButton)) //can only drag when editing
{
TSharedRef<FSourceControlHistoryRowDragDropOp> DragOperation = FSourceControlHistoryRowDragDropOp::New();
// assume that what we're dragging is what we have selected
DragOperation->SelectedItems = MainHistoryListView->GetSelectedItems();
check(DragOperation->SelectedItems.Num() > 0);
return FReply::Handled().BeginDragDrop(DragOperation);
}
else
{
return FReply::Unhandled();
}
}
/**
* An event handler for mouse drag enter events. Intended to be used as a delegate for
* history tree rows. Only handles FSourceControlHistoryRowDragDropOp drag/drop operations.
* Updates the FSourceControlHistoryRowDragDropOp to reflect if a drop action is doable
* (when over this item).
*
* @param DragDropEvent The drag/drop operation that triggered this handler.
* @param HoveredItem The history tree item that is conceptually being hovered over.
*/
void OnRowDragEnter(FDragDropEvent const& DragDropEvent, TSharedPtr<FHistoryTreeItem> const HoveredItem) const
{
TSharedPtr<FSourceControlHistoryRowDragDropOp> DragRowOp = DragDropEvent.GetOperationAs<FSourceControlHistoryRowDragDropOp>();
if (DragRowOp.IsValid())
{
DragRowOp->PendingDropAction = FSourceControlHistoryRowDragDropOp::EDropAction::None;
TArray< TSharedPtr<FHistoryTreeItem> > DiffingItems = DragRowOp->SelectedItems;
check(HoveredItem.IsValid());
DiffingItems.Add(HoveredItem);
if (CanDiffSelectedItems(DiffingItems, DragRowOp->HoverText))
{
DragRowOp->PendingDropAction = FSourceControlHistoryRowDragDropOp::EDropAction::Diff;
FText const RevisionFormatText = NSLOCTEXT("SourceControlHistory", "Revision", "Revision {0}");
FText const CurrentRevisionText = NSLOCTEXT("SourceControlHistory", "CurrentRevsion", "Current Revision");
check(DragRowOp->SelectedItems.Num() > 0);
TSharedPtr<FHistoryTreeItem> DraggedItem = DiffingItems[0];
// set text identifying the dragged item's revision (current version vs. revision X)
FText DraggedRevisionText = CurrentRevisionText;
if (DraggedItem->RevisionListItem.IsValid())
{
DraggedRevisionText = FText::Format(RevisionFormatText, FText::FromString(DraggedItem->RevisionListItem->Revision));
}
// set text identifying the hovered item's revision (current version vs. revision X)
FText HoveredRevisionText = CurrentRevisionText;
if (HoveredItem->RevisionListItem.IsValid())
{
HoveredRevisionText = FText::Format(RevisionFormatText, FText::FromString(HoveredItem->RevisionListItem->Revision));
}
TSharedPtr<FHistoryFileListViewItem> const DraggedFileItem = GetFileListItem(DraggedItem);
// convert DraggedRevisionText from the form "revision X" (or "the current version") to
// "revision X of <filename>"
FString const DraggedFileName = FPaths::GetBaseFilename(DraggedFileItem->FileName);
FText const NamedRevisionTextFormat = NSLOCTEXT("SourceControlHistory", "NamedRevision", "{0} ({1})");
DraggedRevisionText = FText::Format(NamedRevisionTextFormat, FText::FromString(DraggedFileName), DraggedRevisionText);
TSharedPtr<FHistoryFileListViewItem> const HoveredFileItem = GetFileListItem(HoveredItem);
// if we're diffing two separate files against each other
if (DraggedFileItem != HoveredFileItem)
{
// need to separately identify the hovered over item
FString const HoveredFileName = FPaths::GetBaseFilename(HoveredFileItem->FileName);
HoveredRevisionText = FText::Format(NamedRevisionTextFormat, FText::FromString(HoveredFileName), HoveredRevisionText);
}
FText const DropToDiffTextFormat = NSLOCTEXT("SourceControlHistory", "DropToDiff", "Drop {0} to diff against: {1}.");
DragRowOp->HoverText = FText::Format(DropToDiffTextFormat, DraggedRevisionText, HoveredRevisionText);
}
}
}
/**
* An event handler for mouse drag leave events. Intended to be used as a delegate for
* history tree rows. Only handles FSourceControlHistoryRowDragDropOp drag/drop operations.
* Clears any pending drop actions from the FSourceControlHistoryRowDragDropOp.
*
* @param DragDropEvent The drag/drop operation that triggered this handler.
*/
void OnRowDragLeave(FDragDropEvent const& DragDropEvent) const
{
TSharedPtr<FSourceControlHistoryRowDragDropOp> DragRowOp = DragDropEvent.GetOperationAs<FSourceControlHistoryRowDragDropOp>();
if (DragRowOp.IsValid())
{
DragRowOp->HoverText = FText::GetEmpty();
DragRowOp->PendingDropAction = FSourceControlHistoryRowDragDropOp::EDropAction::None;
}
}
/**
* An event handler for mouse drop events. Intended to be used as a delegate for
* history tree rows. Only handles FSourceControlHistoryRowDragDropOp drag/drop operations.
* Executes the pending FSourceControlHistoryRowDragDropOp action (diff, etc.)
*
* @param DragDropEvent The drag/drop operation that triggered this handler.
* @param HoveredItem The history tree item that is conceptually being dropped on to.
* @return A reply detailing how this event was handled ("Unhandled" if the operation was not a FSourceControlHistoryRowDragDropOp).
*/
FReply OnRowDrop(FDragDropEvent const& DragDropEvent, TSharedPtr<FHistoryTreeItem> const HoveredItem) const
{
TSharedPtr<FSourceControlHistoryRowDragDropOp> DragRowOp = DragDropEvent.GetOperationAs<FSourceControlHistoryRowDragDropOp>();
if (DragRowOp.IsValid())
{
if (DragRowOp->PendingDropAction == FSourceControlHistoryRowDragDropOp::EDropAction::Diff)
{
check(DragRowOp->SelectedItems.Num() > 0);
DiffHistoryItems(DragRowOp->SelectedItems[0], HoveredItem);
return FReply::Handled();
}
}
return FReply::Unhandled();
}
/** Main list view of the panel, displays each file history item */
typedef STreeView< TSharedPtr<FHistoryTreeItem> > SHistoryFileListType;
/** ListBox for selecting which object to consolidate */
TSharedPtr< SHistoryFileListType > MainHistoryListView;
/** Items control for the "additional information" subpanel */
TSharedPtr<SBorder> AdditionalInfoItemsControl;
/** All file history items the panel should display */
TArray< TSharedPtr<FHistoryTreeItem> > HistoryCollection;
/** The last selected revision item; Displayed in the "additional information" subpanel */
TWeakPtr<FHistoryRevisionListViewItem> LastSelectedRevisionItem;
};
void FSourceControlWindows::DisplayRevisionHistory( const TArray<FString>& InPackageNames )
{
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
// Query for the file history for the provided packages
TArray<FString> PackageFilenames = SourceControlHelpers::PackageFilenames(InPackageNames);
TSharedRef<FUpdateStatus, ESPMode::ThreadSafe> UpdateStatusOperation = ISourceControlOperation::Create<FUpdateStatus>();
UpdateStatusOperation->SetUpdateHistory(true);
if(SourceControlProvider.Execute(UpdateStatusOperation, PackageFilenames))
{
TArray< FSourceControlStateRef > SourceControlStates;
for(const FString& PackageFilename : PackageFilenames)
{
TArray<FString> RevisionName;
RevisionName.Add(PackageFilename);
while(RevisionName.Num() != 0)
{
int32 InitialNum = SourceControlStates.Num();
SourceControlProvider.GetState(RevisionName, SourceControlStates, EStateCacheUsage::Use);
int32 NewNum = SourceControlStates.Num();
ensure(NewNum >= InitialNum);
RevisionName.Empty();
// check to see if origin of this file is a branch, append the history from the branch point:
if(NewNum > InitialNum)
{
int32 HistorySize = SourceControlStates.Last()->GetHistorySize();
if( HistorySize > 0 )
{
TSharedPtr<class ISourceControlRevision, ESPMode::ThreadSafe> InitialHistory = SourceControlStates.Last()->GetHistoryItem(HistorySize - 1);
TSharedPtr<ISourceControlRevision, ESPMode::ThreadSafe> BranchSource = InitialHistory->GetBranchSource();
if( BranchSource.IsValid() )
{
RevisionName.Add(BranchSource->GetFilename());
}
}
}
}
}
TSharedRef<SWindow> NewWindow = SNew(SWindow)
.Title( NSLOCTEXT("SourceControl.HistoryWindow", "Title", "File History") )
.SizingRule(ESizingRule::UserSized)
.AutoCenter(EAutoCenter::PreferredWorkArea)
.ClientSize(FVector2D(700, 400));
TSharedRef<SSourceControlHistoryWidget> SourceControlWidget =
SNew(SSourceControlHistoryWidget)
.ParentWindow(NewWindow)
.SourceControlStates(SourceControlStates);
NewWindow->SetContent( SourceControlWidget );
TSharedPtr<SWindow> RootWindow = FGlobalTabmanager::Get()->GetRootWindow();
if(RootWindow.IsValid())
{
FSlateApplication::Get().AddWindowAsNativeChild(NewWindow, RootWindow.ToSharedRef());
}
else
{
FSlateApplication::Get().AddWindow(NewWindow);
}
}
}