77 lines
1.5 KiB
C++
77 lines
1.5 KiB
C++
// Project Lab - NHTV Igad
|
|
|
|
#include "UnrealProject.h"
|
|
#include "SkillSelectorItem.h"
|
|
#include "SkillSelector.h"
|
|
#include "SkillWidget.h"
|
|
#include "SkillTreeWidget.h"
|
|
|
|
void USkillSelectorItem::NativeConstruct()
|
|
{
|
|
Super::NativeConstruct();
|
|
|
|
m_skillWidget = WidgetTree->FindWidget<USkillWidget>("InnerSkillWidget");
|
|
if(!m_skillWidget)
|
|
{
|
|
GWERROR(L"InnerSkillWidget not found on " + GetName());
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
m_skillWidget->skillAsset = baseSkillObject;
|
|
m_skillWidget->parent = skillTree;
|
|
m_skillWidget->UpdateSkill();
|
|
}
|
|
|
|
if(m_button)
|
|
{
|
|
m_button->OnPressed.AddDynamic(this, &USkillSelectorItem::m_OnPressed1);
|
|
}
|
|
else
|
|
{
|
|
GWERROR(L"No button found on " + GetName());
|
|
}
|
|
}
|
|
|
|
void USkillSelectorItem::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
|
{
|
|
if(skillTree->IsUsingSkill(baseSkillObject))
|
|
{
|
|
this->SetIsEnabled(false);
|
|
}
|
|
else
|
|
{
|
|
this->SetIsEnabled(true);
|
|
}
|
|
}
|
|
|
|
void USkillSelectorItem::NativeOnSelectionChanged(bool selected, bool controller)
|
|
{
|
|
if(selected)
|
|
{
|
|
m_button->SetBackgroundColor(FLinearColor(1.0f, 1.0f, 1.0f, 0.5f));
|
|
}
|
|
else
|
|
{
|
|
m_button->SetBackgroundColor(FLinearColor(1.0f, 1.0f, 1.0f, 0.0f));
|
|
}
|
|
}
|
|
|
|
void USkillSelectorItem::m_OnPressed1()
|
|
{
|
|
if(!GetIsEnabled())
|
|
return;
|
|
|
|
if(parent)
|
|
{
|
|
USubMenu* menu = parent->GetSubMenu();
|
|
if(menu)
|
|
menu->SelectNewItem(parent);
|
|
|
|
//if(parent->GetSelection() == index)
|
|
skillTree->NewSkill(m_skillWidget);
|
|
parent->SetSelection(index);
|
|
//else
|
|
}
|
|
}
|