-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnrealProtocolContentBrowserExtensions.cpp
69 lines (54 loc) · 2.28 KB
/
UnrealProtocolContentBrowserExtensions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Fill out your copyright notice in the Description page of Project Settings.
#include "UnrealProtocolContentBrowserExtensions.h"
#include "ContentBrowserModule.h"
#include "UnrealProtocol_AssetOpen.h"
#define LOCTEXT_NAMESPACE "UnrealProtocolEd"
class FUnrealProtocolContentBrowserCommands final : public TCommands<FUnrealProtocolContentBrowserCommands>
{
public:
FUnrealProtocolContentBrowserCommands() :
TCommands( TEXT( "UnrealProtocolEditorCommands" ),
NSLOCTEXT( "Contexts", "FUnrealProtocolEditorModule", "Unreal Protocol Editor Plugin" ), FName(),
FAppStyle::GetAppStyleSetName() )
{
}
// TCommands<> interface
virtual void RegisterCommands() override
{
UI_COMMAND( CopyLink, "Copy Link", "copy custom protocol link.", EUserInterfaceActionType::Button,
FInputChord( EModifierKey::Control | EModifierKey::Shift, EKeys::C ) );
}
public:
TSharedPtr<FUICommandInfo> CopyLink;
};
namespace UnrealProtocol::ContentBrowserExtensions
{
static FDelegateHandle DH_ContentBrowserCommandExtender;
void OnExtendContentBrowserCommands( TSharedRef<FUICommandList> CommandList, FOnContentBrowserGetSelection GetSelectionDelegate )
{
CommandList->MapAction( FUnrealProtocolContentBrowserCommands::Get().CopyLink, FExecuteAction::CreateLambda( [] { //
UUnrealProtocol_AssetOpen::StaticClass()->GetDefaultObject<UUnrealProtocol_AssetOpen>()->CopyLink();
} ) );
}
#undef LOCTEXT_NAMESPACE
void FHooks::Install()
{
FUnrealProtocolContentBrowserCommands::Register();
FContentBrowserModule& ContentBrowserModule =
FModuleManager::LoadModuleChecked<FContentBrowserModule>( TEXT( "ContentBrowser" ) );
DH_ContentBrowserCommandExtender =
ContentBrowserModule.GetAllContentBrowserCommandExtenders()
.Emplace_GetRef( FContentBrowserCommandExtender::CreateStatic( &OnExtendContentBrowserCommands ) )
.GetHandle();
}
void FHooks::Uninstall()
{
FContentBrowserModule& ContentBrowserModule =
FModuleManager::LoadModuleChecked<FContentBrowserModule>( TEXT( "ContentBrowser" ) );
ContentBrowserModule.GetAllContentBrowserCommandExtenders().RemoveAll(
[]( const FContentBrowserCommandExtender& Delegate ) { //
return Delegate.GetHandle() == DH_ContentBrowserCommandExtender;
} );
FUnrealProtocolContentBrowserCommands::Unregister();
}
} // namespace UnrealProtocol::ContentBrowserExtensions