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