mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-25 21:27:30 +01:00
Added an importer for HTMLTemplateData.
This commit is contained in:
parent
eca4475f2d
commit
08864f0a25
@ -61,6 +61,8 @@ sources = [
|
||||
]
|
||||
|
||||
if env["tools"]:
|
||||
sources.append("html/editor/resource_importer_html_template_data.cpp")
|
||||
|
||||
sources.append("editor/web_node_editor.cpp")
|
||||
sources.append("editor/web_node_editor_plugin.cpp")
|
||||
sources.append("editor/web_node_editor_web_server.cpp")
|
||||
|
@ -0,0 +1,87 @@
|
||||
/*************************************************************************/
|
||||
/* resource_importer_html_template_data.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* PANDEMONIUM ENGINE */
|
||||
/* https://github.com/Relintai/pandemonium_engine */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2022-present Péter Magyar. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "resource_importer_html_template_data.h"
|
||||
|
||||
#include "core/io/resource_saver.h"
|
||||
|
||||
#include "../html_template_data.h"
|
||||
|
||||
String ResourceImporterHTMLTemplateData::get_importer_name() const {
|
||||
return "html_template_data";
|
||||
}
|
||||
|
||||
String ResourceImporterHTMLTemplateData::get_visible_name() const {
|
||||
return "HTMLTemplateData";
|
||||
}
|
||||
void ResourceImporterHTMLTemplateData::get_recognized_extensions(List<String> *p_extensions) const {
|
||||
p_extensions->push_back("phtpl");
|
||||
}
|
||||
String ResourceImporterHTMLTemplateData::get_save_extension() const {
|
||||
return "res";
|
||||
}
|
||||
|
||||
String ResourceImporterHTMLTemplateData::get_resource_type() const {
|
||||
return "HTMLTemplateData";
|
||||
}
|
||||
|
||||
bool ResourceImporterHTMLTemplateData::get_option_visibility(const String &p_option, const RBMap<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int ResourceImporterHTMLTemplateData::get_preset_count() const {
|
||||
return 0;
|
||||
}
|
||||
String ResourceImporterHTMLTemplateData::get_preset_name(int p_idx) const {
|
||||
return String();
|
||||
}
|
||||
|
||||
void ResourceImporterHTMLTemplateData::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return ResourceSaver::save(p_save_path + ".res", template_data);
|
||||
}
|
||||
|
||||
ResourceImporterHTMLTemplateData::ResourceImporterHTMLTemplateData() {
|
||||
}
|
||||
|
||||
ResourceImporterHTMLTemplateData::~ResourceImporterHTMLTemplateData() {
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
#ifndef RESOURCE_IMPORTER_HTML_TEMPLATE_DATA_H
|
||||
#define RESOURCE_IMPORTER_HTML_TEMPLATE_DATA_H
|
||||
|
||||
/*************************************************************************/
|
||||
/* resource_importer_html_template_data.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* PANDEMONIUM ENGINE */
|
||||
/* https://github.com/Relintai/pandemonium_engine */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2022-present Péter Magyar. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "core/io/resource_importer.h"
|
||||
|
||||
class ResourceImporterHTMLTemplateData : public ResourceImporter {
|
||||
GDCLASS(ResourceImporterHTMLTemplateData, ResourceImporter);
|
||||
|
||||
public:
|
||||
virtual String get_importer_name() const;
|
||||
virtual String get_visible_name() const;
|
||||
virtual void get_recognized_extensions(List<String> *p_extensions) const;
|
||||
virtual String get_save_extension() const;
|
||||
virtual String get_resource_type() const;
|
||||
|
||||
virtual int get_preset_count() const;
|
||||
virtual String get_preset_name(int p_idx) const;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
|
||||
virtual bool get_option_visibility(const String &p_option, const RBMap<StringName, Variant> &p_options) const;
|
||||
virtual Error 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 = nullptr, Variant *r_metadata = nullptr);
|
||||
|
||||
ResourceImporterHTMLTemplateData();
|
||||
~ResourceImporterHTMLTemplateData();
|
||||
};
|
||||
#endif // RESOURCE_IMPORTER_HTML_TEMPLATE_DATA_H
|
@ -39,10 +39,14 @@
|
||||
#include "html/form_validator.h"
|
||||
#include "html/html_builder_bind.h"
|
||||
#include "html/html_parser.h"
|
||||
#include "html/markdown_renderer.h"
|
||||
#include "html/paginator.h"
|
||||
#include "html/html_template.h"
|
||||
#include "html/html_template_data.h"
|
||||
#include "html/markdown_renderer.h"
|
||||
#include "html/paginator.h"
|
||||
|
||||
#if TOOLS_ENABLED
|
||||
#include "html/editor/resource_importer_html_template_data.h"
|
||||
#endif
|
||||
|
||||
#include "http/csrf_token.h"
|
||||
#include "http/http_server_enums.h"
|
||||
@ -87,7 +91,7 @@ void register_web_types(ModuleRegistrationLevel p_level) {
|
||||
if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) {
|
||||
ClassDB::register_class<_HTMLBuilder>();
|
||||
ClassDB::register_class<_HTMLTag>();
|
||||
|
||||
|
||||
ClassDB::register_class<HTMLTemplate>();
|
||||
ClassDB::register_class<HTMLTemplateData>();
|
||||
|
||||
@ -160,6 +164,10 @@ void register_web_types(ModuleRegistrationLevel p_level) {
|
||||
#if TOOLS_ENABLED
|
||||
if (p_level == MODULE_REGISTRATION_LEVEL_EDITOR) {
|
||||
EditorPlugins::add_by_type<WebNodeEditorPlugin>();
|
||||
|
||||
Ref<ResourceImporterHTMLTemplateData> html_template_data_importer;
|
||||
html_template_data_importer.instance();
|
||||
ResourceFormatImporter::get_singleton()->add_importer(html_template_data_importer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user