1 /* 2 * This file is part of Dune Legacy. 3 * 4 * Dune Legacy 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 2 of the License, or 7 * (at your option) any later version. 8 * 9 * Dune Legacy 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 Dune Legacy. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef RADARVIEW_H 19 #define RADARVIEW_H 20 21 #include <RadarViewBase.h> 22 23 #include <DataTypes.h> 24 25 #include <SDL.h> 26 27 28 /// This class manages the mini map at the top right corner of the screen 29 class RadarView : public RadarViewBase 30 { 31 public: 32 /** 33 Constructor 34 */ 35 RadarView(); 36 37 /** 38 Destructor 39 */ 40 virtual ~RadarView(); 41 42 /** 43 Get the map size in x direction 44 \return map width 45 */ 46 virtual int getMapSizeX() const; 47 48 /** 49 Get the map size in y direction 50 \return map height 51 */ 52 virtual int getMapSizeY() const; 53 54 55 /** 56 Draws the radar to screen. This method is called before drawOverlay(). 57 \param Position Position to draw the radar to 58 */ 59 virtual void draw(Point position); 60 61 62 /** 63 This method updates the radar. It should be called every game tick 64 */ 65 void update(); 66 67 68 /** 69 This method sets the radar mode directly. To show the static animation use switchRadarMode(). 70 \param bStatus true = switches the radar on, false = switches the radar off 71 */ setRadarMode(bool bStatus)72 void setRadarMode(bool bStatus) { 73 if(bStatus == true) { 74 currentRadarMode = RadarMode::RadarOn; 75 animFrame = 0; 76 animCounter = NUM_STATIC_FRAME_TIME; 77 } else { 78 currentRadarMode = RadarMode::RadarOff; 79 animFrame = NUM_STATIC_FRAMES - 1; 80 animCounter = NUM_STATIC_FRAME_TIME; 81 } 82 } 83 84 /** 85 This method switches the radar on or off 86 \param bOn true = switches the radar on, false = switches the radar off 87 */ 88 void switchRadarMode(bool bOn); 89 90 private: 91 92 enum class RadarMode { 93 RadarOff, 94 RadarOn, 95 AnimationRadarOff, 96 AnimationRadarOn 97 }; 98 99 void updateRadarSurface(int mapSizeX, int mapSizeY, int scale, int offsetX, int offsetY); 100 101 RadarMode currentRadarMode; ///< the current mode of the radar 102 103 int animFrame; ///< the current animation frame 104 105 int animCounter; ///< this counter is for counting the ticks one animation frame is shown 106 107 SDL_Surface* radarSurface; ///< contains the image to be drawn when the radar is active 108 SDL_Texture* radarTexture; ///< streaming texture to be used when the radar is active 109 SDL_Texture* radarStaticAnimation; ///< holds the animation graphic for radar static 110 111 }; 112 113 #endif // RADARVIEW_H 114