From ce638a69c18ab2464560b984b11e24a3932f9f23 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 25 Feb 2024 19:25:58 +0100 Subject: [PATCH] Now HTMLTemplateDataEditorPlugin will only handle HTMLTemplateDatas, if they are on disk. --- .../resource_importer_html_template_data.cpp | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/web/html/editor/resource_importer_html_template_data.cpp b/modules/web/html/editor/resource_importer_html_template_data.cpp index 54d0cb5ca..12a3506fa 100644 --- a/modules/web/html/editor/resource_importer_html_template_data.cpp +++ b/modules/web/html/editor/resource_importer_html_template_data.cpp @@ -74,9 +74,9 @@ void ResourceImporterHTMLTemplateData::get_import_options(List *r_ Error ResourceImporterHTMLTemplateData::import(const String &p_source_file, const String &p_save_path, const RBMap &p_options, List *r_platform_variants, List *r_gen_files, Variant *r_metadata) { Ref template_data; template_data.instance(); - + Error err = template_data->load_from_file(p_source_file); - + if (err != OK) { return err; } @@ -94,10 +94,16 @@ ResourceImporterHTMLTemplateData::~ResourceImporterHTMLTemplateData() { void HTMLTemplateDataEditorPlugin::edit(Object *p_object) { Ref f = Ref(Object::cast_to(p_object)); - + if (f.is_valid()) { + String path = f->get_path(); + + if (path.empty()) { + return; + } + EditorPlugin *ep = EditorNode::get_singleton()->get_editor_by_name("Text"); - + if (ep) { ep->call("open_file", f->get_path()); } @@ -105,7 +111,15 @@ void HTMLTemplateDataEditorPlugin::edit(Object *p_object) { } bool HTMLTemplateDataEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("HTMLTemplateData"); + Ref f = Ref(Object::cast_to(p_object)); + + if (f.is_valid()) { + String path = f->get_path(); + + return !path.empty(); + } + + return false; } HTMLTemplateDataEditorPlugin::HTMLTemplateDataEditorPlugin(EditorNode *p_node) {