From d6b4d0b3a5d665b76a5f0c4b5c68dd741ff4424f Mon Sep 17 00:00:00 2001 From: dexy Date: Wed, 14 Apr 2021 14:07:37 +1000 Subject: [PATCH] Improved error message for missing .dds files on XML import --- .../GameFiles/Resources/Texture.cs | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/CodeWalker.Core/GameFiles/Resources/Texture.cs b/CodeWalker.Core/GameFiles/Resources/Texture.cs index 3920334..7b1d8bc 100644 --- a/CodeWalker.Core/GameFiles/Resources/Texture.cs +++ b/CodeWalker.Core/GameFiles/Resources/Texture.cs @@ -553,26 +553,37 @@ namespace CodeWalker.GameFiles Format = Xml.GetChildEnumInnerText(node, "Format"); var filename = Xml.GetChildInnerText(node, "FileName"); - try + + if ((!string.IsNullOrEmpty(filename)) && (!string.IsNullOrEmpty(ddsfolder))) { var filepath = Path.Combine(ddsfolder, filename); if (File.Exists(filepath)) { - var dds = File.ReadAllBytes(filepath); - var tex = DDSIO.GetTexture(dds); - if (tex != null) + try { - Data = tex.Data; - Width = tex.Width; - Height = tex.Height; - Depth = tex.Depth; - Levels = tex.Levels; - Format = tex.Format; - Stride = tex.Stride; + var dds = File.ReadAllBytes(filepath); + var tex = DDSIO.GetTexture(dds); + if (tex != null) + { + Data = tex.Data; + Width = tex.Width; + Height = tex.Height; + Depth = tex.Depth; + Levels = tex.Levels; + Format = tex.Format; + 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 { } }