You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
352 lines
9.7 KiB
C++
352 lines
9.7 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SDeviceOutputLog.h"
|
|
#include "Framework/Text/TextLayout.h"
|
|
#include "Widgets/Text/STextBlock.h"
|
|
#include "Widgets/Input/SComboButton.h"
|
|
#include "Misc/ScopeLock.h"
|
|
#include "Modules/ModuleManager.h"
|
|
#include "Widgets/Images/SImage.h"
|
|
#include "Framework/Commands/UIAction.h"
|
|
#include "Widgets/Input/SMultiLineEditableTextBox.h"
|
|
#include "Framework/MultiBox/MultiBoxBuilder.h"
|
|
#include "EditorStyleSet.h"
|
|
#include "Interfaces/ITargetPlatform.h"
|
|
#include "Interfaces/ITargetPlatformManagerModule.h"
|
|
#include "PlatformInfo.h"
|
|
|
|
static bool IsSupportedPlatform(ITargetPlatform* Platform)
|
|
{
|
|
static const FName AndroidPlaftomName("Android"); // TODO: currently implemented only for Android
|
|
|
|
check(Platform);
|
|
const auto& PlatfromInfo = Platform->GetPlatformInfo();
|
|
return PlatfromInfo.IsVanilla() && PlatfromInfo.VanillaPlatformName == AndroidPlaftomName;
|
|
}
|
|
|
|
|
|
void SDeviceOutputLog::Construct( const FArguments& InArgs )
|
|
{
|
|
MessagesTextMarshaller = FOutputLogTextLayoutMarshaller::Create(TArray<TSharedPtr<FLogMessage>>(), &Filter);
|
|
|
|
MessagesTextBox = SNew(SMultiLineEditableTextBox)
|
|
.Style(FEditorStyle::Get(), "Log.TextBox")
|
|
.TextStyle(FEditorStyle::Get(), "Log.Normal")
|
|
.ForegroundColor(FLinearColor::Gray)
|
|
.Marshaller(MessagesTextMarshaller)
|
|
.IsReadOnly(true)
|
|
.AlwaysShowScrollbars(true)
|
|
.OnVScrollBarUserScrolled(this, &SDeviceOutputLog::OnUserScrolled)
|
|
.ContextMenuExtender(this, &SDeviceOutputLog::ExtendTextBoxMenu);
|
|
|
|
ChildSlot
|
|
[
|
|
SNew(SVerticalBox)
|
|
|
|
// Output log area
|
|
+SVerticalBox::Slot()
|
|
.FillHeight(1)
|
|
[
|
|
MessagesTextBox.ToSharedRef()
|
|
]
|
|
// The console input box
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(FMargin(0.0f, 2.0f, 0.0f, 0.0f))
|
|
[
|
|
SNew(SHorizontalBox)
|
|
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SAssignNew(TargetDeviceComboButton, SComboButton)
|
|
.ComboButtonStyle(FEditorStyle::Get(), "OutputLog.Filters.Style")
|
|
.ForegroundColor(FLinearColor::White)
|
|
.OnGetMenuContent(this, &SDeviceOutputLog::MakeDeviceComboButtonMenu)
|
|
.ContentPadding(FMargin(4.0f, 0.0f))
|
|
.ButtonContent()
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SNew(SBox)
|
|
.WidthOverride(16)
|
|
.HeightOverride(16)
|
|
[
|
|
SNew(SImage).Image(this, &SDeviceOutputLog::GetSelectedTargetDeviceBrush)
|
|
]
|
|
]
|
|
|
|
+SHorizontalBox::Slot()
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
SNew(STextBlock)
|
|
.TextStyle(FEditorStyle::Get(), "OutputLog.Filters.Text")
|
|
.Text(this, &SDeviceOutputLog::GetSelectedTargetDeviceText)
|
|
]
|
|
]
|
|
]
|
|
|
|
+SHorizontalBox::Slot()
|
|
.Padding(FMargin(4.0f, 0.0f, 0.0f, 0.0f))
|
|
.FillWidth(1)
|
|
.VAlign(VAlign_Center)
|
|
[
|
|
SNew(SConsoleInputBox)
|
|
.ConsoleCommandCustomExec(this, &SDeviceOutputLog::ExecuteConsoleCommand)
|
|
.OnConsoleCommandExecuted(this, &SDeviceOutputLog::OnConsoleCommandExecuted)
|
|
// Always place suggestions above the input line for the output log widget
|
|
.SuggestionListPlacement( MenuPlacement_AboveAnchor )
|
|
]
|
|
]
|
|
];
|
|
|
|
bIsUserScrolled = false;
|
|
RequestForceScroll();
|
|
|
|
//
|
|
TArray<ITargetPlatform*> Platforms = GetTargetPlatformManager()->GetTargetPlatforms();
|
|
for (ITargetPlatform* Platform : Platforms)
|
|
{
|
|
if (IsSupportedPlatform(Platform))
|
|
{
|
|
Platform->OnDeviceDiscovered().AddRaw(this, &SDeviceOutputLog::HandleTargetPlatformDeviceDiscovered);
|
|
Platform->OnDeviceLost().AddRaw(this, &SDeviceOutputLog::HandleTargetPlatformDeviceLost);
|
|
}
|
|
}
|
|
|
|
// Get list of available devices
|
|
for (ITargetPlatform* Platform : Platforms)
|
|
{
|
|
if (IsSupportedPlatform(Platform))
|
|
{
|
|
TArray<ITargetDevicePtr> TargetDevices;
|
|
Platform->GetAllDevices(TargetDevices);
|
|
|
|
for (const ITargetDevicePtr& Device : TargetDevices)
|
|
{
|
|
if (Device.IsValid())
|
|
{
|
|
AddDeviceEntry(Device.ToSharedRef());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SDeviceOutputLog::~SDeviceOutputLog()
|
|
{
|
|
ITargetPlatformManagerModule* Module = FModuleManager::GetModulePtr<ITargetPlatformManagerModule>("TargetPlatform");
|
|
if (Module)
|
|
{
|
|
TArray<ITargetPlatform*> Platforms = Module->GetTargetPlatforms();
|
|
for (ITargetPlatform* Platform : Platforms)
|
|
{
|
|
Platform->OnDeviceDiscovered().RemoveAll(this);
|
|
Platform->OnDeviceLost().RemoveAll(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
void SDeviceOutputLog::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
|
|
{
|
|
FScopeLock ScopeLock(&BufferedLinesSynch);
|
|
if (BufferedLines.Num() > 0)
|
|
{
|
|
for (const FBufferedLine& Line : BufferedLines)
|
|
{
|
|
MessagesTextMarshaller->AppendMessage(*Line.Data, Line.Verbosity, Line.Category);
|
|
}
|
|
|
|
// Don't scroll to the bottom automatically when the user is scrolling the view or has scrolled it away from the bottom.
|
|
if (!bIsUserScrolled)
|
|
{
|
|
MessagesTextBox->ScrollTo(FTextLocation(MessagesTextMarshaller->GetNumMessages() - 1));
|
|
}
|
|
|
|
BufferedLines.Empty(32);
|
|
}
|
|
}
|
|
|
|
void SDeviceOutputLog::Serialize(const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category)
|
|
{
|
|
FScopeLock ScopeLock(&BufferedLinesSynch);
|
|
BufferedLines.Add(FBufferedLine(V, Category, Verbosity));
|
|
}
|
|
|
|
bool SDeviceOutputLog::CanBeUsedOnAnyThread() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void SDeviceOutputLog::ExecuteConsoleCommand(const FString& ExecCommand)
|
|
{
|
|
if (CurrentDevicePtr.IsValid())
|
|
{
|
|
ITargetDevicePtr PinnedPtr = CurrentDevicePtr->DeviceWeakPtr.Pin();
|
|
if (PinnedPtr.IsValid())
|
|
{
|
|
PinnedPtr->ExecuteConsoleCommand(ExecCommand);
|
|
}
|
|
}
|
|
}
|
|
|
|
void SDeviceOutputLog::HandleTargetPlatformDeviceLost(ITargetDeviceRef LostDevice)
|
|
{
|
|
FTargetDeviceId LostDeviceId = LostDevice->GetId();
|
|
|
|
if (CurrentDevicePtr.IsValid() && CurrentDevicePtr->DeviceId == LostDeviceId)
|
|
{
|
|
// Kill device output object, but do not clean up output in the window
|
|
CurrentDeviceOutputPtr.Reset();
|
|
}
|
|
|
|
// Should not do it, but what if someone somewhere holds strong reference to a lost device?
|
|
for (const TSharedPtr<FTargetDeviceEntry>& EntryPtr : DeviceList)
|
|
{
|
|
if (EntryPtr->DeviceId == LostDeviceId)
|
|
{
|
|
EntryPtr->DeviceWeakPtr = nullptr;
|
|
}
|
|
}
|
|
}
|
|
|
|
void SDeviceOutputLog::HandleTargetPlatformDeviceDiscovered(ITargetDeviceRef DiscoveredDevice)
|
|
{
|
|
FTargetDeviceId DiscoveredDeviceId = DiscoveredDevice->GetId();
|
|
|
|
int32 ExistingEntryIdx = DeviceList.IndexOfByPredicate([&](const TSharedPtr<FTargetDeviceEntry>& Other) {
|
|
return (Other->DeviceId == DiscoveredDeviceId);
|
|
});
|
|
|
|
if (DeviceList.IsValidIndex(ExistingEntryIdx))
|
|
{
|
|
DeviceList[ExistingEntryIdx]->DeviceWeakPtr = DiscoveredDevice;
|
|
|
|
if (CurrentDevicePtr.IsValid() && CurrentDevicePtr->DeviceId == DeviceList[ExistingEntryIdx]->DeviceId)
|
|
{
|
|
CurrentDeviceOutputPtr = DiscoveredDevice->CreateDeviceOutputRouter(this);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AddDeviceEntry(DiscoveredDevice);
|
|
}
|
|
}
|
|
|
|
void SDeviceOutputLog::AddDeviceEntry(ITargetDeviceRef TargetDevice)
|
|
{
|
|
using namespace PlatformInfo;
|
|
FName DeviceIconStyleName = TargetDevice->GetTargetPlatform().GetPlatformInfo().GetIconStyleName(EPlatformIconSize::Normal);
|
|
|
|
TSharedPtr<FTargetDeviceEntry> DeviceEntry = MakeShareable(new FTargetDeviceEntry());
|
|
|
|
DeviceEntry->DeviceId = TargetDevice->GetId();
|
|
DeviceEntry->DeviceName = TargetDevice->GetName();
|
|
DeviceEntry->DeviceIconBrush = FEditorStyle::GetBrush(DeviceIconStyleName);
|
|
DeviceEntry->DeviceWeakPtr = TargetDevice;
|
|
|
|
DeviceList.Add(DeviceEntry);
|
|
}
|
|
|
|
void SDeviceOutputLog::OnDeviceSelectionChanged(FTargetDeviceEntryPtr DeviceEntry)
|
|
{
|
|
CurrentDeviceOutputPtr.Reset();
|
|
OnClearLog();
|
|
CurrentDevicePtr = DeviceEntry;
|
|
|
|
if (DeviceEntry.IsValid())
|
|
{
|
|
ITargetDevicePtr PinnedPtr = DeviceEntry->DeviceWeakPtr.Pin();
|
|
if (PinnedPtr.IsValid() && PinnedPtr->IsConnected())
|
|
{
|
|
CurrentDeviceOutputPtr = PinnedPtr->CreateDeviceOutputRouter(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
TSharedRef<SWidget> SDeviceOutputLog::MakeDeviceComboButtonMenu()
|
|
{
|
|
FMenuBuilder MenuBuilder(/*bInShouldCloseWindowAfterMenuSelection=*/true, nullptr);
|
|
for (const FTargetDeviceEntryPtr& TargetDeviceEntryPtr : DeviceList)
|
|
{
|
|
TSharedRef<SWidget> MenuEntryWidget = GenerateWidgetForDeviceComboBox(TargetDeviceEntryPtr);
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
FUIAction(FExecuteAction::CreateSP(this, &SDeviceOutputLog::OnDeviceSelectionChanged, TargetDeviceEntryPtr)),
|
|
MenuEntryWidget
|
|
);
|
|
}
|
|
return MenuBuilder.MakeWidget();
|
|
}
|
|
|
|
TSharedRef<SWidget> SDeviceOutputLog::GenerateWidgetForDeviceComboBox(const FTargetDeviceEntryPtr& DeviceEntry) const
|
|
{
|
|
return
|
|
SNew(SBox)
|
|
[
|
|
SNew(SHorizontalBox)
|
|
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SNew(SBox)
|
|
.WidthOverride(24)
|
|
.HeightOverride(24)
|
|
[
|
|
SNew(SImage).Image(GetTargetDeviceBrush(DeviceEntry))
|
|
]
|
|
]
|
|
|
|
+SHorizontalBox::Slot()
|
|
.VAlign(VAlign_Center)
|
|
.Padding(FMargin(4.0f, 0.0f))
|
|
[
|
|
SNew(STextBlock).Text(this, &SDeviceOutputLog::GetTargetDeviceText, DeviceEntry)
|
|
]
|
|
];
|
|
}
|
|
|
|
const FSlateBrush* SDeviceOutputLog::GetTargetDeviceBrush(FTargetDeviceEntryPtr DeviceEntry) const
|
|
{
|
|
if (DeviceEntry.IsValid())
|
|
{
|
|
return DeviceEntry->DeviceIconBrush;
|
|
}
|
|
else
|
|
{
|
|
return FEditorStyle::GetBrush("Launcher.Instance_Unknown");
|
|
}
|
|
}
|
|
|
|
const FSlateBrush* SDeviceOutputLog::GetSelectedTargetDeviceBrush() const
|
|
{
|
|
return GetTargetDeviceBrush(CurrentDevicePtr);
|
|
}
|
|
|
|
FText SDeviceOutputLog::GetTargetDeviceText(FTargetDeviceEntryPtr DeviceEntry) const
|
|
{
|
|
if (DeviceEntry.IsValid())
|
|
{
|
|
ITargetDevicePtr PinnedPtr = DeviceEntry->DeviceWeakPtr.Pin();
|
|
if (PinnedPtr.IsValid() && PinnedPtr->IsConnected())
|
|
{
|
|
return FText::FromString(DeviceEntry->DeviceName);
|
|
}
|
|
else
|
|
{
|
|
return FText::Format(NSLOCTEXT("OutputLog", "TargetDeviceOffline", "{0} (Offline)"), FText::FromString(DeviceEntry->DeviceName));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return NSLOCTEXT("OutputLog", "UnknownTargetDevice", "<Unknown device>");
|
|
}
|
|
}
|
|
|
|
FText SDeviceOutputLog::GetSelectedTargetDeviceText() const
|
|
{
|
|
return GetTargetDeviceText(CurrentDevicePtr);
|
|
}
|