CTradeBase.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * CTradeBase.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "TradePanels.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class IMarket;
  14. class CGHeroInstance;
  15. VCMI_LIB_NAMESPACE_END
  16. class CButton;
  17. class CSlider;
  18. class CTradeBase
  19. {
  20. public:
  21. const IMarket * market;
  22. const CGHeroInstance * hero;
  23. //all indexes: 1 = left, 0 = right
  24. std::array<std::vector<std::shared_ptr<CTradeableItem>>, 2> items;
  25. std::shared_ptr<TradePanelBase> leftTradePanel;
  26. std::shared_ptr<TradePanelBase> rightTradePanel;
  27. //highlighted items (nullptr if no highlight)
  28. std::shared_ptr<CTradeableItem> hLeft;
  29. std::shared_ptr<CTradeableItem> hRight;
  30. std::shared_ptr<CButton> deal;
  31. std::shared_ptr<CSlider> offerSlider;
  32. std::vector<std::shared_ptr<CLabel>> labels;
  33. std::vector<std::shared_ptr<CButton>> buttons;
  34. std::vector<std::shared_ptr<CTextBox>> texts;
  35. CTradeBase(const IMarket * market, const CGHeroInstance * hero);
  36. void removeItems(const std::set<std::shared_ptr<CTradeableItem>> & toRemove);
  37. void removeItem(std::shared_ptr<CTradeableItem> item);
  38. void getEmptySlots(std::set<std::shared_ptr<CTradeableItem>> & toRemove);
  39. virtual void makeDeal() = 0;
  40. virtual void deselect();
  41. virtual void onSlotClickPressed(const std::shared_ptr<CTradeableItem> & newSlot, std::shared_ptr<CTradeableItem> & hCurSlot);
  42. };
  43. // Market subclasses
  44. class CExperienceAltar : virtual public CTradeBase, virtual public CIntObject
  45. {
  46. public:
  47. std::shared_ptr<CLabel> expToLevel;
  48. std::shared_ptr<CLabel> expForHero;
  49. std::shared_ptr<CButton> sacrificeAllButton;
  50. const Point dealButtonPos = Point(269, 520);
  51. CExperienceAltar();
  52. virtual void sacrificeAll() = 0;
  53. virtual TExpType calcExpAltarForHero() = 0;
  54. };
  55. class CCreaturesSelling : virtual public CTradeBase, virtual public CIntObject
  56. {
  57. public:
  58. CCreaturesSelling();
  59. bool slotDeletingCheck(const std::shared_ptr<CTradeableItem> & slot);
  60. void updateSubtitle();
  61. };