// Oleg Petruny proprietary.

#pragma once

#include "UObject/Object.h"

#include "WidgetsManager.generated.h"

enum class EInputAnimatedWidgetAnimation : uint8;
enum class EQuickTimeEventResult : uint8;

/**
 * Manager/Wrapper of most of UI widgets.
 * Please, don't create your own widgets but instead append manager class and us it as upper layer.
 * At Init instantiate (non)permanent overlays widgets.
 */
UCLASS(Blueprintable)
class UWidgetsManager : public UObject
{
    GENERATED_BODY()

public:
    void Init();
    void UpdateInputKeys();

    void ShowWidgets();
    void HideWidgets();
    void UpdateWidgetsOwner();

    void ShowMainMenu(bool pause = true);
    void HideMainMenu();

    UFUNCTION(BlueprintCallable, Category = WidgetsManager)
    void ShowInteractionHints(const class UInteractableModificator* modificator = nullptr);
    UFUNCTION(BlueprintCallable, Category = WidgetsManager)
    void HideInteractionHints(const class UInteractableModificator* modificator = nullptr);
    void AnimateInteractionHint(const class UInteractableModificator* modificator, const int32 index, const EInputAnimatedWidgetAnimation animation);

    void EnableCutsceneWidget(class FSkipCutsceneDelegate& skipCutsceneDelegate);
    void DisableCutsceneWidget();
    void AnimateCutsceneWidget(const EInputAnimatedWidgetAnimation animation);

    void ShowQuickTimeEvent(const int32 id, const struct FQuickTimeEventEnqueProperties& properties);
    EQuickTimeEventResult RemoveQuickTimeEvent(const int32 id);
    EQuickTimeEventResult ProcessQuickTimeEvent(const int32 id, const bool released);

    void SetInputDialogueWidget(const FKey key, const FText desc, class FDialogueSkipDelegate& delegate);
    void ShowDialogueWidget(const struct FDialogueRow& dialogue);
    void HideDialogueWidget(const struct FDialogueRow& dialogue);
    void AnimateDialogueWidget(const EInputAnimatedWidgetAnimation animation);

    void ShowInventory();
    void ShowInventory(FText key1, FText key2);
    void SetInventoryFirstItem(FText item);
    void SetInventorySecondItem(FText item);

    void ShowJournal();
    void UpdateJournal(TArray<FText> text);

protected:
    UPROPERTY(EditDefaultsOnly)
    TSet<TSubclassOf<class UUserWidget>> permaOverlayWidgets; // never hidden
    TArray<class UUserWidget*> permaOverlayWidgetsInstances;

    UPROPERTY(EditDefaultsOnly)
    TSet<TSubclassOf<class UUserWidget>> overlayWidgets; // hidden in pause, cutscene
    TArray<class UUserWidget*> overlayWidgetsInstances;

    UPROPERTY(EditDefaultsOnly)
    TSubclassOf<class UMainMenuWidget> mainMenuWidgetClass;
    class UMainMenuWidget* mainMenuWidget = nullptr;

    UPROPERTY(EditDefaultsOnly)
    TSubclassOf<class UInteractableHintWidgetManager> interactableHintWidgetManagerClass; // hidden in cutscene
    class UInteractableHintWidgetManager* interactableHintWidgetManager = nullptr;

    UPROPERTY(EditDefaultsOnly)
    TSubclassOf<class UCutsceneSkipWidget> cutsceneSkipWidgetClass; // never hidden
    class UCutsceneSkipWidget* cutsceneSkipWidget = nullptr;

    UPROPERTY(EditDefaultsOnly)
    TSubclassOf<class UQuickTimeEventWidgetManager> quickTimeEventWidgetManagerClass; // never hidden
    class UQuickTimeEventWidgetManager* quickTimeEventWidgetManager = nullptr;

    UPROPERTY(EditDefaultsOnly)
    TSubclassOf<class UDialogueRowWidgetManager> dialogueRowWidgetManagerClass; // hidden in cutscene
    class UDialogueRowWidgetManager* dialogueRowWidgetManager = nullptr;

    UPROPERTY(EditDefaultsOnly)
    TSubclassOf<class UInventoryWidget> inventoryWidgetClass; // hidden in pause, cutscene
    class UInventoryWidget* inventoryWidget = nullptr;

    UPROPERTY(EditDefaultsOnly)
    TSubclassOf<class UJournalWidget> journalWidgetClass; // hidden in pause, cutscene
    class UJournalWidget* journalWidget = nullptr;

    bool initialized = false;
};
