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

Rework the Configuration Warning system #90049

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RedMser
Copy link
Contributor

@RedMser RedMser commented Mar 30, 2024

Closes godotengine/godot-proposals#9416
Closes godotengine/godot-proposals#550 again
Closes godotengine/godot-proposals#9098
For my first attempt at implementing this (which has since been reverted), see #68420 and #88182

What this PR does

  • User facing changes
    • Configuration warnings are now a more general system called configuration info.
    • Configuration info is available not only on Node, but also on Resource.
    • Configuration info supports different severity levels, which show up as different icons: info, warning (default), error.
    • Configuration info supports being attached to a specific property, which makes the message show in the Inspector.
    • At the top of the inspector, you can now see a list of configuration info for the selected Node or Resource (see screenshots below).
  • API changes
    • A new API _get_configuration_info is available which accepts a mixed Array of Dictionaries and Strings ("my warning" is equivalent to { "message": "my warning" }).
    • C++ code that did warnings.push_back(RTR("...")) will now instead use CONFIG_WARNING(RTR("...")) macro (can be suffixed with _P to refer to a specific property).
    • No compatibility breaking changes. New APIs for everything, old stuff is left untouched but marked deprecated. Any code still using _get_configuration_warnings will behave the same as before.
    • Pulled as much logic out of Node as possible, instead moving it to its own EditorConfigurationInfo class, so logic can be shared with Resources, and between different Editor UIs. Without tools enabled, get_configuration_info is not available, reducing build size by around 100KB.

Screenshots

image

382488897-0cb5dbc1-b2c1-4f4c-ab07-4fcb7fc26c4d

For reviewers

First commit modifies the core and editor only, while the second commit adjusts all Nodes to use the new API.

Notes and Known Issues

These do not have to be resolved to merge this PR, unless deemed necessary by reviewers.

  • Is the name "Configuration Info" clear enough, from a user perspective? I can not think of a better name, now that it's not only used for warnings but also errors and information text... Suggestions welcome!
  • Improve the UI when clicking on the icon next to a property or in the scene tree. Should use the same RichTextLabel logic as the inspector plugin does, to show severity icons and different text color based on severity.
  • Would be nice to have a tooltip when hovering the icon, but since other icons in the Inspector don't have this yet, it can be done in a follow-up PR.
  • Localized property name style probably does not work properly, as it needs additional logic from EditorInspector. Would need to update the ConfigInfo struct with classname.
  • None of the built in resources currently return any configuration info. This can be added as a follow-up.

@RedMser RedMser changed the title configuration warning rework Rework the Configuration Warning system Mar 30, 2024
@RedMser RedMser force-pushed the configuration-warning-rework branch from 647a9ad to db114a6 Compare March 30, 2024 19:18
@AThousandShips AThousandShips added this to the 4.x milestone Mar 30, 2024
editor/editor_configuration_info.h Outdated Show resolved Hide resolved
doc/classes/SceneTree.xml Outdated Show resolved Hide resolved
doc/classes/Resource.xml Outdated Show resolved Hide resolved
doc/classes/Node.xml Outdated Show resolved Hide resolved
scene/main/node.h Show resolved Hide resolved
@RedMser RedMser force-pushed the configuration-warning-rework branch 2 times, most recently from 51e5529 to 7ce5676 Compare March 30, 2024 21:49
@Calinou
Copy link
Member

Calinou commented Apr 1, 2024

  • Test whether exported games don't break, since some of the config info system is now part of the editor and not in Node anymore.

Note that there was some discussion about whether node configuration warnings should be able to show when running a project in an editor build, but outside the editor (i.e. with a print in the Output panel). I can't find the proposal in question, but I remember discussing it myself.

Edit: This was probably in godotengine/godot-proposals#3004 (comment).

It also makes me wonder whether all _get_configuration_warnings() methods (or at least the method bodies) should be placed behind #ifdef TOOLS_ENABLED to reduce binary size.

@RedMser RedMser force-pushed the configuration-warning-rework branch from cbe1b97 to 0ad0b93 Compare May 16, 2024 17:26
@RedMser
Copy link
Contributor Author

RedMser commented May 16, 2024

It also makes me wonder whether all _get_configuration_warnings() methods (or at least the method bodies) should be placed behind #ifdef TOOLS_ENABLED to reduce binary size.

I tried this change (ifdef the entirety of get_configuration_info) and it seems to reduce the binary size by 100KB. Doing so for the body only would be a lot more manual labor, not sure if it's worth the hassle.

