// This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Library General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SMALLMAP_H #define SMALLMAP_H #include #include #include /** Display of the whole game map. * * SmallMap is the widget at the top right of the game screen which provides an * overview of the whole game map. It handles mouse clicks, moving of the * currently visible portion and changes of the underlying map. * * @note: This class shares the viewrect (=which part of the map is currently * visible in the main screen) with BigMap. Furthermore, it draws a rectangle * with changing colors at the position of the viewrect, which is why it has to * keep track of it. */ class SmallMap : public PG_Widget, public PG_TimerObject { public: /** Constructor * * @param parent the parent widget * @param rect the rectangle for the smallmap * @param x_squares the horizontal size of the viewrect * @param y_squares the vertical size of the viewrect * * @note The width and height of the rect should be mapsize+2, else * the drawing code will fail! */ SmallMap(PG_Widget* parent, PG_Rect rect, int x_squares, int y_squares, int pixelsize); ~SmallMap(); //! Draws the viewrect over the (internal) display of the map void drawViewrect(); //! Timer callback for redrawing the viewrect with a different color Uint32 eventTimer(ID id, Uint32 interval); //! Returns the viewrect PG_Rect* getViewrect(){return d_viewrect;} //! Paragui callback if the viewrect changes bool changedViewrect(PG_Widget *widget); //! called if resolution changes void changeResolution(int x_squares,int y_squares); //! Interrupt the internal timer (for redrawing the viewrect) void interruptTimer(); //! Restart the internal timer void restartTimer(); // 2 helping things for the viewrect void inputFunction(int arrowx, int arrowy); // will be connected to BigMap::Redraw() SigC::Signal1 schangingViewrect; private: void setViewrect(int x, int y); // EVENT HANDLERS void eventDraw(SDL_Surface* surface, const PG_Rect& rect); bool eventMouseButtonDown(const SDL_MouseButtonEvent* event); bool eventMouseMotion(const SDL_MouseMotionEvent* event); // DATA SDL_Surface* d_staticMap; PG_Rect* d_viewrect; int d_pixels; bool d_pressed; int d_r; int d_g; int d_b; bool d_add; // keycheck , Value changes to 1 : SDL_KeyboardEvent , Value changes to 0 : SDL_MouseButtonEvent int keycheck; // helping variables for the KeyboardEvent from Thomas Plonka int arrowx ,arrowy; Uint32 d_timerID; //SDL_mutex* d_lock; }; #endif // SMALLMAP_H