From c712c4b30839400ba22e5a6b01f2a20fd9b311fa Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 6 Feb 2021 11:52:33 +0100 Subject: [PATCH] Fix compile for 4.0. --- README.md | 2 +- layers/texture_layer_merger.h | 14 +++++++++++--- texture_merger.h | 11 +++++++++-- texture_packer.cpp | 7 +++++++ texture_packer.h | 17 +++++++++++++---- .../editor_plugin_packer_image_resource.h | 7 +++++++ texture_resource/packer_image_resource.h | 7 +++++++ .../packer_image_resource_importer.h | 12 ++++++++++-- 8 files changed, 65 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0368130..f2d5975 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ It uses the legacy version of [rectpack2D](https://github.com/TeamHypersomnia/re It should work on all platforms. -It supports both godot 3.2 and 4.0 (master). Note that since 4.0 is still in very early stages I only +It supports both godot 3.2 and 4.0 (master [last tested commit](https://github.com/godotengine/godot/commit/b7e10141197fdd9b0dbc4cfa7890329510d36540)). Note that since 4.0 is still in very early stages I only check whether it works from time to time. # Pre-built binaries diff --git a/layers/texture_layer_merger.h b/layers/texture_layer_merger.h index 8b17901..15ce295 100644 --- a/layers/texture_layer_merger.h +++ b/layers/texture_layer_merger.h @@ -23,11 +23,19 @@ SOFTWARE. #ifndef TEXTURE_LAYER_MERGER_H #define TEXTURE_LAYER_MERGER_H -#include "core/reference.h" +#include "core/version.h" -#include "core/image.h" -#include "core/math/rect2.h" +#if VERSION_MAJOR > 3 +#include "core/object/reference.h" +#include "core/templates/vector.h" +#include "core/io/image.h" +#else +#include "core/reference.h" #include "core/vector.h" +#include "core/image.h" +#endif + +#include "core/math/rect2.h" #include "scene/resources/texture.h" #include "core/version.h" diff --git a/texture_merger.h b/texture_merger.h index 894c425..79fcb51 100644 --- a/texture_merger.h +++ b/texture_merger.h @@ -23,10 +23,17 @@ SOFTWARE. #ifndef TEXTURE_MERGER_H #define TEXTURE_MERGER_H -#include "scene/main/node.h" +#include "core/version.h" -#include "core/engine.h" +#if VERSION_MAJOR > 3 +#include "core/templates/vector.h" +#include "core/config/engine.h" +#else #include "core/vector.h" +#include "core/engine.h" +#endif + +#include "scene/main/node.h" #include "texture_packer.h" diff --git a/texture_packer.cpp b/texture_packer.cpp index ed0d082..218b758 100644 --- a/texture_packer.cpp +++ b/texture_packer.cpp @@ -447,10 +447,17 @@ int TexturePacker::get_offset_for_format(Image::Format format) { case Image::FORMAT_BPTC_RGBA: case Image::FORMAT_BPTC_RGBF: case Image::FORMAT_BPTC_RGBFU: +#if VERSION_MAJOR <= 3 case Image::FORMAT_PVRTC2: case Image::FORMAT_PVRTC2A: case Image::FORMAT_PVRTC4: case Image::FORMAT_PVRTC4A: +#else + case Image::FORMAT_PVRTC1_2: + case Image::FORMAT_PVRTC1_2A: + case Image::FORMAT_PVRTC1_4: + case Image::FORMAT_PVRTC1_4A: +#endif case Image::FORMAT_ETC: case Image::FORMAT_ETC2_R11: case Image::FORMAT_ETC2_R11S: diff --git a/texture_packer.h b/texture_packer.h index 284440e..4968d08 100644 --- a/texture_packer.h +++ b/texture_packer.h @@ -23,18 +23,27 @@ SOFTWARE. #ifndef TEXTURE_PACKER_H #define TEXTURE_PACKER_H -#include "core/color.h" +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/image.h" +#include "core/object/reference.h" +#include "core/templates/vector.h" +#include "core/string/ustring.h" +#include "core/math/color.h" +#else #include "core/image.h" #include "core/reference.h" -#include "core/ustring.h" #include "core/vector.h" +#include "core/ustring.h" +#include "core/color.h" +#endif + #include "scene/resources/texture.h" #include #include "rectpack2D/pack.h" -#include "core/version.h" - #if VERSION_MAJOR >= 4 #define PoolVector Vector #define Texture Texture2D diff --git a/texture_resource/editor_plugin_packer_image_resource.h b/texture_resource/editor_plugin_packer_image_resource.h index f09e4ad..6395e8f 100644 --- a/texture_resource/editor_plugin_packer_image_resource.h +++ b/texture_resource/editor_plugin_packer_image_resource.h @@ -23,7 +23,14 @@ SOFTWARE. #ifndef EDITOR_PLUGIN_PACKER_IMAGE_RESOURCE_H #define EDITOR_PLUGIN_PACKER_IMAGE_RESOURCE_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/string/ustring.h" +#else #include "core/ustring.h" +#endif + #include "editor/editor_plugin.h" #include "packer_image_resource_importer.h" diff --git a/texture_resource/packer_image_resource.h b/texture_resource/packer_image_resource.h index 6352273..b8c3a76 100644 --- a/texture_resource/packer_image_resource.h +++ b/texture_resource/packer_image_resource.h @@ -23,7 +23,14 @@ SOFTWARE. #ifndef PACKER_IMAGE_REOURCE_H #define PACKER_IMAGE_REOURCE_H +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/image.h" +#else #include "core/image.h" +#endif + #include "scene/resources/texture.h" class PackerImageResource : public Texture { diff --git a/texture_resource/packer_image_resource_importer.h b/texture_resource/packer_image_resource_importer.h index b688293..cfc7aef 100644 --- a/texture_resource/packer_image_resource_importer.h +++ b/texture_resource/packer_image_resource_importer.h @@ -23,11 +23,19 @@ SOFTWARE. #ifndef PACKER_IMAGE_RESOURCE_H #define PACKER_IMAGE_RESOURCE_H -#include "core/io/resource_saver.h" +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/string/ustring.h" +#include "core/io/image.h" +#else #include "core/ustring.h" +#include "core/image.h" +#endif + +#include "core/io/resource_saver.h" #include "editor/import/editor_import_plugin.h" -#include "core/image.h" #include "core/io/image_loader.h" #include "packer_image_resource.h"