Improve nutexb context menus
This commit is contained in:
parent
655cdff142
commit
de84563377
Binary file not shown.
@ -173,7 +173,7 @@ namespace FirstPlugin
|
|||||||
editor.LoadImage(this);
|
editor.LoadImage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UseSizeRestrictions(object sender, EventArgs args)
|
private void UseSizeRestrictionsAction(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
if (sender is STToolStripItem)
|
if (sender is STToolStripItem)
|
||||||
{
|
{
|
||||||
@ -313,70 +313,57 @@ namespace FirstPlugin
|
|||||||
public override string ExportFilter => FileFilters.NUTEXB;
|
public override string ExportFilter => FileFilters.NUTEXB;
|
||||||
public override string ReplaceFilter => FileFilters.NUTEXB;
|
public override string ReplaceFilter => FileFilters.NUTEXB;
|
||||||
|
|
||||||
private void Replace(object sender, EventArgs args)
|
public override void Replace(string FileName)
|
||||||
{
|
{
|
||||||
OpenFileDialog ofd = new OpenFileDialog();
|
var bntxFile = new BNTX();
|
||||||
ofd.Filter = FileFilters.NUTEXB;
|
var tex = new TextureData();
|
||||||
|
tex.Replace(FileName, MipCount, 0, Format);
|
||||||
|
|
||||||
ofd.Multiselect = false;
|
//If it's null, the operation is cancelled
|
||||||
if (ofd.ShowDialog() == DialogResult.OK)
|
if (tex.Texture == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var surfacesNew = tex.GetSurfaces();
|
||||||
|
var surfaces = GetSurfaces();
|
||||||
|
|
||||||
|
if (LimitFileSize)
|
||||||
{
|
{
|
||||||
var bntxFile = new BNTX();
|
if (surfaces[0].mipmaps[0].Length != surfacesNew[0].mipmaps[0].Length)
|
||||||
var tex = new TextureData();
|
throw new Exception($"Image must be the same size! {surfaces[0].mipmaps[0].Length}");
|
||||||
tex.Replace(ofd.FileName, MipCount,0, Format);
|
|
||||||
|
|
||||||
//If it's null, the operation is cancelled
|
if (mipSizes[0].Length != surfacesNew[0].mipmaps.Count)
|
||||||
if (tex.Texture == null)
|
throw new Exception($"Mip map count must be the same! {mipSizes[0].Length}");
|
||||||
return;
|
|
||||||
|
|
||||||
var surfacesNew = tex.GetSurfaces();
|
if (Width != tex.Texture.Width || Height != tex.Texture.Height)
|
||||||
var surfaces = GetSurfaces();
|
throw new Exception("Image size must be the same!");
|
||||||
|
|
||||||
if (LimitFileSize)
|
ImageData = tex.Texture.TextureData[0][0];
|
||||||
{
|
|
||||||
if (surfaces[0].mipmaps[0].Length != surfacesNew[0].mipmaps[0].Length)
|
|
||||||
throw new Exception($"Image must be the same size! {surfaces[0].mipmaps[0].Length}");
|
|
||||||
|
|
||||||
if (mipSizes[0].Length != surfacesNew[0].mipmaps.Count)
|
Width = tex.Texture.Width;
|
||||||
throw new Exception($"Mip map count must be the same! {mipSizes[0].Length}");
|
Height = tex.Texture.Height;
|
||||||
|
MipCount = tex.Texture.MipCount;
|
||||||
if (Width != tex.Texture.Width || Height != tex.Texture.Height)
|
|
||||||
throw new Exception("Image size must be the same!");
|
|
||||||
|
|
||||||
ImageData = tex.Texture.TextureData[0][0];
|
|
||||||
|
|
||||||
Width = tex.Texture.Width;
|
|
||||||
Height = tex.Texture.Height;
|
|
||||||
MipCount = tex.Texture.MipCount;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ImageData = tex.Texture.TextureData[0][0];
|
|
||||||
|
|
||||||
Width = tex.Texture.Width;
|
|
||||||
Height = tex.Texture.Height;
|
|
||||||
MipCount = tex.Texture.MipCount;
|
|
||||||
|
|
||||||
Format = tex.Format;
|
|
||||||
NutFormat = ConvertGenericToNutFormat(tex.Format);
|
|
||||||
|
|
||||||
mipSizes = TegraX1Swizzle.GenerateMipSizes(tex.Format, tex.Width, tex.Height, tex.Depth, tex.ArrayCount, tex.MipCount, (uint)ImageData.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
surfacesNew.Clear();
|
|
||||||
surfaces.Clear();
|
|
||||||
|
|
||||||
UpdateEditor();
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImageData = tex.Texture.TextureData[0][0];
|
||||||
|
|
||||||
|
Width = tex.Texture.Width;
|
||||||
|
Height = tex.Texture.Height;
|
||||||
|
MipCount = tex.Texture.MipCount;
|
||||||
|
|
||||||
|
Format = tex.Format;
|
||||||
|
NutFormat = ConvertGenericToNutFormat(tex.Format);
|
||||||
|
|
||||||
|
mipSizes = TegraX1Swizzle.GenerateMipSizes(tex.Format, tex.Width, tex.Height, tex.Depth, tex.ArrayCount, tex.MipCount, (uint)ImageData.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
surfacesNew.Clear();
|
||||||
|
surfaces.Clear();
|
||||||
|
|
||||||
|
UpdateEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SaveAction(object sender, EventArgs args)
|
||||||
|
|
||||||
private void Export(object sender, EventArgs args)
|
|
||||||
{
|
|
||||||
ExportImage();
|
|
||||||
}
|
|
||||||
private void Save(object sender, EventArgs args)
|
|
||||||
{
|
{
|
||||||
SaveFileDialog sfd = new SaveFileDialog();
|
SaveFileDialog sfd = new SaveFileDialog();
|
||||||
sfd.Filter = Utils.GetAllFilters(this);
|
sfd.Filter = Utils.GetAllFilters(this);
|
||||||
@ -591,14 +578,15 @@ namespace FirstPlugin
|
|||||||
return TegraX1Swizzle.GetImageData(this, ImageData, ArrayLevel, MipLevel, 1);
|
return TegraX1Swizzle.GetImageData(this, ImageData, ArrayLevel, MipLevel, 1);
|
||||||
}
|
}
|
||||||
ToolStripMenuItem save = new ToolStripMenuItem("Save");
|
ToolStripMenuItem save = new ToolStripMenuItem("Save");
|
||||||
ToolStripMenuItem export = new ToolStripMenuItem("Export");
|
|
||||||
ToolStripMenuItem replace = new ToolStripMenuItem("Replace");
|
|
||||||
ToolStripMenuItem useSizeRestrictions = new ToolStripMenuItem("UseSizeRestrictions");
|
ToolStripMenuItem useSizeRestrictions = new ToolStripMenuItem("UseSizeRestrictions");
|
||||||
|
|
||||||
public void Load(System.IO.Stream stream)
|
public void Load(System.IO.Stream stream)
|
||||||
{
|
{
|
||||||
Text = FileName;
|
Text = FileName;
|
||||||
CanSave = true;
|
CanSave = true;
|
||||||
|
CanReplace = true;
|
||||||
|
CanRename = true;
|
||||||
|
CanDelete = true;
|
||||||
|
|
||||||
Read(new FileReader(stream));
|
Read(new FileReader(stream));
|
||||||
|
|
||||||
@ -607,18 +595,15 @@ namespace FirstPlugin
|
|||||||
|
|
||||||
useSizeRestrictions.Checked = true;
|
useSizeRestrictions.Checked = true;
|
||||||
|
|
||||||
save.Click += Save;
|
save.Click += SaveAction;
|
||||||
replace.Click += Replace;
|
|
||||||
export.Click += Export;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolStripItem[] GetContextMenuItems()
|
public ToolStripItem[] GetContextMenuItems()
|
||||||
{
|
{
|
||||||
List<ToolStripItem> Items = new List<ToolStripItem>();
|
List<ToolStripItem> Items = new List<ToolStripItem>();
|
||||||
Items.Add(save);
|
|
||||||
Items.Add(useSizeRestrictions);
|
Items.Add(useSizeRestrictions);
|
||||||
Items.Add(export);
|
Items.Add(new STToolStipMenuItem("Save", null, SaveAction, Keys.Control | Keys.S));
|
||||||
Items.Add(replace);
|
Items.AddRange(base.GetContextMenuItems());
|
||||||
return Items.ToArray();
|
return Items.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ namespace Toolbox.Library.Forms
|
|||||||
{
|
{
|
||||||
foreach (var item in ((IContextMenuNode)e.Node).GetContextMenuItems())
|
foreach (var item in ((IContextMenuNode)e.Node).GetContextMenuItems())
|
||||||
{
|
{
|
||||||
if (item.Text != "Delete" || item.Text != "Remove")
|
if (item.Text != "Delete" && item.Text != "Remove")
|
||||||
treeNodeContextMenu.Items.Add(item);
|
treeNodeContextMenu.Items.Add(item);
|
||||||
}
|
}
|
||||||
treeNodeContextMenu.Items.Add(new ToolStripMenuItem("Delete", null, DeleteAction, Keys.Control | Keys.Delete));
|
treeNodeContextMenu.Items.Add(new ToolStripMenuItem("Delete", null, DeleteAction, Keys.Control | Keys.Delete));
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user