mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-26 06:20:24 +00:00
Add preview to single textures (ie NUTEXB)
This commit is contained in:
parent
e2edd2e923
commit
b445590961
6 changed files with 49 additions and 2 deletions
|
@ -14,8 +14,10 @@ using Syroot.NintenTools.NSW.Bntx.GFX;
|
||||||
|
|
||||||
namespace FirstPlugin
|
namespace FirstPlugin
|
||||||
{
|
{
|
||||||
public class NUTEXB : STGenericTexture, IFileFormat, IContextMenuNode
|
public class NUTEXB : STGenericTexture, IFileFormat, IContextMenuNode, ISingleTextureIconLoader
|
||||||
{
|
{
|
||||||
|
public STGenericTexture IconTexture { get { return this; } }
|
||||||
|
|
||||||
public FileType FileType { get; set; } = FileType.Image;
|
public FileType FileType { get; set; } = FileType.Image;
|
||||||
|
|
||||||
public override TEX_FORMAT[] SupportedFormats
|
public override TEX_FORMAT[] SupportedFormats
|
||||||
|
|
|
@ -86,6 +86,7 @@ namespace Toolbox.Library
|
||||||
private readonly Dictionary<int, TreeNode> _treeNodes = new Dictionary<int, TreeNode>();
|
private readonly Dictionary<int, TreeNode> _treeNodes = new Dictionary<int, TreeNode>();
|
||||||
|
|
||||||
public List<ITextureIconLoader> TextureIcons = new List<ITextureIconLoader>();
|
public List<ITextureIconLoader> TextureIcons = new List<ITextureIconLoader>();
|
||||||
|
public List<ISingleTextureIconLoader> SingleTextureIcons = new List<ISingleTextureIconLoader>();
|
||||||
|
|
||||||
public TreeViewCustom()
|
public TreeViewCustom()
|
||||||
{
|
{
|
||||||
|
@ -121,6 +122,32 @@ namespace Toolbox.Library
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var texIcon in SingleTextureIcons)
|
||||||
|
{
|
||||||
|
var image = texIcon.IconTexture.GetBitmap();
|
||||||
|
AddImageOnThread(image, texIcon.IconTexture);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
Thread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReloadTextureIcons(ISingleTextureIconLoader textureIcon)
|
||||||
|
{
|
||||||
|
if (Thread != null && Thread.IsAlive)
|
||||||
|
Thread.Abort();
|
||||||
|
|
||||||
|
Thread = new Thread((ThreadStart)(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var image = textureIcon.IconTexture.GetBitmap();
|
||||||
|
AddImageOnThread(image, textureIcon.IconTexture);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.ToString());
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
Thread.Start();
|
Thread.Start();
|
||||||
}
|
}
|
||||||
|
@ -149,7 +176,6 @@ namespace Toolbox.Library
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
Thread.Start();
|
Thread.Start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddImageOnThread(Image image, TreeNode node)
|
public void AddImageOnThread(Image image, TreeNode node)
|
||||||
|
|
|
@ -101,6 +101,10 @@ namespace Toolbox.Library.Forms
|
||||||
ClearNodes();
|
ClearNodes();
|
||||||
treeViewCustom1.Nodes.Add(node); // Add the new nodes
|
treeViewCustom1.Nodes.Add(node); // Add the new nodes
|
||||||
treeViewCustom1.EndUpdate(); // Allow the treeview to update visually
|
treeViewCustom1.EndUpdate(); // Allow the treeview to update visually
|
||||||
|
|
||||||
|
if (node is ISingleTextureIconLoader) {
|
||||||
|
LoadGenericTextureIcons((ISingleTextureIconLoader)node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearNodes()
|
public void ClearNodes()
|
||||||
|
@ -660,6 +664,11 @@ namespace Toolbox.Library.Forms
|
||||||
treeViewCustom1.ReloadTextureIcons(iconList);
|
treeViewCustom1.ReloadTextureIcons(iconList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadGenericTextureIcons(ISingleTextureIconLoader iconTex) {
|
||||||
|
treeViewCustom1.SingleTextureIcons.Add(iconTex);
|
||||||
|
treeViewCustom1.ReloadTextureIcons(iconTex);
|
||||||
|
}
|
||||||
|
|
||||||
private void nodeSizeCB_SelectedIndexChanged(object sender, EventArgs e)
|
private void nodeSizeCB_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var nodeSize = nodeSizeCB.SelectedItem;
|
var nodeSize = nodeSizeCB.SelectedItem;
|
||||||
|
@ -690,6 +699,9 @@ namespace Toolbox.Library.Forms
|
||||||
if (e.Node != null && e.Node is ITextureIconLoader) {
|
if (e.Node != null && e.Node is ITextureIconLoader) {
|
||||||
LoadGenericTextureIcons((ITextureIconLoader)e.Node);
|
LoadGenericTextureIcons((ITextureIconLoader)e.Node);
|
||||||
}
|
}
|
||||||
|
if (e.Node != null && e.Node is ISingleTextureIconLoader) {
|
||||||
|
LoadGenericTextureIcons((ISingleTextureIconLoader)e.Node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,11 @@ namespace Toolbox.Library
|
||||||
{
|
{
|
||||||
List<STGenericTexture> IconTextureList { get; set; }
|
List<STGenericTexture> IconTextureList { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Reprenets a single texture that loads an icon.
|
||||||
|
//These will check both on expand, and on root
|
||||||
|
public interface ISingleTextureIconLoader
|
||||||
|
{
|
||||||
|
STGenericTexture IconTexture { get;}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue