You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#proj UE4.Engine #summary Added Find Results tab to Material Editor #add Added SFindInMaterial class to search and display results from materials, similar to the Blueprint version but didn't seem like there was an obvious method of splitting it up into a base class that could be used by both. Made sure to use the search functions from Material Expressions as well to ensure that the results will be the same or better than they were previously. #change Added new function to UMaterialExpression to get a one line description of it. Most of the time this is just all of the expressions captions combined into one line using spaces, though there were exceptions for constants, textures and function calls so that better information is shown in the results window. Also added a JumpToNode function to FMaterialEditor so that the find results can show the nodes when clicked on. #extra This is only for searching the current material at present, adding support for searching all assets would be a lot more work as we would need to store meta data allowing materials to be searched before they are loaded. [CL 2043640 by Matthew Griffin in Main branch]
123 lines
3.9 KiB
C++
123 lines
3.9 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
/** Item that matched the search results */
|
|
class FFindInMaterialResult
|
|
{
|
|
public:
|
|
/** Create a root (or only text) result */
|
|
FFindInMaterialResult(const FString& InValue);
|
|
|
|
/** Create a listing for a search result*/
|
|
FFindInMaterialResult(const FString& InValue, TSharedPtr<FFindInMaterialResult>& InParent, UClass* InClass, int InDuplicationIndex);
|
|
|
|
/** Create a listing for a pin result */
|
|
FFindInMaterialResult(const FString& InValue, TSharedPtr<FFindInMaterialResult>& InParent, UEdGraphPin* InPin);
|
|
|
|
/** Create a listing for a node result */
|
|
FFindInMaterialResult(const FString& InValue, TSharedPtr<FFindInMaterialResult>& InParent, UEdGraphNode* InNode);
|
|
|
|
/** Called when user clicks on the search item */
|
|
FReply OnClick(TWeakPtr<class FMaterialEditor> MaterialEditor);
|
|
|
|
/* Get Category for this search result */
|
|
FString GetCategory() const;
|
|
|
|
/** Create an icon to represent the result */
|
|
TSharedRef<SWidget> CreateIcon() const;
|
|
|
|
/** Gets the comment on this node if any */
|
|
FString GetCommentText() const;
|
|
|
|
/** Gets the value of the pin if any */
|
|
FString GetValueText() const;
|
|
|
|
/** Any children listed under this category */
|
|
TArray< TSharedPtr<FFindInMaterialResult> > Children;
|
|
|
|
/** Search result Parent */
|
|
TWeakPtr<FFindInMaterialResult> Parent;
|
|
|
|
/*The meta string that was stored in the asset registry for this item */
|
|
FString Value;
|
|
|
|
/*The graph may have multiple instances of whatever we are looking for, this tells us which instance # we refer to*/
|
|
int DuplicationIndex;
|
|
|
|
/*The class this item refers to */
|
|
UClass* Class;
|
|
|
|
/** The pin that this search result refers to */
|
|
TWeakObjectPtr<UEdGraphPin> Pin;
|
|
|
|
/** The graph node that this search result refers to (if not by asset registry or UK2Node) */
|
|
TWeakObjectPtr<UEdGraphNode> GraphNode;
|
|
|
|
/** Display text for comment information */
|
|
FString CommentText;
|
|
};
|
|
|
|
|
|
/** Widget for searching for items that are part of a UEdGraph */
|
|
class SFindInMaterial : public SCompoundWidget
|
|
{
|
|
public:
|
|
SLATE_BEGIN_ARGS(SFindInMaterial){}
|
|
SLATE_END_ARGS()
|
|
|
|
void Construct(const FArguments& InArgs, TSharedPtr<class FMaterialEditor> InMaterialEditor);
|
|
|
|
/** Focuses this widget's search box */
|
|
void FocusForUse();
|
|
|
|
protected:
|
|
typedef TSharedPtr<FFindInMaterialResult> FSearchResult;
|
|
typedef STreeView<FSearchResult> STreeViewType;
|
|
|
|
/** Called when user changes the text they are searching for */
|
|
void OnSearchTextChanged(const FText& Text);
|
|
|
|
/** Called when user changes commits text to the search box */
|
|
void OnSearchTextCommitted(const FText& Text, ETextCommit::Type CommitType);
|
|
|
|
/** Get the children of a row */
|
|
void OnGetChildren(FSearchResult InItem, TArray<FSearchResult>& OutChildren);
|
|
|
|
/** Called when user clicks on a new result */
|
|
void OnTreeSelectionChanged(FSearchResult Item, ESelectInfo::Type SelectInfo);
|
|
|
|
/** Called when a new row is being generated */
|
|
TSharedRef<ITableRow> OnGenerateRow(FSearchResult InItem, const TSharedRef<STableViewBase>& OwnerTable);
|
|
|
|
/** Begins the search based on the SearchValue */
|
|
void InitiateSearch();
|
|
|
|
/** Find any results that contain all of the tokens */
|
|
void MatchTokens(const TArray<FString>& Tokens);
|
|
|
|
/** Determines if a string matches the search tokens */
|
|
static bool StringMatchesSearchTokens(const TArray<FString>& Tokens, const FString& ComparisonString);
|
|
|
|
protected:
|
|
/** Pointer back to the Material editor that owns us */
|
|
TWeakPtr<class FMaterialEditor> MaterialEditorPtr;
|
|
|
|
/** The tree view displays the results */
|
|
TSharedPtr<STreeViewType> TreeView;
|
|
|
|
/** The search text box */
|
|
TSharedPtr<class SSearchBox> SearchTextField;
|
|
|
|
/** This buffer stores the currently displayed results */
|
|
TArray<FSearchResult> ItemsFound;
|
|
|
|
/** we need to keep a handle on the root result, because it won't show up in the tree */
|
|
FSearchResult RootSearchResult;
|
|
|
|
/** The string to highlight in the results */
|
|
FText HighlightText;
|
|
|
|
/** The string to search for */
|
|
FString SearchValue;
|
|
}; |