mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-04 07:05:54 +01:00
Implemented custom script class types for EditorQuickOpen.
This commit is contained in:
parent
2199cba049
commit
5c1254e429
@ -1006,6 +1006,38 @@ Ref<Script> EditorData::script_class_get_base_from_anonymous_path(const String &
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringName EditorData::type_get_from_anonymous_path(const String &p_path) const {
|
||||||
|
Ref<Resource> res = ResourceLoader::load(p_path);
|
||||||
|
|
||||||
|
if (!res.is_valid()) {
|
||||||
|
return StringName();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Script> script = res->get_script();
|
||||||
|
|
||||||
|
StringName res_name = "Resource";
|
||||||
|
|
||||||
|
if (script.is_null()) {
|
||||||
|
return res_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
StringName scls_name = ScriptServer::get_global_class_name(script->get_path());
|
||||||
|
|
||||||
|
if (scls_name != StringName()) {
|
||||||
|
return scls_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (script->get_path().find("::") != -1) {
|
||||||
|
WARN_PRINT_ONCE("If you remove a built-in script that derives a script class, inheritance cannot be determined. The entire script is removed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
script = script->get_base_script();
|
||||||
|
} while (script.is_valid());
|
||||||
|
|
||||||
|
return res_name;
|
||||||
|
}
|
||||||
|
|
||||||
void EditorData::script_class_save_icon_paths() {
|
void EditorData::script_class_save_icon_paths() {
|
||||||
List<StringName> keys;
|
List<StringName> keys;
|
||||||
_script_class_icon_paths.get_key_list(&keys);
|
_script_class_icon_paths.get_key_list(&keys);
|
||||||
|
@ -239,6 +239,7 @@ public:
|
|||||||
Variant script_class_instance(const StringName &p_class) const;
|
Variant script_class_instance(const StringName &p_class) const;
|
||||||
|
|
||||||
Ref<Script> script_class_get_base_from_anonymous_path(const String &p_path) const;
|
Ref<Script> script_class_get_base_from_anonymous_path(const String &p_path) const;
|
||||||
|
StringName type_get_from_anonymous_path(const String &p_path) const;
|
||||||
|
|
||||||
String script_class_get_icon_path(const StringName &p_class) const;
|
String script_class_get_icon_path(const StringName &p_class) const;
|
||||||
void script_class_set_icon_path(const StringName &p_class, const String &p_icon_path);
|
void script_class_set_icon_path(const StringName &p_class, const String &p_icon_path);
|
||||||
|
@ -30,17 +30,19 @@
|
|||||||
|
|
||||||
#include "quick_open.h"
|
#include "quick_open.h"
|
||||||
|
|
||||||
|
#include "core/containers/pair.h"
|
||||||
|
#include "core/input/input_event.h"
|
||||||
|
#include "core/object/class_db.h"
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
|
#include "core/os/memory.h"
|
||||||
|
#include "core/typedefs.h"
|
||||||
|
#include "editor/editor_data.h"
|
||||||
|
#include "editor/editor_file_system.h"
|
||||||
|
#include "editor/editor_node.h"
|
||||||
#include "scene/gui/box_container.h"
|
#include "scene/gui/box_container.h"
|
||||||
#include "scene/gui/button.h"
|
#include "scene/gui/button.h"
|
||||||
#include "scene/gui/line_edit.h"
|
|
||||||
#include "core/object/class_db.h"
|
|
||||||
#include "core/input/input_event.h"
|
|
||||||
#include "core/os/memory.h"
|
|
||||||
#include "core/containers/pair.h"
|
|
||||||
#include "core/typedefs.h"
|
|
||||||
#include "editor/editor_file_system.h"
|
|
||||||
#include "scene/gui/control.h"
|
#include "scene/gui/control.h"
|
||||||
|
#include "scene/gui/line_edit.h"
|
||||||
#include "scene/gui/tree.h"
|
#include "scene/gui/tree.h"
|
||||||
#include "scene/main/node.h"
|
#include "scene/main/node.h"
|
||||||
#include "scene/resources/texture.h"
|
#include "scene/resources/texture.h"
|
||||||
@ -138,16 +140,21 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str
|
|||||||
}
|
}
|
||||||
|
|
||||||
String search_text = search_box->get_text();
|
String search_text = search_box->get_text();
|
||||||
|
EditorData &ed = EditorNode::get_editor_data();
|
||||||
|
|
||||||
Vector<String> base_types = String(base_type).split(String(","));
|
Vector<String> base_types = String(base_type).split(String(","));
|
||||||
for (int i = 0; i < efsd->get_file_count(); i++) {
|
for (int i = 0; i < efsd->get_file_count(); i++) {
|
||||||
String file = efsd->get_file_path(i);
|
String file_path_full = efsd->get_file_path(i);
|
||||||
file = file.substr(6, file.length());
|
String file = file_path_full.substr(6, file_path_full.length());
|
||||||
|
|
||||||
StringName file_type = efsd->get_file_type(i);
|
StringName file_type = efsd->get_file_type(i);
|
||||||
|
StringName script_type = ed.type_get_from_anonymous_path(file_path_full);
|
||||||
|
|
||||||
|
StringName class_name = script_type != StringName() ? script_type : file_type;
|
||||||
|
|
||||||
// Iterate all possible base types.
|
// Iterate all possible base types.
|
||||||
for (int j = 0; j < base_types.size(); j++) {
|
for (int j = 0; j < base_types.size(); j++) {
|
||||||
if (ClassDB::is_parent_class(file_type, base_types[j]) && search_text.is_subsequence_ofi(file)) {
|
if (ed.class_equals_or_inherits(class_name, base_types[j]) && search_text.is_subsequence_ofi(file)) {
|
||||||
Pair<String, Ref<Texture>> pair;
|
Pair<String, Ref<Texture>> pair;
|
||||||
pair.first = file;
|
pair.first = file;
|
||||||
StringName icon_name = search_options->has_theme_icon(file_type, ei) ? file_type : ot;
|
StringName icon_name = search_options->has_theme_icon(file_type, ei) ? file_type : ot;
|
||||||
|
Loading…
Reference in New Issue
Block a user