supertux
sprite_change.hpp
1 // SuperTux
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 // 2023 Vankata453
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef HEADER_SUPERTUX_WORLDMAP_SPRITE_CHANGE_HPP
19 #define HEADER_SUPERTUX_WORLDMAP_SPRITE_CHANGE_HPP
20 
21 #include "worldmap/worldmap_object.hpp"
22 
23 #include <string>
24 
25 namespace worldmap {
26 
27 class SpriteChange final : public WorldMapObject
28 {
29 public:
30  SpriteChange(const ReaderMapping& mapping);
31  ~SpriteChange() override;
32 
33  static std::string class_name() { return "sprite-change"; }
34  virtual std::string get_class_name() const override { return class_name(); }
35  static std::string display_name() { return _("Sprite Change"); }
36  virtual std::string get_display_name() const override { return display_name(); }
37  virtual GameObjectClasses get_class_types() const override { return WorldMapObject::get_class_types().add(typeid(SpriteChange)); }
38 
39  virtual void draw_worldmap(DrawingContext& context) override;
40 
41  virtual ObjectSettings get_settings() override;
42 
46  void set_stay_action();
51  void clear_stay_action(bool propagate = true);
55  bool show_stay_action() const;
56 
60  SpritePtr clone_sprite() const;
61 
62  bool change_on_touch() const { return m_change_on_touch; }
63 
64 private:
67  bool m_change_on_touch;
68 
72  std::string m_stay_action;
73 
76  std::string m_stay_group;
77 
79  bool m_in_stay_action;
80 
81 private:
82  SpriteChange(const SpriteChange&) = delete;
83  SpriteChange& operator=(const SpriteChange&) = delete;
84 };
85 
86 } // namespace worldmap
87 
88 #endif
89 
90 /* EOF */
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: sprite_change.hpp:37
void clear_stay_action(bool propagate=true)
Deactivates the SpriteChange&#39;s stay action, if applicable.
Definition: sprite_change.cpp:65
Definition: worldmap_object.hpp:30
Definition: object_settings.hpp:39
SpritePtr clone_sprite() const
Clone the current sprite.
Definition: sprite_change.cpp:81
bool show_stay_action() const
Get the current value of in_stay_action.
Definition: sprite_change.cpp:53
Definition: object_settings.hpp:32
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: sprite_change.hpp:36
virtual void draw_worldmap(DrawingContext &context) override
Draws the object, when on a worldmap.
Definition: sprite_change.cpp:43
Definition: sprite_change.hpp:27
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
void set_stay_action()
Activates the SpriteChange&#39;s stay action, if applicable.
Definition: sprite_change.cpp:59
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: worldmap_object.hpp:39
Definition: reader_mapping.hpp:32
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42