diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/api/Config.h | 2 | ||||
-rw-r--r-- | src/crepe/api/Sprite.cpp | 5 | ||||
-rw-r--r-- | src/crepe/api/Sprite.h | 4 | ||||
-rw-r--r-- | src/crepe/api/Texture.cpp | 11 | ||||
-rw-r--r-- | src/crepe/api/Texture.h | 5 |
5 files changed, 22 insertions, 5 deletions
diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h index 9b43cdf..2525120 100644 --- a/src/crepe/api/Config.h +++ b/src/crepe/api/Config.h @@ -33,7 +33,7 @@ public: * * Only messages with equal or higher priority than this value will be logged. */ - Log::Level level = Log::Level::DEBUG; + Log::Level level = Log::Level::INFO; /** * \brief Colored log output * diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index 21c8377..65c6cc3 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -1,4 +1,5 @@ #include <cmath> +#include <utility> #include "../util/Log.h" @@ -9,12 +10,12 @@ using namespace std; using namespace crepe; -Sprite::Sprite(game_object_id_t id, const Texture & image, const Color & color, +Sprite::Sprite(game_object_id_t id, Texture & image, const Color & color, const FlipSettings & flip, uint8_t sort_layer, uint8_t order_layer, int height) : Component(id), color(color), flip(flip), - sprite_image(image), + sprite_image(std::move(image)), sorting_in_layer(sort_layer), order_in_layer(order_layer), height(height) { diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index c406b91..9d75ab6 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -45,7 +45,7 @@ public: * \param sort_layer decides the order in layer of the sprite. * \param height the height of the image in game units */ - Sprite(game_object_id_t id, const Texture & image, const Color & color, + Sprite(game_object_id_t id, Texture & image, const Color & color, const FlipSettings & flip, uint8_t sort_layer, uint8_t order_layer, int height); /** @@ -54,7 +54,7 @@ public: ~Sprite(); //! Texture used for the sprite - const Texture & sprite_image; + const Texture sprite_image; //! Color tint of the sprite Color color; diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp index eeb86e9..576bdc3 100644 --- a/src/crepe/api/Texture.cpp +++ b/src/crepe/api/Texture.cpp @@ -17,6 +17,17 @@ Texture::~Texture() { this->texture.reset(); } +Texture::Texture(Texture&& other) noexcept + : texture(std::move(other.texture)){ +} + +Texture& Texture::operator=(Texture&& other) noexcept { + if (this != &other) { + texture = std::move(other.texture); + } + return *this; +} + void Texture::load(const Asset & res) { SDLContext & ctx = SDLContext::get_instance(); this->texture = ctx.texture_from_path(res.get_path()); diff --git a/src/crepe/api/Texture.h b/src/crepe/api/Texture.h index b4f7d07..dc4a6d7 100644 --- a/src/crepe/api/Texture.h +++ b/src/crepe/api/Texture.h @@ -35,6 +35,11 @@ public: */ ~Texture(); // FIXME: this constructor shouldn't be necessary because this class doesn't manage memory + + Texture(Texture&& other) noexcept; + Texture& operator=(Texture&& other) noexcept; + Texture(const Texture&) = delete; + Texture& operator=(const Texture&) = delete; /** * \brief Gets the width of the texture. |