Moved all code to C++.

This commit is contained in:
Jamie Greunbaum 2023-05-06 14:46:38 -04:00
parent 75ae7a10d6
commit a78d861a7a
2 changed files with 25 additions and 1 deletions

View File

@ -3,15 +3,33 @@
#include "LoadingScreenWidget.h"
void ULoadingScreenWidget::NativePreConstruct()
{
FWidgetAnimationDynamicEvent LoadScreenOpened;
LoadScreenOpened.BindUFunction(this, TEXT("LoadScreenOpened"));
this->BindToAnimationFinished(this->Fade, LoadScreenOpened);
this->PlayAnimationForward(this->Fade);
}
void ULoadingScreenWidget::LoadScreenOpened()
{
this->UnbindAllFromAnimationFinished(this->Fade);
#if !WITH_EDITOR
this->OnLoadScreenOpened.ExecuteIfBound();
#endif
}
void ULoadingScreenWidget::BeginFadeOut_Implementation()
{
FWidgetAnimationDynamicEvent LoadScreenClosed;
LoadScreenClosed.BindUFunction(this, TEXT("LoadScreenClosed"));
this->BindToAnimationFinished(this->Fade, LoadScreenClosed);
this->PlayAnimationReverse(this->Fade);
}
void ULoadingScreenWidget::LoadScreenClosed()
{
this->UnbindAllFromAnimationFinished(this->Fade);
#if !WITH_EDITOR
this->OnLoadScreenClosed.ExecuteIfBound();
#endif

View File

@ -18,15 +18,21 @@ class COMMONLOADINGSCREEN_API ULoadingScreenWidget : public UUserWidget
GENERATED_BODY()
public:
virtual void NativePreConstruct() override;
UFUNCTION(BlueprintCallable)
void LoadScreenOpened();
UFUNCTION(BlueprintCallable)
void LoadScreenClosed();
UFUNCTION(BlueprintImplementableEvent)
UFUNCTION(BlueprintNativeEvent)
void BeginFadeOut();
DECLARE_DELEGATE(FOnLoadScreenEvent)
FOnLoadScreenEvent OnLoadScreenOpened;
FOnLoadScreenEvent OnLoadScreenClosed;
protected:
UPROPERTY(Transient, BlueprintReadOnly, meta=(BindWidgetAnim))
TObjectPtr<UWidgetAnimation> Fade;
};