godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Add option to copy file name to FileSystem #10173

Open Arnklit opened 2 months ago

Arnklit commented 2 months ago

Describe the project you are working on

A game in production

Describe the problem or limitation you are having in your project

Often when working on a project with a bigger team you need to communicate about assets, so often we need to get a name of an asset in the project. The "Copy Path" is very useful for this, but sometimes we just want the name of the file, not the full path.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add the option to copy just the file name to the right click menu

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I understand that we shouldn't bloat the right click menu, so I was thinking that maybe the option could show up when toggling with the "alt/option" key, similar to how right click menus often work on MacOS

image

If this enhancement will not be used often, can it be worked around with a few lines of script?

This could probably be worked around with an addon, but would not be very convenient

Is there a reason why this should be core and not an add-on in the asset library?

This is about improving the editor experience out of the box.

m21-cerutti commented 2 months ago

Maybe to not bloat right-click menu we could also have a create > path, filename, UID in a sub section like new. But I think we would need some UX verification about the most used options to keep the most used at the root menu.

Calinou commented 2 months ago

Maybe to not bloat right-click menu we could also have a create > path, filename, UID in a sub section like new. But I think we would need some UX verification about the most used options to keep the most used at the root menu.

Having a submenu for this would require either an additional click, or waiting for the submenu to open. I've rarely seen "Copy" options be in a submenu in most other apps for this reason.

KoBeWi commented 1 week ago

This could probably be worked around with an addon, but would not be very convenient

Possible with the new EditorContextMenuPlugin in 4.4:

@tool
extends EditorPlugin

func _enter_tree() -> void:
    add_context_menu_plugin(CONTEXT_SLOT_FILESYSTEM, CopyNamePlugin.new())

class CopyNamePlugin extends EditorContextMenuPlugin:
    func _popup_menu(paths: PackedStringArray) -> void:
        add_context_menu_item("Copy Name", func(paths: PackedStringArray):
            if not paths.is_empty():
                DisplayServer.clipboard_set(paths[0].get_basename()))

The only inconvenient part is that it appears at the bottom.

image

Arnklit commented 1 week ago

That is actually lovely @KoBeWi ... I figured you still had to "hack" that menu to do it. I personally would love for it to be built in as it makes a lot of sense when working in bigger teams where you often reference assets in communications, but at least it will be very easy to make it as an addon if it doesn't get added in.