summaryrefslogtreecommitdiffstats
path: root/editor/editor_resource_picker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_resource_picker.cpp')
-rw-r--r--editor/editor_resource_picker.cpp38
1 files changed, 11 insertions, 27 deletions
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp
index ed20e50685..27ce27591f 100644
--- a/editor/editor_resource_picker.cpp
+++ b/editor/editor_resource_picker.cpp
@@ -34,7 +34,6 @@
#include "editor/editor_node.h"
#include "editor/editor_quick_open.h"
#include "editor/editor_resource_preview.h"
-#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/filesystem_dock.h"
@@ -42,6 +41,7 @@
#include "editor/plugins/editor_resource_conversion_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
#include "editor/scene_tree_dock.h"
+#include "editor/themes/editor_scale.h"
#include "scene/gui/button.h"
#include "scene/gui/texture_rect.h"
#include "scene/resources/gradient_texture.h"
@@ -487,38 +487,16 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) {
HashSet<StringName> allowed_types;
_get_allowed_types(false, &allowed_types);
- Vector<EditorData::CustomType> custom_resources;
- if (EditorNode::get_editor_data().get_custom_types().has("Resource")) {
- custom_resources = EditorNode::get_editor_data().get_custom_types()["Resource"];
- }
-
for (const StringName &E : allowed_types) {
const String &t = E;
- bool is_custom_resource = false;
- Ref<Texture2D> icon;
- if (!custom_resources.is_empty()) {
- for (int j = 0; j < custom_resources.size(); j++) {
- if (custom_resources[j].name == t) {
- is_custom_resource = true;
- if (custom_resources[j].icon.is_valid()) {
- icon = custom_resources[j].icon;
- }
- break;
- }
- }
- }
-
- if (!is_custom_resource && !ClassDB::can_instantiate(t)) {
+ if (!ClassDB::can_instantiate(t)) {
continue;
}
inheritors_array.push_back(t);
- if (!icon.is_valid()) {
- icon = get_editor_theme_icon(has_theme_icon(t, EditorStringName(EditorIcons)) ? t : String("Object"));
- }
-
+ Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(t, "Object");
int id = TYPE_BASE_ID + idx;
edit_menu->add_icon_item(icon, vformat(TTR("New %s"), t), id);
@@ -675,7 +653,7 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const {
return false;
}
-bool EditorResourcePicker::_is_type_valid(const String p_type_name, HashSet<StringName> p_allowed_types) const {
+bool EditorResourcePicker::_is_type_valid(const String p_type_name, const HashSet<StringName> &p_allowed_types) const {
for (const StringName &E : p_allowed_types) {
String at = E;
if (p_type_name == at || ClassDB::is_parent_class(p_type_name, at) || EditorNode::get_editor_data().script_class_is_parent(p_type_name, at)) {
@@ -804,7 +782,12 @@ void EditorResourcePicker::_notification(int p_what) {
[[fallthrough]];
}
case NOTIFICATION_THEME_CHANGED: {
- assign_button->add_theme_constant_override("icon_max_width", get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)));
+ const int icon_width = get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor));
+ assign_button->add_theme_constant_override("icon_max_width", icon_width);
+ if (edit_menu) {
+ edit_menu->add_theme_constant_override("icon_max_width", icon_width);
+ }
+
edit_button->set_icon(get_theme_icon(SNAME("select_arrow"), SNAME("Tree")));
} break;
@@ -940,6 +923,7 @@ void EditorResourcePicker::_ensure_resource_menu() {
return;
}
edit_menu = memnew(PopupMenu);
+ edit_menu->add_theme_constant_override("icon_max_width", get_theme_constant(SNAME("class_icon_size"), EditorStringName(Editor)));
add_child(edit_menu);
edit_menu->connect("id_pressed", callable_mp(this, &EditorResourcePicker::_edit_menu_cbk));
edit_menu->connect("popup_hide", callable_mp((BaseButton *)edit_button, &BaseButton::set_pressed).bind(false));