@RedMser
Copy link
Contributor Author

RedMser commented Aug 30, 2024

This PR should be ready now. I've rewritten the description, to remove finished TODOs and clarify what this PR exactly does.

A larger UI change has been made by introducing a configuration info summary in the inspector (see screenshots in PR description).

I'd like feedback whether this list should show for Resource only, or also for Node like in the current implementation.

@Mickeon
Copy link
Contributor

Mickeon commented Aug 30, 2024

Quoting my own comment on the matter last time just for the sake for others to remember it, haven't looked at the implementation yet.

@RedMser RedMser force-pushed the configuration-warning-rework branch from 719044b to 84c62af Compare October 6, 2024 19:04
@RedMser
Copy link
Contributor Author

RedMser commented Oct 6, 2024

Thanks for the multiple reviews! I applied the latest changes and squashed everything into two commits. My recompile locally was instant, so my rebase maneuver did not accidentally swallow any changes either ^^

editor/plugins/configuration_info_editor_plugin.cpp Outdated Show resolved Hide resolved
editor/plugins/configuration_info_editor_plugin.cpp Outdated Show resolved Hide resolved
editor/editor_configuration_info.cpp Outdated Show resolved Hide resolved
core/io/resource.cpp Outdated Show resolved Hide resolved
editor/editor_configuration_info.cpp Outdated Show resolved Hide resolved
editor/plugins/configuration_info_editor_plugin.h Outdated Show resolved Hide resolved
scene/main/node.cpp Outdated Show resolved Hide resolved
editor/editor_inspector.cpp Outdated Show resolved Hide resolved
@RedMser RedMser force-pushed the configuration-warning-rework branch from ac5f1b2 to 31acd7a Compare October 7, 2024 18:55
@Calinou
Copy link
Member

Calinou commented Oct 31, 2024

@RedMser Could you look into rebasing this PR so I can review it?

@RedMser RedMser force-pushed the configuration-warning-rework branch from 31acd7a to 3471800 Compare October 31, 2024 01:13
@RedMser RedMser requested review from a team as code owners October 31, 2024 01:13
@RedMser
Copy link
Contributor Author

RedMser commented Oct 31, 2024

@Calinou Updated to latest master! ^^

@Calinou
Copy link
Member

Calinou commented Nov 2, 2024

I get a build failure here after rebasing on top of master on my end:

Compiling scene/2d/physics/scu/scu_scene_2d_physics.gen.cpp ...
In file included from scene/2d/scu/scu_scene_2d_1.gen.cpp:4:
./scene/2d/light_occluder_2d.cpp: In member function 'void OccluderPolygon2D::set_polygon(const Vector<Vector2>&)':
./scene/2d/light_occluder_2d.cpp:93:9: error: 'update_configuration_warning' was not declared in this scope; did you mean 'update_configuration_info'?
   93 |         update_configuration_warning();
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         update_configuration_info
scons: *** [scene/2d/scu/scu_scene_2d_1.gen.linuxbsd.editor.x86_64.o] Error 1
scons: building terminated because of errors.
[Time elapsed: 00:00:37.33]

@RedMser RedMser force-pushed the configuration-warning-rework branch from 3471800 to c09d80e Compare November 2, 2024 00:29
@RedMser
Copy link
Contributor Author

RedMser commented Nov 2, 2024

Seems like this got added a few hours after my rebase, haha. Did another, should work now.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally (rebased on top of master c6c464c), it works as expected. This is a great start 🙂

The API that's exposed seems good to me. Some feedback regarding the UI:

  • The "N Configuration Infos" text should be changed to mention the type of messages it contains, so you can get better information without needing to expand it. For example:

❌ 1 configuration error, 1 warning
⚠️ 2 configuration warnings, 1 info
❌ 3 configuration errors, 1 warning, 2 infos
ℹ️ 2 configuration infos

  • There should be visual feedback when hovering the dropdown that can be expanded (the "1 Configuration Info" part):

image

  • On the above dropdown, the folding arrow should be moved to the left of the text (and it should point to the right when folded) to match usual Tree behavior. Here's a mockup:

image

  • Line spacing should be increased within the expanded dropdown, as it's quite low currently (compared to the rest of the editor):

image

  • The property name written in brackets should be capitalized using EditorPropertyNameProcessor::get_singleton()->process_name() (so that it follows editor settings). Right now, it always displays the original property name which is typically in snake_case, regardless of editor settings.

  • The warning icon next to a property should be moved to the left slightly, so that it's centered:

