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

#include "SCW_FStructVariableDescription.h"
#include "SCW_UObject.h"
#include "SourcifyCoreUEWrapperModule.h"
#include "UserDefinedStructure/UserDefinedStructEditorData.h"

using namespace Sourcify;

SCW_FStructVariableDescription::SCW_FStructVariableDescription(FStructVariableDescription* InStructVariableDescription) : StructVariableDescription(InStructVariableDescription)
{

}

FStructVariableDescription* SCW_FStructVariableDescription::ToFStructVariableDescription() const
{
	return StructVariableDescription;
}

ISCW_FStructVariableDescriptionPtr SCW_FStructVariableDescription::ToFStructVariableDescriptionPtr()
{
	return GetSharedThisAs<SCW_FStructVariableDescription>();
}

ISCW_FStructVariableDescriptionConstPtr SCW_FStructVariableDescription::ToFStructVariableDescriptionPtr() const
{
	return GetSharedThisAs<SCW_FStructVariableDescription>();
}

wstring SCW_FStructVariableDescription::GetDefaultValue() const
{
	return *StructVariableDescription->DefaultValue;
}

wstring SCW_FStructVariableDescription::GetFriendlyName() const
{
	return *StructVariableDescription->FriendlyName;
}

ISCW_UObjectPtr SCW_FStructVariableDescription::GetSubCategoryObject() const
{
	return FSourcifyCoreUEWrapper::Get().Wrap(*StructVariableDescription->SubCategoryObject.LoadSynchronous());
}

void SCW_FStructVariableDescription::SetDefaultValue(const wstring& InDefaultValue) const
{
	StructVariableDescription->DefaultValue = InDefaultValue.c_str();
}

void SCW_FStructVariableDescription::SetSubCategoryObject(ISCW_UObjectPtr InSubCategoryObject)
{
	StructVariableDescription->SubCategoryObject = dynamic_cast<SCW_UObject*>(InSubCategoryObject.get())->ToUObjectRawPtr();
}