From 29b5251f971b7695bd030bc331fe71f3d7965ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 11 Jan 2018 21:17:01 -0300 Subject: [PATCH] Renamed SubTexture to TextureRegion. Fixed a bug with frambuffers and views. --HG-- branch : dev-2.1 --- include/eepp/graphics.hpp | 2 +- include/eepp/graphics/drawable.hpp | 2 +- include/eepp/graphics/drawableresource.hpp | 2 +- include/eepp/graphics/framebuffer.hpp | 1 - include/eepp/graphics/globaltextureatlas.hpp | 4 +- include/eepp/graphics/ninepatch.hpp | 8 +- include/eepp/graphics/packerhelper.hpp | 8 +- include/eepp/graphics/scrollparallax.hpp | 24 +- include/eepp/graphics/sprite.hpp | 66 ++--- include/eepp/graphics/textureatlas.hpp | 38 +-- include/eepp/graphics/textureatlasloader.hpp | 6 +- include/eepp/graphics/textureatlasmanager.hpp | 24 +- include/eepp/graphics/texturepacker.hpp | 10 +- .../{subtexture.hpp => textureregion.hpp} | 82 +++---- include/eepp/maps.hpp | 4 +- include/eepp/maps/gameobjectobject.hpp | 2 +- include/eepp/maps/gameobjectsubtextureex.hpp | 33 --- ...exture.hpp => gameobjecttextureregion.hpp} | 18 +- .../eepp/maps/gameobjecttextureregionex.hpp | 33 +++ include/eepp/maps/gameobjectvirtual.hpp | 6 +- include/eepp/maps/mapeditor/mapeditor.hpp | 14 +- include/eepp/maps/maphelper.hpp | 4 +- include/eepp/ui.hpp | 2 +- include/eepp/ui/tools/textureatlaseditor.hpp | 14 +- include/eepp/ui/uihelper.hpp | 2 +- include/eepp/ui/uisprite.hpp | 6 +- .../{uisubtexture.hpp => uitextureregion.hpp} | 20 +- include/eepp/window/window.hpp | 2 +- projects/linux/ee.files | 21 +- src/eepp/graphics/drawablesearcher.cpp | 14 +- src/eepp/graphics/framebuffer.cpp | 2 +- src/eepp/graphics/framebufferfbo.cpp | 8 +- src/eepp/graphics/ninepatch.cpp | 32 +-- src/eepp/graphics/scrollparallax.cpp | 48 ++-- src/eepp/graphics/sprite.cpp | 66 ++--- src/eepp/graphics/textureatlas.cpp | 24 +- src/eepp/graphics/textureatlasloader.cpp | 70 +++--- src/eepp/graphics/textureatlasmanager.cpp | 88 +++---- src/eepp/graphics/texturepacker.cpp | 62 ++--- .../{subtexture.cpp => textureregion.cpp} | 98 ++++---- src/eepp/maps/gameobjectsprite.cpp | 26 +- src/eepp/maps/gameobjectsubtexture.cpp | 122 ---------- src/eepp/maps/gameobjectsubtextureex.cpp | 99 -------- src/eepp/maps/gameobjecttextureregion.cpp | 122 ++++++++++ src/eepp/maps/gameobjecttextureregionex.cpp | 99 ++++++++ src/eepp/maps/gameobjectvirtual.cpp | 32 +-- src/eepp/maps/mapeditor/mapeditor.cpp | 132 +++++----- src/eepp/maps/tilemap.cpp | 30 +-- src/eepp/ui/tools/textureatlaseditor.cpp | 100 ++++---- .../ui/tools/textureatlassubtextureeditor.hpp | 44 ---- ...pp => textureatlastextureregioneditor.cpp} | 38 +-- .../tools/textureatlastextureregioneditor.hpp | 44 ++++ src/eepp/ui/uicheckbox.cpp | 2 +- src/eepp/ui/uicombobox.cpp | 2 +- src/eepp/ui/uimenuseparator.cpp | 2 +- src/eepp/ui/uinode.cpp | 2 +- src/eepp/ui/uiradiobutton.cpp | 2 +- src/eepp/ui/uiscrollbar.cpp | 2 +- src/eepp/ui/uiskin.cpp | 2 +- src/eepp/ui/uiskinsimple.cpp | 8 +- src/eepp/ui/uislider.cpp | 2 +- src/eepp/ui/uispinbox.cpp | 2 +- src/eepp/ui/uisprite.cpp | 42 ++-- src/eepp/ui/uisubtexture.cpp | 227 ------------------ src/eepp/ui/uitextureregion.cpp | 227 ++++++++++++++++++ src/eepp/ui/uitheme.cpp | 16 +- src/eepp/ui/uiwidgetcreator.cpp | 4 +- src/eepp/ui/uiwindow.cpp | 6 +- src/eepp/ui/uiwinmenu.cpp | 2 +- src/eepp/window/window.cpp | 6 +- src/examples/sprites/sprites.cpp | 8 +- src/test/eetest.cpp | 8 +- src/test/eetest.hpp | 2 +- 73 files changed, 1216 insertions(+), 1216 deletions(-) rename include/eepp/graphics/{subtexture.hpp => textureregion.hpp} (59%) delete mode 100644 include/eepp/maps/gameobjectsubtextureex.hpp rename include/eepp/maps/{gameobjectsubtexture.hpp => gameobjecttextureregion.hpp} (52%) create mode 100644 include/eepp/maps/gameobjecttextureregionex.hpp rename include/eepp/ui/{uisubtexture.hpp => uitextureregion.hpp} (67%) rename src/eepp/graphics/{subtexture.cpp => textureregion.cpp} (71%) delete mode 100644 src/eepp/maps/gameobjectsubtexture.cpp delete mode 100644 src/eepp/maps/gameobjectsubtextureex.cpp create mode 100644 src/eepp/maps/gameobjecttextureregion.cpp create mode 100644 src/eepp/maps/gameobjecttextureregionex.cpp delete mode 100644 src/eepp/ui/tools/textureatlassubtextureeditor.hpp rename src/eepp/ui/tools/{textureatlassubtextureeditor.cpp => textureatlastextureregioneditor.cpp} (50%) create mode 100644 src/eepp/ui/tools/textureatlastextureregioneditor.hpp delete mode 100644 src/eepp/ui/uisubtexture.cpp create mode 100644 src/eepp/ui/uitextureregion.cpp diff --git a/include/eepp/graphics.hpp b/include/eepp/graphics.hpp index c4f879c07..b0ce0ae37 100644 --- a/include/eepp/graphics.hpp +++ b/include/eepp/graphics.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/eepp/graphics/drawable.hpp b/include/eepp/graphics/drawable.hpp index 72cc541ad..5b6988f2d 100644 --- a/include/eepp/graphics/drawable.hpp +++ b/include/eepp/graphics/drawable.hpp @@ -14,7 +14,7 @@ class EE_API Drawable { public: enum Type { TEXTURE, - SUBTEXTURE, + TEXTUREREGION, SPRITE, ARC, RECTANGLE, diff --git a/include/eepp/graphics/drawableresource.hpp b/include/eepp/graphics/drawableresource.hpp index aa575e703..b2ea4b588 100644 --- a/include/eepp/graphics/drawableresource.hpp +++ b/include/eepp/graphics/drawableresource.hpp @@ -9,7 +9,7 @@ namespace EE { namespace Graphics { class EE_API DrawableResource : public Drawable { public: - /** @return The DrawableResource Id. The Id is the String::hash of the SubTexture name. */ + /** @return The DrawableResource Id. The Id is the String::hash of the name. */ const Uint32& getId() const; /** @return The DrawableResource Name. */ diff --git a/include/eepp/graphics/framebuffer.hpp b/include/eepp/graphics/framebuffer.hpp index e61c71180..e13f9e63a 100644 --- a/include/eepp/graphics/framebuffer.hpp +++ b/include/eepp/graphics/framebuffer.hpp @@ -108,7 +108,6 @@ class EE_API FrameBuffer { Texture * mTexture; ColorAf mClearColor; View mView; - View mPrevView; float mProjMat[16]; float mModelViewMat[16]; diff --git a/include/eepp/graphics/globaltextureatlas.hpp b/include/eepp/graphics/globaltextureatlas.hpp index 0a2356f9a..7350d9924 100644 --- a/include/eepp/graphics/globaltextureatlas.hpp +++ b/include/eepp/graphics/globaltextureatlas.hpp @@ -9,8 +9,8 @@ using namespace EE::System; namespace EE { namespace Graphics { -/** @brief Any SubTexture that doesn't belong to an specific TextureAtlas ( a real texture atlas texture ), goes here. - This is useful to auto release the SubTextures. +/** @brief Any TextureRegion that doesn't belong to an specific TextureAtlas ( a real texture atlas texture ), goes here. + This is useful to auto release the TextureRegions. */ class EE_API GlobalTextureAtlas : public TextureAtlas { SINGLETON_DECLARE_HEADERS(GlobalTextureAtlas) diff --git a/include/eepp/graphics/ninepatch.hpp b/include/eepp/graphics/ninepatch.hpp index 370667592..dd4a09e3b 100644 --- a/include/eepp/graphics/ninepatch.hpp +++ b/include/eepp/graphics/ninepatch.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include namespace EE { namespace Graphics { @@ -24,7 +24,7 @@ class EE_API NinePatch : public DrawableResource { NinePatch( const Uint32& TexId, int left, int top, int right, int bottom, const Float& pixelDensity = 1, const std::string& name = "" ); - NinePatch( SubTexture * subTexture, int left, int top, int right, int bottom, const std::string& name = "" ); + NinePatch( TextureRegion * textureRegion, int left, int top, int right, int bottom, const std::string& name = "" ); ~NinePatch(); @@ -36,9 +36,9 @@ class EE_API NinePatch : public DrawableResource { virtual void draw( const Vector2f& position, const Sizef& size ); - SubTexture * getSubTexture( const int& side ); + TextureRegion * getTextureRegion( const int& side ); protected: - SubTexture * mDrawable[ SideCount ]; + TextureRegion * mDrawable[ SideCount ]; Rect mRect; Rectf mRectf; Sizei mSize; diff --git a/include/eepp/graphics/packerhelper.hpp b/include/eepp/graphics/packerhelper.hpp index 984f20371..80e8d1f0e 100644 --- a/include/eepp/graphics/packerhelper.hpp +++ b/include/eepp/graphics/packerhelper.hpp @@ -7,7 +7,7 @@ namespace EE { namespace Graphics { namespace Private { #define HDR_NAME_SIZE 64 -typedef struct sSubTextureHdrSN { +typedef struct sTextureRegionHdrSN { char Name[ HDR_NAME_SIZE ]; Uint64 Date; Int32 X; @@ -22,15 +22,15 @@ typedef struct sSubTextureHdrSN { Int32 DestHeight; Uint32 Flags; Uint32 PixelDensity; -} sSubTextureHdr; +} sTextureRegionHdr; -#define HDR_SUBTEXTURE_FLAG_FLIPED ( 1 << 0 ) +#define HDR_TEXTUREREGION_FLAG_FLIPED ( 1 << 0 ) typedef struct sTextureHdrS { char Name[ HDR_NAME_SIZE ]; Uint32 ResourceID; Uint32 Size; - Int32 SubTextureCount; + Int32 TextureRegionCount; } sTextureHdr; typedef struct sTextureAtlasHdrSN { diff --git a/include/eepp/graphics/scrollparallax.hpp b/include/eepp/graphics/scrollparallax.hpp index d56779747..68d174e6e 100755 --- a/include/eepp/graphics/scrollparallax.hpp +++ b/include/eepp/graphics/scrollparallax.hpp @@ -3,14 +3,14 @@ #include #include -#include +#include #include using namespace EE::System; namespace EE { namespace Graphics { -/** @brief The scroll parallax renders a SubTexture to the screen from a position and a size specified. If the size is bigger than the SubTexture, the SubTexture is rendered as a repeated SubTexture until it covers all the size of the parallax, adding movement to more than one Scroll Parallax will generate the ilusion of depth. +/** @brief The scroll parallax renders a TextureRegion to the screen from a position and a size specified. If the size is bigger than the TextureRegion, the TextureRegion is rendered as a repeated TextureRegion until it covers all the size of the parallax, adding movement to more than one Scroll Parallax will generate the ilusion of depth. ** More info in wikipedia: http://en.wikipedia.org/wiki/Parallax_scrolling */ class EE_API ScrollParallax { @@ -20,16 +20,16 @@ class EE_API ScrollParallax { ~ScrollParallax(); /** Constructor that create's the Scroll Parallax - * @param SubTexture The SubTexture to Draw + * @param TextureRegion The TextureRegion to Draw * @param Position The position of the parallax * @param Size The size of the parallax * @param Speed Speed of movement ( in Pixels Per Second ) * @param Color The Texture Color * @param Blend The Blend Mode ( default BlendAlpha ) */ - ScrollParallax( Graphics::SubTexture * subTexture, const Vector2f& position = Vector2f(), const Sizef& size = Sizef(), const Vector2f& speed = Vector2f(), const Color& color = Color::White, const BlendMode& Blend = BlendAlpha ); + ScrollParallax( Graphics::TextureRegion * TextureRegion, const Vector2f& position = Vector2f(), const Sizef& size = Sizef(), const Vector2f& speed = Vector2f(), const Color& color = Color::White, const BlendMode& Blend = BlendAlpha ); /** Create's the Scroll Parallax - * @param SubTexture The SubTexture to Draw + * @param TextureRegion The TextureRegion to Draw * @param Position The position of the parallax * @param Size The size of the parallax * @param Speed Speed of movement ( in Pixels Per Second ) @@ -37,7 +37,7 @@ class EE_API ScrollParallax { * @param Blend The Blend Mode ( default BlendAlpha ) * @return True if success */ - bool create( Graphics::SubTexture * subTexture, const Vector2f& position = Vector2f(), const Sizef& size = Sizef(), const Vector2f& speed = Vector2f(), const Color& color = Color::White, const BlendMode& Blend = BlendAlpha ); + bool create( Graphics::TextureRegion * TextureRegion, const Vector2f& position = Vector2f(), const Sizef& size = Sizef(), const Vector2f& speed = Vector2f(), const Color& color = Color::White, const BlendMode& Blend = BlendAlpha ); /** Set the parallax texture color. */ void setColor( const Color& Color ) { mColor = Color; } @@ -68,11 +68,11 @@ class EE_API ScrollParallax { /** @return The parallax position */ const Vector2f& getPosition() const; - /** @return The SubTexture used for the parallax.*/ - Graphics::SubTexture * getSubTexture() const; + /** @return The TextureRegion used for the parallax.*/ + Graphics::TextureRegion * getTextureRegion() const; - /** Set Change the SubTexture used for the parallax. */ - void setSubTexture( Graphics::SubTexture * subTexture ); + /** Set Change the TextureRegion used for the parallax. */ + void setTextureRegion( Graphics::TextureRegion * TextureRegion ); /** Set the parallax speed movement. */ void setSpeed( const Vector2f& speed ); @@ -80,7 +80,7 @@ class EE_API ScrollParallax { /** @return The parallax movement speed. */ const Vector2f& getSpeed() const; private: - Graphics::SubTexture * mSubTexture; + Graphics::TextureRegion * mTextureRegion; BlendMode mBlend; Color mColor; Vector2f mInitPos; @@ -93,7 +93,7 @@ class EE_API ScrollParallax { Rectf mAABB; Sizef mRealSize; - void setSubTexture(); + void setTextureRegion(); void setAABB(); }; diff --git a/include/eepp/graphics/sprite.hpp b/include/eepp/graphics/sprite.hpp index 9c65f8e40..035c8b42e 100755 --- a/include/eepp/graphics/sprite.hpp +++ b/include/eepp/graphics/sprite.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include @@ -33,20 +33,20 @@ class EE_API Sprite : public Drawable { * @param name First part of the sub texture name * @param extension Extension of the sub texture name ( if have one, otherwise is empty ) * @param SearchInTextureAtlas If you want only to search in a especific atlas ( NULL if you want to search in all atlases ) - * @note Texture atlases saves the SubTextures names without extension by default. - * @see TextureAtlasManager::GetSubTexturesByPattern + * @note Texture atlases saves the TextureRegions names without extension by default. + * @see TextureAtlasManager::GetTextureRegionsByPattern */ Sprite( const std::string& name, const std::string& extension = "", TextureAtlas * SearchInTextureAtlas = NULL ); - /** Creates a Sprite from a SubTexture - ** @param SubTexture The subtexture to use */ - Sprite( SubTexture * SubTexture ); + /** Creates a Sprite from a TextureRegion + ** @param TextureRegion The TextureRegion to use */ + Sprite( TextureRegion * TextureRegion ); - /** Creates a Sprite instance that holds a new SubTexture from a texture already loaded. - * @param TexId The texture Id used to create the SubTexture - * @param DestSize The destination size of the SubTexture created - * @param Offset The offset added to the position of the frame ( the SubTexture ) - * @param TexSector The sector of the texture used by the SubTexture to be rendered + /** Creates a Sprite instance that holds a new TextureRegion from a texture already loaded. + * @param TexId The texture Id used to create the TextureRegion + * @param DestSize The destination size of the TextureRegion created + * @param Offset The offset added to the position of the frame ( the TextureRegion ) + * @param TexSector The sector of the texture used by the TextureRegion to be rendered */ Sprite( const Uint32& TexId, const Sizef &DestSize = Sizef(0,0), const Vector2i &offset = Vector2i(0,0), const Rect& TexSector = Rect(0,0,0,0) ); @@ -91,7 +91,7 @@ class EE_API Sprite : public Drawable { */ void setSize( const Sizef& size, const unsigned int& FrameNum, const unsigned int& SubFrame ); - /** Set the current SubTexture Size ( destination size ) */ + /** Set the current TextureRegion Size ( destination size ) */ void setSize( const Sizef& size ); /** @return the Frame Number Sprite Size @@ -165,15 +165,15 @@ class EE_API Sprite : public Drawable { void disableVertexColors(); /** Creates an static sprite (no animation) - * @param SubTexture The sprite SubTexture + * @param TextureRegion The sprite TextureRegion * @return True if success */ - bool createStatic( SubTexture * SubTexture ); + bool createStatic( TextureRegion * TextureRegion ); - /** Creates an static sprite (no animation). It creates a new SubTexture. + /** Creates an static sprite (no animation). It creates a new TextureRegion. * @param TexId The internal Texture Id - * @param DestSize The destination size of the SubTexture created - * @param Offset The offset added to the position of the frame ( the SubTexture ) + * @param DestSize The destination size of the TextureRegion created + * @param Offset The offset added to the position of the frame ( the TextureRegion ) * @param TexSector The texture sector to be rendered ( default all the texture ) * @return True if success */ @@ -194,20 +194,20 @@ class EE_API Sprite : public Drawable { unsigned int addFrame( const Uint32& TexId, const Sizef& DestSize = Sizef(0,0), const Vector2i& offset = Vector2i(0,0), const Rect& TexSector = Rect(0,0,0,0) ); /** Add a frame to the sprite (on the current sub frame) - * @param SubTexture The SubTexture used in the frame + * @param TextureRegion The TextureRegion used in the frame * @return The frame position or 0 if fails */ - unsigned int addFrame( SubTexture * SubTexture ); + unsigned int addFrame( TextureRegion * TextureRegion ); - /** Add a vector of SubTexture as an animation. - * @param SubTextures The Frames + /** Add a vector of TextureRegion as an animation. + * @param TextureRegions The Frames */ - bool addFrames( const std::vector SubTextures ); + bool addFrames( const std::vector TextureRegions ); - /** @see TextureAtlasManager::GetSubTexturesByPattern */ + /** @see TextureAtlasManager::GetTextureRegionsByPattern */ bool addFramesByPattern( const std::string& name, const std::string& extension = "", TextureAtlas * SearchInTextureAtlas = NULL ); - bool addFramesByPatternId( const Uint32& SubTextureId, const std::string& extension, TextureAtlas * SearchInTextureAtlas ); + bool addFramesByPatternId( const Uint32& TextureRegionId, const std::string& extension, TextureAtlas * SearchInTextureAtlas ); /** Add a frame on an specific subframe to the sprite * @param TexId The internal Texture Id @@ -221,12 +221,12 @@ class EE_API Sprite : public Drawable { bool addSubFrame( const Uint32& TexId, const unsigned int& NumFrame, const unsigned int& NumSubFrame, const Sizef& DestSize = Sizef(0,0), const Vector2i& offset = Vector2i(0,0), const Rect& TexSector = Rect(0,0,0,0) ); /** Add a frame on an specific subframe to the sprite - * @param SubTexture The SubTexture used in the frame + * @param TextureRegion The TextureRegion used in the frame * @param NumFrame The Frame Number * @param NumSubFrame The Sub Frame Number * @return True if success */ - bool addSubFrame( SubTexture * SubTexture, const unsigned int& NumFrame, const unsigned int& NumSubFrame ); + bool addSubFrame( TextureRegion * TextureRegion, const unsigned int& NumFrame, const unsigned int& NumSubFrame ); /** Draw the sprite to the screen */ void draw(); @@ -274,14 +274,14 @@ class EE_API Sprite : public Drawable { /** Will set Reverse active and set the first frame as the last frame */ void setReverseFromStart(); - /** @return The Current SubTexture */ - SubTexture * getCurrentSubTexture(); + /** @return The Current TextureRegion */ + TextureRegion * getCurrentTextureRegion(); - /** @return The SubTexture Frame from the current sub frame */ - SubTexture * getSubTexture( const unsigned int& frame ); + /** @return The TextureRegion Frame from the current sub frame */ + TextureRegion * getTextureRegion( const unsigned int& frame ); - /** @return The SubTexture Frame from the SubFrame */ - SubTexture * getSubTexture( const unsigned int& frame, const unsigned int& SubFrame ); + /** @return The TextureRegion Frame from the SubFrame */ + TextureRegion * getTextureRegion( const unsigned int& frame, const unsigned int& SubFrame ); /** Start playing from ** @param GoTo Frame that goes from 1 to Number of Frames @@ -346,7 +346,7 @@ class EE_API Sprite : public Drawable { class Frame { public: - std::vector Spr; + std::vector Spr; }; std::vector mFrames; diff --git a/include/eepp/graphics/textureatlas.hpp b/include/eepp/graphics/textureatlas.hpp index 373ca1b80..690cc2392 100644 --- a/include/eepp/graphics/textureatlas.hpp +++ b/include/eepp/graphics/textureatlas.hpp @@ -2,7 +2,7 @@ #define EE_GRAPHICSCTEXTUREATLAS_H #include -#include +#include #include using namespace EE::System; @@ -11,45 +11,45 @@ namespace EE { namespace Graphics { /** @brief The texture atlas class represents a large image containing a collection of sub-images, or "atlas" which contains many smaller sub-images. * The texture atlas in eepp can represent more than one texture or image, but the common use should be a image with sub-images. * More information about Texture Atlases: http://en.wikipedia.org/wiki/Texture_atlas */ -class EE_API TextureAtlas : public ResourceManager { +class EE_API TextureAtlas : public ResourceManager { public: /** Creates a new texture atlas with the given name. */ TextureAtlas( const std::string& name = "" ); ~TextureAtlas(); - /** Adds a SubTexture to the Texture Atlas */ - SubTexture * add( SubTexture * subTexture ); + /** Adds a TextureRegion to the Texture Atlas */ + TextureRegion * add( TextureRegion * textureRegion ); - /** Creates and add to the texture atlas a SubTexture from a Texture. It will use the full Texture as a SubTexture. + /** Creates and add to the texture atlas a TextureRegion from a Texture. It will use the full Texture as a TextureRegion. * @param TexId The texture id * @param Name The texture name ( if any ) */ - SubTexture * add( const Uint32& TexId, const std::string& Name = "" ); + TextureRegion * add( const Uint32& TexId, const std::string& Name = "" ); - /** Creates and add to the texture atlas a SubTexture of the indicated part of the texture. + /** Creates and add to the texture atlas a TextureRegion of the indicated part of the texture. * @param TexId The texture id - * @param SrcRect The texture part that will be used as the SubTexture. + * @param SrcRect The texture part that will be used as the TextureRegion. * @param Name The texture name ( if any ) */ - SubTexture * add( const Uint32& TexId, const Rect& SrcRect, const std::string& Name = "" ); + TextureRegion * add( const Uint32& TexId, const Rect& SrcRect, const std::string& Name = "" ); - /** Creates and add to the texture atlas a SubTexture of the indicated part of the texture. + /** Creates and add to the texture atlas a TextureRegion of the indicated part of the texture. * @param TexId The texture id - * @param SrcRect The texture part that will be used as the SubTexture. - * @param DestSize The destination size that the SubTexture will have when rendered. + * @param SrcRect The texture part that will be used as the TextureRegion. + * @param DestSize The destination size that the TextureRegion will have when rendered. * @param Name The texture name ( if any ) */ - SubTexture * add( const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const std::string& Name = "" ); + TextureRegion * add( const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const std::string& Name = "" ); - /** Creates and add to the texture atlas a SubTexture of the indicated part of the texture. + /** Creates and add to the texture atlas a TextureRegion of the indicated part of the texture. * @param TexId The texture id - * @param SrcRect The texture part that will be used as the SubTexture. - * @param DestSize The destination size that the SubTexture will have when rendered. + * @param SrcRect The texture part that will be used as the TextureRegion. + * @param DestSize The destination size that the TextureRegion will have when rendered. * @param Offset The offset that will be added to the position passed when any Draw call is used. * @param Name The texture name ( if any ) */ - SubTexture * add( const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const Vector2i& Offset, const std::string& Name = "" ); + TextureRegion * add( const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const Vector2i& Offset, const std::string& Name = "" ); /** @return The texture atlas name. */ const std::string& getName() const; @@ -66,12 +66,12 @@ class EE_API TextureAtlas : public ResourceManager { /** @return The texture atlas Id. The Id is the String::hash of the texture atlas name. */ const Uint32& getId() const; - /** @return The number of SubTextures inside the texture atlas. */ + /** @return The number of TextureRegions inside the texture atlas. */ Uint32 getCount(); /** @return The texture that corresponds to the texture atlas. * @param texnum The texture index. A texture atlas can use more than one texture, so it can be 0 to GetTexturesLoadedCount(). Usually a texture atlas corresponds to only one texture, so the texture index is 0. - * @note Some texture atlases could not have any texture, since you can use it as a container of SubTextures from any texture. \n + * @note Some texture atlases could not have any texture, since you can use it as a container of TextureRegions from any texture. \n * The texture atlases loaded from a file always will be linked to a texture. \n * The Global Texture Atlas for example doesn't have any texture linked to it. */ diff --git a/include/eepp/graphics/textureatlasloader.hpp b/include/eepp/graphics/textureatlasloader.hpp index 87cfc3460..2b8cea953 100644 --- a/include/eepp/graphics/textureatlasloader.hpp +++ b/include/eepp/graphics/textureatlasloader.hpp @@ -106,7 +106,7 @@ class EE_API TextureAtlasLoader { */ bool updateTextureAtlas( std::string TextureAtlasPath, std::string ImagesPath ); - /** Rewrites the texture atlas file. Usefull if the SubTextures where modified and need to be updated inside the texture atlas. */ + /** Rewrites the texture atlas file. Usefull if the TextureRegions where modified and need to be updated inside the texture atlas. */ bool updateTextureAtlas(); /** @return The texture that corresponds to the texture atlas. @@ -136,13 +136,13 @@ class EE_API TextureAtlasLoader { typedef struct sTempTexAtlasS { sTextureHdr Texture; - std::vector SubTextures; + std::vector TextureRegions; } sTempTexAtlas; sTextureAtlasHdr mTexGrHdr; std::vector mTempAtlass; - void createSubTextures(); + void createTextureRegions(); }; }} diff --git a/include/eepp/graphics/textureatlasmanager.hpp b/include/eepp/graphics/textureatlasmanager.hpp index 76059bf32..bb6b21e19 100644 --- a/include/eepp/graphics/textureatlasmanager.hpp +++ b/include/eepp/graphics/textureatlasmanager.hpp @@ -2,7 +2,7 @@ #define EE_GRAPHICSCTEXTUREATLASMANAGER_HPP #include -#include +#include #include #include @@ -31,28 +31,28 @@ class EE_API TextureAtlasManager : public ResourceManager { /** Loads a texture atlas from a pack file. */ TextureAtlas * loadFromPack( Pack * Pack, const std::string& FilePackPath ); - /** It will search for a SubTexture Name in the texture atlases loaded. - * @return The first SubTexture found with the given name in any atlas. */ - SubTexture * getSubTextureByName( const std::string& Name ); + /** It will search for a TextureRegion Name in the texture atlases loaded. + * @return The first TextureRegion found with the given name in any atlas. */ + TextureRegion * getTextureRegionByName( const std::string& Name ); - /** It will search for a SubTexture Id in the texture atlases loaded. - * @return The first SubTexture found with the given id in any atlas. */ - SubTexture * getSubTextureById( const Uint32& Id ); + /** It will search for a TextureRegion Id in the texture atlases loaded. + * @return The first TextureRegion found with the given id in any atlas. */ + TextureRegion * getTextureRegionById( const Uint32& Id ); /** Search for a pattern name * For example search for name "car" with extensions "png", i will try to find car00.png car01.png car02.png, and so on, it will continue if find something, otherwise it will stop ( it will always search at least for car00.png and car01.png ) * @param name First part of the sub texture name * @param extension Extension of the sub texture name ( if have one, otherwise is empty ) * @param SearchInTextureAtlas If you want only to search in a especific atlas ( NULL if you want to search in all atlases ) - * @note Texture atlases saves the SubTextures names without extension by default. + * @note Texture atlases saves the TextureRegions names without extension by default. */ - std::vector getSubTexturesByPattern( const std::string& name, const std::string& extension = "", TextureAtlas * SearchInTextureAtlas = NULL ); + std::vector getTextureRegionsByPattern( const std::string& name, const std::string& extension = "", TextureAtlas * SearchInTextureAtlas = NULL ); /** Search for a pattern id. - * This will look for the SubTexture with the id passed, and it will try to find any pattern by the SubTexture name. - * @see GetSubTexturesByPattern + * This will look for the TextureRegion with the id passed, and it will try to find any pattern by the TextureRegion name. + * @see GetTextureRegionsByPattern */ - std::vector getSubTexturesByPatternId( const Uint32& SubTextureId, const std::string& extension = "", TextureAtlas * SearchInTextureAtlas = NULL ); + std::vector getTextureRegionsByPatternId( const Uint32& TextureRegionId, const std::string& extension = "", TextureAtlas * SearchInTextureAtlas = NULL ); /** Prints all the resources name to the screen. */ void printResources(); diff --git a/include/eepp/graphics/texturepacker.hpp b/include/eepp/graphics/texturepacker.hpp index a4787479b..c7a8c3abc 100644 --- a/include/eepp/graphics/texturepacker.hpp +++ b/include/eepp/graphics/texturepacker.hpp @@ -56,7 +56,7 @@ class EE_API TexturePacker { * @param MaxHeight The maximum height that the texture atlas will use. * @param PixelDensity Indicates the device pixel density that represents the resources that will the packer pack. * @param ForcePowOfTwo Indicates that if the max with and height must be adjusted to fit a power of two texture. - * @param PixelBorder Indicates how many pixels will be added to separate one image to another in the texture atlas. Usefull to avoid artifacts when rendered scaled SubTextures. Use at least 1 pixel to separate images if you will scale any SubTexture. + * @param PixelBorder Indicates how many pixels will be added to separate one image to another in the texture atlas. Usefull to avoid artifacts when rendered scaled TextureRegions. Use at least 1 pixel to separate images if you will scale any TextureRegion. * @param AllowFlipping Indicates if the images can be flipped inside the texture atlas. This is not compatible with eepp ( since it can't flip the textures back to the original orientation ). So avoid it for eepp. */ TexturePacker( const Uint32& MaxWidth, const Uint32& MaxHeight, const EE_PIXEL_DENSITY& PixelDensity = PD_MDPI, const bool& ForcePowOfTwo = true, const Uint32& PixelBorder = 0, const bool& AllowFlipping = false ); @@ -80,7 +80,7 @@ class EE_API TexturePacker { * If PackTexture() has not been called, it will be called automatically by the function ( so you don't need to call it ). * @param Filepath The path were it will be saved the new texture atlas. * @param Format The image format of the new texture atlas. - * @param SaveExtensions Indicates if the extensions of the image files must be saved. Usually you wan't to find the SubTextures by its name without extension, but this can be changed here. + * @param SaveExtensions Indicates if the extensions of the image files must be saved. Usually you wan't to find the TextureRegions by its name without extension, but this can be changed here. */ void save( const std::string& Filepath, const Image::SaveType& Format = Image::SaveType::SAVE_TYPE_PNG, const bool& SaveExtensions = false ); @@ -93,7 +93,7 @@ class EE_API TexturePacker { * @param MaxHeight The maximum height that the texture atlas will use. * @param PixelDensity Indicates the device pixel density that represents the resources that will the packer pack. * @param ForcePowOfTwo Indicates that if the max with and height must be adjusted to fit a power of two texture. - * @param PixelBorder Indicates how many pixels will be added to separate one image to another in the texture atlas. Usefull to avoid artifacts when rendered scaled SubTextures. Use at least 1 pixel to separate images if you will scale any SubTexture. + * @param PixelBorder Indicates how many pixels will be added to separate one image to another in the texture atlas. Usefull to avoid artifacts when rendered scaled TextureRegions. Use at least 1 pixel to separate images if you will scale any TextureRegion. * @param AllowFlipping Indicates if the images can be flipped inside the texture atlas. This is not compatible with eepp ( since it can't flip the textures back to the original orientation ). So avoid it for eepp. */ void setOptions( const Uint32& MaxWidth, const Uint32& MaxHeight, const EE_PIXEL_DENSITY& PixelDensity = PD_MDPI, const bool& ForcePowOfTwo = true, const Uint32& PixelBorder = 0, const bool& AllowFlipping = false ); @@ -142,7 +142,7 @@ class EE_API TexturePacker { void childSave( const Image::SaveType& Format ); - void saveSubTextures(); + void saveTextureRegions(); void newFree( Int32 x, Int32 y, Int32 getWidth, Int32 getHeight ); @@ -160,7 +160,7 @@ class EE_API TexturePacker { sTextureHdr createTextureHdr( TexturePacker * Packer ); - void createSubTexturesHdr(TexturePacker * Packer, std::vector & SubTextures ); + void createTextureRegionsHdr(TexturePacker * Packer, std::vector & TextureRegions ); TexturePackerNode * getBestFit( TexturePackerTex * t, TexturePackerNode ** prevBestFit, Int32 * EdgeCount ); diff --git a/include/eepp/graphics/subtexture.hpp b/include/eepp/graphics/textureregion.hpp similarity index 59% rename from include/eepp/graphics/subtexture.hpp rename to include/eepp/graphics/textureregion.hpp index 6273b0c41..66cfaf434 100644 --- a/include/eepp/graphics/subtexture.hpp +++ b/include/eepp/graphics/textureregion.hpp @@ -1,5 +1,5 @@ -#ifndef EE_GRAPHICSCSUBTEXTURE_H -#define EE_GRAPHICSCSUBTEXTURE_H +#ifndef EE_GRAPHICSTEXTUREREGION_HPP +#define EE_GRAPHICSTEXTUREREGION_HPP #include #include @@ -8,68 +8,68 @@ namespace EE { namespace Graphics { -/** @brief A SubTexture is a part of a texture that represent an sprite.*/ -class EE_API SubTexture : public DrawableResource { +/** @brief A TextureRegion is a part of a texture that represent an sprite.*/ +class EE_API TextureRegion : public DrawableResource { public: - /** Creates an empty SubTexture */ - SubTexture(); + /** Creates an empty TextureRegion */ + TextureRegion(); - /** Creates a SubTexture from a Texture. It will use the full Texture as a SubTexture. + /** Creates a TextureRegion from a Texture. It will use the full Texture as a TextureRegion. * @param TexId The texture id * @param Name The texture name ( if any ) */ - SubTexture( const Uint32& TexId, const std::string& name = "" ); + TextureRegion( const Uint32& TexId, const std::string& name = "" ); - /** Creates a SubTexture of the indicated part of the texture. + /** Creates a TextureRegion of the indicated part of the texture. * @param TexId The texture id - * @param SrcRect The texture part that will be used as the SubTexture. + * @param SrcRect The texture part that will be used as the TextureRegion. * @param Name The texture name ( if any ) */ - SubTexture( const Uint32& TexId, const Rect& srcRect, const std::string& name = "" ); + TextureRegion( const Uint32& TexId, const Rect& srcRect, const std::string& name = "" ); - /** Creates a SubTexture of the indicated part of the texture. + /** Creates a TextureRegion of the indicated part of the texture. * @param TexId The texture id - * @param SrcRect The texture part that will be used as the SubTexture. - * @param DestSize The destination size that the SubTexture will have when rendered. + * @param SrcRect The texture part that will be used as the TextureRegion. + * @param DestSize The destination size that the TextureRegion will have when rendered. * @param Name The texture name ( if any ) */ - SubTexture( const Uint32& TexId, const Rect& srcRect, const Sizef& destSize, const std::string& name = "" ); + TextureRegion( const Uint32& TexId, const Rect& srcRect, const Sizef& destSize, const std::string& name = "" ); - /** Creates a SubTexture of the indicated part of the texture. + /** Creates a TextureRegion of the indicated part of the texture. * @param TexId The texture id - * @param SrcRect The texture part that will be used as the SubTexture. - * @param DestSize The destination size that the SubTexture will have when rendered. + * @param SrcRect The texture part that will be used as the TextureRegion. + * @param DestSize The destination size that the TextureRegion will have when rendered. * @param Offset The offset that will be added to the position passed when any Draw call is used. * @param Name The texture name ( if any ) */ - SubTexture( const Uint32& TexId, const Rect& srcRect, const Sizef& destSize, const Vector2i& offset, const std::string& name = "" ); + TextureRegion( const Uint32& TexId, const Rect& srcRect, const Sizef& destSize, const Vector2i& offset, const std::string& name = "" ); - virtual ~SubTexture(); + virtual ~TextureRegion(); - /** @return The Texture Id that holds the SubTexture. */ + /** @return The Texture Id that holds the TextureRegion. */ const Uint32& getTextureId(); - /** Set the Texture Id that holds the SubTexture. */ + /** Set the Texture Id that holds the TextureRegion. */ void setTextureId( const Uint32& TexId ); - /** @return The Texture sector that represents the SubTexture */ + /** @return The Texture sector that represents the TextureRegion */ const Rect& getSrcRect() const; - /** Sets the Texture sector that represents the SubTexture */ + /** Sets the Texture sector that represents the TextureRegion */ void setSrcRect( const Rect& rect ); - /** @return The Destination Size of the SubTexture. */ + /** @return The Destination Size of the TextureRegion. */ const Sizef& getDestSize() const; - /** Sets the Destination Size of the SubTexture. - * The size can be different from the original size of the SubTexture. - * For example if the SubTexture width is 32 pixels, by default the destination width is 32 pixels, but it can be changed to anything want. */ + /** Sets the Destination Size of the TextureRegion. + * The size can be different from the original size of the TextureRegion. + * For example if the TextureRegion width is 32 pixels, by default the destination width is 32 pixels, but it can be changed to anything want. */ void setDestSize( const Sizef& destSize ); - /** @return The SubTexture default offset. The offset is added to the position passed when is drawed. */ + /** @return The TextureRegion default offset. The offset is added to the position passed when is drawed. */ const Vector2i& getOffset() const; - /** Set the SubTexture offset. */ + /** Set the TextureRegion offset. */ void setOffset( const Vector2i& offset ); void draw( const Float& X, const Float& Y, const Color& color = Color::White, const Float& Angle = 0.f, const Vector2f& Scale = Vector2f::One, const BlendMode& Blend = BlendAlpha, const RenderMode& Effect = RENDER_NORMAL, OriginPoint Center = OriginPoint(OriginPoint::OriginCenter) ); @@ -84,10 +84,10 @@ class EE_API SubTexture : public DrawableResource { virtual void draw(const Vector2f& position, const Sizef & size ); - /** @return The texture instance used by the SubTexture. */ + /** @return The texture instance used by the TextureRegion. */ Graphics::Texture * getTexture(); - /** Replaces a color in the SubTexture ( needs Lock() ) */ + /** Replaces a color in the TextureRegion ( needs Lock() ) */ void replaceColor( Color ColorKey, Color NewColor ); /** Creates a mask from a color. */ @@ -102,16 +102,16 @@ class EE_API SubTexture : public DrawableResource { /** Creates a copy in memory from the texture loaded in VRAM. */ void cacheColors(); - /** @return The alpha value that corresponds to the position indicated in the SubTexture. - * If the SubTexture wasn't locked before this call, it will be locked automatically. */ + /** @return The alpha value that corresponds to the position indicated in the TextureRegion. + * If the TextureRegion wasn't locked before this call, it will be locked automatically. */ Uint8 getAlphaAt( const Int32& X, const Int32& Y ); - /** @return The color that corresponds to the position indicated in the SubTexture. - * If the SubTexture wasn't locked before this call, it will be locked automatically. */ + /** @return The color that corresponds to the position indicated in the TextureRegion. + * If the TextureRegion wasn't locked before this call, it will be locked automatically. */ Color getColorAt( const Int32& X, const Int32& Y ); - /** @brief Set a color to the position indicated in the SubTexture. - * If the SubTexture wasn't locked before this call, it will be locked automatically. + /** @brief Set a color to the position indicated in the TextureRegion. + * If the TextureRegion wasn't locked before this call, it will be locked automatically. */ void setColorAt( const Int32& X, const Int32& Y, const Color& Color ); @@ -126,7 +126,7 @@ class EE_API SubTexture : public DrawableResource { * @see Texture::Unlock */ bool unlock( const bool& KeepData = false, const bool& Modified = false ); - /** @return The SubTexture size in the texture. This is the source rect size. */ + /** @return The TextureRegion size in the texture. This is the source rect size. */ Sizei getRealSize(); /** @return This is the same as Destination Size but with the values rounded as integers. */ @@ -135,11 +135,11 @@ class EE_API SubTexture : public DrawableResource { /** @return A pixel pointer to the texture loaded in memory ( downloaded from VRAM doing Lock()/Unlock() ). */ const Uint8* getPixelsPtr(); - /** Saves the SubTexture to a file in the file format specified. + /** Saves the TextureRegion to a file in the file format specified. * This will get the Texture from VRAM ( it will not work with OpenGL ES ) */ bool saveToFile( const std::string& filepath, const Image::SaveType& Format ); - /** Sets the Destination Size as the Source Rect Size ( the real size of the SubTexture ) multiplied by the pixel density. */ + /** Sets the Destination Size as the Source Rect Size ( the real size of the TextureRegion ) multiplied by the pixel density. */ void resetDestSize(); Float getPixelDensity() const; diff --git a/include/eepp/maps.hpp b/include/eepp/maps.hpp index f8542f730..fd874c8c9 100644 --- a/include/eepp/maps.hpp +++ b/include/eepp/maps.hpp @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/include/eepp/maps/gameobjectobject.hpp b/include/eepp/maps/gameobjectobject.hpp index 093e2884e..a6c181e24 100644 --- a/include/eepp/maps/gameobjectobject.hpp +++ b/include/eepp/maps/gameobjectobject.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include using namespace EE::Graphics; namespace EE { namespace Maps { diff --git a/include/eepp/maps/gameobjectsubtextureex.hpp b/include/eepp/maps/gameobjectsubtextureex.hpp deleted file mode 100644 index b5be81595..000000000 --- a/include/eepp/maps/gameobjectsubtextureex.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef CGAMEOBJECTSUBTEXTUREEX_HPP -#define CGAMEOBJECTSUBTEXTUREEX_HPP - -#include -#include - -namespace EE { namespace Maps { - -class EE_API GameObjectSubTextureEx : public GameObjectSubTexture { - public: - GameObjectSubTextureEx( const Uint32& Flags, MapLayer * Layer, Graphics::SubTexture * SubTexture = NULL, const Vector2f& Pos = Vector2f(), BlendMode Blend = BlendAlpha, RenderMode Render = RENDER_NORMAL, Float Angle = 0.f, Vector2f Scale = Vector2f::One, Color color = Color::White ); - - virtual ~GameObjectSubTextureEx(); - - virtual void draw(); - - virtual Uint32 getType() const; - - virtual bool isType( const Uint32& type ); - - virtual void setFlag( const Uint32& Flag ); - protected: - BlendMode mBlend; - RenderMode mRender; - Float mAngle; - Vector2f mScale; - Color mColor; - Color * mVertexColors; -}; - -}} - -#endif diff --git a/include/eepp/maps/gameobjectsubtexture.hpp b/include/eepp/maps/gameobjecttextureregion.hpp similarity index 52% rename from include/eepp/maps/gameobjectsubtexture.hpp rename to include/eepp/maps/gameobjecttextureregion.hpp index bb92e4bfb..af44fa55b 100644 --- a/include/eepp/maps/gameobjectsubtexture.hpp +++ b/include/eepp/maps/gameobjecttextureregion.hpp @@ -1,19 +1,19 @@ -#ifndef EE_MAPS_CGAMEOBJECTSUBTEXTURE_HPP -#define EE_MAPS_CGAMEOBJECTSUBTEXTURE_HPP +#ifndef EE_MAPS_CGAMEOBJECTTEXTUREREGION_HPP +#define EE_MAPS_CGAMEOBJECTTEXTUREREGION_HPP #include #include -#include +#include using namespace EE::Graphics; namespace EE { namespace Maps { -class EE_API GameObjectSubTexture : public GameObject { +class EE_API GameObjectTextureRegion : public GameObject { public: - GameObjectSubTexture( const Uint32& Flags, MapLayer * Layer, Graphics::SubTexture * SubTexture = NULL, const Vector2f& Pos = Vector2f() ); + GameObjectTextureRegion( const Uint32& Flags, MapLayer * Layer, Graphics::TextureRegion * TextureRegion = NULL, const Vector2f& Pos = Vector2f() ); - virtual ~GameObjectSubTexture(); + virtual ~GameObjectTextureRegion(); virtual void draw(); @@ -27,9 +27,9 @@ class EE_API GameObjectSubTexture : public GameObject { virtual Sizei getSize(); - Graphics::SubTexture * getSubTexture() const; + Graphics::TextureRegion * getTextureRegion() const; - void setSubTexture( Graphics::SubTexture * subTexture ); + void setTextureRegion( Graphics::TextureRegion * TextureRegion ); virtual Uint32 getType() const; @@ -39,7 +39,7 @@ class EE_API GameObjectSubTexture : public GameObject { virtual void setDataId( Uint32 Id ); protected: - Graphics::SubTexture * mSubTexture; + Graphics::TextureRegion * mTextureRegion; Vector2f mPos; Vector2i mTilePos; }; diff --git a/include/eepp/maps/gameobjecttextureregionex.hpp b/include/eepp/maps/gameobjecttextureregionex.hpp new file mode 100644 index 000000000..d42807c1b --- /dev/null +++ b/include/eepp/maps/gameobjecttextureregionex.hpp @@ -0,0 +1,33 @@ +#ifndef EE_GAMEOBJECTTEXTUREREGIONEX_HPP +#define EE_GAMEOBJECTTEXTUREREGIONEX_HPP + +#include +#include + +namespace EE { namespace Maps { + +class EE_API GameObjectTextureRegionEx : public GameObjectTextureRegion { + public: + GameObjectTextureRegionEx( const Uint32& Flags, MapLayer * Layer, Graphics::TextureRegion * TextureRegion = NULL, const Vector2f& Pos = Vector2f(), BlendMode Blend = BlendAlpha, RenderMode Render = RENDER_NORMAL, Float Angle = 0.f, Vector2f Scale = Vector2f::One, Color color = Color::White ); + + virtual ~GameObjectTextureRegionEx(); + + virtual void draw(); + + virtual Uint32 getType() const; + + virtual bool isType( const Uint32& type ); + + virtual void setFlag( const Uint32& Flag ); + protected: + BlendMode mBlend; + RenderMode mRender; + Float mAngle; + Vector2f mScale; + Color mColor; + Color * mVertexColors; +}; + +}} + +#endif diff --git a/include/eepp/maps/gameobjectvirtual.hpp b/include/eepp/maps/gameobjectvirtual.hpp index beb00bb34..0eb4d20a7 100644 --- a/include/eepp/maps/gameobjectvirtual.hpp +++ b/include/eepp/maps/gameobjectvirtual.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include using namespace EE::Graphics; namespace EE { namespace Maps { @@ -14,7 +14,7 @@ class EE_API GameObjectVirtual : public GameObject { public: GameObjectVirtual( Uint32 getDataId, MapLayer * Layer, const Uint32& Flags = GObjFlags::GAMEOBJECT_STATIC, Uint32 RealType = GAMEOBJECT_TYPE_VIRTUAL, const Vector2f& Pos = Vector2f() ); - GameObjectVirtual( SubTexture * SubTexture, MapLayer * Layer, const Uint32& Flags = GObjFlags::GAMEOBJECT_STATIC, Uint32 RealType = GAMEOBJECT_TYPE_VIRTUAL, const Vector2f& Pos = Vector2f() ); + GameObjectVirtual( TextureRegion * TextureRegion, MapLayer * Layer, const Uint32& Flags = GObjFlags::GAMEOBJECT_STATIC, Uint32 RealType = GAMEOBJECT_TYPE_VIRTUAL, const Vector2f& Pos = Vector2f() ); virtual ~GameObjectVirtual(); @@ -42,7 +42,7 @@ class EE_API GameObjectVirtual : public GameObject { Uint32 mDataId; Vector2f mPos; MapLayer * mLayer; - SubTexture * mSubTexture; + TextureRegion * mTextureRegion; }; }} diff --git a/include/eepp/maps/mapeditor/mapeditor.hpp b/include/eepp/maps/mapeditor/mapeditor.hpp index 3d89d51b5..0b7154968 100644 --- a/include/eepp/maps/mapeditor/mapeditor.hpp +++ b/include/eepp/maps/mapeditor/mapeditor.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -49,8 +49,8 @@ class EE_API MapEditor { MapEditorCloseCb mCloseCb; UIDropDownList * mTextureAtlasesList; UIWidget * mWinContainer; - UIListBox * mSubTextureList; - UISubTexture * mGfxPreview; + UIListBox * mTextureRegionList; + UITextureRegion * mGfxPreview; TextureAtlas * mCurSG; UIScrollBar * mMapHScroll; UIScrollBar * mMapVScroll; @@ -67,7 +67,7 @@ class EE_API MapEditor { UIPushButton * mBtnGOTypeAdd; Uint32 mCurGOType; Uint32 mCurGOFlags; - UIWidget * mSubTextureCont; + UIWidget * mTextureRegionCont; UIWidget * mLightCont; UIWidget * mObjectCont; UIWidget * mSGCont; @@ -110,7 +110,7 @@ class EE_API MapEditor { void createObjectsContainer(); - void createSubTextureContainer( Int32 Width ); + void createTextureRegionContainer( Int32 Width ); void windowClose( const UIEvent * Event ); @@ -126,7 +126,7 @@ class EE_API MapEditor { void fillSGCombo(); - void fillSubTextureList(); + void fillTextureRegionList(); void createNewMap(); @@ -144,7 +144,7 @@ class EE_API MapEditor { void mapSave( const UIEvent * Event ); - void onSubTextureChange( const UIEvent * Event ); + void onTextureRegionChange( const UIEvent * Event ); void onTypeChange( const UIEvent * Event ); diff --git a/include/eepp/maps/maphelper.hpp b/include/eepp/maps/maphelper.hpp index fd3505f64..f6d881e5e 100644 --- a/include/eepp/maps/maphelper.hpp +++ b/include/eepp/maps/maphelper.hpp @@ -94,8 +94,8 @@ class GObjFlags { enum EE_GAMEOBJECT_TYPE { GAMEOBJECT_TYPE_BASE = 2088954976UL, //String::hash( "Base" ) GAMEOBJECT_TYPE_VIRTUAL = 3708695628UL, //String::hash( "Virtual" ) - GAMEOBJECT_TYPE_SUBTEXTURE = 1772101792UL, //String::hash( "SubTexture" ) - GAMEOBJECT_TYPE_SUBTEXTUREEX = 1378537981UL, //String::hash( "SubTextureEx" ) + GAMEOBJECT_TYPE_TEXTUREREGION = 1772101792UL, //String::hash( "SubTexture" ) + GAMEOBJECT_TYPE_TEXTUREREGIONEX = 1378537981UL, //String::hash( "SubTextureEx" ) GAMEOBJECT_TYPE_SPRITE = 3517332124UL, //String::hash( "Sprite" ) GAMEOBJECT_TYPE_OBJECT = 3343895260UL, //String::hash( "Object" ) GAMEOBJECT_TYPE_POLYGON = 482716845UL, //String::hash( "Polygon" ) diff --git a/include/eepp/ui.hpp b/include/eepp/ui.hpp index 618ea7fe8..b5c9ae835 100644 --- a/include/eepp/ui.hpp +++ b/include/eepp/ui.hpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/eepp/ui/tools/textureatlaseditor.hpp b/include/eepp/ui/tools/textureatlaseditor.hpp index 77a7b506e..59a37e650 100644 --- a/include/eepp/ui/tools/textureatlaseditor.hpp +++ b/include/eepp/ui/tools/textureatlaseditor.hpp @@ -12,7 +12,7 @@ namespace EE { namespace UI { namespace Tools { -class TextureAtlasSubTextureEditor; +class TextureAtlasTextureRegionEditor; class EE_API TextureAtlasEditor { public: @@ -43,14 +43,14 @@ class EE_API TextureAtlasEditor { TGEditorCloseCb mCloseCb; TexturePacker * mTexturePacker; TextureAtlasLoader *mTextureAtlasLoader; - SubTexture * mCurSubTexture; + TextureRegion * mCurTextureRegion; UISpinBox * mSpinOffX; UISpinBox * mSpinOffY; UISpinBox * mSpinDestW; UISpinBox * mSpinDestH; - UIListBox * mSubTextureList; + UIListBox * mTextureRegionList; UIWinMenu * mWinMenu; - TextureAtlasSubTextureEditor * mSubTextureEditor; + TextureAtlasTextureRegionEditor * mTextureRegionEditor; UITGEUpdater * mTGEU; void windowClose( const UIEvent * Event ); @@ -65,11 +65,11 @@ class EE_API TextureAtlasEditor { void onTextureAtlasClose( const UIEvent * Event ); - void onSubTextureChange( const UIEvent * Event ); + void onTextureRegionChange( const UIEvent * Event ); void updateControls(); - void fillSubTextureList(); + void fillTextureRegionList(); void onOffXChange( const UIEvent * Event ); @@ -91,7 +91,7 @@ class EE_API TextureAtlasEditor { void update(); - UIWidget * createTextureAtlasSubTextureEditor( std::string name ); + UIWidget * createTextureAtlasTextureRegionEditor( std::string name ); }; }}} diff --git a/include/eepp/ui/uihelper.hpp b/include/eepp/ui/uihelper.hpp index d07e4bff0..b6422e055 100644 --- a/include/eepp/ui/uihelper.hpp +++ b/include/eepp/ui/uihelper.hpp @@ -72,7 +72,7 @@ enum UI_CONTROL_TYPES { UI_TYPE_NODE = 0, UI_TYPE_WIDGET, UI_TYPE_IMAGE, - UI_TYPE_SUBTEXTURE, + UI_TYPE_TEXTUREREGION, UI_TYPE_SPRITE, UI_TYPE_TEXTVIEW, UI_TYPE_TEXTINPUT, diff --git a/include/eepp/ui/uisprite.hpp b/include/eepp/ui/uisprite.hpp index 9f32c1d1a..945a4acc4 100644 --- a/include/eepp/ui/uisprite.hpp +++ b/include/eepp/ui/uisprite.hpp @@ -5,7 +5,7 @@ namespace EE { namespace Graphics { class Sprite; -class SubTexture; +class TextureRegion; }} namespace EE { namespace UI { @@ -51,14 +51,14 @@ class EE_API UISprite : public UIWidget { Graphics::Sprite * mSprite; RenderMode mRender; Vector2i mAlignOffset; - SubTexture * mSubTextureLast; + TextureRegion * mTextureRegionLast; bool mDealloc; void updateSize(); void autoAlign(); - void checkSubTextureUpdate(); + void checkTextureRegionUpdate(); virtual void onSizeChange(); diff --git a/include/eepp/ui/uisubtexture.hpp b/include/eepp/ui/uitextureregion.hpp similarity index 67% rename from include/eepp/ui/uisubtexture.hpp rename to include/eepp/ui/uitextureregion.hpp index 00f073d60..fc9cca7f5 100644 --- a/include/eepp/ui/uisubtexture.hpp +++ b/include/eepp/ui/uitextureregion.hpp @@ -4,18 +4,18 @@ #include namespace EE { namespace Graphics { -class SubTexture; +class TextureRegion; }} namespace EE { namespace UI { -class EE_API UISubTexture : public UIWidget { +class EE_API UITextureRegion : public UIWidget { public: - static UISubTexture * New(); + static UITextureRegion * New(); - UISubTexture(); + UITextureRegion(); - virtual ~UISubTexture(); + virtual ~UITextureRegion(); virtual Uint32 getType() const; @@ -25,9 +25,9 @@ class EE_API UISubTexture : public UIWidget { virtual void setAlpha( const Float& alpha ); - Graphics::SubTexture * getSubTexture() const; + Graphics::TextureRegion * getTextureRegion() const; - UISubTexture * setSubTexture( Graphics::SubTexture * subTexture ); + UITextureRegion * setTextureRegion( Graphics::TextureRegion * TextureRegion ); const Color& getColor() const; @@ -43,10 +43,10 @@ class EE_API UISubTexture : public UIWidget { Uint32 getScaleType() const; - UISubTexture * setScaleType(const Uint32 & scaleType); + UITextureRegion * setScaleType(const Uint32 & scaleType); protected: Uint32 mScaleType; - Graphics::SubTexture * mSubTexture; + Graphics::TextureRegion * mTextureRegion; Color mColor; RenderMode mRender; Vector2i mAlignOffset; @@ -59,7 +59,7 @@ class EE_API UISubTexture : public UIWidget { void autoAlign(); - void drawSubTexture(); + void drawTextureRegion(); }; }} diff --git a/include/eepp/window/window.hpp b/include/eepp/window/window.hpp index 0506043ac..15308744d 100644 --- a/include/eepp/window/window.hpp +++ b/include/eepp/window/window.hpp @@ -281,7 +281,7 @@ class EE_API Window { /** Set the current active view @param View New view to use (pass GetDefaultView() to set the default view) */ - void setView( const View& view ); + void setView( const View& view, bool forceRefresh = false ); /** Get the current view */ const View& getView() const; diff --git a/projects/linux/ee.files b/projects/linux/ee.files index b666562ff..483336681 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -26,6 +26,7 @@ ../../include/eepp/graphics/renderer/rendererhelper.hpp ../../include/eepp/graphics/rendermode.hpp ../../include/eepp/graphics/text.hpp +../../include/eepp/graphics/textureregion.hpp ../../include/eepp/graphics/vertexbufferhelper.hpp ../../include/eepp/math/interpolation1d.hpp ../../include/eepp/math/interpolation2d.hpp @@ -45,7 +46,7 @@ ../../include/eepp/ui/uinode.hpp ../../include/eepp/ui/uirelativelayout.hpp ../../include/eepp/ui/uiscrollview.hpp -../../include/eepp/ui/uisubtexture.hpp +../../include/eepp/ui/uitextureregion.hpp ../../include/eepp/ui/uitable.hpp ../../include/eepp/ui/uitablecell.hpp ../../include/eepp/ui/uitextview.hpp @@ -100,7 +101,7 @@ ../../src/eepp/ui/uinode.cpp ../../src/eepp/ui/uirelativelayout.cpp ../../src/eepp/ui/uiscrollview.cpp -../../src/eepp/ui/uisubtexture.cpp +../../src/eepp/ui/uitextureregion.cpp ../../src/eepp/ui/uitable.cpp ../../src/eepp/ui/uitablecell.cpp ../../src/eepp/ui/uitextview.cpp @@ -192,8 +193,8 @@ ../../include/eepp/maps/maplayer.hpp ../../include/eepp/maps/gameobjectvirtual.hpp ../../include/eepp/maps/gameobjectsprite.hpp -../../include/eepp/maps/gameobjectsubtextureex.hpp -../../include/eepp/maps/gameobjectsubtexture.hpp +../../include/eepp/maps/gameobjecttextureregionex.hpp +../../include/eepp/maps/gameobjecttextureregion.hpp ../../include/eepp/maps/gameobject.hpp ../../include/eepp/maps/base.hpp ../../src/eepp/maps/mapeditor/uimapnew.hpp @@ -210,8 +211,8 @@ ../../src/eepp/maps/maplayer.cpp ../../src/eepp/maps/gameobjectvirtual.cpp ../../src/eepp/maps/gameobjectsprite.cpp -../../src/eepp/maps/gameobjectsubtextureex.cpp -../../src/eepp/maps/gameobjectsubtexture.cpp +../../src/eepp/maps/gameobjecttextureregionex.cpp +../../src/eepp/maps/gameobjecttextureregion.cpp ../../src/eepp/maps/gameobject.cpp ../../src/eepp/maps/mapeditor/uimapnew.cpp ../../src/eepp/maps/mapeditor/uimap.cpp @@ -242,7 +243,7 @@ ../../include/eepp/graphics/sprite.hpp ../../include/eepp/graphics/textureatlasmanager.hpp ../../include/eepp/graphics/textureatlas.hpp -../../include/eepp/graphics/subtexture.hpp +../../include/eepp/graphics/textureregion.hpp ../../include/eepp/graphics/shaderprogrammanager.hpp ../../include/eepp/graphics/shaderprogram.hpp ../../include/eepp/graphics/shader.hpp @@ -358,7 +359,7 @@ ../../include/eepp/ui/uiborder.hpp ../../include/eepp/ui/uibackground.hpp ../../include/eepp/ui/base.hpp -../../src/eepp/ui/tools/textureatlassubtextureeditor.hpp +../../src/eepp/ui/tools/textureatlastextureregioneditor.hpp ../../src/eepp/ui/tools/textureatlasnew.hpp ../../include/eepp/ui/tools/textureatlaseditor.hpp ../../src/eepp/ui/uiwidgetcreator.cpp @@ -403,7 +404,7 @@ ../../src/eepp/ui/uicheckbox.cpp ../../src/eepp/ui/uiborder.cpp ../../src/eepp/ui/uibackground.cpp -../../src/eepp/ui/tools/textureatlassubtextureeditor.cpp +../../src/eepp/ui/tools/textureatlastextureregioneditor.cpp ../../src/eepp/ui/tools/textureatlasnew.cpp ../../src/eepp/ui/tools/textureatlaseditor.cpp ../../include/eepp/math/vector3.hpp @@ -554,7 +555,7 @@ ../../src/eepp/graphics/sprite.cpp ../../src/eepp/graphics/textureatlasmanager.cpp ../../src/eepp/graphics/textureatlas.cpp -../../src/eepp/graphics/subtexture.cpp +../../src/eepp/graphics/textureregion.cpp ../../src/eepp/graphics/shaderprogrammanager.cpp ../../src/eepp/graphics/shaderprogram.cpp ../../src/eepp/graphics/shader.cpp diff --git a/src/eepp/graphics/drawablesearcher.cpp b/src/eepp/graphics/drawablesearcher.cpp index 1fc79ad18..4b5634674 100644 --- a/src/eepp/graphics/drawablesearcher.cpp +++ b/src/eepp/graphics/drawablesearcher.cpp @@ -10,12 +10,12 @@ namespace EE { namespace Graphics { bool DrawableSearcher::sPrintWarnings = false; static Drawable * getSprite( const std::string& sprite ) { - std::vector tSubTextureVec = TextureAtlasManager::instance()->getSubTexturesByPattern( sprite ); + std::vector tTextureRegionVec = TextureAtlasManager::instance()->getTextureRegionsByPattern( sprite ); - if ( tSubTextureVec.size() ) { + if ( tTextureRegionVec.size() ) { Sprite * tSprite = eeNew( Graphics::Sprite, () ); tSprite->createAnimation(); - tSprite->addFrames( tSubTextureVec ); + tSprite->addFrames( tTextureRegionVec ); return tSprite; } @@ -25,7 +25,7 @@ static Drawable * getSprite( const std::string& sprite ) { static Drawable * searchByNameInternal( const std::string& name ) { Uint32 id = String::hash( name ); - Drawable * drawable = TextureAtlasManager::instance()->getSubTextureById( id ); + Drawable * drawable = TextureAtlasManager::instance()->getTextureRegionById( id ); if ( NULL == drawable) { drawable = NinePatchManager::instance()->getById( id ); @@ -43,8 +43,8 @@ Drawable * DrawableSearcher::searchByName( const std::string& name ) { if ( name.size() ) { if ( name[0] == '@' ) { - if ( String::startsWith( name, "@subtexture/" ) ) { - drawable = TextureAtlasManager::instance()->getSubTextureByName( name.substr( 12 ) ); + if ( String::startsWith( name, "@textureregion/" ) || String::startsWith( name, "@subtexture/" ) ) { + drawable = TextureAtlasManager::instance()->getTextureRegionByName( name.substr( 12 ) ); } else if ( String::startsWith( name, "@image/" ) ) { drawable = TextureFactory::instance()->getByName( name.substr( 7 ) ); } else if ( String::startsWith( name, "@texture/" ) ) { @@ -70,7 +70,7 @@ Drawable * DrawableSearcher::searchByName( const std::string& name ) { } Drawable * DrawableSearcher::searchById( const Uint32& id ) { - Drawable * drawable = TextureAtlasManager::instance()->getSubTextureById( id ); + Drawable * drawable = TextureAtlasManager::instance()->getTextureRegionById( id ); if ( NULL == drawable ) { drawable = TextureFactory::instance()->getByHash( id ); diff --git a/src/eepp/graphics/framebuffer.cpp b/src/eepp/graphics/framebuffer.cpp index 242cb1380..ab1e8a1f3 100644 --- a/src/eepp/graphics/framebuffer.cpp +++ b/src/eepp/graphics/framebuffer.cpp @@ -82,7 +82,7 @@ void FrameBuffer::recoverView() { sFBOActiveViews.remove(&mView); if ( sFBOActiveViews.empty() ) { - mWindow->setView( mWindow->getView() ); + mWindow->setView( mWindow->getView(), true ); } else { const View* view = sFBOActiveViews.back(); GLi->viewport( 0, 0, view->getSize().getWidth(), view->getSize().getHeight() ); diff --git a/src/eepp/graphics/framebufferfbo.cpp b/src/eepp/graphics/framebufferfbo.cpp index 4934e2e3f..3f6dbc5d7 100644 --- a/src/eepp/graphics/framebufferfbo.cpp +++ b/src/eepp/graphics/framebufferfbo.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include namespace EE { namespace Graphics { @@ -264,10 +264,10 @@ void FrameBufferFBO::draw( const Vector2f & position, const Sizef & size ) { void FrameBufferFBO::draw( Rect src, Rect dst ) { if ( NULL != mTexture ) { - SubTexture subTexture( getTexture()->getId(), src ); + TextureRegion textureRegion( getTexture()->getId(), src ); Sizei size( dst.getSize() ); - subTexture.setDestSize( Sizef( size.x, size.y ) ); - subTexture.draw( dst.Left, dst.Top, Color::White ); + textureRegion.setDestSize( Sizef( size.x, size.y ) ); + textureRegion.draw( dst.Left, dst.Top, Color::White ); } else if ( mColorBuffer ) { GLi->bindFramebuffer(GL_READ_FRAMEBUFFER, mFrameBuffer); GLi->bindFramebuffer(GL_DRAW_FRAMEBUFFER, mLastFB); diff --git a/src/eepp/graphics/ninepatch.cpp b/src/eepp/graphics/ninepatch.cpp index 651c5285d..1c36dc9f3 100644 --- a/src/eepp/graphics/ninepatch.cpp +++ b/src/eepp/graphics/ninepatch.cpp @@ -21,7 +21,7 @@ NinePatch::NinePatch(const Uint32& TexId, int left, int top, int right, int bott } } -NinePatch::NinePatch( SubTexture * subTexture, int left, int top, int right, int bottom, const std::string& name ): +NinePatch::NinePatch(TextureRegion * textureRegion, int left, int top, int right, int bottom, const std::string& name ): DrawableResource( Drawable::NINEPATCH, name ), mRect( left, top, right, bottom ), mPixelDensity(1) @@ -31,19 +31,19 @@ NinePatch::NinePatch( SubTexture * subTexture, int left, int top, int right, int Texture * tex; - if ( NULL != subTexture && ( tex = subTexture->getTexture() ) != NULL ) { - mPixelDensity = subTexture->getPixelDensity(); + if ( NULL != textureRegion && ( tex = textureRegion->getTexture() ) != NULL ) { + mPixelDensity = textureRegion->getPixelDensity(); - Rect r( subTexture->getSrcRect() ); + Rect r( textureRegion->getSrcRect() ); mSize = r.getSize(); createFromTexture( tex->getId(), left, top, right, bottom ); for ( int i = 0; i < SideCount; i++ ) { - SubTexture * side = static_cast( mDrawable[i] ); + TextureRegion * side = static_cast( mDrawable[i] ); - side->setPixelDensity( subTexture->getPixelDensity() ); + side->setPixelDensity( textureRegion->getPixelDensity() ); Rect sideRect = side->getSrcRect(); @@ -96,22 +96,22 @@ void NinePatch::draw( const Vector2f& position, const Sizef& size ) { } } -SubTexture * NinePatch::getSubTexture( const int& side ) { +TextureRegion * NinePatch::getTextureRegion( const int& side ) { if ( side < SideCount ) return mDrawable[ side ]; return NULL; } void NinePatch::createFromTexture(const Uint32 & TexId, int left, int top, int right, int bottom) { - mDrawable[ Left ] = eeNew( SubTexture, ( TexId, Rect( 0, top, left, mSize.getHeight() - bottom ) ) ); - mDrawable[ Right ] = eeNew( SubTexture, ( TexId, Rect( mSize.getWidth() - right, top, mSize.getWidth(), mSize.getHeight() - bottom ) ) ); - mDrawable[ Down ] = eeNew( SubTexture, ( TexId, Rect( left, mSize.getHeight() - bottom, mSize.getWidth() - right, mSize.getHeight() ) ) ); - mDrawable[ Up ] = eeNew( SubTexture, ( TexId, Rect( left, 0, mSize.getWidth() - right, top ) ) ); - mDrawable[ UpLeft ] = eeNew( SubTexture, ( TexId, Rect( 0, 0, left, top ) ) ); - mDrawable[ UpRight] = eeNew( SubTexture, ( TexId, Rect( mSize.getWidth() - right, 0, mSize.getWidth(), top ) ) ); - mDrawable[ DownLeft] = eeNew( SubTexture, ( TexId, Rect( 0, mSize.getHeight() - bottom, left, mSize.getHeight() ) ) ); - mDrawable[ DownRight ] = eeNew( SubTexture, ( TexId, Rect( mSize.getWidth() - right, mSize.getHeight() - bottom, mSize.getWidth(), mSize.getHeight() ) ) ); - mDrawable[ Center ] = eeNew( SubTexture, ( TexId, Rect( left, top, mSize.getWidth() - right, mSize.getHeight() - bottom ) ) ); + mDrawable[ Left ] = eeNew( TextureRegion, ( TexId, Rect( 0, top, left, mSize.getHeight() - bottom ) ) ); + mDrawable[ Right ] = eeNew( TextureRegion, ( TexId, Rect( mSize.getWidth() - right, top, mSize.getWidth(), mSize.getHeight() - bottom ) ) ); + mDrawable[ Down ] = eeNew( TextureRegion, ( TexId, Rect( left, mSize.getHeight() - bottom, mSize.getWidth() - right, mSize.getHeight() ) ) ); + mDrawable[ Up ] = eeNew( TextureRegion, ( TexId, Rect( left, 0, mSize.getWidth() - right, top ) ) ); + mDrawable[ UpLeft ] = eeNew( TextureRegion, ( TexId, Rect( 0, 0, left, top ) ) ); + mDrawable[ UpRight] = eeNew( TextureRegion, ( TexId, Rect( mSize.getWidth() - right, 0, mSize.getWidth(), top ) ) ); + mDrawable[ DownLeft] = eeNew( TextureRegion, ( TexId, Rect( 0, mSize.getHeight() - bottom, left, mSize.getHeight() ) ) ); + mDrawable[ DownRight ] = eeNew( TextureRegion, ( TexId, Rect( mSize.getWidth() - right, mSize.getHeight() - bottom, mSize.getWidth(), mSize.getHeight() ) ) ); + mDrawable[ Center ] = eeNew( TextureRegion, ( TexId, Rect( left, top, mSize.getWidth() - right, mSize.getHeight() - bottom ) ) ); mRect = Rect( left, top, right, bottom ); diff --git a/src/eepp/graphics/scrollparallax.cpp b/src/eepp/graphics/scrollparallax.cpp index 678fa70fb..f32fa1ae6 100755 --- a/src/eepp/graphics/scrollparallax.cpp +++ b/src/eepp/graphics/scrollparallax.cpp @@ -4,7 +4,7 @@ namespace EE { namespace Graphics { ScrollParallax::ScrollParallax() : - mSubTexture( NULL ), + mTextureRegion( NULL ), mBlend( BlendAlpha ), mColor( 255, 255, 255, 255 ) { @@ -13,24 +13,24 @@ ScrollParallax::ScrollParallax() : ScrollParallax::~ScrollParallax() {} -ScrollParallax::ScrollParallax( Graphics::SubTexture * SubTexture, const Vector2f& Position, const Sizef& Size, const Vector2f& Speed, const Color& Color, const BlendMode& Blend ) { - create( SubTexture, Position, Size, Speed, Color, Blend ); +ScrollParallax::ScrollParallax( Graphics::TextureRegion * TextureRegion, const Vector2f& Position, const Sizef& Size, const Vector2f& Speed, const Color& Color, const BlendMode& Blend ) { + create( TextureRegion, Position, Size, Speed, Color, Blend ); } -Graphics::SubTexture * ScrollParallax::getSubTexture() const { - return mSubTexture; +Graphics::TextureRegion * ScrollParallax::getTextureRegion() const { + return mTextureRegion; } -void ScrollParallax::setSubTexture( Graphics::SubTexture * subTexture ) { - mSubTexture = subTexture; +void ScrollParallax::setTextureRegion( Graphics::TextureRegion * TextureRegion ) { + mTextureRegion = TextureRegion; - setSubTexture(); + setTextureRegion(); } -void ScrollParallax::setSubTexture() { - if ( NULL != mSubTexture ) { - mRect = mSubTexture->getSrcRect(); - mRealSize = Vector2f( (Float)mSubTexture->getPxSize().getWidth(), (Float)mSubTexture->getPxSize().getHeight() ); +void ScrollParallax::setTextureRegion() { + if ( NULL != mTextureRegion ) { + mRect = mTextureRegion->getSrcRect(); + mRealSize = Vector2f( (Float)mTextureRegion->getPxSize().getWidth(), (Float)mTextureRegion->getPxSize().getHeight() ); mTiles.x = ( (Int32)mSize.getWidth() / (Int32)mRealSize.getWidth() ) + 1; mTiles.y = ( (Int32)mSize.getHeight() / (Int32)mRealSize.getHeight() ) + 1; @@ -41,8 +41,8 @@ void ScrollParallax::setAABB() { mAABB = Rectf( mInitPos.x, mInitPos.y, mInitPos.x + mSize.getWidth(), mInitPos.y + mSize.getHeight() ); } -bool ScrollParallax::create( Graphics::SubTexture * SubTexture, const Vector2f& Position, const Sizef& Size, const Vector2f& Speed, const Color& Color, const BlendMode& Blend ) { - mSubTexture = SubTexture; +bool ScrollParallax::create( Graphics::TextureRegion * TextureRegion, const Vector2f& Position, const Sizef& Size, const Vector2f& Speed, const Color& Color, const BlendMode& Blend ) { + mTextureRegion = TextureRegion; mPos = Position; mSize = Size; mInitPos = mPos; @@ -51,7 +51,7 @@ bool ScrollParallax::create( Graphics::SubTexture * SubTexture, const Vector2f& mBlend = Blend; setAABB(); - setSubTexture(); + setTextureRegion(); return true; } @@ -59,7 +59,7 @@ bool ScrollParallax::create( Graphics::SubTexture * SubTexture, const Vector2f& void ScrollParallax::setSize( const Sizef& size ) { mSize = size; - setSubTexture(); + setTextureRegion(); setAABB(); } @@ -82,7 +82,7 @@ const Vector2f& ScrollParallax::getPosition() const { } void ScrollParallax::draw() { - if ( NULL != mSubTexture && mAABB.Left != mAABB.Right && mAABB.Top != mAABB.Bottom && 0 != mColor.a ) { + if ( NULL != mTextureRegion && mAABB.Left != mAABB.Right && mAABB.Top != mAABB.Bottom && 0 != mColor.a ) { mPos += mSpeed * (Float)mElapsed.getElapsed().asSeconds(); if ( mPos.x > mAABB.Left + mRealSize.getWidth() || mPos.x < mAABB.Left - mRealSize.getWidth() ) @@ -102,8 +102,8 @@ void ScrollParallax::draw() { if ( mSpeed.y > 0.f ) Pos.y -= mRealSize.getHeight(); - Float pd = mSubTexture->getPixelDensity() / PixelDensity::getPixelDensity(); - Float ps = PixelDensity::getPixelDensity() / mSubTexture->getPixelDensity(); + Float pd = mTextureRegion->getPixelDensity() / PixelDensity::getPixelDensity(); + Float ps = PixelDensity::getPixelDensity() / mTextureRegion->getPixelDensity(); for ( Int32 y = -1; y < mTiles.y; y++ ) { for ( Int32 x = -1; x < mTiles.x; x++ ) { @@ -129,11 +129,11 @@ void ScrollParallax::draw() { Rect.Bottom -= (Int32)( ( ( Pos.y + mRealSize.getHeight() ) - mAABB.Bottom ) * pd ); } - mSubTexture->setSrcRect( Rect ); - mSubTexture->setDestSize( Vector2f( Rect.getSize().x * ps, Rect.getSize().y * ps ) ); + mTextureRegion->setSrcRect( Rect ); + mTextureRegion->setDestSize( Vector2f( Rect.getSize().x * ps, Rect.getSize().y * ps ) ); if ( !( Rect.Right == 0 || Rect.Bottom == 0 ) ) - mSubTexture->draw( AABB.Left, AABB.Top, mColor, 0.f, Vector2f::One, mBlend ); + mTextureRegion->draw( AABB.Left, AABB.Top, mColor, 0.f, Vector2f::One, mBlend ); } Pos.x += mRealSize.getWidth(); @@ -147,8 +147,8 @@ void ScrollParallax::draw() { Pos.y += mRealSize.getHeight(); } - mSubTexture->setSrcRect( mRect ); - mSubTexture->resetDestSize(); + mTextureRegion->setSrcRect( mRect ); + mTextureRegion->resetDestSize(); } } diff --git a/src/eepp/graphics/sprite.cpp b/src/eepp/graphics/sprite.cpp index 49051ab71..8d130b0b3 100755 --- a/src/eepp/graphics/sprite.cpp +++ b/src/eepp/graphics/sprite.cpp @@ -51,7 +51,7 @@ Sprite::Sprite( const std::string& name, const std::string& extension, TextureAt addFramesByPattern( name, extension, SearchInTextureAtlas ); } -Sprite::Sprite( SubTexture * SubTexture ) : +Sprite::Sprite( TextureRegion * TextureRegion ) : Drawable( Drawable::SPRITE ), mFlags( SPRITE_FLAG_AUTO_ANIM | SPRITE_FLAG_EVENTS_ENABLED ), mRotation( 0.f ), @@ -69,7 +69,7 @@ Sprite::Sprite( SubTexture * SubTexture ) : mUserData( NULL ) { mCb.Reset(); - createStatic( SubTexture ); + createStatic( TextureRegion ); } Sprite::Sprite( const Uint32& TexId, const Sizef &DestSize, const Vector2i &Offset, const Rect& TexSector ) : @@ -219,9 +219,9 @@ void Sprite::setCurrentSubFrame( const unsigned int& CurSubFrame ) { } Quad2f Sprite::getQuad() { - SubTexture * S; + TextureRegion * S; - if ( mFrames.size() && ( S = getCurrentSubTexture() ) ) { + if ( mFrames.size() && ( S = getCurrentTextureRegion() ) ) { Rectf TmpR( mPosition.x, mPosition.y, mPosition.x + S->getDestSize().x, @@ -277,9 +277,9 @@ Quad2f Sprite::getQuad() { Rectf Sprite::getAABB() { Rectf TmpR; - SubTexture * S; + TextureRegion * S; - if ( mFrames.size() && ( S = getCurrentSubTexture() ) ) { + if ( mFrames.size() && ( S = getCurrentTextureRegion() ) ) { if ( mRotation != 0 || mEffect >= 4 ) { return getQuad().toAABB(); } else { // The method used if mAngle != 0 works for mAngle = 0, but i prefer to use the faster way @@ -321,10 +321,10 @@ unsigned int Sprite::framePos() { return (unsigned int)mFrames.size() - 1; } -bool Sprite::createStatic( SubTexture * SubTexture ) { +bool Sprite::createStatic( TextureRegion * TextureRegion ) { reset(); - addFrame( SubTexture ); + addFrame( TextureRegion ); return true; } @@ -350,11 +350,11 @@ void Sprite::createAnimation( const unsigned int& SubFramesNum ) { mSubFrames = SubFramesNum; } -bool Sprite::addFrames( const std::vector SubTextures ) { - if ( SubTextures.size() ) { - for ( unsigned int i = 0; i < SubTextures.size(); i++ ) { - if ( NULL != SubTextures[i] ) { - addFrame( SubTextures[i] ); +bool Sprite::addFrames( const std::vector TextureRegions ) { + if ( TextureRegions.size() ) { + for ( unsigned int i = 0; i < TextureRegions.size(); i++ ) { + if ( NULL != TextureRegions[i] ) { + addFrame( TextureRegions[i] ); } } @@ -364,25 +364,25 @@ bool Sprite::addFrames( const std::vector SubTextures ) { return false; } -bool Sprite::addFramesByPatternId( const Uint32& SubTextureId, const std::string& extension, TextureAtlas * SearchInTextureAtlas ) { - std::vector SubTextures = TextureAtlasManager::instance()->getSubTexturesByPatternId( SubTextureId, extension, SearchInTextureAtlas ); +bool Sprite::addFramesByPatternId( const Uint32& TextureRegionId, const std::string& extension, TextureAtlas * SearchInTextureAtlas ) { + std::vector TextureRegions = TextureAtlasManager::instance()->getTextureRegionsByPatternId( TextureRegionId, extension, SearchInTextureAtlas ); - if ( SubTextures.size() ) { - addFrames( SubTextures ); + if ( TextureRegions.size() ) { + addFrames( TextureRegions ); return true; } - eePRINTL( "Sprite::AddFramesByPatternId: Couldn't find any pattern with Id: %d", SubTextureId ); + eePRINTL( "Sprite::AddFramesByPatternId: Couldn't find any pattern with Id: %d", TextureRegionId ); return false; } bool Sprite::addFramesByPattern( const std::string& name, const std::string& extension, TextureAtlas * SearchInTextureAtlas ) { - std::vector SubTextures = TextureAtlasManager::instance()->getSubTexturesByPattern( name, extension, SearchInTextureAtlas ); + std::vector TextureRegions = TextureAtlasManager::instance()->getTextureRegionsByPattern( name, extension, SearchInTextureAtlas ); - if ( SubTextures.size() ) { - addFrames( SubTextures ); + if ( TextureRegions.size() ) { + addFrames( TextureRegions ); return true; } @@ -392,7 +392,7 @@ bool Sprite::addFramesByPattern( const std::string& name, const std::string& ext return false; } -bool Sprite::addSubFrame( SubTexture * SubTexture, const unsigned int& NumFrame, const unsigned int& NumSubFrame ) { +bool Sprite::addSubFrame( TextureRegion * TextureRegion, const unsigned int& NumFrame, const unsigned int& NumSubFrame ) { unsigned int NF, NSF; if ( NumFrame >= mFrames.size() ) @@ -409,7 +409,7 @@ bool Sprite::addSubFrame( SubTexture * SubTexture, const unsigned int& NumFrame, if ( mFrames[NF].Spr.size() != (unsigned int)mSubFrames ) mFrames[NF].Spr.resize( mSubFrames ); - mFrames[NF].Spr[NSF] = SubTexture; + mFrames[NF].Spr[NSF] = TextureRegion; return true; } @@ -417,10 +417,10 @@ bool Sprite::addSubFrame( SubTexture * SubTexture, const unsigned int& NumFrame, return false; } -unsigned int Sprite::addFrame( SubTexture * SubTexture ) { +unsigned int Sprite::addFrame( TextureRegion * TextureRegion ) { unsigned int id = framePos(); - addSubFrame( SubTexture, id, mCurrentSubFrame ); + addSubFrame( TextureRegion, id, mCurrentSubFrame ); return id; } @@ -439,7 +439,7 @@ bool Sprite::addSubFrame(const Uint32& TexId, const unsigned int& NumFrame, cons return false; Texture * Tex = TextureFactory::instance()->getTexture( TexId ); - SubTexture * S = GlobalTextureAtlas::instance()->add( eeNew( SubTexture, () ) ); + TextureRegion * S = GlobalTextureAtlas::instance()->add( eeNew( TextureRegion, () ) ); S->setTextureId( TexId ); @@ -568,7 +568,7 @@ void Sprite::draw( const BlendMode& Blend, const RenderMode& Effect ) { if ( SPR_FGET( SPRITE_FLAG_AUTO_ANIM ) ) update(); - SubTexture * S = getCurrentSubTexture(); + TextureRegion * S = getCurrentTextureRegion(); if ( S == NULL ) return; @@ -591,7 +591,7 @@ void Sprite::draw( const Vector2f& position, const Sizef& size ) { if ( SPR_FGET( SPRITE_FLAG_AUTO_ANIM ) ) update(); - SubTexture * S = getCurrentSubTexture(); + TextureRegion * S = getCurrentTextureRegion(); if ( S == NULL ) return; @@ -635,7 +635,7 @@ unsigned int Sprite::getSubFrame( const unsigned int& SubFrame ) { } Vector2i Sprite::getOffset() { - SubTexture* S = getCurrentSubTexture(); + TextureRegion* S = getCurrentTextureRegion(); if ( S != NULL ) return S->getOffset(); @@ -644,7 +644,7 @@ Vector2i Sprite::getOffset() { } void Sprite::setOffset( const Vector2i& offset ) { - SubTexture* S = getCurrentSubTexture(); + TextureRegion* S = getCurrentTextureRegion(); if ( S != NULL ) { S->setOffset( offset ); @@ -686,21 +686,21 @@ bool Sprite::getAutoAnimate() const { return 0 != SPR_FGET( SPRITE_FLAG_AUTO_ANIM ); } -SubTexture* Sprite::getCurrentSubTexture() { +TextureRegion* Sprite::getCurrentTextureRegion() { if ( mFrames.size() ) return mFrames[ mCurrentFrame ].Spr[ mCurrentSubFrame ]; return NULL; } -SubTexture * Sprite::getSubTexture( const unsigned int& frame ) { +TextureRegion * Sprite::getTextureRegion( const unsigned int& frame ) { if ( frame < mFrames.size() ) return mFrames[ frame ].Spr[ mCurrentSubFrame ]; return NULL; } -SubTexture * Sprite::getSubTexture( const unsigned int& frame, const unsigned int& SubFrame ) { +TextureRegion * Sprite::getTextureRegion( const unsigned int& frame, const unsigned int& SubFrame ) { if ( frame < mFrames.size() ) return mFrames[ frame ].Spr[ SubFrame ]; diff --git a/src/eepp/graphics/textureatlas.cpp b/src/eepp/graphics/textureatlas.cpp index 39bc3ad84..d78c051e3 100644 --- a/src/eepp/graphics/textureatlas.cpp +++ b/src/eepp/graphics/textureatlas.cpp @@ -3,7 +3,7 @@ namespace EE { namespace Graphics { TextureAtlas::TextureAtlas( const std::string& name ) : - ResourceManager ( true ) + ResourceManager ( true ) { setName( name ); } @@ -32,28 +32,28 @@ const Uint32& TextureAtlas::getId() const { return mId; } -SubTexture * TextureAtlas::add( SubTexture * subTexture ) { - return ResourceManager::add( subTexture ); +TextureRegion * TextureAtlas::add( TextureRegion * textureRegion ) { + return ResourceManager::add( textureRegion ); } -SubTexture * TextureAtlas::add( const Uint32& TexId, const std::string& Name ) { - return add( eeNew( SubTexture, ( TexId, Name ) ) ); +TextureRegion * TextureAtlas::add( const Uint32& TexId, const std::string& Name ) { + return add( eeNew( TextureRegion, ( TexId, Name ) ) ); } -SubTexture * TextureAtlas::add( const Uint32& TexId, const Rect& SrcRect, const std::string& Name ) { - return add( eeNew( SubTexture, ( TexId, SrcRect, Name ) ) ); +TextureRegion * TextureAtlas::add( const Uint32& TexId, const Rect& SrcRect, const std::string& Name ) { + return add( eeNew( TextureRegion, ( TexId, SrcRect, Name ) ) ); } -SubTexture * TextureAtlas::add( const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const std::string& Name ) { - return add( eeNew ( SubTexture, ( TexId, SrcRect, DestSize, Name ) ) ); +TextureRegion * TextureAtlas::add( const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const std::string& Name ) { + return add( eeNew ( TextureRegion, ( TexId, SrcRect, DestSize, Name ) ) ); } -SubTexture * TextureAtlas::add( const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const Vector2i& Offset, const std::string& Name ) { - return add( eeNew ( SubTexture, ( TexId, SrcRect, DestSize, Offset, Name ) ) ); +TextureRegion * TextureAtlas::add( const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const Vector2i& Offset, const std::string& Name ) { + return add( eeNew ( TextureRegion, ( TexId, SrcRect, DestSize, Offset, Name ) ) ); } Uint32 TextureAtlas::getCount() { - return ResourceManager::getCount(); + return ResourceManager::getCount(); } void TextureAtlas::setTextures( std::vector textures ) { diff --git a/src/eepp/graphics/textureatlasloader.cpp b/src/eepp/graphics/textureatlasloader.cpp index ad747f4d1..98f52505e 100644 --- a/src/eepp/graphics/textureatlasloader.cpp +++ b/src/eepp/graphics/textureatlasloader.cpp @@ -87,7 +87,7 @@ void TextureAtlasLoader::update() { mRL.update(); if ( mRL.isLoaded() && !mLoaded ) - createSubTextures(); + createTextureRegions(); } void TextureAtlasLoader::loadFromStream( IOStream& IOS ) { @@ -104,7 +104,7 @@ void TextureAtlasLoader::loadFromStream( IOStream& IOS ) { IOS.read( (char*)&tTextureHdr, sizeof(sTextureHdr) ); tTexAtlas.Texture = tTextureHdr; - tTexAtlas.SubTextures.resize( tTextureHdr.SubTextureCount ); + tTexAtlas.TextureRegions.resize( tTextureHdr.TextureRegionCount ); std::string name( &tTextureHdr.Name[0] ); std::string path( FileSystem::fileRemoveFileName( mTextureAtlasPath ) + name ); @@ -120,7 +120,7 @@ void TextureAtlasLoader::loadFromStream( IOStream& IOS ) { } } - IOS.read( (char*)&tTexAtlas.SubTextures[0], sizeof(sSubTextureHdr) * tTextureHdr.SubTextureCount ); + IOS.read( (char*)&tTexAtlas.TextureRegions[0], sizeof(sTextureRegionHdr) * tTextureHdr.TextureRegionCount ); mTempAtlass.push_back( tTexAtlas ); } @@ -131,7 +131,7 @@ void TextureAtlasLoader::loadFromStream( IOStream& IOS ) { mRL.load(); if ( !mThreaded || ( !mSkipResourceLoad && 0 == mRL.getCount() ) ) - createSubTextures(); + createTextureRegions(); } } } @@ -180,7 +180,7 @@ TextureAtlas * TextureAtlasLoader::getTextureAtlas() const { return mTextureAtlas; } -void TextureAtlasLoader::createSubTextures() { +void TextureAtlasLoader::createTextureRegions() { mIsLoading = false; bool IsAlreadyLoaded = false; @@ -222,27 +222,27 @@ void TextureAtlasLoader::createSubTextures() { if ( NULL != tTex ) { if ( !IsAlreadyLoaded ) { - for ( Int32 i = 0; i < tTexHdr->SubTextureCount; i++ ) { - sSubTextureHdr * tSh = &tTexAtlas->SubTextures[i]; + for ( Int32 i = 0; i < tTexHdr->TextureRegionCount; i++ ) { + sTextureRegionHdr * tSh = &tTexAtlas->TextureRegions[i]; - std::string SubTextureName( &tSh->Name[0] ); + std::string TextureRegionName( &tSh->Name[0] ); if ( mTexGrHdr.Flags & HDR_TEXTURE_ATLAS_REMOVE_EXTENSION ) - SubTextureName = FileSystem::fileRemoveExtension( SubTextureName ); + TextureRegionName = FileSystem::fileRemoveExtension( TextureRegionName ); Rect tRect( tSh->X, tSh->Y, tSh->X + tSh->Width, tSh->Y + tSh->Height ); - SubTexture * tSubTexture = eeNew( SubTexture, ( tTex->getId(), tRect, Sizef( (Float)tSh->DestWidth, (Float)tSh->DestHeight ), Vector2i( tSh->OffsetX, tSh->OffsetY ), SubTextureName ) ); + TextureRegion * tTextureRegion = eeNew( TextureRegion, ( tTex->getId(), tRect, Sizef( (Float)tSh->DestWidth, (Float)tSh->DestHeight ), Vector2i( tSh->OffsetX, tSh->OffsetY ), TextureRegionName ) ); - tSubTexture->setPixelDensity( PixelDensity::toFloat( tSh->PixelDensity ) ); - //if ( tSh->Flags & HDR_SUBTEXTURE_FLAG_FLIPED ) + tTextureRegion->setPixelDensity( PixelDensity::toFloat( tSh->PixelDensity ) ); + //if ( tSh->Flags & HDR_TEXTUREREGION_FLAG_FLIPED ) // Should rotate the sub texture, but.. sub texture rotation is not stored. - mTextureAtlas->add( tSubTexture ); + mTextureAtlas->add( tTextureRegion ); } } } else { - eePRINTL( "TextureAtlasLoader::CreateSubTextures: Failed to find texture atlas texture, it seems that is not loaded for some reason. Couldn't find: %s", path.c_str() ); + eePRINTL( "TextureAtlasLoader::createTextureRegions: Failed to find texture atlas texture, it seems that is not loaded for some reason. Couldn't find: %s", path.c_str() ); eeASSERT( NULL != tTex ); @@ -295,15 +295,15 @@ bool TextureAtlasLoader::updateTextureAtlas() { sTempTexAtlas * tTexAtlas = &mTempAtlass[z]; sTextureHdr * tTexHdr = &tTexAtlas->Texture; - for ( Int32 i = 0; i < tTexHdr->SubTextureCount; i++ ) { - sSubTextureHdr * tSh = &tTexAtlas->SubTextures[i]; - SubTexture * tSubTexture = mTextureAtlas->getById( tSh->ResourceID ); + for ( Int32 i = 0; i < tTexHdr->TextureRegionCount; i++ ) { + sTextureRegionHdr * tSh = &tTexAtlas->TextureRegions[i]; + TextureRegion * tTextureRegion = mTextureAtlas->getById( tSh->ResourceID ); - if ( NULL != tSubTexture ) { - tSh->OffsetX = tSubTexture->getOffset().x; - tSh->OffsetY = tSubTexture->getOffset().x; - tSh->DestWidth = (Int32)tSubTexture->getDestSize().x; - tSh->DestHeight = (Int32)tSubTexture->getDestSize().y; + if ( NULL != tTextureRegion ) { + tSh->OffsetX = tTextureRegion->getOffset().x; + tSh->OffsetY = tTextureRegion->getOffset().x; + tSh->DestWidth = (Int32)tTextureRegion->getDestSize().x; + tSh->DestHeight = (Int32)tTextureRegion->getDestSize().y; } } } @@ -319,7 +319,7 @@ bool TextureAtlasLoader::updateTextureAtlas() { fs.write( reinterpret_cast ( tTexHdr ), sizeof(sTextureHdr) ); - fs.write( reinterpret_cast ( &tTexAtlas->SubTextures[0] ), sizeof(sSubTextureHdr) * (std::streamsize)tTexAtlas->SubTextures.size() ); + fs.write( reinterpret_cast ( &tTexAtlas->TextureRegions[0] ), sizeof(sTextureRegionHdr) * (std::streamsize)tTexAtlas->TextureRegions.size() ); } return true; @@ -348,12 +348,12 @@ bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath, std:: Uint32 z; - Uint32 totalSubTextures = 0; + Uint32 totalTextureRegions = 0; for ( z = 0; z < mTempAtlass.size(); z++ ) { - totalSubTextures += mTempAtlass[z].Texture.SubTextureCount; + totalTextureRegions += mTempAtlass[z].Texture.TextureRegionCount; - if ( mTempAtlass[z].Texture.SubTextureCount > 0 ) { - pixelDensity = (EE_PIXEL_DENSITY)mTempAtlass[z].SubTextures[0].PixelDensity; + if ( mTempAtlass[z].Texture.TextureRegionCount > 0 ) { + pixelDensity = (EE_PIXEL_DENSITY)mTempAtlass[z].TextureRegions[0].PixelDensity; } } @@ -368,7 +368,7 @@ bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath, std:: totalImages++; } - if ( totalSubTextures != totalImages ) { + if ( totalTextureRegions != totalImages ) { NeedUpdate = 2; } else { for ( z = 0; z < mTempAtlass.size(); z++ ) { @@ -376,16 +376,16 @@ bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath, std:: sTextureHdr * tTexHdr = &tTexAtlas->Texture; if ( 2 != NeedUpdate ) { - for ( Int32 i = 0; i < tTexHdr->SubTextureCount; i++ ) { - sSubTextureHdr * tSh = &tTexAtlas->SubTextures[i]; + for ( Int32 i = 0; i < tTexHdr->TextureRegionCount; i++ ) { + sTextureRegionHdr * tSh = &tTexAtlas->TextureRegions[i]; std::string path( ImagesPath + tSh->Name ); if ( FileSystem::fileSize( path ) ) { if ( tSh->Date != FileSystem::fileGetModificationDate( path ) ) { if ( stbi_info( path.c_str(), &x, &y, &c ) ) { - if ( ( !( tSh->Flags & HDR_SUBTEXTURE_FLAG_FLIPED ) && tSh->Width == x && tSh->Height == y ) || // If size or channels changed, the image need update - ( ( tSh->Flags & HDR_SUBTEXTURE_FLAG_FLIPED ) && tSh->Width == y && tSh->Height == x ) || + if ( ( !( tSh->Flags & HDR_TEXTUREREGION_FLAG_FLIPED ) && tSh->Width == x && tSh->Height == y ) || // If size or channels changed, the image need update + ( ( tSh->Flags & HDR_TEXTUREREGION_FLAG_FLIPED ) && tSh->Width == y && tSh->Height == x ) || tSh->Channels != c ) { @@ -447,8 +447,8 @@ bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath, std:: fs.write( reinterpret_cast (tTexHdr), sizeof(sTextureHdr) ); - for ( Int32 i = 0; i < tTexHdr->SubTextureCount; i++ ) { - sSubTextureHdr * tSh = &tTexAtlas->SubTextures[i]; + for ( Int32 i = 0; i < tTexHdr->TextureRegionCount; i++ ) { + sTextureRegionHdr * tSh = &tTexAtlas->TextureRegions[i]; std::string imgcopypath( ImagesPath + tSh->Name ); @@ -472,7 +472,7 @@ bool TextureAtlasLoader::updateTextureAtlas( std::string TextureAtlasPath, std:: } } - fs.write( reinterpret_cast (&tTexAtlas->SubTextures[0]), sizeof(sSubTextureHdr) * tTexHdr->SubTextureCount ); + fs.write( reinterpret_cast (&tTexAtlas->TextureRegions[0]), sizeof(sTextureRegionHdr) * tTexHdr->TextureRegionCount ); Img.saveToFile( tapath, (Image::SaveType)mTexGrHdr.Format ); diff --git a/src/eepp/graphics/textureatlasmanager.cpp b/src/eepp/graphics/textureatlasmanager.cpp index c7284e5e6..07acba927 100644 --- a/src/eepp/graphics/textureatlasmanager.cpp +++ b/src/eepp/graphics/textureatlasmanager.cpp @@ -41,29 +41,29 @@ TextureAtlas * TextureAtlasManager::loadFromPack( Pack * Pack, const std::string return loader.getTextureAtlas(); } -SubTexture * TextureAtlasManager::getSubTextureByName( const std::string& Name ) { - SubTexture * tSubTexture = getSubTextureById( String::hash( Name ) ); +TextureRegion * TextureAtlasManager::getTextureRegionByName( const std::string& Name ) { + TextureRegion * tTextureRegion = getTextureRegionById( String::hash( Name ) ); if ( mWarnings ) { - eePRINTC( NULL == tSubTexture, "TextureAtlasManager::GetSubTextureByName SubTexture '%s' not found\n", Name.c_str() ); + eePRINTC( NULL == tTextureRegion, "TextureAtlasManager::getTextureRegionByName TextureRegion '%s' not found\n", Name.c_str() ); } - return tSubTexture; + return tTextureRegion; } -SubTexture * TextureAtlasManager::getSubTextureById( const Uint32& Id ) { +TextureRegion * TextureAtlasManager::getTextureRegionById( const Uint32& Id ) { std::list::iterator it; TextureAtlas * tSG = NULL; - SubTexture * tSubTexture = NULL; + TextureRegion * tTextureRegion = NULL; for ( it = mResources.begin(); it != mResources.end(); it++ ) { tSG = (*it); - tSubTexture = tSG->getById( Id ); + tTextureRegion = tSG->getById( Id ); - if ( NULL != tSubTexture ) - return tSubTexture; + if ( NULL != tTextureRegion ) + return tTextureRegion; } return NULL; @@ -76,25 +76,25 @@ void TextureAtlasManager::printResources() { (*it)->printNames(); } -std::vector TextureAtlasManager::getSubTexturesByPatternId( const Uint32& SubTextureId, const std::string& extension, TextureAtlas * SearchInTextureAtlas ) { - SubTexture * tSubTexture = NULL; +std::vector TextureAtlasManager::getTextureRegionsByPatternId( const Uint32& TextureRegionId, const std::string& extension, TextureAtlas * SearchInTextureAtlas ) { + TextureRegion * tTextureRegion = NULL; std::string tName; if ( NULL == SearchInTextureAtlas ) - tSubTexture = getSubTextureById( SubTextureId ); + tTextureRegion = getTextureRegionById( TextureRegionId ); else - tSubTexture = SearchInTextureAtlas->getById( SubTextureId ); + tTextureRegion = SearchInTextureAtlas->getById( TextureRegionId ); - if ( NULL != tSubTexture ) { + if ( NULL != tTextureRegion ) { if ( extension.size() ) - tName = String::removeNumbersAtEnd( FileSystem::fileRemoveExtension( tSubTexture->getName() ) ) + extension; + tName = String::removeNumbersAtEnd( FileSystem::fileRemoveExtension( tTextureRegion->getName() ) ) + extension; else - tName = tSubTexture->getName(); + tName = tTextureRegion->getName(); - return getSubTexturesByPattern( String::removeNumbersAtEnd( tSubTexture->getName() ), "", SearchInTextureAtlas ); + return getTextureRegionsByPattern( String::removeNumbersAtEnd( tTextureRegion->getName() ), "", SearchInTextureAtlas ); } - return std::vector(); + return std::vector(); } void TextureAtlasManager::setPrintWarnings( const bool& warn ) { @@ -105,11 +105,11 @@ const bool& TextureAtlasManager::getPrintWarnings() const { return mWarnings; } -std::vector TextureAtlasManager::getSubTexturesByPattern( const std::string& name, const std::string& extension, TextureAtlas * SearchInTextureAtlas ) { - std::vector SubTextures; +std::vector TextureAtlasManager::getTextureRegionsByPattern( const std::string& name, const std::string& extension, TextureAtlas * SearchInTextureAtlas ) { + std::vector TextureRegions; std::string search; bool found = true; - SubTexture * tSubTexture = NULL; + TextureRegion * tTextureRegion = NULL; std::string realext = ""; int c = 0; int t = 0; @@ -123,11 +123,11 @@ std::vector TextureAtlasManager::getSubTexturesByPattern( const std search = String::strFormated( "%s%d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) - tSubTexture = getSubTextureByName( search ); + tTextureRegion = getTextureRegionByName( search ); else - tSubTexture = SearchInTextureAtlas->getByName( search ); + tTextureRegion = SearchInTextureAtlas->getByName( search ); - if ( NULL != tSubTexture ) { + if ( NULL != tTextureRegion ) { t = 1; break; @@ -140,11 +140,11 @@ std::vector TextureAtlasManager::getSubTexturesByPattern( const std search = String::strFormated( "%s%02d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) - tSubTexture = getSubTextureByName( search ); + tTextureRegion = getTextureRegionByName( search ); else - tSubTexture = SearchInTextureAtlas->getByName( search ); + tTextureRegion = SearchInTextureAtlas->getByName( search ); - if ( NULL != tSubTexture ) { + if ( NULL != tTextureRegion ) { t = 2; break; @@ -157,11 +157,11 @@ std::vector TextureAtlasManager::getSubTexturesByPattern( const std search = String::strFormated( "%s%03d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) - tSubTexture = getSubTextureByName( search ); + tTextureRegion = getTextureRegionByName( search ); else - tSubTexture = SearchInTextureAtlas->getByName( search ); + tTextureRegion = SearchInTextureAtlas->getByName( search ); - if ( NULL != tSubTexture ) { + if ( NULL != tTextureRegion ) { t = 3; break; @@ -173,11 +173,11 @@ std::vector TextureAtlasManager::getSubTexturesByPattern( const std search = String::strFormated( "%s%04d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) - tSubTexture = getSubTextureByName( search ); + tTextureRegion = getTextureRegionByName( search ); else - tSubTexture = SearchInTextureAtlas->getByName( search ); + tTextureRegion = SearchInTextureAtlas->getByName( search ); - if ( NULL != tSubTexture ) { + if ( NULL != tTextureRegion ) { t = 4; break; @@ -189,11 +189,11 @@ std::vector TextureAtlasManager::getSubTexturesByPattern( const std search = String::strFormated( "%s%05d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) - tSubTexture = getSubTextureByName( search ); + tTextureRegion = getTextureRegionByName( search ); else - tSubTexture = SearchInTextureAtlas->getByName( search ); + tTextureRegion = SearchInTextureAtlas->getByName( search ); - if ( NULL != tSubTexture ) { + if ( NULL != tTextureRegion ) { t = 5; break; @@ -205,11 +205,11 @@ std::vector TextureAtlasManager::getSubTexturesByPattern( const std search = String::strFormated( "%s%06d%s", name.c_str(), i, realext.c_str() ); if ( NULL == SearchInTextureAtlas ) - tSubTexture = getSubTextureByName( search ); + tTextureRegion = getTextureRegionByName( search ); else - tSubTexture = SearchInTextureAtlas->getByName( search ); + tTextureRegion = SearchInTextureAtlas->getByName( search ); - if ( NULL != tSubTexture ) { + if ( NULL != tTextureRegion ) { t = 6; break; @@ -235,12 +235,12 @@ std::vector TextureAtlasManager::getSubTexturesByPattern( const std if ( found ) { if ( NULL == SearchInTextureAtlas ) - tSubTexture = getSubTextureByName( search ); + tTextureRegion = getTextureRegionByName( search ); else - tSubTexture = SearchInTextureAtlas->getByName( search ); + tTextureRegion = SearchInTextureAtlas->getByName( search ); - if ( NULL != tSubTexture ) { - SubTextures.push_back( tSubTexture ); + if ( NULL != tTextureRegion ) { + TextureRegions.push_back( tTextureRegion ); found = true; } else { @@ -255,7 +255,7 @@ std::vector TextureAtlasManager::getSubTexturesByPattern( const std } while ( found ); } - return SubTextures; + return TextureRegions; } }} diff --git a/src/eepp/graphics/texturepacker.cpp b/src/eepp/graphics/texturepacker.cpp index 0a9d51d48..63cbfde49 100644 --- a/src/eepp/graphics/texturepacker.cpp +++ b/src/eepp/graphics/texturepacker.cpp @@ -622,7 +622,7 @@ void TexturePacker::save( const std::string& Filepath, const Image::SaveType& Fo childSave( Format ); - saveSubTextures(); + saveTextureRegions(); } Int32 TexturePacker::getChildCount() { @@ -637,7 +637,7 @@ Int32 TexturePacker::getChildCount() { return ChildCount; } -void TexturePacker::saveSubTextures() { +void TexturePacker::saveTextureRegions() { if ( NULL != mParent ) return; @@ -677,7 +677,7 @@ void TexturePacker::saveSubTextures() { HdrPos++; } - std::vector tSubTexturesHdr; + std::vector tTextureRegionsHdr; std::string path = FileSystem::fileRemoveExtension( mFilepath ) + EE_TEXTURE_ATLAS_EXTENSION; IOStreamFile fs ( path , std::ios::out | std::ios::binary ); @@ -687,10 +687,10 @@ void TexturePacker::saveSubTextures() { fs.write( reinterpret_cast (&TexHdr[ 0 ]), sizeof(sTextureHdr) ); - createSubTexturesHdr( this, tSubTexturesHdr ); + createTextureRegionsHdr( this, tTextureRegionsHdr ); - if ( tSubTexturesHdr.size() ) - fs.write( reinterpret_cast (&tSubTexturesHdr[ 0 ]), sizeof(sSubTextureHdr) * (std::streamsize)tSubTexturesHdr.size() ); + if ( tTextureRegionsHdr.size() ) + fs.write( reinterpret_cast (&tTextureRegionsHdr[ 0 ]), sizeof(sTextureRegionHdr) * (std::streamsize)tTextureRegionsHdr.size() ); Int32 HdrPos = 1; TexturePacker * Child = mChild; @@ -698,10 +698,10 @@ void TexturePacker::saveSubTextures() { while ( NULL != Child ) { fs.write( reinterpret_cast (&TexHdr[ HdrPos ]), sizeof(sTextureHdr) ); - createSubTexturesHdr( Child, tSubTexturesHdr ); + createTextureRegionsHdr( Child, tTextureRegionsHdr ); - if ( tSubTexturesHdr.size() ) - fs.write( reinterpret_cast (&tSubTexturesHdr[ 0 ]), sizeof(sSubTextureHdr) * (std::streamsize)tSubTexturesHdr.size() ); + if ( tTextureRegionsHdr.size() ) + fs.write( reinterpret_cast (&tTextureRegionsHdr[ 0 ]), sizeof(sTextureRegionHdr) * (std::streamsize)tTextureRegionsHdr.size() ); Child = Child->getChild(); @@ -710,17 +710,17 @@ void TexturePacker::saveSubTextures() { } } -void TexturePacker::createSubTexturesHdr( TexturePacker * Packer, std::vector& SubTextures ) { - SubTextures.clear(); +void TexturePacker::createTextureRegionsHdr( TexturePacker * Packer, std::vector& TextureRegions ) { + TextureRegions.clear(); - sSubTextureHdr tSubTextureHdr; + sTextureRegionHdr tTextureRegionHdr; Uint32 c = 0; std::list tTextures = *(Packer->getTexturePackPtr()); std::list::iterator it; TexturePackerTex * tTex; - SubTextures.resize( tTextures.size() ); + TextureRegions.resize( tTextures.size() ); for ( it = tTextures.begin(); it != tTextures.end(); it++ ) { tTex = (*it); @@ -728,31 +728,31 @@ void TexturePacker::createSubTexturesHdr( TexturePacker * Packer, std::vectorplaced() ) { std::string name = FileSystem::fileNameFromPath( tTex->name() ); - memset( tSubTextureHdr.Name, 0, HDR_NAME_SIZE ); + memset( tTextureRegionHdr.Name, 0, HDR_NAME_SIZE ); - String::strCopy( tSubTextureHdr.Name, name.c_str(), HDR_NAME_SIZE ); + String::strCopy( tTextureRegionHdr.Name, name.c_str(), HDR_NAME_SIZE ); if ( !mSaveExtensions ) name = FileSystem::fileRemoveExtension( name ); - tSubTextureHdr.ResourceID = String::hash( name ); - tSubTextureHdr.Width = tTex->width(); - tSubTextureHdr.Height = tTex->height(); - tSubTextureHdr.Channels = tTex->channels(); - tSubTextureHdr.DestWidth = tTex->width(); - tSubTextureHdr.DestHeight = tTex->height(); - tSubTextureHdr.OffsetX = 0; - tSubTextureHdr.OffsetY = 0; - tSubTextureHdr.X = tTex->x(); - tSubTextureHdr.Y = tTex->y(); - tSubTextureHdr.Date = FileSystem::fileGetModificationDate( tTex->name() ); - tSubTextureHdr.Flags = 0; - tSubTextureHdr.PixelDensity = (Uint32)mPixelDensity; + tTextureRegionHdr.ResourceID = String::hash( name ); + tTextureRegionHdr.Width = tTex->width(); + tTextureRegionHdr.Height = tTex->height(); + tTextureRegionHdr.Channels = tTex->channels(); + tTextureRegionHdr.DestWidth = tTex->width(); + tTextureRegionHdr.DestHeight = tTex->height(); + tTextureRegionHdr.OffsetX = 0; + tTextureRegionHdr.OffsetY = 0; + tTextureRegionHdr.X = tTex->x(); + tTextureRegionHdr.Y = tTex->y(); + tTextureRegionHdr.Date = FileSystem::fileGetModificationDate( tTex->name() ); + tTextureRegionHdr.Flags = 0; + tTextureRegionHdr.PixelDensity = (Uint32)mPixelDensity; if ( tTex->flipped() ) - tSubTextureHdr.Flags |= HDR_SUBTEXTURE_FLAG_FLIPED; + tTextureRegionHdr.Flags |= HDR_TEXTUREREGION_FLAG_FLIPED; - SubTextures[c] = tSubTextureHdr; + TextureRegions[c] = tTextureRegionHdr; c++; } @@ -770,7 +770,7 @@ sTextureHdr TexturePacker::createTextureHdr( TexturePacker * Packer ) { TexHdr.ResourceID = String::hash( name ); TexHdr.Size = FileSystem::fileSize( Packer->getFilepath() ); - TexHdr.SubTextureCount = Packer->getPlacedCount(); + TexHdr.TextureRegionCount = Packer->getPlacedCount(); return TexHdr; } diff --git a/src/eepp/graphics/subtexture.cpp b/src/eepp/graphics/textureregion.cpp similarity index 71% rename from src/eepp/graphics/subtexture.cpp rename to src/eepp/graphics/textureregion.cpp index a684b5fe0..f0a8921ab 100644 --- a/src/eepp/graphics/subtexture.cpp +++ b/src/eepp/graphics/textureregion.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -10,8 +10,8 @@ using namespace EE::Graphics::Private; namespace EE { namespace Graphics { -SubTexture::SubTexture() : - DrawableResource( Drawable::SUBTEXTURE ), +TextureRegion::TextureRegion() : + DrawableResource( Drawable::TEXTUREREGION ), mPixels(NULL), mAlphaMask(NULL), mTexId(0), @@ -24,8 +24,8 @@ SubTexture::SubTexture() : { } -SubTexture::SubTexture( const Uint32& TexId, const std::string& name ) : - DrawableResource( Drawable::SUBTEXTURE, name ), +TextureRegion::TextureRegion( const Uint32& TexId, const std::string& name ) : + DrawableResource( Drawable::TEXTUREREGION, name ), mPixels(NULL), mAlphaMask(NULL), mTexId( TexId ), @@ -38,8 +38,8 @@ SubTexture::SubTexture( const Uint32& TexId, const std::string& name ) : { } -SubTexture::SubTexture( const Uint32& TexId, const Rect& SrcRect, const std::string& name ) : - DrawableResource( Drawable::SUBTEXTURE, name ), +TextureRegion::TextureRegion( const Uint32& TexId, const Rect& SrcRect, const std::string& name ) : + DrawableResource( Drawable::TEXTUREREGION, name ), mPixels(NULL), mAlphaMask(NULL), mTexId( TexId ), @@ -52,8 +52,8 @@ SubTexture::SubTexture( const Uint32& TexId, const Rect& SrcRect, const std::str { } -SubTexture::SubTexture( const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const std::string& name ) : - DrawableResource( Drawable::SUBTEXTURE, name ), +TextureRegion::TextureRegion( const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const std::string& name ) : + DrawableResource( Drawable::TEXTUREREGION, name ), mPixels(NULL), mAlphaMask(NULL), mTexId( TexId ), @@ -66,8 +66,8 @@ SubTexture::SubTexture( const Uint32& TexId, const Rect& SrcRect, const Sizef& D { } -SubTexture::SubTexture(const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const Vector2i &Offset, const std::string& name ) : - DrawableResource( Drawable::SUBTEXTURE, name ), +TextureRegion::TextureRegion(const Uint32& TexId, const Rect& SrcRect, const Sizef& DestSize, const Vector2i &Offset, const std::string& name ) : + DrawableResource( Drawable::TEXTUREREGION, name ), mPixels(NULL), mAlphaMask(NULL), mTexId( TexId ), @@ -80,24 +80,24 @@ SubTexture::SubTexture(const Uint32& TexId, const Rect& SrcRect, const Sizef& De { } -SubTexture::~SubTexture() { +TextureRegion::~TextureRegion() { clearCache(); } -const Uint32& SubTexture::getTextureId() { +const Uint32& TextureRegion::getTextureId() { return mTexId; } -void SubTexture::setTextureId( const Uint32& TexId ) { +void TextureRegion::setTextureId( const Uint32& TexId ) { mTexId = TexId; mTexture = TextureFactory::instance()->getTexture( TexId ); } -const Rect& SubTexture::getSrcRect() const { +const Rect& TextureRegion::getSrcRect() const { return mSrcRect; } -void SubTexture::setSrcRect( const Rect& rect ) { +void TextureRegion::setSrcRect( const Rect& rect ) { mSrcRect = rect; if ( NULL != mPixels ) @@ -107,11 +107,11 @@ void SubTexture::setSrcRect( const Rect& rect ) { cacheAlphaMask(); } -const Sizef& SubTexture::getDestSize() const { +const Sizef& TextureRegion::getDestSize() const { return mDestSize; } -void SubTexture::setDestSize( const Sizef& destSize ) { +void TextureRegion::setDestSize( const Sizef& destSize ) { mDestSize = destSize; if ( mOriDestSize.x == 0 && mOriDestSize.y == 0 ) { @@ -119,49 +119,49 @@ void SubTexture::setDestSize( const Sizef& destSize ) { } } -const Vector2i& SubTexture::getOffset() const { +const Vector2i& TextureRegion::getOffset() const { return mOffset; } -void SubTexture::setOffset( const Vector2i& offset ) { +void TextureRegion::setOffset( const Vector2i& offset ) { mOffset = offset; } -void SubTexture::draw( const Float& X, const Float& Y, const Color& Color, const Float& Angle, const Vector2f& Scale, const BlendMode& Blend, const RenderMode& Effect, OriginPoint Center ) { +void TextureRegion::draw( const Float& X, const Float& Y, const Color& Color, const Float& Angle, const Vector2f& Scale, const BlendMode& Blend, const RenderMode& Effect, OriginPoint Center ) { if ( NULL != mTexture ) mTexture->drawEx( X + mOffset.x, Y + mOffset.y, mDestSize.x, mDestSize.y, Angle, Scale, Color, Color, Color, Color, Blend, Effect, Center, mSrcRect ); } -void SubTexture::draw( const Float& X, const Float& Y, const Float& Angle, const Vector2f& Scale, const Color& Color0, const Color& Color1, const Color& Color2, const Color& Color3, const BlendMode& Blend, const RenderMode& Effect, OriginPoint Center ) { +void TextureRegion::draw( const Float& X, const Float& Y, const Float& Angle, const Vector2f& Scale, const Color& Color0, const Color& Color1, const Color& Color2, const Color& Color3, const BlendMode& Blend, const RenderMode& Effect, OriginPoint Center ) { if ( NULL != mTexture ) mTexture->drawEx( X + mOffset.x, Y + mOffset.y, mDestSize.x, mDestSize.y, Angle, Scale, Color0, Color1, Color2, Color3, Blend, Effect, Center, mSrcRect ); } -void SubTexture::draw( const Quad2f Q, const Vector2f& Offset, const Float& Angle, const Vector2f& Scale, const Color& Color0, const Color& Color1, const Color& Color2, const Color& Color3, const BlendMode& Blend ) { +void TextureRegion::draw( const Quad2f Q, const Vector2f& Offset, const Float& Angle, const Vector2f& Scale, const Color& Color0, const Color& Color1, const Color& Color2, const Color& Color3, const BlendMode& Blend ) { if ( NULL != mTexture ) mTexture->drawQuadEx( Q, Offset, Angle, Scale, Color0, Color1, Color2, Color3, Blend, mSrcRect ); } -void SubTexture::draw() { +void TextureRegion::draw() { draw( mPosition ); } -void SubTexture::draw( const Vector2f& position ) { +void TextureRegion::draw( const Vector2f& position ) { draw( position.x, position.y, getColor() ); } -void SubTexture::draw( const Vector2f & position, const Sizef& size ) { +void TextureRegion::draw( const Vector2f & position, const Sizef& size ) { Sizef oldSize( mDestSize ); mDestSize = size; draw( position.x, position.y, getColor() ); mDestSize = oldSize; } -Graphics::Texture * SubTexture::getTexture() { +Graphics::Texture * TextureRegion::getTexture() { return mTexture; } -void SubTexture::replaceColor( Color ColorKey, Color NewColor ) { +void TextureRegion::replaceColor( Color ColorKey, Color NewColor ) { mTexture->lock(); for ( int y = mSrcRect.Top; y < mSrcRect.Bottom; y++ ) { @@ -174,15 +174,15 @@ void SubTexture::replaceColor( Color ColorKey, Color NewColor ) { mTexture->unlock( false, true ); } -void SubTexture::createMaskFromColor(Color ColorKey, Uint8 Alpha) { +void TextureRegion::createMaskFromColor(Color ColorKey, Uint8 Alpha) { replaceColor( ColorKey, Color( ColorKey.r, ColorKey.g, ColorKey.b, Alpha ) ); } -void SubTexture::createMaskFromColor(RGB ColorKey, Uint8 Alpha) { +void TextureRegion::createMaskFromColor(RGB ColorKey, Uint8 Alpha) { createMaskFromColor( Color( ColorKey.r, ColorKey.g, ColorKey.b, 255 ), Alpha ); } -void SubTexture::cacheAlphaMask() { +void TextureRegion::cacheAlphaMask() { Uint32 size = ( mSrcRect.Right - mSrcRect.Left ) * ( mSrcRect.Bottom - mSrcRect.Top ); eeSAFE_DELETE_ARRAY( mAlphaMask ); @@ -207,7 +207,7 @@ void SubTexture::cacheAlphaMask() { mTexture->unlock(); } -void SubTexture::cacheColors() { +void TextureRegion::cacheColors() { mTexture->lock(); Uint32 size = ( mSrcRect.Right - mSrcRect.Left ) * ( mSrcRect.Bottom - mSrcRect.Top ) * mTexture->getChannels(); @@ -243,7 +243,7 @@ void SubTexture::cacheColors() { mTexture->unlock(); } -Uint8 SubTexture::getAlphaAt( const Int32& X, const Int32& Y ) { +Uint8 TextureRegion::getAlphaAt( const Int32& X, const Int32& Y ) { if ( mTexture->hasLocalCopy() ) return mTexture->getPixel( mSrcRect.Left + X, mSrcRect.Right + Y ).a; @@ -258,7 +258,7 @@ Uint8 SubTexture::getAlphaAt( const Int32& X, const Int32& Y ) { return getAlphaAt( X, Y ); } -Color SubTexture::getColorAt( const Int32& X, const Int32& Y ) { +Color TextureRegion::getColorAt( const Int32& X, const Int32& Y ) { if ( mTexture->hasLocalCopy() ) return mTexture->getPixel( mSrcRect.Left + X, mSrcRect.Right + Y ); @@ -281,7 +281,7 @@ Color SubTexture::getColorAt( const Int32& X, const Int32& Y ) { return getColorAt( X, Y ); } -void SubTexture::setColorAt( const Int32& X, const Int32& Y, const Color& Color ) { +void TextureRegion::setColorAt( const Int32& X, const Int32& Y, const Color& Color ) { if ( NULL != mPixels ) { Uint32 Channels = mTexture->getChannels(); unsigned int Pos = ( X + Y * ( mSrcRect.Right - mSrcRect.Left ) ) * Channels; @@ -296,18 +296,18 @@ void SubTexture::setColorAt( const Int32& X, const Int32& Y, const Color& Color } } -void SubTexture::clearCache() { +void TextureRegion::clearCache() { eeSAFE_DELETE_ARRAY( mPixels ); eeSAFE_DELETE_ARRAY( mAlphaMask ); } -Uint8 * SubTexture::lock() { +Uint8 * TextureRegion::lock() { cacheColors(); return &mPixels[0]; } -bool SubTexture::unlock( const bool& KeepData, const bool& Modified ) { +bool TextureRegion::unlock( const bool& KeepData, const bool& Modified ) { if ( NULL != mPixels && NULL != mTexture ) { if ( Modified ) { TextureSaver saver( mTexture->getHandle() ); @@ -335,15 +335,15 @@ bool SubTexture::unlock( const bool& KeepData, const bool& Modified ) { return false; } -Sizei SubTexture::getRealSize() { +Sizei TextureRegion::getRealSize() { return mSrcRect.getSize(); } -Sizef SubTexture::getSize() { +Sizef TextureRegion::getSize() { return Sizef( (Float)((Int32)( mOriDestSize.getWidth() / mPixelDensity )), (Float)((Int32)( mOriDestSize.getHeight() / mPixelDensity )) ); } -const Uint8* SubTexture::getPixelsPtr() { +const Uint8* TextureRegion::getPixelsPtr() { if ( mPixels == NULL ) { lock(); unlock(true); @@ -352,7 +352,7 @@ const Uint8* SubTexture::getPixelsPtr() { return reinterpret_cast (&mPixels[0]); } -bool SubTexture::saveToFile(const std::string& filepath, const Image::SaveType & Format) { +bool TextureRegion::saveToFile(const std::string& filepath, const Image::SaveType & Format) { bool Res = false; lock(); @@ -372,32 +372,32 @@ bool SubTexture::saveToFile(const std::string& filepath, const Image::SaveType & return Res; } -void SubTexture::resetDestSize() { +void TextureRegion::resetDestSize() { mDestSize.x = mOriDestSize.getWidth(); mDestSize.y = mOriDestSize.getHeight(); } -Float SubTexture::getPixelDensity() const { +Float TextureRegion::getPixelDensity() const { return mPixelDensity; } -void SubTexture::setPixelDensity( const Float & pixelDensity ) { +void TextureRegion::setPixelDensity( const Float & pixelDensity ) { mPixelDensity = pixelDensity; } -Sizei SubTexture::getDpSize() { +Sizei TextureRegion::getDpSize() { return Sizei( (Int32)( mOriDestSize.getWidth() / mPixelDensity ), (Int32)( mOriDestSize.getHeight() / mPixelDensity ) ); } -Sizei SubTexture::getPxSize() { +Sizei TextureRegion::getPxSize() { return Sizei( (Int32)( mOriDestSize.getWidth() / mPixelDensity * PixelDensity::getPixelDensity() ), (Int32)( mOriDestSize.getHeight() / mPixelDensity * PixelDensity::getPixelDensity() ) ); } -Sizef SubTexture::getOriDestSize() const { +Sizef TextureRegion::getOriDestSize() const { return mOriDestSize; } -void SubTexture::setOriDestSize(const Sizef & oriDestSize) { +void TextureRegion::setOriDestSize(const Sizef & oriDestSize) { mOriDestSize = oriDestSize; } diff --git a/src/eepp/maps/gameobjectsprite.cpp b/src/eepp/maps/gameobjectsprite.cpp index f2aeafc7a..7fe7e440c 100644 --- a/src/eepp/maps/gameobjectsprite.cpp +++ b/src/eepp/maps/gameobjectsprite.cpp @@ -32,10 +32,10 @@ bool GameObjectSprite::isType( const Uint32& type ) { void GameObjectSprite::draw() { if ( NULL != mSprite ) { - SubTexture * subTexture = mSprite->getCurrentSubTexture(); - Sizef destSizeO = subTexture->getDestSize(); - Sizei realSize = subTexture->getRealSize(); - subTexture->setDestSize( Sizef( (Float)realSize.getWidth(), (Float)realSize.getHeight() ) ); + TextureRegion * TextureRegion = mSprite->getCurrentTextureRegion(); + Sizef destSizeO = TextureRegion->getDestSize(); + Sizei realSize = TextureRegion->getRealSize(); + TextureRegion->setDestSize( Sizef( (Float)realSize.getWidth(), (Float)realSize.getHeight() ) ); mSprite->setRotation( getRotation() ); @@ -73,7 +73,7 @@ void GameObjectSprite::draw() { mSprite->draw(); - subTexture->setDestSize( destSizeO ); + TextureRegion->setDestSize( destSizeO ); } } @@ -106,7 +106,7 @@ void GameObjectSprite::setTilePosition( Vector2i pos ) { Sizei GameObjectSprite::getSize() { if ( NULL != mSprite ) - return mSprite->getSubTexture(0)->getRealSize(); + return mSprite->getTextureRegion(0)->getRealSize(); return Sizei(); } @@ -132,27 +132,27 @@ void GameObjectSprite::setFlag( const Uint32& Flag ) { } Uint32 GameObjectSprite::getDataId() { - return mSprite->getSubTexture(0)->getId(); + return mSprite->getTextureRegion(0)->getId(); } void GameObjectSprite::setDataId( Uint32 Id ) { Graphics::Sprite * tSprite = NULL; if ( mFlags & GObjFlags::GAMEOBJECT_ANIMATED ) { - std::vector tSubTextureVec = TextureAtlasManager::instance()->getSubTexturesByPatternId( Id ); + std::vector tTextureRegionVec = TextureAtlasManager::instance()->getTextureRegionsByPatternId( Id ); - if ( tSubTextureVec.size() ) { + if ( tTextureRegionVec.size() ) { tSprite = eeNew( Graphics::Sprite, () ); tSprite->createAnimation(); - tSprite->addFrames( tSubTextureVec ); + tSprite->addFrames( tTextureRegionVec ); setSprite( tSprite ); } } else { - Graphics::SubTexture * tSubTexture = TextureAtlasManager::instance()->getSubTextureById( Id ); + Graphics::TextureRegion * tTextureRegion = TextureAtlasManager::instance()->getTextureRegionById( Id ); - if ( NULL != tSubTexture ) { - setSprite( eeNew( Graphics::Sprite, ( tSubTexture ) ) ); + if ( NULL != tTextureRegion ) { + setSprite( eeNew( Graphics::Sprite, ( tTextureRegion ) ) ); } } } diff --git a/src/eepp/maps/gameobjectsubtexture.cpp b/src/eepp/maps/gameobjectsubtexture.cpp deleted file mode 100644 index 85e3233a4..000000000 --- a/src/eepp/maps/gameobjectsubtexture.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include -#include -#include -#include - -namespace EE { namespace Maps { - -GameObjectSubTexture::GameObjectSubTexture( const Uint32& Flags, MapLayer * Layer, Graphics::SubTexture * SubTexture, const Vector2f& Pos ) : - GameObject( Flags, Layer ), - mSubTexture( SubTexture ), - mPos( Pos ) -{ - assignTilePos(); -} - -GameObjectSubTexture::~GameObjectSubTexture() { -} - -Uint32 GameObjectSubTexture::getType() const { - return GAMEOBJECT_TYPE_SUBTEXTURE; -} - -bool GameObjectSubTexture::isType( const Uint32& type ) { - return ( GameObjectSubTexture::getType() == type ) ? true : GameObject::isType( type ); -} - -void GameObjectSubTexture::draw() { - if ( NULL != mSubTexture ) { - Sizef destSizeO = mSubTexture->getDestSize(); - Sizei realSize = mSubTexture->getRealSize(); - mSubTexture->setDestSize( Sizef( (Float)realSize.getWidth(), (Float)realSize.getHeight() ) ); - - if ( mLayer->getMap()->getLightsEnabled() && mLayer->getLightsEnabled() ) { - MapLightManager * LM = mLayer->getMap()->getLightManager(); - - if ( MAP_LAYER_TILED == mLayer->getType() ) { - Vector2i Tile = reinterpret_cast ( mLayer )->getCurrentTile(); - - if ( LM->isByVertex() ) { - mSubTexture->draw( - mPos.x, - mPos.y, - getRotation(), - Vector2f::One, - *LM->getTileColor( Tile, 0 ), - *LM->getTileColor( Tile, 1 ), - *LM->getTileColor( Tile, 2 ), - *LM->getTileColor( Tile, 3 ), - getBlendModeFromFlags(), - getRenderModeFromFlags() - ); - } else { - mSubTexture->draw( mPos.x, mPos.y, *LM->getTileColor( Tile ), getRotation(), Vector2f::One, BlendAlpha, getRenderModeFromFlags() ); - } - } else { - if ( LM->isByVertex() ) { - mSubTexture->draw( - mPos.x, - mPos.y, - getRotation(), - Vector2f::One, - LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), - LM->getColorFromPos( Vector2f( mPos.x, mPos.y + mSubTexture->getDestSize().y ) ), - LM->getColorFromPos( Vector2f( mPos.x + mSubTexture->getDestSize().x, mPos.y + mSubTexture->getDestSize().y ) ), - LM->getColorFromPos( Vector2f( mPos.x + mSubTexture->getDestSize().y, mPos.y ) ), - getBlendModeFromFlags(), - getRenderModeFromFlags() - ); - } else { - mSubTexture->draw( mPos.x, mPos.y, LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), getRotation(), Vector2f::One, getBlendModeFromFlags(), getRenderModeFromFlags() ); - } - } - } else { - mSubTexture->draw( mPos.x, mPos.y, Color::White, getRotation(), Vector2f::One, getBlendModeFromFlags(), getRenderModeFromFlags() ); - } - - mSubTexture->setDestSize( destSizeO ); - } -} - -Vector2f GameObjectSubTexture::getPosition() const { - return mPos; -} - -void GameObjectSubTexture::setPosition( Vector2f pos ) { - mPos = pos; - GameObject::setPosition( pos ); -} - -Vector2i GameObjectSubTexture::getTilePosition() const { - return mTilePos; -} - -void GameObjectSubTexture::setTilePosition( Vector2i pos ) { - mTilePos = pos; -} - -Sizei GameObjectSubTexture::getSize() { - if ( NULL != mSubTexture ) - return mSubTexture->getRealSize(); - - return Sizei(); -} - -Graphics::SubTexture * GameObjectSubTexture::getSubTexture() const { - return mSubTexture; -} - -void GameObjectSubTexture::setSubTexture( Graphics::SubTexture * subTexture ) { - mSubTexture = subTexture; -} - -Uint32 GameObjectSubTexture::getDataId() { - return mSubTexture->getId(); -} - -void GameObjectSubTexture::setDataId( Uint32 Id ) { - setSubTexture( TextureAtlasManager::instance()->getSubTextureById( Id ) ); -} - -}} diff --git a/src/eepp/maps/gameobjectsubtextureex.cpp b/src/eepp/maps/gameobjectsubtextureex.cpp deleted file mode 100644 index bcec2e9a6..000000000 --- a/src/eepp/maps/gameobjectsubtextureex.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include -#include -#include - -namespace EE { namespace Maps { - -GameObjectSubTextureEx::GameObjectSubTextureEx( const Uint32& Flags, MapLayer * Layer, Graphics::SubTexture * SubTexture, const Vector2f& Pos, BlendMode Blend, RenderMode Render, Float Angle, Vector2f Scale, Color Color ) : - GameObjectSubTexture( Flags, Layer, SubTexture, Pos ), - mBlend( Blend ), - mRender( Render ), - mAngle( Angle ), - mScale( Scale ), - mColor( Color ), - mVertexColors( NULL ) -{ - mRender = getRenderModeFromFlags(); - mBlend = getBlendModeFromFlags(); - - if ( 0 == mAngle ) - mAngle = getRotation(); -} - -GameObjectSubTextureEx::~GameObjectSubTextureEx() -{ -} - -Uint32 GameObjectSubTextureEx::getType() const { - return GAMEOBJECT_TYPE_SUBTEXTUREEX; -} - -bool GameObjectSubTextureEx::isType( const Uint32& type ) { - return ( GameObjectSubTextureEx::getType() == type ) ? true : GameObjectSubTexture::isType( type ); -} - -void GameObjectSubTextureEx::draw() { - if ( NULL != mSubTexture ) { - Sizef destSizeO = mSubTexture->getDestSize(); - Sizei realSize = mSubTexture->getRealSize(); - mSubTexture->setDestSize( Sizef( (Float)realSize.getWidth(), (Float)realSize.getHeight() ) ); - - if ( mLayer->getMap()->getLightsEnabled() && mLayer->getLightsEnabled() ) { - MapLightManager * LM = mLayer->getMap()->getLightManager(); - - if ( MAP_LAYER_TILED == mLayer->getType() ) { - Vector2i Tile = reinterpret_cast ( mLayer )->getCurrentTile(); - - if ( LM->isByVertex() ) { - mSubTexture->draw( - mPos.x, - mPos.y, - mAngle, - mScale, - *LM->getTileColor( Tile, 0 ), - *LM->getTileColor( Tile, 1 ), - *LM->getTileColor( Tile, 2 ), - *LM->getTileColor( Tile, 3 ), - mBlend, - mRender - ); - } else { - mSubTexture->draw( mPos.x, mPos.y, *LM->getTileColor( Tile ), mAngle, mScale, mBlend, mRender ); - } - } else { - if ( LM->isByVertex() ) { - mSubTexture->draw( - mPos.x, - mPos.y, - mAngle, - mScale, - LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), - LM->getColorFromPos( Vector2f( mPos.x, mPos.y + mSubTexture->getDestSize().y ) ), - LM->getColorFromPos( Vector2f( mPos.x + mSubTexture->getDestSize().x, mPos.y + mSubTexture->getDestSize().y ) ), - LM->getColorFromPos( Vector2f( mPos.x + mSubTexture->getDestSize().x, mPos.y ) ), - mBlend, - mRender - ); - } else { - mSubTexture->draw( mPos.x, mPos.y, LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), mAngle, mScale, mBlend, mRender ); - } - } - } else { - if ( NULL != mVertexColors ) { - mSubTexture->draw( mPos.x, mPos.y, mAngle, mScale, mVertexColors[0], mVertexColors[1], mVertexColors[2], mVertexColors[4], mBlend, mRender ); - } else { - mSubTexture->draw( mPos.x, mPos.y, mColor, mAngle, mScale, mBlend, mRender ); - } - } - - mSubTexture->setDestSize( destSizeO ); - } -} - -void GameObjectSubTextureEx::setFlag( const Uint32& Flag ) { - mRender = getRenderModeFromFlags(); - mBlend = getBlendModeFromFlags(); - GameObject::setFlag( Flag ); -} - -}} diff --git a/src/eepp/maps/gameobjecttextureregion.cpp b/src/eepp/maps/gameobjecttextureregion.cpp new file mode 100644 index 000000000..673d0a007 --- /dev/null +++ b/src/eepp/maps/gameobjecttextureregion.cpp @@ -0,0 +1,122 @@ +#include +#include +#include +#include +#include + +namespace EE { namespace Maps { + +GameObjectTextureRegion::GameObjectTextureRegion( const Uint32& Flags, MapLayer * Layer, Graphics::TextureRegion * TextureRegion, const Vector2f& Pos ) : + GameObject( Flags, Layer ), + mTextureRegion( TextureRegion ), + mPos( Pos ) +{ + assignTilePos(); +} + +GameObjectTextureRegion::~GameObjectTextureRegion() { +} + +Uint32 GameObjectTextureRegion::getType() const { + return GAMEOBJECT_TYPE_TEXTUREREGION; +} + +bool GameObjectTextureRegion::isType( const Uint32& type ) { + return ( GameObjectTextureRegion::getType() == type ) ? true : GameObject::isType( type ); +} + +void GameObjectTextureRegion::draw() { + if ( NULL != mTextureRegion ) { + Sizef destSizeO = mTextureRegion->getDestSize(); + Sizei realSize = mTextureRegion->getRealSize(); + mTextureRegion->setDestSize( Sizef( (Float)realSize.getWidth(), (Float)realSize.getHeight() ) ); + + if ( mLayer->getMap()->getLightsEnabled() && mLayer->getLightsEnabled() ) { + MapLightManager * LM = mLayer->getMap()->getLightManager(); + + if ( MAP_LAYER_TILED == mLayer->getType() ) { + Vector2i Tile = reinterpret_cast ( mLayer )->getCurrentTile(); + + if ( LM->isByVertex() ) { + mTextureRegion->draw( + mPos.x, + mPos.y, + getRotation(), + Vector2f::One, + *LM->getTileColor( Tile, 0 ), + *LM->getTileColor( Tile, 1 ), + *LM->getTileColor( Tile, 2 ), + *LM->getTileColor( Tile, 3 ), + getBlendModeFromFlags(), + getRenderModeFromFlags() + ); + } else { + mTextureRegion->draw( mPos.x, mPos.y, *LM->getTileColor( Tile ), getRotation(), Vector2f::One, BlendAlpha, getRenderModeFromFlags() ); + } + } else { + if ( LM->isByVertex() ) { + mTextureRegion->draw( + mPos.x, + mPos.y, + getRotation(), + Vector2f::One, + LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), + LM->getColorFromPos( Vector2f( mPos.x, mPos.y + mTextureRegion->getDestSize().y ) ), + LM->getColorFromPos( Vector2f( mPos.x + mTextureRegion->getDestSize().x, mPos.y + mTextureRegion->getDestSize().y ) ), + LM->getColorFromPos( Vector2f( mPos.x + mTextureRegion->getDestSize().y, mPos.y ) ), + getBlendModeFromFlags(), + getRenderModeFromFlags() + ); + } else { + mTextureRegion->draw( mPos.x, mPos.y, LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), getRotation(), Vector2f::One, getBlendModeFromFlags(), getRenderModeFromFlags() ); + } + } + } else { + mTextureRegion->draw( mPos.x, mPos.y, Color::White, getRotation(), Vector2f::One, getBlendModeFromFlags(), getRenderModeFromFlags() ); + } + + mTextureRegion->setDestSize( destSizeO ); + } +} + +Vector2f GameObjectTextureRegion::getPosition() const { + return mPos; +} + +void GameObjectTextureRegion::setPosition( Vector2f pos ) { + mPos = pos; + GameObject::setPosition( pos ); +} + +Vector2i GameObjectTextureRegion::getTilePosition() const { + return mTilePos; +} + +void GameObjectTextureRegion::setTilePosition( Vector2i pos ) { + mTilePos = pos; +} + +Sizei GameObjectTextureRegion::getSize() { + if ( NULL != mTextureRegion ) + return mTextureRegion->getRealSize(); + + return Sizei(); +} + +Graphics::TextureRegion * GameObjectTextureRegion::getTextureRegion() const { + return mTextureRegion; +} + +void GameObjectTextureRegion::setTextureRegion( Graphics::TextureRegion * TextureRegion ) { + mTextureRegion = TextureRegion; +} + +Uint32 GameObjectTextureRegion::getDataId() { + return mTextureRegion->getId(); +} + +void GameObjectTextureRegion::setDataId( Uint32 Id ) { + setTextureRegion( TextureAtlasManager::instance()->getTextureRegionById( Id ) ); +} + +}} diff --git a/src/eepp/maps/gameobjecttextureregionex.cpp b/src/eepp/maps/gameobjecttextureregionex.cpp new file mode 100644 index 000000000..37c399921 --- /dev/null +++ b/src/eepp/maps/gameobjecttextureregionex.cpp @@ -0,0 +1,99 @@ +#include +#include +#include + +namespace EE { namespace Maps { + +GameObjectTextureRegionEx::GameObjectTextureRegionEx( const Uint32& Flags, MapLayer * Layer, Graphics::TextureRegion * TextureRegion, const Vector2f& Pos, BlendMode Blend, RenderMode Render, Float Angle, Vector2f Scale, Color Color ) : + GameObjectTextureRegion( Flags, Layer, TextureRegion, Pos ), + mBlend( Blend ), + mRender( Render ), + mAngle( Angle ), + mScale( Scale ), + mColor( Color ), + mVertexColors( NULL ) +{ + mRender = getRenderModeFromFlags(); + mBlend = getBlendModeFromFlags(); + + if ( 0 == mAngle ) + mAngle = getRotation(); +} + +GameObjectTextureRegionEx::~GameObjectTextureRegionEx() +{ +} + +Uint32 GameObjectTextureRegionEx::getType() const { + return GAMEOBJECT_TYPE_TEXTUREREGIONEX; +} + +bool GameObjectTextureRegionEx::isType( const Uint32& type ) { + return ( GameObjectTextureRegionEx::getType() == type ) ? true : GameObjectTextureRegion::isType( type ); +} + +void GameObjectTextureRegionEx::draw() { + if ( NULL != mTextureRegion ) { + Sizef destSizeO = mTextureRegion->getDestSize(); + Sizei realSize = mTextureRegion->getRealSize(); + mTextureRegion->setDestSize( Sizef( (Float)realSize.getWidth(), (Float)realSize.getHeight() ) ); + + if ( mLayer->getMap()->getLightsEnabled() && mLayer->getLightsEnabled() ) { + MapLightManager * LM = mLayer->getMap()->getLightManager(); + + if ( MAP_LAYER_TILED == mLayer->getType() ) { + Vector2i Tile = reinterpret_cast ( mLayer )->getCurrentTile(); + + if ( LM->isByVertex() ) { + mTextureRegion->draw( + mPos.x, + mPos.y, + mAngle, + mScale, + *LM->getTileColor( Tile, 0 ), + *LM->getTileColor( Tile, 1 ), + *LM->getTileColor( Tile, 2 ), + *LM->getTileColor( Tile, 3 ), + mBlend, + mRender + ); + } else { + mTextureRegion->draw( mPos.x, mPos.y, *LM->getTileColor( Tile ), mAngle, mScale, mBlend, mRender ); + } + } else { + if ( LM->isByVertex() ) { + mTextureRegion->draw( + mPos.x, + mPos.y, + mAngle, + mScale, + LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), + LM->getColorFromPos( Vector2f( mPos.x, mPos.y + mTextureRegion->getDestSize().y ) ), + LM->getColorFromPos( Vector2f( mPos.x + mTextureRegion->getDestSize().x, mPos.y + mTextureRegion->getDestSize().y ) ), + LM->getColorFromPos( Vector2f( mPos.x + mTextureRegion->getDestSize().x, mPos.y ) ), + mBlend, + mRender + ); + } else { + mTextureRegion->draw( mPos.x, mPos.y, LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), mAngle, mScale, mBlend, mRender ); + } + } + } else { + if ( NULL != mVertexColors ) { + mTextureRegion->draw( mPos.x, mPos.y, mAngle, mScale, mVertexColors[0], mVertexColors[1], mVertexColors[2], mVertexColors[4], mBlend, mRender ); + } else { + mTextureRegion->draw( mPos.x, mPos.y, mColor, mAngle, mScale, mBlend, mRender ); + } + } + + mTextureRegion->setDestSize( destSizeO ); + } +} + +void GameObjectTextureRegionEx::setFlag( const Uint32& Flag ) { + mRender = getRenderModeFromFlags(); + mBlend = getBlendModeFromFlags(); + GameObject::setFlag( Flag ); +} + +}} diff --git a/src/eepp/maps/gameobjectvirtual.cpp b/src/eepp/maps/gameobjectvirtual.cpp index cce25cf97..d19d548d8 100644 --- a/src/eepp/maps/gameobjectvirtual.cpp +++ b/src/eepp/maps/gameobjectvirtual.cpp @@ -14,20 +14,20 @@ GameObjectVirtual::GameObjectVirtual( Uint32 DataId, MapLayer * Layer, const Uin mDataId( DataId ), mPos( Pos ), mLayer( NULL ), - mSubTexture( NULL ) + mTextureRegion( NULL ) { } -GameObjectVirtual::GameObjectVirtual( SubTexture * SubTexture, MapLayer * Layer, const Uint32& Flags, Uint32 Type, const Vector2f& Pos ) : +GameObjectVirtual::GameObjectVirtual( TextureRegion * TextureRegion, MapLayer * Layer, const Uint32& Flags, Uint32 Type, const Vector2f& Pos ) : GameObject( Flags, Layer ), mType( Type ), mDataId( 0 ), mPos( Pos ), mLayer( Layer ), - mSubTexture( SubTexture ) + mTextureRegion( TextureRegion ) { - if ( NULL != SubTexture ) - mDataId = SubTexture->getId(); + if ( NULL != TextureRegion ) + mDataId = TextureRegion->getId(); } GameObjectVirtual::~GameObjectVirtual() { @@ -46,8 +46,8 @@ Uint32 GameObjectVirtual::getRealType() const { } Sizei GameObjectVirtual::getSize() { - if ( NULL != mSubTexture ) - return Sizei( (Int32)mSubTexture->getDestSize().x, (Int32)mSubTexture->getDestSize().y ); + if ( NULL != mTextureRegion ) + return Sizei( (Int32)mTextureRegion->getDestSize().x, (Int32)mTextureRegion->getDestSize().y ); if ( NULL != mLayer ) return mLayer->getMap()->getTileSize(); @@ -56,7 +56,7 @@ Sizei GameObjectVirtual::getSize() { } void GameObjectVirtual::draw() { - if ( NULL != mSubTexture ) { + if ( NULL != mTextureRegion ) { if ( mLayer->getMap()->getLightsEnabled() && mLayer->getLightsEnabled() ) { MapLightManager * LM = mLayer->getMap()->getLightManager(); @@ -64,7 +64,7 @@ void GameObjectVirtual::draw() { Vector2i Tile = reinterpret_cast ( mLayer )->getCurrentTile(); if ( LM->isByVertex() ) { - mSubTexture->draw( + mTextureRegion->draw( mPos.x, mPos.y, getRotation(), @@ -77,28 +77,28 @@ void GameObjectVirtual::draw() { getRenderModeFromFlags() ); } else { - mSubTexture->draw( mPos.x, mPos.y, *LM->getTileColor( Tile ), getRotation(), Vector2f::One, getBlendModeFromFlags(), getRenderModeFromFlags() ); + mTextureRegion->draw( mPos.x, mPos.y, *LM->getTileColor( Tile ), getRotation(), Vector2f::One, getBlendModeFromFlags(), getRenderModeFromFlags() ); } } else { if ( LM->isByVertex() ) { - mSubTexture->draw( + mTextureRegion->draw( mPos.x, mPos.y, getRotation(), Vector2f::One, LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), - LM->getColorFromPos( Vector2f( mPos.x, mPos.y + mSubTexture->getDestSize().y ) ), - LM->getColorFromPos( Vector2f( mPos.x + mSubTexture->getDestSize().x, mPos.y + mSubTexture->getDestSize().y ) ), - LM->getColorFromPos( Vector2f( mPos.x + mSubTexture->getDestSize().x, mPos.y ) ), + LM->getColorFromPos( Vector2f( mPos.x, mPos.y + mTextureRegion->getDestSize().y ) ), + LM->getColorFromPos( Vector2f( mPos.x + mTextureRegion->getDestSize().x, mPos.y + mTextureRegion->getDestSize().y ) ), + LM->getColorFromPos( Vector2f( mPos.x + mTextureRegion->getDestSize().x, mPos.y ) ), getBlendModeFromFlags(), getRenderModeFromFlags() ); } else { - mSubTexture->draw( mPos.x, mPos.y, LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), getRotation(), Vector2f::One, BlendAlpha, getRenderModeFromFlags() ); + mTextureRegion->draw( mPos.x, mPos.y, LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ), getRotation(), Vector2f::One, BlendAlpha, getRenderModeFromFlags() ); } } } else { - mSubTexture->draw( mPos.x, mPos.y, Color::White, getRotation(), Vector2f::One, getBlendModeFromFlags(), getRenderModeFromFlags() ); + mTextureRegion->draw( mPos.x, mPos.y, Color::White, getRotation(), Vector2f::One, getBlendModeFromFlags(), getRenderModeFromFlags() ); } } else { Primitives P; diff --git a/src/eepp/maps/mapeditor/mapeditor.cpp b/src/eepp/maps/mapeditor/mapeditor.cpp index dab12d1b7..88cfb315c 100644 --- a/src/eepp/maps/mapeditor/mapeditor.cpp +++ b/src/eepp/maps/mapeditor/mapeditor.cpp @@ -9,8 +9,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -177,19 +177,19 @@ void MapEditor::createETGMenu() { Int32 ContPosX = mWinContainer->getSize().getWidth() - Width - DistToBorder; Int32 DistFromTopMenu = 4; - mSubTextureCont = UIWidget::New(); - mSubTextureCont->setParent( mWinContainer ); - mSubTextureCont->setSize( Sizei( Width + DistToBorder, mWinContainer->getSize().getHeight() ) ); - mSubTextureCont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); + mTextureRegionCont = UIWidget::New(); + mTextureRegionCont->setParent( mWinContainer ); + mTextureRegionCont->setSize( Sizei( Width + DistToBorder, mWinContainer->getSize().getHeight() ) ); + mTextureRegionCont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); mLightCont = UIWidget::New(); mLightCont->setParent( mWinContainer ); - mLightCont->setSize( mSubTextureCont->getSize() ); + mLightCont->setSize( mTextureRegionCont->getSize() ); mLightCont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); mObjectCont = UIWidget::New(); mObjectCont->setParent( mWinContainer ); - mObjectCont->setSize( mSubTextureCont->getSize() ); + mObjectCont->setSize( mTextureRegionCont->getSize() ); mObjectCont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); mTabWidget = UITabWidget::New(); @@ -205,14 +205,14 @@ void MapEditor::createETGMenu() { createLighContainer(); - createSubTextureContainer( Width ); + createTextureRegionContainer( Width ); createObjectsContainer(); } void MapEditor::createTabs() { mTabWidget->removeAll(); - mTabWidget->add( "Sprites", mSubTextureCont ); + mTabWidget->add( "Sprites", mTextureRegionCont ); if ( NULL != mUIMap && NULL != mUIMap->Map() ) { if ( mUIMap->Map()->getLightsEnabled() ) { @@ -241,28 +241,28 @@ void MapEditor::onTabSelected( const UIEvent * Event ) { void MapEditor::fillGotyList() { std::vector items; - items.push_back( "SubTexture" ); - items.push_back( "SubTextureEx" ); + items.push_back( "TextureRegion" ); + items.push_back( "TextureRegionEx" ); items.push_back( "Sprite" ); mGOTypeList->getListBox()->clear(); mGOTypeList->getListBox()->addListBoxItems( items ); mGOTypeList->getListBox()->setSelected(0); } -void MapEditor::createSubTextureContainer( Int32 Width ) { +void MapEditor::createTextureRegionContainer( Int32 Width ) { UITextView * Txt; Uint32 TxtFlags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP; - Txt = createTextBox( "Add Game Object as...", mSubTextureCont, Sizei( Width, 16 ), Vector2i( TAB_CONT_X_DIST, 4 ), TxtFlags, Text::Shadow ); + Txt = createTextBox( "Add Game Object as...", mTextureRegionCont, Sizei( Width, 16 ), Vector2i( TAB_CONT_X_DIST, 4 ), TxtFlags, Text::Shadow ); mGOTypeList = UIDropDownList::New(); - mGOTypeList->setFontStyle( Text::Shadow )->setParent( mSubTextureCont )->setSize( Width - 26, 0 )->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 ); + mGOTypeList->setFontStyle( Text::Shadow )->setParent( mTextureRegionCont )->setSize( Width - 26, 0 )->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 ); mGOTypeList->addEventListener( UIEvent::OnItemSelected, cb::Make1( this, &MapEditor::onTypeChange ) ); fillGotyList(); mBtnGOTypeAdd = UIPushButton::New(); - mBtnGOTypeAdd->setParent( mSubTextureCont )->setSize( 24, mGOTypeList->getSize().getHeight() ) + mBtnGOTypeAdd->setParent( mTextureRegionCont )->setSize( 24, mGOTypeList->getSize().getHeight() ) ->setPosition( mGOTypeList->getPosition().x + mGOTypeList->getSize().getWidth() + 2, mGOTypeList->getPosition().y ); mBtnGOTypeAdd->setIcon( mTheme->getIconByName( "add" ) )->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); mBtnGOTypeAdd->setTooltipText( "Adds a new game object type\nunknown by the map editor." ); @@ -271,66 +271,66 @@ void MapEditor::createSubTextureContainer( Int32 Width ) { if ( NULL == mBtnGOTypeAdd->getIcon()->getDrawable() ) mBtnGOTypeAdd->setText( "..." ); - Txt = createTextBox( "Layers:", mSubTextureCont, Sizei( Width, 16 ), Vector2i( TAB_CONT_X_DIST, mGOTypeList->getPosition().y + mGOTypeList->getSize().getHeight() + 4 ), TxtFlags, Text::Shadow ); + Txt = createTextBox( "Layers:", mTextureRegionCont, Sizei( Width, 16 ), Vector2i( TAB_CONT_X_DIST, mGOTypeList->getPosition().y + mGOTypeList->getSize().getHeight() + 4 ), TxtFlags, Text::Shadow ); mLayerList = UIDropDownList::New(); - mLayerList->setFontStyle( Text::Shadow )->setParent( mSubTextureCont )->setSize( Width, 0 )->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 ); + mLayerList->setFontStyle( Text::Shadow )->setParent( mTextureRegionCont )->setSize( Width, 0 )->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 ); mLayerList->addEventListener( UIEvent::OnItemSelected, cb::Make1( this, &MapEditor::onLayerSelect ) ); - Txt = createTextBox( "Game Object Flags:", mSubTextureCont, Sizei( Width, 16 ), Vector2i( TAB_CONT_X_DIST, mLayerList->getPosition().y + mLayerList->getSize().getHeight() + 4 ), TxtFlags, Text::Shadow ); + Txt = createTextBox( "Game Object Flags:", mTextureRegionCont, Sizei( Width, 16 ), Vector2i( TAB_CONT_X_DIST, mLayerList->getPosition().y + mLayerList->getSize().getHeight() + 4 ), TxtFlags, Text::Shadow ); Uint32 ChkFlags = UI_CONTROL_DEFAULT_ALIGN | UI_AUTO_SIZE | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP; mChkMirrored = UICheckBox::New(); - mChkMirrored->setFontStyle( Text::Shadow )->setParent( mSubTextureCont )->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); + mChkMirrored->setFontStyle( Text::Shadow )->setParent( mTextureRegionCont )->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); mChkMirrored->setText( "Mirrored" ); mChkMirrored->addEventListener( UIEvent::OnValueChange, cb::Make1( this, &MapEditor::chkClickMirrored ) ); mChkFliped = UICheckBox::New(); - mChkFliped->setFontStyle( Text::Shadow )->setParent( mSubTextureCont )->setPosition( mChkMirrored->getPosition().x + mChkMirrored->getSize().getWidth() + 32, mChkMirrored->getPosition().y )->resetFlags( ChkFlags ); + mChkFliped->setFontStyle( Text::Shadow )->setParent( mTextureRegionCont )->setPosition( mChkMirrored->getPosition().x + mChkMirrored->getSize().getWidth() + 32, mChkMirrored->getPosition().y )->resetFlags( ChkFlags ); mChkFliped->setText( "Fliped" ); mChkFliped->addEventListener( UIEvent::OnValueChange, cb::Make1( this, &MapEditor::chkClickFlipped ) ); mChkBlocked = UICheckBox::New(); - mChkBlocked->setFontStyle( Text::Shadow )->setParent( mSubTextureCont )->setPosition( mChkMirrored->getPosition().x, mChkMirrored->getPosition().y + mChkMirrored->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); + mChkBlocked->setFontStyle( Text::Shadow )->setParent( mTextureRegionCont )->setPosition( mChkMirrored->getPosition().x, mChkMirrored->getPosition().y + mChkMirrored->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); mChkBlocked->setText( "Blocked" ); mChkBlocked->setTooltipText( "Blocks the tile occupied by the sprite." ); mChkBlocked->addEventListener( UIEvent::OnValueChange, cb::Make1( this, &MapEditor::chkClickBlocked ) ); mChkAnim = UICheckBox::New(); - mChkAnim->setFontStyle( Text::Shadow )->setParent( mSubTextureCont )->setPosition( mChkFliped->getPosition().x, mChkFliped->getPosition().y + mChkFliped->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); + mChkAnim->setFontStyle( Text::Shadow )->setParent( mTextureRegionCont )->setPosition( mChkFliped->getPosition().x, mChkFliped->getPosition().y + mChkFliped->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); mChkAnim->setText( "Animated" ); mChkAnim->setTooltipText( "Indicates if the Sprite is animated." ); mChkAnim->addEventListener( UIEvent::OnValueChange, cb::Make1( this, &MapEditor::chkClickAnimated ) ); mChkRot90 = UICheckBox::New(); - mChkRot90->setFontStyle( Text::Shadow )->setParent( mSubTextureCont )->setPosition( mChkBlocked->getPosition().x, mChkBlocked->getPosition().y + mChkBlocked->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); + mChkRot90->setFontStyle( Text::Shadow )->setParent( mTextureRegionCont )->setPosition( mChkBlocked->getPosition().x, mChkBlocked->getPosition().y + mChkBlocked->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); mChkRot90->setText( String::fromUtf8( "Rotate 90º" ) ); mChkRot90->addEventListener( UIEvent::OnValueChange, cb::Make1( this, &MapEditor::chkClickRot90 ) ); mChkAutoFix = UICheckBox::New(); - mChkAutoFix->setFontStyle( Text::Shadow )->setParent( mSubTextureCont )->setPosition( mChkAnim->getPosition().x, mChkAnim->getPosition().y + mChkAnim->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); + mChkAutoFix->setFontStyle( Text::Shadow )->setParent( mTextureRegionCont )->setPosition( mChkAnim->getPosition().x, mChkAnim->getPosition().y + mChkAnim->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); mChkAutoFix->setText( "AutoFix TilePos" ); mChkAutoFix->setTooltipText( "In a tiled layer if the sprite is moved,\nit will update the current tile position automatically." ); mChkAutoFix->addEventListener( UIEvent::OnValueChange, cb::Make1( this, &MapEditor::chkClickAutoFix ) ); mChkBlendAdd = UICheckBox::New(); - mChkBlendAdd->setFontStyle( Text::Shadow )->setParent( mSubTextureCont )->setPosition( mChkRot90->getPosition().x, mChkRot90->getPosition().y + mChkRot90->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); + mChkBlendAdd->setFontStyle( Text::Shadow )->setParent( mTextureRegionCont )->setPosition( mChkRot90->getPosition().x, mChkRot90->getPosition().y + mChkRot90->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); mChkBlendAdd->setText( "Additive Blend" ); mChkBlendAdd->setTooltipText( "Use additive blend mode." ); mChkBlendAdd->addEventListener( UIEvent::OnValueChange, cb::Make1( this, &MapEditor::chkClickAutoFix ) ); - Txt = createTextBox( "Game Object Data:", mSubTextureCont, Sizei( Width, 16 ), Vector2i( TAB_CONT_X_DIST, mChkBlendAdd->getPosition().y + mChkBlendAdd->getSize().getHeight() + 8 ), TxtFlags, Text::Shadow ); + Txt = createTextBox( "Game Object Data:", mTextureRegionCont, Sizei( Width, 16 ), Vector2i( TAB_CONT_X_DIST, mChkBlendAdd->getPosition().y + mChkBlendAdd->getSize().getHeight() + 8 ), TxtFlags, Text::Shadow ); mChkDI = UICheckBox::New(); - mChkDI->setFontStyle( Text::Shadow )->setParent( mSubTextureCont )->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); + mChkDI->setFontStyle( Text::Shadow )->setParent( mTextureRegionCont )->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 )->resetFlags( ChkFlags ); mChkDI->setText( "Add as DataId" ); mChkDI->setTooltipText( "If the resource it's not a sprite,\nyou can reference it with a data id" ); mChkDI->addEventListener( UIEvent::OnValueChange, cb::Make1( this, &MapEditor::chkClickDI ) ); mSGCont = UIWidget::New(); - mSGCont->setParent( mSubTextureCont )->setPosition( TAB_CONT_X_DIST, mChkDI->getPosition().y + mChkDI->getSize().getHeight() + 8 )->setSize( Width, 400 ); + mSGCont->setParent( mTextureRegionCont )->setPosition( TAB_CONT_X_DIST, mChkDI->getPosition().y + mChkDI->getSize().getHeight() + 8 )->setSize( Width, 400 ); mSGCont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); mSGCont->setEnabled( true ); mSGCont->setVisible( true ); @@ -341,23 +341,23 @@ void MapEditor::createSubTextureContainer( Int32 Width ) { mTextureAtlasesList->setFontStyle( Text::Shadow )->setParent( mSGCont )->setSize( Width, 0 )->setPosition( 0, Txt->getPosition().y +Txt->getSize().getHeight() + 4 ); mTextureAtlasesList->addEventListener( UIEvent::OnItemSelected, cb::Make1( this, &MapEditor::onTextureAtlasChange ) ); - mSubTextureList = UIListBox::New(); - mSubTextureList->setParent( mSGCont ) + mTextureRegionList = UIListBox::New(); + mTextureRegionList->setParent( mSGCont ) ->setPosition( 0, mTextureAtlasesList->getPosition().y + mTextureAtlasesList->getSize().getHeight() + 4 ) - ->setSize( Width, mSubTextureList->getRowHeight() * 9 + mSubTextureList->getContainerPadding().Top + mSubTextureList->getContainerPadding().Bottom ); - mSubTextureList->setAnchors(UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); - mSubTextureList->addEventListener( UIEvent::OnItemSelected, cb::Make1( this, &MapEditor::onSubTextureChange ) ); + ->setSize( Width, mTextureRegionList->getRowHeight() * 9 + mTextureRegionList->getContainerPadding().Top + mTextureRegionList->getContainerPadding().Bottom ); + mTextureRegionList->setAnchors(UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); + mTextureRegionList->addEventListener( UIEvent::OnItemSelected, cb::Make1( this, &MapEditor::onTextureRegionChange ) ); - mGfxPreview = UISubTexture::New(); + mGfxPreview = UITextureRegion::New(); mGfxPreview->setScaleType( UIScaleType::FitInside ) ->resetFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ) ->setParent( mSGCont )->setSize( Width, Width ) - ->setPosition( 0, mSubTextureList->getPosition().y + mSubTextureList->getSize().getHeight() + 4 ); + ->setPosition( 0, mTextureRegionList->getPosition().y + mTextureRegionList->getSize().getHeight() + 4 ); mGfxPreview->setBorderEnabled( true )->setColor( Color( 0, 0, 0, 200 ) ); mDICont = UIWidget::New(); - mDICont->setParent( mSubTextureCont )->setPosition( TAB_CONT_X_DIST, mChkDI->getPosition().y + mChkDI->getSize().getHeight() + 8 ); + mDICont->setParent( mTextureRegionCont )->setPosition( TAB_CONT_X_DIST, mChkDI->getPosition().y + mChkDI->getSize().getHeight() + 8 ); mDICont->setSize( Width, 400 ); mDICont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); mDICont->setEnabled( false ); @@ -690,17 +690,17 @@ void MapEditor::updateFlags() { } void MapEditor::onTypeChange( const UIEvent * Event ) { - if ( mGOTypeList->getText() == "SubTexture" ) - mCurGOType = GAMEOBJECT_TYPE_SUBTEXTURE; - else if ( mGOTypeList->getText() == "SubTextureEx" ) - mCurGOType = GAMEOBJECT_TYPE_SUBTEXTUREEX; + if ( mGOTypeList->getText() == "TextureRegion" ) + mCurGOType = GAMEOBJECT_TYPE_TEXTUREREGION; + else if ( mGOTypeList->getText() == "TextureRegionEx" ) + mCurGOType = GAMEOBJECT_TYPE_TEXTUREREGIONEX; else if ( mGOTypeList->getText() == "Sprite" ) mCurGOType = GAMEOBJECT_TYPE_SPRITE; else mCurGOType = String::hash( mGOTypeList->getText().toUtf8() ); if ( NULL != mChkAnim && NULL != mGOTypeList && mChkAnim->isActive() && mGOTypeList->getText() != "Sprite" ) { - if ( mGOTypeList->getText() == "SubTexture" || mGOTypeList->getText() == "SubTextureEx" ) { + if ( mGOTypeList->getText() == "TextureRegion" || mGOTypeList->getText() == "TextureRegionEx" ) { mChkAnim->setActive( false ); } } @@ -732,7 +732,7 @@ void MapEditor::chkClickAutoFix( const UIEvent * Event ) { void MapEditor::chkClickAnimated( const UIEvent * Event ) { updateFlags(); - if ( mChkAnim->isActive() && ( mGOTypeList->getText() == "SubTexture" || mGOTypeList->getText() == "SubTextureEx" ) ) { + if ( mChkAnim->isActive() && ( mGOTypeList->getText() == "TextureRegion" || mGOTypeList->getText() == "TextureRegionEx" ) ) { mGOTypeList->getListBox()->setSelected( "Sprite" ); } } @@ -780,43 +780,43 @@ void MapEditor::fillSGCombo() { } } -void MapEditor::fillSubTextureList() { +void MapEditor::fillTextureRegionList() { TextureAtlasManager * SGM = TextureAtlasManager::instance(); mCurSG = SGM->getByName( mTextureAtlasesList->getText() ); - std::list& Res = mCurSG->getResources(); + std::list& Res = mCurSG->getResources(); - mSubTextureList->clear(); + mTextureRegionList->clear(); if ( NULL != mCurSG ) { std::vector items; - for ( std::list::iterator it = Res.begin(); it != Res.end(); it++ ) { + for ( std::list::iterator it = Res.begin(); it != Res.end(); it++ ) { items.push_back( (*it)->getName() ); } if ( items.size() ) { std::sort( items.begin(), items.end() ); - mSubTextureList->addListBoxItems( items ); - mSubTextureList->setSelected( 0 ); + mTextureRegionList->addListBoxItems( items ); + mTextureRegionList->setSelected( 0 ); } } - mSubTextureList->getVerticalScrollBar()->setClickStep( 8.f / (Float)mSubTextureList->getCount() ); + mTextureRegionList->getVerticalScrollBar()->setClickStep( 8.f / (Float)mTextureRegionList->getCount() ); } -void MapEditor::onSubTextureChange( const UIEvent * Event ) { +void MapEditor::onTextureRegionChange( const UIEvent * Event ) { if ( NULL != mCurSG ) { - SubTexture * tSubTexture = mCurSG->getByName( mSubTextureList->getItemSelectedText() ); + TextureRegion * tTextureRegion = mCurSG->getByName( mTextureRegionList->getItemSelectedText() ); - if ( NULL != tSubTexture ) { - mGfxPreview->setSubTexture( tSubTexture ); + if ( NULL != tTextureRegion ) { + mGfxPreview->setTextureRegion( tTextureRegion ); } } } void MapEditor::onTextureAtlasChange( const UIEvent * Event ) { - fillSubTextureList(); + fillTextureRegionList(); } void MapEditor::createNewMap() { @@ -1229,25 +1229,25 @@ void MapEditor::windowClose( const UIEvent * Event ) { GameObject * MapEditor::createGameObject() { GameObject * tObj = NULL; - if ( GAMEOBJECT_TYPE_SUBTEXTURE == mCurGOType ) { + if ( GAMEOBJECT_TYPE_TEXTUREREGION == mCurGOType ) { - tObj = eeNew( GameObjectSubTexture, ( mCurGOFlags, mCurLayer, mGfxPreview->getSubTexture() ) ); + tObj = eeNew( GameObjectTextureRegion, ( mCurGOFlags, mCurLayer, mGfxPreview->getTextureRegion() ) ); - } else if ( GAMEOBJECT_TYPE_SUBTEXTUREEX == mCurGOType ) { + } else if ( GAMEOBJECT_TYPE_TEXTUREREGIONEX == mCurGOType ) { - tObj = eeNew( GameObjectSubTextureEx, ( mCurGOFlags, mCurLayer, mGfxPreview->getSubTexture() ) ); + tObj = eeNew( GameObjectTextureRegionEx, ( mCurGOFlags, mCurLayer, mGfxPreview->getTextureRegion() ) ); } else if ( GAMEOBJECT_TYPE_SPRITE == mCurGOType ) { if ( mChkAnim->isActive() ) { - Sprite * tAnimSprite = eeNew( Sprite, ( String::removeNumbersAtEnd( mGfxPreview->getSubTexture()->getName() ) ) ); + Sprite * tAnimSprite = eeNew( Sprite, ( String::removeNumbersAtEnd( mGfxPreview->getTextureRegion()->getName() ) ) ); tObj = eeNew( GameObjectSprite, ( mCurGOFlags, mCurLayer, tAnimSprite ) ); tAnimSprite->setAutoAnimate( false ); } else { - Sprite * tStatiSprite = eeNew( Sprite, ( mGfxPreview->getSubTexture() ) ); + Sprite * tStatiSprite = eeNew( Sprite, ( mGfxPreview->getTextureRegion() ) ); tObj = eeNew( GameObjectSprite, ( mCurGOFlags, mCurLayer, tStatiSprite ) ); } @@ -1257,7 +1257,7 @@ GameObject * MapEditor::createGameObject() { if ( mChkDI->isActive() ) tObj = eeNew( GameObjectVirtual, ( String::hash( mDataIdInput->getText().toUtf8() ), mCurLayer, mCurGOFlags, mCurGOType ) ); else - tObj = eeNew( GameObjectVirtual, ( mGfxPreview->getSubTexture(), mCurLayer, mCurGOFlags, mCurGOType ) ); + tObj = eeNew( GameObjectVirtual, ( mGfxPreview->getTextureRegion(), mCurLayer, mCurGOFlags, mCurGOType ) ); } return tObj; @@ -1317,8 +1317,8 @@ GameObject * MapEditor::getCurrentGOOver() { void MapEditor::onMapMouseClick( const UIEvent * Event ) { const UIEventMouse * MEvent = reinterpret_cast ( Event ); - if ( mSubTextureCont->isVisible() ) { - if ( NULL == mCurLayer || NULL == mGfxPreview->getSubTexture() || UIManager::instance()->getDownControl() != mUIMap ) { + if ( mTextureRegionCont->isVisible() ) { + if ( NULL == mCurLayer || NULL == mGfxPreview->getTextureRegion() || UIManager::instance()->getDownControl() != mUIMap ) { if ( NULL == mCurLayer ) createNoLayerAlert( "No layers found" ); @@ -1362,8 +1362,8 @@ void MapEditor::onMapMouseClick( const UIEvent * Event ) { void MapEditor::onMapMouseDown( const UIEvent * Event ) { const UIEventMouse * MEvent = reinterpret_cast ( Event ); - if ( mSubTextureCont->isVisible() ) { - if ( NULL == mCurLayer || NULL == mGfxPreview->getSubTexture() || UIManager::instance()->getDownControl() != mUIMap ) + if ( mTextureRegionCont->isVisible() ) { + if ( NULL == mCurLayer || NULL == mGfxPreview->getTextureRegion() || UIManager::instance()->getDownControl() != mUIMap ) return; diff --git a/src/eepp/maps/tilemap.cpp b/src/eepp/maps/tilemap.cpp index bf9edd04c..fed319b81 100644 --- a/src/eepp/maps/tilemap.cpp +++ b/src/eepp/maps/tilemap.cpp @@ -1,7 +1,7 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -597,21 +597,21 @@ GameObjectPolyData& TileMap::getPolyObjData( Uint32 Id ) { GameObject * TileMap::createGameObject( const Uint32& Type, const Uint32& Flags, MapLayer * Layer, const Uint32& DataId ) { switch ( Type ) { - case GAMEOBJECT_TYPE_SUBTEXTURE: + case GAMEOBJECT_TYPE_TEXTUREREGION: { - GameObjectSubTexture * tSubTexture = eeNew( GameObjectSubTexture, ( Flags, Layer ) ); + GameObjectTextureRegion * tTextureRegion = eeNew( GameObjectTextureRegion, ( Flags, Layer ) ); - tSubTexture->setDataId( DataId ); + tTextureRegion->setDataId( DataId ); - return tSubTexture; + return tTextureRegion; } - case GAMEOBJECT_TYPE_SUBTEXTUREEX: + case GAMEOBJECT_TYPE_TEXTUREREGIONEX: { - GameObjectSubTextureEx * tSubTextureEx = eeNew( GameObjectSubTextureEx, ( Flags, Layer ) ); + GameObjectTextureRegionEx * tTextureRegionEx = eeNew( GameObjectTextureRegionEx, ( Flags, Layer ) ); - tSubTextureEx->setDataId( DataId ); + tTextureRegionEx->setDataId( DataId ); - return tSubTextureEx; + return tTextureRegionEx; } case GAMEOBJECT_TYPE_SPRITE: { @@ -651,10 +651,10 @@ GameObject * TileMap::createGameObject( const Uint32& Type, const Uint32& Flags, return mCreateGOCb( Type, Flags, Layer, DataId ); } else { GameObjectVirtual * tVirtual; - SubTexture * tIsSubTexture = TextureAtlasManager::instance()->getSubTextureById( DataId ); + TextureRegion * tIsTextureRegion = TextureAtlasManager::instance()->getTextureRegionById( DataId ); - if ( NULL != tIsSubTexture ) { - tVirtual = eeNew( GameObjectVirtual, ( tIsSubTexture, Layer, Flags, Type ) ); + if ( NULL != tIsTextureRegion ) { + tVirtual = eeNew( GameObjectVirtual, ( tIsTextureRegion, Layer, Flags, Type ) ); } else { tVirtual = eeNew( GameObjectVirtual, ( DataId, Layer, Flags, Type ) ); } @@ -1231,7 +1231,7 @@ void TileMap::saveToStream( IOStream& IOS ) { sMapTileGOHdr tTGOHdr; - //! The DataId should be the SubTexture hash name ( at least in the cases of type SubTexture, SubTextureEx and Sprite. + //! The DataId should be the TextureRegion hash name ( at least in the cases of type TextureRegion, TextureRegionEx and Sprite. tTGOHdr.Id = tObj->getDataId(); //! If the object type is virtual, means that the real type is stored elsewhere. @@ -1268,7 +1268,7 @@ void TileMap::saveToStream( IOStream& IOS ) { sMapObjGOHdr tOGOHdr; - //! The DataId should be the SubTexture hash name ( at least in the cases of type SubTexture, SubTextureEx and Sprite. + //! The DataId should be the TextureRegion hash name ( at least in the cases of type TextureRegion, TextureRegionEx and Sprite. //! And for the Poly Obj should be an arbitrary value assigned by the map on the moment of creation tOGOHdr.Id = tObj->getDataId(); diff --git a/src/eepp/ui/tools/textureatlaseditor.cpp b/src/eepp/ui/tools/textureatlaseditor.cpp index 705460760..34adb473e 100644 --- a/src/eepp/ui/tools/textureatlaseditor.cpp +++ b/src/eepp/ui/tools/textureatlaseditor.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -12,9 +12,9 @@ namespace EE { namespace UI { namespace Tools { -UIWidget * TextureAtlasEditor::createTextureAtlasSubTextureEditor( std::string name ) { - mSubTextureEditor = TextureAtlasSubTextureEditor::New( this ); - return mSubTextureEditor; +UIWidget * TextureAtlasEditor::createTextureAtlasTextureRegionEditor( std::string name ) { + mTextureRegionEditor = TextureAtlasTextureRegionEditor::New( this ); + return mTextureRegionEditor; } TextureAtlasEditor::TextureAtlasEditor( UIWindow * AttatchTo, const TGEditorCloseCb& callback ) : @@ -22,7 +22,7 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow * AttatchTo, const TGEditorClos mCloseCb( callback ), mTexturePacker( NULL ), mTextureAtlasLoader( NULL ), - mCurSubTexture( NULL ) + mCurTextureRegion( NULL ) { if ( NULL == UIThemeManager::instance()->getDefaultTheme() ) { eePRINTL( "TextureAtlasEditor needs a default theme assigned to work." ); @@ -57,12 +57,12 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow * AttatchTo, const TGEditorClos " " " " " " - " " " " - " " - " " - " " + " " + " " + " " " " " " @@ -91,14 +91,14 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow * AttatchTo, const TGEditorClos " " ""; - UIWidgetCreator::addCustomWidgetCallback( "TextureAtlasSubTextureEditor", cb::Make1( this, &TextureAtlasEditor::createTextureAtlasSubTextureEditor ) ); + UIWidgetCreator::addCustomWidgetCallback( "TextureAtlasTextureRegionEditor", cb::Make1( this, &TextureAtlasEditor::createTextureAtlasTextureRegionEditor ) ); UIManager::instance()->loadLayoutFromString( layout, mUIContainer ); - UIWidgetCreator::removeCustomWidgetCallback( "TextureAtlasSubTextureEditor" ); + UIWidgetCreator::removeCustomWidgetCallback( "TextureAtlasTextureRegionEditor" ); - mUIContainer->bind( "SubTextureList", mSubTextureList ); - mSubTextureList->addEventListener( UIEvent::OnItemSelected, cb::Make1( this, &TextureAtlasEditor::onSubTextureChange ) ); + mUIContainer->bind( "TextureRegionList", mTextureRegionList ); + mTextureRegionList->addEventListener( UIEvent::OnItemSelected, cb::Make1( this, &TextureAtlasEditor::onTextureRegionChange ) ); mUIContainer->bind( "offX", mSpinOffX ); mSpinOffX->addEventListener( UIEvent::OnValueChange, cb::Make1( this, &TextureAtlasEditor::onOffXChange ) ); @@ -140,10 +140,10 @@ TextureAtlasEditor::~TextureAtlasEditor() { void TextureAtlasEditor::onResetDestSize( const UIEvent * Event ) { const UIEventMouse * MouseEvent = reinterpret_cast ( Event ); - if ( NULL != mCurSubTexture && MouseEvent->getFlags() & EE_BUTTON_LMASK ) { - Sizef RealSize( mCurSubTexture->getRealSize().getWidth() * mCurSubTexture->getPixelDensity(), mCurSubTexture->getRealSize().getHeight() * mCurSubTexture->getPixelDensity() ); + if ( NULL != mCurTextureRegion && MouseEvent->getFlags() & EE_BUTTON_LMASK ) { + Sizef RealSize( mCurTextureRegion->getRealSize().getWidth() * mCurTextureRegion->getPixelDensity(), mCurTextureRegion->getRealSize().getHeight() * mCurTextureRegion->getPixelDensity() ); - mCurSubTexture->setOriDestSize( Sizef( RealSize.x, RealSize.y ) ); + mCurTextureRegion->setOriDestSize( Sizef( RealSize.x, RealSize.y ) ); mSpinDestW->setValue( RealSize.getWidth() ); mSpinDestH->setValue( RealSize.getHeight() ); @@ -153,7 +153,7 @@ void TextureAtlasEditor::onResetDestSize( const UIEvent * Event ) { void TextureAtlasEditor::onResetOffset( const UIEvent * Event ) { const UIEventMouse * MouseEvent = reinterpret_cast ( Event ); - if ( NULL != mCurSubTexture && MouseEvent->getFlags() & EE_BUTTON_LMASK ) { + if ( NULL != mCurTextureRegion && MouseEvent->getFlags() & EE_BUTTON_LMASK ) { mSpinOffX->setValue( 0 ); mSpinOffY->setValue( 0 ); } @@ -162,8 +162,8 @@ void TextureAtlasEditor::onResetOffset( const UIEvent * Event ) { void TextureAtlasEditor::onCenterOffset( const UIEvent * Event ) { const UIEventMouse * MouseEvent = reinterpret_cast ( Event ); - if ( NULL != mCurSubTexture && MouseEvent->getFlags() & EE_BUTTON_LMASK ) { - Sizei NSize( -( (Int32)mCurSubTexture->getDpSize().x / 2 ), -( (Int32)mCurSubTexture->getDpSize().y / 2 ) ); + if ( NULL != mCurTextureRegion && MouseEvent->getFlags() & EE_BUTTON_LMASK ) { + Sizei NSize( -( (Int32)mCurTextureRegion->getDpSize().x / 2 ), -( (Int32)mCurTextureRegion->getDpSize().y / 2 ) ); mSpinOffX->setValue( NSize.x ); mSpinOffY->setValue( NSize.y ); @@ -173,8 +173,8 @@ void TextureAtlasEditor::onCenterOffset( const UIEvent * Event ) { void TextureAtlasEditor::onHBOffset( const UIEvent * Event ) { const UIEventMouse * MouseEvent = reinterpret_cast ( Event ); - if ( NULL != mCurSubTexture && MouseEvent->getFlags() & EE_BUTTON_LMASK ) { - Sizei NSize( -( (Int32)mCurSubTexture->getDpSize().x / 2 ), -(Int32)mCurSubTexture->getDpSize().y ); + if ( NULL != mCurTextureRegion && MouseEvent->getFlags() & EE_BUTTON_LMASK ) { + Sizei NSize( -( (Int32)mCurTextureRegion->getDpSize().x / 2 ), -(Int32)mCurTextureRegion->getDpSize().y ); mSpinOffX->setValue( NSize.x ); mSpinOffY->setValue( NSize.y ); @@ -182,28 +182,28 @@ void TextureAtlasEditor::onHBOffset( const UIEvent * Event ) { } void TextureAtlasEditor::onOffXChange( const UIEvent * Event ) { - if ( NULL != mCurSubTexture ) { - mCurSubTexture->setOffset( Vector2i( (Int32)mSpinOffX->getValue(), mCurSubTexture->getOffset().y ) ); + if ( NULL != mCurTextureRegion ) { + mCurTextureRegion->setOffset( Vector2i( (Int32)mSpinOffX->getValue(), mCurTextureRegion->getOffset().y ) ); } } void TextureAtlasEditor::onOffYChange( const UIEvent * Event ) { - if ( NULL != mCurSubTexture ) { - mCurSubTexture->setOffset( Vector2i( mCurSubTexture->getOffset().x, (Int32)mSpinOffY->getValue() ) ); + if ( NULL != mCurTextureRegion ) { + mCurTextureRegion->setOffset( Vector2i( mCurTextureRegion->getOffset().x, (Int32)mSpinOffY->getValue() ) ); } } void TextureAtlasEditor::onDestWChange( const UIEvent * Event ) { - if ( NULL != mCurSubTexture ) { - mCurSubTexture->setOriDestSize( Sizef( (Int32)mSpinDestW->getValue(), mCurSubTexture->getDpSize().y ) ); - mSubTextureEditor->getGfx()->setSize( (Int32)mSpinDestW->getValue(), mSubTextureEditor->getGfx()->getSize().getHeight() ); + if ( NULL != mCurTextureRegion ) { + mCurTextureRegion->setOriDestSize( Sizef( (Int32)mSpinDestW->getValue(), mCurTextureRegion->getDpSize().y ) ); + mTextureRegionEditor->getGfx()->setSize( (Int32)mSpinDestW->getValue(), mTextureRegionEditor->getGfx()->getSize().getHeight() ); } } void TextureAtlasEditor::onDestHChange( const UIEvent * Event ) { - if ( NULL != mCurSubTexture ) { - mCurSubTexture->setOriDestSize( Sizef( mCurSubTexture->getDpSize().x, (Int32)mSpinDestH->getValue() ) ); - mSubTextureEditor->getGfx()->setSize( mSubTextureEditor->getGfx()->getSize().getWidth(), (Int32)mSpinDestH->getValue() ); + if ( NULL != mCurTextureRegion ) { + mCurTextureRegion->setOriDestSize( Sizef( mCurTextureRegion->getDpSize().x, (Int32)mSpinDestH->getValue() ) ); + mTextureRegionEditor->getGfx()->setSize( mTextureRegionEditor->getGfx()->getSize().getWidth(), (Int32)mSpinDestH->getValue() ); } } @@ -265,44 +265,44 @@ void TextureAtlasEditor::onTextureAtlasCreate( TexturePacker * TexPacker ) { void TextureAtlasEditor::updateControls() { if ( NULL != mTextureAtlasLoader && mTextureAtlasLoader->isLoaded() ) { - fillSubTextureList(); + fillTextureRegionList(); } } -void TextureAtlasEditor::fillSubTextureList() { +void TextureAtlasEditor::fillTextureRegionList() { if ( NULL == mTextureAtlasLoader || NULL == mTextureAtlasLoader->getTextureAtlas() || !mTextureAtlasLoader->isLoaded() ) return; - std::list& Res = mTextureAtlasLoader->getTextureAtlas()->getResources(); + std::list& Res = mTextureAtlasLoader->getTextureAtlas()->getResources(); - mSubTextureList->clear(); + mTextureRegionList->clear(); std::vector items; - for ( std::list::iterator it = Res.begin(); it != Res.end(); it++ ) { + for ( std::list::iterator it = Res.begin(); it != Res.end(); it++ ) { items.push_back( (*it)->getName() ); } if ( items.size() ) { std::sort( items.begin(), items.end() ); - mSubTextureList->addListBoxItems( items ); - mSubTextureList->setSelected( 0 ); + mTextureRegionList->addListBoxItems( items ); + mTextureRegionList->setSelected( 0 ); } - mSubTextureList->getVerticalScrollBar()->setClickStep( 8.f / (Float)mSubTextureList->getCount() ); + mTextureRegionList->getVerticalScrollBar()->setClickStep( 8.f / (Float)mTextureRegionList->getCount() ); } -void TextureAtlasEditor::onSubTextureChange( const UIEvent * Event ) { +void TextureAtlasEditor::onTextureRegionChange( const UIEvent * Event ) { if ( NULL != mTextureAtlasLoader && NULL != mTextureAtlasLoader->getTextureAtlas() ) { - mCurSubTexture = mTextureAtlasLoader->getTextureAtlas()->getByName( mSubTextureList->getItemSelectedText() ); + mCurTextureRegion = mTextureAtlasLoader->getTextureAtlas()->getByName( mTextureRegionList->getItemSelectedText() ); - if ( NULL != mCurSubTexture ) { - mSubTextureEditor->setSubTexture( mCurSubTexture ); - mSpinOffX->setValue( mCurSubTexture->getOffset().x ); - mSpinOffY->setValue( mCurSubTexture->getOffset().y ); - mSpinDestW->setValue( mCurSubTexture->getDpSize().x ); - mSpinDestH->setValue( mCurSubTexture->getDpSize().y ); + if ( NULL != mCurTextureRegion ) { + mTextureRegionEditor->setTextureRegion( mCurTextureRegion ); + mSpinOffX->setValue( mCurTextureRegion->getOffset().x ); + mSpinOffY->setValue( mCurTextureRegion->getOffset().y ); + mSpinDestW->setValue( mCurTextureRegion->getDpSize().x ); + mSpinDestH->setValue( mCurTextureRegion->getDpSize().y ); } } } @@ -339,13 +339,13 @@ void TextureAtlasEditor::saveTextureAtlas( const UIEvent * Event ) { void TextureAtlasEditor::onTextureAtlasClose( const UIEvent * Event ) { eeSAFE_DELETE( mTextureAtlasLoader ); - mSubTextureList->clear(); + mTextureRegionList->clear(); mSpinOffX->setValue( 0 ); mSpinOffY->setValue( 0 ); mSpinDestW->setValue( 0 ); mSpinDestH->setValue( 0 ); - mSubTextureEditor->setSubTexture( NULL ); - mCurSubTexture = NULL; + mTextureRegionEditor->setTextureRegion( NULL ); + mCurTextureRegion = NULL; } }}} diff --git a/src/eepp/ui/tools/textureatlassubtextureeditor.hpp b/src/eepp/ui/tools/textureatlassubtextureeditor.hpp deleted file mode 100644 index c9477b361..000000000 --- a/src/eepp/ui/tools/textureatlassubtextureeditor.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef EE_UITOOLSCTEXTUREATLASSUBTEXTUREEDITOR_HPP -#define EE_UITOOLSCTEXTUREATLASSUBTEXTUREEDITOR_HPP - -#include -#include -#include -#include - -namespace EE { namespace UI { namespace Tools { - -class TextureAtlasEditor; - -class EE_API TextureAtlasSubTextureEditor : public UIWidget { - public: - static TextureAtlasSubTextureEditor * New( TextureAtlasEditor * Editor ); - - TextureAtlasSubTextureEditor( TextureAtlasEditor * Editor ); - - virtual ~TextureAtlasSubTextureEditor(); - - virtual void draw(); - - virtual void update(); - - Graphics::SubTexture * getSubTexture() const; - - void setSubTexture( Graphics::SubTexture * subTexture ); - - UISubTexture * getGfx() const; - protected: - UITheme * mTheme; - UISubTexture * mGfx; - UINode * mDrag; - Vector2i mUICenter; - TextureAtlasEditor * mEditor; - - virtual void onSizeChange(); - - void getCenter(); -}; - -}}} - -#endif diff --git a/src/eepp/ui/tools/textureatlassubtextureeditor.cpp b/src/eepp/ui/tools/textureatlastextureregioneditor.cpp similarity index 50% rename from src/eepp/ui/tools/textureatlassubtextureeditor.cpp rename to src/eepp/ui/tools/textureatlastextureregioneditor.cpp index 503ceffeb..22cd87ce6 100644 --- a/src/eepp/ui/tools/textureatlassubtextureeditor.cpp +++ b/src/eepp/ui/tools/textureatlastextureregioneditor.cpp @@ -1,15 +1,15 @@ -#include +#include #include #include #include namespace EE { namespace UI { namespace Tools { -TextureAtlasSubTextureEditor * TextureAtlasSubTextureEditor::TextureAtlasSubTextureEditor::New( TextureAtlasEditor * Editor ) { - return eeNew( TextureAtlasSubTextureEditor, ( Editor ) ); +TextureAtlasTextureRegionEditor * TextureAtlasTextureRegionEditor::TextureAtlasTextureRegionEditor::New( TextureAtlasEditor * Editor ) { + return eeNew( TextureAtlasTextureRegionEditor, ( Editor ) ); } -TextureAtlasSubTextureEditor::TextureAtlasSubTextureEditor( TextureAtlasEditor * Editor ) : +TextureAtlasTextureRegionEditor::TextureAtlasTextureRegionEditor( TextureAtlasEditor * Editor ) : UIWidget(), mGfx( NULL ), mEditor( Editor ) @@ -20,7 +20,7 @@ TextureAtlasSubTextureEditor::TextureAtlasSubTextureEditor( TextureAtlasEditor * mTheme = UIThemeManager::instance()->getDefaultTheme(); - mGfx = UISubTexture::New(); + mGfx = UITextureRegion::New(); mGfx->setParent( this ); mGfx->setVisible( true ); mGfx->setEnabled( true ); @@ -36,10 +36,10 @@ TextureAtlasSubTextureEditor::TextureAtlasSubTextureEditor( TextureAtlasEditor * getCenter(); } -TextureAtlasSubTextureEditor::~TextureAtlasSubTextureEditor() { +TextureAtlasTextureRegionEditor::~TextureAtlasTextureRegionEditor() { } -void TextureAtlasSubTextureEditor::draw() { +void TextureAtlasTextureRegionEditor::draw() { Primitives P; P.setColor( Color( 255, 0, 0, mAlpha ) ); P.setLineWidth( PixelDensity::dpToPx( 1.f ) ); @@ -52,42 +52,42 @@ void TextureAtlasSubTextureEditor::draw() { UIWidget::draw(); } -void TextureAtlasSubTextureEditor::update() { +void TextureAtlasTextureRegionEditor::update() { Vector2i Pos = mDrag->getRealPosition(); UIWidget::update(); - if ( NULL != mGfx->getSubTexture() && mDrag->isDragEnabled() && mDrag->isDragging() && Pos != mDrag->getRealPosition() ) { + if ( NULL != mGfx->getTextureRegion() && mDrag->isDragEnabled() && mDrag->isDragging() && Pos != mDrag->getRealPosition() ) { Vector2i Diff = -( Pos - mDrag->getRealPosition() ); Diff = PixelDensity::pxToDpI( Diff ); - mGfx->getSubTexture()->setOffset( Vector2i( mGfx->getSubTexture()->getOffset().x + Diff.x, mGfx->getSubTexture()->getOffset().y + Diff.y ) ); + mGfx->getTextureRegion()->setOffset( Vector2i( mGfx->getTextureRegion()->getOffset().x + Diff.x, mGfx->getTextureRegion()->getOffset().y + Diff.y ) ); - mEditor->getSpinOffX()->setValue( mGfx->getSubTexture()->getOffset().x ); - mEditor->getSpinOffY()->setValue( mGfx->getSubTexture()->getOffset().y ); + mEditor->getSpinOffX()->setValue( mGfx->getTextureRegion()->getOffset().x ); + mEditor->getSpinOffY()->setValue( mGfx->getTextureRegion()->getOffset().y ); } mGfx->setPosition( mUICenter ); } -void TextureAtlasSubTextureEditor::onSizeChange() { +void TextureAtlasTextureRegionEditor::onSizeChange() { getCenter(); } -Graphics::SubTexture * TextureAtlasSubTextureEditor::getSubTexture() const { - return mGfx->getSubTexture(); +Graphics::TextureRegion * TextureAtlasTextureRegionEditor::getTextureRegion() const { + return mGfx->getTextureRegion(); } -void TextureAtlasSubTextureEditor::setSubTexture( Graphics::SubTexture * subTexture ) { - mGfx->setSubTexture( subTexture ); +void TextureAtlasTextureRegionEditor::setTextureRegion( Graphics::TextureRegion * TextureRegion ) { + mGfx->setTextureRegion( TextureRegion ); } -UISubTexture * TextureAtlasSubTextureEditor::getGfx() const { +UITextureRegion * TextureAtlasTextureRegionEditor::getGfx() const { return mGfx; } -void TextureAtlasSubTextureEditor::getCenter() { +void TextureAtlasTextureRegionEditor::getCenter() { mUICenter = Vector2i( mSize.getWidth() / 2, mSize.getHeight() / 2 ); } diff --git a/src/eepp/ui/tools/textureatlastextureregioneditor.hpp b/src/eepp/ui/tools/textureatlastextureregioneditor.hpp new file mode 100644 index 000000000..4f54e7f03 --- /dev/null +++ b/src/eepp/ui/tools/textureatlastextureregioneditor.hpp @@ -0,0 +1,44 @@ +#ifndef EE_UITOOLSCTEXTUREATLASTEXTUREREGIONEDITOR_HPP +#define EE_UITOOLSCTEXTUREATLASTEXTUREREGIONEDITOR_HPP + +#include +#include +#include +#include + +namespace EE { namespace UI { namespace Tools { + +class TextureAtlasEditor; + +class EE_API TextureAtlasTextureRegionEditor : public UIWidget { + public: + static TextureAtlasTextureRegionEditor * New( TextureAtlasEditor * Editor ); + + TextureAtlasTextureRegionEditor( TextureAtlasEditor * Editor ); + + virtual ~TextureAtlasTextureRegionEditor(); + + virtual void draw(); + + virtual void update(); + + Graphics::TextureRegion * getTextureRegion() const; + + void setTextureRegion( Graphics::TextureRegion * TextureRegion ); + + UITextureRegion * getGfx() const; + protected: + UITheme * mTheme; + UITextureRegion * mGfx; + UINode * mDrag; + Vector2i mUICenter; + TextureAtlasEditor * mEditor; + + virtual void onSizeChange(); + + void getCenter(); +}; + +}}} + +#endif diff --git a/src/eepp/ui/uicheckbox.cpp b/src/eepp/ui/uicheckbox.cpp index f0009fa10..94080ae62 100644 --- a/src/eepp/ui/uicheckbox.cpp +++ b/src/eepp/ui/uicheckbox.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/src/eepp/ui/uicombobox.cpp b/src/eepp/ui/uicombobox.cpp index d1b6ebae9..42e76be1e 100644 --- a/src/eepp/ui/uicombobox.cpp +++ b/src/eepp/ui/uicombobox.cpp @@ -1,5 +1,5 @@ #include -#include +#include namespace EE { namespace UI { diff --git a/src/eepp/ui/uimenuseparator.cpp b/src/eepp/ui/uimenuseparator.cpp index 39059eeb1..1519026fb 100644 --- a/src/eepp/ui/uimenuseparator.cpp +++ b/src/eepp/ui/uimenuseparator.cpp @@ -1,5 +1,5 @@ #include -#include +#include namespace EE { namespace UI { diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 20af1efa4..59d4b2f62 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/eepp/ui/uiradiobutton.cpp b/src/eepp/ui/uiradiobutton.cpp index ab84f52a5..fd41b6fb4 100644 --- a/src/eepp/ui/uiradiobutton.cpp +++ b/src/eepp/ui/uiradiobutton.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/src/eepp/ui/uiscrollbar.cpp b/src/eepp/ui/uiscrollbar.cpp index 6dc144e41..63592f50b 100644 --- a/src/eepp/ui/uiscrollbar.cpp +++ b/src/eepp/ui/uiscrollbar.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include namespace EE { namespace UI { diff --git a/src/eepp/ui/uiskin.cpp b/src/eepp/ui/uiskin.cpp index 70ffbe1d6..865b8712f 100644 --- a/src/eepp/ui/uiskin.cpp +++ b/src/eepp/ui/uiskin.cpp @@ -1,5 +1,5 @@ #include -#include +#include namespace EE { namespace UI { diff --git a/src/eepp/ui/uiskinsimple.cpp b/src/eepp/ui/uiskinsimple.cpp index bbd1e6870..0c47394d4 100644 --- a/src/eepp/ui/uiskinsimple.cpp +++ b/src/eepp/ui/uiskinsimple.cpp @@ -86,10 +86,10 @@ Sizei UISkinSimple::getSize( const Uint32 & state ) { Rect UISkinSimple::getBorderSize( const Uint32 & state ) { if ( NULL != mDrawable[ state ] && mDrawable[ state ]->getDrawableType() == Drawable::NINEPATCH ) { NinePatch * ninePatch( static_cast( mDrawable[ state ] ) ); - SubTexture * stl( ninePatch->getSubTexture( NinePatch::Left ) ); - SubTexture * str( ninePatch->getSubTexture( NinePatch::Right ) ); - SubTexture * stt( ninePatch->getSubTexture( NinePatch::Up ) ); - SubTexture * stb( ninePatch->getSubTexture( NinePatch::Down ) ); + TextureRegion * stl( ninePatch->getTextureRegion( NinePatch::Left ) ); + TextureRegion * str( ninePatch->getTextureRegion( NinePatch::Right ) ); + TextureRegion * stt( ninePatch->getTextureRegion( NinePatch::Up ) ); + TextureRegion * stb( ninePatch->getTextureRegion( NinePatch::Down ) ); Rect size( stl->getSize().getWidth(), stt->getSize().getHeight(), str->getSize().getWidth(), stb->getSize().getHeight() ); return size; } diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp index d1f68c931..825eedb28 100644 --- a/src/eepp/ui/uislider.cpp +++ b/src/eepp/ui/uislider.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include namespace EE { namespace UI { diff --git a/src/eepp/ui/uispinbox.cpp b/src/eepp/ui/uispinbox.cpp index a6e392b48..934df2bb7 100644 --- a/src/eepp/ui/uispinbox.cpp +++ b/src/eepp/ui/uispinbox.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include namespace EE { namespace UI { diff --git a/src/eepp/ui/uisprite.cpp b/src/eepp/ui/uisprite.cpp index d1c90b542..44c04f807 100644 --- a/src/eepp/ui/uisprite.cpp +++ b/src/eepp/ui/uisprite.cpp @@ -14,7 +14,7 @@ UISprite::UISprite() : mSprite( NULL ), mRender( RENDER_NORMAL ), mAlignOffset(0,0), - mSubTextureLast(NULL) + mTextureRegionLast(NULL) { } @@ -50,21 +50,21 @@ void UISprite::draw() { if ( mVisible ) { if ( NULL != mSprite && 0.f != mAlpha ) { - checkSubTextureUpdate(); + checkTextureRegionUpdate(); mSprite->setPosition( Vector2f( (Float)( mScreenPos.x + mAlignOffset.x ), (Float)( mScreenPos.y + mAlignOffset.y ) ) ); - SubTexture * subTexture = mSprite->getCurrentSubTexture(); + TextureRegion * textureRegion = mSprite->getCurrentTextureRegion(); - if ( NULL != subTexture ) { - Sizef oDestSize = subTexture->getDestSize(); - Sizei pxSize = subTexture->getPxSize(); + if ( NULL != textureRegion ) { + Sizef oDestSize = textureRegion->getDestSize(); + Sizei pxSize = textureRegion->getPxSize(); - subTexture->setDestSize( Sizef( (Float)pxSize.x, (Float)pxSize.y ) ); + textureRegion->setDestSize( Sizef( (Float)pxSize.x, (Float)pxSize.y ) ); mSprite->draw( getBlendMode(), mRender ); - subTexture->setDestSize( oDestSize ); + textureRegion->setDestSize( oDestSize ); } } } @@ -74,20 +74,20 @@ void UISprite::update() { UIWidget::update(); if ( NULL != mSprite ) { - SubTexture * subTexture = mSprite->getCurrentSubTexture(); + TextureRegion * textureRegion = mSprite->getCurrentTextureRegion(); mSprite->update(); - if ( subTexture != mSprite->getCurrentSubTexture() ) + if ( textureRegion != mSprite->getCurrentTextureRegion() ) invalidateDraw(); } } -void UISprite::checkSubTextureUpdate() { - if ( NULL != mSprite && NULL != mSprite->getCurrentSubTexture() && mSprite->getCurrentSubTexture() != mSubTextureLast ) { +void UISprite::checkTextureRegionUpdate() { + if ( NULL != mSprite && NULL != mSprite->getCurrentTextureRegion() && mSprite->getCurrentTextureRegion() != mTextureRegionLast ) { updateSize(); autoAlign(); - mSubTextureLast = mSprite->getCurrentSubTexture(); + mTextureRegionLast = mSprite->getCurrentTextureRegion(); } } @@ -128,30 +128,30 @@ void UISprite::setRenderMode( const RenderMode& render ) { void UISprite::updateSize() { if ( mFlags & UI_AUTO_SIZE ) { if ( NULL != mSprite ) { - if ( NULL != mSprite->getCurrentSubTexture() && mSprite->getCurrentSubTexture()->getDpSize() != mSize ) - setSize( mSprite->getCurrentSubTexture()->getDpSize() ); + if ( NULL != mSprite->getCurrentTextureRegion() && mSprite->getCurrentTextureRegion()->getDpSize() != mSize ) + setSize( mSprite->getCurrentTextureRegion()->getDpSize() ); } } } void UISprite::autoAlign() { - if ( NULL == mSprite || NULL == mSprite->getCurrentSubTexture() ) + if ( NULL == mSprite || NULL == mSprite->getCurrentTextureRegion() ) return; - SubTexture * tSubTexture = mSprite->getCurrentSubTexture(); + TextureRegion * tTextureRegion = mSprite->getCurrentTextureRegion(); if ( HAlignGet( mFlags ) == UI_HALIGN_CENTER ) { - mAlignOffset.x = mSize.getWidth() / 2 - tSubTexture->getDpSize().getWidth() / 2; + mAlignOffset.x = mSize.getWidth() / 2 - tTextureRegion->getDpSize().getWidth() / 2; } else if ( fontHAlignGet( mFlags ) == UI_HALIGN_RIGHT ) { - mAlignOffset.x = mSize.getWidth() - tSubTexture->getDpSize().getWidth(); + mAlignOffset.x = mSize.getWidth() - tTextureRegion->getDpSize().getWidth(); } else { mAlignOffset.x = 0; } if ( VAlignGet( mFlags ) == UI_VALIGN_CENTER ) { - mAlignOffset.y = mSize.getHeight() / 2 - tSubTexture->getDpSize().getHeight() / 2; + mAlignOffset.y = mSize.getHeight() / 2 - tTextureRegion->getDpSize().getHeight() / 2; } else if ( fontVAlignGet( mFlags ) == UI_VALIGN_BOTTOM ) { - mAlignOffset.y = mSize.getHeight() - tSubTexture->getDpSize().getHeight(); + mAlignOffset.y = mSize.getHeight() - tTextureRegion->getDpSize().getHeight(); } else { mAlignOffset.y = 0; } diff --git a/src/eepp/ui/uisubtexture.cpp b/src/eepp/ui/uisubtexture.cpp deleted file mode 100644 index fe23f8d5d..000000000 --- a/src/eepp/ui/uisubtexture.cpp +++ /dev/null @@ -1,227 +0,0 @@ -#include -#include -#include -#include - -namespace EE { namespace UI { - -UISubTexture * UISubTexture::New() { - return eeNew( UISubTexture, () ); -} - -UISubTexture::UISubTexture() : - UIWidget(), - mSubTexture( NULL ), - mColor(), - mRender( RENDER_NORMAL ), - mAlignOffset(0,0) -{ - mFlags |= UI_AUTO_SIZE; - - onAutoSize(); -} - -UISubTexture::~UISubTexture() { -} - -Uint32 UISubTexture::getType() const { - return UI_TYPE_SUBTEXTURE; -} - -bool UISubTexture::isType( const Uint32& type ) const { - return UISubTexture::getType() == type ? true : UIWidget::isType( type ); -} - -UISubTexture * UISubTexture::setSubTexture( Graphics::SubTexture * subTexture ) { - mSubTexture = subTexture; - - onAutoSize(); - - if ( NULL != mSubTexture && mSize.x == 0 && mSize.y == 0 ) { - setSize( mSubTexture->getDpSize() ); - } - - autoAlign(); - - notifyLayoutAttrChange(); - - invalidateDraw(); - - return this; -} - -void UISubTexture::onAutoSize() { - if ( ( mFlags & UI_AUTO_SIZE ) && Sizei::Zero == mSize ) { - if ( NULL != mSubTexture ) { - setSize( mSubTexture->getDpSize() ); - } - } -} - -void UISubTexture::draw() { - UINode::draw(); - - if ( mVisible ) { - if ( NULL != mSubTexture && 0.f != mAlpha ) { - Sizef oDestSize = mSubTexture->getDestSize(); - Vector2i oOff = mSubTexture->getOffset(); - - if ( mScaleType == UIScaleType::Expand ) { - mSubTexture->setOffset( Vector2i( 0, 0 ) ); - mSubTexture->setDestSize( Vector2f( mRealSize.x, mRealSize.y ) ); - - autoAlign(); - - drawSubTexture(); - - } else if ( mScaleType == UIScaleType::FitInside ) { - mSubTexture->setOffset( Vector2i( 0, 0 ) ); - - Sizei pxSize = mSubTexture->getPxSize(); - Float Scale1 = mRealSize.x / (Float)pxSize.x; - Float Scale2 = mRealSize.y / (Float)pxSize.y; - - if ( Scale1 < 1 || Scale2 < 1 ) { - if ( Scale2 < Scale1 ) - Scale1 = Scale2; - - mSubTexture->setDestSize( Sizef( pxSize.x * Scale1, pxSize.y * Scale1 ) ); - - autoAlign(); - - drawSubTexture(); - } else { - mSubTexture->setDestSize( Vector2f( (Float)pxSize.x, (Float)pxSize.y ) ); - - autoAlign(); - - drawSubTexture(); - } - } else { - mSubTexture->setOffset( Vector2i( (Int32)( (Float)oOff.x / mSubTexture->getPixelDensity() * PixelDensity::getPixelDensity() ), - (Int32)( (Float)oOff.y / mSubTexture->getPixelDensity() * PixelDensity::getPixelDensity() ) - ) ); - - mSubTexture->setDestSize( Vector2f( (Float)mSubTexture->getPxSize().x, (Float)mSubTexture->getPxSize().y ) ); - - autoAlign(); - - drawSubTexture(); - } - - mSubTexture->setDestSize( oDestSize ); - mSubTexture->setOffset( oOff ); - } - } -} - -void UISubTexture::drawSubTexture() { - mSubTexture->draw( (Float)mScreenPos.x + mAlignOffset.x, (Float)mScreenPos.y + mAlignOffset.y, mColor, 0.f, Vector2f::One, getBlendMode(), mRender ); -} - -void UISubTexture::setAlpha( const Float& alpha ) { - UIWidget::setAlpha( alpha ); - mColor.a = (Uint8)alpha; -} - -Graphics::SubTexture * UISubTexture::getSubTexture() const { - return mSubTexture; -} - -const Color& UISubTexture::getColor() const { - return mColor; -} - -void UISubTexture::setColor( const Color& col ) { - mColor = col; - setAlpha( col.a ); -} - -const RenderMode& UISubTexture::getRenderMode() const { - return mRender; -} - -void UISubTexture::setRenderMode( const RenderMode& render ) { - mRender = render; - invalidateDraw(); -} - -void UISubTexture::autoAlign() { - if ( NULL == mSubTexture ) - return; - - if ( HAlignGet( mFlags ) == UI_HALIGN_CENTER ) { - mAlignOffset.x = mRealSize.getWidth() / 2 - mSubTexture->getDestSize().x / 2; - } else if ( fontHAlignGet( mFlags ) == UI_HALIGN_RIGHT ) { - mAlignOffset.x = mRealSize.getWidth() - mSubTexture->getDestSize().x; - } else { - mAlignOffset.x = 0; - } - - if ( VAlignGet( mFlags ) == UI_VALIGN_CENTER ) { - mAlignOffset.y = mRealSize.getHeight() / 2 - mSubTexture->getDestSize().y / 2; - } else if ( fontVAlignGet( mFlags ) == UI_VALIGN_BOTTOM ) { - mAlignOffset.y = mRealSize.getHeight() - mSubTexture->getDestSize().y; - } else { - mAlignOffset.y = 0; - } -} - -void UISubTexture::onSizeChange() { - onAutoSize(); - autoAlign(); - UIWidget::onSizeChange(); -} - -void UISubTexture::onAlignChange() { - onAutoSize(); - autoAlign(); -} - -const Vector2i& UISubTexture::getAlignOffset() const { - return mAlignOffset; -} - -void UISubTexture::loadFromXmlNode(const pugi::xml_node & node) { - beginPropertiesTransaction(); - - UIWidget::loadFromXmlNode( node ); - - for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) { - std::string name = ait->name(); - String::toLowerInPlace( name ); - - if ( "src" == name || "subtexture" == name ) { - DrawableResource * res = NULL; - - if ( NULL != ( res = GlobalTextureAtlas::instance()->getByName( ait->as_string() ) ) && res->getDrawableType() == Drawable::SUBTEXTURE ) { - setSubTexture( static_cast( res ) ); - } - } else if ( "scaletype" == name ) { - std::string val = ait->as_string(); - String::toLowerInPlace( val ); - - if ( "expand" == val ) { - setScaleType( UIScaleType::Expand ); - } else if ( "fit_inside" == val || "fitinside" == val ) { - setScaleType( UIScaleType::FitInside ); - } else if ( "none" == val ) { - setScaleType( UIScaleType::None ); - } - } - } - - endPropertiesTransaction(); -} - -Uint32 UISubTexture::getScaleType() const { - return mScaleType; -} - -UISubTexture * UISubTexture::setScaleType(const Uint32& scaleType) { - mScaleType = scaleType; - invalidateDraw(); - return this; -} - -}} diff --git a/src/eepp/ui/uitextureregion.cpp b/src/eepp/ui/uitextureregion.cpp new file mode 100644 index 000000000..348cf3321 --- /dev/null +++ b/src/eepp/ui/uitextureregion.cpp @@ -0,0 +1,227 @@ +#include +#include +#include +#include + +namespace EE { namespace UI { + +UITextureRegion * UITextureRegion::New() { + return eeNew( UITextureRegion, () ); +} + +UITextureRegion::UITextureRegion() : + UIWidget(), + mTextureRegion( NULL ), + mColor(), + mRender( RENDER_NORMAL ), + mAlignOffset(0,0) +{ + mFlags |= UI_AUTO_SIZE; + + onAutoSize(); +} + +UITextureRegion::~UITextureRegion() { +} + +Uint32 UITextureRegion::getType() const { + return UI_TYPE_TEXTUREREGION; +} + +bool UITextureRegion::isType( const Uint32& type ) const { + return UITextureRegion::getType() == type ? true : UIWidget::isType( type ); +} + +UITextureRegion * UITextureRegion::setTextureRegion( Graphics::TextureRegion * TextureRegion ) { + mTextureRegion = TextureRegion; + + onAutoSize(); + + if ( NULL != mTextureRegion && mSize.x == 0 && mSize.y == 0 ) { + setSize( mTextureRegion->getDpSize() ); + } + + autoAlign(); + + notifyLayoutAttrChange(); + + invalidateDraw(); + + return this; +} + +void UITextureRegion::onAutoSize() { + if ( ( mFlags & UI_AUTO_SIZE ) && Sizei::Zero == mSize ) { + if ( NULL != mTextureRegion ) { + setSize( mTextureRegion->getDpSize() ); + } + } +} + +void UITextureRegion::draw() { + UINode::draw(); + + if ( mVisible ) { + if ( NULL != mTextureRegion && 0.f != mAlpha ) { + Sizef oDestSize = mTextureRegion->getDestSize(); + Vector2i oOff = mTextureRegion->getOffset(); + + if ( mScaleType == UIScaleType::Expand ) { + mTextureRegion->setOffset( Vector2i( 0, 0 ) ); + mTextureRegion->setDestSize( Vector2f( mRealSize.x, mRealSize.y ) ); + + autoAlign(); + + drawTextureRegion(); + + } else if ( mScaleType == UIScaleType::FitInside ) { + mTextureRegion->setOffset( Vector2i( 0, 0 ) ); + + Sizei pxSize = mTextureRegion->getPxSize(); + Float Scale1 = mRealSize.x / (Float)pxSize.x; + Float Scale2 = mRealSize.y / (Float)pxSize.y; + + if ( Scale1 < 1 || Scale2 < 1 ) { + if ( Scale2 < Scale1 ) + Scale1 = Scale2; + + mTextureRegion->setDestSize( Sizef( pxSize.x * Scale1, pxSize.y * Scale1 ) ); + + autoAlign(); + + drawTextureRegion(); + } else { + mTextureRegion->setDestSize( Vector2f( (Float)pxSize.x, (Float)pxSize.y ) ); + + autoAlign(); + + drawTextureRegion(); + } + } else { + mTextureRegion->setOffset( Vector2i( (Int32)( (Float)oOff.x / mTextureRegion->getPixelDensity() * PixelDensity::getPixelDensity() ), + (Int32)( (Float)oOff.y / mTextureRegion->getPixelDensity() * PixelDensity::getPixelDensity() ) + ) ); + + mTextureRegion->setDestSize( Vector2f( (Float)mTextureRegion->getPxSize().x, (Float)mTextureRegion->getPxSize().y ) ); + + autoAlign(); + + drawTextureRegion(); + } + + mTextureRegion->setDestSize( oDestSize ); + mTextureRegion->setOffset( oOff ); + } + } +} + +void UITextureRegion::drawTextureRegion() { + mTextureRegion->draw( (Float)mScreenPos.x + mAlignOffset.x, (Float)mScreenPos.y + mAlignOffset.y, mColor, 0.f, Vector2f::One, getBlendMode(), mRender ); +} + +void UITextureRegion::setAlpha( const Float& alpha ) { + UIWidget::setAlpha( alpha ); + mColor.a = (Uint8)alpha; +} + +Graphics::TextureRegion * UITextureRegion::getTextureRegion() const { + return mTextureRegion; +} + +const Color& UITextureRegion::getColor() const { + return mColor; +} + +void UITextureRegion::setColor( const Color& col ) { + mColor = col; + setAlpha( col.a ); +} + +const RenderMode& UITextureRegion::getRenderMode() const { + return mRender; +} + +void UITextureRegion::setRenderMode( const RenderMode& render ) { + mRender = render; + invalidateDraw(); +} + +void UITextureRegion::autoAlign() { + if ( NULL == mTextureRegion ) + return; + + if ( HAlignGet( mFlags ) == UI_HALIGN_CENTER ) { + mAlignOffset.x = mRealSize.getWidth() / 2 - mTextureRegion->getDestSize().x / 2; + } else if ( fontHAlignGet( mFlags ) == UI_HALIGN_RIGHT ) { + mAlignOffset.x = mRealSize.getWidth() - mTextureRegion->getDestSize().x; + } else { + mAlignOffset.x = 0; + } + + if ( VAlignGet( mFlags ) == UI_VALIGN_CENTER ) { + mAlignOffset.y = mRealSize.getHeight() / 2 - mTextureRegion->getDestSize().y / 2; + } else if ( fontVAlignGet( mFlags ) == UI_VALIGN_BOTTOM ) { + mAlignOffset.y = mRealSize.getHeight() - mTextureRegion->getDestSize().y; + } else { + mAlignOffset.y = 0; + } +} + +void UITextureRegion::onSizeChange() { + onAutoSize(); + autoAlign(); + UIWidget::onSizeChange(); +} + +void UITextureRegion::onAlignChange() { + onAutoSize(); + autoAlign(); +} + +const Vector2i& UITextureRegion::getAlignOffset() const { + return mAlignOffset; +} + +void UITextureRegion::loadFromXmlNode(const pugi::xml_node & node) { + beginPropertiesTransaction(); + + UIWidget::loadFromXmlNode( node ); + + for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) { + std::string name = ait->name(); + String::toLowerInPlace( name ); + + if ( "src" == name || "textureregion" == name || "subtexture" == name ) { + DrawableResource * res = NULL; + + if ( NULL != ( res = GlobalTextureAtlas::instance()->getByName( ait->as_string() ) ) && res->getDrawableType() == Drawable::TEXTUREREGION ) { + setTextureRegion( static_cast( res ) ); + } + } else if ( "scaletype" == name ) { + std::string val = ait->as_string(); + String::toLowerInPlace( val ); + + if ( "expand" == val ) { + setScaleType( UIScaleType::Expand ); + } else if ( "fit_inside" == val || "fitinside" == val ) { + setScaleType( UIScaleType::FitInside ); + } else if ( "none" == val ) { + setScaleType( UIScaleType::None ); + } + } + } + + endPropertiesTransaction(); +} + +Uint32 UITextureRegion::getScaleType() const { + return mScaleType; +} + +UITextureRegion * UITextureRegion::setScaleType(const Uint32& scaleType) { + mScaleType = scaleType; + invalidateDraw(); + return this; +} + +}} diff --git a/src/eepp/ui/uitheme.cpp b/src/eepp/ui/uitheme.cpp index 0d8957d20..194892acb 100644 --- a/src/eepp/ui/uitheme.cpp +++ b/src/eepp/ui/uitheme.cpp @@ -60,15 +60,15 @@ UITheme * UITheme::loadFromTextureAtlas( UITheme * tTheme, Graphics::TextureAtla tTheme->setTextureAtlas( TextureAtlas ); - std::list& resources = TextureAtlas->getResources(); - std::list::iterator it; + std::list& resources = TextureAtlas->getResources(); + std::list::iterator it; std::string sAbbr( tTheme->getAbbr() + "_" ); std::map elemFound; for ( it = resources.begin(); it != resources.end(); it++ ) { - SubTexture* subTexture = *it; + TextureRegion* TextureRegion = *it; - std::string name( subTexture->getName() ); + std::string name( TextureRegion->getName() ); if ( String::startsWith( name, sAbbr ) ) { std::vector dotParts = String::split( name, '.' ); @@ -98,7 +98,7 @@ UITheme * UITheme::loadFromTextureAtlas( UITheme * tTheme, Graphics::TextureAtla elemFound[ elemNameFromSkinSimple( nameParts ) ] = false; - NinePatchManager::instance()->add( eeNew( NinePatch, ( subTexture, l, t, r, b, realName ) ) ); + NinePatchManager::instance()->add( eeNew( NinePatch, ( TextureRegion, l, t, r, b, realName ) ) ); } else { std::vector nameParts = String::split( name, '_' ); @@ -154,7 +154,7 @@ UITheme * UITheme::loadFromDirectroy( UITheme * tTheme, const std::string& Path if ( !FileSystem::isDirectory( fpath ) ) { if ( String::startsWith( name, sAbbrIcon ) ) { - tSG->add( eeNew( SubTexture, ( TextureFactory::instance()->loadFromFile( fpath ), name ) ) ); + tSG->add( eeNew( TextureRegion, ( TextureFactory::instance()->loadFromFile( fpath ), name ) ) ); } else if ( String::startsWith( name, sAbbr ) ) { std::vector dotParts = String::split( name, '.' ); @@ -194,11 +194,11 @@ UITheme * UITheme::loadFromDirectroy( UITheme * tTheme, const std::string& Path if ( UISkin::isStateName( nameParts[ lPart ] ) ) { elemFound[ elemNameFromSkinSimple( nameParts ) ] = false; - tSG->add( eeNew( SubTexture, ( TextureFactory::instance()->loadFromFile( fpath ), name ) ) ); + tSG->add( eeNew( TextureRegion, ( TextureFactory::instance()->loadFromFile( fpath ), name ) ) ); } else if ( UISkin::isStateName( nameParts[ llPart ] ) && UISkinComplex::isSideSuffix( nameParts[ lPart ] ) ) { elemFound[ elemNameFromSkinComplex( nameParts ) ] = true; - tSG->add( eeNew( SubTexture, ( TextureFactory::instance()->loadFromFile( fpath ), name ) ) ); + tSG->add( eeNew( TextureRegion, ( TextureFactory::instance()->loadFromFile( fpath ), name ) ) ); } } } diff --git a/src/eepp/ui/uiwidgetcreator.cpp b/src/eepp/ui/uiwidgetcreator.cpp index 216519670..57520c88c 100644 --- a/src/eepp/ui/uiwidgetcreator.cpp +++ b/src/eepp/ui/uiwidgetcreator.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -68,7 +68,7 @@ UIWidget * UIWidgetCreator::createFromName( std::string widgetName ) { else if ( widgetName == "selectbutton" ) return UISelectButton::New(); else if ( widgetName == "window" ) return UIWindow::New(); else if ( widgetName == "scrollview" ) return UIScrollView::New(); - else if ( widgetName == "subtexture" ) return UISubTexture::New(); + else if ( widgetName == "textureregion" ) return UITextureRegion::New(); else if ( widgetName == "touchdragable" ) return UITouchDragableWidget::New(); else if ( widgetName == "gridlayout" ) return UIGridLayout::New(); diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 5cf822ffc..1381fa252 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -272,8 +272,8 @@ void UIWindow::drawFrameBuffer() { if ( mFrameBuffer->hasColorBuffer() ) { mFrameBuffer->draw( Rect( 0, 0, mRealSize.getWidth(), mRealSize.getHeight() ), Rect( mScreenPos.x, mScreenPos.y, mScreenPos.x + mRealSize.getWidth(), mScreenPos.y + mRealSize.getHeight() ) ); } else { - SubTexture subTexture( mFrameBuffer->getTexture()->getId(), Rect( 0, 0, mRealSize.getWidth(), mRealSize.getHeight() ) ); - subTexture.draw( mScreenPosf.x, mScreenPosf.y, Color::White, mAngle, mScale ); + TextureRegion textureRegion( mFrameBuffer->getTexture()->getId(), Rect( 0, 0, mRealSize.getWidth(), mRealSize.getHeight() ) ); + textureRegion.draw( mScreenPosf.x, mScreenPosf.y, Color::White, mAngle, mScale ); } } } diff --git a/src/eepp/ui/uiwinmenu.cpp b/src/eepp/ui/uiwinmenu.cpp index 84e3467ff..a0d9a8850 100644 --- a/src/eepp/ui/uiwinmenu.cpp +++ b/src/eepp/ui/uiwinmenu.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include namespace EE { namespace UI { diff --git a/src/eepp/window/window.cpp b/src/eepp/window/window.cpp index 290915de7..7bfcd22f6 100644 --- a/src/eepp/window/window.cpp +++ b/src/eepp/window/window.cpp @@ -160,10 +160,10 @@ Rect Window::getViewport( const View& view ) { static_cast(0.5f + height * viewport.Bottom)); } -void Window::setView( const View& view ) { +void Window::setView( const View& view , bool forceRefresh ) { const View * viewPtr = &view; - if ( viewPtr != mCurrentView ) { + if ( viewPtr != mCurrentView || forceRefresh ) { mCurrentView = viewPtr; Rect viewport = getViewport( *mCurrentView ); @@ -203,7 +203,7 @@ void Window::setup2D( const bool& KeepView ) { } if ( !KeepView ) { - setView( mDefaultView ); + setView( mDefaultView, true ); } BlendMode::setMode( BlendAlpha, true ); diff --git a/src/examples/sprites/sprites.cpp b/src/examples/sprites/sprites.cpp index 591bdf894..6381b0e32 100644 --- a/src/examples/sprites/sprites.cpp +++ b/src/examples/sprites/sprites.cpp @@ -102,14 +102,14 @@ EE_MAIN_FUNC int main (int argc, char * argv []) Uint32 PlanetId = TextureFactory::instance()->loadFromFile( "assets/sprites/7.png" ); Uint32 RockId = TextureFactory::instance()->loadFromFile( "assets/sprites/5.png" ); - // Load a previously generated texture atlas that contains the SubTextures needed to load an animated sprite + // Load a previously generated texture atlas that contains the TextureRegions needed to load an animated sprite TextureAtlasLoader Blindies( "assets/atlases/bnb.eta" ); // Create the animated rock spriteR // Load the rock frames from the texture, adding the frames manually for ( Int32 my = 0; my < 4; my++ ) { for( Int32 mx = 0; mx < 8; mx++ ) { - // DestSize as 0,0 will use the SubTexture size + // DestSize as 0,0 will use the TextureRegion size Rock.addFrame( RockId, Sizef( 0, 0 ), Vector2i( 0, 0 ), Rect( mx * 64, my * 64, mx * 64 + 64, my * 64 + 64 ) ); } } @@ -117,9 +117,9 @@ EE_MAIN_FUNC int main (int argc, char * argv []) // Create a static sprite Planet.createStatic( PlanetId ); - // It will look for a SubTexture ( in any Texture Atlas loaded, or the GlobalTextureAtlas ) animation by its name, it will search + // It will look for a TextureRegion ( in any Texture Atlas loaded, or the GlobalTextureAtlas ) animation by its name, it will search // for "gn00" to "gnXX" to create a new animation - // see TextureAtlasManager::GetSubTexturesByPattern for more information. + // see TextureAtlasManager::GetTextureRegionsByPattern for more information. // This is the easiest way to load animated sprites. Blindy.addFramesByPattern( "gn" ); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index eb4829d0a..8860dfd2f 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -46,7 +46,7 @@ class UIBlurredWindow : public UIWindow { mFboBlur->resize( mRealSize.x / fboDiv, mRealSize.y / fboDiv ); } - SubTexture subTexture( curFBO->getTexture()->getId(), + TextureRegion textureRegion( curFBO->getTexture()->getId(), Rect( mScreenPos.x, mScreenPos.y, mScreenPos.x + mRealSize.x, mScreenPos.y + mRealSize.y ) ); @@ -55,7 +55,7 @@ class UIBlurredWindow : public UIWindow { mFboBlur->setClearColor( ColorAf( cc.r / 255.f, cc.g / 255.f, cc.b / 255.f, 0 ) ); mFboBlur->bind(); mFboBlur->clear(); - subTexture.draw(Vector2f(0,0),mFboBlur->getSizef()); + textureRegion.draw(Vector2f(0,0),mFboBlur->getSizef()); mFboBlur->unbind(); mBlurShader->bind(); @@ -1282,8 +1282,8 @@ void EETest::loadTextures() { mBlindy.addFramesByPattern( "rn" ); mBlindy.setPosition( Vector2f( 320.f, 0.f ) ); - mBoxSprite = eeNew( Sprite, ( GlobalTextureAtlas::instance()->add( eeNew( SubTexture, ( TN[3], "ilmare" ) ) ) ) ); - mCircleSprite = eeNew( Sprite, ( GlobalTextureAtlas::instance()->add( eeNew( SubTexture, ( TN[1], "thecircle" ) ) ) ) ); + mBoxSprite = eeNew( Sprite, ( GlobalTextureAtlas::instance()->add( eeNew( TextureRegion, ( TN[3], "ilmare" ) ) ) ) ); + mCircleSprite = eeNew( Sprite, ( GlobalTextureAtlas::instance()->add( eeNew( TextureRegion, ( TN[1], "thecircle" ) ) ) ) ); eePRINTL( "Textures loading time: %4.3f ms.", TE.getElapsed().asMilliseconds() ); diff --git a/src/test/eetest.hpp b/src/test/eetest.hpp index 6d67c39b8..1dd5b58f2 100644 --- a/src/test/eetest.hpp +++ b/src/test/eetest.hpp @@ -53,7 +53,7 @@ class EETest : private Thread { std::vector TN; std::vector TNP; - std::vector Tiles; + std::vector Tiles; std::vector PS; Vector2i Mouse;