// Copyright Epic Games, Inc. All Rights Reserved. #include "Widgets/GameSettingListView.h" #include "Widgets/GameSettingListEntry.h" #include "Widgets/GameSettingVisualData.h" #include "Engine/Engine.h" #include "GameSetting.h" #include "GameSettingRegistry.h" #include "GameSettingCollection.h" #if WITH_EDITOR #include "Editor/WidgetCompilerLog.h" #endif #define LOCTEXT_NAMESPACE "GameSetting" UGameSettingListView::UGameSettingListView(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { } #if WITH_EDITOR void UGameSettingListView::ValidateCompiledDefaults(IWidgetCompilerLog& InCompileLog) const { Super::ValidateCompiledDefaults(InCompileLog); if (!VisualData) { InCompileLog.Error(FText::Format(FText::FromString("{0} has no VisualData defined."), FText::FromString(GetName()))); } } #endif UUserWidget& UGameSettingListView::OnGenerateEntryWidgetInternal(UObject* Item, TSubclassOf DesiredEntryClass, const TSharedRef& OwnerTable) { UGameSetting* SettingItem = Cast(Item); TSubclassOf SettingEntryClass = TSubclassOf(DesiredEntryClass); if (VisualData) { if (const TSubclassOf EntryClassSetting = VisualData->GetEntryForSetting(SettingItem)) { SettingEntryClass = EntryClassSetting; } else { //UE_LOG(LogGameSettings, Error, TEXT("UGameSettingListView: No Entry Class Found!")); } } else { //UE_LOG(LogGameSettings, Error, TEXT("UGameSettingListView: No VisualData Defined!")); } UGameSettingListEntryBase& EntryWidget = GenerateTypedEntry(SettingEntryClass, OwnerTable); if (!IsDesignTime()) { if (const FText* Override = NameOverrides.Find(SettingItem->GetDevName())) { EntryWidget.SetDisplayNameOverride(*Override); } EntryWidget.SetSetting(SettingItem); } return EntryWidget; } bool UGameSettingListView::OnIsSelectableOrNavigableInternal(UObject* SelectedItem) { if (const UGameSettingCollection* CollectionItem = Cast(SelectedItem)) { return CollectionItem->IsSelectable(); } return true; } void UGameSettingListView::AddNameOverride(const FName& DevName, const FText& OverrideName) { NameOverrides.Add(DevName, OverrideName); } #undef LOCTEXT_NAMESPACE