Skip to content

Commit

Permalink
Now HTMLTemplateDataEditorPlugin will only handle HTMLTemplateDatas, …
Browse files Browse the repository at this point in the history
…if they are on disk.
  • Loading branch information
Relintai committed Feb 25, 2024
1 parent 35e3285 commit ce638a6
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions modules/web/html/editor/resource_importer_html_template_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ void ResourceImporterHTMLTemplateData::get_import_options(List<ImportOption> *r_
Error ResourceImporterHTMLTemplateData::import(const String &p_source_file, const String &p_save_path, const RBMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
Ref<HTMLTemplateData> template_data;
template_data.instance();

Error err = template_data->load_from_file(p_source_file);

if (err != OK) {
return err;
}
Expand All @@ -94,18 +94,32 @@ ResourceImporterHTMLTemplateData::~ResourceImporterHTMLTemplateData() {

void HTMLTemplateDataEditorPlugin::edit(Object *p_object) {
Ref<HTMLTemplateData> f = Ref<HTMLTemplateData>(Object::cast_to<HTMLTemplateData>(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());
}
}
}

bool HTMLTemplateDataEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("HTMLTemplateData");
Ref<HTMLTemplateData> f = Ref<HTMLTemplateData>(Object::cast_to<HTMLTemplateData>(p_object));

if (f.is_valid()) {
String path = f->get_path();

return !path.empty();
}

return false;
}

HTMLTemplateDataEditorPlugin::HTMLTemplateDataEditorPlugin(EditorNode *p_node) {
Expand Down

0 comments on commit ce638a6

Please sign in to comment.