// Project Lab - NHTV Igad

#pragma once

#include "Blueprint/UserWidget.h"
#include "MenuButton.h"
#include <set>
#include "LobbySlot.generated.h"

UCLASS()
class UNREALPROJECT_API ULobbySlot : public UMenuButton
{
	GENERATED_BODY()

public:
	virtual void NativeConstruct() override;
	virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;

	void SetTeamIndex(uint32 idx);

	// Must be called from blueprint to setup this element
	UFUNCTION(BlueprintCallable, Category = "Lobby")
	void Init(UTextBlock* teamName, UVerticalBox* playerList);

	void UpdatePlayers(TArray<class APlayerStateBase*> players);
	void SetState(bool open);

	UFUNCTION(BlueprintCallable, Category = "Lobby")
	bool OnSlotSelected();

	UPROPERTY(EditDefaultsOnly, Category = "Lobby")
	UFont* font;

	UPROPERTY(EditDefaultsOnly, Category="Lobby")
	TSubclassOf<class ULobbyPlayerSlot> lobbyPlayerSlotClass;

private:
	ULobbySlot(const FObjectInitializer& init);

	void m_UpdateTeamTitle();

	UPROPERTY()
	UTextBlock* m_teamName;
	UPROPERTY()
	UVerticalBox* m_playerList;
	UPROPERTY()
	TArray<class ULobbyPlayerSlot*> m_playerSlots;

	UPROPERTY()
	UButton* m_joinButton;
	uint32 m_teamIndex;
	UPROPERTY()
	TArray<class APlayerStateBase*>  m_players;
	bool m_open;
};
