Skip to content

Commit

Permalink
added blotter invocation to tools menu
Browse files Browse the repository at this point in the history
  • Loading branch information
TCR-Nick committed Dec 8, 2024
1 parent 96d41e6 commit defb41a
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 10 deletions.
Binary file modified InkpotDemo/Plugins/Inkpot/Content/Inkpot/InkpotDebug.uasset
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public InkpotEditor(ReadOnlyTargetRules Target) : base(Target)
"Slate",
"SlateCore",
"UMG",

"Blutility"
"UMGEditor",
"Blutility"
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

void UBlotterOption::Set(const FString& Name, bool bInIsSelected )
{
Super::Set(Name);
Super::SetText(Name);
bIsSelected = bInIsSelected;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Blotter/BlotterString.h"


void UBlotterString::Set(const FString& InText)
void UBlotterString::SetText(const FString& InText)
{
Text = FText::FromString( InText );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ TArray<UBlotterString*> UInkpotBlotter::MakeDisplayStrings(const TArray<FString>
for (auto& string : InStrings)
{
UBlotterString* displayString = NewObject<UBlotterString>(this);
displayString->Set(string);
displayString->SetText(string);
displayStrings.Add(displayString);
}
}
else
{
UBlotterString* displayString = NewObject<UBlotterString>(this);
displayString->Set(TEXT("[EMPTY]"));
displayString->SetText(TEXT("[EMPTY]"));
displayStrings.Add(displayString);
}
return displayStrings;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#include "InkpotEditorModule.h"
#include "AssetToolsModule.h"
#include "Utility/InkpotLog.h"
#include "Asset/InkpotStoryAssetActions.h"
#include "AssetToolsModule.h"
#include "Framework/Commands/UIAction.h"
#include "LevelEditor.h"
#include "EditorUtilityWidget.h"
#include "EditorUtilityWidgetBlueprint.h"
#include "EditorUtilitySubsystem.h"
#include "Interfaces/IPluginManager.h"

#define LOCTEXT_NAMESPACE "FInkEditorModule"

void FInkpotEditorModule::StartupModule()
{
InitAssetCategory();

InitMenuOptions();
}

void FInkpotEditorModule::ShutdownModule()
Expand All @@ -28,6 +35,63 @@ EAssetTypeCategories::Type FInkpotEditorModule::GetAssetCategory() const
return InkpotAssetCategory;
}

void FInkpotEditorModule::InitMenuOptions()
{
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");

TSharedPtr<FExtender> MenuExtender = MakeShareable( new FExtender() );
MenuExtender->AddMenuExtension(
"Source Control",
EExtensionHook::Before,
nullptr,
FMenuExtensionDelegate::CreateRaw( this, &FInkpotEditorModule::FillMenu )
);

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

void FInkpotEditorModule::AddMenu(FMenuBarBuilder& MenuBuilder)
{
MenuBuilder.AddPullDownMenu(
LOCTEXT("InkpotLocMenuKey", "Inkpot"),
LOCTEXT("InkpotLocMenuTip", "Opens menu for Inkpot"),
FNewMenuDelegate::CreateRaw(this, &FInkpotEditorModule::FillMenu),
FName(TEXT("Inkpot")),
FName(TEXT("Inkpot")));
}

void FInkpotEditorModule::FillMenu(FMenuBuilder& MenuBuilder)
{
FUIAction Action( FExecuteAction::CreateStatic(&FInkpotEditorModule::OpenBlotter) );

MenuBuilder.BeginSection(FName(TEXT("Inkpot")), LOCTEXT("InkpotLocMenuKey", "Inkpot") );

MenuBuilder.AddMenuEntry(
LOCTEXT( "InkpotLocBlotterKey", "Blotter" ),
LOCTEXT( "InkpotLocBlotterTip", "Opens the blotter for debugging the current story." ),
FSlateIcon(),
Action
);
}

void FInkpotEditorModule::OpenBlotter()
{
const FSoftObjectPath widgetAssetPath(TEXT("/Inkpot/Inkpot/InkpotDebug.InkpotDebug"));
UObject* widgetAssetLoaded = widgetAssetPath.TryLoad();
if (widgetAssetLoaded == nullptr)
{
INKPOT_WARN("Missing Expected widget class, cannot open blotter.");
return;
}
UEditorUtilityWidgetBlueprint* widget = Cast<UEditorUtilityWidgetBlueprint>(widgetAssetLoaded);
if (widget == nullptr)
{
INKPOT_WARN("Blotter widget is not an UEditorUtilityWidgetBlueprint, cannot open blotter.");
return;
}
UEditorUtilitySubsystem* EditorUtilitySubsystem = GEditor->GetEditorSubsystem<UEditorUtilitySubsystem>();
EditorUtilitySubsystem->SpawnAndRegisterTab(widget);
}

IMPLEMENT_MODULE(FInkpotEditorModule, InkpotEditor)
#undef LOCTEXT_NAMESPACE

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class INKPOTEDITOR_API UBlotterString : public UObject
{
GENERATED_BODY()
public:
void Set(const FString& Name);
void SetText(const FString& Name);

UFUNCTION(BlueprintPure, Category = "Inkpot|Blotter")
const FText& GetText() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class FInkpotEditorModule : public IModuleInterface

private:
void InitAssetCategory();
void InitMenuOptions();

UFUNCTION()
void AddMenu( FMenuBarBuilder& MenuBuilder );

UFUNCTION()
void FillMenu( FMenuBuilder& MenuBuilder );

UFUNCTION()
static void OpenBlotter();

private:
EAssetTypeCategories::Type InkpotAssetCategory;
Expand Down

0 comments on commit defb41a

Please sign in to comment.