1 /*
2 Copyright (C) 2005 David Kamphausen <david.kamphausen@web.de>
3 
4 This program 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 This program 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 this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18 #ifndef __lc_minimap_h__
19 #define __lc_minimap_h__
20 
21 #include "gui/Component.hpp"
22 #include "gui/Color.hpp"
23 #include "lincity/lin-city.h"
24 #include "gui/Texture.hpp"
25 #include "MapPoint.hpp"
26 
27 #include <memory>
28 
29 class XmlReader;
30 class Button;
31 class CheckButton;
32 
33 class MiniMap:public Component
34 {
35 public:
36     enum DisplayMode {NORMAL,POLLUTION,UB40,STARVE,POWER,FIRE,CRICKET,HEALTH,COAL,TRAFFIC,MAX};
37 
38     MiniMap();
39     ~MiniMap();
40 
41     void parse(XmlReader& reader);
42 
43     virtual void draw(Painter &painter);
44     virtual void event(const Event& event);
45 
46     void setGameViewCorners(const MapPoint& upperLeft,
47             const MapPoint& upperRight, const MapPoint& lowerRight,
48             const MapPoint& lowerLeft);
49 
50     Color getColor(int x,int y) const;
51     Color getColorNormal(int x,int y) const;
52     void showMpsEnv( MapPoint tile );
53     void hideMpsEnv();
54 
55     void switchView(const std::string& viewname);
56 
57 private:
58     void mapViewButtonClicked(CheckButton* button, int);
59     void speedButtonClicked(CheckButton* button, int);
60     void zoomInButtonClicked(Button* button);
61     void zoomOutButtonClicked(Button* button);
62 
63     void switchButton(CheckButton* button, int);
64     void switchMapViewButton(const std::string &pName);
65 
66     void attachButtons();
67     Component *findRoot(Component *c);
68     Vector2 mapPointToVector(MapPoint p);
69 
70     Vector2 gameViewPoints[ 4 ];
71     short mappointoldtype[WORLD_SIDE_LEN][WORLD_SIDE_LEN];
72 
73     DisplayMode mMode;
74 
75     int tilesize;
76     int border;
77 
78     std::vector<CheckButton*> switchButtons;
79     std::auto_ptr<Texture> mTexture;
80 
81     int mpsXOld, mpsYOld, mpsStyleOld;
82 
83     bool mFullRefresh;
84     bool alreadyAttached;
85     bool inside;
86     // used for the middle mouse button popup to remember last visible tab
87     std::string lastTabName;
88 };
89 
90 MiniMap* getMiniMap();
91 
92 #endif
93