2017-07-13 10:26:03 +02:00
|
|
|
/*
|
2023-02-01 16:42:03 +02:00
|
|
|
* CMinimap.h, part of VCMI engine
|
2017-07-13 10:26:03 +02:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2012-06-13 16:04:06 +03:00
|
|
|
#pragma once
|
|
|
|
|
2023-02-01 20:42:06 +02:00
|
|
|
#include "../gui/CIntObject.h"
|
|
|
|
#include "../../lib/GameConstants.h"
|
2023-02-10 15:29:30 +02:00
|
|
|
#include "../render/Canvas.h"
|
2012-06-13 16:04:06 +03:00
|
|
|
|
2023-02-12 19:58:31 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
2023-02-10 15:29:30 +02:00
|
|
|
class ColorRGBA;
|
2023-02-12 19:58:31 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2012-06-13 16:04:06 +03:00
|
|
|
class CMinimap;
|
|
|
|
|
|
|
|
class CMinimapInstance : public CIntObject
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
CMinimap * parent;
|
2023-02-10 15:29:30 +02:00
|
|
|
std::unique_ptr<Canvas> minimap;
|
2012-06-13 16:04:06 +03:00
|
|
|
int level;
|
|
|
|
|
|
|
|
//get color of selected tile on minimap
|
2023-02-10 15:29:30 +02:00
|
|
|
ColorRGBA getTileColor(const int3 & pos) const;
|
2012-06-13 16:04:06 +03:00
|
|
|
|
2023-02-10 15:29:30 +02:00
|
|
|
void redrawMinimap();
|
2012-06-13 16:04:06 +03:00
|
|
|
public:
|
|
|
|
CMinimapInstance(CMinimap * parent, int level);
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
void showAll(SDL_Surface * to) override;
|
|
|
|
void refreshTile(const int3 & pos);
|
2012-06-13 16:04:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Minimap which is displayed at the right upper corner of adventure map
|
|
|
|
class CMinimap : public CIntObject
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CPicture> aiShield; //the graphic displayed during AI turn
|
|
|
|
std::shared_ptr<CMinimapInstance> minimap;
|
2023-02-23 19:46:41 +02:00
|
|
|
Rect screenArea;
|
2012-06-13 16:04:06 +03:00
|
|
|
int level;
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void clickLeft(tribool down, bool previousState) override;
|
|
|
|
void clickRight(tribool down, bool previousState) override;
|
|
|
|
void hover (bool on) override;
|
2023-02-02 15:49:23 +02:00
|
|
|
void mouseMoved (const Point & cursorPosition) override;
|
2012-06-13 16:04:06 +03:00
|
|
|
|
2023-02-10 15:29:30 +02:00
|
|
|
/// relocates center of adventure map screen to currently hovered tile
|
2012-07-07 11:45:45 +03:00
|
|
|
void moveAdvMapSelection();
|
|
|
|
|
2023-02-10 15:29:30 +02:00
|
|
|
protected:
|
|
|
|
/// computes coordinates of tile below cursor pos
|
|
|
|
int3 pixelToTile(const Point & cursorPos) const;
|
|
|
|
|
|
|
|
/// computes position of tile within minimap instance
|
|
|
|
Point tileToPixels(const int3 & position) const;
|
|
|
|
|
2012-06-13 16:04:06 +03:00
|
|
|
public:
|
2023-02-10 15:29:30 +02:00
|
|
|
explicit CMinimap(const Rect & position);
|
2012-06-13 16:04:06 +03:00
|
|
|
|
2023-02-23 19:46:41 +02:00
|
|
|
void onMapViewMoved(const Rect & visibleArea, int mapLevel);
|
2012-06-13 16:04:06 +03:00
|
|
|
void update();
|
|
|
|
void setAIRadar(bool on);
|
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
void showAll(SDL_Surface * to) override;
|
2012-06-13 16:04:06 +03:00
|
|
|
|
2023-02-10 15:29:30 +02:00
|
|
|
void updateTile(const int3 &pos);
|
2012-06-13 16:04:06 +03:00
|
|
|
};
|
|
|
|
|