46 lines
No EOL
1.3 KiB
C#
46 lines
No EOL
1.3 KiB
C#
#if TOOLS
|
|
|
|
using Godot;
|
|
using System.Linq;
|
|
|
|
namespace PT;
|
|
|
|
[Tool]
|
|
public partial class PtContextMenuPlugin : EditorContextMenuPlugin
|
|
{
|
|
public void MarkAsPlaceholder(Variant filesVariant)
|
|
{
|
|
// TODO: recursively mark folders
|
|
var files = (string[])filesVariant;
|
|
if (files == null) return;
|
|
|
|
foreach (var fileName in files)
|
|
{
|
|
var file = FileAccess.Open(fileName + PlaceholderTracker.TODO_EXTENSION, FileAccess.ModeFlags.Write);
|
|
file.Close();
|
|
}
|
|
}
|
|
|
|
public void MarkAsReadyForRelease(Variant filesVariant)
|
|
{
|
|
// TODO: recursively mark folders
|
|
var files = (string[])filesVariant;
|
|
if (files == null) return;
|
|
|
|
foreach (var fileName in files)
|
|
{
|
|
DirAccess.RemoveAbsolute(fileName + PlaceholderTracker.TODO_EXTENSION);
|
|
}
|
|
}
|
|
|
|
public override void _PopupMenu(string[] paths)
|
|
{
|
|
if (paths.Any(path => !PlaceholderTracker.IsFilePlaceholder(path)))
|
|
AddContextMenuItem("Mark as placeholder", new Callable(this, MethodName.MarkAsPlaceholder));
|
|
|
|
if (paths.Any(path => PlaceholderTracker.IsFilePlaceholder(path)))
|
|
AddContextMenuItem("Mark as ready for release", new Callable(this, MethodName.MarkAsReadyForRelease));
|
|
}
|
|
}
|
|
|
|
#endif |