Revert ca83136
[supertux.git] / src / sprite / sprite_data.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 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_SPRITE_SPRITE_DATA_HPP
18 #define HEADER_SUPERTUX_SPRITE_SPRITE_DATA_HPP
19
20 #include <map>
21 #include <vector>
22
23 #include "util/reader_fwd.hpp"
24 #include "video/surface.hpp"
25
26 class SpriteData
27 {
28 public:
29   /** cur has to be a pointer to data in the form of ((hitbox 5 10 0 0) ...) */
30   SpriteData(const Reader& cur, const std::string& basedir);
31   ~SpriteData();
32
33   const std::string& get_name() const
34   {
35     return name;
36   }
37
38 private:
39   friend class Sprite;
40
41   struct Action
42   {
43     Action();
44     ~Action();
45
46     std::string name;
47
48     /** Position correction */
49     float x_offset;
50     float y_offset;
51
52     /** Hitbox width */
53     float hitbox_w;
54
55     /** Hitbox height */
56     float hitbox_h;
57
58     /** Drawing priority in queue */
59     int z_order;
60
61     /** Frames per second */
62     float fps;
63
64     std::vector<SurfacePtr> surfaces;
65   };
66
67   typedef std::map <std::string, Action*> Actions;
68
69   void parse_action(const Reader& lispreader, const std::string& basedir);
70   /** Get an action */
71   const Action* get_action(const std::string& act);
72
73   Actions actions;
74   std::string name;
75 };
76
77 #endif
78
79 /* EOF */