Skip to content

Commit

Permalink
Merge branch '5.1_dev' into 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlicekdominik committed Dec 23, 2022
2 parents 20047c0 + 53027b1 commit e77b7c3
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ActorInteractionPlugin.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "3.0.1.0",
"VersionName": "3.0.1.1",
"FriendlyName": "Actor Interaction Plugin",
"Description": "Actor Interaction Plugin is an Open-source Mountea Framework components-based simple framework providing utilities for smart Actor Interaction with other Actors. Developed with Game Developers in mind to allow as easy as possible implementation while maintaining high scalability and diverse options to tweak everything.",
"Category": "Mountea Framework",
Expand Down
Binary file added Resources/HelpIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Mountea_Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public ActorInteractionPluginEditor(ReadOnlyTargetRules Target) : base(Target)

"WebBrowser",
"EditorStyle",
"DeveloperSettings"
"DeveloperSettings",

"MainFrame",
"ToolMenus",
"InputCore"
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@
#include "AssetActions/InteractableComponentAssetActions.h"

#include "AssetToolsModule.h"
#include "HelpButton/AIntPCommands.h"
#include "HelpButton/AIntPHelpStyle.h"
#include "Kismet2/KismetEditorUtilities.h"
#include "Popup/AIntPPopup.h"
#include "Utilities/ActorInteractionEditorUtilities.h"

#include "ToolMenus.h"

#include "Interfaces/IMainFrameModule.h"

DEFINE_LOG_CATEGORY(ActorInteractionPluginEditor);

static const FName AIntPHelpTabName("MounteaFramework");

#define LOCTEXT_NAMESPACE "FActorInteractionPluginEditor"

void FActorInteractionPluginEditor::StartupModule()
Expand Down Expand Up @@ -112,10 +119,28 @@ void FActorInteractionPluginEditor::StartupModule()

// Register popup
{


AIntPPopup::Register();
}

// Register Help Button
{
FAIntPHelpStyle::Initialize();
FAIntPHelpStyle::ReloadTextures();

FAIntPCommands::Register();

PluginCommands = MakeShareable(new FUICommandList);

PluginCommands->MapAction(
FAIntPCommands::Get().PluginAction,
FExecuteAction::CreateRaw(this, &FActorInteractionPluginEditor::PluginButtonClicked),
FCanExecuteAction());

IMainFrameModule& mainFrame = FModuleManager::Get().LoadModuleChecked<IMainFrameModule>("MainFrame");
mainFrame.GetMainFrameCommandBindings()->Append(PluginCommands.ToSharedRef());

UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateRaw(this, &FActorInteractionPluginEditor::RegisterMenus));
}
}

void FActorInteractionPluginEditor::ShutdownModule()
Expand All @@ -135,6 +160,17 @@ void FActorInteractionPluginEditor::ShutdownModule()
}
}

// Help Button Cleanup
{
UToolMenus::UnRegisterStartupCallback(this);

UToolMenus::UnregisterOwner(this);

FAIntPHelpStyle::Shutdown();

FAIntPCommands::Unregister();
}

UE_LOG(ActorInteractionPluginEditor, Warning, TEXT("ActorInteractionPluginEditor module has been unloaded"));
}

Expand Down Expand Up @@ -182,6 +218,56 @@ void FActorInteractionPluginEditor::HandleNewInteractableBlueprintCreated(UBluep
Blueprint->BlueprintCategory = FString("Interaction");
}

void FActorInteractionPluginEditor::PluginButtonClicked()
{
const FString URL = "https://discord.gg/2vXWEEN";

if (!URL.IsEmpty())
{
FPlatformProcess::LaunchURL(*URL, nullptr, nullptr);
}
}

void FActorInteractionPluginEditor::RegisterMenus()
{
// Owner will be used for cleanup in call to UToolMenus::UnregisterOwner
FToolMenuOwnerScoped OwnerScoped(this);

// Register in Window tab
{
UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.MainMenu.Help");
{
FToolMenuSection& Section = Menu->FindOrAddSection("MounteaFramework");
Section.Label = FText::FromString(TEXT("Mountea Framework"));

FToolMenuEntry Entry = Section.AddMenuEntryWithCommandList
(
FAIntPCommands::Get().PluginAction,
PluginCommands,
NSLOCTEXT("MounteaSupport", "TabTitle", "Mountea Support"),
NSLOCTEXT("MounteaSupport", "TooltipText", "Opens Mountea Framework Support channel"),
FSlateIcon(FAIntPHelpStyle::GetStyleSetName(), "AIntPSupport.PluginAction.small")
);
}
}

// Register in Level Editor Toolbar
{
UToolMenu* ToolbarMenu = UToolMenus::Get()->ExtendMenu("LevelEditor.LevelEditorToolBar.PlayToolBar");
{
FToolMenuSection& Section = ToolbarMenu->FindOrAddSection("MounteaFramework");
{
Section.Label = FText::FromString(TEXT("Mountea Framework"));

FToolMenuEntry& Entry = Section.AddEntry(FToolMenuEntry::InitToolBarButton(FAIntPCommands::Get().PluginAction));
Entry.SetCommandList(PluginCommands);

Entry.InsertPosition.Position = EToolMenuInsertType::First;
}
}
}
}

