object_layer.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Flexlay - A Generic 2D Game Editor
  2. // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.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. #ifndef HEADER_FLEXLAY_OBJECT_LAYER_HPP
  17. #define HEADER_FLEXLAY_OBJECT_LAYER_HPP
  18. #include "meta_data.hpp"
  19. #include "layer.hpp"
  20. #include "objmap_object.hpp"
  21. #include "objmap_control_point.hpp"
  22. class ObjectLayerImpl;
  23. /** The ObjectLayer provides a simple Layer for holding positioned
  24. objects. Objects can consist of a CL_Sprite and some properties
  25. accessible from scripting languages or any other thing that is a
  26. ObjMapObject. */
  27. class ObjectLayer
  28. {
  29. public:
  30. typedef std::vector<ObjMapObject> Objects;
  31. typedef std::vector<ObjMapControlPoint> ControlPoints;
  32. static ObjectLayer current_;
  33. static ObjectLayer current() { return current_; }
  34. static void set_current(ObjectLayer c) { current_ = c; }
  35. ObjectLayer();
  36. ~ObjectLayer();
  37. void add_object(const ObjMapObject& obj);
  38. void delete_object(const ObjMapObject& obj);
  39. /** Moved the given object one position up in the object stack */
  40. void raise(const ObjMapObject& obj);
  41. /** Moved the given object one position down in the object stack */
  42. void lower(const ObjMapObject& obj);
  43. /** Moves the object to the given height in the object stack (0 is
  44. lowest position, size()-1 is highest */
  45. void move_to(const ObjMapObject& obj, int height);
  46. /** Returns the index at which the given object is in the Objects
  47. array or -1 if the object couldn't be found */
  48. int get_object_index(const ObjMapObject& obj);
  49. void add_control_point(const ObjMapControlPoint& obj);
  50. void delete_control_points();
  51. ObjMapObject find_object(const CL_Pointf& pos);
  52. ObjMapControlPoint find_control_point(const CL_Pointf& pos);
  53. std::vector<ObjMapObject> get_selection(const CL_Rectf& rect);
  54. std::vector<ObjMapObject> get_objects();
  55. Layer to_layer();
  56. private:
  57. std::shared_ptr<ObjectLayerImpl> impl;
  58. };
  59. #endif
  60. /* EOF */