Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/JavascriptEditor/JavascriptEdMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class FJavascriptEdModeFactory : public IEditorModeFactory, public FGCObject
return MakeShareable(new FJavascriptEdModeInstance(Parent));
}

#if ENGINE_MINOR_VERSION < 26
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 26
virtual UEdMode* CreateScriptableMode() const override
{
return nullptr;
Expand Down
43 changes: 27 additions & 16 deletions Source/JavascriptEditor/JavascriptEditor.Build.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using UnrealBuildTool;
using System;
using UnrealBuildTool;

public class JavascriptEditor : ModuleRules
{
public static bool IsVREditorNeeded()
public static Int32[] ParseEditorVersions()
{
string[] VersionHeader = Utils.ReadAllText("../Source/Runtime/Launch/Resources/Version.h").Replace("\r\n", "\n").Replace("\t", " ").Split('\n');
string EngineVersionMajor = "4";
Expand All @@ -18,7 +19,7 @@ public static bool IsVREditorNeeded()
EngineVersionMinor = Line.Split(' ')[2];
}
}
return System.Int32.Parse(EngineVersionMajor) == 4 && System.Int32.Parse(EngineVersionMinor) >= 14;
return new Int32[] { System.Int32.Parse(EngineVersionMajor), System.Int32.Parse(EngineVersionMinor) };
}

public JavascriptEditor(ReadOnlyTargetRules Target) : base(Target)
Expand Down Expand Up @@ -54,7 +55,12 @@ public JavascriptEditor(ReadOnlyTargetRules Target) : base(Target)
}
);

if (IsVREditorNeeded())
var vers = ParseEditorVersions();
var EngineMajorVer = vers[0];
var EngineMinorVer = vers[1];

// Is VREditor Needed?
if (EngineMajorVer > 4 || EngineMinorVer >= 14)
{
PrivateDependencyModuleNames.AddRange(new string []{ "LevelEditor", "ViewportInteraction", "VREditor" });
}
Expand Down Expand Up @@ -95,19 +101,24 @@ public JavascriptEditor(ReadOnlyTargetRules Target) : base(Target)
"StaticMeshEditor"
}
);

if (EngineMajorVer > 4)
{
PrivateDependencyModuleNames.Add("EditorFramework");
}
}

// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64))
// {
// if (UEBuildConfiguration.bCompileSteamOSS == true)
// {
// DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
// }
// }
}
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// if (Target.IsInPlatformGroup(UnrealPlatformGroup.Windows))
// {
// if (UEBuildConfiguration.bCompileSteamOSS == true)
// {
// DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
// }
// }
}
}
28 changes: 23 additions & 5 deletions Source/JavascriptEditor/JavascriptEditorLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@

#include "Engine/DataTable.h"
#include "Engine/EngineTypes.h"
#include "Toolkits/AssetEditorManager.h"
#if ENGINE_MAJOR_VERSION == 4
#include "Toolkits/AssetEditorManager.h"
#endif
#include "Kismet2/KismetEditorUtilities.h"

