Initial commit
This commit is contained in:
commit
bb075d6353
20 changed files with 336 additions and 0 deletions
46
addons/placeholder_tracker/PtContextMenuPlugin.cs
Normal file
46
addons/placeholder_tracker/PtContextMenuPlugin.cs
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue