Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
map.h
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
3 // * Copyright (C) 2012 Polish Portal of Colobot (PPC)
4 // *
5 // * This program is free software: you can redistribute it and/or modify
6 // * it under the terms of the GNU General Public License as published by
7 // * the Free Software Foundation, either version 3 of the License, or
8 // * (at your option) any later version.
9 // *
10 // * This program is distributed in the hope that it will be useful,
11 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // * GNU General Public License for more details.
14 // *
15 // * You should have received a copy of the GNU General Public License
16 // * along with this program. If not, see http://www.gnu.org/licenses/.
17 
18 // map.h
19 
20 #pragma once
21 
22 
23 #include "ui/control.h"
24 
25 #include "common/event.h"
26 
28 #include "graphics/engine/water.h"
29 #include "graphics/engine/engine.h"
30 #include "graphics/core/device.h"
31 #include "graphics/core/vertex.h"
32 
33 #include "math/geometry.h"
34 
35 #include "object/object.h"
36 #include "object/robotmain.h"
37 
38 
39 namespace Ui {
40 
41 const int MAPMAXOBJECT = 100;
42 
43 enum MapColor
44 {
45  MAPCOLOR_NULL,
46  MAPCOLOR_BASE,
47  MAPCOLOR_FIX,
48  MAPCOLOR_MOVE,
49  MAPCOLOR_ALIEN,
50  MAPCOLOR_WAYPOINTb,
51  MAPCOLOR_WAYPOINTr,
52  MAPCOLOR_WAYPOINTg,
53  MAPCOLOR_WAYPOINTy,
54  MAPCOLOR_WAYPOINTv,
55  MAPCOLOR_BBOX,
56 };
57 
58 struct MapObject
59 {
60  char bUsed;
61  CObject* object;
62  MapColor color;
63  ObjectType type;
64  Math::Point pos;
65  float dir;
66 };
67 
68 
69 
70 class CMap : public CControl
71 {
72 public:
73  CMap();
74  ~CMap();
75 
76  bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
77  bool EventProcess(const Event &event);
78  void Draw();
79 
80  void UpdateTerrain();
81  void UpdateTerrain(int bx, int by, int ex, int ey);
82 
83  void SetFixImage(const char *filename);
84  bool GetFixImage();
85 
86  void SetOffset(float ox, float oy);
87  void SetAngle(float angle);
88  void SetMode(int mode);
89  void SetToy(bool bToy);
90  void SetDebug(bool bDebug);
91 
92  void SetZoom(float value);
93  float GetZoom();
94 
95  void SetEnable(bool bEnable);
96  bool GetEnable();
97 
98  void SetFloorColor(Gfx::Color color);
99  void SetWaterColor(Gfx::Color color);
100 
101  void FlushObject();
102  void UpdateObject(CObject* pObj);
103 
104  CObject* DetectObject(Math::Point pos, bool &bInMap);
105  void SetHighlight(CObject* pObj);
106 
107 protected:
108  Math::Point AdjustOffset(Math::Point offset);
109  void SelectObject(Math::Point pos);
110  Math::Point MapInter(Math::Point pos, float dir);
111  void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color);
112  void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite);
113  void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite);
114  void DrawHighlight(Math::Point pos);
115  void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2);
116  void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2);
117  void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom);
118 
119 protected:
120  Gfx::CTerrain* m_terrain;
121  Gfx::CWater* m_water;
122  CRobotMain* m_main;
123 
124  bool m_bEnable;
125  float m_time;
126  float m_half;
127  float m_zoom;
128  Math::Point m_offset;
129  float m_angle;
130  Gfx::Color m_floorColor;
131  Gfx::Color m_waterColor;
132  MapObject m_map[MAPMAXOBJECT];
133  int m_totalFix;
134  int m_totalMove;
135  int m_highlightRank;
136  Math::Point m_mapPos;
137  Math::Point m_mapDim;
138  bool m_bRadar;
139  char m_fixImage[100];
140  int m_mode;
141  bool m_bToy;
142  bool m_bDebug;
143 };
144 
145 
146 }
147 
Main graphics engine - CEngine class.
Definition: map.h:70
Terrain rendering - CTerrain class.
CRobotMain - main class of Colobot game engine.
Definition: robotmain.h:196
ObjectType
Type of game object.
Definition: object.h:46
Definition: map.h:58
Vertex structs.
2D point
Definition: point.h:46
Terrain loader/generator and manager.
Definition: terrain.h:220
CObject - base class for all game objects.
Event types, structs and event queue.
Water manager/renderer.
Definition: water.h:116
Abstract graphics device - CDevice class and related structs/enums.
Math functions related to 3D geometry calculations, transformations, etc.
RGBA color.
Definition: color.h:35
EventType
Type of event message.
Definition: event.h:35
Event sent by system, interface or game.
Definition: event.h:686
Water rendering - CWater class.
Definition: object.h:352
Definition: control.h:64