42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "CraftingIngredientRowWidget.h"
|
|
|
|
#include "Components/Image.h"
|
|
#include "Components/TextBlock.h"
|
|
#include "ItemDataAsset.h"
|
|
|
|
void UCraftingIngredientRowWidget::SetIngredient(const FCraftIngredientStatus& Status)
|
|
{
|
|
if (IngredientIcon)
|
|
{
|
|
UTexture2D* Icon = Status.Item ? Status.Item->Icon : nullptr;
|
|
if (Icon)
|
|
{
|
|
IngredientIcon->SetBrushFromTexture(Icon);
|
|
IngredientIcon->SetVisibility(ESlateVisibility::HitTestInvisible);
|
|
}
|
|
else
|
|
{
|
|
// Sans ca, un objet sans icone afficherait le carre blanc du brush
|
|
// par defaut au milieu de la liste.
|
|
IngredientIcon->SetVisibility(ESlateVisibility::Hidden);
|
|
}
|
|
}
|
|
|
|
if (IngredientNameText)
|
|
{
|
|
IngredientNameText->SetText(Status.Item ? Status.Item->DisplayName : FText::GetEmpty());
|
|
}
|
|
|
|
if (IngredientCountText)
|
|
{
|
|
IngredientCountText->SetText(FText::Format(CountFormat,
|
|
FText::AsNumber(Status.OwnedQuantity),
|
|
FText::AsNumber(Status.RequiredQuantity)));
|
|
|
|
IngredientCountText->SetColorAndOpacity(FSlateColor(Status.IsSatisfied() ? EnoughColor : MissingColor));
|
|
}
|
|
}
|