Skip to content

Commit

Permalink
Merge pull request #1 from zenustech/engine/zenoembed
Browse files Browse the repository at this point in the history
merge Engine/zenoembed
  • Loading branch information
DarcJC authored Mar 31, 2023
2 parents e561d44 + 37c2a5d commit 3f7672a
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 16 deletions.
Binary file modified Content/Material/Function/MF_PositionAndNormmalVAT.uasset
Binary file not shown.
Binary file modified Content/Material/Mat_PositionAndNormalVAT.uasset
Binary file not shown.
14 changes: 4 additions & 10 deletions Source/ZenoEditor/Private/UI/Menu/VATEditorExtenderService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,24 @@
#define LOCTEXT_NAMESPACE "FVATEditorExtenderService"

FVATEditorExtenderService::FVATEditorExtenderService()
: CommandList(MakeShared<FUICommandList>())
: FZenoEditorExtenderServiceBase()
{
}

void FVATEditorExtenderService::Register()
{
MapAction();

FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
MenuBarExtender = MakeShareable(new FExtender);

FZenoEditorExtenderServiceBase::Register();
MenuBarExtender->AddMenuBarExtension("Help", EExtensionHook::After, CommandList, FMenuBarExtensionDelegate::CreateRaw(this, &FVATEditorExtenderService::ExtendMenuBar));

LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(MenuBarExtender);
}

void FVATEditorExtenderService::Unregister()
{
FZenoEditorExtenderServiceBase::Unregister();
}

void FVATEditorExtenderService::ExtendMenuBar(FMenuBarBuilder& Builder)
{
const FName ZenoHook = "MENU_Zeno";
Builder.AddPullDownMenu(LOCTEXT("Zeno", "Zeno"), LOCTEXT("ZenoTooltip", "Zeno Tools"), FNewMenuDelegate::CreateRaw(this, &FVATEditorExtenderService::ExtendVATPullDownMenu), ZenoHook, ZenoHook);
Builder.AddPullDownMenu(LOCTEXT("Zeno", "Zeno"), LOCTEXT("ZenoTooltip", "Zeno Tools"), FNewMenuDelegate::CreateRaw(this, &FVATEditorExtenderService::ExtendVATPullDownMenu), ZenoHookLabel, ZenoHookLabel);
}

void FVATEditorExtenderService::ExtendVATPullDownMenu(FMenuBuilder& Builder)
Expand Down
21 changes: 21 additions & 0 deletions Source/ZenoEditor/Private/UI/Menu/ZenoEditorMenuExtender.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
#include "UI/Menu/ZenoEditorMenuExtender.h"

#include "LevelEditor.h"

FZenoEditorExtenderServiceBase::FZenoEditorExtenderServiceBase()
: CommandList(MakeShared<FUICommandList>())
{
}

void FZenoEditorExtenderServiceBase::Register()
{
MapAction();
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
MenuBarExtender = MakeShareable(new FExtender);
LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(MenuBarExtender);
}

void FZenoEditorExtenderServiceBase::Unregister()
{
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
LevelEditorModule.GetMenuExtensibilityManager()->RemoveExtender(MenuBarExtender);
}

