[godot] Fix importers for extension settings

This commit is contained in:
Mario Zechner 2024-10-08 15:49:23 +02:00
parent 14992a57c3
commit 6dbed6044f
5 changed files with 36 additions and 9 deletions

View File

@ -4,6 +4,7 @@
"C_Cpp.default.browse.path": [
"${workspaceFolder}"
],
"C_Cpp.default.defines": ["TOOLS_ENABLED", "SPINE_GODOT_EXTENSION"],
"dotnet.defaultSolution": "disable",
"files.associations": {
"*.inc": "cpp"

View File

@ -287,10 +287,14 @@ Error SpineAtlasResource::load_from_file(const String &path) {
#endif
#if VERSION_MAJOR > 3
JSON json;
error = json.parse(json_string);
if (error != OK) return error;
Variant result = json.get_data();
JSON *json = memnew(JSON);
error = json->parse(json_string);
if (error != OK) {
memdelete(json);
return error;
}
Variant result = json->get_data();
memdelete(json);
#else
String error_string;
int error_line;
@ -337,9 +341,10 @@ Error SpineAtlasResource::save_to_file(const String &path) {
content["atlas_data"] = atlas_data;
content["normal_texture_prefix"] = normal_map_prefix;
#if VERSION_MAJOR > 3
JSON json;
file->store_string(json.stringify(content));
JSON *json = memnew(JSON);
file->store_string(json->stringify(content));
file->flush();
memdelete(json);
#else
file->store_string(JSON::print(content));
file->close();

View File

@ -64,8 +64,18 @@ Error SpineAtlasResourceImportPlugin::import(const String &source_file, const St
return error;
}
// FIXME get_import_options is not available in godot-cpp
#ifndef SPINE_GODOT_EXTENSION
#ifdef SPINE_GODOT_EXTENSION
TypedArray<Dictionary> SpineAtlasResourceImportPlugin::_get_import_options(const String &p_path, int32_t p_preset_index) const {
TypedArray<Dictionary> options;
Dictionary dictionary;
dictionary["name"] = "normal_map_prefix";
dictionary["type"] = Variant::STRING;
dictionary["hint_string"] = "String";
dictionary["default_value"] = String("n");
options.push_back(dictionary);
return options;
}
#else
#if VERSION_MAJOR > 3
void SpineAtlasResourceImportPlugin::get_import_options(const String &path, List<ImportOption> *options, int preset) const {
#else

View File

@ -94,6 +94,8 @@ public:
virtual float _get_priority() const override { return 1; }
TypedArray<Dictionary> _get_import_options(const String &p_path, int32_t p_preset_index) const override;
virtual bool _get_option_visibility(const String &p_path, const StringName &p_option_name, const Dictionary &p_options) const override { return true; };
virtual Error _import(const String &p_source_file, const String &p_save_path, const Dictionary &p_options, const TypedArray<String> &p_platform_variants, const TypedArray<String> &p_gen_files) const override;
@ -163,6 +165,11 @@ public:
float _get_priority() const override { return 1; }
TypedArray<Dictionary> _get_import_options(const String &p_path, int32_t p_preset_index) const override {
TypedArray<Dictionary> options;
return options;
}
virtual bool _get_option_visibility(const String &p_path, const StringName &p_option_name, const Dictionary &p_options) const override { return true; };
virtual Error _import(const String &p_source_file, const String &p_save_path, const Dictionary &p_options, const TypedArray<String> &p_platform_variants, const TypedArray<String> &p_gen_files) const override;
@ -232,6 +239,11 @@ public:
float _get_priority() const override { return 1; }
TypedArray<Dictionary> _get_import_options(const String &p_path, int32_t p_preset_index) const override {
TypedArray<Dictionary> options;
return options;
}
virtual bool _get_option_visibility(const String &p_path, const StringName &p_option_name, const Dictionary &p_options) const override { return true; };
virtual Error _import(const String &p_source_file, const String &p_save_path, const Dictionary &p_options, const TypedArray<String> &p_platform_variants, const TypedArray<String> &p_gen_files) const override;

View File

@ -192,7 +192,6 @@ void register_spine_godot_types() {
ResourceSaver::add_resource_format_saver(skeleton_file_saver);
#endif
#endif
printf(">>>>>>>>>>>>>>>>>>>> fuck\n");
}
#if VERSION_MAJOR > 3