initial commit, lordsawar source, slightly modified
[lordsawar] / src / MapRenderer.h
1 // Copyright (C) 2003 Michael Bartl
2 // Copyright (C) 2003, 2004 Ulf Lorenz
3 // Copyright (C) 2005 Andrea Paternesi
4 // Copyright (C) 2007, 2008, 2009 Ben Asselstine
5 //
6 //  This program is free software; you can redistribute it and/or modify
7 //  it under the terms of the GNU General Public License as published by
8 //  the Free Software Foundation; either version 3 of the License, or
9 //  (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU Library General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
19 //  02110-1301, USA.
20
21 #ifndef MAPRENDERER_H
22 #define MAPRENDERER_H
23
24 #include <gtkmm.h>
25 #include <string>
26 #include "vector.h"
27
28 /** Class which cares about rendering of the map.
29   * 
30   * This class is initalized with the drawing surface of the BigMap class. It
31   * cares for the actual terrain drawing. 
32   */
33
34 class MapRenderer
35 {
36     public:
37
38         /** Constructor, also does the smoothing of the GameMap.
39           * 
40           * @param surface      the surface which is rendered with render()
41           */
42         MapRenderer(Glib::RefPtr<Gdk::Pixmap> surface);
43         ~MapRenderer();
44
45         /** Render a portion of the map.
46           * 
47           * The part of the map which is drawn starts at the tile (tileX,tileY)
48           * and goes on till (tileX+columns, tileY+rows). The drawing is done on
49           * the surface handed over in the constructor and starts at pixel
50           * position (x,y).
51           */
52         void render(int x, int y, int tileX, int tileY, int columns, int rows);
53
54         void render(int x, int y, int tileStartX, int tileStartY,
55                     int columns, int rows, Glib::RefPtr<Gdk::Pixmap> surface,
56                     Glib::RefPtr<Gdk::GC> context);
57
58         void render_tile(Vector<int> draw, Vector<int> tile,
59                          Glib::RefPtr<Gdk::Pixmap> surface, 
60                          Glib::RefPtr<Gdk::GC> context);
61
62         //! Save the current view of map tiles as an image (bmp file).
63         bool saveViewAsBitmap(std::string filename);
64
65         //! Save all of the map tiles as one big image (bmp file).
66         bool saveAsBitmap(std::string filename);
67     private:
68         //Data
69         Glib::RefPtr<Gdk::Pixmap> d_surface;
70         Glib::RefPtr<Gdk::GC> gc;
71
72 };
73
74 #endif // MAPRENDERER_H
75
76 // End of file