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

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 SetFogOpacityLevels(const uint8_t explored, const uint8_t revealed, const uint8_t unseen);
63 
64  void UpdateXY(const Vec2i &pos);
65  void UpdateSeenXY(const Vec2i &) {}
66  void Update();
67  void Create();
68  void Destroy();
69  void Draw() const;
70  void DrawViewportArea(const CViewport &viewport) const;
71  void AddEvent(const Vec2i &pos, IntColor color);
72 
73  Vec2i ScreenToTilePos(const PixelPos &screenPos) const;
74  PixelPos TilePosToScreenPos(const Vec2i &tilePos) const;
75 
76  bool Contains(const PixelPos &screenPos) const;
77 public:
78  int X;
79  int Y;
80  int W;
81  int H;
82  int XOffset;
83  int YOffset;
88 private:
89  struct MinimapSettings
90  {
92  uint8_t FogVisibleOpacity {0x00};
93  uint8_t FogExploredOpacity {0x55};
94  uint8_t FogRevealedOpacity {0xAA};
95  uint8_t FogUnseenOpacity {0xFF};
96  } Settings;
97 };
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__
CMinimap::Transparent
bool Transparent
Definition: minimap.h:86
CMinimap::UpdateCache
bool UpdateCache
Definition: minimap.h:87
CMinimap::Contains
bool Contains(const PixelPos &screenPos) const
Definition: minimap.cpp:543
CMinimap::DrawViewportArea
void DrawViewportArea(const CViewport &viewport) const
Definition: minimap.cpp:516
IntColor
uint32_t IntColor
Definition: color.h:37
vec2i.h
CMinimap::SetFogOpacityLevels
void SetFogOpacityLevels(const uint8_t explored, const uint8_t revealed, const uint8_t unseen)
Definition: minimap.cpp:231
CViewport
Definition: viewport.h:63
CMinimap::Create
void Create()
Definition: minimap.cpp:107
Vec2T
Definition: vec2i.h:36
CMinimap::CMinimap
CMinimap()
Definition: minimap.h:58
CMinimap::X
int X
Definition: minimap.h:78
CMinimap::Destroy
void Destroy()
Definition: minimap.cpp:491
CMinimap::H
int H
Definition: minimap.h:81
CMinimap::TilePosToScreenPos
PixelPos TilePosToScreenPos(const Vec2i &tilePos) const
Definition: minimap.cpp:481
CMinimap::Y
int Y
Definition: minimap.h:79
CMinimap::XOffset
int XOffset
Definition: minimap.h:82
MinimapSurface
SDL_Surface * MinimapSurface
Definition: minimap.cpp:72
Settings
Definition: settings.h:230
CMinimap::UpdateSeenXY
void UpdateSeenXY(const Vec2i &)
Definition: minimap.h:65
CMinimap::ScreenToTilePos
Vec2i ScreenToTilePos(const PixelPos &screenPos) const
Definition: minimap.cpp:465
CMinimap
Definition: minimap.h:46
CMinimap::W
int W
Definition: minimap.h:80
CMinimap::YOffset
int YOffset
Definition: minimap.h:83
CMinimap::Draw
void Draw() const
Definition: minimap.cpp:450
CMinimap::WithTerrain
bool WithTerrain
Definition: minimap.h:84
CMinimap::Update
void Update()
Definition: minimap.cpp:375
CMinimap::UpdateXY
void UpdateXY(const Vec2i &pos)
Definition: minimap.cpp:243
color.h
CMinimap::ShowSelected
bool ShowSelected
Definition: minimap.h:85
CMinimap::AddEvent
void AddEvent(const Vec2i &pos, IntColor color)
Definition: minimap.cpp:532
(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.