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_WORLDMAP_SPRITE_CHANGE_HPP
18#define HEADER_SUPERTUX_WORLDMAP_SPRITE_CHANGE_HPP
19
20#include <list>
21#include <string>
22
23#include "math/vector.hpp"
24#include "sprite/sprite_ptr.hpp"
25#include "supertux/game_object.hpp"
26
27class ReaderMapping;
28class Sprite;
29
30namespace worldmap {
31
32class SpriteChange final : public GameObject
33{
34private:
35 static std::list<SpriteChange*> s_all_sprite_changes;
36
37public:
38 SpriteChange(const ReaderMapping& mapping);
39 virtual ~SpriteChange();
40
41 virtual void draw(DrawingContext& context) override;
42 virtual void update(float dt_sec) override;
43
44 /**
45 * Activates the SpriteChange's stay action, if applicable
46 */
47 void set_stay_action();
48
49 /**
50 * Deactivates the SpriteChange's stay action, if applicable
51 * @param propagate : Also change stay actions in the same stay group
52 */
53 void clear_stay_action(bool propagate = true);
54
55 /*
56 * Get the current value of in_stay_action
57 */
58 bool show_stay_action() const;
59
60 Vector get_pos() const { return m_pos; }
61
62private:
63 Vector m_pos;
64
65public:
66 /** should tuxs sprite change when the tile has been completely entered,
67 or already when the tile was just touched */
68 bool m_change_on_touch;
69
70 /** sprite to change tux image to */
71 SpritePtr m_sprite;
72 std::string m_sprite_name;
73
74private:
75 /** stay action can be used for objects like boats or cars, if it is
76 not empty then this sprite will be displayed when tux left the
77 tile towards another SpriteChange object. */
78 std::string m_stay_action;
79
80 /** name of a group in which only one SpriteChange will ever have
81 its stay_action displayed. Leave empty if you don't care. */
82 std::string m_stay_group;
83
84private:
85 /** should the stayaction be displayed */
86 bool m_in_stay_action;
87
88private:
89 SpriteChange(const SpriteChange&) = delete;
90 SpriteChange& operator=(const SpriteChange&) = delete;
91};
92
93} // namespace worldmap
94
95#endif
96
97/* EOF */
98