diff --git a/spine-godot/.vscode/settings.json b/spine-godot/.vscode/settings.json index 05c009d72..9192e49a3 100644 --- a/spine-godot/.vscode/settings.json +++ b/spine-godot/.vscode/settings.json @@ -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" diff --git a/spine-godot/spine_godot/SpineAtlasResource.cpp b/spine-godot/spine_godot/SpineAtlasResource.cpp index fbd9f8634..fabdcb477 100644 --- a/spine-godot/spine_godot/SpineAtlasResource.cpp +++ b/spine-godot/spine_godot/SpineAtlasResource.cpp @@ -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(); diff --git a/spine-godot/spine_godot/SpineEditorPlugin.cpp b/spine-godot/spine_godot/SpineEditorPlugin.cpp index 2202e1876..8f146b171 100644 --- a/spine-godot/spine_godot/SpineEditorPlugin.cpp +++ b/spine-godot/spine_godot/SpineEditorPlugin.cpp @@ -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 SpineAtlasResourceImportPlugin::_get_import_options(const String &p_path, int32_t p_preset_index) const { + TypedArray 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 *options, int preset) const { #else diff --git a/spine-godot/spine_godot/SpineEditorPlugin.h b/spine-godot/spine_godot/SpineEditorPlugin.h index 52abcbd54..4df9edc09 100644 --- a/spine-godot/spine_godot/SpineEditorPlugin.h +++ b/spine-godot/spine_godot/SpineEditorPlugin.h @@ -94,6 +94,8 @@ class SpineAtlasResourceImportPlugin : public EditorImportPlugin { virtual float _get_priority() const override { return 1; } + TypedArray _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 &p_platform_variants, const TypedArray &p_gen_files) const override; @@ -163,6 +165,11 @@ class SpineJsonResourceImportPlugin : public EditorImportPlugin { float _get_priority() const override { return 1; } + TypedArray _get_import_options(const String &p_path, int32_t p_preset_index) const override { + TypedArray 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 &p_platform_variants, const TypedArray &p_gen_files) const override; @@ -232,6 +239,11 @@ class SpineBinaryResourceImportPlugin : public EditorImportPlugin { float _get_priority() const override { return 1; } + TypedArray _get_import_options(const String &p_path, int32_t p_preset_index) const override { + TypedArray 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 &p_platform_variants, const TypedArray &p_gen_files) const override; diff --git a/spine-godot/spine_godot/register_types.cpp b/spine-godot/spine_godot/register_types.cpp index bc5ca04b9..2f04e9cbf 100644 --- a/spine-godot/spine_godot/register_types.cpp +++ b/spine-godot/spine_godot/register_types.cpp @@ -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