Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

minimap.h

00001 /***************************************************************************
00002                           map.h  -  description
00003                              -------------------
00004     begin                : Thu Jan 29 2004
00005     copyright            : (C) 2004 by Daroth-U
00006     email                : daroth-u@ifrance.com
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef MINIMAP_H
00019 #define MINIMAP_H
00020 
00021 #define MINI_MAP_X_SCALE 3
00022 #define MINI_MAP_Y_SCALE 3
00023 
00024 #define MINI_MAP_PARTY_VIEW 4
00025 
00026 #define MINI_MAP_WIDTH MAP_WIDTH/MINI_MAP_X_SCALE
00027 #define MINI_MAP_DEPTH MAP_DEPTH/MINI_MAP_Y_SCALE
00028 
00029 
00030 #include "constants.h"
00031 #include "location.h"
00032 #include "sdlhandler.h"
00033 #include "shape.h"
00034 #include "map.h"
00035 #include "dungeongenerator.h"
00036 #include "scourge.h"
00037 #include "math.h"
00038 #include "gui/window.h"
00039 #include "gui/canvas.h"
00040 #include "gui/widgetview.h"
00041 
00042 using namespace std;
00043 
00044 // forward decl.
00045 class Shape;
00046 //class Map;
00047 class Scourge;
00048 class Util;
00049 class Location;
00050 
00051 typedef struct _MiniMapPoint {
00052     GLfloat r, g, b;
00053     bool visible;
00054 }MiniMapPoint;
00055 
00059 class MiniMap : public WidgetView {
00060  private:
00061     
00062   // Basic Idea : minimap is already filled but a point becomes visible only
00063   // if the party has reached it.
00064   MiniMapPoint pos[MINI_MAP_WIDTH][MINI_MAP_DEPTH];
00065   Scourge *scourge;  
00066   
00067         Window *win;
00068   Canvas *canvas;
00069   
00070   GLfloat zoomFactor;   // Determines the zoom factor of the minimap   
00071   int mode;             // 0 : show structures : wall, doors and floor , 1: add monsters ... 
00072   bool showMiniMap;     // true : draw it, false : don't draw the minimap
00073   int screenHeight;     // Needed for glScissor used in MiniMap::Draw()
00074   
00075   // Texture that will hold the minimap
00076   int textureSizeH, textureSizeW;   
00077   GLuint texture[1];
00078   unsigned char * textureInMemory;
00079   bool mustBuildTexture;   
00080   
00081   // Real width and height of minimap in pixels (i.e. : without insignificant
00082   // pixels at the bottom or at the right side) including a little marge.
00083   int effectiveWidth, effectiveHeight; 
00084   int maxX, maxY;
00085   int minX, minY;
00086   float midX, midY;  
00087   
00088   // Transform Map coordinates to MiniMap coordinates
00089   void toMiniMapCoord(int &x, int &y);       
00090   
00091  public:
00092   MiniMap::MiniMap();
00093   MiniMap::~MiniMap();
00094   MiniMap(Scourge *scourge);
00095 
00096   void reset();
00097 
00098   inline void show() { win->setVisible(true); }
00099   inline void hide() { win->setVisible(false); }
00100   inline Window *getWindow() { return win; }
00101   inline void resize(int w, int h) { win->resize(w, h); canvas->resize(w, h - 25); }
00102   
00103   // x, y are in *global Map* coordinates (see Map.h to know its size) 
00104   void colorMiniMapPoint(int x, int y, Shape *shape, Location *pos);
00105   void eraseMiniMapPoint(int x, int y);
00106   void zoomIn();
00107   void zoomOut();
00108   
00109   bool checkInside(int a, int b); 
00110   inline void toggle(){showMiniMap = !showMiniMap;} 
00111   void computeDrawValues(); // needed before drawing the minimap
00112   void updateFog(int a, int b); // gradually set the minimap visible for the player
00113   void buildTexture(int xCoord, int yCoord);
00114 
00115   void drawWidget(Widget *w);
00116   
00117   //void handleMouseClick(Uint16 mapx, Uint16 mapy, Uint16 mapz, Uint8 button);    
00118   
00119  protected:
00120   
00121 };
00122 
00123 #endif

Generated on Thu Jun 16 21:50:43 2005 for scourge by  doxygen 1.4.0