-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Add prompt to save scripts on quit [4.0] #55586
Conversation
42f8b90
to
5e1fbea
Compare
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.
Seems okay, couple comments inline, though I do wonder about ordering, whether we should save the scenes first, then the scripts.
Also whether we need to do something similar for the shader editor.
5e1fbea
to
0f46930
Compare
I think it makes the most sense to save scripts before scenes, partly because it seems intuitive to me to save the 'resources' before the scenes which utilise them, but mainly due to the option to save each scene individually. If you're not paying much attention (e.g. simply pressing enter for every 'save scene' dialog) you could just accidentally save all scripts without even knowing what the unsaved scripts were. I'm happy to discuss this further though.
Good point - I think this is a good idea, but should I implement it in a future PR instead? I'd like to keep this one fairly small, especially since I'm now making some wider changes to allow script discarding. I believe your suggestion goes hand in hand with handling of built-in scripts, which are slightly weird because saving them necessarily saves their scene, and vice-versa. When I make a PR for this I might simply add text to warn the user of this, or maybe implement something to mitigate this effect. |
0f46930
to
50f9aab
Compare
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 don't think there's necessarily a right order as it could be argued that changing a scene involves it's resources. I was thinking here if we could avoid additional popups. Though thinking about it, that would only apply to built-in scripts?
} | ||
|
||
// User has chosen to save scripts before quit. | ||
editor_data.get_editor("Script")->save_external_data(); |
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.
Do we need to call this at all here, as when the editor exits it's called automatically?
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.
Good point, thank you - I forgot about that, I'll test it with the line removed.
I was a bit vague by saying 'resources' - I meant specifically external scripts, and in my local version built-in scripts are included in the popup with a message informing the user that they will be saved when their scenes are. I'm not sure what you mean about avoiding additional popups - I only add one popup asking to save all external scripts and listing them, and I don't think this can (or should) be avoided. Could you clarify this for me please? |
By the way, I've been having a lot of trouble discarding scripts, which is why I haven't updated this PR with my updated version yet. Part of my message to the contributors chat on the subject:
@KoBeWi helped me out with |
Start of another conversation relating to usability of the popup: https://chat.godotengine.org/channel/devel?msg=BABJmMxA8mX5sgFEu |
For popups I was thinking if we save the scene first that will in turn save the scrips, so we could avoid having this popup appear under that use case. For As for |
Isn't the purpose of this to show the user which script changes will be saved so that they can change their mind? For example, they might have temporarily changed or deleted some code and forgotten about it. Do you think it's more important that scripts are simply always saved on quit (i.e. when scenes are or with a dedicated prompt otherwise)? Not criticising, I think I just misunderstood your intention.
I added some behaviour for That usability discussion is interesting, I think it's a shame it was never picked up. Maybe some broader work is needed which would integrate improved script-saving behaviour with a more comprehensive scene-saving UI? |
I guess it would depend if you see scenes as entirely separate entities to scripts. As a change in a script could be considered a change in the scene. Unless the script is not part of any scene. In which case it would be shown as a popup here. But I released that would only really apply to built-in scripts. So this approach does make more sense for the common usecase. Personally not a fan of permanent temporary workarounds, would much rather wait for that other bug to get fixed first. Yeah to get usability right would probably require some broader development in some way, shape, or form. I think for now what we have is good enough. Could chuck it in an |
That's what I was thinking of, yeah - to me external scripts being saved when scenes are (which are entirely separate files that have references to scripts) is confusing to the user and could result in data loss if they messed around with their scripts in testing. I agree, I don't want to add 'temporary' statefulness that will probably interact weirdly with other things and confuse contributors. The PR can probably wait until scripts have a nice way of being discarded. I might look into using an |
I'm thinking about implementing a generic solution for all editor plugins: |
Superseded by #67503. |
Fix #55026