1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00
vcmi/client/adventureMap/CMinimap.h

74 lines
1.7 KiB
C
Raw Normal View History

/*
2023-02-01 16:42:03 +02:00
* CMinimap.h, part of VCMI engine
*
* 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
*
*/
#pragma once
#include "../gui/CIntObject.h"
#include "../../lib/GameConstants.h"
2023-02-10 15:29:30 +02:00
#include "../render/Canvas.h"
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
class CMinimap;
class CMinimapInstance : public CIntObject
{
CMinimap * parent;
2023-02-10 15:29:30 +02:00
std::unique_ptr<Canvas> minimap;
int level;
//get color of selected tile on minimap
2023-02-10 15:29:30 +02:00
ColorRGBA getTileColor(const int3 & pos) const;
2023-02-10 15:29:30 +02:00
void redrawMinimap();
public:
CMinimapInstance(CMinimap * parent, int level);
void showAll(SDL_Surface * to) override;
void refreshTile(const int3 & pos);
};
/// Minimap which is displayed at the right upper corner of adventure map
class CMinimap : public CIntObject
{
std::shared_ptr<CPicture> aiShield; //the graphic displayed during AI turn
std::shared_ptr<CMinimapInstance> minimap;
int level;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void hover (bool on) override;
void mouseMoved (const Point & cursorPosition) override;
2023-02-10 15:29:30 +02:00
/// relocates center of adventure map screen to currently hovered tile
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;
public:
2023-02-10 15:29:30 +02:00
explicit CMinimap(const Rect & position);
void update();
void setLevel(int level);
void setAIRadar(bool on);
void showAll(SDL_Surface * to) override;
2023-02-10 15:29:30 +02:00
void updateTile(const int3 &pos);
};