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

Refactor editor icon retrieval #21717

Merged
merged 1 commit into from
Sep 14, 2018

Conversation

willnationsdev
Copy link
Contributor

@willnationsdev willnationsdev commented Sep 3, 2018

It looks like this has a ton of different changes, but the vast majority of this is just about centralizing copy-pasta code all over the Godot Editor into a centralized location that does the same processing in every case (rather than bits and pieces that the copy-pasta had induced at various locations).

Fixes #21615 and circumvents any previous "fixes" surrounding "_editor_icon" metadata.

  1. Create EditorData::script_class_get_name(p_path) so that a path alone can fetch us the name, and from there, the icon path. Start caching these values during EditorFileSystem::_scan_script_classes(...).
  2. Create EditorData::get_object_icon(obj, ...) and EditorData::get_object_icon_name(name, ...) to fetch the appropriate editor icon depending on whether an object pointer or a String/StringName is available. Edit: we changed get_object_icon_name to get_class_icon.
  3. Fix a script class icon bug in create_dialog.cpp regarding the current_item_is_preferred in the cpp_type case (prevents a possible ClassDB::is_parent_class() ERR_FAIL_COND_V trigger).
  4. Replace all "_editor_icon" metadata fetches with the above functions. Allow editor nodes to check the live data directly rather than using the third-party "_editor_icon" metadata that was desynchronizing and causing all sorts of random bugs in different places.
    • group_editor.cpp
    • canvas_item_editor_plugin.cpp
    • spatial_editor_plugin.cpp
    • scene_tree_dock.cpp
    • scene_tree_editor.cpp
  5. I then noticed that the same methods could be used to refactor and centralize the vast majority of get_icon(...) calls in the editor classes, so I started to evaluate all of those files and determine if their usage could be converted into an EditorData call without compromising their logical functionality. I believe I've done that, but I'm sure people will want to investigate it further.

@akien-mga
Copy link
Member

There are some style issues: https://travis-ci.org/godotengine/godot/jobs/423784992

@willnationsdev
Copy link
Contributor Author

@akien-mga Should be good to go, if someone wants to review it.

@@ -29,6 +29,7 @@
/*************************************************************************/

#include "animation_bezier_editor.h"
#include "editor/editor_node.h"
Copy link
Member

Choose a reason for hiding this comment

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

Please always leave an empty line between the .cpp's own header (animation_bezier_editor.h) and the other Godot headers.

@akien-mga
Copy link
Member

Rebase needed after my change of core includes to be absolute.

reduz
reduz previously requested changes Sep 13, 2018
}
}

Ref<Texture> EditorData::get_object_icon(const Object *p_object, const Control *p_control, const String &p_fallback) const {
Copy link
Member

Choose a reason for hiding this comment

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

This is way too complicated. Make the function part of EditorNode and get the icon from the theme or from the gui_base instance, so you dont have to pass instances around.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

reduz
reduz previously requested changes Sep 14, 2018
return NULL;
}

Ref<Texture> EditorNode::get_object_icon_name(const String &p_class, const String &p_fallback) const {
Copy link
Member

Choose a reason for hiding this comment

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

Two suggestions about this function:

  • rename to get_class_icon (i think it makes more sense)
  • fallback could have a default argument "Object" so it does not need to be passed always

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@akien-mga
Copy link
Member

Thanks!

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.

Area2d Black Icon on Mac OSX 10.13
3 participants