tile_set_parser.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SuperTux
  2. // Copyright (C) 2008 Matthias Braun <matze@braunis.de>,
  3. // Ingo Ruhnke <grumbel@gmail.com>
  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_SUPERTUX_TILE_SET_PARSER_HPP
  18. #define HEADER_SUPERTUX_SUPERTUX_TILE_SET_PARSER_HPP
  19. #include <string>
  20. #include <vector>
  21. #include <optional>
  22. #include "math/rect.hpp"
  23. #include "supertux/tile.hpp"
  24. class ReaderMapping;
  25. class TileSet;
  26. class TileSetParser final
  27. {
  28. private:
  29. TileSet& m_tileset;
  30. std::string m_filename;
  31. std::string m_tiles_path;
  32. public:
  33. TileSetParser(TileSet& tileset, const std::string& filename);
  34. void parse(int32_t start = 0, int32_t end = 0, int32_t offset = 0, bool imported = false);
  35. private:
  36. void parse_tile(const ReaderMapping& reader, int32_t min, int32_t max, int32_t offset);
  37. void parse_tiles(const ReaderMapping& reader, int32_t min, int32_t max, int32_t offset);
  38. std::vector<SurfacePtr> parse_imagespecs(const ReaderMapping& cur,
  39. const std::optional<Rect>& region = std::nullopt) const;
  40. private:
  41. TileSetParser(const TileSetParser&) = delete;
  42. TileSetParser& operator=(const TileSetParser&) = delete;
  43. };
  44. #endif
  45. /* EOF */