1
0
mirror of synced 2024-12-02 19:17:24 +01:00

Improve nutexb context menus

This commit is contained in:
KillzXGaming 2019-08-16 17:18:44 -04:00
parent 655cdff142
commit de84563377
5 changed files with 49 additions and 64 deletions

Binary file not shown.

View File

@ -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,17 +313,11 @@ 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();
ofd.Filter = FileFilters.NUTEXB;
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{ {
var bntxFile = new BNTX(); var bntxFile = new BNTX();
var tex = new TextureData(); var tex = new TextureData();
tex.Replace(ofd.FileName, MipCount,0, Format); tex.Replace(FileName, MipCount, 0, Format);
//If it's null, the operation is cancelled //If it's null, the operation is cancelled
if (tex.Texture == null) if (tex.Texture == null)
@ -368,15 +362,8 @@ namespace FirstPlugin
UpdateEditor(); 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();
} }

View File

@ -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));