Skip to content

Commit

Permalink
Merge pull request #7 from JanSeliv/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
JanSeliv authored Dec 26, 2024
2 parents 9037e3c + ceb8383 commit 7f73697
Show file tree
Hide file tree
Showing 45 changed files with 838 additions and 275 deletions.
Binary file modified Binaries/Win64/UnrealEditor-SettingsWidgetConstructor.dll
Binary file not shown.
Binary file modified Binaries/Win64/UnrealEditor-SettingsWidgetConstructor.pdb
Binary file not shown.
Binary file not shown.
Binary file modified Binaries/Win64/UnrealEditor-SettingsWidgetConstructorEditor.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion Binaries/Win64/UnrealEditor.modules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"BuildId": "27405482",
"BuildId": "33043543",
"Modules":
{
"SettingsWidgetConstructor": "UnrealEditor-SettingsWidgetConstructor.dll",
Expand Down
18 changes: 10 additions & 8 deletions Config/BaseSettingsWidgetConstructor.ini
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
[/Script/SettingsWidgetConstructorEditor.SettingsWidgetFactory]
SettingsWidgetClassInternal=WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/WBP_SettingsWidgetConstructor.WBP_SettingsWidgetConstructor_C'
SettingsWidgetClassInternal=/Script/UMG.WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/WBP_SettingsWidgetConstructor.WBP_SettingsWidgetConstructor_C'

[/Script/SettingsWidgetConstructor.SettingsDataAsset]
SettingsDataTableInternal=
SettingsDataRegistryInternal=/SettingsWidgetConstructor/Data/DR_SettingsDataTables.DR_SettingsDataTables
ButtonClassInternal=WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsButton.WBP_SettingsButton_C'
CheckboxClassInternal=WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsCheckBox.WBP_SettingsCheckBox_C'
ComboboxClassInternal=WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsCombobox.WBP_SettingsCombobox_C'
SliderClassInternal=WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsSlider.WBP_SettingsSlider_C'
TextLineClassInternal=WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsTextLine.WBP_SettingsTextLine_C'
UserInputClassInternal=WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsTextInput.WBP_SettingsTextInput_C'
ButtonClassInternal=/Script/UMG.WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsButton.WBP_SettingsButton_C'
CheckboxClassInternal=/Script/UMG.WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsCheckBox.WBP_SettingsCheckBox_C'
ComboboxClassInternal=/Script/UMG.WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsCombobox.WBP_SettingsCombobox_C'
SliderClassInternal=/Script/UMG.WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsSlider.WBP_SettingsSlider_C'
TextLineClassInternal=/Script/UMG.WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsTextLine.WBP_SettingsTextLine_C'
UserInputClassInternal=/Script/UMG.WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsTextInput.WBP_SettingsTextInput_C'
TooltipClassInternal=/Script/UMG.WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsToolTip.WBP_SettingsToolTip_C'
ColumnClassInternal=/Script/UMG.WidgetBlueprintGeneratedClass'/SettingsWidgetConstructor/Subwidgets/WBP_SettingsMenuColumn.WBP_SettingsMenuColumn_C'
bAutoConstructInternal=True
bAutoFocusOnOpenInternal=True
SettingsPercentSizeInternal=(X=0.600000,Y=0.400000)
SettingsPaddingInternal=(Left=50.000000,Top=50.000000,Right=50.000000,Bottom=50.000000)
ScrollboxPercentHeightInternal=1.000000
ScrollboxPaddingInternal=(Left=0.000000,Top=0.000000,Right=0.000000,Bottom=0.000000)
ColumnPaddingInternal=(Left=10.000000,Top=0.000000,Right=10.000000,Bottom=0.000000)
SpaceBetweenColumnsInternal=10.000000
ButtonThemeDataInternal=(PressedPadding=(Left=0.000000,Top=0.000000,Right=0.000000,Bottom=0.000000),Texture=Texture2D'"/SettingsWidgetConstructor/Textures/T_Settings_Button.T_Settings_Button"',Size=(X=128.000000,Y=128.000000),DrawAs=Box,Margin=(Left=0.250000,Top=0.250000,Right=0.250000,Bottom=0.250000),Padding=(Left=0.000000,Top=0.000000,Right=0.000000,Bottom=0.000000))
CheckboxThemeDataInternal=(CheckedTexture=Texture2D'"/SettingsWidgetConstructor/Textures/T_Settings_Checkbox_checked.T_Settings_Checkbox_checked"',UndeterminedTexture=None,Texture=Texture2D'"/SettingsWidgetConstructor/Textures/T_Settings_Checkbox_unchecked.T_Settings_Checkbox_unchecked"',Size=(X=24.000000,Y=24.000000),DrawAs=Image,Margin=(Left=0.000000,Top=0.000000,Right=0.000000,Bottom=0.000000),Padding=(Left=0.000000,Top=0.000000,Right=0.000000,Bottom=0.000000))
Expand Down
Binary file modified Content/Subwidgets/WBP_SettingsButton.uasset
Binary file not shown.
Binary file modified Content/Subwidgets/WBP_SettingsCheckBox.uasset
Binary file not shown.
Binary file modified Content/Subwidgets/WBP_SettingsCombobox.uasset
Binary file not shown.
Binary file modified Content/Subwidgets/WBP_SettingsMenuColumn.uasset
Binary file not shown.
Binary file removed Content/Subwidgets/WBP_SettingsScrollItem.uasset
Binary file not shown.
Binary file removed Content/Subwidgets/WBP_SettingsScrollWrapper.uasset
Binary file not shown.
Binary file removed Content/Subwidgets/WBP_SettingsScrollbox.uasset
Binary file not shown.
Binary file modified Content/Subwidgets/WBP_SettingsSlider.uasset
Binary file not shown.
Binary file removed Content/Subwidgets/WBP_SettingsSpacer.uasset
Binary file not shown.
Binary file modified Content/Subwidgets/WBP_SettingsTextInput.uasset
Binary file not shown.
Binary file modified Content/Subwidgets/WBP_SettingsTextLine.uasset
Binary file not shown.
Binary file modified Content/Subwidgets/WBP_SettingsToolTip.uasset
Binary file not shown.
Binary file modified Content/WBP_SettingsWidgetConstructor.uasset
Binary file not shown.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Check out our [Release](https://github.com/JanSeliv/SettingsWidgetConstructor/re
Also, explore this [game project repository](https://github.com/JanSeliv/Bomber) to view the Settings Widget Constructor in action.

## 📅 Changelog
#### 2024-12-26
- Updated to **Unreal Engine 5.4**.
- Moved a significant chunk of the logic from blueprints to code and simplified amount of widgets used.
#### 2023-10-12
- Updated to **Unreal Engine 5.3**
- Added **multiple Settings Data Tables** support ([see doc](https://docs.google.com/document/d/1IXnOqrgaXTClP-0cIo28a9f6GHc9N1BCgTNnMk-X9VQ/edit#heading=h.cix3vjszb2vm)).
Expand Down
2 changes: 1 addition & 1 deletion SettingsWidgetConstructor.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "mailto:[email protected]",
"EngineVersion": "5.3.0",
"EngineVersion": "5.4.0",
"EnabledByDefault": true,
"CanContainContent": true,
"IsBetaVersion": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ void FSettingsButton::BindSetting(USettingsWidget& SettingsWidget, const FSettin
SettingsWidget.BindButton(PrimaryData, *this);
}

// Calls the Add function of the Settings Widget of this setting type
void FSettingsButton::AddSetting(USettingsWidget& SettingsWidget, const FSettingsPrimary& PrimaryData)
{
SettingsWidget.AddButton(PrimaryData, *this);
}

/*********************************************************************************************
* FSettingsCheckbox
********************************************************************************************* */
Expand Down Expand Up @@ -67,12 +61,6 @@ void FSettingsCheckbox::BindSetting(USettingsWidget& SettingsWidget, const FSett
SettingsWidget.BindCheckbox(PrimaryData, *this);
}

// Calls the Add function of the Settings Widget of this setting type
void FSettingsCheckbox::AddSetting(USettingsWidget& SettingsWidget, const FSettingsPrimary& InOutPrimaryData)
{
SettingsWidget.AddCheckbox(InOutPrimaryData, *this);
}

/*********************************************************************************************
* FSettingsCombobox
********************************************************************************************* */
Expand Down Expand Up @@ -120,12 +108,6 @@ void FSettingsCombobox::BindSetting(USettingsWidget& SettingsWidget, const FSett
SettingsWidget.BindCombobox(PrimaryData, *this);
}

// Calls the Add function of the Settings Widget of this setting type
void FSettingsCombobox::AddSetting(USettingsWidget& SettingsWidget, const FSettingsPrimary& InOutPrimaryData)
{
SettingsWidget.AddCombobox(InOutPrimaryData, *this);
}

/*********************************************************************************************
* FSettingsSlider
********************************************************************************************* */
Expand Down Expand Up @@ -156,12 +138,6 @@ void FSettingsSlider::BindSetting(USettingsWidget& SettingsWidget, const FSettin
SettingsWidget.BindSlider(PrimaryData, *this);
}

// Calls the Add function of the Settings Widget of this setting type
void FSettingsSlider::AddSetting(USettingsWidget& SettingsWidget, const FSettingsPrimary& InOutPrimaryData)
{
SettingsWidget.AddSlider(InOutPrimaryData, *this);
}

/*********************************************************************************************
* FSettingsTextLine
********************************************************************************************* */
Expand Down Expand Up @@ -193,12 +169,6 @@ void FSettingsTextLine::BindSetting(USettingsWidget& SettingsWidget, const FSett
SettingsWidget.BindTextLine(PrimaryData, *this);
}

// Calls the Add function of the Settings Widget of this setting type
void FSettingsTextLine::AddSetting(USettingsWidget& SettingsWidget, const FSettingsPrimary& InOutPrimaryData)
{
SettingsWidget.AddTextLine(InOutPrimaryData, *this);
}

/*********************************************************************************************
* FSettingsUserInput
********************************************************************************************* */
Expand Down Expand Up @@ -229,12 +199,6 @@ void FSettingsUserInput::BindSetting(USettingsWidget& SettingsWidget, const FSet
SettingsWidget.BindUserInput(PrimaryData, *this);
}

// Calls the Add function of the Settings Widget of this setting type
void FSettingsUserInput::AddSetting(USettingsWidget& SettingsWidget, const FSettingsPrimary& InOutPrimaryData)
{
SettingsWidget.AddUserInput(InOutPrimaryData, *this);
}

/*********************************************************************************************
* FSettingsCustomWidget
********************************************************************************************* */
Expand All @@ -257,9 +221,3 @@ void FSettingsCustomWidget::BindSetting(USettingsWidget& SettingsWidget, const F
{
SettingsWidget.BindCustomWidget(PrimaryData, *this);
}

// Calls the Add function of the Settings Widget of this setting type
void FSettingsCustomWidget::AddSetting(USettingsWidget& SettingsWidget, const FSettingsPrimary& InOutPrimaryData)
{
SettingsWidget.AddCustomWidget(InOutPrimaryData, *this);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "Data/SettingsDataTable.h"
#include "MyUtilsLibraries/SettingsUtilsLibrary.h"
//---
#include "DataRegistry.h"
#include "Engine/Engine.h"
#include "Misc/CoreDelegates.h"
//---
#include UE_INLINE_GENERATED_CPP_BY_NAME(SettingsDataAsset)

// Returns the data table, it has to be set manually
Expand All @@ -14,7 +18,7 @@ const USettingsDataTable* USettingsDataAsset::GetSettingsDataTable() const
}

// Returns the Settings Data Registry asset, is automatically set by default to which 'Settings Data Table' is added by itself
const UDataRegistry* USettingsDataAsset::GetSettingsDataRegistry() const
UDataRegistry* USettingsDataAsset::GetSettingsDataRegistry() const
{
return SettingsDataRegistryInternal.LoadSynchronous();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ USettingsDataTable::USettingsDataTable()
RowStruct = FSettingsRow::StaticStruct();
}

// Returns the table rows
void USettingsDataTable::GetSettingRows(TMap<FName, FSettingsRow>& OutRows) const
{
GetRows(OutRows);
}

#if WITH_EDITOR
// Called on every change in this data table to automatic set the key name by specified setting tag
void USettingsDataTable::OnThisDataTableChanged(FName RowKey, const uint8& RowData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ class FSWCWidgetUtilsLibrary
* As an example, it returns SCheckbox slate widget from UCheckBox widget. */
template <typename T>
static FORCEINLINE TSharedPtr<T> GetSlateWidget(const UWidget* ForWidget) { return ForWidget ? StaticCastSharedPtr<T>(ForWidget->GetCachedWidget()) : nullptr; }

/** Completely destroys specified widget.
* Is useful for MGF-modules unloading in runtime.
* In most gameplay cases it should not be used, since it's expensive: prefer collapse widget instead. */
static void DestroyWidget(UUserWidget& ParentWidget);
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ UGameUserSettings* USettingsUtilsLibrary::GetGameUserSettings(const UObject* Opt
}

// Returns all Settings Rows from project's Settings Data Table and all other additional Data Tables from 'SettingsDataTable' Data Registry
void USettingsUtilsLibrary::GetAllSettingRows(TMap<FName, FSettingsRow>& OutSettingRows)
void USettingsUtilsLibrary::GenerateAllSettingRows(TMap<FName, FSettingsPicker>& OutSettingRows)
{
if (!OutSettingRows.IsEmpty())
{
Expand Down Expand Up @@ -102,7 +102,7 @@ void USettingsUtilsLibrary::GetAllSettingRows(TMap<FName, FSettingsRow>& OutSett
for (const FSettingsRow& Row : OrderedSettings)
{
const FName Tag = Row.SettingsPicker.PrimaryData.Tag.GetTagName();
OutSettingRows.Add(Tag, Row);
OutSettingRows.Add(Tag, Row.SettingsPicker);

// Check if there's an override block for this tag
const FSettingTag SettingTag = Row.SettingsPicker.PrimaryData.Tag;
Expand All @@ -113,7 +113,7 @@ void USettingsUtilsLibrary::GetAllSettingRows(TMap<FName, FSettingsRow>& OutSett
for (const FSettingsRow& OverrideRow : *OverrideBlock)
{
const FName OverrideTag = OverrideRow.SettingsPicker.PrimaryData.Tag.GetTagName();
OutSettingRows.Add(OverrideTag, OverrideRow);
OutSettingRows.Add(OverrideTag, OverrideRow.SettingsPicker);
}
}
}
Expand All @@ -129,7 +129,7 @@ void USettingsUtilsLibrary::RegisterDataTable(const TSoftObjectPtr<const USettin
UDataRegistrySubsystem* DataRegistrySubsystem = UDataRegistrySubsystem::Get();
checkf(DataRegistrySubsystem, TEXT("ERROR: [%i] %s:\n'DataRegistrySubsystem' is null!"), __LINE__, *FString(__FUNCTION__));

const TSoftObjectPtr<const UDataRegistry>& SettingsDataRegistry = USettingsDataAsset::Get().GetSettingsDataRegistrySoft();
const TSoftObjectPtr<UDataRegistry>& SettingsDataRegistry = USettingsDataAsset::Get().GetSettingsDataRegistrySoft();
if (ensureMsgf(!SettingsDataRegistry.IsNull(), TEXT("ASSERT: 'SettingsDataRegistry' is null, it has to be set automatically, something went wrong!")))
{
// Initialize the Settings Data Registry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,37 @@ UUserWidget* FSWCWidgetUtilsLibrary::FindWidgetOfClass(UObject* WorldContextObje
{
TArray<UUserWidget*> FoundWidgets;
UWidgetBlueprintLibrary::GetAllWidgetsOfClass(WorldContextObject, /*out*/FoundWidgets, ParentWidgetClass);
return !FoundWidgets.IsEmpty()? FoundWidgets[0] : nullptr;
return !FoundWidgets.IsEmpty() ? FoundWidgets[0] : nullptr;
}

// Completely destroys specified widget
void FSWCWidgetUtilsLibrary::DestroyWidget(UUserWidget& ParentWidget)
{
// Get an array of all child widgets
TArray<UWidget*> ChildWidgets;
const UWidgetTree* WidgetTree = ParentWidget.WidgetTree;
WidgetTree->GetAllWidgets(ChildWidgets);

// Iterate through the child widgets
for (UWidget* ChildWidgetIt : ChildWidgets)
{
UUserWidget* ChildUserWidget = Cast<UUserWidget>(ChildWidgetIt);
const UWidgetTree* WidgetTreeIt = IsValid(ChildUserWidget) ? ChildUserWidget->WidgetTree : nullptr;
const bool bHasChildWidgets = WidgetTreeIt && WidgetTreeIt->RootWidget;

if (bHasChildWidgets)
{
// If the child widget has its own child widgets, recursively remove and destroy them
DestroyWidget(*ChildUserWidget);
}
}

// Hide widget to let last chance react on visibility change
ParentWidget.SetVisibility(ESlateVisibility::Collapsed);

// Remove the child widget from the viewport
ParentWidget.RemoveFromParent();

// RemoveFromParent() does not completely destroy widget, so schedule the child widget for destruction
ParentWidget.ConditionalBeginDestroy();
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright (c) Yevhenii Selivanov.

#include "SettingsWidgetConstructorModule.h"

#define LOCTEXT_NAMESPACE "FSettingsWidgetConstructorModule"

//---
#include "Modules/ModuleManager.h"
// Called right after the module DLL has been loaded and the module object has been created
void FSettingsWidgetConstructorModule::StartupModule()
{
Expand All @@ -17,6 +16,4 @@ void FSettingsWidgetConstructorModule::ShutdownModule()
// we call this function before unloading the module.
}

#undef LOCTEXT_NAMESPACE

IMPLEMENT_MODULE(FSettingsWidgetConstructorModule, SettingsWidgetConstructor)
Loading

0 comments on commit 7f73697

Please sign in to comment.