Initial commit

This commit is contained in:
Иван Кузьменко 2025-02-01 07:45:07 +03:00
commit bb075d6353
20 changed files with 336 additions and 0 deletions

View file

@ -0,0 +1,46 @@
#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