diff --git a/Content/G2I_Game/UI/DA_WidgetsCatalog.uasset b/Content/G2I_Game/UI/DA_WidgetsCatalog.uasset index 3dc342cb..e003428f 100644 Binary files a/Content/G2I_Game/UI/DA_WidgetsCatalog.uasset and b/Content/G2I_Game/UI/DA_WidgetsCatalog.uasset differ diff --git a/Content/G2I_Game/UI/Elements/DT_RichTextStyles.uasset b/Content/G2I_Game/UI/Elements/DT_RichTextStyles.uasset index 051531fd..79bc64cc 100644 Binary files a/Content/G2I_Game/UI/Elements/DT_RichTextStyles.uasset and b/Content/G2I_Game/UI/Elements/DT_RichTextStyles.uasset differ diff --git a/Content/G2I_Game/UI/Menu/Creators/WB_Creators.uasset b/Content/G2I_Game/UI/Menu/Creators/WB_Creators.uasset new file mode 100644 index 00000000..e0ba5cf3 Binary files /dev/null and b/Content/G2I_Game/UI/Menu/Creators/WB_Creators.uasset differ diff --git a/Content/G2I_Game/UI/Menu/Options/WB_Options.uasset b/Content/G2I_Game/UI/Menu/Options/WB_Options.uasset index 34bd70d4..f34eae19 100644 Binary files a/Content/G2I_Game/UI/Menu/Options/WB_Options.uasset and b/Content/G2I_Game/UI/Menu/Options/WB_Options.uasset differ diff --git a/Content/G2I_Game/UI/StringsRu/ST_Creators.uasset b/Content/G2I_Game/UI/StringsRu/ST_Creators.uasset index ad21fee2..1ad8490e 100644 Binary files a/Content/G2I_Game/UI/StringsRu/ST_Creators.uasset and b/Content/G2I_Game/UI/StringsRu/ST_Creators.uasset differ diff --git a/Source/G2I/Private/UI/G2IUIManager.cpp b/Source/G2I/Private/UI/G2IUIManager.cpp index e46b9dfd..7b91c3bc 100644 --- a/Source/G2I/Private/UI/G2IUIManager.cpp +++ b/Source/G2I/Private/UI/G2IUIManager.cpp @@ -19,6 +19,7 @@ #include "Components/WidgetSwitcher.h" #include "Gameplay/G2IKeyHintWidget.h" #include "HUD/G2IAimingWidget.h" +#include "Menu/G2ICreatorsWidget.h" #include "Menu/Elements/NumericalRow/G2INumericalMultiValuePropertyRow.h" #include "Menu/Elements/G2IControlListItem.h" #include "Menu/Elements/G2IControlRow.h" @@ -501,6 +502,21 @@ void UG2IUIManager::SetupOptionsWidget(const TFunction& NewBackAction) c } } +void UG2IUIManager::SetupCreatorsWidget(const TFunction& NewBackAction) const +{ + if (!ensure(DisplayManager)) + { + UE_LOG(LogG2I, Error, TEXT("%s: Couldn't find %s"), *GetName(), + *UG2IUIDisplayManager::StaticClass()->GetName()); + return; + } + if (UG2ICreatorsWidget *Widget = Cast( + DisplayManager->GetWidget(EG2IWidgetNames::Creators))) + { + Widget->OnBack = NewBackAction; + } +} + void UG2IUIManager::SetPropertyRow(UG2ITextMultiValuePropertyRow* PropertySelector, const FString& PropertyNameStringID, TArray& ValuesNamesStringID, const int32 DefaultValueIndex) const { diff --git a/Source/G2I/Private/UI/Widgets/Menu/G2ICreatorsWidget.cpp b/Source/G2I/Private/UI/Widgets/Menu/G2ICreatorsWidget.cpp new file mode 100644 index 00000000..115ea495 --- /dev/null +++ b/Source/G2I/Private/UI/Widgets/Menu/G2ICreatorsWidget.cpp @@ -0,0 +1,44 @@ +#include "Menu/G2ICreatorsWidget.h" +#include "G2I.h" +#include "G2IUIManager.h" +#include "G2IWidgetNames.h" +#include "Components/Button.h" + +void UG2ICreatorsWidget::InitializeAfterManagerLoading() +{ + Super::InitializeAfterManagerLoading(); + + BindDelegates(); +} + +void UG2ICreatorsWidget::BindDelegates() +{ + if (ensure(BackButton)) + { + BackButton->OnClicked.AddDynamic(this, &ThisClass::OnBackButtonClicked); + } + else + { + UE_LOG(LogG2I, Error, TEXT("%s: Couldn't find BackButton"), *GetName()); + } +} + +void UG2ICreatorsWidget::OnBackButtonClicked() +{ + if (ensure(OnBack)) + { + OnBack(); + } + else + { + UE_LOG(LogG2I, Warning, TEXT("Back function is undefined in %s"), *GetName()); + } + + if (!ensure(UIManager)) + { + UE_LOG(LogG2I, Error, TEXT("%s: Couldn't find %s"), *GetName(), + *UG2IUIManager::StaticClass()->GetName()); + return; + } + UIManager->CloseWidget(EG2IWidgetNames::Creators); +} diff --git a/Source/G2I/Private/UI/Widgets/Menu/G2IMainMenuWidget.cpp b/Source/G2I/Private/UI/Widgets/Menu/G2IMainMenuWidget.cpp index 67c39ccf..fa2626b9 100644 --- a/Source/G2I/Private/UI/Widgets/Menu/G2IMainMenuWidget.cpp +++ b/Source/G2I/Private/UI/Widgets/Menu/G2IMainMenuWidget.cpp @@ -46,7 +46,7 @@ void UG2IMainMenuWidget::BindDelegates() } if (ensure(CreatorsButton)) { - CreatorsButton->SetIsEnabled(false); + CreatorsButton->OnClicked.AddDynamic(this, &ThisClass::OnCreatorsButtonClicked); } else { @@ -122,6 +122,20 @@ void UG2IMainMenuWidget::OnOptionsButtonClicked() UIManager->SetupOptionsWidget(GetShowCurrentWidgetFunction()); } +void UG2IMainMenuWidget::OnCreatorsButtonClicked() +{ + if (!ensure(UIManager)) + { + UE_LOG(LogG2I, Error, TEXT("%s: Couldn't find %s"), *GetName(), + *UG2IUIManager::StaticClass()->GetName()); + return; + } + UIManager->HideWidget(EG2IWidgetNames::MainMenu); + UIManager->OpenWidget(EG2IWidgetNames::Creators); + + UIManager->SetupCreatorsWidget(GetShowCurrentWidgetFunction()); +} + void UG2IMainMenuWidget::OnQuitGameButtonClicked() { if (!ensure(UIManager)) diff --git a/Source/G2I/Public/UI/G2IUIManager.h b/Source/G2I/Public/UI/G2IUIManager.h index f53e3b57..4ca8d2d9 100644 --- a/Source/G2I/Public/UI/G2IUIManager.h +++ b/Source/G2I/Public/UI/G2IUIManager.h @@ -114,6 +114,9 @@ class G2I_API UG2IUIManager : public UGameInstanceSubsystem // ==================== LOADING WIDGET ==================== void SetLoadingProgressPercent(float Percent) const; + // ==================== CREATORS WIDGET ==================== + void SetupCreatorsWidget(const TFunction& NewBackAction) const; + // ==================== OPTIONS WIDGETS ==================== void SetupOptionsWidget(const TFunction& NewBackAction) const; void SetupControlsWidget(UWidgetSwitcher* CharacterControlsSwitcher) const; diff --git a/Source/G2I/Public/UI/Widgets/Menu/G2ICreatorsWidget.h b/Source/G2I/Public/UI/Widgets/Menu/G2ICreatorsWidget.h new file mode 100644 index 00000000..9a32b83c --- /dev/null +++ b/Source/G2I/Public/UI/Widgets/Menu/G2ICreatorsWidget.h @@ -0,0 +1,34 @@ +#pragma once + +#include "CoreMinimal.h" +#include "G2IUserWidget.h" +#include "G2ICreatorsWidget.generated.h" + +class UButton; + +UCLASS() +class G2I_API UG2ICreatorsWidget : public UG2IUserWidget +{ + GENERATED_BODY() + +public: + + UPROPERTY(meta = (BindWidget)) + TObjectPtr BackButton; + +public: + + TFunction OnBack; + +protected: + + virtual void InitializeAfterManagerLoading() override; + + UFUNCTION() + void OnBackButtonClicked(); + +private: + + void BindDelegates(); + +}; diff --git a/Source/G2I/Public/UI/Widgets/Menu/G2IMainMenuWidget.h b/Source/G2I/Public/UI/Widgets/Menu/G2IMainMenuWidget.h index 0f2ade1b..f0c9ab65 100644 --- a/Source/G2I/Public/UI/Widgets/Menu/G2IMainMenuWidget.h +++ b/Source/G2I/Public/UI/Widgets/Menu/G2IMainMenuWidget.h @@ -38,6 +38,9 @@ class G2I_API UG2IMainMenuWidget : public UG2IUserWidget UFUNCTION() void OnOptionsButtonClicked(); + UFUNCTION() + void OnCreatorsButtonClicked(); + UFUNCTION() void OnQuitGameButtonClicked();