#if WITH_EDITOR
Expand Down Expand Up @@ -202,18 +204,30 @@ void UJavascriptEditorLibrary::OpenPopupWindow(UWidget* Widget, const FVector2D&

void UJavascriptEditorLibrary::GetAllTags(const FJavascriptAssetData& AssetData, TArray<FName>& OutArray)
{
#if ENGINE_MAJOR_VERSION > 4
AssetData.SourceAssetData.TagsAndValues.CopyMap().GetKeys(OutArray);
#else
AssetData.SourceAssetData.TagsAndValues.GetKeys(OutArray);
#endif
}

bool UJavascriptEditorLibrary::GetTagValue(const FJavascriptAssetData& AssetData, const FName& Name, FString& OutValue)
{
#if ENGINE_MAJOR_VERSION > 4
auto Value = AssetData.SourceAssetData.TagsAndValues.FindTag(Name);
if (Value.IsSet())
{
OutValue = Value.GetValue();
return true;
}
#else
auto Value = AssetData.SourceAssetData.TagsAndValues.GetMap().Find(Name);

if (Value)
{
OutValue = *Value;
return true;
}
#endif
else
{
return false;
Expand Down Expand Up @@ -496,7 +510,7 @@ void UJavascriptEditorLibrary::DrawPolygon(const FJavascriptPDI& PDI, const TArr
}

static auto TransparentPlaneMaterialXY = (UMaterial*)StaticLoadObject(UMaterial::StaticClass(), NULL, TEXT("/Engine/EditorMaterials/WidgetVertexColorMaterial.WidgetVertexColorMaterial"), NULL, LOAD_None, NULL);
#if ENGINE_MINOR_VERSION < 22
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 22
MeshBuilder.Draw(PDI.PDI, FMatrix::Identity, TransparentPlaneMaterialXY->GetRenderProxy(false), DepthPriority, 0.f);
#else
MeshBuilder.Draw(PDI.PDI, FMatrix::Identity, TransparentPlaneMaterialXY->GetRenderProxy(), DepthPriority, 0.f);
Expand Down Expand Up @@ -691,7 +705,11 @@ FJavascriptSlateWidget UJavascriptEditorLibrary::GetRootWindow()
void UJavascriptEditorLibrary::CreatePropertyEditorToolkit(TArray<UObject*> ObjectsForPropertiesMenu)
{
FPropertyEditorModule& PropertyEditorModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
#if ENGINE_MAJOR_VERSION > 4
PropertyEditorModule.CreatePropertyEditorToolkit(TSharedPtr<IToolkitHost>(), ObjectsForPropertiesMenu);
#else
PropertyEditorModule.CreatePropertyEditorToolkit(EToolkitMode::Standalone, TSharedPtr<IToolkitHost>(), ObjectsForPropertiesMenu);
#endif
}

static FName NAME_LevelEditor("LevelEditor");
Expand Down Expand Up @@ -1310,7 +1328,7 @@ bool UJavascriptEditorLibrary::LoadImageFromDiskAsync(const FString& ImagePath,
{
Texture->SRGB = true;
Texture->UpdateResource();
#if ENGINE_MINOR_VERSION < 22
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 22
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
FWriteRawDataToTexture,
FTexture2DDynamicResource*, TextureResource, static_cast<FTexture2DDynamicResource*>(Texture->Resource),
Expand Down Expand Up @@ -1432,7 +1450,7 @@ FString UJavascriptEditorLibrary::GetDataTableAsJSON(UDataTable* InDataTable, ui

void UJavascriptEditorLibrary::AddRichCurve(UCurveTable* InCurveTable, const FName& Key, const FRichCurve& InCurve)
{
#if ENGINE_MINOR_VERSION < 22
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 22
FRichCurve* NewCurve = new FRichCurve();
NewCurve->SetKeys(InCurve.GetConstRefOfKeys());
NewCurve->PreInfinityExtrap = InCurve.PreInfinityExtrap;
Expand Down
33 changes: 21 additions & 12 deletions Source/JavascriptEditor/JavascriptEditorViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
#include "AssetViewerSettings.h"
#include "Launch/Resources/Version.h"
#include "Components/DirectionalLightComponent.h"
#if ENGINE_MAJOR_VERSION > 4
#include "UnrealWidget.h"
#endif

#define LOCTEXT_NAMESPACE "JavascriptEditor"

PRAGMA_DISABLE_SHADOW_VARIABLE_WARNINGS

#if ENGINE_MAJOR_VERSION > 4
namespace WidgetAlias = UE::Widget;
#else
using WidgetAlias = FWidget;
#endif

class FJavascriptPreviewScene : public FAdvancedPreviewScene
{
public:
Expand All @@ -38,7 +47,7 @@ class FJavascriptPreviewScene : public FAdvancedPreviewScene
{
return SkyComponent;
}
#if ENGINE_MINOR_VERSION < 23
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 23
class USphereReflectionCaptureComponent* GetDefaultSphereReflectionComponent()
{
return SphereReflectionComponent;
Expand Down Expand Up @@ -208,11 +217,11 @@ class FJavascriptEditorViewportClient : public FEditorViewportClient
}
}

virtual FWidget::EWidgetMode GetWidgetMode() const override
virtual WidgetAlias::EWidgetMode GetWidgetMode() const override
{
if (Widget.IsValid() && Widget->OnGetWidgetMode.IsBound())
{
return (FWidget::EWidgetMode)Widget->OnGetWidgetMode.Execute(Widget.Get());
return (WidgetAlias::EWidgetMode)Widget->OnGetWidgetMode.Execute(Widget.Get());
}
else
{
Expand Down Expand Up @@ -265,7 +274,7 @@ class FJavascriptEditorViewportClient : public FEditorViewportClient
{
for (FActorIterator It(PreviewScene->GetWorld()); It; ++It)
{
#if ENGINE_MINOR_VERSION > 14
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 14) || ENGINE_MAJOR_VERSION > 4
It->DispatchBeginPlay();
#else
if (It->HasActorBegunPlay() == false)
Expand Down Expand Up @@ -447,13 +456,13 @@ class SAutoRefreshEditorViewport : public SEditorViewport

void SetWidgetMode(EJavascriptWidgetMode WidgetMode)
{
EditorViewportClient->SetWidgetMode(WidgetMode == EJavascriptWidgetMode::WM_None ? FWidget::WM_None : (FWidget::EWidgetMode)WidgetMode);
EditorViewportClient->SetWidgetMode(WidgetMode == EJavascriptWidgetMode::WM_None ? WidgetAlias::WM_None : (WidgetAlias::EWidgetMode)WidgetMode);
}

EJavascriptWidgetMode GetWidgetMode()
{
FWidget::EWidgetMode WidgetMode = EditorViewportClient->GetWidgetMode();
return FWidget::WM_None ? EJavascriptWidgetMode::WM_None : (EJavascriptWidgetMode)WidgetMode;
WidgetAlias::EWidgetMode WidgetMode = EditorViewportClient->GetWidgetMode();
return WidgetAlias::WM_None ? EJavascriptWidgetMode::WM_None : (EJavascriptWidgetMode)WidgetMode;
}

FString GetEngineShowFlags()
Expand Down Expand Up @@ -508,7 +517,7 @@ class SAutoRefreshEditorViewport : public SEditorViewport
{
return PreviewScene.GetDefaultSkySphereComponent();
}
#if ENGINE_MINOR_VERSION < 23
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 23
class USphereReflectionCaptureComponent* GetDefaultSphereReflectionComponent()
{
return PreviewScene.GetDefaultSphereReflectionComponent();
Expand All @@ -534,7 +543,7 @@ class SAutoRefreshEditorViewport : public SEditorViewport
UStaticMeshComponent* Component = *Itr;
if (Component && Component->GetOwner() == nullptr)
{
#if ENGINE_MINOR_VERSION >= 14
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 14) || ENGINE_MAJOR_VERSION > 4
auto StaticMesh = Component->GetStaticMesh();
#else
auto StaticMesh = Component->StaticMesh;
Expand Down Expand Up @@ -838,7 +847,7 @@ void UJavascriptEditorViewport::DeprojectScreenToWorld(const FVector2D &ScreenPo
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues( ViewportWidget->EditorViewportClient->Viewport, ViewportWidget->EditorViewportClient->GetScene(), ViewportWidget->EditorViewportClient->EngineShowFlags ));
FSceneView* View = ViewportWidget->EditorViewportClient->CalcSceneView(&ViewFamily);

#if ENGINE_MINOR_VERSION >= 14
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 14) || ENGINE_MAJOR_VERSION > 4
const auto& InvViewProjMatrix = View->ViewMatrices.GetInvViewProjectionMatrix();
#else
const auto& InvViewProjMatrix = View->ViewMatrices.GetInvViewProjMatrix();
Expand All @@ -854,7 +863,7 @@ void UJavascriptEditorViewport::ProjectWorldToScreen(const FVector &WorldPositio
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues( ViewportWidget->EditorViewportClient->Viewport, ViewportWidget->EditorViewportClient->GetScene(), ViewportWidget->EditorViewportClient->EngineShowFlags ));
FSceneView* View = ViewportWidget->EditorViewportClient->CalcSceneView(&ViewFamily);

#if ENGINE_MINOR_VERSION >= 14
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 14) || ENGINE_MAJOR_VERSION > 4
const auto& ViewProjMatrix = View->ViewMatrices.GetViewProjectionMatrix();
#else
const auto& ViewProjMatrix = View->ViewMatrices.GetViewProjMatrix();
Expand Down Expand Up @@ -970,7 +979,7 @@ class UStaticMeshComponent* UJavascriptEditorViewport::GetDefaultSkySphereCompon

class USphereReflectionCaptureComponent* UJavascriptEditorViewport::GetDefaultSphereReflectionComponent()
{
#if ENGINE_MINOR_VERSION < 23
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 23
if (ViewportWidget.IsValid())
{
return ViewportWidget->GetDefaultSphereReflectionComponent();
Expand Down
10 changes: 7 additions & 3 deletions Source/JavascriptEditor/JavascriptMenuLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ void UJavascriptMenuLibrary::AddSeparator(FJavascriptMenuBuilder& Builder)
else if (Builder.ToolMenu)
{
FToolMenuSection& Section = Builder.ToolMenu->Sections.Num() > 0 ? Builder.ToolMenu->Sections.Top() : Builder.ToolMenu->AddSection(FName());
#if ENGINE_MAJOR_VERSION > 4
Section.AddSeparator(FName());
#else
Section.AddMenuSeparator(FName());
#endif
}
}

Expand Down Expand Up @@ -152,7 +156,7 @@ void UJavascriptMenuLibrary::AddMenuEntry(FJavascriptMenuBuilder& Builder, UJava
DefaultAction.CanExecuteAction = FCanExecuteAction::CreateUObject(Object, &UJavascriptMenuContext::Public_CanExecute);
DefaultAction.ExecuteAction = FExecuteAction::CreateUObject(Object, &UJavascriptMenuContext::Public_Execute);
DefaultAction.GetActionCheckState = FGetActionCheckState::CreateUObject(Object, &UJavascriptMenuContext::Public_GetActionCheckState);
#if ENGINE_MINOR_VERSION > 22
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22) || ENGINE_MAJOR_VERSION > 4
const EUserInterfaceActionType CommandType = EUserInterfaceActionType(Object->ActionType.GetValue());
#else
const EUserInterfaceActionType::Type CommandType = EUserInterfaceActionType::Type(Object->ActionType.GetValue());
Expand All @@ -172,7 +176,7 @@ void UJavascriptMenuLibrary::AddMenuEntry(FJavascriptMenuBuilder& Builder, UJava
DefaultAction.CanExecuteAction = FCanExecuteAction::CreateUObject(Object, &UJavascriptMenuContext::Public_CanExecute);
DefaultAction.ExecuteAction = FExecuteAction::CreateUObject(Object, &UJavascriptMenuContext::Public_Execute);
DefaultAction.GetActionCheckState = FGetActionCheckState::CreateUObject(Object, &UJavascriptMenuContext::Public_GetActionCheckState);
#if ENGINE_MINOR_VERSION > 22
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22) || ENGINE_MAJOR_VERSION > 4
const EUserInterfaceActionType CommandType = EUserInterfaceActionType(Object->ActionType.GetValue());
#else
const EUserInterfaceActionType::Type CommandType = EUserInterfaceActionType::Type(Object->ActionType.GetValue());
Expand Down Expand Up @@ -318,7 +322,7 @@ FJavascriptUICommandInfo UJavascriptMenuLibrary::UI_COMMAND_Function(FJavascript
const FString DotOutCommandName = FString::Printf(TEXT(".%s"), *info.Id);
const TCHAR* FriendlyName = *info.FriendlyName;
const TCHAR* InDescription = *info.Description;
#if ENGINE_MINOR_VERSION > 22
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22) || ENGINE_MAJOR_VERSION > 4
const EUserInterfaceActionType CommandType = EUserInterfaceActionType(info.ActionType.GetValue());
#else
const EUserInterfaceActionType::Type CommandType = EUserInterfaceActionType::Type(info.ActionType.GetValue());
Expand Down
2 changes: 1 addition & 1 deletion Source/JavascriptEditor/JavascriptUICommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void UJavascriptUICommands::Uninitialize()

void UJavascriptUICommands::BroadcastCommandsChanged(const FString& InContextName)
{
#if ENGINE_MINOR_VERSION > 14
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 14) || ENGINE_MAJOR_VERSION > 4
TSharedPtr<FBindingContext> ExistingBindingContext = FInputBindingManager::Get().GetContextByName(*InContextName);
if (ExistingBindingContext.IsValid())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void UJavascriptGraphAssetGraphSchema::GetGraphContextActions(FGraphContextMenuB
}
}

#if ENGINE_MINOR_VERSION < 24
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 24
void UJavascriptGraphAssetGraphSchema::GetContextMenuActions(const UEdGraph* CurrentGraph, const UEdGraphNode* InGraphNode, const UEdGraphPin* InGraphPin, class FMenuBuilder* MenuBuilder, bool bIsDebugging) const
{
if (OnBuildMenu.IsBound())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class UJavascriptGraphAssetGraphSchema : public UEdGraphSchema

//~ Begin EdGraphSchema Interface
virtual void GetGraphContextActions(FGraphContextMenuBuilder& ContextMenuBuilder) const override;
#if ENGINE_MINOR_VERSION < 24
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 24
virtual void GetContextMenuActions(const UEdGraph* CurrentGraph, const UEdGraphNode* InGraphNode, const UEdGraphPin* InGraphPin, class FMenuBuilder* MenuBuilder, bool bIsDebugging) const override;
#else
virtual void GetContextMenuActions(class UToolMenu* Menu, class UGraphNodeContextMenuContext* Context) const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ FJavascriptArrangedWidget UJavascriptGraphEditorLibrary::FindPinGeometries(FJava
FJavascriptPinWidget UJavascriptGraphEditorLibrary::FindPinToPinWidgetMap(FJavascriptDetermineLinkGeometryContainer Container, FJavascriptEdGraphPin Pin)
{
FJavascriptPinWidget Widget = FJavascriptPinWidget();
#if ENGINE_MINOR_VERSION > 22
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22) || ENGINE_MAJOR_VERSION > 4
TSharedPtr<SGraphPin>* SGraphPinHandle = Container.PinToPinWidgetMap->Find(Pin);
if (SGraphPinHandle)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/JavascriptGraphEditor/JavascriptGraphEditorLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct FJavascriptDetermineLinkGeometryContainer
TSharedRef<SWidget>* InOutputPinWidget,
TMap<UEdGraphNode*, int32>* InNodeWidgetMap,
TMap<TSharedRef<SWidget>, FArrangedWidget>* InPinGeometries,
#if ENGINE_MINOR_VERSION > 22
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22) || ENGINE_MAJOR_VERSION > 4
TMap< UEdGraphPin*, TSharedPtr<SGraphPin> >* InPinToPinWidgetMap
#else
TMap< UEdGraphPin*, TSharedRef<SGraphPin> >* InPinToPinWidgetMap
Expand All @@ -124,7 +124,7 @@ struct FJavascriptDetermineLinkGeometryContainer
TMap<UEdGraphNode*, int32>* NodeWidgetMap;

TMap<TSharedRef<SWidget>, FArrangedWidget>* PinGeometries;
#if ENGINE_MINOR_VERSION > 22
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22) || ENGINE_MAJOR_VERSION > 4
TMap< UEdGraphPin*, TSharedPtr<SGraphPin> >* PinToPinWidgetMap;
#else
TMap< UEdGraphPin*, TSharedRef<SGraphPin> >* PinToPinWidgetMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FJavascriptEditableTextGraphPin : public IEditableTextProperty
virtual bool IsDefaultValue() const override
{
FString TextAsString;
#if ENGINE_MINOR_VERSION < 22
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 22
if (FTextStringHelper::WriteToString(TextAsString, GraphPinObj->DefaultTextValue))
{
return TextAsString.Equals(GraphPinObj->AutogeneratedDefaultValue, ESearchCase::CaseSensitive);
Expand Down
Loading