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 ========================== Change3152124on 2016/10/05 by Jamie.Dale Fixed SOutputLog filter not handling OnTextCommitted Change 3152255 on 2016/10/05 by Michael.Dupuis #jira UE-28173 Support \" properly in FName Change 3152273 on 2016/10/05 by Nick.Darnell Core - The module manager is now thread safer, we had a critical section around the internal module list - but we were incrementing/decrementing shared pointers to module data shared pointers that were not thread safe outside of the critical section. Ran into a crash working on some heavily threaded code in automation. Change 3152314 on 2016/10/05 by Nick.Darnell Automation - Continued work to rough out the automation workflow for screenshot. Still lots of work remaining, but it appears the basic of approving images might be working as of this CL. Change 3152316 on 2016/10/05 by Michael.Dupuis #jira UE-30346 Update selection when in tree view mode Change 3152317 on 2016/10/05 by Nick.Darnell Automation - Adding some test shots to compare against to EngineTest for screenshot approval. Change 3152319 on 2016/10/05 by Michael.Dupuis #jira UE-29817 StringAssetReference will now only open an Asset picker (not actor picker) as the goal is to reference an asset Change 3152521 on 2016/10/05 by Nick.Darnell Automation - Fixing some issues with where it reads the screenshot compare rules. Change 3152536 on 2016/10/05 by Alexis.Matte Fix FBX automation test. - Make sure the fbx test can avoid automatic detection of the mesh type - Avoid to log the warning when the importer set the material usage after creating a material for skeletalmesh. Change 3152572 on 2016/10/05 by Nick.Darnell Automation - The GameProjectAutomationTests now do some pre-run house cleaning to make sure the project doesn't already exist, and tries to remove it if it was created previously but not deleted. Change 3152591 on 2016/10/05 by Nick.Darnell Automation - Changing the game project errors to be errors. Change 3153115 on 2016/10/06 by Jamie.Dale Removed superflous padding when SPropertyEditorAsset had no buttons Change 3153215 on 2016/10/06 by Michael.Dupuis Fixed build warning Change 3153248 on 2016/10/06 by Nick.Darnell Automation - Working on solving projects not being generated, suspect UBT isn't built or isn't available. Change 3153255 on 2016/10/06 by Nick.Darnell PR #2835: Fix TestEqual AddError Message in FAutomationTestBase (Contributed by dorgonman) #jira UE-36922 Change 3153300 on 2016/10/06 by Nick.Darnell Automation - Enabled verbose logging to automation build farm. Change 3153343 on 2016/10/06 by Matt.Kuhlenschmidt PR #2825: More project launcher progress improvements (Contributed by projectgheist) Change 3153506 on 2016/10/06 by Gareth.Martin Fixed crash trying to edit landscape with r.LightPropagationVolume=1 enabled #jira UE-36933 Change 3153752 on 2016/10/06 by tim.gautier Add toggle button to UMG_Behavior. Set Level Blueprint for TM-UMG to AllWidget Change 3153763 on 2016/10/06 by Nick.Darnell Automation - Disable verbose logging. Change 3153778 on 2016/10/06 by Nick.Darnell PR #2837: Fixed engine compilation with defined LOG_SLATE_EVENTS (Contributed by Pierdek) #jira UE-36940 Change 3153943 on 2016/10/06 by Nick.Darnell Automation - Disabling some broken tests. Change 3154035 on 2016/10/06 by Nick.Darnell Automation - Fixing re-runs for tests that want them. Previously this wasn't working for any test that was run using the Reprostring method of being executed. Change 3154039 on 2016/10/06 by Nick.Darnell Automation - Updating some test assets in the EngineTest project. Change 3154476 on 2016/10/07 by Richard.TalbotWatkin Fix to regression where vertex color view in Mesh Paint Mode no longer worked correctly. We now allow selected static meshes to go down the dynamic path if VertexColors show mode is active. #jira UE-36772 - Selecting a channel in Vertex Paint mode does not show the channel color Change 3154650 on 2016/10/07 by Alexis.Matte Add new front axis facing X option to fbx importer Change 3154785 on 2016/10/07 by Nick.Darnell Automation - Continued work on automation, ripping out the message bus from the screenshot manager, that's causing the screenshot manager to recieve shots from every machine ever running tests. The Automation Controller is now in charge, and will tell the screenshot manager whatever it needs. Change 3155131 on 2016/10/07 by Michael.Dupuis #jira UE-36509 Do not disabled inverse filter when doing a sync to asset Change 3155141 on 2016/10/07 by Michael.Dupuis #jira UE-36056 Do not open the Actor Picker if we're working on an archetype object Change 3155262 on 2016/10/07 by Michael.Dupuis #jira UE-19737 reset ctrl key when resetting state to None Change 3156326 on 2016/10/09 by Matt.Kuhlenschmidt Fixed crash when asset picker is used without a property editor (usually a heavily customized property). Change 3156473 on 2016/10/10 by Richard.TalbotWatkin Attempt to make geometry render / rebuild more robust in the hope of catching UE-36265. #jira UE-36265 - [CrashReport] UE4Editor_Engine!FModelSceneProxy::HasSelectedSurfaces() [modelrender.cpp:538] Change 3156479 on 2016/10/10 by Richard.TalbotWatkin Fixed non-editor build. Change 3156579 on 2016/10/10 by Alexis.Matte Add a check to make sure curve pointer is valid. #jira UE-36177 Change 3156585 on 2016/10/10 by Ben.Marsh Fix line endings for screenshot settings. Change 3156617 on 2016/10/10 by Matt.Kuhlenschmidt Disable per-pixel blending of menus by default. Causes artifacts on windows versions and we are not using it. Change 3156674 on 2016/10/10 by Nick.Darnell Automation - Continued work on the automation workflow. Now screenshot functional test actors actually have the screenshot processed for differences during the test back on the test controller machine, and then waits for the results of the comparison to be performed. Change 3156709 on 2016/10/10 by Alexis.Matte #jira UE-16337 Make sure the base mesh import data transform is used when we import a LOD. Change 3156714 on 2016/10/10 by Nick.Darnell Automation - Fixing -game crash due to TestName being null in functional test. Change 3156721 on 2016/10/10 by Nick.Darnell Automation - FunctionalAITest now implements IsReady to check if the navigation mesh has finished being built. Change 3156748 on 2016/10/10 by Nick.Darnell Autopmation - Fixing a warning. Change 3156943 on 2016/10/10 by Alex.Delesky Fixed an issue where closing out the "Add Code" window with an active toast stating that an IDE was downloading would prevent the toast from clearing correctly. #jira none Change 3156946 on 2016/10/10 by Alex.Delesky #jira UE-36414 - Adding support for the P4Changelist command line argument to the P4 operations that were missing it. Change 3158215 on 2016/10/11 by Nick.Darnell Automation - Continued work on the screenshot comparison, fixed a crash, the system now reports if the screenshot was new, as well as similar, so that the script can react and warn when new screenshots are produced. Manually fired screenshots now properly wait until they've been compared before the test moves forward. Change 3158322 on 2016/10/11 by Michael.Dupuis #jira UE-36063 If the collection is not shown when trying to save one, force show them so the user understand what is going on Change 3158333 on 2016/10/11 by Alex.Delesky #jira UE-36829 - Rebuilt SVN 1.9.4 libs for Windows with CyrusSASL 2.1.26 and SWIG 3.0.10 support. Change 3158399 on 2016/10/11 by Nick.Darnell Automation - TTF Font log statements that were not warnings are no longer warnings. Change 3158406 on 2016/10/11 by Nick.Darnell Automation - Updating some automation scripts in the engnine that were using file paths to now use FStringAssetReferences, that cleaned up a lot of nasty convert filepath to asset reference code in the tests. Also introducing some maps, and setting up the configs to use them to try and appease some of the existing tests that were expecting them. Change 3158419 on 2016/10/11 by Alex.Delesky #jira UE-36829 - SVN 1.9.4 libraries, but also with Java 8u101 support. Change 3158537 on 2016/10/11 by Nick.Darnell Automation - Updating some automation scripts in the engnine that were using file paths to now use FStringAssetReferences, that cleaned up a lot of nasty convert filepath to asset reference code in the tests. Also introducing some maps, and setting up the configs to use them to try and appease some of the existing tests that were expecting them. Adding some missing files. Change 3158726 on 2016/10/11 by Michael.Dupuis #jira UE-37001 Perform manual migration of UICurve to proper config category Change 3158728 on 2016/10/11 by Nick.Darnell Automation - Fixing some warnings. Adding more testing to the Domino map to serve as a better example. Change 3158753 on 2016/10/11 by Michael.Dupuis #jira UE-26261 change it's by its Change 3158984 on 2016/10/11 by Alexis.Matte Fix D&D folder import in content browser. We have to expand the root directory to have the correct path. #jira UE-32155 Change 3159640 on 2016/10/12 by Jamie.Dale Split localized package redirection out of FCoreDelegates::PackageNameResolvers They're different enough in behavior that the delegate resolution was breaking the localized package resolution by resolving in too many places and causing the localized package to be loaded with its real localized name as well as the fake non-localized name. #jira UE-37119 Change 3159741 on 2016/10/12 by Nick.Darnell Slate - Fixing the SGraphPanel's mouse offset calculations so that it works with HDPI mode. Change 3159762 on 2016/10/12 by Nick.Darnell Automation - Adding a way to take a screenshot with the UI, not great yet - it doesn't really obey the rules of resolution, because of the method it uses. Change 3160210 on 2016/10/12 by Gareth.Martin Fixed crash when changing Landscape LOD while using "Grass use Landscape Lightmap" Change 3160216 on 2016/10/12 by Gareth.Martin Removed unused FLandscapeComponentSceneProxy::LayerNames and made LayerColors editor-only Fixed negative LODBias on landscape components to actually do anything Change 3160239 on 2016/10/12 by Gareth.Martin Removed an unused variable Change 3160455 on 2016/10/12 by Jamie.Dale Fixed FText properties exported to asset tags displaying in their NSLOCTEXT form in the asset tooltips Change 3160457 on 2016/10/12 by Jamie.Dale Localization automation now groups everything into a single CL and reverts PO files without significant changes Change 3160554 on 2016/10/12 by Nick.Darnell UMG - Fixing some panning logic to work with HDPI mode in the designer. Change 3161712 on 2016/10/13 by Jamie.Dale Fixed TSharedMapView using hard-coded types Change 3163044 on 2016/10/14 by Jamie.Dale Fixed line-break iterators incorrectly breaking words in CJK Change 3163046 on 2016/10/14 by Jamie.Dale Text layout no longer creates break candidates when wrapping is disabled Change 3163217 on 2016/10/14 by Jamie.Dale Fixed ensure caused by FMediaTextureResource::GetResourceSizeEx Change 3163641 on 2016/10/14 by Alex.Delesky #jira UE-36829 - Updated Mac SVN libraries, along with a more accurate changelog for Windows SVN libs Change 3164428 on 2016/10/17 by Nick.Darnell Slate - Making the FReply for SetMousePos easier to debug, since that option is potentially very frustrating to debug when someone is changing it. Change 3164833 on 2016/10/17 by Jamie.Dale Fixed ParseNumber consuming strings with multiple sequential dots as valid numbers, eg) "10..." Change 3164868 on 2016/10/17 by Alexis.Matte Remove re-import material and LOD import material #jira UE-36640 Change 3164874 on 2016/10/17 by Alexis.Matte Fix fbx scene re-import of staticmesh loosing there materials #jira UE-37032 Change 3165080 on 2016/10/17 by Alexis.Matte Remove skinxx workflow for static mesh #jira UE-37262 Change 3165232 on 2016/10/17 by Nick.Darnell Automation - Adding some sub-level testing. Change 3165822 on 2016/10/18 by Nick.Darnell Slate - Add a counter to track how much time we spend drawing custom verts each frame. Change 3165934 on 2016/10/18 by Nick.Darnell Slate - Addding cycle counters to SInvalidationPanel's Tick and Paint. Change 3165947 on 2016/10/18 by Nick.Darnell Slate - Addding very verbose slate stats behind a compiler flag to avoid the large overhead of these stats. To enable them you'll need to set WITH_VERY_VERBOSE_SLATE_STATS to 1, added a guide on debugging slate performance to the SlateGlobals.h // HOW TO GET AN IN-DEPTH PERFORMANCE ANALYSIS OF SLATE // // Step 1) // Set WITH_VERY_VERBOSE_SLATE_STATS to 1. // // Step 2) // When running the game (outside of the editor), run these commandline options // in order and you'll get a large dump of where all the time is going in Slate. // // stat group enable slateverbose // stat group enable slateveryverbose // stat dumpave -root=stat_slate -num=120 -ms=0 Change 3165962 on 2016/10/18 by Nick.Darnell UMG - Play first frame of sequence in UMG immediately when told to play an animation. Change 3165981 on 2016/10/18 by Nick.Darnell Core - GetDisplayNameText now stores the FName for DisplayName in a static instead of using TEXT("DisplayName"). Change 3166000 on 2016/10/18 by Jamie.Dale Removed bulk-data from fonts The main complaints about composite fonts have always been: 1) They use too much memory at runtime. 2) They bloat if you use the same font face twice. 3) They often break when used outside the game thread. This change aims to address all of these issues by removing bulk-data from fonts (which was the cause of the memory bloat and threading issues), and introduces UFontFace assets (which allow you to re-use the same font face in different entries within a composite font). No existing font data is lost during this transition, however you must manually update your UFont assets to reference external UFontFace assets before you're able to edit the existing data (which is automatically upgraded to UFontFace assets *within* the UFont package). This upgrade can be done via the composite font editor. During cook these UFontFace assets write out the actual TTF/OTF font data as a .ufont file, which is what FreeType actually loads at runtime (the internals of the Slate font cache are now completely independent of UObjects and their lifetimes and loading concerns). Since we're now always loading files from disk, we can also give the user an option of whether to "pre-load" (which will load the entire font into memory, like bulk-data always used to), or "stream" the font from disk (which has minimal memory overhead, but needs decent I/O performance). Change 3166001 on 2016/10/18 by Jamie.Dale Updated the Launcher to no longer use bulk-data for fonts Change3166003on 2016/10/18 by Jamie.Dale Updated the Engine fonts to use UFontFace assets Change 3166028 on 2016/10/18 by Alex.Delesky #jira UE-37021 - The scrollbar will now remain at the bottom of the output log after specifying a filter. Change 3166071 on 2016/10/18 by Nick.Darnell Slate - Fixing a warning about hiding an inherited member. Change 3166213 on 2016/10/18 by Jamie.Dale Fixing crash caused by accessing a zeroed FText Change 3166222 on 2016/10/18 by Nick.Darnell Automation - Adding some code to end the sub level test when it starts. Change 3166231 on 2016/10/18 by Nick.Darnell Editor - Fixing the build warning, SOutputLog.cpp:748:4: warning: field 'TextLayout' will be initialized after field 'CachedNumMessages' Change 3166717 on 2016/10/18 by Nick.Darnell Automation - Removing references to old options that are no longer file paths, and are now StringAssetReferences these options were not being used by anyone as far as I can tell. #jira UE-37482 Change 3167279 on 2016/10/19 by Jamie.Dale Fixed text render component regression with custom MIDs #jira UE-37305 Change 3167356 on 2016/10/19 by Alexis.Matte Make sure the old asset are build correctly #jira UE-37461 Change 3167359 on 2016/10/19 by Alexis.Matte Fix re-import of mesh material assignment regression #jira UE-37479 [CL 3168049 by Matt Kuhlenschmidt in Main branch]
1180 lines
30 KiB
C++
1180 lines
30 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "OutputLogPrivatePCH.h"
|
|
#include "SOutputLog.h"
|
|
#include "SScrollBorder.h"
|
|
#include "GameFramework/GameModeBase.h"
|
|
#include "GameFramework/GameStateBase.h"
|
|
#include "Engine/LocalPlayer.h"
|
|
#include "SSearchBox.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "SOutputLog"
|
|
|
|
/** Expression context to test the given messages against the current text filter */
|
|
class FLogFilter_TextFilterExpressionContext : public ITextFilterExpressionContext
|
|
{
|
|
public:
|
|
explicit FLogFilter_TextFilterExpressionContext(const FLogMessage& InMessage) : Message(&InMessage) {}
|
|
|
|
/** Test the given value against the strings extracted from the current item */
|
|
virtual bool TestBasicStringExpression(const FTextFilterString& InValue, const ETextFilterTextComparisonMode InTextComparisonMode) const override { return TextFilterUtils::TestBasicStringExpression(*Message->Message, InValue, InTextComparisonMode); }
|
|
|
|
/**
|
|
* Perform a complex expression test for the current item
|
|
* No complex expressions in this case - always returns false
|
|
*/
|
|
virtual bool TestComplexExpression(const FName& InKey, const FTextFilterString& InValue, const ETextFilterComparisonOperation InComparisonOperation, const ETextFilterTextComparisonMode InTextComparisonMode) const override { return false; }
|
|
|
|
private:
|
|
/** Message that is being filtered */
|
|
const FLogMessage* Message;
|
|
};
|
|
|
|
/** Custom console editable text box whose only purpose is to prevent some keys from being typed */
|
|
class SConsoleEditableTextBox : public SEditableTextBox
|
|
{
|
|
public:
|
|
SLATE_BEGIN_ARGS( SConsoleEditableTextBox ) {}
|
|
|
|
/** Hint text that appears when there is no text in the text box */
|
|
SLATE_ATTRIBUTE(FText, HintText)
|
|
|
|
/** Called whenever the text is changed interactively by the user */
|
|
SLATE_EVENT(FOnTextChanged, OnTextChanged)
|
|
|
|
/** Called whenever the text is committed. This happens when the user presses enter or the text box loses focus. */
|
|
SLATE_EVENT(FOnTextCommitted, OnTextCommitted)
|
|
|
|
SLATE_END_ARGS()
|
|
|
|
|
|
void Construct( const FArguments& InArgs )
|
|
{
|
|
SetStyle(&FCoreStyle::Get().GetWidgetStyle< FEditableTextBoxStyle >("NormalEditableTextBox"));
|
|
|
|
SBorder::Construct(SBorder::FArguments()
|
|
.BorderImage(this, &SConsoleEditableTextBox::GetConsoleBorder)
|
|
.BorderBackgroundColor(Style->BackgroundColor)
|
|
.ForegroundColor(Style->ForegroundColor)
|
|
.Padding(Style->Padding)
|
|
[
|
|
SAssignNew( EditableText, SConsoleEditableText )
|
|
.HintText( InArgs._HintText )
|
|
.OnTextChanged( InArgs._OnTextChanged )
|
|
.OnTextCommitted( InArgs._OnTextCommitted )
|
|
] );
|
|
}
|
|
|
|
private:
|
|
class SConsoleEditableText : public SEditableText
|
|
{
|
|
public:
|
|
SLATE_BEGIN_ARGS( SConsoleEditableText ) {}
|
|
/** The text that appears when there is nothing typed into the search box */
|
|
SLATE_ATTRIBUTE(FText, HintText)
|
|
/** Called whenever the text is changed interactively by the user */
|
|
SLATE_EVENT(FOnTextChanged, OnTextChanged)
|
|
|
|
/** Called whenever the text is committed. This happens when the user presses enter or the text box loses focus. */
|
|
SLATE_EVENT(FOnTextCommitted, OnTextCommitted)
|
|
SLATE_END_ARGS()
|
|
|
|
void Construct( const FArguments& InArgs )
|
|
{
|
|
SEditableText::Construct
|
|
(
|
|
SEditableText::FArguments()
|
|
.HintText( InArgs._HintText )
|
|
.OnTextChanged( InArgs._OnTextChanged )
|
|
.OnTextCommitted( InArgs._OnTextCommitted )
|
|
.ClearKeyboardFocusOnCommit( false )
|
|
.IsCaretMovedWhenGainFocus( false )
|
|
.MinDesiredWidth( 400.0f )
|
|
);
|
|
}
|
|
|
|
virtual FReply OnKeyDown( const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent )
|
|
{
|
|
// Special case handling. Intercept the tilde key. It is not suitable for typing in the console
|
|
if( InKeyEvent.GetKey() == EKeys::Tilde )
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
else
|
|
{
|
|
return SEditableText::OnKeyDown( MyGeometry, InKeyEvent );
|
|
}
|
|
}
|
|
|
|
virtual FReply OnKeyChar( const FGeometry& MyGeometry, const FCharacterEvent& InCharacterEvent )
|
|
{
|
|
// Special case handling. Intercept the tilde key. It is not suitable for typing in the console
|
|
if( InCharacterEvent.GetCharacter() != 0x60 )
|
|
{
|
|
return SEditableText::OnKeyChar( MyGeometry, InCharacterEvent );
|
|
}
|
|
else
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
/** @return Border image for the text box based on the hovered and focused state */
|
|
const FSlateBrush* GetConsoleBorder() const
|
|
{
|
|
if (EditableText->HasKeyboardFocus())
|
|
{
|
|
return &Style->BackgroundImageFocused;
|
|
}
|
|
else
|
|
{
|
|
if (EditableText->IsHovered())
|
|
{
|
|
return &Style->BackgroundImageHovered;
|
|
}
|
|
else
|
|
{
|
|
return &Style->BackgroundImageNormal;
|
|
}
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
SConsoleInputBox::SConsoleInputBox()
|
|
: SelectedSuggestion(-1)
|
|
, bIgnoreUIUpdate(false)
|
|
{
|
|
}
|
|
|
|
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
void SConsoleInputBox::Construct( const FArguments& InArgs )
|
|
{
|
|
OnConsoleCommandExecuted = InArgs._OnConsoleCommandExecuted;
|
|
ConsoleCommandCustomExec = InArgs._ConsoleCommandCustomExec;
|
|
|
|
ChildSlot
|
|
[
|
|
SAssignNew( SuggestionBox, SMenuAnchor )
|
|
.Placement( InArgs._SuggestionListPlacement )
|
|
[
|
|
SAssignNew(InputText, SConsoleEditableTextBox)
|
|
.OnTextCommitted(this, &SConsoleInputBox::OnTextCommitted)
|
|
.HintText( NSLOCTEXT( "ConsoleInputBox", "TypeInConsoleHint", "Enter console command" ) )
|
|
.OnTextChanged(this, &SConsoleInputBox::OnTextChanged)
|
|
]
|
|
.MenuContent
|
|
(
|
|
SNew(SBorder)
|
|
.BorderImage(FEditorStyle::GetBrush("Menu.Background"))
|
|
.Padding( FMargin(2) )
|
|
[
|
|
SNew(SBox)
|
|
.HeightOverride(250) // avoids flickering, ideally this would be adaptive to the content without flickering
|
|
[
|
|
SAssignNew(SuggestionListView, SListView< TSharedPtr<FString> >)
|
|
.ListItemsSource(&Suggestions)
|
|
.SelectionMode( ESelectionMode::Single ) // Ideally the mouse over would not highlight while keyboard controls the UI
|
|
.OnGenerateRow(this, &SConsoleInputBox::MakeSuggestionListItemWidget)
|
|
.OnSelectionChanged(this, &SConsoleInputBox::SuggestionSelectionChanged)
|
|
.ItemHeight(18)
|
|
]
|
|
]
|
|
)
|
|
];
|
|
}
|
|
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
|
|
void SConsoleInputBox::Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
|
|
{
|
|
if (!GIntraFrameDebuggingGameThread && !IsEnabled())
|
|
{
|
|
SetEnabled(true);
|
|
}
|
|
else if (GIntraFrameDebuggingGameThread && IsEnabled())
|
|
{
|
|
SetEnabled(false);
|
|
}
|
|
}
|
|
|
|
|
|
void SConsoleInputBox::SuggestionSelectionChanged(TSharedPtr<FString> NewValue, ESelectInfo::Type SelectInfo)
|
|
{
|
|
if(bIgnoreUIUpdate)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for(int32 i = 0; i < Suggestions.Num(); ++i)
|
|
{
|
|
if(NewValue == Suggestions[i])
|
|
{
|
|
SelectedSuggestion = i;
|
|
MarkActiveSuggestion();
|
|
|
|
// If the user selected this suggestion by clicking on it, then go ahead and close the suggestion
|
|
// box as they've chosen the suggestion they're interested in.
|
|
if( SelectInfo == ESelectInfo::OnMouseClick )
|
|
{
|
|
SuggestionBox->SetIsOpen( false );
|
|
}
|
|
|
|
// Ideally this would set the focus back to the edit control
|
|
// FWidgetPath WidgetToFocusPath;
|
|
// FSlateApplication::Get().GeneratePathToWidgetUnchecked( InputText.ToSharedRef(), WidgetToFocusPath );
|
|
// FSlateApplication::Get().SetKeyboardFocus( WidgetToFocusPath, EFocusCause::SetDirectly );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
TSharedRef<ITableRow> SConsoleInputBox::MakeSuggestionListItemWidget(TSharedPtr<FString> Text, const TSharedRef<STableViewBase>& OwnerTable)
|
|
{
|
|
check(Text.IsValid());
|
|
|
|
FString Left, Mid, Right, TempRight, Combined;
|
|
|
|
if(Text->Split(TEXT("\t"), &Left, &TempRight))
|
|
{
|
|
if (TempRight.Split(TEXT("\t"), &Mid, &Right))
|
|
{
|
|
Combined = Left + Mid + Right;
|
|
}
|
|
else
|
|
{
|
|
Combined = Left + Right;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Combined = *Text;
|
|
}
|
|
|
|
FText HighlightText = FText::FromString(Mid);
|
|
|
|
return
|
|
SNew(STableRow< TSharedPtr<FString> >, OwnerTable)
|
|
[
|
|
SNew(SBox)
|
|
.WidthOverride(300) // to enforce some minimum width, ideally we define the minimum, not a fixed width
|
|
[
|
|
SNew(STextBlock)
|
|
.Text(FText::FromString(Combined))
|
|
.TextStyle( FEditorStyle::Get(), "Log.Normal")
|
|
.HighlightText(HighlightText)
|
|
]
|
|
];
|
|
}
|
|
|
|
class FConsoleVariableAutoCompleteVisitor
|
|
{
|
|
public:
|
|
// @param Name must not be 0
|
|
// @param CVar must not be 0
|
|
static void OnConsoleVariable(const TCHAR *Name, IConsoleObject* CVar,TArray<FString>& Sink)
|
|
{
|
|
#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
if(CVar->TestFlags(ECVF_Cheat))
|
|
{
|
|
return;
|
|
}
|
|
#endif // (UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
if(CVar->TestFlags(ECVF_Unregistered))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Sink.Add(Name);
|
|
}
|
|
};
|
|
|
|
void SConsoleInputBox::OnTextChanged(const FText& InText)
|
|
{
|
|
if(bIgnoreUIUpdate)
|
|
{
|
|
return;
|
|
}
|
|
|
|
const FString& InputTextStr = InputText->GetText().ToString();
|
|
if(!InputTextStr.IsEmpty())
|
|
{
|
|
TArray<FString> AutoCompleteList;
|
|
|
|
// console variables
|
|
{
|
|
IConsoleManager::Get().ForEachConsoleObjectThatContains(
|
|
FConsoleObjectVisitor::CreateStatic< TArray<FString>& >(
|
|
&FConsoleVariableAutoCompleteVisitor::OnConsoleVariable,
|
|
AutoCompleteList ), *InputTextStr);
|
|
}
|
|
|
|
AutoCompleteList.Sort();
|
|
|
|
for(uint32 i = 0; i < (uint32)AutoCompleteList.Num(); ++i)
|
|
{
|
|
FString &ref = AutoCompleteList[i];
|
|
int32 Start = ref.Find(InputTextStr);
|
|
|
|
if (Start != INDEX_NONE)
|
|
{
|
|
ref = ref.Left(Start) + TEXT("\t") + ref.Mid(Start, InputTextStr.Len()) + TEXT("\t") + ref.RightChop(Start + InputTextStr.Len());
|
|
}
|
|
}
|
|
|
|
SetSuggestions(AutoCompleteList, false);
|
|
}
|
|
else
|
|
{
|
|
ClearSuggestions();
|
|
}
|
|
}
|
|
|
|
void SConsoleInputBox::OnTextCommitted( const FText& InText, ETextCommit::Type CommitInfo)
|
|
{
|
|
if (CommitInfo == ETextCommit::OnEnter)
|
|
{
|
|
if (!InText.IsEmpty())
|
|
{
|
|
IConsoleManager::Get().AddConsoleHistoryEntry( *InText.ToString() );
|
|
|
|
// Copy the exec text string out so we can clear the widget's contents. If the exec command spawns
|
|
// a new window it can cause the text box to lose focus, which will result in this function being
|
|
// re-entered. We want to make sure the text string is empty on re-entry, so we'll clear it out
|
|
const FString ExecString = InText.ToString();
|
|
|
|
// Clear the console input area
|
|
bIgnoreUIUpdate = true;
|
|
InputText->SetText(FText::GetEmpty());
|
|
bIgnoreUIUpdate = false;
|
|
|
|
// Exec!
|
|
if (ConsoleCommandCustomExec.IsBound())
|
|
{
|
|
ConsoleCommandCustomExec.Execute(ExecString);
|
|
}
|
|
else
|
|
{
|
|
bool bWasHandled = false;
|
|
UWorld* World = NULL;
|
|
UWorld* OldWorld = NULL;
|
|
|
|
// The play world needs to handle these commands if it exists
|
|
if( GIsEditor && GEditor->PlayWorld && !GIsPlayInEditorWorld )
|
|
{
|
|
World = GEditor->PlayWorld;
|
|
OldWorld = SetPlayInEditorWorld( GEditor->PlayWorld );
|
|
}
|
|
|
|
ULocalPlayer* Player = GEngine->GetDebugLocalPlayer();
|
|
if( Player )
|
|
{
|
|
UWorld* PlayerWorld = Player->GetWorld();
|
|
if( !World )
|
|
{
|
|
World = PlayerWorld;
|
|
}
|
|
bWasHandled = Player->Exec( PlayerWorld, *ExecString, *GLog );
|
|
}
|
|
|
|
if( !World )
|
|
{
|
|
World = GEditor->GetEditorWorldContext().World();
|
|
}
|
|
if( World )
|
|
{
|
|
if( !bWasHandled )
|
|
{
|
|
AGameModeBase* const GameMode = World->GetAuthGameMode();
|
|
AGameStateBase* const GameState = World->GetGameState();
|
|
if( GameMode && GameMode->ProcessConsoleExec( *ExecString, *GLog, NULL ) )
|
|
{
|
|
bWasHandled = true;
|
|
}
|
|
else if (GameState && GameState->ProcessConsoleExec(*ExecString, *GLog, NULL))
|
|
{
|
|
bWasHandled = true;
|
|
}
|
|
}
|
|
|
|
if( !bWasHandled && !Player)
|
|
{
|
|
if( GIsEditor )
|
|
{
|
|
bWasHandled = GEditor->Exec( World, *ExecString, *GLog );
|
|
}
|
|
else
|
|
{
|
|
bWasHandled = GEngine->Exec( World, *ExecString, *GLog );
|
|
}
|
|
}
|
|
}
|
|
// Restore the old world of there was one
|
|
if( OldWorld )
|
|
{
|
|
RestoreEditorWorld( OldWorld );
|
|
}
|
|
}
|
|
}
|
|
|
|
ClearSuggestions();
|
|
|
|
OnConsoleCommandExecuted.ExecuteIfBound();
|
|
}
|
|
}
|
|
|
|
FReply SConsoleInputBox::OnPreviewKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
|
|
{
|
|
if(SuggestionBox->IsOpen())
|
|
{
|
|
if(KeyEvent.GetKey() == EKeys::Up || KeyEvent.GetKey() == EKeys::Down)
|
|
{
|
|
if(KeyEvent.GetKey() == EKeys::Up)
|
|
{
|
|
if(SelectedSuggestion < 0)
|
|
{
|
|
// from edit control to end of list
|
|
SelectedSuggestion = Suggestions.Num() - 1;
|
|
}
|
|
else
|
|
{
|
|
// got one up, possibly back to edit control
|
|
--SelectedSuggestion;
|
|
}
|
|
}
|
|
|
|
if(KeyEvent.GetKey() == EKeys::Down)
|
|
{
|
|
if(SelectedSuggestion < Suggestions.Num() - 1)
|
|
{
|
|
// go one down, possibly from edit control to top
|
|
++SelectedSuggestion;
|
|
}
|
|
else
|
|
{
|
|
// back to edit control
|
|
SelectedSuggestion = -1;
|
|
}
|
|
}
|
|
|
|
MarkActiveSuggestion();
|
|
|
|
return FReply::Handled();
|
|
}
|
|
else if (KeyEvent.GetKey() == EKeys::Tab)
|
|
{
|
|
if (Suggestions.Num())
|
|
{
|
|
if (SelectedSuggestion >= 0 && SelectedSuggestion < Suggestions.Num())
|
|
{
|
|
MarkActiveSuggestion();
|
|
OnTextCommitted(InputText->GetText(), ETextCommit::OnEnter);
|
|
}
|
|
else
|
|
{
|
|
SelectedSuggestion = 0;
|
|
MarkActiveSuggestion();
|
|
}
|
|
}
|
|
|
|
return FReply::Handled();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(KeyEvent.GetKey() == EKeys::Up)
|
|
{
|
|
TArray<FString> History;
|
|
|
|
IConsoleManager::Get().GetConsoleHistory(History);
|
|
|
|
SetSuggestions(History, true);
|
|
|
|
if(Suggestions.Num())
|
|
{
|
|
SelectedSuggestion = Suggestions.Num() - 1;
|
|
MarkActiveSuggestion();
|
|
}
|
|
|
|
return FReply::Handled();
|
|
}
|
|
}
|
|
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
void SConsoleInputBox::SetSuggestions(TArray<FString>& Elements, bool bInHistoryMode)
|
|
{
|
|
FString SelectionText;
|
|
if (SelectedSuggestion >= 0 && SelectedSuggestion < Suggestions.Num())
|
|
{
|
|
SelectionText = *Suggestions[SelectedSuggestion];
|
|
}
|
|
|
|
SelectedSuggestion = -1;
|
|
Suggestions.Empty();
|
|
SelectedSuggestion = -1;
|
|
|
|
for(uint32 i = 0; i < (uint32)Elements.Num(); ++i)
|
|
{
|
|
Suggestions.Add(MakeShareable(new FString(Elements[i])));
|
|
|
|
if (Elements[i] == SelectionText)
|
|
{
|
|
SelectedSuggestion = i;
|
|
}
|
|
}
|
|
|
|
if(Suggestions.Num())
|
|
{
|
|
// Ideally if the selection box is open the output window is not changing it's window title (flickers)
|
|
SuggestionBox->SetIsOpen(true, false);
|
|
SuggestionListView->RequestScrollIntoView(Suggestions.Last());
|
|
}
|
|
else
|
|
{
|
|
SuggestionBox->SetIsOpen(false);
|
|
}
|
|
}
|
|
|
|
void SConsoleInputBox::OnFocusLost( const FFocusEvent& InFocusEvent )
|
|
{
|
|
// SuggestionBox->SetIsOpen(false);
|
|
}
|
|
|
|
void SConsoleInputBox::MarkActiveSuggestion()
|
|
{
|
|
bIgnoreUIUpdate = true;
|
|
if(SelectedSuggestion >= 0)
|
|
{
|
|
SuggestionListView->SetSelection(Suggestions[SelectedSuggestion]);
|
|
SuggestionListView->RequestScrollIntoView(Suggestions[SelectedSuggestion]); // Ideally this would only scroll if outside of the view
|
|
|
|
InputText->SetText(FText::FromString(GetSelectionText()));
|
|
}
|
|
else
|
|
{
|
|
SuggestionListView->ClearSelection();
|
|
}
|
|
bIgnoreUIUpdate = false;
|
|
}
|
|
|
|
void SConsoleInputBox::ClearSuggestions()
|
|
{
|
|
SelectedSuggestion = -1;
|
|
SuggestionBox->SetIsOpen(false);
|
|
Suggestions.Empty();
|
|
}
|
|
|
|
FString SConsoleInputBox::GetSelectionText() const
|
|
{
|
|
FString ret = *Suggestions[SelectedSuggestion];
|
|
|
|
ret = ret.Replace(TEXT("\t"), TEXT(""));
|
|
|
|
return ret;
|
|
}
|
|
|
|
TSharedRef< FOutputLogTextLayoutMarshaller > FOutputLogTextLayoutMarshaller::Create(TArray< TSharedPtr<FLogMessage> > InMessages, FLogFilter* InFilter)
|
|
{
|
|
return MakeShareable(new FOutputLogTextLayoutMarshaller(MoveTemp(InMessages), InFilter));
|
|
}
|
|
|
|
FOutputLogTextLayoutMarshaller::~FOutputLogTextLayoutMarshaller()
|
|
{
|
|
}
|
|
|
|
void FOutputLogTextLayoutMarshaller::SetText(const FString& SourceString, FTextLayout& TargetTextLayout)
|
|
{
|
|
TextLayout = &TargetTextLayout;
|
|
AppendMessagesToTextLayout(Messages);
|
|
}
|
|
|
|
void FOutputLogTextLayoutMarshaller::GetText(FString& TargetString, const FTextLayout& SourceTextLayout)
|
|
{
|
|
SourceTextLayout.GetAsText(TargetString);
|
|
}
|
|
|
|
bool FOutputLogTextLayoutMarshaller::AppendMessage(const TCHAR* InText, const ELogVerbosity::Type InVerbosity, const FName& InCategory)
|
|
{
|
|
TArray< TSharedPtr<FLogMessage> > NewMessages;
|
|
if(SOutputLog::CreateLogMessages(InText, InVerbosity, InCategory, NewMessages))
|
|
{
|
|
const bool bWasEmpty = Messages.Num() == 0;
|
|
Messages.Append(NewMessages);
|
|
|
|
if(TextLayout)
|
|
{
|
|
// If we were previously empty, then we'd have inserted a dummy empty line into the document
|
|
// We need to remove this line now as it would cause the message indices to get out-of-sync with the line numbers, which would break auto-scrolling
|
|
if(bWasEmpty)
|
|
{
|
|
TextLayout->ClearLines();
|
|
}
|
|
|
|
// If we've already been given a text layout, then append these new messages rather than force a refresh of the entire document
|
|
AppendMessagesToTextLayout(NewMessages);
|
|
}
|
|
else
|
|
{
|
|
MarkMessagesCacheAsDirty();
|
|
MakeDirty();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void FOutputLogTextLayoutMarshaller::AppendMessageToTextLayout(const TSharedPtr<FLogMessage>& InMessage)
|
|
{
|
|
if (!Filter->IsMessageAllowed(InMessage))
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Increment the cached count if we're not rebuilding the log
|
|
if ( !IsDirty() )
|
|
{
|
|
CachedNumMessages++;
|
|
}
|
|
|
|
const FTextBlockStyle& MessageTextStyle = FEditorStyle::Get().GetWidgetStyle<FTextBlockStyle>(InMessage->Style);
|
|
|
|
TSharedRef<FString> LineText = InMessage->Message;
|
|
|
|
TArray<TSharedRef<IRun>> Runs;
|
|
Runs.Add(FSlateTextRun::Create(FRunInfo(), LineText, MessageTextStyle));
|
|
|
|
TextLayout->AddLine(FSlateTextLayout::FNewLineData(MoveTemp(LineText), MoveTemp(Runs)));
|
|
}
|
|
|
|
void FOutputLogTextLayoutMarshaller::AppendMessagesToTextLayout(const TArray<TSharedPtr<FLogMessage>>& InMessages)
|
|
{
|
|
TArray<FTextLayout::FNewLineData> LinesToAdd;
|
|
LinesToAdd.Reserve(InMessages.Num());
|
|
|
|
int32 NumAddedMessages = 0;
|
|
|
|
for (const auto& CurrentMessage : InMessages)
|
|
{
|
|
if (!Filter->IsMessageAllowed(CurrentMessage))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
++NumAddedMessages;
|
|
|
|
const FTextBlockStyle& MessageTextStyle = FEditorStyle::Get().GetWidgetStyle<FTextBlockStyle>(CurrentMessage->Style);
|
|
|
|
TSharedRef<FString> LineText = CurrentMessage->Message;
|
|
|
|
TArray<TSharedRef<IRun>> Runs;
|
|
Runs.Add(FSlateTextRun::Create(FRunInfo(), LineText, MessageTextStyle));
|
|
|
|
LinesToAdd.Emplace(MoveTemp(LineText), MoveTemp(Runs));
|
|
}
|
|
|
|
// Increment the cached message count if the log is not being rebuilt
|
|
if ( !IsDirty() )
|
|
{
|
|
CachedNumMessages += NumAddedMessages;
|
|
}
|
|
|
|
TextLayout->AddLines(LinesToAdd);
|
|
}
|
|
|
|
void FOutputLogTextLayoutMarshaller::ClearMessages()
|
|
{
|
|
Messages.Empty();
|
|
MakeDirty();
|
|
}
|
|
|
|
void FOutputLogTextLayoutMarshaller::CountMessages()
|
|
{
|
|
// Do not re-count if not dirty
|
|
if (!bNumMessagesCacheDirty)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CachedNumMessages = 0;
|
|
|
|
for (const auto& CurrentMessage : Messages)
|
|
{
|
|
if (Filter->IsMessageAllowed(CurrentMessage))
|
|
{
|
|
CachedNumMessages++;
|
|
}
|
|
}
|
|
|
|
// Cache re-built, remove dirty flag
|
|
bNumMessagesCacheDirty = false;
|
|
}
|
|
|
|
int32 FOutputLogTextLayoutMarshaller::GetNumMessages() const
|
|
{
|
|
return Messages.Num();
|
|
}
|
|
|
|
int32 FOutputLogTextLayoutMarshaller::GetNumFilteredMessages()
|
|
{
|
|
// No need to filter the messages if the filter is not set
|
|
if (!Filter->IsFilterSet())
|
|
{
|
|
return GetNumMessages();
|
|
}
|
|
|
|
// Re-count messages if filter changed before we refresh
|
|
if (bNumMessagesCacheDirty)
|
|
{
|
|
CountMessages();
|
|
}
|
|
|
|
return CachedNumMessages;
|
|
}
|
|
|
|
void FOutputLogTextLayoutMarshaller::MarkMessagesCacheAsDirty()
|
|
{
|
|
bNumMessagesCacheDirty = true;
|
|
}
|
|
|
|
FOutputLogTextLayoutMarshaller::FOutputLogTextLayoutMarshaller(TArray< TSharedPtr<FLogMessage> > InMessages, FLogFilter* InFilter)
|
|
: Messages(MoveTemp(InMessages))
|
|
, CachedNumMessages(0)
|
|
, Filter(InFilter)
|
|
, TextLayout(nullptr)
|
|
{
|
|
}
|
|
|
|
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
void SOutputLog::Construct( const FArguments& InArgs )
|
|
{
|
|
MessagesTextMarshaller = FOutputLogTextLayoutMarshaller::Create(MoveTemp(InArgs._Messages), &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, &SOutputLog::OnUserScrolled)
|
|
.ContextMenuExtender(this, &SOutputLog::ExtendTextBoxMenu);
|
|
|
|
ChildSlot
|
|
[
|
|
SNew(SVerticalBox)
|
|
|
|
// Console output and filters
|
|
+SVerticalBox::Slot()
|
|
[
|
|
SNew(SBorder)
|
|
.Padding(3)
|
|
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
|
|
[
|
|
SNew(SVerticalBox)
|
|
|
|
// Output Log Filter
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
.Padding(FMargin(0.0f, 0.0f, 0.0f, 4.0f))
|
|
[
|
|
SNew(SHorizontalBox)
|
|
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SNew(SComboButton)
|
|
.ComboButtonStyle(FEditorStyle::Get(), "OutputLog.Filters.Style")
|
|
.ForegroundColor(FLinearColor::White)
|
|
.ContentPadding(0)
|
|
.ToolTipText(LOCTEXT("AddFilterToolTip", "Add an output log filter."))
|
|
.OnGetMenuContent(this, &SOutputLog::MakeAddFilterMenu)
|
|
.HasDownArrow(true)
|
|
.ContentPadding(FMargin(1, 0))
|
|
.ButtonContent()
|
|
[
|
|
SNew(SHorizontalBox)
|
|
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SNew(STextBlock)
|
|
.TextStyle(FEditorStyle::Get(), "OutputLog.Filters.Text")
|
|
.Font(FEditorStyle::Get().GetFontStyle("FontAwesome.9"))
|
|
.Text(FText::FromString(FString(TEXT("\xf0b0"))) /*fa-filter*/)
|
|
]
|
|
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
.Padding(2, 0, 0, 0)
|
|
[
|
|
SNew(STextBlock)
|
|
.TextStyle(FEditorStyle::Get(), "OutputLog.Filters.Text")
|
|
.Text(LOCTEXT("Filters", "Filters"))
|
|
]
|
|
]
|
|
]
|
|
|
|
+SHorizontalBox::Slot()
|
|
.Padding(4, 1, 0, 0)
|
|
[
|
|
SAssignNew(FilterTextBox, SSearchBox)
|
|
.HintText(LOCTEXT("SearchLogHint", "Search Log"))
|
|
.OnTextChanged(this, &SOutputLog::OnFilterTextChanged)
|
|
.OnTextCommitted(this, &SOutputLog::OnFilterTextCommitted)
|
|
.DelayChangeNotificationsWhileTyping(true)
|
|
]
|
|
]
|
|
|
|
// 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(SConsoleInputBox)
|
|
.OnConsoleCommandExecuted(this, &SOutputLog::OnConsoleCommandExecuted)
|
|
|
|
// Always place suggestions above the input line for the output log widget
|
|
.SuggestionListPlacement(MenuPlacement_AboveAnchor)
|
|
]
|
|
];
|
|
|
|
GLog->AddOutputDevice(this);
|
|
|
|
bIsUserScrolled = false;
|
|
RequestForceScroll();
|
|
}
|
|
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
|
|
SOutputLog::~SOutputLog()
|
|
{
|
|
if (GLog != NULL)
|
|
{
|
|
GLog->RemoveOutputDevice(this);
|
|
}
|
|
}
|
|
|
|
bool SOutputLog::CreateLogMessages( const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category, TArray< TSharedPtr<FLogMessage> >& OutMessages )
|
|
{
|
|
if (Verbosity == ELogVerbosity::SetColor)
|
|
{
|
|
// Skip Color Events
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
FName Style;
|
|
if (Category == NAME_Cmd)
|
|
{
|
|
Style = FName(TEXT("Log.Command"));
|
|
}
|
|
else if (Verbosity == ELogVerbosity::Error)
|
|
{
|
|
Style = FName(TEXT("Log.Error"));
|
|
}
|
|
else if (Verbosity == ELogVerbosity::Warning)
|
|
{
|
|
Style = FName(TEXT("Log.Warning"));
|
|
}
|
|
else
|
|
{
|
|
Style = FName(TEXT("Log.Normal"));
|
|
}
|
|
|
|
// Determine how to format timestamps
|
|
static ELogTimes::Type LogTimestampMode = ELogTimes::None;
|
|
if (UObjectInitialized() && !GExitPurge)
|
|
{
|
|
// Logging can happen very late during shutdown, even after the UObject system has been torn down, hence the init check above
|
|
LogTimestampMode = GetDefault<UEditorStyleSettings>()->LogTimestampMode;
|
|
}
|
|
|
|
const int32 OldNumMessages = OutMessages.Num();
|
|
|
|
// handle multiline strings by breaking them apart by line
|
|
TArray<FTextRange> LineRanges;
|
|
FString CurrentLogDump = V;
|
|
FTextRange::CalculateLineRangesFromString(CurrentLogDump, LineRanges);
|
|
|
|
bool bIsFirstLineInMessage = true;
|
|
for (const FTextRange& LineRange : LineRanges)
|
|
{
|
|
if (!LineRange.IsEmpty())
|
|
{
|
|
FString Line = CurrentLogDump.Mid(LineRange.BeginIndex, LineRange.Len());
|
|
Line = Line.ConvertTabsToSpaces(4);
|
|
|
|
// Hard-wrap lines to avoid them being too long
|
|
static const int32 HardWrapLen = 360;
|
|
for (int32 CurrentStartIndex = 0; CurrentStartIndex < Line.Len();)
|
|
{
|
|
int32 HardWrapLineLen = 0;
|
|
if (bIsFirstLineInMessage)
|
|
{
|
|
FString MessagePrefix = FOutputDeviceHelper::FormatLogLine(Verbosity, Category, nullptr, LogTimestampMode);
|
|
|
|
HardWrapLineLen = FMath::Min(HardWrapLen - MessagePrefix.Len(), Line.Len() - CurrentStartIndex);
|
|
FString HardWrapLine = Line.Mid(CurrentStartIndex, HardWrapLineLen);
|
|
|
|
OutMessages.Add(MakeShareable(new FLogMessage(MakeShareable(new FString(MessagePrefix + HardWrapLine)), Verbosity, Style)));
|
|
}
|
|
else
|
|
{
|
|
HardWrapLineLen = FMath::Min(HardWrapLen, Line.Len() - CurrentStartIndex);
|
|
FString HardWrapLine = Line.Mid(CurrentStartIndex, HardWrapLineLen);
|
|
|
|
OutMessages.Add(MakeShareable(new FLogMessage(MakeShareable(new FString(MoveTemp(HardWrapLine))), Verbosity, Style)));
|
|
}
|
|
|
|
bIsFirstLineInMessage = false;
|
|
CurrentStartIndex += HardWrapLineLen;
|
|
}
|
|
}
|
|
}
|
|
|
|
return OldNumMessages != OutMessages.Num();
|
|
}
|
|
}
|
|
|
|
void SOutputLog::Serialize(const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category)
|
|
{
|
|
if ( MessagesTextMarshaller->AppendMessage(V, Verbosity, 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 )
|
|
{
|
|
RequestForceScroll();
|
|
}
|
|
}
|
|
}
|
|
|
|
void SOutputLog::ExtendTextBoxMenu(FMenuBuilder& Builder)
|
|
{
|
|
FUIAction ClearOutputLogAction(
|
|
FExecuteAction::CreateRaw( this, &SOutputLog::OnClearLog ),
|
|
FCanExecuteAction::CreateSP( this, &SOutputLog::CanClearLog )
|
|
);
|
|
|
|
Builder.AddMenuEntry(
|
|
NSLOCTEXT("OutputLog", "ClearLogLabel", "Clear Log"),
|
|
NSLOCTEXT("OutputLog", "ClearLogTooltip", "Clears all log messages"),
|
|
FSlateIcon(),
|
|
ClearOutputLogAction
|
|
);
|
|
}
|
|
|
|
void SOutputLog::OnClearLog()
|
|
{
|
|
// Make sure the cursor is back at the start of the log before we clear it
|
|
MessagesTextBox->GoTo(FTextLocation(0));
|
|
|
|
MessagesTextMarshaller->ClearMessages();
|
|
MessagesTextBox->Refresh();
|
|
bIsUserScrolled = false;
|
|
}
|
|
|
|
void SOutputLog::OnUserScrolled(float ScrollOffset)
|
|
{
|
|
bIsUserScrolled = ScrollOffset < 1.0 && !FMath::IsNearlyEqual(ScrollOffset, 1.0f);
|
|
}
|
|
|
|
bool SOutputLog::CanClearLog() const
|
|
{
|
|
return MessagesTextMarshaller->GetNumMessages() > 0;
|
|
}
|
|
|
|
void SOutputLog::OnConsoleCommandExecuted()
|
|
{
|
|
RequestForceScroll();
|
|
}
|
|
|
|
void SOutputLog::RequestForceScroll()
|
|
{
|
|
if (MessagesTextMarshaller->GetNumFilteredMessages() > 0)
|
|
{
|
|
MessagesTextBox->ScrollTo(FTextLocation(MessagesTextMarshaller->GetNumFilteredMessages() - 1));
|
|
bIsUserScrolled = false;
|
|
}
|
|
}
|
|
|
|
void SOutputLog::Refresh()
|
|
{
|
|
// Re-count messages if filter changed before we refresh
|
|
MessagesTextMarshaller->CountMessages();
|
|
|
|
MessagesTextBox->GoTo(FTextLocation(0));
|
|
MessagesTextMarshaller->MakeDirty();
|
|
MessagesTextBox->Refresh();
|
|
RequestForceScroll();
|
|
}
|
|
|
|
void SOutputLog::OnFilterTextChanged(const FText& InFilterText)
|
|
{
|
|
if (Filter.GetFilterText().ToString().Equals(InFilterText.ToString(), ESearchCase::CaseSensitive))
|
|
{
|
|
// nothing to do
|
|
return;
|
|
}
|
|
|
|
// Flag the messages count as dirty
|
|
MessagesTextMarshaller->MarkMessagesCacheAsDirty();
|
|
|
|
// Set filter phrases
|
|
Filter.SetFilterText(InFilterText);
|
|
|
|
// Report possible syntax errors back to the user
|
|
FilterTextBox->SetError(Filter.GetSyntaxErrors());
|
|
|
|
// Repopulate the list to show only what has not been filtered out.
|
|
Refresh();
|
|
}
|
|
|
|
void SOutputLog::OnFilterTextCommitted(const FText& InFilterText, ETextCommit::Type InCommitType)
|
|
{
|
|
OnFilterTextChanged(InFilterText);
|
|
}
|
|
|
|
TSharedRef<SWidget> SOutputLog::MakeAddFilterMenu()
|
|
{
|
|
FMenuBuilder MenuBuilder(/*bInShouldCloseWindowAfterMenuSelection=*/true, nullptr);
|
|
FillVerbosityEntries(MenuBuilder);
|
|
return MenuBuilder.MakeWidget();
|
|
}
|
|
|
|
void SOutputLog::FillVerbosityEntries(FMenuBuilder& MenuBuilder)
|
|
{
|
|
MenuBuilder.BeginSection("OutputLogVerbosityEntries");
|
|
{
|
|
MenuBuilder.AddMenuEntry(
|
|
LOCTEXT("ShowMessages", "Messages"),
|
|
LOCTEXT("ShowMessages_Tooltip", "Filter the Output Log to show messages"),
|
|
FSlateIcon(),
|
|
FUIAction(FExecuteAction::CreateSP(this, &SOutputLog::MenuLogs_Execute),
|
|
FCanExecuteAction::CreateSP(this, &SOutputLog::Menu_CanExecute),
|
|
FIsActionChecked::CreateSP(this, &SOutputLog::MenuLogs_IsChecked)),
|
|
NAME_None,
|
|
EUserInterfaceActionType::ToggleButton
|
|
);
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
LOCTEXT("ShowWarnings", "Warnings"),
|
|
LOCTEXT("ShowWarnings_Tooltip", "Filter the Output Log to show warnings"),
|
|
FSlateIcon(),
|
|
FUIAction(FExecuteAction::CreateSP(this, &SOutputLog::MenuWarnings_Execute),
|
|
FCanExecuteAction::CreateSP(this, &SOutputLog::Menu_CanExecute),
|
|
FIsActionChecked::CreateSP(this, &SOutputLog::MenuWarnings_IsChecked)),
|
|
NAME_None,
|
|
EUserInterfaceActionType::ToggleButton
|
|
);
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
LOCTEXT("ShowErrors", "Errors"),
|
|
LOCTEXT("ShowErrors_Tooltip", "Filter the Output Log to show errors"),
|
|
FSlateIcon(),
|
|
FUIAction(FExecuteAction::CreateSP(this, &SOutputLog::MenuErrors_Execute),
|
|
FCanExecuteAction::CreateSP(this, &SOutputLog::Menu_CanExecute),
|
|
FIsActionChecked::CreateSP(this, &SOutputLog::MenuErrors_IsChecked)),
|
|
NAME_None,
|
|
EUserInterfaceActionType::ToggleButton
|
|
);
|
|
}
|
|
MenuBuilder.EndSection();
|
|
}
|
|
|
|
bool SOutputLog::Menu_CanExecute() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool SOutputLog::MenuLogs_IsChecked() const
|
|
{
|
|
return Filter.bShowLogs;
|
|
}
|
|
|
|
bool SOutputLog::MenuWarnings_IsChecked() const
|
|
{
|
|
return Filter.bShowWarnings;
|
|
}
|
|
|
|
bool SOutputLog::MenuErrors_IsChecked() const
|
|
{
|
|
return Filter.bShowErrors;
|
|
}
|
|
|
|
void SOutputLog::MenuLogs_Execute()
|
|
{
|
|
Filter.bShowLogs = !Filter.bShowLogs;
|
|
|
|
// Flag the messages count as dirty
|
|
MessagesTextMarshaller->MarkMessagesCacheAsDirty();
|
|
|
|
Refresh();
|
|
}
|
|
|
|
void SOutputLog::MenuWarnings_Execute()
|
|
{
|
|
Filter.bShowWarnings = !Filter.bShowWarnings;
|
|
|
|
// Flag the messages count as dirty
|
|
MessagesTextMarshaller->MarkMessagesCacheAsDirty();
|
|
|
|
Refresh();
|
|
}
|
|
|
|
void SOutputLog::MenuErrors_Execute()
|
|
{
|
|
Filter.bShowErrors = !Filter.bShowErrors;
|
|
|
|
// Flag the messages count as dirty
|
|
MessagesTextMarshaller->MarkMessagesCacheAsDirty();
|
|
|
|
Refresh();
|
|
}
|
|
|
|
bool FLogFilter::IsMessageAllowed(const TSharedPtr<FLogMessage>& Message)
|
|
{
|
|
// Filter Verbosity
|
|
{
|
|
if (Message->Verbosity == ELogVerbosity::Error && !bShowErrors)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (Message->Verbosity == ELogVerbosity::Warning && !bShowWarnings)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (Message->Verbosity != ELogVerbosity::Error && Message->Verbosity != ELogVerbosity::Warning && !bShowLogs)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Filter search phrase
|
|
{
|
|
if (!TextFilterExpressionEvaluator.TestTextFilter(FLogFilter_TextFilterExpressionContext(*Message)))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|