Improve texture loader with error icons and messages
This commit is contained in:
parent
2478527a1c
commit
adccce2db8
@ -207,24 +207,31 @@ namespace LayoutBXLYT.Cafe
|
||||
string folder = Path.GetDirectoryName(FilePath);
|
||||
foreach (var file in Directory.GetFiles(folder))
|
||||
{
|
||||
if (Utils.GetExtension(file) == ".bflim")
|
||||
try
|
||||
{
|
||||
BFLIM bflim = (BFLIM)STFileLoader.OpenFileFormat(file);
|
||||
if (!textures.ContainsKey(bflim.FileName))
|
||||
textures.Add(bflim.FileName, bflim);
|
||||
}
|
||||
if (Utils.GetExtension(file) == ".bntx")
|
||||
{
|
||||
BNTX bntx = (BNTX)STFileLoader.OpenFileFormat(file);
|
||||
foreach (var tex in bntx.Textures)
|
||||
if (Utils.GetExtension(file) == ".bflim")
|
||||
{
|
||||
if (!textures.ContainsKey(tex.Key))
|
||||
textures.Add(tex.Key, tex.Value);
|
||||
BFLIM bflim = (BFLIM)STFileLoader.OpenFileFormat(file);
|
||||
if (!textures.ContainsKey(bflim.FileName))
|
||||
textures.Add(bflim.FileName, bflim);
|
||||
}
|
||||
if (Utils.GetExtension(file) == ".bntx")
|
||||
{
|
||||
BNTX bntx = (BNTX)STFileLoader.OpenFileFormat(file);
|
||||
foreach (var tex in bntx.Textures)
|
||||
{
|
||||
if (!textures.ContainsKey(tex.Key))
|
||||
textures.Add(tex.Key, tex.Value);
|
||||
}
|
||||
|
||||
string fileName = Path.GetFileName(file);
|
||||
if (!header.TextureManager.BinaryContainers.ContainsKey(fileName))
|
||||
header.TextureManager.BinaryContainers.Add(fileName, bntx);
|
||||
string fileName = Path.GetFileName(file);
|
||||
if (!header.TextureManager.BinaryContainers.ContainsKey(fileName))
|
||||
header.TextureManager.BinaryContainers.Add(fileName, bntx);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
STErrorDialog.Show($"Failed to load texture {file}. ", "Layout Editor", ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,23 +240,30 @@ namespace LayoutBXLYT.Cafe
|
||||
{
|
||||
foreach (var file in archive.Files)
|
||||
{
|
||||
if (Utils.GetExtension(file.FileName) == ".bntx")
|
||||
try
|
||||
{
|
||||
BNTX bntx = (BNTX)file.OpenFile();
|
||||
file.FileFormat = bntx;
|
||||
foreach (var tex in bntx.Textures)
|
||||
if (!textures.ContainsKey(tex.Key))
|
||||
textures.Add(tex.Key, tex.Value);
|
||||
if (Utils.GetExtension(file.FileName) == ".bntx")
|
||||
{
|
||||
BNTX bntx = (BNTX)file.OpenFile();
|
||||
file.FileFormat = bntx;
|
||||
foreach (var tex in bntx.Textures)
|
||||
if (!textures.ContainsKey(tex.Key))
|
||||
textures.Add(tex.Key, tex.Value);
|
||||
|
||||
if (!header.TextureManager.BinaryContainers.ContainsKey($"{archive.FileName}.bntx"))
|
||||
header.TextureManager.BinaryContainers.Add($"{archive.FileName}.bntx", bntx);
|
||||
if (!header.TextureManager.BinaryContainers.ContainsKey($"{archive.FileName}.bntx"))
|
||||
header.TextureManager.BinaryContainers.Add($"{archive.FileName}.bntx", bntx);
|
||||
}
|
||||
if (Utils.GetExtension(file.FileName) == ".bflim")
|
||||
{
|
||||
BFLIM bflim = (BFLIM)file.OpenFile();
|
||||
file.FileFormat = bflim;
|
||||
if (!textures.ContainsKey(bflim.FileName))
|
||||
textures.Add(bflim.FileName, bflim);
|
||||
}
|
||||
}
|
||||
if (Utils.GetExtension(file.FileName) == ".bflim")
|
||||
catch (Exception ex)
|
||||
{
|
||||
BFLIM bflim = (BFLIM)file.OpenFile();
|
||||
file.FileFormat = bflim;
|
||||
if (!textures.ContainsKey(bflim.FileName))
|
||||
textures.Add(bflim.FileName, bflim);
|
||||
STErrorDialog.Show($"Failed to load texture {file.FileName}. ", "Layout Editor", ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,17 +115,24 @@ namespace LayoutBXLYT
|
||||
{
|
||||
foreach (var file in IFileInfo.ArchiveParent.Files)
|
||||
{
|
||||
if (Utils.GetExtension(file.FileName) == ".tpl")
|
||||
try
|
||||
{
|
||||
TPL tpl = (TPL)file.OpenFile();
|
||||
file.FileFormat = tpl;
|
||||
foreach (var tex in tpl.IconTextureList)
|
||||
if (Utils.GetExtension(file.FileName) == ".tpl")
|
||||
{
|
||||
//Only need the first texture
|
||||
if (!textures.ContainsKey(tex.Text))
|
||||
textures.Add(file.FileName, tex);
|
||||
TPL tpl = (TPL)file.OpenFile();
|
||||
file.FileFormat = tpl;
|
||||
foreach (var tex in tpl.IconTextureList)
|
||||
{
|
||||
//Only need the first texture
|
||||
if (!textures.ContainsKey(tex.Text))
|
||||
textures.Add(file.FileName, tex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
STErrorDialog.Show($"Failed to load texture {file.FileName}. ", "Layout Editor", ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,9 +77,9 @@ namespace LayoutBXLYT
|
||||
ActiveLayout = header;
|
||||
listViewCustom1.Items.Clear();
|
||||
imgListSmall.Images.Clear();
|
||||
imgListSmall.Images.Add(new Bitmap(30, 30));
|
||||
imgListSmall.Images.Add(FirstPlugin.Properties.Resources.MissingTexture);
|
||||
imgListBig.Images.Clear();
|
||||
imgListBig.Images.Add(new Bitmap(60, 60));
|
||||
imgListBig.Images.Add(FirstPlugin.Properties.Resources.MissingTexture);
|
||||
|
||||
listViewCustom1.LargeImageList = imgListBig;
|
||||
listViewCustom1.SmallImageList = imgListSmall;
|
||||
|
10
File_Format_Library/Properties/Resources.Designer.cs
generated
10
File_Format_Library/Properties/Resources.Designer.cs
generated
@ -200,6 +200,16 @@ namespace FirstPlugin.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap MissingTexture {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("MissingTexture", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
@ -196,4 +196,7 @@
|
||||
<data name="LayoutAnimation" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\LayoutAnimation.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="MissingTexture" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\MissingTexture.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
File_Format_Library/Resources/MissingTexture.png
Normal file
BIN
File_Format_Library/Resources/MissingTexture.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Loading…
x
Reference in New Issue
Block a user