Files
UnrealEngineUWP/Engine/Source/Developer/AutomationWindow/Private/SAutomationTestItemContextMenu.h
Matthew Griffin bb70b349ce Merging CL 2804086 from //UE4/Release-4.11 to Dev-Main (//UE4/Dev-Main) to isolate copyright update
#lockdown Nick.Penwarden

[CL 2819020 by Matthew Griffin in Main branch]
2016-01-07 08:17:16 -05:00

81 lines
1.8 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#pragma once
#if WITH_EDITOR
#define LOCTEXT_NAMESPACE "SAutomationTestItemContextMenu"
class SAutomationTestItemContextMenu
: public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SAutomationTestItemContextMenu) {}
SLATE_END_ARGS()
public:
/**
* Construct this widget.
*
* @param InArgs The declaration data for this widget.
* @param InSessionManager The session to use.
*/
void Construct( const FArguments& InArgs, const TArray<FString>& InAssetNames )
{
AssetNames = InAssetNames;
ChildSlot
[
SNew(SBorder)
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
.Content()
[
MakeContextMenu( )
]
];
}
protected:
/**
* Builds the context menu widget.
*
* @return The context menu.
*/
TSharedRef<SWidget> MakeContextMenu( )
{
FMenuBuilder MenuBuilder(true, NULL);
MenuBuilder.BeginSection("AutomationOptions", LOCTEXT("MenuHeadingText", "Automation Options"));
{
MenuBuilder.AddMenuEntry(LOCTEXT("AutomationMenuEntryLoadText", "Load the asset(s)"), FText::GetEmpty(), FSlateIcon(), FUIAction(FExecuteAction::CreateRaw(this, &SAutomationTestItemContextMenu::HandleContextItemTerminate)));
}
MenuBuilder.EndSection();
return MenuBuilder.MakeWidget();
}
private:
/** Handle the context menu closing down. If an asset is selected, request that it gets loaded */
void HandleContextItemTerminate( )
{
for (int32 AssetIndex = 0; AssetIndex < AssetNames.Num(); ++AssetIndex)
{
FModuleManager::GetModuleChecked<IAutomationControllerModule>("AutomationController").GetAutomationController()->RequestLoadAsset(AssetNames[AssetIndex]);
}
}
private:
/** Holds the selected asset name. */
TArray<FString> AssetNames;
};
#undef LOCTEXT_NAMESPACE
#endif //WITH_EDITOR