mirror of
https://github.com/vcmi/vcmi.git
synced 2025-05-13 22:06:58 +02:00
Quest Log: cleanup minimap code
Usage of shared_ptr suggested by @alexwins
This commit is contained in:
parent
5a5c126f0e
commit
8beed60815
@ -72,26 +72,21 @@ CMinimap (position),
|
|||||||
void CQuestMinimap::addQuestMarks (const QuestInfo * q)
|
void CQuestMinimap::addQuestMarks (const QuestInfo * q)
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||||
for (auto icon : icons)
|
|
||||||
delete icon;
|
|
||||||
icons.clear();
|
icons.clear();
|
||||||
|
|
||||||
int3 tile;
|
int3 tile;
|
||||||
if (q->obj)
|
if (q->obj)
|
||||||
{
|
|
||||||
tile = q->obj->pos;
|
tile = q->obj->pos;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
tile = q->tile;
|
tile = q->tile;
|
||||||
}
|
|
||||||
int x,y;
|
int x,y;
|
||||||
minimap->tileToPixels (tile, x, y);
|
minimap->tileToPixels (tile, x, y);
|
||||||
|
|
||||||
if (level != tile.z)
|
if (level != tile.z)
|
||||||
setLevel(tile.z);
|
setLevel(tile.z);
|
||||||
|
|
||||||
CQuestIcon * pic = new CQuestIcon ("VwSymbol.def", 3, x, y);
|
auto pic = make_shared<CQuestIcon>("VwSymbol.def", 3, x, y);
|
||||||
|
|
||||||
pic->moveBy (Point ( -pic->pos.w/2, -pic->pos.h/2));
|
pic->moveBy (Point ( -pic->pos.w/2, -pic->pos.h/2));
|
||||||
pic->callback = std::bind (&CQuestMinimap::iconClicked, this);
|
pic->callback = std::bind (&CQuestMinimap::iconClicked, this);
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
class CQuestMinimap : public CMinimap
|
class CQuestMinimap : public CMinimap
|
||||||
{
|
{
|
||||||
std::vector <CQuestIcon *> icons;
|
std::vector <shared_ptr<CQuestIcon>> icons;
|
||||||
|
|
||||||
void clickLeft(tribool down, bool previousState){}; //minimap ignores clicking on its surface
|
void clickLeft(tribool down, bool previousState){}; //minimap ignores clicking on its surface
|
||||||
void iconClicked();
|
void iconClicked();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user