SContentBrowserPathPicker.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
  2. #pragma once
  3. #include "CoreMinimal.h"
  4. #include "Widgets/DeclarativeSyntaxSupport.h"
  5. #include "Input/Reply.h"
  6. #include "Widgets/SCompoundWidget.h"
  7. class SEditableTextBox;
  8. class SWindow;
  9. //////////////////////////////////////////////////////////////////////////
  10. // SCreateAssetFromActor
  11. DECLARE_DELEGATE_OneParam(FOnPathChosen, const FString&);
  12. class SContentBrowserPathPicker : public SCompoundWidget
  13. {
  14. public:
  15. SLATE_BEGIN_ARGS(SContentBrowserPathPicker)
  16. : _AssetFilenameSuffix()
  17. , _HeadingText()
  18. , _CreateButtonText()
  19. {}
  20. /** The default suffix to use for the asset filename */
  21. SLATE_ARGUMENT(FString, AssetFilenameSuffix)
  22. /** The text to display at the top of the dialog */
  23. SLATE_ARGUMENT(FText, HeadingText)
  24. /** The label for the create button */
  25. SLATE_ARGUMENT(FText, CreateButtonText)
  26. SLATE_ARGUMENT(FText, DefaultNameOverride)
  27. /** Action to perform when create clicked */
  28. SLATE_EVENT(FOnPathChosen, OnCreateAssetAction)
  29. SLATE_END_ARGS()
  30. /** Constructs this widget with InArgs */
  31. void Construct(const FArguments& InArgs, TSharedPtr<SWindow> InParentWindow);
  32. private:
  33. /** Callback when the "create asset" button is clicked. */
  34. FReply OnCreateAssetFromActorClicked();
  35. /** Callback when the selected asset path has changed. */
  36. void OnSelectAssetPath(const FString& Path);
  37. /** Destroys the window when the operation is cancelled. */
  38. FReply OnCancelCreateAssetFromActor();
  39. /** Callback when level selection has changed, will destroy the window. */
  40. void OnLevelSelectionChanged(UObject* InObjectSelected);
  41. /** Callback when the user changes the filename for the Blueprint */
  42. void OnFilenameChanged(const FText& InNewName);
  43. /** Callback to see if creating an asset is enabled */
  44. bool IsCreateAssetFromActorEnabled() const;
  45. /** Rquest to destroy the parent window */
  46. void RequestDestroyParentWindow();
  47. bool ISContentBrowserPathPickerEnabled() const;
  48. private:
  49. static FString LastAssetPath;
  50. private:
  51. /** The window this widget is nested in */
  52. TWeakPtr<SWindow> ParentWindow;
  53. /** The selected path to create the asset */
  54. FString AssetPath;
  55. /** The resultant actor instance label, based on the original actor labels */
  56. FString ActorInstanceLabel;
  57. /** The default suffix to use for the asset filename */
  58. FString AssetFilenameSuffix;
  59. /** The text to display as a heading for the dialog */
  60. FText HeadingText;
  61. /** The label to be displayed on the create button */
  62. FText CreateButtonText;
  63. /** Filename textbox widget */
  64. TSharedPtr<SEditableTextBox> FileNameWidget;
  65. /** True if an error is currently being reported */
  66. bool bIsReportingError;
  67. /** Called when the create button is clicked */
  68. FOnPathChosen OnCreateAssetAction;
  69. /** Used to keep track of the delegate in the selection event */
  70. FDelegateHandle SelectionDelegateHandle;
  71. };