class EE::Graphics::TextureAtlasManager

Overview

The Texture Atlas Manager is a singleton class that manages all the instances of Texture Atlases instanciated. Releases the Texture Atlases instances automatically. So the user doesn’t need to release any Texture Atlas instance. More…

#include <textureatlasmanager.hpp>

class TextureAtlasManager: public EE::System::ResourceManagerMulti {
public:
    // construction

    virtual ~TextureAtlasManager();

    // methods

    TextureAtlas* loadFromFile(const std::string& TextureAtlasPath);
    TextureAtlas* loadFromStream(IOStream& IOS);
    TextureAtlas* loadFromMemory(const Uint8* Data, const Uint32& DataSize, const std::string& TextureAtlasName);
    TextureAtlas* loadFromPack(Pack* Pack, const std::string& FilePackPath);
    TextureRegion* getTextureRegionByName(const std::string& Name);
    TextureRegion* getTextureRegionById(const String::HashType& Id);
    std::vector<TextureRegion*> getTextureRegionsByPattern(const std::string& name, const std::string& extension = "", TextureAtlas* SearchInTextureAtlas = NULL);
    std::vector<TextureRegion*> getTextureRegionsByPatternId(const Uint32& TextureRegionId, const std::string& extension = "", TextureAtlas* SearchInTextureAtlas = NULL);
    void printResources();
    void setPrintWarnings(const bool& warn);
    const bool& getPrintWarnings() const;
};

Inherited Members

public:
    // methods

    virtual T* add(T* resource);
    bool remove(T* resource, bool remove = true);
    bool removeById(const String::HashType& id, bool remove = true);
    bool removeByName(const std::string& name, bool remove = true);
    T* getByName(const std::string& name);
    T* getById(const String::HashType& id);
    Uint32 getCount();
    Uint32 getCount(const std::string& name);
    Uint32 getCount(const String::HashType& id);
    bool exists(const std::string& name);
    bool existsId(const String::HashType& id);
    void destroy();
    void printNames();
    std::unordered_multimap<String::HashType, T*>& getResources();
    const bool& isDestroying() const;

Detailed Documentation

The Texture Atlas Manager is a singleton class that manages all the instances of Texture Atlases instanciated. Releases the Texture Atlases instances automatically. So the user doesn’t need to release any Texture Atlas instance.

Methods

TextureAtlas* loadFromFile(const std::string& TextureAtlasPath)

Loads a texture atlas from its path ( the texture atlas binary is expected, not the texture, the “.eta” file ).

TextureAtlas* loadFromStream(IOStream& IOS)

Loads a texture atlas from a io stream.

TextureAtlas* loadFromMemory(const Uint8* Data, const Uint32& DataSize, const std::string& TextureAtlasName)

Loads a texture atlas from memory.

TextureAtlas* loadFromPack(Pack* Pack, const std::string& FilePackPath)

Loads a texture atlas from a pack file.

TextureRegion* getTextureRegionByName(const std::string& Name)

It will search for a TextureRegion Name in the texture atlases loaded.

Returns:

The first TextureRegion found with the given name in any atlas.

TextureRegion* getTextureRegionById(const String::HashType& Id)

It will search for a TextureRegion Id in the texture atlases loaded.

Returns:

The first TextureRegion found with the given id in any atlas.

std::vector<TextureRegion*> getTextureRegionsByPattern(const std::string& name, const std::string& extension = "", TextureAtlas* SearchInTextureAtlas = NULL)

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 )

Note

Texture atlases saves the TextureRegions names without extension by default.

Parameters:

name

First part of the sub texture name

extension

Extension of the sub texture name ( if have one, otherwise is empty )

SearchInTextureAtlas

If you want only to search in a especific atlas ( NULL if you want to search in all atlases )

std::vector<TextureRegion*> getTextureRegionsByPatternId(const Uint32& TextureRegionId, const std::string& extension = "", TextureAtlas* SearchInTextureAtlas = NULL)

Search for a pattern id. This will look for the TextureRegion with the id passed, and it will try to find any pattern by the TextureRegion name.

See also:

GetTextureRegionsByPattern

void printResources()

Prints all the resources name to the screen.

void setPrintWarnings(const bool& warn)

Sets if the warnings for not finding a resource must be printed in screen.

const bool& getPrintWarnings() const

Returns:

If warnings are being printed.