-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Copy Paste feature for Scene Tree Dock #19327
Conversation
editor/scene_tree_dock.cpp
Outdated
if (copied_nodes.empty()) { | ||
current_option = -1; | ||
accept->get_ok()->set_text(TTR("I see...")); | ||
accept->set_text(TTR("Nothing in copy. Sorry Dude. Copy Something First.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normal sentence case should be used in dialogs (don't capitalize every word). Also, I would advise making it simpler and dropping the "Sorry Dude"; something like "Clipboard is empty, nothing to copy." should be enough.
editor/scene_tree_dock.cpp
Outdated
if (copied_nodes.empty()) { | ||
current_option = -1; | ||
accept->get_ok()->set_text(TTR("I see...")); | ||
accept->set_text(TTR("Nothing in copy. Sorry Dude. Copy Something First.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to change it sorry. It was just place holder back then.
Fixed the problems and squashed everything together. |
I thought this form of copy paste should use the system clipboard? (Would allow way more use cases) |
We really need a copy/paste that will work between scenes and on hierarchies. I seem to remember another PR from last year that did a similar thing to this one, and only pasted within the scene. Not sure how this is any better than just using the existing duplication functionality? |
@Zylann I know that but then again you will have to convert the nodes to actual nodes rather than reference cause references can't be saved if the original is closed, that means we have to implement conversion of references to instances and then store them on clipboard. I am rather new to programming on actual software. Mostly hackerrank. Realized that how much more real programmers need to work. Although I too want to implement it but the problem is I am currently trying to figure out blenders implementation of it which is rather perfect even allowing for inter-instance copy paste. @fracteed There are 2 advantages of this feature,
And I am not asking for this to become the copy-paste feature for Godot. I probably be back to visit the feature once I figure out the implementation that is used in Blender, which should be similar. Until then if it's the unanimous decision to close it then close it I shall. |
@swarnimarun don't let my comments deter you in the slightest, as I applaud any effort in this direction! Hopefully one of the more experienced devs can help you develop this into a cross scene copy/paste which is sorely needed :) Not sure if you looked at #14810 as it seems similar? |
@swarnimarun yeah I think it was mentionned somewhere it should work using serialization, a bit like scn. Using refs can be dangerous even within the same instance. |
@Zylann Was thinking of that, will be looking into it. @fracteed Yeah saw that PR now, it's not useful cause it's quite like mine just seems to be using node_path rather than actual copy and paste. Figuring out a proper implementation should not be that hard but well it's just that I experience level is quite low so it will be me running around in circles until I figure things out. But those things can't stop me, might(more like will) slow me down though. |
I wonder if this can be a bit like the copy params feature of the inspector, but copy a "tree branch" of parameters instead. |
@eon-s Yeah I thought the same thing, but the problem with that is we also have to be able to copy whole trees no matter the complexity and copying the params for all of them not a really good idea, so creating a new feature to do it is inevitable. |
So we have three WIP PRs for this kind of feature, we'll have to decide which one to focus on and eventually merge:
|
editor/scene_tree_dock.cpp
Outdated
@@ -1599,6 +1731,7 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node) { | |||
void SceneTreeDock::set_edited_scene(Node *p_scene) { | |||
|
|||
edited_scene = p_scene; | |||
copied_nodes.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It feels to me this will memleak, you should do a proper function to get rid of the nodes when you no longer need them
- Copying/Pasting nodes between scenes does look like a desired feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may also want to call the clear clipboard funciton on exit (NOTIFICATION_EXIT_TREE)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But only if node stuff is being copied. Why not copy serialized data instead? Would work across scenes, even if nodes are deleted, and perhaps even across instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created this PR while I was learning basics.
And, yeah @Zylann and @poke1024, I get that serialisation will be best.
I was earlier planning to write a function like _parse_nodes
(to serialize) from the Scene State,
And probably just keep the signals between the copied nodes and ignore the rest.
After that I could de-serialise on paste and the rest was simple.
I was still waiting for the right time to implement it, as it's a little new for me. And as, this will likely result in me redoing the whole copy paste feature.
And I was tight on time these days, as I just got busy with my College, just got in.
And from what I have been told, I think that without multi-scene or multi-instance copy-paste it's useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not really any risk in copying the nodes and keeping them in memory. Nodes are completely disabled while outside the scene tree. You can even copy them across scenes fine.
There really is no need to do serialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reduz there is if another unrelated part of the editor destroys them. If you delete them or close the scene for example.
I ask here to not add more noise to the review, about the serialization, won't it be better for the use of regular clipboard and keep cut/copy there even with the engine closed? |
@eon-s As a user: yes! As developer: might be tricky, as the serialized content might be large depending on the kind of tree/sub trees you copy and cannot keep refcounted objects without copying them. Ever got that dialog box from Excel "your clipboard is very large, do you really want to export it to the system clipboard?" Adds quite more complexity to serialization I guess. |
Gonna be reworking on this so probably gonna be a bit of noise here. |
Closing this for now. Will be redoing this one as a few things have changed since and this one doesn't even work anymore... |
There are a few issues with creating a proper copy and paste some also cause of my limited skill but I created this PR just for the basic Copy-Paste feature.
I have tried my best to use the existing API rather than add new things to the system to bloat it up.
Hopefully there isn't any problems, this is my first serious PR. Sorry in advance for wasting anyone's time.
I also added some new icons hope no one minds. I am not sure if there is a design philosophy behind the designs but I tried to maintain some uniformity.
The caveats with it are,
I would really like to fix the problems with the inter-scene stuff.Figured that there is only way that is to save data of the nodes separately and use it to create nodes in the specific scene but this will require creating more than I did like to do now.
So I will work on that later. For this I don't think much more can be done.