supertux
node_marker.hpp
1 // SuperTux
2 // Copyright (C) 2016 Hume2 <teratux.mail@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_EDITOR_NODE_MARKER_HPP
18 #define HEADER_SUPERTUX_EDITOR_NODE_MARKER_HPP
19 
20 #include <editor/bezier_marker.hpp>
21 #include "editor/marker_object.hpp"
22 #include "object/path.hpp"
23 
24 class NodeMarker final : public MarkerObject
25 {
26 public:
27  NodeMarker(std::vector<Path::Node>::iterator node_iterator, size_t id_, UID before, UID after);
28  virtual GameObjectClasses get_class_types() const override { return MarkerObject::get_class_types().add(typeid(NodeMarker)); }
29 
30  virtual void move_to(const Vector& pos) override;
31  virtual void editor_delete() override;
32  virtual Vector get_point_vector() const override;
33  virtual Vector get_offset() const override;
34  virtual bool has_settings() const override { return true; }
35  virtual ObjectSettings get_settings() override;
36  virtual void editor_update() override;
37  virtual void remove_me() override;
38 
39  void update_iterator();
40  void update_node_times();
41 
44  void move_other_marker(UID marker, Vector position);
45 
46  void save_state() override;
47  void check_state() override;
48 
49 private:
50  Path* m_path;
51  std::vector<Path::Node>::iterator prev_node();
52  std::vector<Path::Node>::const_iterator next_node() const;
53  void update_node_time(std::vector<Path::Node>::iterator current, std::vector<Path::Node>::const_iterator next);
54 
55  UID m_bezier_before;
56  UID m_bezier_after;
57 
58 public:
59  std::vector<Path::Node>::iterator m_node;
60 
61 private:
62  size_t m_id;
63 
64 private:
65  NodeMarker(const NodeMarker&) = delete;
66  NodeMarker& operator=(const NodeMarker&) = delete;
67 };
68 
69 #endif
70 
71 /* EOF */
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: marker_object.hpp:31
virtual bool has_settings() const override
Indicates if get_settings() is implemented.
Definition: node_marker.hpp:34
virtual void editor_update() override
Called each frame in the editor, used to keep linked objects together (e.g.
Definition: node_marker.cpp:159
Definition: object_settings.hpp:39
Definition: path.hpp:48
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: node_marker.hpp:28
Definition: marker_object.hpp:26
void move_other_marker(UID marker, Vector position)
Moves the bezier marker that ISN&#39;T marker to the given position.
Definition: node_marker.cpp:209
Definition: uid.hpp:37
virtual void remove_me() override
schedules this object to be removed at the end of the frame
Definition: node_marker.cpp:53
virtual void editor_delete() override
The editor requested the deletion of the object.
Definition: node_marker.cpp:106
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: node_marker.hpp:24
void save_state() override
Save/check the current state of the object.
Definition: node_marker.cpp:221