_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
minimap.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1998-2005 by Lutz Sammer and Jimmy Salmon
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 //
29 
30 #ifndef __MINIMAP_H__
31 #define __MINIMAP_H__
32 
34 
35 #include "color.h"
36 #include "vec2i.h"
37 
38 class CViewport;
39 
40 struct SDL_Surface;
41 
42 /*----------------------------------------------------------------------------
43 -- Declarations
44 ----------------------------------------------------------------------------*/
45 
46 class CMinimap
47 {
48  template <const int BPP>
49  void UpdateMapTerrain(void *const mpixels, const int mpitch,
50  const void *const tpixels, const int tpitch);
51 
52  void UpdateTerrain();
53 
54  template <const int BPP>
55  void UpdateSeen(void *const pixels, const int pitch);
56 
57 public:
58  CMinimap() : X(0), Y(0), W(0), H(0), XOffset(0), YOffset(0),
59  WithTerrain(false), ShowSelected(false),
60  Transparent(false), UpdateCache(false) {}
61 
62  void UpdateXY(const Vec2i &pos);
63  void UpdateSeenXY(const Vec2i &) {}
64  void Update();
65  void Create();
66 #if defined(USE_OPENGL) || defined(USE_GLES)
67  void FreeOpenGL();
68  void Reload();
69 #endif
70  void Destroy();
71  void Draw() const;
72  void DrawViewportArea(const CViewport &viewport) const;
73  void AddEvent(const Vec2i &pos, IntColor color);
74 
75  Vec2i ScreenToTilePos(const PixelPos &screenPos) const;
76  PixelPos TilePosToScreenPos(const Vec2i &tilePos) const;
77 
78  bool Contains(const PixelPos &screenPos) const;
79 public:
80  int X;
81  int Y;
82  int W;
83  int H;
84  int XOffset;
85  int YOffset;
90 };
91 
92 #if defined(USE_OPENGL) || defined(USE_GLES)
93 // Minimap surface with units (for OpenGL)
94 extern unsigned char *MinimapSurfaceGL;
95 // Minimap surface with terrain only (for OpenGL)
96 extern unsigned char *MinimapTerrainSurfaceGL;
97 #endif
98 
99 // Minimap surface with units (for software)
100 extern SDL_Surface *MinimapSurface;
101 // Minimap surface with terrain only (for software)
102 extern SDL_Surface *MinimapTerrainSurface;
103 
105 
106 #endif // !__MINIMAP_H__
bool Transparent
Definition: minimap.h:88
bool Contains(const PixelPos &screenPos) const
Definition: minimap.cpp:782
void DrawViewportArea(const CViewport &viewport) const
Definition: minimap.cpp:755
Definition: minimap.h:46
void UpdateSeenXY(const Vec2i &)
Definition: minimap.h:63
int W
Definition: minimap.h:82
bool WithTerrain
Definition: minimap.h:86
int YOffset
Definition: minimap.h:85
unsigned char * MinimapTerrainSurfaceGL
Definition: minimap.cpp:75
void UpdateXY(const Vec2i &pos)
Definition: minimap.cpp:317
PixelPos TilePosToScreenPos(const Vec2i &tilePos) const
Definition: minimap.cpp:713
void Update()
Definition: minimap.cpp:507
void Destroy()
Definition: minimap.cpp:723
void Create()
Definition: minimap.cpp:132
void Reload()
Definition: minimap.cpp:204
Definition: viewport.h:63
int Y
Definition: minimap.h:81
CMinimap()
Definition: minimap.h:58
int XOffset
Definition: minimap.h:84
SDL_Surface * MinimapSurface
Definition: minimap.cpp:70
SDL_Surface * MinimapTerrainSurface
generated minimap
Definition: minimap.cpp:71
unsigned char * MinimapSurfaceGL
generated minimap terrain
Definition: minimap.cpp:74
void AddEvent(const Vec2i &pos, IntColor color)
Definition: minimap.cpp:771
int H
Definition: minimap.h:83
Vec2i ScreenToTilePos(const PixelPos &screenPos) const
Definition: minimap.cpp:697
Definition: vec2i.h:36
uint32_t IntColor
Definition: color.h:74
int X
Definition: minimap.h:80
bool UpdateCache
Definition: minimap.h:89
void Draw() const
Definition: minimap.cpp:635
void FreeOpenGL()
Definition: minimap.cpp:196
bool ShowSelected
Definition: minimap.h:87
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.