You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Please note that file comments had no purpose in nearly all cases and just added visual clutter. The two files that had meaningful file comments had their comments moved into the corresponding classes. There are still hundreds of file comments left in other files that will be removed over time. Also cleaned up some random stuff along the way: - relative paths to public headers within the same module are no longer necessary (automatically discovered by UBT now) - header guards are deprecated, use #pragma once instead (all compilers support it now) - space between multiple template brackets is no longer required (all compilers support >> now) - NULL to nullptr, OVERRIDE to override - spelling errors, whitespace, line breaks [CL 2104067 by Max Preussner in Main branch]
306 lines
8.3 KiB
C++
306 lines
8.3 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
|
|
/**
|
|
* Implements a project settings section.
|
|
*/
|
|
class FSettingsSection
|
|
: public ISettingsSection
|
|
{
|
|
public:
|
|
|
|
/**
|
|
* Creates and initializes a new settings section from the given settings object.
|
|
*
|
|
* @param InCategory The settings category that owns this section.
|
|
* @param InName The setting section's name.
|
|
* @param InDisplayName The section's localized display name.
|
|
* @param InDescription The section's localized description text.
|
|
* @param InDelegates The section's optional callback delegates.
|
|
* @param InSettingsObject The object that holds the settings for this section.
|
|
*/
|
|
FSettingsSection( const ISettingsCategoryRef& InCategory, const FName& InName, const FText& InDisplayName, const FText& InDescription, const FSettingsSectionDelegates& InDelegates, const TWeakObjectPtr<UObject>& InSettingsObject )
|
|
: Category(InCategory)
|
|
, Description(InDescription)
|
|
, DisplayName(InDisplayName)
|
|
, Name(InName)
|
|
, SettingsObject(InSettingsObject)
|
|
, CanEditDelegate(InDelegates.CanEditDelegate)
|
|
, ExportDelegate(InDelegates.ExportDelegate)
|
|
, ImportDelegate(InDelegates.ImportDelegate)
|
|
, ModifiedDelegate(InDelegates.ModifiedDelegate)
|
|
, ResetDefaultsDelegate(InDelegates.ResetDefaultsDelegate)
|
|
, SaveDefaultsDelegate(InDelegates.SaveDefaultsDelegate)
|
|
, SaveDelegate(InDelegates.SaveDelegate)
|
|
, StatusDelegate(InDelegates.StatusDelegate)
|
|
{ }
|
|
|
|
/**
|
|
* Creates and initializes a new settings section from the given custom settings widget.
|
|
*
|
|
* @param InCategory The settings category that owns this section.
|
|
* @param InName The setting section's name.
|
|
* @param InDisplayName The section's localized display name.
|
|
* @param InDescription The section's localized description text.
|
|
* @param InDelegates The section's optional callback delegates.
|
|
* @param InCustomWidget A custom settings widget.
|
|
*/
|
|
FSettingsSection( const ISettingsCategoryRef& InCategory, const FName& InName, const FText& InDisplayName, const FText& InDescription, const FSettingsSectionDelegates& InDelegates, const TSharedRef<SWidget>& InCustomWidget )
|
|
: Category(InCategory)
|
|
, CustomWidget(InCustomWidget)
|
|
, Description(InDescription)
|
|
, DisplayName(InDisplayName)
|
|
, Name(InName)
|
|
, CanEditDelegate(InDelegates.CanEditDelegate)
|
|
, ExportDelegate(InDelegates.ExportDelegate)
|
|
, ImportDelegate(InDelegates.ImportDelegate)
|
|
, ModifiedDelegate(InDelegates.ModifiedDelegate)
|
|
, ResetDefaultsDelegate(InDelegates.ResetDefaultsDelegate)
|
|
, SaveDefaultsDelegate(InDelegates.SaveDefaultsDelegate)
|
|
, SaveDelegate(InDelegates.SaveDelegate)
|
|
, StatusDelegate(InDelegates.StatusDelegate)
|
|
{ }
|
|
|
|
public:
|
|
|
|
// ISettingsSection interface
|
|
|
|
virtual bool CanEdit( ) const override
|
|
{
|
|
if (CanEditDelegate.IsBound())
|
|
{
|
|
return CanEditDelegate.Execute();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
virtual bool CanExport( ) const override
|
|
{
|
|
return (ExportDelegate.IsBound() || (SettingsObject.IsValid() && SettingsObject->GetClass()->HasAnyClassFlags(CLASS_Config)));
|
|
}
|
|
|
|
virtual bool CanImport( ) const override
|
|
{
|
|
return (ImportDelegate.IsBound() || (SettingsObject.IsValid() && SettingsObject->GetClass()->HasAnyClassFlags(CLASS_Config)));
|
|
}
|
|
|
|
virtual bool CanResetDefaults( ) const override
|
|
{
|
|
return (ResetDefaultsDelegate.IsBound() || (SettingsObject.IsValid() && SettingsObject->GetClass()->HasAnyClassFlags(CLASS_Config) && !SettingsObject->GetClass()->HasAnyClassFlags(CLASS_DefaultConfig)));
|
|
}
|
|
|
|
virtual bool CanSave( ) const override
|
|
{
|
|
return (SaveDelegate.IsBound() || (SettingsObject.IsValid() && SettingsObject->GetClass()->HasAnyClassFlags(CLASS_Config)));
|
|
}
|
|
|
|
virtual bool CanSaveDefaults( ) const override
|
|
{
|
|
return (SaveDefaultsDelegate.IsBound() || (SettingsObject.IsValid() && SettingsObject->GetClass()->HasAnyClassFlags(CLASS_Config) && !SettingsObject->GetClass()->HasAnyClassFlags(CLASS_DefaultConfig)));
|
|
}
|
|
|
|
virtual bool Export( const FString& Filename ) override
|
|
{
|
|
if (ExportDelegate.IsBound())
|
|
{
|
|
return ExportDelegate.Execute(Filename);
|
|
}
|
|
|
|
if (SettingsObject.IsValid())
|
|
{
|
|
SettingsObject->SaveConfig(CPF_Config, *Filename);
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
virtual ISettingsCategoryWeakPtr GetCategory( ) override
|
|
{
|
|
return Category;
|
|
}
|
|
|
|
virtual TWeakPtr<SWidget> GetCustomWidget( ) const override
|
|
{
|
|
return CustomWidget;
|
|
}
|
|
|
|
virtual const FText& GetDescription( ) const override
|
|
{
|
|
return Description;
|
|
}
|
|
|
|
virtual const FText& GetDisplayName( ) const override
|
|
{
|
|
return DisplayName;
|
|
}
|
|
|
|
virtual const FName& GetName( ) const override
|
|
{
|
|
return Name;
|
|
}
|
|
|
|
virtual TWeakObjectPtr<UObject> GetSettingsObject( ) const override
|
|
{
|
|
return SettingsObject;
|
|
}
|
|
|
|
virtual FText GetStatus( ) const override
|
|
{
|
|
if (StatusDelegate.IsBound())
|
|
{
|
|
return StatusDelegate.Execute();
|
|
}
|
|
|
|
return FText::GetEmpty();
|
|
}
|
|
|
|
virtual bool HasDefaultSettingsObject( ) override
|
|
{
|
|
if (!SettingsObject.IsValid())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return SettingsObject->GetClass()->HasAnyClassFlags(CLASS_DefaultConfig);
|
|
}
|
|
|
|
virtual bool Import( const FString& Filename ) override
|
|
{
|
|
if (ImportDelegate.IsBound())
|
|
{
|
|
return ImportDelegate.Execute(Filename);
|
|
}
|
|
|
|
if (SettingsObject.IsValid())
|
|
{
|
|
SettingsObject->LoadConfig(SettingsObject->GetClass(), *Filename, UE4::LCPF_PropagateToInstances);
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
virtual bool ResetDefaults( ) override
|
|
{
|
|
if (ResetDefaultsDelegate.IsBound())
|
|
{
|
|
return ResetDefaultsDelegate.Execute();
|
|
}
|
|
|
|
if (SettingsObject.IsValid() && SettingsObject->GetClass()->HasAnyClassFlags(CLASS_Config) && !SettingsObject->GetClass()->HasAnyClassFlags(CLASS_DefaultConfig))
|
|
{
|
|
FString ConfigName = SettingsObject->GetClass()->GetConfigName();
|
|
|
|
GConfig->EmptySection(*SettingsObject->GetClass()->GetPathName(), ConfigName);
|
|
GConfig->Flush(false);
|
|
|
|
FConfigCacheIni::LoadGlobalIniFile(ConfigName, *FPaths::GetBaseFilename(ConfigName), nullptr, nullptr, true);
|
|
|
|
SettingsObject->ReloadConfig(nullptr, nullptr, UE4::LCPF_PropagateToInstances|UE4::LCPF_PropagateToChildDefaultObjects);
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
virtual bool Save( ) override
|
|
{
|
|
if (ModifiedDelegate.IsBound() && !ModifiedDelegate.Execute())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (SaveDelegate.IsBound())
|
|
{
|
|
return SaveDelegate.Execute();
|
|
}
|
|
|
|
if (SettingsObject.IsValid())
|
|
{
|
|
if (SettingsObject->GetClass()->HasAnyClassFlags(CLASS_DefaultConfig))
|
|
{
|
|
SettingsObject->UpdateDefaultConfigFile();
|
|
}
|
|
else
|
|
{
|
|
SettingsObject->SaveConfig();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
virtual bool SaveDefaults( ) override
|
|
{
|
|
if (SaveDefaultsDelegate.IsBound())
|
|
{
|
|
return SaveDefaultsDelegate.Execute();
|
|
}
|
|
|
|
if (SettingsObject.IsValid())
|
|
{
|
|
SettingsObject->UpdateDefaultConfigFile();
|
|
SettingsObject->ReloadConfig(nullptr, nullptr, UE4::LCPF_PropagateToInstances);
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
private:
|
|
|
|
// Holds a pointer to the settings category that owns this section.
|
|
ISettingsCategoryWeakPtr Category;
|
|
|
|
// Holds the section's custom editor widget.
|
|
TWeakPtr<SWidget> CustomWidget;
|
|
|
|
// Holds the section's description text.
|
|
FText Description;
|
|
|
|
// Holds the section's localized display name.
|
|
FText DisplayName;
|
|
|
|
// Holds the section's name.
|
|
FName Name;
|
|
|
|
// Holds the settings object.
|
|
TWeakObjectPtr<UObject> SettingsObject;
|
|
|
|
private:
|
|
|
|
// Holds a delegate that is executed to check whether a settings section can be edited.
|
|
FOnSettingsSectionCanEdit CanEditDelegate;
|
|
|
|
// Holds a delegate that is executed when the settings section should be exported to a file.
|
|
FOnSettingsSectionExport ExportDelegate;
|
|
|
|
// Holds a delegate that is executed when the settings section should be imported from a file.
|
|
FOnSettingsSectionImport ImportDelegate;
|
|
|
|
// Holds a delegate that is executed after the settings section has been modified.
|
|
FOnSettingsSectionModified ModifiedDelegate;
|
|
|
|
// Holds a delegate that is executed when the settings section should have its values reset to default.
|
|
FOnSettingsSectionResetDefaults ResetDefaultsDelegate;
|
|
|
|
// Holds a delegate that is executed when a settings section should have its values saved as default.
|
|
FOnSettingsSectionSaveDefaults SaveDefaultsDelegate;
|
|
|
|
// Holds a delegate that is executed when a settings section should have its values saved.
|
|
FOnSettingsSectionSave SaveDelegate;
|
|
|
|
// Holds a delegate that is executed to retrieve a status message for a settings section.
|
|
FOnSettingsSectionStatus StatusDelegate;
|
|
};
|