51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "CraftingRecipeBook.h"
|
|
|
|
#include "CraftingRecipeDataAsset.h"
|
|
|
|
#if WITH_EDITOR
|
|
#include "Misc/DataValidation.h"
|
|
#endif
|
|
|
|
#define LOCTEXT_NAMESPACE "CraftingBook"
|
|
|
|
#if WITH_EDITOR
|
|
EDataValidationResult UCraftingRecipeBook::IsDataValid(FDataValidationContext& Context) const
|
|
{
|
|
EDataValidationResult Result = Super::IsDataValid(Context);
|
|
|
|
// Une case vide dans le tableau ne casse rien au runtime, on la saute. Mais
|
|
// c'est le symptome d'une recette supprimee ou d'un ajout laisse en plan, et
|
|
// la grille de craft aurait un trou sans qu'on sache pourquoi.
|
|
TSet<const UCraftingRecipeDataAsset*> SeenRecipes;
|
|
SeenRecipes.Reserve(Recipes.Num());
|
|
|
|
for (int32 Index = 0; Index < Recipes.Num(); ++Index)
|
|
{
|
|
const UCraftingRecipeDataAsset* Recipe = Recipes[Index];
|
|
|
|
if (!Recipe)
|
|
{
|
|
Context.AddWarning(FText::Format(
|
|
LOCTEXT("BookNullRecipe", "Book entry {0} is empty."), Index));
|
|
continue;
|
|
}
|
|
|
|
bool bAlreadySeen = false;
|
|
SeenRecipes.Add(Recipe, &bAlreadySeen);
|
|
if (bAlreadySeen)
|
|
{
|
|
Context.AddWarning(FText::Format(
|
|
LOCTEXT("BookDuplicateRecipe", "Recipe {0} is listed twice: it will show up twice in the grid."),
|
|
FText::FromString(Recipe->GetName())));
|
|
}
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
#endif
|
|
|
|
#undef LOCTEXT_NAMESPACE
|