Improved error message for missing .dds files on XML import

This commit is contained in:
dexy 2021-04-14 14:07:37 +10:00
parent fc0d84d9dd
commit d6b4d0b3a5

View File

@ -553,10 +553,13 @@ namespace CodeWalker.GameFiles
Format = Xml.GetChildEnumInnerText<TextureFormat>(node, "Format"); Format = Xml.GetChildEnumInnerText<TextureFormat>(node, "Format");
var filename = Xml.GetChildInnerText(node, "FileName"); var filename = Xml.GetChildInnerText(node, "FileName");
try
if ((!string.IsNullOrEmpty(filename)) && (!string.IsNullOrEmpty(ddsfolder)))
{ {
var filepath = Path.Combine(ddsfolder, filename); var filepath = Path.Combine(ddsfolder, filename);
if (File.Exists(filepath)) if (File.Exists(filepath))
{
try
{ {
var dds = File.ReadAllBytes(filepath); var dds = File.ReadAllBytes(filepath);
var tex = DDSIO.GetTexture(dds); var tex = DDSIO.GetTexture(dds);
@ -571,8 +574,16 @@ namespace CodeWalker.GameFiles
Stride = tex.Stride; Stride = tex.Stride;
} }
} }
catch
{
throw new Exception("Texture file format not supported:\n" + filepath);
}
}
else
{
throw new Exception("Texture file not found:\n" + filepath);
}
} }
catch { }
} }