supertux
tile_set.hpp
1 // SuperTux
2 // Copyright (C) 2008 Matthias Braun <matze@braunis.de>
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 
17 #ifndef HEADER_SUPERTUX_SUPERTUX_TILE_SET_HPP
18 #define HEADER_SUPERTUX_SUPERTUX_TILE_SET_HPP
19 
20 #include <map>
21 #include <memory>
22 #include <stdint.h>
23 #include <string>
24 
25 #include "math/fwd.hpp"
26 #include "supertux/autotile.hpp"
27 #include "supertux/tile.hpp"
28 #include "video/color.hpp"
29 #include "video/surface_ptr.hpp"
30 
31 class Canvas;
32 class DrawingContext;
33 
34 class Tilegroup final
35 {
36 public:
37  Tilegroup();
38 
39  bool developers_group = false;
40  std::string name;
41  std::vector<int> tiles;
42 };
43 
44 class TileSet final
45 {
46 public:
47  static std::unique_ptr<TileSet> from_file(const std::string& filename);
48 
49 public:
50  TileSet();
51  ~TileSet() = default;
52 
53  void add_tile(int id, std::unique_ptr<Tile> tile);
54 
57  void add_unassigned_tilegroup();
58 
60  void remove_deprecated_tiles();
61 
62  void add_tilegroup(const Tilegroup& tilegroup);
63 
64  const Tile& get(const uint32_t id) const;
65 
66  AutotileSet* get_autotileset_from_tile(uint32_t tile_id) const;
67 
68  uint32_t get_max_tileid() const {
69  return static_cast<uint32_t>(m_tiles.size());
70  }
71 
72  const std::vector<Tilegroup>& get_tilegroups() const {
73  return m_tilegroups;
74  }
75 
76  void print_debug_info(const std::string& filename);
77 
78 public:
79  // Must be public because of tile_set_parser.cpp
80  std::vector<std::unique_ptr<AutotileSet>> m_autotilesets;
81 
82  // Additional attributes
83 
84  // Must be public because of tile_set_parser.cpp and thunderstorm.cpp
85  std::map<uint32_t, uint32_t> m_thunderstorm_tiles;
86 
87 private:
88  std::vector<std::unique_ptr<Tile> > m_tiles;
89  std::vector<Tilegroup> m_tilegroups;
90 
91 private:
92  TileSet(const TileSet&) = delete;
93  TileSet& operator=(const TileSet&) = delete;
94 };
95 
96 #endif
97 
98 /* EOF */
Definition: tile_set.hpp:34
Definition: tile.hpp:32
Definition: canvas.hpp:43
Definition: tile_set.hpp:44
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
Definition: autotile.hpp:79