tilemap_layer.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_TILEMAP_LAYER_HPP
  17. #define HEADER_FLEXLAY_TILEMAP_LAYER_HPP
  18. #include <ClanLib/Display/pixel_buffer.h>
  19. #include <memory>
  20. #include "field.hpp"
  21. #include "meta_data.hpp"
  22. #include "layer.hpp"
  23. class Tileset;
  24. class TileBrush;
  25. class TilemapLayerImpl;
  26. class TilemapLayer
  27. {
  28. private:
  29. static TilemapLayer current_;
  30. public:
  31. static TilemapLayer current();
  32. static void set_current(TilemapLayer t);
  33. TilemapLayer();
  34. TilemapLayer(Tileset tileset, int w, int h);
  35. ~TilemapLayer();
  36. void draw(const GraphicContextState& state, CL_GraphicContext* gc);
  37. Tileset get_tileset();
  38. int get_tile (int, int);
  39. Field<int>* get_field();
  40. /** @param pos position of the old map in the new resized one
  41. @param size height of the new map */
  42. void resize(const CL_Size& size, const CL_Point& point);
  43. const std::vector<int>& get_data();
  44. void set_data(std::vector<int> d);
  45. void set_metadata(const MetaData& obj);
  46. MetaData get_metadata() const;
  47. /** Draw the gives brush to the map */
  48. void draw_tile(const TileBrush& brush, const CL_Point& pos);
  49. /** Draw the given single tile to the map */
  50. void draw_tile(int id, const CL_Point& pos);
  51. int get_width() const;
  52. int get_height() const;
  53. void set_background_color(const CL_Color& color);
  54. void set_foreground_color(const CL_Color& color);
  55. void set_draw_attribute(bool t);
  56. bool get_draw_attribute() const;
  57. void set_draw_grid(bool t);
  58. bool get_draw_grid() const;
  59. CL_PixelBuffer create_pixelbuffer();
  60. static void draw_tiles(Field<int>* field, const TileBrush& brush, const CL_Point& pos);
  61. bool has_bounding_rect() const;
  62. CL_Rect get_bounding_rect();
  63. /** Convert a coordinate given in world position into a tile
  64. coordinate */
  65. CL_Point world2tile(const CL_Pointf& pos) const;
  66. bool is_null() const { return !impl.get(); }
  67. Layer to_layer();
  68. private:
  69. std::shared_ptr<TilemapLayerImpl> impl;
  70. };
  71. #endif
  72. /* EOF */