#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "UICharacterCreatePage_Base.generated.h"

class UEditableTextBox;
class UComboBoxString;
class UCommonTextBlock;
class UUIButton_Base;

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FZMMOOnCharCreateRequestSent);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FZMMOOnCharCreateCancelled);

/**
 * Page de criacao de personagem dentro do Lobby. Form minimo: nome + classId
 * (combo) + appearance default. Quando confirma, monta o payload do
 * C_CHAR_CREATE e envia via UZeusCharServerSubsystem. O Lobby host escuta
 * S_CHAR_CREATE_OK/REJECT.
 *
 * Wire C_CHAR_CREATE (espelha char-create.service.ts):
 *   uint8[16] worldId + uint8 slot + string name + uint16 classId
 *   + uint32 hair + uint32 hairColor + uint32 skinColor + uint8 bodyType
 */
UCLASS(Abstract, Blueprintable)
class ZMMO_API UUICharacterCreatePage_Base : public UUserWidget
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintCallable, Category = "Zeus|CharCreate")
	void SubmitCreate();

	UFUNCTION(BlueprintCallable, Category = "Zeus|CharCreate")
	void CancelCreate();

	UPROPERTY(BlueprintAssignable, Category = "Zeus|CharCreate")
	FZMMOOnCharCreateRequestSent OnRequestSent;

	UPROPERTY(BlueprintAssignable, Category = "Zeus|CharCreate")
	FZMMOOnCharCreateCancelled OnCancelled;

protected:
	virtual void NativeConstruct() override;
	virtual void NativeDestruct() override;

	void HandleSubmitClicked() { SubmitCreate(); }
	void HandleCancelClicked() { CancelCreate(); }

	UPROPERTY(meta = (BindWidget))         TObjectPtr<UEditableTextBox> Input_Name;
	UPROPERTY(meta = (BindWidgetOptional)) TObjectPtr<UComboBoxString>  Combo_Class;
	UPROPERTY(meta = (BindWidget))         TObjectPtr<UUIButton_Base>   Btn_Confirm;
	UPROPERTY(meta = (BindWidgetOptional)) TObjectPtr<UUIButton_Base>   Btn_Cancel;
	UPROPERTY(meta = (BindWidgetOptional)) TObjectPtr<UCommonTextBlock> Text_Error;

private:
	bool bBound = false;
};
