Files
UnrealEngineUWP/Engine/Source/Developer/OutputLog/Private/SDeviceOutputLog.cpp

330 lines
9.1 KiB
C++
Raw Normal View History

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "OutputLogPrivatePCH.h"
#include "SDeviceOutputLog.h"
#include "ITargetPlatform.h"
#include "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 )
{
Copying //UE4/Dev-Editor to Dev-Main (//UE4/Dev-Main) #lockdown nick.penwarden Change 2889481 on 2016/03/02 by Richard.TalbotWatkin Fixed socket preview component in Static Mesh Editor so that it remains correctly attached if the socket is renamed (Contributed by Manny-MADE). PR #2094 #jira UE-27338 - GitHub 2094 : BUGFIX: Socket preview component broken in Static Mesh Editor FSlateAtlasedTextureResource Made changes to the Perforce source control provider so that operations can be cancelled with immediate effect if there is an issue connecting to the server. #jira UE-24632 - "Updating file(s) source control status..." dialog doesn't allow Cancel #RB Thomas.Sarkanen Change 2890359 on 2016/03/02 by Nick.Darnell Jira Mirroring - Adding some tools for matching gits sha to perforce commits. Also adding the program for scraping jira issues and pushing them elsewhere. Change 2892008 on 2016/03/03 by Richard.TalbotWatkin Back out changelist 2813475 Change 2892086 on 2016/03/03 by Richard.TalbotWatkin Back out changelist 2813457 Change 2892117 on 2016/03/03 by Richard.TalbotWatkin Back out changelist 2812830 Change 2892316 on 2016/03/03 by Richard.TalbotWatkin Fixed conversion of brushes to volumes so that the original transform isn't lost. #jira UE-24404 - Convert Actor from BSP to volume can affect the actor transform Change 2892765 on 2016/03/03 by Andrew.Rodham Changed public facing level editor classes to use ILevelEditor instead of SLevelEditor #codereview Mike.Fricker Change 2894154 on 2016/03/04 by Richard.TalbotWatkin Fixed error in USplineComponent::GetSegmentLength when the segment is linear or constant. Change 2894481 on 2016/03/04 by Cody.Albert #jira UE-27830 Fixed mismatched layout name Change 2896339 on 2016/03/06 by Richard.TalbotWatkin Fixed undo issues in texture paint mode. #jira UE-21206 - Texture Painting bugs Change 2896713 on 2016/03/07 by Joe.Conley Replacing #ifndef with #pragma once Change 2896955 on 2016/03/07 by Cody.Albert #jira UE-27711 Added initialization for LastHighlightInteractionTime Change 2898895 on 2016/03/08 by Richard.TalbotWatkin More optimizations to editing actors with a large number of components. Improved performance when executing construction scripts. #jira UE-24821 - Blueprints with thousands of components perform very badly when selected in the Level Viewport Change 2900770 on 2016/03/09 by Joe.Conley Change #ifndef to #pragma once for headers under Runtime/Engine/Public Change 2900835 on 2016/03/09 by Richard.TalbotWatkin Fixed issues with scrolling items into view in STileView. Also fixed bugs in STileView::ReGenerateItems. #jira UE-20441 - Hitting F2 to rename an asset in the Content Browser moves the asset out of view if the CB is at default size and location #jira UE-20807 - Browse to Asset in Content Browser focuses just on the text #codereview Nick.Atamas Change 2900837 on 2016/03/09 by Richard.TalbotWatkin Added an OnKeyDownHandler to SSearchBox and SAssetSearchBox so that functionality for handling keypresses which is normally handled by SEditableText can be overridden. Added custom behavior to SAssetPicker and SAssetSearchBox so that up/down cursor keys can be used to change focus from the text box to the menu. #jira UE-20567 - UX Regression on Open Asset Panel This also addresses a similar issue with the auto-complete popup in the Content Browser search bar. Change 2900847 on 2016/03/09 by Richard.TalbotWatkin Fixed include dependency. Change 2900951 on 2016/03/09 by Richard.TalbotWatkin Fixed non-dependent name lookup for superclass member access. Change 2901325 on 2016/03/09 by Jamie.Dale PR #2107: Output Log Filtering (Contributed by phoboz-net) Change 2901391 on 2016/03/09 by Jamie.Dale Some more output log filter improvements We now defer the search until you finish typing, and the filter list itself now uses toggle buttons (like the content browser) so that you can toggle multiple filters without having to re-open the menu. Change 2901736 on 2016/03/09 by Alexis.Matte #jira UE-14632 Export staticmeshactor which are base on blueprint class as a blueprint instead of exporting it as an actor. #codereview nick.darnell Change 2903162 on 2016/03/10 by Alexis.Matte Fbx scene importer, Fix crash when changing the material base path in the material tab page #codereview nick.darnell Change 2903903 on 2016/03/10 by Richard.TalbotWatkin Fixed crash when attempting to paste an object from the level viewport into the content browser. #jira UE-26100 - Crash when attempting to copy an object from the world into the content browser Change 2903947 on 2016/03/10 by Richard.TalbotWatkin [CL 2937134 by Nick Darnell in Main branch]
2016-04-07 16:16:52 -04:00
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, 4.0f, 0.0f, 0.0f))
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.AutoWidth()
[
SAssignNew(TargetDeviceComboBox, SComboBox<FTargetDeviceEntryPtr>)
.OptionsSource(&DeviceList)
.ButtonStyle(FEditorStyle::Get(), "ToolBar.Button")
.OnSelectionChanged(this, &SDeviceOutputLog::OnDeviceSelectionChanged)
.OnGenerateWidget(this, &SDeviceOutputLog::GenerateWidgetForDeviceComboBox)
.ContentPadding(FMargin(4.0f, 0.0f))
.Content()
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SBox)
.WidthOverride(16)
.HeightOverride(16)
[
SNew(SImage).Image(this, &SDeviceOutputLog::GetSelectedTargetDeviceBrush)
]
]
+SHorizontalBox::Slot()
.VAlign(VAlign_Center)
[
SNew(STextBlock).Text(this, &SDeviceOutputLog::GetSelectedTargetDeviceText)
]
]
]
+SHorizontalBox::Slot()
.Padding(FMargin(4.0f, 0.0f, 0.0f, 4.0f))
.FillWidth(1)
[
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)
{
FTargetDeviceEntryPtr SelectedDeviceEntry = TargetDeviceComboBox->GetSelectedItem();
if (SelectedDeviceEntry.IsValid())
{
ITargetDevicePtr PinnedPtr = SelectedDeviceEntry->DeviceWeakPtr.Pin();
if (PinnedPtr.IsValid())
{
PinnedPtr->ExecuteConsoleCommand(ExecCommand);
}
}
}
void SDeviceOutputLog::HandleTargetPlatformDeviceLost(ITargetDeviceRef LostDevice)
{
auto LostDeviceId = LostDevice->GetId();
FTargetDeviceEntryPtr SelectedDeviceEntry = TargetDeviceComboBox->GetSelectedItem();
if (SelectedDeviceEntry.IsValid() && SelectedDeviceEntry->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 (TargetDeviceComboBox->GetSelectedItem() == DeviceList[ExistingEntryIdx])
{
CurrentDeviceOutputPtr = DiscoveredDevice->CreateDeviceOutputRouter(this);
}
}
else
{
AddDeviceEntry(DiscoveredDevice);
TargetDeviceComboBox->RefreshOptions();
}
}
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, ESelectInfo::Type SelectInfo)
{
CurrentDeviceOutputPtr.Reset();
OnClearLog();
if (DeviceEntry.IsValid())
{
ITargetDevicePtr PinnedPtr = DeviceEntry->DeviceWeakPtr.Pin();
if (PinnedPtr.IsValid() && PinnedPtr->IsConnected())
{
CurrentDeviceOutputPtr = PinnedPtr->CreateDeviceOutputRouter(this);
}
}
}
TSharedRef<SWidget> SDeviceOutputLog::GenerateWidgetForDeviceComboBox(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
{
FTargetDeviceEntryPtr DeviceEntry = TargetDeviceComboBox->GetSelectedItem();
return GetTargetDeviceBrush(DeviceEntry);
}
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
{
FTargetDeviceEntryPtr DeviceEntry = TargetDeviceComboBox->GetSelectedItem();
return GetTargetDeviceText(DeviceEntry);
}