supertux
path_gameobject.hpp
1 // SuperTux
2 // Copyright (C) 2018 Ingo Ruhnke <grumbel@gmail.com>
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_OBJECT_PATH_GAMEOBJECT_HPP
18 #define HEADER_SUPERTUX_OBJECT_PATH_GAMEOBJECT_HPP
19 
20 #include "sprite/sprite_ptr.hpp"
21 #include "supertux/game_object.hpp"
22 #include "math/fwd.hpp"
23 
24 class Path;
25 
26 enum class PathStyle
27 {
28  NONE,
29  SOLID
30 };
31 
32 class PathGameObject : public GameObject
33 {
34 public:
36  PathGameObject(const Vector& pos);
37  PathGameObject(const ReaderMapping& mapping, bool backward_compatibility_hack=false);
38  ~PathGameObject() override;
39 
40  virtual void update(float dt_sec) override;
41  virtual void draw(DrawingContext& context) override;
42 
43  static std::string class_name() { return "path"; }
44  virtual std::string get_class_name() const override { return class_name(); }
45  static std::string display_name() { return _("Path"); }
46  virtual std::string get_display_name() const override { return display_name(); }
47  virtual GameObjectClasses get_class_types() const override { return GameObject::get_class_types().add(typeid(PathGameObject)); }
48 
49  virtual const std::string get_icon_path() const override {
50  return "images/engine/editor/path.png";
51  }
52 
53  virtual void editor_select() override;
54  virtual void editor_deselect() override;
55 
56  virtual void remove_me() override;
57 
58  virtual void on_flip(float height) override;
59 
60  virtual ObjectSettings get_settings() override;
61 
62  void regenerate_name();
63 
64  Path& get_path() { return *m_path; }
65 
66  void copy_into(PathGameObject& other);
67 
69  bool is_saveable() const override;
70 
71 private:
72  std::unique_ptr<Path> m_path;
73  PathStyle m_style;
74  SpritePtr m_edge_sprite;
75  SpritePtr m_node_sprite;
76 
77 private:
78  PathGameObject(const PathGameObject&) = delete;
79  PathGameObject& operator=(const PathGameObject&) = delete;
80 };
81 
82 #endif
83 
84 /* EOF */
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: path_gameobject.hpp:47
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: path_gameobject.hpp:46
Definition: object_settings.hpp:39
Definition: path.hpp:48
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual GameObjectClasses get_class_types() const
List notable classes in inheritance hierarchy of class.
Definition: game_object.cpp:113
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
Definition: reader_mapping.hpp:32
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
Definition: path_gameobject.hpp:32