/* * CTradeBase.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 "TradePanels.h" VCMI_LIB_NAMESPACE_BEGIN class IMarket; class CGHeroInstance; VCMI_LIB_NAMESPACE_END class CButton; class CSlider; class CTradeBase { public: const IMarket * market; const CGHeroInstance * hero; //all indexes: 1 = left, 0 = right std::array>, 2> items; std::shared_ptr bidTradePanel; std::shared_ptr offerTradePanel; //highlighted items (nullptr if no highlight) std::shared_ptr hLeft; std::shared_ptr hRight; std::shared_ptr deal; std::shared_ptr offerSlider; std::shared_ptr maxAmount; std::vector> labels; std::vector> texts; CTradeBase(const IMarket * market, const CGHeroInstance * hero); void removeItems(const std::set> & toRemove); void removeItem(std::shared_ptr item); void getEmptySlots(std::set> & toRemove); virtual void makeDeal() = 0; virtual void deselect(); virtual void onSlotClickPressed(const std::shared_ptr & newSlot, std::shared_ptr & hCurSlot); virtual void updateSlots() {}; // TODO make pure virtual }; // Market subclasses class CExperienceAltar : virtual public CTradeBase, virtual public CIntObject { public: std::shared_ptr expToLevel; std::shared_ptr expForHero; std::shared_ptr sacrificeAllButton; const Point dealButtonPos = Point(269, 520); CExperienceAltar(); virtual void sacrificeAll() = 0; virtual TExpType calcExpAltarForHero() = 0; }; class CCreaturesSelling : virtual public CTradeBase, virtual public CIntObject { public: CCreaturesSelling(); bool slotDeletingCheck(const std::shared_ptr & slot); void updateSubtitle(); void updateSlots() override; }; class CResourcesBuying : virtual public CTradeBase, virtual public CIntObject { public: CResourcesBuying(TradePanelBase::UpdateSlotsFunctor callback); void updateSubtitles(EMarketMode marketMode); }; class CResourcesSelling : virtual public CTradeBase, virtual public CIntObject { public: CResourcesSelling(); void updateSlots() override; }; class CMarketMisc : virtual public CTradeBase, virtual public CIntObject { public: struct SelectionParamOneSide { std::string text; int imageIndex; }; using SelectionParams = std::tuple, std::optional>; using SelectionParamsFunctor = std::function; CMarketMisc(SelectionParamsFunctor callback); void deselect() override; void updateSelected(); protected: int bidQty; int offerQty; SelectionParamsFunctor selectionParamsCallback; };