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

#pragma once

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

class UTextButton;
class UButton;
class UCommonActivatableWidgetStack;
class UConfirmModalWidget;

// Front-end main menu. Owns the Continue / New Game / Settings / Credits / Quit flow.
// Confirmation popups, credits and settings are pushed onto ModalStack (a stack in the
// widget tree). The gameplay / menu maps are data-driven via the soft map references.
UCLASS(Abstract)
class NAKEDDESIRE_API UMainMenuWidget : public UCommonActivatableWidget
{
	GENERATED_BODY()

public:
	UMainMenuWidget();

protected:
	virtual void NativeOnActivated() override;

private:
	UPROPERTY(meta = (BindWidget))
	TObjectPtr<UTextButton> ContinueButton;

	UPROPERTY(meta = (BindWidget))
	TObjectPtr<UTextButton> NewGameButton;

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

	UPROPERTY(meta = (BindWidget))
	TObjectPtr<UTextButton> CreditsButton;

	UPROPERTY(meta = (BindWidget))
	TObjectPtr<UTextButton> QuitButton;

	// Stack the confirm popup / credits / settings screens are pushed onto.
	UPROPERTY(meta = (BindWidget))
	TObjectPtr<UCommonActivatableWidgetStack> ModalStack;

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

	UPROPERTY(EditDefaultsOnly, Category = "UI")
	TSubclassOf<UCommonActivatableWidget> CreditsWidgetClass;

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

	// Level "New Game" / "Continue" load into (the §0.2 slice district).
	UPROPERTY(EditDefaultsOnly, Category = "UI", meta = (AllowedClasses = "/Script/Engine.World"))
	TSoftObjectPtr<UWorld> GameplayMap;

	UFUNCTION()
	void OnContinueClicked();

	UFUNCTION()
	void OnNewGameClicked();

	UFUNCTION()
	void OnSettingsClicked();

	UFUNCTION()
	void OnCreditsClicked();

	UFUNCTION()
	void OnQuitClicked();

	void HandleNewGameConfirmed();
	void HandleQuitConfirmed();

	void OpenGameplayLevel();
};