Skip to content
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

Disable editing properties in foreign resources #63282

Merged

Conversation

SaracenOne
Copy link
Member

@SaracenOne SaracenOne commented Jul 21, 2022

This PR adds new behaviour to the inspector to prevent the user from accidentally editing properties of resources embedded in other scenes (foreign resources) since these will not be saved and can lead to changes accidentally being lost the user assumes will be persistent. Editing these resources can still be possible by right-clicking on them and selecting 'edit', which will follow the pre-existing behaviour of opening up the corresponding scene and displaying it in the inspector. For resources which are embedded inside of imported scenes (those derived from imported formats such as GLTF) however, the 'edit' option will be replaced by an inspect option which will still switch the inspector this resource, but will not change the scene and instead display it in a 'read-only' fashion.

The InspectorDock warning button has also been changed to provide clarity when inspecting read-only objects. It is also now considered a more general info button due to considering the displaying of a read-only state to be more informative than warning-worthy, which also includes a new icon when displaying something considered information rather than a warning (flipping an existing exclamation mark vector and putting it inside a circle, a true stroke of genius! Clearly, I must be made Godot's new resident graphics designer)

godot windows opt tools 64_qvOUfoCQTJ

godot windows opt tools 64_UEw3tz2iGZ

Furthermore, read-only mode is also applied to remote debug inspector objects with its own contextual information.

godot windows opt tools 64_oKSCa31LQQ

Intended to compliment similar changes to bespoke editor plugins in:
#63249 #63245 #63253 #63252 #63251

@Zireael07
Copy link
Contributor

Yay, I've had more than one case of editing something and then "wtf where did my changes go?", presumably due to this.

@Calinou Calinou added this to the 4.0 milestone Jul 21, 2022
@Calinou
Copy link
Member

Calinou commented Jul 21, 2022

Looks good!

Could you increase the opacity of read-only properties slightly? The text contrast rate against the background is a bit low right now.

@SaracenOne
Copy link
Member Author

SaracenOne commented Jul 21, 2022

@Calinou How does this look? I changed the blending to pure black and pure white on the dark and light themes respectively from 0.5 to 0.25 for the readonly color
godot windows opt tools 64_e9ItadO1Uq
godot windows opt tools 64_EdCoW5n5rM

That being said, I notice the the warning color is pretty bad on the light theme. That might be worth chaning too, but I'm not sure what a good colour would be.

@Calinou
Copy link
Member

Calinou commented Jul 21, 2022

How does this look? I changed the blending to pure black and pure white on the dark and light themes respectively from 0.5 to 0.25 for the readonly color

Looks good to me now 🙂

@SaracenOne SaracenOne force-pushed the disable_foreign_resource_edits branch from 19da8be to 61bd0ad Compare July 21, 2022 17:17
@SaracenOne
Copy link
Member Author

SaracenOne commented Jul 21, 2022

Okay, it's now been updated with improved read-only colors

@reduz
Copy link
Member

reduz commented Aug 8, 2022

Awesome, you are my hero!

@KoBeWi
Copy link
Member

KoBeWi commented Aug 8, 2022

How does it relate to #59496? Editing foreign resources in the inspector should already be impossible.

editor/editor_node.cpp Outdated Show resolved Hide resolved
editor/editor_node.cpp Show resolved Hide resolved
@@ -212,7 +253,7 @@ void EditorResourcePicker::_update_menu_items() {
}

// Add options to convert existing resource to another type of resource.
if (edited_resource.is_valid()) {
if (is_editable() && edited_resource.is_valid()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind if the base scene is editable (instantiated or inherited), even if the subresource is not editable you can still replace it by another custom one and this change will be kept.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I'm able to tell, the behaviour invoked by using the is_editable function should be correct, as in, the conversion options won't appear if a resource is part of another non-editable resource, but it will still appear if its a node property, irrespective of whether its instantiated or inherited.

editor/editor_resource_picker.h Outdated Show resolved Hide resolved
editor/editor_inspector.cpp Show resolved Hide resolved
@reduz
Copy link
Member

reduz commented Aug 8, 2022

Really good work, some changes noted and needs a rebase.

@reduz
Copy link
Member

reduz commented Aug 8, 2022

@KoBeWi I think both should be complementary, possibly with an extra option in the picker "Edit in its own scene"

@reduz
Copy link
Member

reduz commented Aug 8, 2022

This feature also should be useful to extend VCS support to show locked files non-editable too.

@SaracenOne
Copy link
Member Author

SaracenOne commented Aug 9, 2022

Okay, I shall update this and address the concerns. I like the notion of extending this to VCS locking; that slipped my mind

@reduz
Copy link
Member

reduz commented Aug 18, 2022

Reminder to update this, would be good to have for Beta.

@SaracenOne
Copy link
Member Author

Shoot, sorry about the delay. Other things have been causing a lot of distractions for me lately.

@SaracenOne SaracenOne force-pushed the disable_foreign_resource_edits branch 3 times, most recently from 4ce8795 to 1f9ea76 Compare August 18, 2022 15:20
@SaracenOne
Copy link
Member Author

Okay, @reduz, I've made changes to this and I think it's okay now

editor/icons/NodeInfo.svg Outdated Show resolved Hide resolved
@KoBeWi
Copy link
Member

KoBeWi commented Aug 20, 2022

Is this supposed to handle every property? It's still possible to edit a shader in a foreign shader material.

@reduz
Copy link
Member

reduz commented Aug 22, 2022

@KoBeWi This is inspector only, for the other editors there are separate PRs

editor/editor_node.cpp Outdated Show resolved Hide resolved
editor/editor_node.cpp Outdated Show resolved Hide resolved
editor/editor_node.cpp Outdated Show resolved Hide resolved
editor/inspector_dock.h Outdated Show resolved Hide resolved
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks, but seems good to merge overall. See also KoBeWi's comment about optimizing the SVG.

@SaracenOne SaracenOne force-pushed the disable_foreign_resource_edits branch 2 times, most recently from 2db90a2 to e8215d0 Compare August 23, 2022 22:11
from imported scenes or objects returning
true from a function named '_is_read_only' and
disable resaving imported resources.
@SaracenOne SaracenOne force-pushed the disable_foreign_resource_edits branch from e8215d0 to dd814a0 Compare August 23, 2022 22:16
@SaracenOne
Copy link
Member Author

The SVG icon should be properly optimized in the latest version. I followed the instructions @KoBeWi linked, so it should be okay unless I did something wrong.

@akien-mga akien-mga merged commit 792f7cc into godotengine:master Aug 24, 2022
@akien-mga
Copy link
Member

Thanks!

@fire fire deleted the disable_foreign_resource_edits branch September 16, 2022 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants