// Oleg Petruny proprietary.

#include "MainMenuWidget.h"

#include "Animation/WidgetAnimation.h"

#include "CustomGameInstance.h"
#include "MainGameModeBase.h"
#include "MainMenuButtonWidget.h"
#include "Widgets/WidgetsManager.h"

bool UMainMenuWidget::Initialize()
{
    if(ButtonLoadLastSave)
    {
        auto GI = UCustomGameInstance::Get();
        if(GI && GI->saveData)
        {
            ButtonLoadLastSave->SetIsEnabled(true);
            ButtonLoadLastSave->SetRenderOpacity(1.0f);
        }
    }

    //FWidgetAnimationDynamicEvent closeFinished;
    //closeFinished.BindDynamic(this, &UMainMenuWidget::Closed);
    //BindToAnimationFinished(closeAnimation, closeFinished);

    return UUserWidget::Initialize();
}

void UMainMenuWidget::Show(bool fast)
{
    SetVisibility(ESlateVisibility::Visible);
    //StopAnimation(closeAnimation);
    //
    //if(fast)
    //    PlayAnimation(showFastAnimation, 0, 1, EUMGSequencePlayMode::Forward, 1, false);
    //else
    //    PlayAnimation(showFullAnimation, 0, 1, EUMGSequencePlayMode::Forward, 1, false);
    //
    //OnMainMenuOpeningDelegate.Broadcast();
}

void UMainMenuWidget::Hide()
{
    //StopAnimation(showFastAnimation);
    //StopAnimation(showFullAnimation);

    //PlayAnimation(closeAnimation);
    //OnMainMenuClosingDelegate.Broadcast();
    SetVisibility(ESlateVisibility::Hidden);
}

void UMainMenuWidget::Closed()
{
    SetVisibility(ESlateVisibility::Hidden);
    //OnMainMenuClosedDelegate.Broadcast();
}
