autotile_parser.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SuperTux
  2. // Copyright (C) 2020 A. Semphris <semphris@protonmail.com>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #ifndef HEADER_SUPERTUX_SUPERTUX_AUTOTILE_PARSER_HPP
  17. #define HEADER_SUPERTUX_SUPERTUX_AUTOTILE_PARSER_HPP
  18. #include <string>
  19. #include <vector>
  20. #include "supertux/autotile.hpp"
  21. class ReaderMapping;
  22. class AutotileParser final
  23. {
  24. private:
  25. std::vector<std::unique_ptr<AutotileSet>>& m_autotilesets;
  26. std::string m_filename;
  27. std::string m_tiles_path;
  28. public:
  29. AutotileParser(std::vector<std::unique_ptr<AutotileSet>>& autotilesets, const std::string& filename);
  30. void parse();
  31. private:
  32. void parse_autotileset(const ReaderMapping& reader, bool corner);
  33. Autotile* parse_autotile(const ReaderMapping& reader, bool corner);
  34. void parse_mask(const std::string& mask, std::vector<AutotileMask>& autotile_masks, bool solid);
  35. void parse_mask_corner(const std::string& mask, std::vector<AutotileMask>& autotile_masks);
  36. void parse_mask(const std::string& mask, std::vector<AutotileMask>& autotile_masks, bool solid, bool is_corner);
  37. private:
  38. AutotileParser(const AutotileParser&) = delete;
  39. AutotileParser& operator=(const AutotileParser&) = delete;
  40. };
  41. #endif
  42. /* EOF */