2014-10-14 13:11:37 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Colobot: Gold Edition source code
|
2015-08-22 14:40:02 +00:00
|
|
|
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
|
|
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
2014-10-14 13:11:37 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see http://gnu.org/licenses
|
|
|
|
*/
|
2012-06-26 20:23:05 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-08-06 11:25:24 +00:00
|
|
|
#include "ui/controls/control.h"
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2012-09-18 22:04:21 +00:00
|
|
|
#include "common/event.h"
|
2012-06-26 20:23:05 +00:00
|
|
|
|
2015-08-02 11:09:48 +00:00
|
|
|
#include "object/object_type.h"
|
2012-08-21 18:53:39 +00:00
|
|
|
|
2015-08-02 11:09:48 +00:00
|
|
|
class CObject;
|
2012-08-21 18:53:39 +00:00
|
|
|
|
2015-08-02 11:09:48 +00:00
|
|
|
namespace Gfx
|
|
|
|
{
|
|
|
|
class CWater;
|
|
|
|
class CTerrain;
|
|
|
|
}
|
2013-02-16 21:37:43 +00:00
|
|
|
|
2012-08-21 18:53:39 +00:00
|
|
|
|
2015-08-02 09:40:47 +00:00
|
|
|
namespace Ui
|
|
|
|
{
|
2012-06-26 20:23:05 +00:00
|
|
|
|
|
|
|
const int MAPMAXOBJECT = 100;
|
|
|
|
|
|
|
|
enum MapColor
|
|
|
|
{
|
|
|
|
MAPCOLOR_NULL,
|
|
|
|
MAPCOLOR_BASE,
|
|
|
|
MAPCOLOR_FIX,
|
|
|
|
MAPCOLOR_MOVE,
|
|
|
|
MAPCOLOR_ALIEN,
|
|
|
|
MAPCOLOR_WAYPOINTb,
|
|
|
|
MAPCOLOR_WAYPOINTr,
|
|
|
|
MAPCOLOR_WAYPOINTg,
|
|
|
|
MAPCOLOR_WAYPOINTy,
|
|
|
|
MAPCOLOR_WAYPOINTv,
|
|
|
|
MAPCOLOR_BBOX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MapObject
|
|
|
|
{
|
2015-08-11 20:47:07 +00:00
|
|
|
bool bUsed = false;
|
|
|
|
CObject* object = nullptr;
|
|
|
|
MapColor color = MAPCOLOR_NULL;
|
|
|
|
ObjectType type = OBJECT_NULL;
|
|
|
|
Math::Point pos;
|
|
|
|
float dir = 0.0f;
|
2012-06-26 20:23:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CMap : public CControl
|
|
|
|
{
|
2013-05-26 15:47:54 +00:00
|
|
|
public:
|
|
|
|
CMap();
|
|
|
|
~CMap();
|
|
|
|
|
2015-08-17 19:53:28 +00:00
|
|
|
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) override;
|
|
|
|
bool EventProcess(const Event &event) override;
|
|
|
|
void Draw() override;
|
2013-05-26 15:47:54 +00:00
|
|
|
|
|
|
|
void UpdateTerrain();
|
|
|
|
void UpdateTerrain(int bx, int by, int ex, int ey);
|
|
|
|
|
2015-08-11 20:47:07 +00:00
|
|
|
void SetFixImage(const std::string& filename);
|
2013-05-26 15:47:54 +00:00
|
|
|
bool GetFixImage();
|
|
|
|
|
|
|
|
void SetOffset(float ox, float oy);
|
|
|
|
void SetAngle(float angle);
|
|
|
|
void SetMode(int mode);
|
|
|
|
void SetToy(bool bToy);
|
|
|
|
void SetDebug(bool bDebug);
|
|
|
|
|
|
|
|
void SetZoom(float value);
|
|
|
|
float GetZoom();
|
|
|
|
|
|
|
|
void SetEnable(bool bEnable);
|
|
|
|
bool GetEnable();
|
|
|
|
|
|
|
|
void SetFloorColor(Gfx::Color color);
|
|
|
|
void SetWaterColor(Gfx::Color color);
|
|
|
|
|
|
|
|
void FlushObject();
|
|
|
|
void UpdateObject(CObject* pObj);
|
|
|
|
|
|
|
|
CObject* DetectObject(Math::Point pos, bool &bInMap);
|
|
|
|
void SetHighlight(CObject* pObj);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Math::Point AdjustOffset(Math::Point offset);
|
|
|
|
void SelectObject(Math::Point pos);
|
|
|
|
Math::Point MapInter(Math::Point pos, float dir);
|
|
|
|
void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color);
|
|
|
|
void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite);
|
|
|
|
void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite);
|
|
|
|
void DrawHighlight(Math::Point pos);
|
|
|
|
void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2);
|
|
|
|
void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2);
|
|
|
|
void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Gfx::CTerrain* m_terrain;
|
|
|
|
Gfx::CWater* m_water;
|
|
|
|
CRobotMain* m_main;
|
|
|
|
|
|
|
|
bool m_bEnable;
|
|
|
|
float m_time;
|
|
|
|
float m_half;
|
|
|
|
float m_zoom;
|
|
|
|
Math::Point m_offset;
|
|
|
|
float m_angle;
|
|
|
|
Gfx::Color m_floorColor;
|
|
|
|
Gfx::Color m_waterColor;
|
|
|
|
MapObject m_map[MAPMAXOBJECT];
|
|
|
|
int m_totalFix;
|
|
|
|
int m_totalMove;
|
|
|
|
int m_highlightRank;
|
|
|
|
Math::Point m_mapPos;
|
|
|
|
Math::Point m_mapDim;
|
|
|
|
bool m_bRadar;
|
2015-08-11 20:47:07 +00:00
|
|
|
std::string m_fixImage;
|
2013-05-26 15:47:54 +00:00
|
|
|
int m_mode;
|
|
|
|
bool m_bToy;
|
|
|
|
bool m_bDebug;
|
2012-06-26 20:23:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-08-21 18:53:39 +00:00
|
|
|
}
|