// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "AssetRegistry/AssetData.h" #include "Types/SlateEnums.h" #include "Widgets/SCompoundWidget.h" #include "Widgets/Views/SListView.h" class IDetailsView; class ITableRow; class SSearchBox; class STableViewBase; class STextBlock; class UItemDataAsset; struct FPropertyChangedEvent; /** One row shown in the item list of the editor window. */ struct FItemListEntry { /** Registry data of the data asset (never loads the asset on its own). */ FAssetData AssetData; /** Human readable item name (FText source), used as the row label and for sorting. */ FString ItemName; /** Underlying value of the ItemCategory enum (e.g. Category::Plant), INDEX_NONE if unknown. */ int32 CategoryValue = INDEX_NONE; /** Lower-cased text used for filtering (name + category + asset + package path). */ FString SearchText; }; /** * Editor tool window that lets the user type an item name, pick the matching * ItemDataAsset and edit its properties directly on the asset. */ class SItemEditorWindow : public SCompoundWidget { public: SLATE_BEGIN_ARGS(SItemEditorWindow) {} SLATE_END_ARGS() void Construct(const FArguments& InArgs); virtual ~SItemEditorWindow(); /** Re-queries the Asset Registry for every UItemDataAsset in the project. */ void RefreshAssetList(); private: using FItemEntry = TSharedPtr; // Slate callbacks TSharedRef OnGenerateRow(FItemEntry InItem, const TSharedRef& InOwnerTable); void OnSearchTextChanged(const FText& InText); void OnSearchTextCommitted(const FText& InText, ETextCommit::Type InCommitType); void OnItemSelectionChanged(FItemEntry InItem, ESelectInfo::Type InSelectInfo); void OnItemDoubleClicked(FItemEntry InItem); void OnAssetPropertyChanged(const FPropertyChangedEvent& InEvent); // Toolbar / button handlers FReply OnRefreshClicked(); FReply OnSaveClicked(); FReply OnOpenAssetEditorClicked(); FReply OnFindInContentBrowserClicked(); void OnAutoSaveCheckChanged(ECheckBoxState InState); // Category filter void InitCategoryFilter(); TSharedRef MakeCategoryFilterWidget(); TSharedRef MakeCategoryCheckBox(int32 InCategoryValue, const FText& InLabel); ECheckBoxState IsCategoryChecked(int32 InCategoryValue) const; void OnCategoryToggled(int32 InCategoryValue, ECheckBoxState InState); // Helpers void ApplyFilter(); void SelectFirstVisibleItem(); FItemEntry FindEntryForAsset(const UItemDataAsset* InAsset); UItemDataAsset* LoadAssetForEntry(FItemEntry InItem); UItemDataAsset* GetCurrentAsset() const; void UpdateEntryFromLoadedAsset(FItemEntry InEntry, const UItemDataAsset* InAsset); void SaveCurrentAsset(); void SetStatusMessage(const FString& InMessage, bool bIsError = false); void OpenInAssetEditor(UItemDataAsset* InAsset); void ShowInContentBrowser(UItemDataAsset* InAsset); FText GetSelectionStatusText() const; static FString GetEntryDisplayName(const FItemListEntry& InEntry); static FString BuildEntrySearchText(const FItemListEntry& InEntry); static FString GetTaggedItemName(const FAssetData& InAsset); /** All data assets of type UItemDataAsset found in the project (registry only). */ TArray> ItemEntries; /** Subset of ItemEntries currently visible after applying the search filter. */ TArray FilteredItems; /** Ordered category values offered as filter chips (underlying Category enum values). */ TArray CategoryFilterValues; /** ItemCategory values that should be shown in the list; empty means show every category. */ TSet SelectedCategoryValues; /** The data asset currently being edited. */ TWeakObjectPtr CurrentAsset; TSharedPtr SearchBox; TSharedPtr> ListView; TSharedPtr DetailsView; TSharedPtr StatusText; FText SearchFilterText; bool bAutoSaveOnChange = false; };