image

Here's a mockup of how it should look like:

image

  • When hovering the warning icon, a tooltip with the warning description should appear, like when you hover it in the Scene tree dock. Right now, it shows the property's documentation instead.

@RedMser RedMser force-pushed the configuration-warning-rework branch from c09d80e to d35cb3e Compare November 2, 2024 17:34
@RedMser
Copy link
Contributor Author

RedMser commented Nov 2, 2024

Thanks for your review and feedback! Screenshot after the suggested changes:

image

The "N Configuration Infos" text should be changed

Done, see _get_summary_text. I intentionally split the translations like this, since I assume some languages can't simply prefix/suffix the word "configuration" without changing conjugation.

Your mockup included emojis for the icons, but I decided not to add an icon for the dropdown title text. The list below already has many icons, so by not having an icon on the title, it gives it a bit of hierarchy. Let me know if you have a strong opinion on changing it.

visual feedback when hovering the dropdown
the folding arrow should be moved to the left of the text (and it should point to the right when folded)

Done. I've copied the UI from the "control positioning warning" inspector plugin, so it would make sense to update that one in a new PR as well.

Line spacing should be increased

Done.

The property name written in brackets should be capitalized

Done, although it will probably fail for "localized" property style, since there's a lot of additional logic in the inspector which would need to be pulled out (see code snippet). We would also need to update the struct to include class name.

// Get the property label's string.
String name_override = (path.contains("/")) ? path.substr(path.rfind("/") + 1) : path;
String feature_tag;
{
const int dot = name_override.find(".");
if (dot != -1) {
feature_tag = name_override.substr(dot);
name_override = name_override.substr(0, dot);
}
}
// Don't localize script variables.
EditorPropertyNameProcessor::Style name_style = property_name_style;
if ((p.usage & PROPERTY_USAGE_SCRIPT_VARIABLE) && name_style == EditorPropertyNameProcessor::STYLE_LOCALIZED) {
name_style = EditorPropertyNameProcessor::STYLE_CAPITALIZED;
}
const String property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(name_override, name_style, p.name, doc_name) + feature_tag;

I'd consider this a known issue for now which can be optimized later.

The warning icon next to a property should [...] centered

Done by adding 50% extra width. I also noticed that I forgot to update the minimum size, so I added that and refactored duplicate code into helper methods.

When hovering the warning icon, a tooltip [...]

It is a known limitation of this PR, since none of the icon buttons in EditorProperty have tooltips right now (insert keyframe, deletable, etc.). A follow-up PR could introduce a tooltip system for all of these buttons.

@RedMser RedMser requested a review from Calinou November 2, 2024 17:38
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

The UI looks great now!

@adamscott
Copy link
Member

I would keep Node::_get_configuration_warnings() and similar methods for backward compatibility sake. Removing the functionality would break so many plugins.

I would make it so that if configuration info is given, then it takes priority on any configuration warning given.

@RedMser RedMser force-pushed the configuration-warning-rework branch from d35cb3e to 1ebc7d3 Compare November 2, 2024 18:01
@RedMser
Copy link
Contributor Author

RedMser commented Nov 2, 2024

@adamscott Current behavior is that both methods exist side-by-side and work, with _get_configuration_warnings marked as deprecated (to be removed in 5.0, which will likely break plugins anyway).
The results of both methods are merged together into one array, so nothing takes priority over the other.

I have not explicitly tested backwards compatibility for GDExtension or modules, but I would hope it works as intended when not compiling with DISABLE_DEPRECATED.
The idea is that compiling a GDExtension for 4.3 with config warnings API, and loading that into this PR, should work as expected.

@RedMser RedMser force-pushed the configuration-warning-rework branch from 1ebc7d3 to c1df3be Compare November 2, 2024 20:10
- Introduces the new configuration info system.
- Supported on Node and Resource.
- Different severity levels, can be on properties.
- Show summary of config info at the top of the inspector.
- Backwards compatible API (configuration warnings API still works,
  although it is marked as deprecated).
@RedMser RedMser force-pushed the configuration-warning-rework branch from c1df3be to 0128098 Compare November 23, 2024 13:53
Uses the CONFIG_ macros and specifies the property where appropriate.
@RedMser RedMser force-pushed the configuration-warning-rework branch from 0128098 to 34b0fc7 Compare November 23, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants