88#include " AssetViewerSettings.h"
99#include " Launch/Resources/Version.h"
1010#include " Components/DirectionalLightComponent.h"
11+ #if ENGINE_MAJOR_VERSION > 4
12+ #include " UnrealWidget.h"
13+ #endif
1114
1215#define LOCTEXT_NAMESPACE " JavascriptEditor"
1316
1417PRAGMA_DISABLE_SHADOW_VARIABLE_WARNINGS
1518
19+ #if ENGINE_MAJOR_VERSION > 4
20+ namespace WidgetAlias = UE::Widget;
21+ #else
22+ using WidgetAlias = FWidget;
23+ #endif
24+
1625class FJavascriptPreviewScene : public FAdvancedPreviewScene
1726{
1827public:
@@ -38,7 +47,7 @@ class FJavascriptPreviewScene : public FAdvancedPreviewScene
3847 {
3948 return SkyComponent;
4049 }
41- #if ENGINE_MINOR_VERSION < 23
50+ #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 23
4251 class USphereReflectionCaptureComponent * GetDefaultSphereReflectionComponent ()
4352 {
4453 return SphereReflectionComponent;
@@ -208,11 +217,11 @@ class FJavascriptEditorViewportClient : public FEditorViewportClient
208217 }
209218 }
210219
211- virtual FWidget ::EWidgetMode GetWidgetMode () const override
220+ virtual WidgetAlias ::EWidgetMode GetWidgetMode () const override
212221 {
213222 if (Widget.IsValid () && Widget->OnGetWidgetMode .IsBound ())
214223 {
215- return (FWidget ::EWidgetMode)Widget->OnGetWidgetMode .Execute (Widget.Get ());
224+ return (WidgetAlias ::EWidgetMode)Widget->OnGetWidgetMode .Execute (Widget.Get ());
216225 }
217226 else
218227 {
@@ -265,7 +274,7 @@ class FJavascriptEditorViewportClient : public FEditorViewportClient
265274 {
266275 for (FActorIterator It (PreviewScene->GetWorld ()); It; ++It)
267276 {
268- #if ENGINE_MINOR_VERSION > 14
277+ #if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 14) || ENGINE_MAJOR_VERSION > 4
269278 It->DispatchBeginPlay ();
270279#else
271280 if (It->HasActorBegunPlay () == false )
@@ -447,13 +456,13 @@ class SAutoRefreshEditorViewport : public SEditorViewport
447456
448457 void SetWidgetMode (EJavascriptWidgetMode WidgetMode)
449458 {
450- EditorViewportClient->SetWidgetMode (WidgetMode == EJavascriptWidgetMode::WM_None ? FWidget ::WM_None : (FWidget ::EWidgetMode)WidgetMode);
459+ EditorViewportClient->SetWidgetMode (WidgetMode == EJavascriptWidgetMode::WM_None ? WidgetAlias ::WM_None : (WidgetAlias ::EWidgetMode)WidgetMode);
451460 }
452461
453462 EJavascriptWidgetMode GetWidgetMode ()
454463 {
455- FWidget ::EWidgetMode WidgetMode = EditorViewportClient->GetWidgetMode ();
456- return FWidget ::WM_None ? EJavascriptWidgetMode::WM_None : (EJavascriptWidgetMode)WidgetMode;
464+ WidgetAlias ::EWidgetMode WidgetMode = EditorViewportClient->GetWidgetMode ();
465+ return WidgetAlias ::WM_None ? EJavascriptWidgetMode::WM_None : (EJavascriptWidgetMode)WidgetMode;
457466 }
458467
459468 FString GetEngineShowFlags ()
@@ -508,7 +517,7 @@ class SAutoRefreshEditorViewport : public SEditorViewport
508517 {
509518 return PreviewScene.GetDefaultSkySphereComponent ();
510519 }
511- #if ENGINE_MINOR_VERSION < 23
520+ #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 23
512521 class USphereReflectionCaptureComponent * GetDefaultSphereReflectionComponent ()
513522 {
514523 return PreviewScene.GetDefaultSphereReflectionComponent ();
@@ -534,7 +543,7 @@ class SAutoRefreshEditorViewport : public SEditorViewport
534543 UStaticMeshComponent* Component = *Itr;
535544 if (Component && Component->GetOwner () == nullptr )
536545 {
537- #if ENGINE_MINOR_VERSION >= 14
546+ #if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 14) || ENGINE_MAJOR_VERSION > 4
538547 auto StaticMesh = Component->GetStaticMesh ();
539548#else
540549 auto StaticMesh = Component->StaticMesh ;
@@ -838,7 +847,7 @@ void UJavascriptEditorViewport::DeprojectScreenToWorld(const FVector2D &ScreenPo
838847 FSceneViewFamilyContext ViewFamily (FSceneViewFamily::ConstructionValues ( ViewportWidget->EditorViewportClient ->Viewport , ViewportWidget->EditorViewportClient ->GetScene (), ViewportWidget->EditorViewportClient ->EngineShowFlags ));
839848 FSceneView* View = ViewportWidget->EditorViewportClient ->CalcSceneView (&ViewFamily);
840849
841- #if ENGINE_MINOR_VERSION >= 14
850+ #if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 14) || ENGINE_MAJOR_VERSION > 4
842851 const auto & InvViewProjMatrix = View->ViewMatrices .GetInvViewProjectionMatrix ();
843852#else
844853 const auto & InvViewProjMatrix = View->ViewMatrices .GetInvViewProjMatrix ();
@@ -854,7 +863,7 @@ void UJavascriptEditorViewport::ProjectWorldToScreen(const FVector &WorldPositio
854863 FSceneViewFamilyContext ViewFamily (FSceneViewFamily::ConstructionValues ( ViewportWidget->EditorViewportClient ->Viewport , ViewportWidget->EditorViewportClient ->GetScene (), ViewportWidget->EditorViewportClient ->EngineShowFlags ));
855864 FSceneView* View = ViewportWidget->EditorViewportClient ->CalcSceneView (&ViewFamily);
856865
857- #if ENGINE_MINOR_VERSION >= 14
866+ #if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 14) || ENGINE_MAJOR_VERSION > 4
858867 const auto & ViewProjMatrix = View->ViewMatrices .GetViewProjectionMatrix ();
859868#else
860869 const auto & ViewProjMatrix = View->ViewMatrices .GetViewProjMatrix ();
@@ -970,7 +979,7 @@ class UStaticMeshComponent* UJavascriptEditorViewport::GetDefaultSkySphereCompon
970979
971980class USphereReflectionCaptureComponent * UJavascriptEditorViewport::GetDefaultSphereReflectionComponent ()
972981{
973- #if ENGINE_MINOR_VERSION < 23
982+ #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 23
974983 if (ViewportWidget.IsValid ())
975984 {
976985 return ViewportWidget->GetDefaultSphereReflectionComponent ();
0 commit comments