修复 foodImage 读取问题

This commit is contained in:
Hakoyu 2023-11-28 15:10:50 +08:00
parent 250da82648
commit 1be307cc93
2 changed files with 4 additions and 1 deletions

View File

@ -58,6 +58,8 @@ public static class Extensions
/// <returns>复制的图像</returns>
public static BitmapImage Copy(this BitmapImage image)
{
if (image is null)
return null;
BitmapImage newImage = new();
newImage.BeginInit();
newImage.DecodePixelWidth = image.DecodePixelWidth;

View File

@ -166,7 +166,8 @@ public class ModLoader
foreach (ILine li in tmp)
{
var food = LPSConvert.DeserializeObject<Food>(li);
var imagePath = $"{path.FullName}\\image\\food\\{food.Name}.png";
var imagePath =
$"{path.FullName}\\image\\food\\{(string.IsNullOrWhiteSpace(food.Image) ? food.Name : food.Image)}.png";
if (File.Exists(imagePath))
food.Image = imagePath;
Foods.Add(food);