Add archive menu to opened archive files
This commit is contained in:
parent
3018004ae9
commit
f4506d9b63
@ -158,8 +158,8 @@ namespace FirstPlugin.Forms
|
||||
OnLoadedTab();
|
||||
}
|
||||
|
||||
public override void OnControlClosing()
|
||||
{
|
||||
public override void OnControlClosing() {
|
||||
animationPanel.ClosePanel();
|
||||
}
|
||||
|
||||
private void OnLoadedTab()
|
||||
|
@ -9,6 +9,7 @@ bin/pokemon/pm0000_00/anm/pm0000_00_battle01.gfbanmcfg
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_capture01.gfbanmcfg
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_camp.gfbanmcfg
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_app01.gfbanmcfg
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_ba01_land01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_ba01_landA01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_ba01_landB01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_ba01_landC01.gfbanm
|
||||
@ -31,7 +32,12 @@ bin/pokemon/pm0000_00/anm/pm0000_00_fi31_run_wait01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_fi31_wait_run01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_mouth01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_gloop01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_loop01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_eye01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_eye01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_cm10_bawait_kwwait01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_cm10_kwwait_bawait01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_kw01_wait01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_kw10_respond01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_kw11_turnA01.gfbanm
|
||||
bin/pokemon/pm0000_00/anm/pm0000_00_kw11_turnB01.gfbanm
|
||||
|
@ -64,8 +64,14 @@ namespace Toolbox.Library.Forms
|
||||
{
|
||||
if (FileRoot.FileNodes[i].Item2 is ArchiveFileWrapper)
|
||||
{
|
||||
try {
|
||||
((ArchiveFileWrapper)FileRoot.FileNodes[i].Item2).OpenFileFormat(treeViewCustom1);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -310,18 +316,18 @@ namespace Toolbox.Library.Forms
|
||||
|
||||
private void GetArchiveMenus(TreeNode node, ArchiveFileInfo info)
|
||||
{
|
||||
STToolStipMenuItem menuItem = new STToolStipMenuItem("Archive");
|
||||
treeNodeContextMenu.Items.Add(menuItem);
|
||||
|
||||
var items = info.FileWrapper.GetContextMenuItems();
|
||||
foreach (var item in items)
|
||||
menuItem.DropDownItems.Add(item);
|
||||
}
|
||||
|
||||
private void treeViewCustom1_MouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
if (e.Node is IContextMenuNode)
|
||||
{
|
||||
bool IsRoot = e.Node.Parent == null;
|
||||
bool HasChildren = e.Node.Nodes.Count > 0;
|
||||
|
||||
treeNodeContextMenu.Items.Clear();
|
||||
if (e.Node.Tag != null && e.Node.Tag is ArchiveFileInfo)
|
||||
{
|
||||
@ -331,6 +337,11 @@ namespace Toolbox.Library.Forms
|
||||
GetArchiveMenus(e.Node, (ArchiveFileInfo)e.Node.Tag);
|
||||
}
|
||||
|
||||
if (e.Node is IContextMenuNode)
|
||||
{
|
||||
bool IsRoot = e.Node.Parent == null;
|
||||
bool HasChildren = e.Node.Nodes.Count > 0;
|
||||
|
||||
if (IsRoot)
|
||||
{
|
||||
foreach (var item in ((IContextMenuNode)e.Node).GetContextMenuItems())
|
||||
@ -361,14 +372,15 @@ namespace Toolbox.Library.Forms
|
||||
if (!HasExpand && HasChildren)
|
||||
treeNodeContextMenu.Items.Add(new ToolStripMenuItem("Expand All", null, ExpandAllAction, Keys.Control | Keys.P));
|
||||
|
||||
treeNodeContextMenu.Show(Cursor.Position);
|
||||
|
||||
//Select the node without the evemt
|
||||
//We don't want editors displaying on only right clicking
|
||||
SuppressAfterSelectEvent = true;
|
||||
treeViewCustom1.SelectedNode = e.Node;
|
||||
SuppressAfterSelectEvent = false;
|
||||
}
|
||||
|
||||
if (treeNodeContextMenu.Items.Count > 0)
|
||||
treeNodeContextMenu.Show(Cursor.Position);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -493,6 +505,19 @@ namespace Toolbox.Library.Forms
|
||||
LibraryGUI.GetAnimationPanel().CurrentAnimation = running;
|
||||
}
|
||||
}
|
||||
if (Node is IAnimationContainer)
|
||||
{
|
||||
Viewport viewport = LibraryGUI.GetActiveViewport();
|
||||
if (viewport == null)
|
||||
return;
|
||||
|
||||
var running = ((IAnimationContainer)Node).AnimationController;
|
||||
if (LibraryGUI.GetAnimationPanel() != null) {
|
||||
Console.WriteLine($"running {Node.Tag}");
|
||||
|
||||
LibraryGUI.GetAnimationPanel().CurrentSTAnimation = running;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveFile(TreeNode File)
|
||||
|
@ -126,7 +126,7 @@ namespace Toolbox.Library
|
||||
[Browsable(false)]
|
||||
public virtual Dictionary<string, string> ExtensionImageKeyLookup { get; }
|
||||
|
||||
public virtual void Replace()
|
||||
public virtual bool Replace()
|
||||
{
|
||||
string fileName = Path.GetFileName(FileName.RemoveIllegaleFileNameCharacters());
|
||||
|
||||
@ -138,7 +138,9 @@ namespace Toolbox.Library
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
FileData = File.ReadAllBytes(ofd.FileName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void Export()
|
||||
@ -675,7 +677,7 @@ namespace Toolbox.Library
|
||||
{
|
||||
new STToolStripItem("Rename", RenameAction) { Enabled = ArchiveFile.CanRenameFiles },
|
||||
new STToolStripItem("Extract Folder", ExtractAction),
|
||||
new STToolStripItem("Replace Folder", ReplaceAction) { Enabled = ArchiveFile.CanReplaceFiles },
|
||||
new STToolStripItem("Replace Folder", ReplaceAction) { Enabled = ArchiveFile.CanReplaceFiles && ArchiveFile.CanAddFiles },
|
||||
new STToolStripItem("Delete Folder", DeleteAction) { Enabled = ArchiveFile.CanDeleteFiles },
|
||||
new STToolStripSeparator(),
|
||||
new STToolStripItem("Add Folder", AddFolderAction) { Enabled = ArchiveFile.CanAddFiles },
|
||||
@ -799,6 +801,7 @@ namespace Toolbox.Library
|
||||
Extension = FindMatch(archiveFileInfo.FileData);
|
||||
}
|
||||
|
||||
|
||||
switch (Extension)
|
||||
{
|
||||
case ".bntx": SetImageKey("bntx"); break;
|
||||
@ -807,6 +810,7 @@ namespace Toolbox.Library
|
||||
case ".aamp": SetImageKey("aamp"); break;
|
||||
case ".bfres": SetImageKey("bfres"); break;
|
||||
case ".sbfres": SetImageKey("sbfres"); break;
|
||||
case ".gfbmdl": SetImageKey("model"); break;
|
||||
case ".dds":
|
||||
case ".tga":
|
||||
case ".jpg":
|
||||
@ -932,15 +936,54 @@ namespace Toolbox.Library
|
||||
DialogResult result = MessageBox.Show($"Are your sure you want to remove {Text}? This cannot be undone!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
ArchiveFile.DeleteFile(ArchiveFileInfo);
|
||||
bool isRemoved = ArchiveFile.DeleteFile(ArchiveFileInfo);
|
||||
if (!isRemoved) return;
|
||||
|
||||
if (Parent != null)
|
||||
Parent.Nodes.Remove(this);
|
||||
else if (ArchiveFileInfo.FileFormat != null &&
|
||||
ArchiveFileInfo.FileFormat is TreeNode)
|
||||
{
|
||||
var prevNode = (TreeNode)ArchiveFileInfo.FileFormat;
|
||||
var parent = prevNode.Parent;
|
||||
|
||||
var index = parent.Nodes.IndexOf(prevNode);
|
||||
parent.Nodes.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReplaceAction(object sender, EventArgs args)
|
||||
{
|
||||
ArchiveFileInfo.Replace();
|
||||
if (!ArchiveFile.CanReplaceFiles) return;
|
||||
|
||||
bool IsReplaced = ArchiveFileInfo.Replace();
|
||||
if (!IsReplaced) return;
|
||||
|
||||
if (ArchiveFileInfo.FileFormat != null)
|
||||
{
|
||||
if (ArchiveFileInfo.FileFormat is IArchiveFile)
|
||||
{
|
||||
|
||||
}
|
||||
if (ArchiveFileInfo.FileFormat is TreeNode)
|
||||
{
|
||||
var prevNode = (TreeNode)ArchiveFileInfo.FileFormat;
|
||||
var parent = prevNode.Parent;
|
||||
|
||||
var index = parent.Nodes.IndexOf(prevNode);
|
||||
parent.Nodes.RemoveAt(index);
|
||||
parent.Nodes.Insert(index, this);
|
||||
}
|
||||
|
||||
ArchiveFileInfo.FileFormat.Unload();
|
||||
ArchiveFileInfo.FileFormat = null;
|
||||
Nodes.Clear();
|
||||
|
||||
ArchiveFileInfo.OpenFile();
|
||||
OpenFileFormat(TreeView);
|
||||
}
|
||||
|
||||
UpdateEditor();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user