sprite_manager.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SuperTux
  2. // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
  3. // 2023 Vankata453
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef HEADER_SUPERTUX_SPRITE_SPRITE_MANAGER_HPP
  18. #define HEADER_SUPERTUX_SPRITE_SPRITE_MANAGER_HPP
  19. #include "util/currenton.hpp"
  20. #include <map>
  21. #include <memory>
  22. #include <string>
  23. #include "sprite/sprite_ptr.hpp"
  24. class SpriteData;
  25. class SpriteManager final : public Currenton<SpriteManager>
  26. {
  27. private:
  28. static std::unique_ptr<SpriteData> s_dummy_sprite_data;
  29. private:
  30. typedef std::map<std::string, std::unique_ptr<SpriteData> > Sprites;
  31. Sprites m_sprites;
  32. bool m_load_successful;
  33. public:
  34. SpriteManager();
  35. bool last_load_successful() const { return m_load_successful; }
  36. /** loads a sprite. */
  37. SpritePtr create(const std::string& filename);
  38. private:
  39. SpriteData* load(const std::string& filename);
  40. private:
  41. SpriteManager(const SpriteManager&) = delete;
  42. SpriteManager& operator=(const SpriteManager&) = delete;
  43. };
  44. #endif
  45. /* EOF */