You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3284872 on 2017/02/03 by Graeme.Thornton
Seperate pak cache granularity from pak signing chunk size
Change 3285765 on 2017/02/03 by Graeme.Thornton
Fix stats warnings because each slate new loading screen thread has the same stat name, but is assigned to a different thread
#jira UE-41478
Change 3286913 on 2017/02/04 by Ben.Marsh
IncludeTool: Merging fixes.
* Don't remove existing forward declarations unless explicitly instructed to do so. Files are optimized with these declarations in place, so removing them can cause output files to fail to build. It can be a useful separate step though, so expose it as a command-line option instead.
* Add a specific option for which files should be output by the tool. Any files which are excluded from this list are treated specially when generating output files, so as to prevent them from causing files to be omitted from other files that include them. Also add an option to force this mode for all headers, for use when testing formatting/include path generation.
Change 3287100 on 2017/02/05 by Ben.Marsh
UBT: Move platform settings into platform-specific TargetRules objects.
Change 3287106 on 2017/02/05 by Ben.Marsh
Merge UEBuildPlatformContext into UEBuildPlatform. Now that targets can have platform-specific settings, there is no need to separate a platform class which contains target-specific information.
Change 3287398 on 2017/02/06 by Steve.Robb
Fix for UHT failing when -WarningsAsErrors and -Verbose are specified together.
Change 3287399 on 2017/02/06 by Steve.Robb
Log verbosities made more readable in the debugger.
Change 3287410 on 2017/02/06 by Steve.Robb
Fix for TStructOpsTypeTraits where WithCopy gives a different result between specializing the traits and not providing WithCopy and not specializing the traits at all.
#fyi marc.audy
Change 3288020 on 2017/02/06 by Ben.Marsh
Prevent forward declaration of the ITextData class. We need to include the header for the debugger visualizers to work correctly.
Change 3291817 on 2017/02/08 by Steve.Robb
New EBlueprintCompileReinstancerFlags used to construct FBlueprintCompileReinstancer, instead of lots of bools.
Change 3292090 on 2017/02/08 by Graeme.Thornton
Crash fix - don't update font engine services if it was never created
#jira UE-33953
Change 3292993 on 2017/02/08 by Ben.Marsh
Add an option to disable force-including PCHs for files in the non-unity working set. (bAdaptiveUnityDisablesPCH)
Change 3293231 on 2017/02/08 by Ben.Marsh
BuildGraph: Allow overriding the changelist that a badge should be displayed for (with the Change="" attribute on the Badge declaration in XML), so the code changelist can be used if necessary. Also link to the failed step if only one has failed.
Change 3294213 on 2017/02/09 by Ben.Marsh
EC: Allow setting a property on frequent CI jobs that allows us to exclude it from job searches for generating the dashboard. Filtering on the client side is causing dashboard pages to be almost empty.
Change 3294753 on 2017/02/09 by Ben.Zeigler
#jira UE-41151 Fix UObjectLibrary::RemoveObject to remove from the correct array, and add comment mentioning that the dynamic use of Object Library is semi-deprecated
Change 3296070 on 2017/02/09 by Ben.Zeigler
Explicitly turn off Copy for a struct that has a linked list internally. I think turning Copy on by default for all non POD Types is pretty risky and is likely to crash for other games. In this case it was being copied for network replication, and it didn't have one defined so the default C++ one copied the linked list and crashed on destruction.
Change 3296420 on 2017/02/10 by Graeme.Thornton
Remove remaining references to AES_KEY, instead using the encryption key delegates to access the key where needed
Refactored encryption and signing key access in unrealpak to make it easier to use
Change 3296609 on 2017/02/10 by Ben.Marsh
BuildGraph: Fix error running the <Copy> task with an empty "From" argument.
* FileSystemReference.IsUnderDirectory() was not correctly handling cases where the directory was a root directory (and has to end in a path separator)
* FilePattern.AsDirectoryReference() with an empty token would append a path separator to an empty string, resulting in it referencing the root directory rather than the given base directory.
Change 3297440 on 2017/02/10 by Ben.Marsh
UBT: Move the FileFilter class into UnrealBuildTool.
Change 3297725 on 2017/02/10 by Ben.Zeigler
#jira UE-39199 Fix issue with enum value redirects using the wrong short or long name, it now fully supports both.
Clean up a lot of confusingly named and broken functions on UEnum:
#jira UE-41348 Deprecate FindEnumIndex, GetEnum, GetEnumName, replace with GetIndexByName, GetNameByIndex, and GetNameStringByIndex and clean up warnings
#jira UE-38187 Deprecate GetDisplayNameText and GetEnumText, replaced both with GetDisplayNameTextAtIndex which is now callable outside the editor and has a better comment
Deprecate FindEnumRedirects and replace with GetIndexByNameString. Fix code to not check the redirects array 5 times per enum lookup
Fix GetValueAsString to actually act on a value, not an index. This matches common usage and the function's name
While fixing deprecation warnings on internal games, fixed dozens of cases where it was using Index functions when it should have been using Value functions
Delete some now redundant enum editor code and pipe everything through UEnum
Change 3297979 on 2017/02/10 by Ben.Zeigler
Fix issues parsing Enums that are literally the string "None", which is allowed but leads to some odd behavior
Change 3298299 on 2017/02/10 by Steve.Robb
TTuple improvements:
- equality comparable
- serializable
- in the correct folder
2-tuples are specialized to be syntactically compatible with both TPair and TTuple.
TPair is now an alias for a 2-tuple and is no longer bound to TPairInitializer.
#fyi robert.manuszewski,ben.marsh
Change 3298460 on 2017/02/11 by Ben.Marsh
UGS: Set the correct result from running custom tasks.
Change 3298462 on 2017/02/11 by Ben.Marsh
UBT: Fix some deprecated messages that have the wrong release version, and add a better message for how ModuleRules constructors need to be updated.
Change 3299447 on 2017/02/13 by Graeme.Thornton
Fix AES and pak signing key embedding for content only projects
- Force temp target when any keys are specified by project config
Change 3299649 on 2017/02/13 by Steve.Robb
PLATFORM_HAS_DEFAULTED_OPERATORS fixed.
Other obsolete compiler switches removed.
Change 3299787 on 2017/02/13 by Steve.Robb
IsAbstract() for testing if a reflected native type contains pure virtual functions. Needed for BP nativization.
#fyi robert.manuszewski
Change 3300576 on 2017/02/13 by Ben.Marsh
EC: Add support for starting builds on any agent type. Mapping from agent types to resource pools is stored in an EC property sheet (/Generated/<Stream>/AgentTypes), allowing EC procedures to map it to a resource pool from a parameter.
Change 3300600 on 2017/02/13 by Ben.Marsh
EC: Add the -ClearHistory argument to UAT run to export BuildGraph settings, to allow running on incremental workspaces.
Change 3300624 on 2017/02/13 by Ben.Marsh
Switch incremental builds for all streams to start up on the incremental agent.
Change 3302134 on 2017/02/14 by Steve.Robb
UnrealCodeAnalyzer removed.
#fyi ben.marsh,robert.manuszewski
Change 3302639 on 2017/02/14 by Ben.Zeigler
Fix crash cooking odin with default command line
#jira UE-41952 Delete StealthTeleport map that crashes on load, and update default cook list that gets used if nothing specified
Change 3303002 on 2017/02/14 by Ben.Zeigler
#jira UE-41061 Fix it so editor only filtering on savepackage is uniformly applied regardless of if it's at package or object level
#jira UE-41880 Rewrite editor/client/server only filtering logic in SavePackage to fix various bugs. It now does all of the filtering up front, and won't process any filtered objects for imports or exports
Rename NotForEditorGame to NotAlwaysLoadedForEditorGame and improve comments, this flag says that the asset should be loaded EVEN IF it is editor only, it does not affect loading for normal objects
Change the non-map cook flags to RF_Public instead of RF_Standalone. Blueprint classes aren't RF_Standalone so were only being cooked before due to an accident of the dependency checker
Change it so anything with a Transient outer is marked transient at save time. These objects would not save out properly anyway
Fix it so -cooksinglepackage works properly again and excludes localization and startup packages
Tested with Fortnite and Odin, Odin works but with lots of warnings with nativization on which I need to investigate
Change 3303084 on 2017/02/14 by Ben.Zeigler
Attempt to get Nativization and EDL working without warnings
Change 3305153 on 2017/02/15 by Ben.Zeigler
Fix Fortnite and Orion cook, I don't understand why this passed my local testing
Fix the CDO subobject finder to actually return things instead of doing nothing, and fix a shadow variable warning
Change 3305959 on 2017/02/16 by Gil.Gribb
UE4 - Tweaked out the EDL loader for the switch with benefits to all platforms.
Change 3306159 on 2017/02/16 by Ben.Marsh
Fix path to target binaries when building non-monolithic in a unique build environment.
Change 3306584 on 2017/02/16 by Steve.Robb
UEnum internal functions renamed from Index to Value.
GetValueAsString_Internal() parameter now takes an int64, as is expected for enum values.
#fyi ben.zeigler
Change 3307836 on 2017/02/16 by Ben.Zeigler
#jira UE-42055 Load very old redirects in cooked builds. Matinee has no way of resaving redirects, so as long as matinee exists we need to keep them around forever, or fix matinee manually
Fixes lighting in Infiltrator demo
Change 3307929 on 2017/02/16 by Ben.Zeigler
#jira UE-42055 Second half of matinee redirector fix
Change 3308840 on 2017/02/17 by Matthew.Griffin
Reimplementing CL#3305808 from 4.15
Changed QA label build process so that it only allows version with 3 components (we always add the .0 for initial releases)
Change 3309115 on 2017/02/17 by Ben.Marsh
Windows: Fix the GetModulesDirectory() function always returning the engine binaries directory. It's possible to build non-monolithic targets which output all engine binaries to the game binaries directory - a requirement to being able to set game-specific defines or build settings, because we don't want shared engine binaries to be tainted with them. The module manager needs to be able to operate early on, before many of the game settings have been initialized, so just return the directory containing the Core module instead.
Change 3309120 on 2017/02/17 by Ben.Marsh
Fix support for creating modular builds which don't use the shared build environment.
Change 3309125 on 2017/02/17 by Ben.Marsh
Require that -CookDir arguments are specified separately on the command line. '+' is a valid path character (and common in build versions), so we shouldn't treat it as an argument separator.
Change 3309128 on 2017/02/17 by Ben.Marsh
Fix UnrealPak failures when enumerating all files from a source directory, if that directory happens to contain spaces.
Change 3309131 on 2017/02/17 by Ben.Marsh
Fix list of discovered assets being cleared by second call to FindFilesRecursive() when building DDC. Disable the -cookdir parameter again.
Change 3309140 on 2017/02/17 by Ben.Marsh
UAT: Fix exception moving a file from one location to another if the target directory does not exist.
Change 3309212 on 2017/02/17 by Ben.Marsh
Fixes/improvements for mod editor and code mods:
* A separate top-level project is generated for each code mod in the Visual Studio solution.
* Plugin descriptors now have a flag to identify themselves as mod as opposed to a regular game plugin, which prevents project plugins from getting their own VS project. New mods created with the mod editor will have this set by default, as do the three existing sample mods.
* Cleaning and building code mods will never modify engine binaries. Presence of the Engine/Build/InstalledProjectBuild.txt file is used to indicate running in this environment. This flag also disables options to edit metadata for non-mod plugins in installed builds.
* Plugin browser now includes a separate category for mods.
* Mod editor now behaves as an "installed" program by default, and will use the user's home folder for storing settings.
Change 3309231 on 2017/02/17 by Steve.Robb
Fix for Ar << bSomeBool where Ar is a derived class which overrides an operator<<.
#jira UE-42052
Change 3309248 on 2017/02/17 by Ben.Marsh
Add support for hot-reloading game plugin modules from Visual Studio, as long as their module returns IsGameModule() = true.
Change 3309257 on 2017/02/17 by Ben.Marsh
Prevent game binaries from being renamed for hot reload when working with installed projects.
Change 3309355 on 2017/02/17 by Steven.Hutton
Changes to make the website compatible with the new database changes.
Change 3309371 on 2017/02/17 by Ben.Marsh
Fix exception on shutdown when running asset registry with threads disabled.
#jira UE-41951
Change 3309389 on 2017/02/17 by Ben.Zeigler
#jira UE-42051 Fix ensure and crash when loading a null asset ID via the LoadAsset BP node
Change 3309570 on 2017/02/17 by Gil.Gribb
UE4 - Switch load time performace tweaks, plus abstracted the IO tracker and handle manager for other platforms and applied it to the PS4.
Change 3310039 on 2017/02/17 by Ben.Marsh
BuildGraph: Prevent exception when trying to delete a file that does not exist.
Change 3311484 on 2017/02/20 by Chris.Wood
CrashReportProcess crash add retry logic improvements (CRP v1.2.16)
Change 3311600 on 2017/02/20 by Matthew.Griffin
Updated StripSymbols functions so that all platforms can deal with the source and target file being the same
Change 3311675 on 2017/02/20 by Steve.Robb
FNativeClassHeaderGenerator::CurrentSourceFile stack replaced with C++ stack.
Change 3311893 on 2017/02/20 by Ben.Marsh
UGS: Add support for notifying users if CIS steps fail for content changes. Badges which test content should be listed in the [Notifications] section of the project-specific INI file, through +ContentBadges= lines.
Change 3313966 on 2017/02/21 by Ben.Marsh
Fix EC parsing of error messages output by the editor in the form "LogXYZ:Error:". Greedy optional subexpression in regex was matching everything until a space, so terminate a colon too.
Change 3314398 on 2017/02/21 by Ben.Zeigler
#jira UE-42212 Fix shutdown of AnimGraph module to be safer
[CL 3315211 by Ben Marsh in Main branch]
1054 lines
36 KiB
C++
1054 lines
36 KiB
C++
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "PropertyEditorHelpers.h"
|
|
#include "Widgets/Layout/SBorder.h"
|
|
#include "Widgets/Input/SCheckBox.h"
|
|
#include "UserInterface/PropertyEditor/PropertyEditorConstants.h"
|
|
#include "IDocumentation.h"
|
|
|
|
#include "PropertyHandleImpl.h"
|
|
|
|
#include "UserInterface/PropertyEditor/SPropertyEditor.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorNumeric.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorArray.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorCombo.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorEditInline.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorText.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorBool.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorArrayItem.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorTitle.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorDateTime.h"
|
|
#include "UserInterface/PropertyEditor/SResetToDefaultPropertyEditor.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorAsset.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorClass.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorSet.h"
|
|
#include "UserInterface/PropertyEditor/SPropertyEditorMap.h"
|
|
|
|
#include "Kismet2/KismetEditorUtilities.h"
|
|
#include "EditorClassUtils.h"
|
|
#include "Engine/Selection.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "PropertyEditor"
|
|
|
|
void SPropertyNameWidget::Construct( const FArguments& InArgs, TSharedPtr<FPropertyEditor> InPropertyEditor )
|
|
{
|
|
PropertyEditor = InPropertyEditor;
|
|
|
|
TSharedPtr<SHorizontalBox> HorizontalBox;
|
|
ChildSlot
|
|
[
|
|
SAssignNew(HorizontalBox, SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
.Padding( FMargin( 0, 1, 0, 1 ) )
|
|
.FillWidth(1)
|
|
[
|
|
SNew(SBorder)
|
|
.BorderImage_Static( &PropertyEditorConstants::GetOverlayBrush, PropertyEditor.ToSharedRef() )
|
|
.Padding( FMargin( 0.0f, 2.0f ) )
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
SNew( SPropertyEditorTitle, PropertyEditor.ToSharedRef() )
|
|
.StaticDisplayName( PropertyEditor->GetDisplayName() )
|
|
.OnDoubleClicked( InArgs._OnDoubleClicked )
|
|
.ToolTip( IDocumentation::Get()->CreateToolTip( PropertyEditor->GetToolTipText(), NULL, PropertyEditor->GetDocumentationLink(), PropertyEditor->GetDocumentationExcerptName() ) )
|
|
]
|
|
]
|
|
|
|
];
|
|
|
|
if( InArgs._DisplayResetToDefault && !PropertyEditor->GetPropertyHandle()->HasMetaData(TEXT("NoResetToDefault")) )
|
|
{
|
|
HorizontalBox->AddSlot()
|
|
.AutoWidth()
|
|
.VAlign(VAlign_Center)
|
|
.Padding(2,1)
|
|
[
|
|
SNew( SResetToDefaultPropertyEditor, PropertyEditor.ToSharedRef() )
|
|
];
|
|
}
|
|
}
|
|
|
|
void SPropertyValueWidget::Construct( const FArguments& InArgs, TSharedPtr<FPropertyEditor> PropertyEditor, TSharedPtr<IPropertyUtilities> InPropertyUtilities )
|
|
{
|
|
MinDesiredWidth = 0.0f;
|
|
MaxDesiredWidth = 0.0f;
|
|
|
|
SetEnabled( TAttribute<bool>( PropertyEditor.ToSharedRef(), &FPropertyEditor::IsPropertyEditingEnabled ) );
|
|
|
|
|
|
ValueEditorWidget = ConstructPropertyEditorWidget( PropertyEditor, InPropertyUtilities );
|
|
|
|
if ( !ValueEditorWidget->GetToolTip().IsValid() )
|
|
{
|
|
ValueEditorWidget->SetToolTipText( PropertyEditor->GetToolTipText() );
|
|
}
|
|
|
|
|
|
if( InArgs._ShowPropertyButtons )
|
|
{
|
|
TSharedRef<SHorizontalBox> HorizontalBox = SNew(SHorizontalBox);
|
|
|
|
HorizontalBox->AddSlot()
|
|
.FillWidth(1) // Fill the entire width if possible
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
ValueEditorWidget.ToSharedRef()
|
|
];
|
|
|
|
TArray< TSharedRef<SWidget> > RequiredButtons;
|
|
PropertyEditorHelpers::MakeRequiredPropertyButtons( PropertyEditor.ToSharedRef(), /*OUT*/RequiredButtons );
|
|
|
|
for( int32 ButtonIndex = 0; ButtonIndex < RequiredButtons.Num(); ++ButtonIndex )
|
|
{
|
|
HorizontalBox->AddSlot()
|
|
.AutoWidth()
|
|
.HAlign(HAlign_Center)
|
|
.VAlign(VAlign_Center)
|
|
.Padding( 2.0f, 1.0f )
|
|
[
|
|
RequiredButtons[ButtonIndex]
|
|
];
|
|
}
|
|
|
|
ChildSlot
|
|
[
|
|
HorizontalBox
|
|
];
|
|
|
|
}
|
|
else
|
|
{
|
|
ChildSlot
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
ValueEditorWidget.ToSharedRef()
|
|
];
|
|
}
|
|
|
|
|
|
}
|
|
|
|
TSharedRef<SWidget> SPropertyValueWidget::ConstructPropertyEditorWidget( TSharedPtr<FPropertyEditor>& PropertyEditor, TSharedPtr<IPropertyUtilities> InPropertyUtilities )
|
|
{
|
|
const TSharedRef<FPropertyEditor> PropertyEditorRef = PropertyEditor.ToSharedRef();
|
|
const TSharedRef<IPropertyUtilities> PropertyUtilitiesRef = InPropertyUtilities.ToSharedRef();
|
|
|
|
const TSharedRef< FPropertyNode > PropertyNode = PropertyEditorRef->GetPropertyNode();
|
|
const int32 NodeArrayIndex = PropertyNode->GetArrayIndex();
|
|
UProperty* Property = PropertyNode->GetProperty();
|
|
|
|
FSlateFontInfo FontStyle = FEditorStyle::GetFontStyle( PropertyEditorConstants::PropertyFontStyle );
|
|
TSharedPtr<SWidget> PropertyWidget;
|
|
if( Property )
|
|
{
|
|
// ORDER MATTERS: first widget type to support the property node wins!
|
|
if ( SPropertyEditorArray::Supports(PropertyEditorRef) )
|
|
{
|
|
TSharedRef<SPropertyEditorArray> ArrayWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorArray, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
ArrayWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if ( SPropertyEditorSet::Supports(PropertyEditorRef) )
|
|
{
|
|
TSharedRef<SPropertyEditorSet> SetWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorSet, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
SetWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if ( SPropertyEditorMap::Supports(PropertyEditorRef) )
|
|
{
|
|
TSharedRef<SPropertyEditorMap> MapWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorMap, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
MapWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if ( SPropertyEditorAsset::Supports( PropertyEditorRef ) )
|
|
{
|
|
TSharedRef<SPropertyEditorAsset> AssetWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorAsset, PropertyEditorRef )
|
|
.ThumbnailPool( PropertyUtilitiesRef->GetThumbnailPool() );
|
|
|
|
AssetWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if ( SPropertyEditorClass::Supports( PropertyEditorRef ) )
|
|
{
|
|
TSharedRef<SPropertyEditorClass> ClassWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorClass, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
ClassWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if ( SPropertyEditorNumeric<float>::Supports( PropertyEditorRef ) )
|
|
{
|
|
auto NumericWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorNumeric<float>, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
NumericWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if ( SPropertyEditorNumeric<double>::Supports( PropertyEditorRef ) )
|
|
{
|
|
auto NumericWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorNumeric<double>, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
NumericWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if (SPropertyEditorNumeric<int8>::Supports(PropertyEditorRef))
|
|
{
|
|
auto NumericWidget =
|
|
SAssignNew(PropertyWidget, SPropertyEditorNumeric<int8>, PropertyEditorRef)
|
|
.Font(FontStyle);
|
|
|
|
NumericWidget->GetDesiredWidth(MinDesiredWidth, MaxDesiredWidth);
|
|
}
|
|
else if (SPropertyEditorNumeric<int16>::Supports(PropertyEditorRef))
|
|
{
|
|
auto NumericWidget =
|
|
SAssignNew(PropertyWidget, SPropertyEditorNumeric<int16>, PropertyEditorRef)
|
|
.Font(FontStyle);
|
|
|
|
NumericWidget->GetDesiredWidth(MinDesiredWidth, MaxDesiredWidth);
|
|
}
|
|
else if ( SPropertyEditorNumeric<int32>::Supports( PropertyEditorRef ) )
|
|
{
|
|
auto NumericWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorNumeric<int32>, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
NumericWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if (SPropertyEditorNumeric<int64>::Supports(PropertyEditorRef))
|
|
{
|
|
auto NumericWidget =
|
|
SAssignNew(PropertyWidget, SPropertyEditorNumeric<int64>, PropertyEditorRef)
|
|
.Font(FontStyle);
|
|
|
|
NumericWidget->GetDesiredWidth(MinDesiredWidth, MaxDesiredWidth);
|
|
}
|
|
else if ( SPropertyEditorNumeric<uint8>::Supports( PropertyEditorRef ) )
|
|
{
|
|
auto NumericWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorNumeric<uint8>, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
NumericWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if (SPropertyEditorNumeric<uint16>::Supports(PropertyEditorRef))
|
|
{
|
|
auto NumericWidget =
|
|
SAssignNew(PropertyWidget, SPropertyEditorNumeric<uint16>, PropertyEditorRef)
|
|
.Font(FontStyle);
|
|
|
|
NumericWidget->GetDesiredWidth(MinDesiredWidth, MaxDesiredWidth);
|
|
}
|
|
else if (SPropertyEditorNumeric<uint32>::Supports(PropertyEditorRef))
|
|
{
|
|
auto NumericWidget =
|
|
SAssignNew(PropertyWidget, SPropertyEditorNumeric<uint32>, PropertyEditorRef)
|
|
.Font(FontStyle);
|
|
|
|
NumericWidget->GetDesiredWidth(MinDesiredWidth, MaxDesiredWidth);
|
|
}
|
|
else if (SPropertyEditorNumeric<uint64>::Supports(PropertyEditorRef))
|
|
{
|
|
auto NumericWidget =
|
|
SAssignNew(PropertyWidget, SPropertyEditorNumeric<uint64>, PropertyEditorRef)
|
|
.Font(FontStyle);
|
|
|
|
NumericWidget->GetDesiredWidth(MinDesiredWidth, MaxDesiredWidth);
|
|
}
|
|
else if ( SPropertyEditorCombo::Supports( PropertyEditorRef ) )
|
|
{
|
|
TSharedRef<SPropertyEditorCombo> ComboWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorCombo, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
ComboWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if ( SPropertyEditorEditInline::Supports( PropertyEditorRef ) )
|
|
{
|
|
TSharedRef<SPropertyEditorEditInline> EditInlineWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorEditInline, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
EditInlineWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if ( SPropertyEditorText::Supports( PropertyEditorRef ) )
|
|
{
|
|
TSharedRef<SPropertyEditorText> TextWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorText, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
TextWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if ( SPropertyEditorBool::Supports( PropertyEditorRef ) )
|
|
{
|
|
TSharedRef<SPropertyEditorBool> BoolWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorBool, PropertyEditorRef );
|
|
|
|
BoolWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
|
|
}
|
|
else if ( SPropertyEditorArrayItem::Supports( PropertyEditorRef ) )
|
|
{
|
|
TSharedRef<SPropertyEditorArrayItem> ArrayItemWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorArrayItem, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
ArrayItemWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
}
|
|
else if ( SPropertyEditorDateTime::Supports( PropertyEditorRef ) )
|
|
{
|
|
TSharedRef<SPropertyEditorDateTime> DateTimeWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditorDateTime, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
}
|
|
}
|
|
|
|
if( !PropertyWidget.IsValid() )
|
|
{
|
|
TSharedRef<SPropertyEditor> BasePropertyEditorWidget =
|
|
SAssignNew( PropertyWidget, SPropertyEditor, PropertyEditorRef )
|
|
.Font( FontStyle );
|
|
|
|
BasePropertyEditorWidget->GetDesiredWidth( MinDesiredWidth, MaxDesiredWidth );
|
|
|
|
}
|
|
|
|
return PropertyWidget.ToSharedRef();
|
|
}
|
|
|
|
void SEditConditionWidget::Construct( const FArguments& Args, TSharedPtr<FPropertyEditor> InPropertyEditor )
|
|
{
|
|
PropertyEditor = InPropertyEditor;
|
|
CustomEditCondition = Args._CustomEditCondition;
|
|
|
|
SetVisibility( HasEditCondition() ? EVisibility::Visible : EVisibility::Collapsed );
|
|
|
|
ChildSlot
|
|
[
|
|
// Some properties become irrelevant depending on the value of other properties.
|
|
// We prevent the user from editing those properties by disabling their widgets.
|
|
// This is a shortcut for toggling the property that disables us.
|
|
SNew( SCheckBox )
|
|
.OnCheckStateChanged( this, &SEditConditionWidget::OnEditConditionCheckChanged )
|
|
.IsChecked( this, &SEditConditionWidget::OnGetEditConditionCheckState )
|
|
];
|
|
}
|
|
|
|
bool SEditConditionWidget::HasEditCondition() const
|
|
{
|
|
return
|
|
( PropertyEditor.IsValid() && PropertyEditor->HasEditCondition() && PropertyEditor->SupportsEditConditionToggle() )
|
|
|| ( CustomEditCondition.OnEditConditionValueChanged.IsBound() );
|
|
}
|
|
|
|
void SEditConditionWidget::OnEditConditionCheckChanged( ECheckBoxState CheckState )
|
|
{
|
|
if( PropertyEditor.IsValid() && PropertyEditor->HasEditCondition() && PropertyEditor->SupportsEditConditionToggle() )
|
|
{
|
|
PropertyEditor->SetEditConditionState( CheckState == ECheckBoxState::Checked );
|
|
}
|
|
else
|
|
{
|
|
CustomEditCondition.OnEditConditionValueChanged.ExecuteIfBound( CheckState == ECheckBoxState::Checked );
|
|
}
|
|
}
|
|
|
|
ECheckBoxState SEditConditionWidget::OnGetEditConditionCheckState() const
|
|
{
|
|
bool bEditConditionMet = ( PropertyEditor.IsValid() && PropertyEditor->HasEditCondition() && PropertyEditor->IsEditConditionMet() ) || CustomEditCondition.EditConditionValue.Get();
|
|
return bEditConditionMet ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
|
|
}
|
|
|
|
namespace PropertyEditorHelpers
|
|
{
|
|
bool IsBuiltInStructProperty( const UProperty* Property )
|
|
{
|
|
bool bIsBuiltIn = false;
|
|
|
|
const UStructProperty* StructProp = Cast<const UStructProperty>( Property );
|
|
if( StructProp && StructProp->Struct )
|
|
{
|
|
FName StructName = StructProp->Struct->GetFName();
|
|
|
|
bIsBuiltIn = StructName == NAME_Rotator ||
|
|
StructName == NAME_Color ||
|
|
StructName == NAME_LinearColor ||
|
|
StructName == NAME_Vector ||
|
|
StructName == NAME_Quat ||
|
|
StructName == NAME_Vector4 ||
|
|
StructName == NAME_Vector2D ||
|
|
StructName == NAME_IntPoint;
|
|
}
|
|
|
|
return bIsBuiltIn;
|
|
}
|
|
|
|
bool IsChildOfArray( const FPropertyNode& InPropertyNode )
|
|
{
|
|
return GetArrayParent( InPropertyNode ) != NULL;
|
|
}
|
|
|
|
bool IsChildOfSet( const FPropertyNode& InPropertyNode )
|
|
{
|
|
return GetSetParent( InPropertyNode ) != NULL;
|
|
}
|
|
|
|
bool IsChildOfMap(const FPropertyNode& InPropertyNode)
|
|
{
|
|
return GetMapParent(InPropertyNode) != NULL;
|
|
}
|
|
|
|
bool IsStaticArray( const FPropertyNode& InPropertyNode )
|
|
{
|
|
const UProperty* NodeProperty = InPropertyNode.GetProperty();
|
|
return NodeProperty && NodeProperty->ArrayDim != 1 && InPropertyNode.GetArrayIndex() == -1;
|
|
}
|
|
|
|
bool IsDynamicArray( const FPropertyNode& InPropertyNode )
|
|
{
|
|
const UProperty* NodeProperty = InPropertyNode.GetProperty();
|
|
return NodeProperty && Cast<const UArrayProperty>(NodeProperty) != NULL;
|
|
}
|
|
|
|
const UProperty* GetArrayParent( const FPropertyNode& InPropertyNode )
|
|
{
|
|
const UProperty* ParentProperty = InPropertyNode.GetParentNode() != NULL ? InPropertyNode.GetParentNode()->GetProperty() : NULL;
|
|
|
|
if( ParentProperty )
|
|
{
|
|
if( (ParentProperty->IsA<UArrayProperty>()) || // dynamic array
|
|
(InPropertyNode.GetArrayIndex() != INDEX_NONE && ParentProperty->ArrayDim > 0) ) //static array
|
|
{
|
|
return ParentProperty;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
const UProperty* GetSetParent( const FPropertyNode& InPropertyNode )
|
|
{
|
|
const UProperty* ParentProperty = InPropertyNode.GetParentNode() != NULL ? InPropertyNode.GetParentNode()->GetProperty() : NULL;
|
|
|
|
if ( ParentProperty )
|
|
{
|
|
if (ParentProperty->IsA<USetProperty>())
|
|
{
|
|
return ParentProperty;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
const UProperty* GetMapParent( const FPropertyNode& InPropertyNode )
|
|
{
|
|
const UProperty* ParentProperty = InPropertyNode.GetParentNode() != NULL ? InPropertyNode.GetParentNode()->GetProperty() : NULL;
|
|
|
|
if (ParentProperty)
|
|
{
|
|
if (ParentProperty->IsA<UMapProperty>())
|
|
{
|
|
return ParentProperty;
|
|
}
|
|
|
|
//@todo: Also check a key/value node parent property?
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
bool IsEditInlineClassAllowed( UClass* CheckClass, bool bAllowAbstract )
|
|
{
|
|
return !CheckClass->HasAnyClassFlags(CLASS_Hidden|CLASS_HideDropDown|CLASS_Deprecated)
|
|
&& (bAllowAbstract || !CheckClass->HasAnyClassFlags(CLASS_Abstract));
|
|
}
|
|
|
|
FText GetToolTipText( const UProperty* const Property )
|
|
{
|
|
if( Property )
|
|
{
|
|
return Property->GetToolTipText();
|
|
}
|
|
|
|
return FText::GetEmpty();
|
|
}
|
|
|
|
FString GetDocumentationLink( const UProperty* const Property )
|
|
{
|
|
if ( Property != NULL )
|
|
{
|
|
UStruct* OwnerStruct = Property->GetOwnerStruct();
|
|
|
|
if ( OwnerStruct != NULL )
|
|
{
|
|
return FString::Printf( TEXT("Shared/Types/%s%s"), OwnerStruct->GetPrefixCPP(), *OwnerStruct->GetName() );
|
|
}
|
|
}
|
|
|
|
return TEXT("");
|
|
}
|
|
|
|
FString GetEnumDocumentationLink(const UProperty* const Property)
|
|
{
|
|
if(Property != NULL)
|
|
{
|
|
const UByteProperty* ByteProperty = Cast<UByteProperty>(Property);
|
|
const UEnumProperty* EnumProperty = Cast<UEnumProperty>(Property);
|
|
if(ByteProperty || EnumProperty || (Property->IsA(UStrProperty::StaticClass()) && Property->HasMetaData(TEXT("Enum"))))
|
|
{
|
|
UEnum* Enum = nullptr;
|
|
if(ByteProperty)
|
|
{
|
|
Enum = ByteProperty->Enum;
|
|
}
|
|
else if (EnumProperty)
|
|
{
|
|
Enum = EnumProperty->GetEnum();
|
|
}
|
|
else
|
|
{
|
|
|
|
FString EnumName = Property->GetMetaData(TEXT("Enum"));
|
|
Enum = FindObject<UEnum>(ANY_PACKAGE, *EnumName, true);
|
|
}
|
|
|
|
if(Enum)
|
|
{
|
|
return FString::Printf(TEXT("Shared/Enums/%s"), *Enum->GetName());
|
|
}
|
|
}
|
|
}
|
|
|
|
return TEXT("");
|
|
}
|
|
|
|
FString GetDocumentationExcerptName(const UProperty* const Property)
|
|
{
|
|
if ( Property != NULL )
|
|
{
|
|
return Property->GetName();
|
|
}
|
|
|
|
return TEXT("");
|
|
}
|
|
|
|
TSharedPtr<IPropertyHandle> GetPropertyHandle( TSharedRef<FPropertyNode> PropertyNode, FNotifyHook* NotifyHook, TSharedPtr<IPropertyUtilities> PropertyUtilities )
|
|
{
|
|
TSharedPtr<IPropertyHandle> PropertyHandle;
|
|
|
|
// Always check arrays first, many types can be static arrays
|
|
if( FPropertyHandleArray::Supports( PropertyNode ) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleArray( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else if( FPropertyHandleInt::Supports( PropertyNode ) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleInt( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else if( FPropertyHandleFloat::Supports( PropertyNode ) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleFloat( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else if ( FPropertyHandleDouble::Supports( PropertyNode ) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleDouble( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else if( FPropertyHandleBool::Supports( PropertyNode ) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleBool( PropertyNode, NotifyHook, PropertyUtilities ) ) ;
|
|
}
|
|
else if( FPropertyHandleByte::Supports( PropertyNode ) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleByte( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else if( FPropertyHandleObject::Supports( PropertyNode ) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleObject( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else if( FPropertyHandleString::Supports( PropertyNode ) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleString( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else if (FPropertyHandleText::Supports(PropertyNode))
|
|
{
|
|
PropertyHandle = MakeShareable(new FPropertyHandleText(PropertyNode, NotifyHook, PropertyUtilities));
|
|
}
|
|
else if( FPropertyHandleVector::Supports( PropertyNode ) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleVector( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else if( FPropertyHandleRotator::Supports( PropertyNode ) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleRotator( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else if (FPropertyHandleSet::Supports(PropertyNode))
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleSet( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else if ( FPropertyHandleMap::Supports(PropertyNode) )
|
|
{
|
|
PropertyHandle = MakeShareable( new FPropertyHandleMap( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
else
|
|
{
|
|
// Untyped or doesn't support getting the property directly but the property is still valid(probably struct property)
|
|
PropertyHandle = MakeShareable( new FPropertyHandleBase( PropertyNode, NotifyHook, PropertyUtilities ) );
|
|
}
|
|
|
|
return PropertyHandle;
|
|
}
|
|
|
|
static bool SupportsObjectPropertyButtons( UProperty* NodeProperty, bool bUsingAssetPicker )
|
|
{
|
|
return (NodeProperty->IsA<UObjectPropertyBase>() || NodeProperty->IsA<UInterfaceProperty>()) && (!bUsingAssetPicker || !SPropertyEditorAsset::Supports(NodeProperty));
|
|
}
|
|
|
|
static bool IsStringAssetReference( const UProperty* Property )
|
|
{
|
|
bool bIsStringAssetRef = false;
|
|
|
|
const UStructProperty* StructProp = Cast<const UStructProperty>( Property );
|
|
if( StructProp && StructProp->Struct )
|
|
{
|
|
FName StructName = StructProp->Struct->GetFName();
|
|
|
|
static const FName StringAssetRef("StringAssetReference");
|
|
|
|
bIsStringAssetRef = StructName == StringAssetRef;
|
|
}
|
|
|
|
return bIsStringAssetRef;
|
|
}
|
|
|
|
static bool IsStringClassReference( const UProperty* Property )
|
|
{
|
|
bool bIsStringClassRef = false;
|
|
|
|
const UStructProperty* StructProp = Cast<const UStructProperty>( Property );
|
|
if( StructProp && StructProp->Struct )
|
|
{
|
|
FName StructName = StructProp->Struct->GetFName();
|
|
|
|
static const FName StringClassRef("StringClassReference");
|
|
|
|
bIsStringClassRef = StructName == StringClassRef;
|
|
}
|
|
|
|
return bIsStringClassRef;
|
|
}
|
|
|
|
void GetRequiredPropertyButtons( TSharedRef<FPropertyNode> PropertyNode, TArray<EPropertyButton::Type>& OutRequiredButtons, bool bUsingAssetPicker )
|
|
{
|
|
UProperty* NodeProperty = PropertyNode->GetProperty();
|
|
|
|
// If no property is bound, don't create any buttons.
|
|
if ( !NodeProperty )
|
|
{
|
|
return;
|
|
}
|
|
|
|
// If the property is an item of a const container, don't create any buttons.
|
|
const UArrayProperty* OuterArrayProp = Cast<UArrayProperty>( NodeProperty->GetOuter() );
|
|
const USetProperty* OuterSetProp = Cast<USetProperty>( NodeProperty->GetOuter() );
|
|
const UMapProperty* OuterMapProp = Cast<UMapProperty>( NodeProperty->GetOuter() );
|
|
|
|
//////////////////////////////
|
|
// Handle a container property.
|
|
if( NodeProperty->IsA(UArrayProperty::StaticClass()) || NodeProperty->IsA(USetProperty::StaticClass()) || NodeProperty->IsA(UMapProperty::StaticClass()) )
|
|
{
|
|
if (!NodeProperty->IsA(UArrayProperty::StaticClass()))
|
|
{
|
|
// Only Sets and Maps get a Documentation widget
|
|
OutRequiredButtons.Add(EPropertyButton::Documentation);
|
|
}
|
|
|
|
if( !(NodeProperty->PropertyFlags & CPF_EditFixedSize) )
|
|
{
|
|
OutRequiredButtons.Add( EPropertyButton::Add );
|
|
OutRequiredButtons.Add( EPropertyButton::Empty );
|
|
}
|
|
}
|
|
|
|
//////////////////////////////
|
|
// Handle an object property.
|
|
|
|
|
|
if( SupportsObjectPropertyButtons( NodeProperty, bUsingAssetPicker ) )
|
|
{
|
|
//ignore this node if the consistency check should happen for the children
|
|
bool bStaticSizedArray = (NodeProperty->ArrayDim > 1) && (PropertyNode->GetArrayIndex() == -1);
|
|
if (!bStaticSizedArray)
|
|
{
|
|
if( PropertyNode->HasNodeFlags(EPropertyNodeFlags::EditInlineNew) )
|
|
{
|
|
// hmmm, seems like this code could be removed and the code inside the 'if <UClassProperty>' check
|
|
// below could be moved outside the else....but is there a reason to allow class properties to have the
|
|
// following buttons if the class property is marked 'editinline' (which is effectively what this logic is doing)
|
|
if( !(NodeProperty->PropertyFlags & CPF_NoClear) )
|
|
{
|
|
OutRequiredButtons.Add( EPropertyButton::Clear );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// ignore class properties
|
|
if( (Cast<const UClassProperty>( NodeProperty ) == NULL) && (Cast<const UAssetClassProperty>( NodeProperty ) == NULL) )
|
|
{
|
|
UObjectPropertyBase* ObjectProperty = Cast<UObjectPropertyBase>( NodeProperty );
|
|
|
|
if( ObjectProperty && ObjectProperty->PropertyClass->IsChildOf( AActor::StaticClass() ) )
|
|
{
|
|
// add button for picking the actor from the viewport
|
|
OutRequiredButtons.Add( EPropertyButton::PickActorInteractive );
|
|
}
|
|
else
|
|
{
|
|
// add button for filling the value of this item with the selected object from the GB
|
|
OutRequiredButtons.Add( EPropertyButton::Use );
|
|
}
|
|
|
|
// add button to display the generic browser
|
|
OutRequiredButtons.Add( EPropertyButton::Browse );
|
|
|
|
// reference to object resource that isn't dynamically created (i.e. some content package)
|
|
if( !(NodeProperty->PropertyFlags & CPF_NoClear) )
|
|
{
|
|
// add button to clear the text
|
|
OutRequiredButtons.Add( EPropertyButton::Clear );
|
|
}
|
|
|
|
// Do not allow actor object properties to show the asset picker
|
|
if( ( ObjectProperty && !ObjectProperty->PropertyClass->IsChildOf( AActor::StaticClass() ) ) || IsStringAssetReference(NodeProperty) )
|
|
{
|
|
// add button for picking the asset from an asset picker
|
|
OutRequiredButtons.Add( EPropertyButton::PickAsset );
|
|
}
|
|
else if( ObjectProperty && ObjectProperty->PropertyClass->IsChildOf( AActor::StaticClass() ) )
|
|
{
|
|
// add button for picking the actor from the scene outliner
|
|
OutRequiredButtons.Add( EPropertyButton::PickActor );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//////////////////////////////
|
|
// Handle a class property.
|
|
|
|
UClassProperty* ClassProp = Cast<UClassProperty>(NodeProperty);
|
|
if( ClassProp || IsStringClassReference(NodeProperty))
|
|
{
|
|
OutRequiredButtons.Add( EPropertyButton::Use );
|
|
OutRequiredButtons.Add( EPropertyButton::Browse );
|
|
|
|
UClass* Class = (ClassProp ? ClassProp->MetaClass : FEditorClassUtils::GetClassFromString(NodeProperty->GetMetaData("MetaClass")));
|
|
|
|
if (Class && FKismetEditorUtilities::CanCreateBlueprintOfClass(Class) && !NodeProperty->HasMetaData("DisallowCreateNew"))
|
|
{
|
|
OutRequiredButtons.Add( EPropertyButton::NewBlueprint );
|
|
}
|
|
|
|
if( !(NodeProperty->PropertyFlags & CPF_NoClear) )
|
|
{
|
|
OutRequiredButtons.Add( EPropertyButton::Clear );
|
|
}
|
|
}
|
|
else if (NodeProperty->IsA<UAssetClassProperty>() )
|
|
{
|
|
OutRequiredButtons.Add( EPropertyButton::Use );
|
|
|
|
OutRequiredButtons.Add( EPropertyButton::Browse );
|
|
|
|
if( !(NodeProperty->PropertyFlags & CPF_NoClear) )
|
|
{
|
|
OutRequiredButtons.Add( EPropertyButton::Clear );
|
|
}
|
|
}
|
|
|
|
if( OuterArrayProp )
|
|
{
|
|
if( PropertyNode->HasNodeFlags(EPropertyNodeFlags::SingleSelectOnly) && !(OuterArrayProp->PropertyFlags & CPF_EditFixedSize) )
|
|
{
|
|
if (OuterArrayProp->HasMetaData(TEXT("NoElementDuplicate")))
|
|
{
|
|
OutRequiredButtons.Add( EPropertyButton::Insert_Delete );
|
|
}
|
|
else
|
|
{
|
|
OutRequiredButtons.Add( EPropertyButton::Insert_Delete_Duplicate );
|
|
}
|
|
}
|
|
}
|
|
|
|
if (OuterSetProp || OuterMapProp)
|
|
{
|
|
UProperty* OuterNodeProperty = Cast<UProperty>(NodeProperty->GetOuter());
|
|
|
|
if ( PropertyNode->HasNodeFlags(EPropertyNodeFlags::SingleSelectOnly) && !(OuterNodeProperty->PropertyFlags & CPF_EditFixedSize) )
|
|
{
|
|
OutRequiredButtons.Add(EPropertyButton::Delete);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void MakeRequiredPropertyButtons( const TSharedRef<FPropertyNode>& PropertyNode, const TSharedRef<IPropertyUtilities>& PropertyUtilities, TArray< TSharedRef<SWidget> >& OutButtons, const TArray<EPropertyButton::Type>& ButtonsToIgnore, bool bUsingAssetPicker )
|
|
{
|
|
const TSharedRef<FPropertyEditor> PropertyEditor = FPropertyEditor::Create( PropertyNode, PropertyUtilities );
|
|
PropertyEditorHelpers::MakeRequiredPropertyButtons( PropertyEditor, OutButtons, ButtonsToIgnore, bUsingAssetPicker );
|
|
}
|
|
|
|
void MakeRequiredPropertyButtons( const TSharedRef< FPropertyEditor >& PropertyEditor, TArray< TSharedRef<SWidget> >& OutButtons, const TArray<EPropertyButton::Type>& ButtonsToIgnore, bool bUsingAssetPicker )
|
|
{
|
|
TArray< EPropertyButton::Type > RequiredButtons;
|
|
GetRequiredPropertyButtons( PropertyEditor->GetPropertyNode(), RequiredButtons, bUsingAssetPicker );
|
|
|
|
for( int32 ButtonIndex = 0; ButtonIndex < RequiredButtons.Num(); ++ButtonIndex )
|
|
{
|
|
if( !ButtonsToIgnore.Contains( RequiredButtons[ButtonIndex] ) )
|
|
{
|
|
OutButtons.Add( MakePropertyButton( RequiredButtons[ButtonIndex], PropertyEditor ) );
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A helper function that retrieves the path name of the currently selected
|
|
* item (the value that will be used to set the associated property from the
|
|
* "use selection" button)
|
|
*
|
|
* @param PropertyNode The associated property that the selection is a candidate for.
|
|
* @return Empty if the selection isn't compatible with the specified property, else the path-name of the object/class selected in the editor.
|
|
*/
|
|
static FString GetSelectionPathNameForProperty(TSharedRef<FPropertyNode> PropertyNode)
|
|
{
|
|
FString SelectionPathName;
|
|
|
|
UProperty* Property = PropertyNode->GetProperty();
|
|
UClassProperty* ClassProperty = Cast<UClassProperty>(Property);
|
|
UAssetClassProperty* AssetClassProperty = Cast<UAssetClassProperty>(Property);
|
|
|
|
if (ClassProperty || AssetClassProperty)
|
|
{
|
|
UClass const* const SelectedClass = GEditor->GetFirstSelectedClass(ClassProperty ? ClassProperty->MetaClass : AssetClassProperty->MetaClass);
|
|
if (SelectedClass != nullptr)
|
|
{
|
|
SelectionPathName = SelectedClass->GetPathName();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UClass* ObjectClass = UObject::StaticClass();
|
|
|
|
bool bMustBeLevelActor = false;
|
|
UClass* RequiredInterface = nullptr;
|
|
|
|
if (UObjectPropertyBase* ObjectProperty = Cast<UObjectPropertyBase>(Property))
|
|
{
|
|
ObjectClass = ObjectProperty->PropertyClass;
|
|
bMustBeLevelActor = ObjectProperty->GetOwnerProperty()->GetBoolMetaData(TEXT("MustBeLevelActor"));
|
|
RequiredInterface = ObjectProperty->GetOwnerProperty()->GetClassMetaData(TEXT("MustImplement"));
|
|
}
|
|
else if (UInterfaceProperty* InterfaceProperty = Cast<UInterfaceProperty>(Property))
|
|
{
|
|
ObjectClass = InterfaceProperty->InterfaceClass;
|
|
}
|
|
|
|
UObject* SelectedObject = nullptr;
|
|
if (bMustBeLevelActor)
|
|
{
|
|
USelection* const SelectedSet = GEditor->GetSelectedActors();
|
|
SelectedObject = SelectedSet->GetTop(ObjectClass, RequiredInterface);
|
|
}
|
|
else
|
|
{
|
|
USelection* const SelectedSet = GEditor->GetSelectedSet(ObjectClass);
|
|
SelectedObject = SelectedSet->GetTop(ObjectClass, RequiredInterface);
|
|
}
|
|
|
|
if (SelectedObject != nullptr)
|
|
{
|
|
SelectionPathName = SelectedObject->GetPathName();
|
|
}
|
|
}
|
|
|
|
return SelectionPathName;
|
|
}
|
|
|
|
|
|
static bool IsPropertyButtonEnabled( TWeakPtr<FPropertyNode> PropertyNode )
|
|
{
|
|
return PropertyNode.IsValid() ? !PropertyNode.Pin()->IsEditConst() : false;
|
|
}
|
|
|
|
/**
|
|
* A helper method that checks to see if the editor's current selection is
|
|
* compatible with the specified property.
|
|
*
|
|
* @param PropertyNode The property you desire to set from the "use selected" button.
|
|
* @return False if the currently selected object is restricted for the specified property, true otherwise.
|
|
*/
|
|
static bool IsUseSelectedUnrestricted(TWeakPtr<FPropertyNode> PropertyNode)
|
|
{
|
|
TSharedPtr<FPropertyNode> PropertyNodePin = PropertyNode.Pin();
|
|
return ( PropertyNodePin.IsValid() && IsPropertyButtonEnabled(PropertyNode) ) ? !PropertyNodePin->IsRestricted( GetSelectionPathNameForProperty( PropertyNodePin.ToSharedRef() ) ) : false;
|
|
}
|
|
|
|
/**
|
|
* A helper method that checks to see if the editor's current selection is
|
|
* restricted, and then returns a tooltip explaining why (otherwise, it
|
|
* returns a default explanation of the "use selected" button).
|
|
*
|
|
* @param PropertyNode The property that would be set from the "use selected" button.
|
|
* @return A tooltip for the "use selected" button.
|
|
*/
|
|
static FText GetUseSelectedTooltip(TWeakPtr<FPropertyNode> PropertyNode)
|
|
{
|
|
TSharedPtr<FPropertyNode> PropertyNodePin = PropertyNode.Pin();
|
|
FText ToolTip;
|
|
if (PropertyNodePin.IsValid() && !PropertyNodePin->GenerateRestrictionToolTip(GetSelectionPathNameForProperty(PropertyNodePin.ToSharedRef()), ToolTip))
|
|
{
|
|
ToolTip = LOCTEXT("UseButtonToolTipText", "Use Selected Asset from Content Browser");
|
|
}
|
|
|
|
return ToolTip;
|
|
}
|
|
|
|
TSharedRef<SWidget> MakePropertyButton( const EPropertyButton::Type ButtonType, const TSharedRef< FPropertyEditor >& PropertyEditor )
|
|
{
|
|
TSharedPtr<SWidget> NewButton;
|
|
|
|
TWeakPtr<FPropertyNode> WeakPropertyEditor = PropertyEditor->GetPropertyNode();
|
|
|
|
TAttribute<bool>::FGetter IsPropertyButtonEnabledDelegate = TAttribute<bool>::FGetter::CreateStatic(&IsPropertyButtonEnabled, WeakPropertyEditor);
|
|
TAttribute<bool> IsEnabledAttribute = TAttribute<bool>::Create( IsPropertyButtonEnabledDelegate );
|
|
|
|
switch( ButtonType )
|
|
{
|
|
case EPropertyButton::Add:
|
|
NewButton = PropertyCustomizationHelpers::MakeAddButton( FSimpleDelegate::CreateSP( PropertyEditor, &FPropertyEditor::AddItem ), FText(), IsEnabledAttribute );
|
|
break;
|
|
|
|
case EPropertyButton::Empty:
|
|
NewButton = PropertyCustomizationHelpers::MakeEmptyButton( FSimpleDelegate::CreateSP( PropertyEditor, &FPropertyEditor::EmptyArray ), FText(), IsEnabledAttribute );
|
|
break;
|
|
|
|
case EPropertyButton::Delete:
|
|
case EPropertyButton::Insert_Delete:
|
|
case EPropertyButton::Insert_Delete_Duplicate:
|
|
{
|
|
FExecuteAction InsertAction;
|
|
FExecuteAction DeleteAction = FExecuteAction::CreateSP( PropertyEditor, &FPropertyEditor::DeleteItem );
|
|
FExecuteAction DuplicateAction;
|
|
|
|
if (ButtonType == EPropertyButton::Insert_Delete || ButtonType == EPropertyButton::Insert_Delete_Duplicate)
|
|
{
|
|
InsertAction = FExecuteAction::CreateSP(PropertyEditor, &FPropertyEditor::InsertItem);
|
|
}
|
|
|
|
if (ButtonType == EPropertyButton::Insert_Delete_Duplicate)
|
|
{
|
|
DuplicateAction = FExecuteAction::CreateSP( PropertyEditor, &FPropertyEditor::DuplicateItem );
|
|
}
|
|
|
|
NewButton = PropertyCustomizationHelpers::MakeInsertDeleteDuplicateButton( InsertAction, DeleteAction, DuplicateAction );
|
|
NewButton->SetEnabled( IsEnabledAttribute );
|
|
break;
|
|
}
|
|
|
|
case EPropertyButton::Browse:
|
|
NewButton = PropertyCustomizationHelpers::MakeBrowseButton( FSimpleDelegate::CreateSP( PropertyEditor, &FPropertyEditor::BrowseTo ) );
|
|
break;
|
|
|
|
case EPropertyButton::Clear:
|
|
NewButton = PropertyCustomizationHelpers::MakeClearButton( FSimpleDelegate::CreateSP( PropertyEditor, &FPropertyEditor::ClearItem ), FText(), IsEnabledAttribute );
|
|
break;
|
|
|
|
case EPropertyButton::Use:
|
|
{
|
|
FSimpleDelegate OnClickDelegate = FSimpleDelegate::CreateSP(PropertyEditor, &FPropertyEditor::UseSelected);
|
|
TAttribute<bool>::FGetter EnabledDelegate = TAttribute<bool>::FGetter::CreateStatic(&IsUseSelectedUnrestricted, WeakPropertyEditor);
|
|
TAttribute<FText>::FGetter TooltipDelegate = TAttribute<FText>::FGetter::CreateStatic(&GetUseSelectedTooltip, WeakPropertyEditor);
|
|
|
|
NewButton = PropertyCustomizationHelpers::MakeUseSelectedButton(OnClickDelegate, TAttribute<FText>::Create(TooltipDelegate), TAttribute<bool>::Create(EnabledDelegate));
|
|
break;
|
|
}
|
|
|
|
case EPropertyButton::PickAsset:
|
|
NewButton = PropertyCustomizationHelpers::MakeAssetPickerAnchorButton( FOnGetAllowedClasses::CreateSP( PropertyEditor, &FPropertyEditor::OnGetClassesForAssetPicker ), FOnAssetSelected::CreateSP( PropertyEditor, &FPropertyEditor::OnAssetSelected ) );
|
|
break;
|
|
|
|
case EPropertyButton::PickActor:
|
|
NewButton = PropertyCustomizationHelpers::MakeActorPickerAnchorButton( FOnGetActorFilters::CreateSP( PropertyEditor, &FPropertyEditor::OnGetActorFiltersForSceneOutliner ), FOnActorSelected::CreateSP( PropertyEditor, &FPropertyEditor::OnActorSelected ) );
|
|
break;
|
|
|
|
case EPropertyButton::PickActorInteractive:
|
|
NewButton = PropertyCustomizationHelpers::MakeInteractiveActorPicker( FOnGetAllowedClasses::CreateSP( PropertyEditor, &FPropertyEditor::OnGetClassesForAssetPicker ), FOnShouldFilterActor(), FOnActorSelected::CreateSP( PropertyEditor, &FPropertyEditor::OnActorSelected ) );
|
|
break;
|
|
|
|
case EPropertyButton::NewBlueprint:
|
|
NewButton = PropertyCustomizationHelpers::MakeNewBlueprintButton( FSimpleDelegate::CreateSP( PropertyEditor, &FPropertyEditor::MakeNewBlueprint ) );
|
|
break;
|
|
|
|
case EPropertyButton::EditConfigHierarchy:
|
|
NewButton = PropertyCustomizationHelpers::MakeEditConfigHierarchyButton(FSimpleDelegate::CreateSP(PropertyEditor, &FPropertyEditor::EditConfigHierarchy));
|
|
break;
|
|
|
|
case EPropertyButton::Documentation:
|
|
NewButton = PropertyCustomizationHelpers::MakeDocumentationButton(PropertyEditor);
|
|
break;
|
|
|
|
default:
|
|
checkf( 0, TEXT( "Unknown button type" ) );
|
|
break;
|
|
}
|
|
|
|
return NewButton.ToSharedRef();
|
|
}
|
|
|
|
void CollectObjectNodes( TSharedPtr<FPropertyNode> StartNode, TArray<FObjectPropertyNode*>& OutObjectNodes )
|
|
{
|
|
if( StartNode->AsObjectNode() != NULL )
|
|
{
|
|
OutObjectNodes.Add( StartNode->AsObjectNode() );
|
|
}
|
|
|
|
for( int32 ChildIndex = 0; ChildIndex < StartNode->GetNumChildNodes(); ++ChildIndex )
|
|
{
|
|
CollectObjectNodes( StartNode->GetChildNode( ChildIndex ), OutObjectNodes );
|
|
}
|
|
|
|
}
|
|
|
|
TArray<FName> GetValidEnumsFromPropertyOverride(const UProperty* Property, const UEnum* InEnum)
|
|
{
|
|
TArray<FName> ValidEnumValues;
|
|
|
|
static const FName ValidEnumValuesName("ValidEnumValues");
|
|
if(Property->HasMetaData(ValidEnumValuesName))
|
|
{
|
|
TArray<FString> ValidEnumValuesAsString;
|
|
|
|
Property->GetMetaData(ValidEnumValuesName).ParseIntoArray(ValidEnumValuesAsString, TEXT(","));
|
|
for(auto& Value : ValidEnumValuesAsString)
|
|
{
|
|
Value.Trim();
|
|
ValidEnumValues.Add(*InEnum->GenerateFullEnumName(*Value));
|
|
}
|
|
}
|
|
|
|
return ValidEnumValues;
|
|
}
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|