Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "RedTalaria.h"
#include "RedTalariaLevelAtCameraCoordsUrls.h"
#include "ToolMenus.h"
#include "Misc/EngineVersionComparison.h"
#include "HAL/PlatformApplicationMisc.h"

#define LOCTEXT_NAMESPACE "Editor.RedHermesLevelAtCameraCoordsEndpointEditorExtension"
Expand All @@ -25,11 +26,23 @@ void URedHermesLevelAtCameraCoordsEndpointEditorExtension::RegisterViewportOptio
{
FToolMenuOwnerScoped ToolMenuOwnerScoped(this);

if (UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.LevelViewportToolBar.Options"))
#if UE_VERSION_OLDER_THAN(5,6,0)
static const FName ViewportMenuName("LevelEditor.LevelViewportToolBar.Options");
static const FName ViewportMenuFirstSection("LevelViewportViewportOptions");
#else
static const FName ViewportMenuName("LevelEditor.LevelViewportToolBar.Camera");
static const FName ViewportMenuFirstSection("LevelViewportCameraType_Perspective");
#endif

if (UToolMenu* Menu = UToolMenus::Get()->ExtendMenu(ViewportMenuName))
{
static auto GetPerspectiveLevelEditorViewportClient = [](const FToolMenuContext& MenuContext) -> FLevelEditorViewportClient* {
ULevelViewportToolBarContext* Context = MenuContext.FindContext<ULevelViewportToolBarContext>();
if (Context && Context->LevelViewportToolBarWidget.IsValid())
#if UE_VERSION_OLDER_THAN(5,7,0)
if (ULevelViewportToolBarContext* Context = MenuContext.FindContext<ULevelViewportToolBarContext>();
Context && Context->LevelViewportToolBarWidget.IsValid())
#else
if (ULevelViewportContext* Context = MenuContext.FindContext<ULevelViewportContext>())
#endif
{
FLevelEditorViewportClient* ViewportClient = Context->GetLevelViewportClient();
if (ViewportClient && ViewportClient->ViewportType == LVT_Perspective)
Expand Down Expand Up @@ -58,8 +71,8 @@ void URedHermesLevelAtCameraCoordsEndpointEditorExtension::RegisterViewportOptio

FToolMenuSection& Section = Menu->AddSection(
TEXT("Hermes"),
LOCTEXT("LevelViewportToolBar.Options.Hermes", "Hermes"),
FToolMenuInsert(TEXT("LevelViewportViewportOptions"), EToolMenuInsertType::Before));
LOCTEXT("LevelViewportToolBar.Section.Hermes", "Hermes"),
FToolMenuInsert(ViewportMenuFirstSection, EToolMenuInsertType::Before));
Section.AddMenuEntry("CopyURL",
LOCTEXT("ViewportAction.CopyCameraCoordsUrl", "Copy camera coords URL"),
LOCTEXT("ViewportAction.CopyCameraCoordsUrlTooltip", "Copy an URL that will open this level at the current camera position"),
Expand Down