// © 2025 Naked People Team. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "CommonActivatableWidget.h"
#include "PauseMenuWidget.generated.h"

class UButton;
class UCommonActivatableWidgetStack;
class UConfirmModalWidget;

// In-game pause menu. Pauses the game while active and offers Resume / Settings / Main Menu.
// The Main Menu action confirms first. Confirm popup / settings push onto ModalStack.
UCLASS(Abstract)
class NAKEDDESIRE_API UPauseMenuWidget : public UCommonActivatableWidget
{
	GENERATED_BODY()

public:
	UPauseMenuWidget();

protected:
	virtual void NativeOnActivated() override;
	virtual void NativeOnDeactivated() override;

private:
	UPROPERTY(meta = (BindWidget))
	TObjectPtr<UButton> ResumeButton;

	UPROPERTY(meta = (BindWidget))
	TObjectPtr<UButton> SettingsButton;

	UPROPERTY(meta = (BindWidget))
	TObjectPtr<UButton> MainMenuButton;

	// Stack the confirm popup / settings screen are pushed onto (nested so this menu stays active).
	UPROPERTY(meta = (BindWidget))
	TObjectPtr<UCommonActivatableWidgetStack> ModalStack;

	UPROPERTY(EditDefaultsOnly, Category = "UI")
	TSubclassOf<UConfirmModalWidget> ConfirmModalClass;

	// Optional — wired once the settings screen exists. Settings button no-ops until then.
	UPROPERTY(EditDefaultsOnly, Category = "UI")
	TSubclassOf<UCommonActivatableWidget> SettingsWidgetClass;

	UPROPERTY(EditDefaultsOnly, Category = "UI", meta = (AllowedClasses = "/Script/Engine.World"))
	TSoftObjectPtr<UWorld> MainMenuMap;
	
	FTimerHandle PauseTimerHandle;

	UFUNCTION()
	void OnResumeClicked();

	UFUNCTION()
	void OnSettingsClicked();

	UFUNCTION()
	void OnMainMenuClicked();

	void HandleMainMenuConfirmed();
	void PauseGame();
};