2014-07-13 16:31:00 +03:00
|
|
|
/*
|
|
|
|
* CTradeWindow.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
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-12-04 23:21:49 +02:00
|
|
|
#include "../widgets/markets/CTradeBase.h"
|
2023-04-23 14:10:35 +02:00
|
|
|
#include "../widgets/CWindowWithArtifacts.h"
|
2017-07-13 10:26:03 +02:00
|
|
|
#include "CWindowObject.h"
|
2022-07-26 15:07:42 +02:00
|
|
|
|
2014-07-15 10:14:49 +03:00
|
|
|
class CSlider;
|
2018-04-07 13:34:11 +02:00
|
|
|
class CGStatusBar;
|
2014-07-13 16:31:00 +03:00
|
|
|
|
2023-11-05 00:53:37 +02:00
|
|
|
class CTradeWindow : public CTradeBase, public CWindowObject, public CWindowWithArtifacts //base for markets and altar of sacrifice
|
2014-07-13 16:31:00 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
EType itemsType[2];
|
|
|
|
|
2023-08-19 20:43:50 +02:00
|
|
|
EMarketMode mode;
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CButton> ok;
|
|
|
|
std::shared_ptr<CButton> max;
|
|
|
|
|
|
|
|
std::shared_ptr<CSlider> slider; //for choosing amount to be exchanged
|
2014-07-13 16:31:00 +03:00
|
|
|
bool readyToTrade;
|
|
|
|
|
2023-09-28 00:17:05 +02:00
|
|
|
CTradeWindow(const ImagePath & bgName, const IMarket * Market, const CGHeroInstance * Hero, const std::function<void()> & onWindowClosed, EMarketMode Mode); //c
|
2014-07-13 16:31:00 +03:00
|
|
|
|
2023-06-02 15:42:18 +02:00
|
|
|
void showAll(Canvas & to) override;
|
2023-10-07 01:44:37 +02:00
|
|
|
void close() override;
|
2014-07-13 16:31:00 +03:00
|
|
|
|
|
|
|
void initSubs(bool Left);
|
|
|
|
void initTypes();
|
|
|
|
void initItems(bool Left);
|
2023-08-19 20:43:50 +02:00
|
|
|
void setMode(EMarketMode Mode); //mode setter
|
2014-07-13 16:31:00 +03:00
|
|
|
|
2023-11-13 17:43:02 +02:00
|
|
|
void artifactSelected(CArtPlace * slot); //used when selling artifacts -> called when user clicked on artifact slot
|
2014-07-13 16:31:00 +03:00
|
|
|
virtual void selectionChanged(bool side) = 0; //true == left
|
|
|
|
virtual Point selectionOffset(bool Left) const = 0;
|
2023-11-05 02:01:23 +02:00
|
|
|
virtual std::string updateSlotSubtitle(bool Left) const = 0;
|
|
|
|
virtual void updateGarrison() = 0;
|
2014-07-13 16:31:00 +03:00
|
|
|
virtual void artifactsChanged(bool left) = 0;
|
2018-04-07 13:34:11 +02:00
|
|
|
protected:
|
2023-09-28 00:17:05 +02:00
|
|
|
std::function<void()> onWindowClosed;
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CGStatusBar> statusBar;
|
2022-12-02 18:52:05 +02:00
|
|
|
std::vector<std::shared_ptr<CPicture>> images;
|
2014-07-13 16:31:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class CMarketplaceWindow : public CTradeWindow
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CLabel> titleLabel;
|
2023-07-06 20:37:18 +02:00
|
|
|
std::shared_ptr<CArtifactsOfHeroMarket> arts;
|
2018-04-07 13:34:11 +02:00
|
|
|
|
2023-08-19 20:43:50 +02:00
|
|
|
bool printButtonFor(EMarketMode M) const;
|
2014-07-13 16:31:00 +03:00
|
|
|
|
2023-08-23 14:07:50 +02:00
|
|
|
ImagePath getBackgroundForMode(EMarketMode mode);
|
2014-07-13 16:31:00 +03:00
|
|
|
public:
|
|
|
|
int r1, r2; //suggested amounts of traded resources
|
|
|
|
bool madeTransaction; //if player made at least one transaction
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CTextBox> traderText;
|
2014-07-13 16:31:00 +03:00
|
|
|
|
|
|
|
void setMax();
|
|
|
|
void sliderMoved(int to);
|
2023-11-05 00:53:37 +02:00
|
|
|
void makeDeal() override;
|
2015-10-12 15:47:10 +02:00
|
|
|
void selectionChanged(bool side) override; //true == left
|
2023-09-28 00:17:05 +02:00
|
|
|
CMarketplaceWindow(const IMarket * Market, const CGHeroInstance * Hero, const std::function<void()> & onWindowClosed, EMarketMode Mode);
|
2017-07-17 23:04:00 +02:00
|
|
|
~CMarketplaceWindow();
|
2014-07-13 16:31:00 +03:00
|
|
|
|
2015-10-12 15:47:10 +02:00
|
|
|
Point selectionOffset(bool Left) const override;
|
2023-11-05 02:01:23 +02:00
|
|
|
std::string updateSlotSubtitle(bool Left) const override;
|
2014-07-13 16:31:00 +03:00
|
|
|
|
2023-11-05 02:01:23 +02:00
|
|
|
void updateGarrison() override; //removes creatures with count 0 from the list (apparently whole stack has been sold)
|
2015-10-12 15:47:10 +02:00
|
|
|
void artifactsChanged(bool left) override;
|
2016-11-26 14:14:43 +02:00
|
|
|
void resourceChanged();
|
2014-07-13 16:31:00 +03:00
|
|
|
void updateTraderText();
|
|
|
|
};
|