void FZenoEditorMenuExtender::Register()
{
for (const auto Pair : Services)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "UI/Menu/ZenoEmbedGraphEditorExtenderService.h"

#include "LevelEditor.h"
#include "ZenoEditorCommand.h"

#define LOCTEXT_NAMESPACE "FZenoEmbedGraphEditorExtenderService"

FZenoEmbedGraphEditorExtenderService::FZenoEmbedGraphEditorExtenderService()
: FZenoEditorExtenderServiceBase()
{
}

void FZenoEmbedGraphEditorExtenderService::Register()
{
FZenoEditorExtenderServiceBase::Register();
MenuBarExtender->AddMenuBarExtension("Help", EExtensionHook::After, CommandList, FMenuBarExtensionDelegate::CreateRaw(this, &FZenoEmbedGraphEditorExtenderService::ExtendTopMenuBar));
}

void FZenoEmbedGraphEditorExtenderService::Unregister()
{
FZenoEditorExtenderServiceBase::Unregister();
}

FZenoEmbedGraphEditorExtenderService& FZenoEmbedGraphEditorExtenderService::Get()
{
static FZenoEmbedGraphEditorExtenderService Service;
return Service;
}

void FZenoEmbedGraphEditorExtenderService::ExtendTopMenuBar(FMenuBarBuilder& Builder)
{
Builder.AddPullDownMenu(LOCTEXT("Zeno", "Zeno"), LOCTEXT("ZenoTooltip", "Zeno Tools"), FNewMenuDelegate::CreateRaw(this, &FZenoEmbedGraphEditorExtenderService::ExtendEmbedPullDownMenu), ZenoHookLabel, ZenoHookLabel);
}

void FZenoEmbedGraphEditorExtenderService::ExtendEmbedPullDownMenu(FMenuBuilder& Builder)
{
Builder.AddMenuEntry(FZenoEditorCommand::Get().Debug);
}

void FZenoEmbedGraphEditorExtenderService::MapAction()
{
CommandList->MapAction(FZenoEditorCommand::Get().Debug, FExecuteAction::CreateRaw(this, &FZenoEmbedGraphEditorExtenderService::Debug));
}

void FZenoEmbedGraphEditorExtenderService::Debug()
{
UE_LOG(LogTemp, Error, TEXT("123"));
}

#undef LOCTEXT_NAMESPACE

REGISTER_EDITOR_EXTENDER_SERVICE("Embed", FZenoEmbedGraphEditorExtenderService);
8 changes: 2 additions & 6 deletions Source/ZenoEditor/Public/UI/Menu/VATEditorExtenderService.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "ZenoEditorMenuExtender.h"

class FVATEditorExtenderService final : public IZenoEditorExtenderService
class FVATEditorExtenderService final : public FZenoEditorExtenderServiceBase
{
public:
FVATEditorExtenderService();
Expand All @@ -11,14 +11,10 @@ class FVATEditorExtenderService final : public IZenoEditorExtenderService

void ExtendMenuBar(FMenuBarBuilder& Builder);
void ExtendVATPullDownMenu(FMenuBuilder& Builder);
void MapAction();
virtual void MapAction() override;

static FVATEditorExtenderService& Get();

private:
TSharedPtr<FExtender> MenuBarExtender;
TSharedPtr<FUICommandList> CommandList;

private:
void Debug();
void ImportWavefrontObjFile();
Expand Down
16 changes: 16 additions & 0 deletions Source/ZenoEditor/Public/UI/Menu/ZenoEditorMenuExtender.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ class IZenoEditorExtenderService
virtual void Unregister() = 0;
};

class FZenoEditorExtenderServiceBase : public IZenoEditorExtenderService
{
public:
FZenoEditorExtenderServiceBase();

virtual void Register() override;
virtual void Unregister() override;
virtual void MapAction() {};

protected:
TSharedPtr<FUICommandList> CommandList;
TSharedPtr<FExtender> MenuBarExtender;

inline static FName ZenoHookLabel = "MENU_Zeno";
};

class FZenoEditorMenuExtender final : public IZenoEditorExtenderService
{
public:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once
#include "ZenoEditorMenuExtender.h"

class FZenoEmbedGraphEditorExtenderService final : public FZenoEditorExtenderServiceBase
{
public:
FZenoEmbedGraphEditorExtenderService();

virtual void Register() override;
virtual void Unregister() override;

static FZenoEmbedGraphEditorExtenderService& Get();

private:
void ExtendTopMenuBar(FMenuBarBuilder& Builder);
void ExtendEmbedPullDownMenu(FMenuBuilder& Builder);

protected:
virtual void MapAction() override;

// Actions
void Debug();
};

0 comments on commit 3f7672a

Please sign in to comment.