mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-16 17:11:28 +00:00
UDBScript: added an option to open the selected folder in the Explorer to the context menu of folder items in the file tree
This commit is contained in:
parent
1f13839dbd
commit
c62b8315c4
2 changed files with 36 additions and 11 deletions
|
@ -49,14 +49,16 @@ namespace CodeImp.DoomBuilder.UDBScript
|
|||
{
|
||||
internal class ScriptDirectoryStructure
|
||||
{
|
||||
public string Path;
|
||||
public string Name;
|
||||
public bool Expanded;
|
||||
public string Hash;
|
||||
public List<ScriptDirectoryStructure> Directories;
|
||||
public List<ScriptInfo> Scripts;
|
||||
|
||||
public ScriptDirectoryStructure(string name, bool expanded, string hash)
|
||||
public ScriptDirectoryStructure(string path, string name, bool expanded, string hash)
|
||||
{
|
||||
Path = path;
|
||||
Name = name;
|
||||
Expanded = expanded;
|
||||
Hash = hash;
|
||||
|
@ -386,7 +388,7 @@ namespace CodeImp.DoomBuilder.UDBScript
|
|||
string hash = SHA256Hash.Get(path);
|
||||
bool expanded = General.Settings.ReadPluginSetting("directoryexpand." + hash, true);
|
||||
string name = path.TrimEnd(Path.DirectorySeparatorChar).Split(Path.DirectorySeparatorChar).Last();
|
||||
ScriptDirectoryStructure sds = new ScriptDirectoryStructure(name, expanded, hash);
|
||||
ScriptDirectoryStructure sds = new ScriptDirectoryStructure(path, name, expanded, hash);
|
||||
|
||||
foreach (string directory in Directory.GetDirectories(path))
|
||||
sds.Directories.Add(LoadScriptDirectoryStructure(directory));
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Controls;
|
||||
|
@ -35,7 +36,8 @@ namespace CodeImp.DoomBuilder.UDBScript
|
|||
#region ================== Variables
|
||||
|
||||
private ImageList images;
|
||||
private ContextMenuStrip contextmenu;
|
||||
private ContextMenuStrip filecontextmenu;
|
||||
private ContextMenuStrip foldercontextmenu;
|
||||
ToolStripItem[] slotitems;
|
||||
|
||||
#endregion
|
||||
|
@ -63,7 +65,10 @@ namespace CodeImp.DoomBuilder.UDBScript
|
|||
|
||||
#region ================== Methods
|
||||
|
||||
private void CreateContextMenu()
|
||||
/// <summary>
|
||||
/// Creates the context menu for file items.
|
||||
/// </summary>
|
||||
private void CreateFileContextMenu()
|
||||
{
|
||||
ToolStripMenuItem edititem = new ToolStripMenuItem("Edit");
|
||||
edititem.Click += EditScriptClicked;
|
||||
|
@ -84,14 +89,29 @@ namespace CodeImp.DoomBuilder.UDBScript
|
|||
setslot.DropDownItems.AddRange(slotitems);
|
||||
setslot.DropDownItemClicked += ItemClicked;
|
||||
|
||||
contextmenu = new ContextMenuStrip();
|
||||
contextmenu.Items.AddRange(new ToolStripItem[]
|
||||
filecontextmenu = new ContextMenuStrip();
|
||||
filecontextmenu.Items.AddRange(new ToolStripItem[]
|
||||
{
|
||||
edititem,
|
||||
setslot
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the context menu for folder items.
|
||||
/// </summary>
|
||||
private void CreateFolderContextMenu()
|
||||
{
|
||||
ToolStripMenuItem openitem = new ToolStripMenuItem("Open in Explorer");
|
||||
openitem.Click += (s, e) => { try { Process.Start("explorer.exe", ((ScriptDirectoryStructure)filetree.SelectedNodes[0].Tag).Path); } catch { } };
|
||||
|
||||
foldercontextmenu = new ContextMenuStrip();
|
||||
foldercontextmenu.Items.AddRange(new ToolStripItem[]
|
||||
{
|
||||
openitem
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hotkey text for a script s lot.
|
||||
/// </summary>
|
||||
|
@ -112,7 +132,7 @@ namespace CodeImp.DoomBuilder.UDBScript
|
|||
/// <summary>
|
||||
/// Updates the context menu of the slots so that the items show the script name and hotkey (if applicable)
|
||||
/// </summary>
|
||||
private void UpdateContextMenu()
|
||||
private void UpdateFileContextMenu()
|
||||
{
|
||||
for (int i = 0; i < BuilderPlug.NUM_SCRIPT_SLOTS; i++)
|
||||
{
|
||||
|
@ -174,7 +194,7 @@ namespace CodeImp.DoomBuilder.UDBScript
|
|||
BuilderPlug.Me.SetScriptSlot((int)e.ClickedItem.Tag, si);
|
||||
}
|
||||
|
||||
UpdateContextMenu();
|
||||
UpdateFileContextMenu();
|
||||
|
||||
foreach (TreeNode node in filetree.Nodes)
|
||||
UpdateTree(node);
|
||||
|
@ -272,6 +292,7 @@ namespace CodeImp.DoomBuilder.UDBScript
|
|||
|
||||
tn.Tag = subsds;
|
||||
tn.SelectedImageKey = tn.ImageKey = "Folder";
|
||||
tn.ContextMenuStrip = foldercontextmenu;
|
||||
|
||||
if (subsds.Expanded)
|
||||
tn.Expand();
|
||||
|
@ -300,7 +321,7 @@ namespace CodeImp.DoomBuilder.UDBScript
|
|||
|
||||
tn.Tag = si;
|
||||
tn.SelectedImageKey = tn.ImageKey = "Script";
|
||||
tn.ContextMenuStrip = contextmenu;
|
||||
tn.ContextMenuStrip = filecontextmenu;
|
||||
|
||||
newnodes.Add(tn);
|
||||
}
|
||||
|
@ -406,8 +427,10 @@ namespace CodeImp.DoomBuilder.UDBScript
|
|||
if (!Visible || Disposing)
|
||||
return;
|
||||
|
||||
CreateContextMenu();
|
||||
UpdateContextMenu();
|
||||
CreateFileContextMenu();
|
||||
UpdateFileContextMenu();
|
||||
CreateFolderContextMenu();
|
||||
|
||||
FillTree();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue