2023-04-23 14:10:35 +02:00
|
|
|
/*
|
|
|
|
* CWindowWithArtifacts.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
|
|
|
|
|
2024-04-23 15:21:45 +02:00
|
|
|
#include "../widgets/CArtifactsOfHeroMain.h"
|
|
|
|
#include "../widgets/CArtifactsOfHeroKingdom.h"
|
|
|
|
#include "../widgets/CArtifactsOfHeroAltar.h"
|
|
|
|
#include "../widgets/CArtifactsOfHeroMarket.h"
|
|
|
|
#include "../widgets/CArtifactsOfHeroBackpack.h"
|
|
|
|
#include "CWindowObject.h"
|
2023-04-23 14:10:35 +02:00
|
|
|
|
2024-04-23 15:21:45 +02:00
|
|
|
class CWindowWithArtifacts : virtual public CWindowObject
|
2023-04-23 14:10:35 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
using CArtifactsOfHeroPtr = std::variant<
|
|
|
|
std::weak_ptr<CArtifactsOfHeroMarket>,
|
|
|
|
std::weak_ptr<CArtifactsOfHeroAltar>,
|
|
|
|
std::weak_ptr<CArtifactsOfHeroKingdom>,
|
2023-07-06 21:14:12 +02:00
|
|
|
std::weak_ptr<CArtifactsOfHeroMain>,
|
2023-11-07 14:17:34 +02:00
|
|
|
std::weak_ptr<CArtifactsOfHeroBackpack>,
|
|
|
|
std::weak_ptr<CArtifactsOfHeroQuickBackpack>>;
|
2023-07-16 20:16:12 +02:00
|
|
|
using CloseCallback = std::function<void()>;
|
2023-04-23 14:10:35 +02:00
|
|
|
|
2024-04-23 19:26:21 +02:00
|
|
|
std::vector<CArtifactsOfHeroPtr> artSets;
|
|
|
|
CloseCallback closeCallback;
|
|
|
|
|
2024-04-16 16:45:31 +02:00
|
|
|
explicit CWindowWithArtifacts(const std::vector<CArtifactsOfHeroPtr> * artSets = nullptr);
|
2024-04-23 19:26:21 +02:00
|
|
|
void addSet(CArtifactsOfHeroPtr newArtSet);
|
|
|
|
void addSetAndCallbacks(CArtifactsOfHeroPtr newArtSet);
|
|
|
|
void addCloseCallback(const CloseCallback & callback);
|
2023-04-23 14:10:35 +02:00
|
|
|
const CGHeroInstance * getHeroPickedArtifact();
|
|
|
|
const CArtifactInstance * getPickedArtifact();
|
2024-04-23 19:26:21 +02:00
|
|
|
void clickPressedArtPlaceHero(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
|
|
|
|
void showPopupArtPlaceHero(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
|
|
|
|
void gestureArtPlaceHero(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
|
2024-04-23 15:21:45 +02:00
|
|
|
void activate() override;
|
|
|
|
void deactivate() override;
|
2024-04-27 01:08:47 +02:00
|
|
|
void enableArtifactsCostumeSwitcher() const;
|
2023-04-23 14:10:35 +02:00
|
|
|
|
2024-04-23 12:49:35 +02:00
|
|
|
virtual void artifactRemoved(const ArtifactLocation & artLoc);
|
|
|
|
virtual void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw);
|
|
|
|
virtual void artifactDisassembled(const ArtifactLocation & artLoc);
|
|
|
|
virtual void artifactAssembled(const ArtifactLocation & artLoc);
|
2023-04-23 14:10:35 +02:00
|
|
|
|
2023-09-18 21:58:08 +02:00
|
|
|
protected:
|
2024-04-23 19:26:21 +02:00
|
|
|
void update() const;
|
2023-04-23 14:10:35 +02:00
|
|
|
std::optional<std::tuple<const CGHeroInstance*, const CArtifactInstance*>> getState();
|
2024-04-23 19:26:21 +02:00
|
|
|
std::optional<CArtifactsOfHeroPtr> findAOHbyRef(const CArtifactsOfHeroBase & artsInst);
|
2023-09-03 20:41:00 +02:00
|
|
|
void markPossibleSlots();
|
2024-04-23 19:26:21 +02:00
|
|
|
bool checkSpecialArts(const CArtifactInstance & artInst, const CGHeroInstance * hero, bool isTrade) const;
|
2024-04-16 16:45:31 +02:00
|
|
|
void setCursorAnimation(const CArtifactInstance & artInst);
|
2023-04-23 14:10:35 +02:00
|
|
|
};
|