Download LyraStarterGame/Plugins/GameSettings/Source/Private/GameSettingCollection.cpp from Alexhas2/unitysamples: direct link, hf CLI and curl.
- Browser
- Download file 3.56 kB
-
https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Plugins/GameSettings/Source/Private/GameSettingCollection.cpp
- Command line
-
hf download hf://datasets/Alexhas2/unitysamples/LyraStarterGame/Plugins/GameSettings/Source/Private/GameSettingCollection.cpp
-
curl -L -o GameSettingCollection.cpp https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Plugins/GameSettings/Source/Private/GameSettingCollection.cpp
3.56 kB
| // Copyright Epic Games, Inc. All Rights Reserved. | |
| //-------------------------------------- | |
| // UGameSettingCollection | |
| //-------------------------------------- | |
| UGameSettingCollection::UGameSettingCollection() | |
| { | |
| } | |
| void UGameSettingCollection::AddSetting(UGameSetting* Setting) | |
| { | |
| ensureAlwaysMsgf(Setting->GetSettingParent() == nullptr, TEXT("This setting already has a parent!")); | |
| ensureAlwaysMsgf(!Settings.Contains(Setting), TEXT("This collection already includes this setting!")); | |
| Settings.Add(Setting); | |
| Setting->SetSettingParent(this); | |
| if (LocalPlayer) | |
| { | |
| Setting->Initialize(LocalPlayer); | |
| } | |
| } | |
| TArray<UGameSettingCollection*> UGameSettingCollection::GetChildCollections() const | |
| { | |
| TArray<UGameSettingCollection*> CollectionSettings; | |
| for (UGameSetting* ChildSetting : Settings) | |
| { | |
| if (UGameSettingCollection* ChildCollection = Cast<UGameSettingCollection>(ChildSetting)) | |
| { | |
| CollectionSettings.Add(ChildCollection); | |
| } | |
| } | |
| return CollectionSettings; | |
| } | |
| void UGameSettingCollection::GetSettingsForFilter(const FGameSettingFilterState& FilterState, TArray<UGameSetting*>& InOutSettings) const | |
| { | |
| for (UGameSetting* ChildSetting : Settings) | |
| { | |
| // If the child setting is a collection, only add it to the set if it has any visible children. | |
| if (Cast<UGameSettingCollectionPage>(ChildSetting)) | |
| { | |
| if (FilterState.DoesSettingPassFilter(*ChildSetting)) | |
| { | |
| InOutSettings.Add(ChildSetting); | |
| } | |
| } | |
| else if (UGameSettingCollection* ChildCollection = Cast<UGameSettingCollection>(ChildSetting)) | |
| { | |
| TArray<UGameSetting*> ChildSettings; | |
| ChildCollection->GetSettingsForFilter(FilterState, ChildSettings); | |
| if (ChildSettings.Num() > 0) | |
| { | |
| // Don't add the root setting to the returned items, it's the container of N-possible | |
| // other settings and containers we're actually displaying right now. | |
| if (!FilterState.IsSettingInRootList(ChildSetting)) | |
| { | |
| InOutSettings.Add(ChildSetting); | |
| } | |
| InOutSettings.Append(ChildSettings); | |
| } | |
| } | |
| else | |
| { | |
| if (FilterState.DoesSettingPassFilter(*ChildSetting)) | |
| { | |
| InOutSettings.Add(ChildSetting); | |
| } | |
| } | |
| } | |
| } | |
| //-------------------------------------- | |
| // UGameSettingCollectionPage | |
| //-------------------------------------- | |
| UGameSettingCollectionPage::UGameSettingCollectionPage() | |
| { | |
| } | |
| void UGameSettingCollectionPage::OnInitialized() | |
| { | |
| Super::OnInitialized(); | |
| ensureAlwaysMsgf(!NavigationText.IsEmpty(), TEXT("You must provide a NavigationText for this setting.")); | |
| ensureAlwaysMsgf(!DescriptionRichText.IsEmpty(), TEXT("You must provide a description for new page collections.")); | |
| } | |
| void UGameSettingCollectionPage::GetSettingsForFilter(const FGameSettingFilterState& FilterState, TArray<UGameSetting*>& InOutSettings) const | |
| { | |
| // If we're including nested pages, call the super and dump them all, otherwise, we pretend we have none for the filtering. | |
| // because our settings are displayed on another page. | |
| if (FilterState.bIncludeNestedPages || FilterState.IsSettingInRootList(this)) | |
| { | |
| Super::GetSettingsForFilter(FilterState, InOutSettings); | |
| } | |
| } | |
| void UGameSettingCollectionPage::ExecuteNavigation() | |
| { | |
| OnExecuteNavigationEvent.Broadcast(this); | |
| } | |