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 <memory>
21 #include <stdint.h>
22 #include <string>
23 
24 #include "video/color.hpp"
25 #include "video/surface_ptr.hpp"
26 
27 class Canvas;
28 class DrawingContext;
29 class Tile;
30 class Vector;
31 
32 class Tilegroup final
33 {
34 public:
35  Tilegroup();
36 
37  bool developers_group = false;
38  std::string name;
39  std::vector<int> tiles;
40 };
41 
42 class TileSet final
43 {
44 public:
45  static std::unique_ptr<TileSet> from_file(const std::string& filename);
46 
47 public:
48  TileSet();
49 
50  void add_tile(int id, std::unique_ptr<Tile> tile);
51 
54  void add_unassigned_tilegroup();
55 
56  void add_tilegroup(const Tilegroup& tilegroup);
57 
58  const Tile& get(const uint32_t id) const;
59 
60  uint32_t get_max_tileid() const {
61  return static_cast<uint32_t>(m_tiles.size());
62  }
63 
64  const std::vector<Tilegroup>& get_tilegroups() const {
65  return m_tilegroups;
66  }
67 
68  void print_debug_info(const std::string& filename);
69 
70 private:
71  std::vector<std::unique_ptr<Tile> > m_tiles;
72  std::vector<Tilegroup> m_tilegroups;
73 
74 private:
75  TileSet(const TileSet&) = delete;
76  TileSet& operator=(const TileSet&) = delete;
77 };
78 
79 #endif
80 
81 /* EOF */
Simple two dimensional vector.
Definition: vector.hpp:24
Definition: tile_set.hpp:32
Definition: tile.hpp:32
Definition: canvas.hpp:43
Definition: tile_set.hpp:42
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42