#undef LOCTEXT_NAMESPACE

IMPLEMENT_MODULE(FActorInteractionPluginEditor, ActorInteractionPluginEditor);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Fill out your copyright notice in the Description page of Project Settings.


#include "AIntPCommands.h"

#define LOCTEXT_NAMESPACE "ActorInteractionPluginEditorModule"

void FAIntPCommands::RegisterCommands()
{
UI_COMMAND(PluginAction, "Support", "Opens Mountea Framework Support channel", EUserInterfaceActionType::Button, FInputChord(EModifierKey::Control|EModifierKey::Shift|EModifierKey::Alt, EKeys::X));
}

#undef LOCTEXT_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "AIntPHelpStyle.h"


class FAIntPCommands : public TCommands<FAIntPCommands>
{
public:

FAIntPCommands()
: TCommands<FAIntPCommands>(TEXT("AIntPSupport"), NSLOCTEXT("Contexts", "Support", "ActorInteraction Plugin"), NAME_None, FAIntPHelpStyle::GetStyleSetName())
{
}

// TCommands<> interface
virtual void RegisterCommands() override;

public:

TSharedPtr< FUICommandInfo > PluginAction;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Fill out your copyright notice in the Description page of Project Settings.


#include "AIntPHelpStyle.h"
#include "Framework/Application/SlateApplication.h"
#include "Styling/SlateStyleRegistry.h"
#include "Slate/SlateGameResources.h"
#include "Interfaces/IPluginManager.h"

TSharedPtr< FSlateStyleSet > FAIntPHelpStyle::StyleInstance = nullptr;

void FAIntPHelpStyle::Initialize()
{
if (!StyleInstance.IsValid())
{
StyleInstance = Create();
FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance);
}
}

void FAIntPHelpStyle::Shutdown()
{
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance);
ensure(StyleInstance.IsUnique());
StyleInstance.Reset();
}

void FAIntPHelpStyle::ReloadTextures()
{
if (FSlateApplication::IsInitialized())
{
FSlateApplication::Get().GetRenderer()->ReloadTextureResources();
}
}

const ISlateStyle& FAIntPHelpStyle::Get()
{
return *StyleInstance;
}

FName FAIntPHelpStyle::GetStyleSetName()
{
static FName StyleSetName(TEXT("AIntPHelpStyle"));
return StyleSetName;
}

#define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define TTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".ttf") ), __VA_ARGS__ )
#define OTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".otf") ), __VA_ARGS__ )

const FVector2D Icon16x16(16.0f, 16.0f);
const FVector2D Icon20x20(20.0f, 20.0f);
const FVector2D Icon40x40(40.0f, 40.0f);

TSharedRef<FSlateStyleSet> FAIntPHelpStyle::Create()
{
TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("AIntPHelpStyle"));
Style->SetContentRoot(IPluginManager::Get().FindPlugin("ActorInteractionPlugin")->GetBaseDir() / TEXT("Resources"));

Style->Set("AIntPSupport.PluginAction", new IMAGE_BRUSH(TEXT("Mountea_Logo"), Icon40x40));
Style->Set("AIntPSupport.PluginAction.small", new IMAGE_BRUSH(TEXT("HelpIcon"), Icon20x20));

return Style;
}

#undef IMAGE_BRUSH
#undef BOX_BRUSH
#undef BORDER_BRUSH
#undef TTF_FONT
#undef OTF_FONT
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Styling/SlateStyle.h"

class FAIntPHelpStyle
{
public:

static void Initialize();

static void Shutdown();

/** reloads textures used by slate renderer */
static void ReloadTextures();

/** @return The Slate style set for the Actor Interaction Plugin Help Button */
static const ISlateStyle& Get();

static FName GetStyleSetName();

private:

static TSharedRef< class FSlateStyleSet > Create();

private:

static TSharedPtr< class FSlateStyleSet > StyleInstance;
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,17 @@ class FActorInteractionPluginEditor : public IModuleInterface

TSharedPtr<class FInteractorComponentAssetActions> InteractorComponentAssetActions;
TSharedPtr<class FInteractableComponentAssetActions> InteractableComponentAssetActions;

public:

/** This function will be bound to Command. */
void PluginButtonClicked();

private:

void RegisterMenus();

private:

TSharedPtr<class FUICommandList> PluginCommands;
};

0 comments on commit e77b7c3

Please sign in to comment.