path_gameobject.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #ifndef HEADER_SUPERTUX_OBJECT_PATH_GAMEOBJECT_HPP
  17. #define HEADER_SUPERTUX_OBJECT_PATH_GAMEOBJECT_HPP
  18. #include "sprite/sprite_ptr.hpp"
  19. #include "supertux/game_object.hpp"
  20. #include "math/fwd.hpp"
  21. class Path;
  22. enum class PathStyle
  23. {
  24. NONE,
  25. SOLID
  26. };
  27. class PathGameObject : public GameObject
  28. {
  29. public:
  30. PathGameObject();
  31. PathGameObject(const Vector& pos);
  32. PathGameObject(const ReaderMapping& mapping, bool backward_compatibility_hack=false);
  33. ~PathGameObject() override;
  34. virtual void update(float dt_sec) override;
  35. virtual void draw(DrawingContext& context) override;
  36. static std::string class_name() { return "path"; }
  37. virtual std::string get_class_name() const override { return class_name(); }
  38. static std::string display_name() { return _("Path"); }
  39. virtual std::string get_display_name() const override { return display_name(); }
  40. virtual const std::string get_icon_path() const override {
  41. return "images/engine/editor/path.png";
  42. }
  43. virtual void editor_select() override;
  44. virtual void editor_deselect() override;
  45. virtual void remove_me() override;
  46. virtual void on_flip(float height) override;
  47. virtual ObjectSettings get_settings() override;
  48. void regenerate_name();
  49. Path& get_path() { return *m_path; }
  50. void copy_into(PathGameObject& other);
  51. /** Allows saving the object only if the path is referenced somewhere. */
  52. bool is_saveable() const override;
  53. private:
  54. std::unique_ptr<Path> m_path;
  55. PathStyle m_style;
  56. SpritePtr m_edge_sprite;
  57. SpritePtr m_node_sprite;
  58. private:
  59. PathGameObject(const PathGameObject&) = delete;
  60. PathGameObject& operator=(const PathGameObject&) = delete;
  61. };
  62. #endif
  63. /* EOF */