1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00
vcmi/client/widgets/CArtifactsOfHeroBase.h

70 lines
2.6 KiB
C++
Raw Normal View History

2023-04-23 14:10:35 +02:00
/*
* CArtifactsOfHeroBase.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 "CArtifactHolder.h"
class CArtifactsOfHeroBase : public CIntObject
{
protected:
using ArtPlacePtr = std::shared_ptr<CHeroArtPlace>;
2023-09-17 17:40:14 +02:00
using BpackScrollFunctor = std::function<void(int)>;
2023-04-23 14:10:35 +02:00
public:
using ArtPlaceMap = std::map<ArtifactPosition, ArtPlacePtr>;
2023-09-17 17:40:14 +02:00
using ClickFunctor = std::function<void(CArtifactsOfHeroBase&, CHeroArtPlace&)>;
2023-07-06 21:14:12 +02:00
using PutBackPickedArtCallback = std::function<void()>;
2023-04-23 14:10:35 +02:00
2023-09-17 17:40:14 +02:00
ClickFunctor leftClickCallback;
ClickFunctor showPopupCallback;
2023-04-23 14:10:35 +02:00
CArtifactsOfHeroBase();
2023-07-06 21:14:12 +02:00
virtual void putBackPickedArtifact();
virtual void setPutBackPickedArtifactCallback(PutBackPickedArtCallback callback);
2023-04-23 14:10:35 +02:00
virtual void leftClickArtPlace(CHeroArtPlace & artPlace);
virtual void rightClickArtPlace(CHeroArtPlace & artPlace);
virtual void setHero(const CGHeroInstance * hero);
virtual const CGHeroInstance * getHero() const;
virtual void scrollBackpack(int offset);
virtual void markPossibleSlots(const CArtifactInstance * art, bool assumeDestRemoved = true);
virtual void unmarkSlots();
virtual ArtPlacePtr getArtPlace(const ArtifactPosition & slot);
virtual void updateWornSlots();
virtual void updateBackpackSlots();
virtual void updateSlot(const ArtifactPosition & slot);
virtual const CArtifactInstance * getPickedArtifact();
protected:
2023-07-06 20:37:18 +02:00
const CGHeroInstance * curHero;
2023-04-23 14:10:35 +02:00
ArtPlaceMap artWorn;
std::vector<ArtPlacePtr> backpack;
std::shared_ptr<CButton> leftBackpackRoll;
std::shared_ptr<CButton> rightBackpackRoll;
int backpackPos; // Position to display artifacts in heroes backpack
2023-07-06 21:14:12 +02:00
PutBackPickedArtCallback putBackPickedArtCallback;
2023-04-23 14:10:35 +02:00
const std::vector<Point> slotPos =
{
Point(509,30), Point(567,240), Point(509,80), //0-2
Point(383,68), Point(564,183), Point(509,130), //3-5
Point(431,68), Point(610,183), Point(515,295), //6-8
Point(383,143), Point(399,194), Point(415,245), //9-11
Point(431,296), Point(564,30), Point(610,30), //12-14
Point(610,76), Point(610,122), Point(610,310), //15-17
Point(381,296) //18
};
2023-09-17 17:40:14 +02:00
virtual void init(CHeroArtPlace::ClickFunctor lClickCallback, CHeroArtPlace::ClickFunctor showPopupCallback,
const Point & position, BpackScrollFunctor scrollCallback);
2023-04-23 14:10:35 +02:00
// Assigns an artifacts to an artifact place depending on it's new slot ID
virtual void setSlotData(ArtPlacePtr artPlace, const ArtifactPosition & slot, const CArtifactSet & artSet);
virtual void scrollBackpackForArtSet(int offset, const CArtifactSet & artSet);
};