// Fill out your copyright notice in the Description page of Project Settings.


#include "Widget/MsgBox/CsdkMsgBoxBase.h"

void UCsdkMsgBoxBase::SetMidBtnInfo(const FString& Content, const FString& MidBtnText,
	const FOnMsgBoxBtnClicked& MidBtnAction)
{
	UnBindsAll();
	OnMidBtnClicked = MidBtnAction;
	SetMidBtnInfo(Content,MidBtnText);
}

void UCsdkMsgBoxBase::SetLeftBtnAndRightBtnInfo(const FString& Content, const FString& LeftBtnText,
	const FOnMsgBoxBtnClicked& LeftBtnAction, const FString& RightBtnText, const FOnMsgBoxBtnClicked& RightBtnAction)
{
	UnBindsAll();
	OnLeftBtnClicked = LeftBtnAction;
	OnRightBtnClicked = RightBtnAction;
	SetLeftBtnAndRightBtnInfo( Content, LeftBtnText,RightBtnText);
}

void UCsdkMsgBoxBase::LeftBtnClick()
{
	OnBtnClick(OnLeftBtnClicked);
}

void UCsdkMsgBoxBase::MidBtnClick()
{
	OnBtnClick(OnMidBtnClicked);
}

void UCsdkMsgBoxBase::RightBtnClick()
{
	OnBtnClick(OnRightBtnClicked);
}

void UCsdkMsgBoxBase::UnBindsAll()
{
	OnLeftBtnClicked.Unbind();
	OnMidBtnClicked.Unbind();
	OnRightBtnClicked.Unbind();
}

void UCsdkMsgBoxBase::OnBtnClick(const FOnMsgBoxBtnClicked& OnBtnClicked)
{
	if(OnBtnClicked.IsBound())
	{
		OnBtnClicked.Execute();
	}
	RemoveFromParent();
}
