// Copyright (c) 2024 Codemongous LLC. All Rights Reserved.

#include "SCW_UWidgetTree.h"
#include "SourcifyCoreUEWrapperModule.h"
#include "Blueprint/WidgetTree.h"

using namespace Sourcify;

SCW_UWidgetTree::SCW_UWidgetTree(UWidgetTree* InWidgetTree) : SCW_UObject(InWidgetTree), WidgetTree(InWidgetTree)
{

}

UWidgetTree* SCW_UWidgetTree::ToUWidgetTree() const
{
	return WidgetTree.Get();
}

ISCW_UWidgetTreePtr SCW_UWidgetTree::ToUWidgetTreePtr()
{
	return GetSharedThisAs<SCW_UWidgetTree>();
}

ISCW_UWidgetTreeConstPtr SCW_UWidgetTree::ToUWidgetTreePtr() const
{
	return GetSharedThisAs<SCW_UWidgetTree>();
}

ISCW_UWidgetPtr SCW_UWidgetTree::FindWidget(const wstring& Name) const
{
	UWidget* Widget = WidgetTree->FindWidget(Name.c_str());
	return Widget ? FSourcifyCoreUEWrapper::Get().Wrap(*Widget) : nullptr;
}