|
|
@@ -23,10 +23,9 @@
|
|
|
#include "../../../lib/CGeneralTextHandler.h"
|
|
|
#include "../../../lib/mapObjects/CGHeroInstance.h"
|
|
|
#include "../../../lib/mapObjects/CGMarket.h"
|
|
|
-#include "../../../lib/mapObjects/CGTownInstance.h"
|
|
|
|
|
|
CFreelancerGuild::CFreelancerGuild(const IMarket * market, const CGHeroInstance * hero)
|
|
|
- : CMarketBase(market, hero, [this](){return CFreelancerGuild::getSelectionParams();})
|
|
|
+ : CMarketBase(market, hero)
|
|
|
, CResourcesBuying(
|
|
|
[this](const std::shared_ptr<CTradeableItem> & heroSlot){CFreelancerGuild::onSlotClickPressed(heroSlot, offerTradePanel);},
|
|
|
[this](){CMarketBase::updateSubtitlesForBid(EMarketMode::CREATURE_RESOURCE, bidTradePanel->getSelectedItemId());})
|
|
|
@@ -35,7 +34,7 @@ CFreelancerGuild::CFreelancerGuild(const IMarket * market, const CGHeroInstance
|
|
|
OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE);
|
|
|
|
|
|
labels.emplace_back(std::make_shared<CLabel>(titlePos.x, titlePos.y, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW,
|
|
|
- (*CGI->townh)[ETownType::STRONGHOLD]->town->buildings[BuildingID::FREELANCERS_GUILD]->getNameTranslated()));
|
|
|
+ VLC->generaltexth->translate("object.core.freelancersGuild.name")));
|
|
|
labels.emplace_back(std::make_shared<CLabel>(155, 103, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE,
|
|
|
boost::str(boost::format(CGI->generaltexth->allTexts[272]) % hero->getNameTranslated())));
|
|
|
deal = std::make_shared<CButton>(dealButtonPosWithSlider, AnimationPath::builtin("TPMRKB.DEF"),
|
|
|
@@ -62,32 +61,34 @@ void CFreelancerGuild::deselect()
|
|
|
{
|
|
|
CMarketBase::deselect();
|
|
|
CMarketSlider::deselect();
|
|
|
+ CMarketTraderText::deselect();
|
|
|
}
|
|
|
|
|
|
void CFreelancerGuild::makeDeal()
|
|
|
{
|
|
|
if(auto toTrade = offerSlider->getValue(); toTrade != 0)
|
|
|
{
|
|
|
- LOCPLINT->cb->trade(market, EMarketMode::CREATURE_RESOURCE, SlotID(bidTradePanel->highlightedSlot->serial), GameResID(offerTradePanel->highlightedSlot->id), bidQty * toTrade, hero);
|
|
|
+ LOCPLINT->cb->trade(market, EMarketMode::CREATURE_RESOURCE, SlotID(bidTradePanel->highlightedSlot->serial), GameResID(offerTradePanel->getSelectedItemId()), bidQty * toTrade, hero);
|
|
|
+ CMarketTraderText::makeDeal();
|
|
|
deselect();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-CMarketBase::SelectionParams CFreelancerGuild::getSelectionParams() const
|
|
|
+CMarketBase::MarketShowcasesParams CFreelancerGuild::getShowcasesParams() const
|
|
|
{
|
|
|
- if(bidTradePanel->highlightedSlot && offerTradePanel->highlightedSlot)
|
|
|
+ if(bidTradePanel->isHighlighted() && offerTradePanel->isHighlighted())
|
|
|
return std::make_tuple(
|
|
|
- SelectionParamOneSide {std::to_string(bidQty * offerSlider->getValue()), CGI->creatures()->getByIndex(bidTradePanel->highlightedSlot->id)->getIconIndex()},
|
|
|
- SelectionParamOneSide {std::to_string(offerQty * offerSlider->getValue()), offerTradePanel->highlightedSlot->id});
|
|
|
+ ShowcaseParams {std::to_string(bidQty * offerSlider->getValue()), CGI->creatures()->getByIndex(bidTradePanel->getSelectedItemId())->getIconIndex()},
|
|
|
+ ShowcaseParams {std::to_string(offerQty * offerSlider->getValue()), offerTradePanel->getSelectedItemId()});
|
|
|
else
|
|
|
return std::make_tuple(std::nullopt, std::nullopt);
|
|
|
}
|
|
|
|
|
|
void CFreelancerGuild::highlightingChanged()
|
|
|
{
|
|
|
- if(bidTradePanel->highlightedSlot && offerTradePanel->highlightedSlot)
|
|
|
+ if(bidTradePanel->isHighlighted() && offerTradePanel->isHighlighted())
|
|
|
{
|
|
|
- market->getOffer(bidTradePanel->highlightedSlot->id, offerTradePanel->highlightedSlot->id, bidQty, offerQty, EMarketMode::CREATURE_RESOURCE);
|
|
|
+ market->getOffer(bidTradePanel->getSelectedItemId(), offerTradePanel->getSelectedItemId(), bidQty, offerQty, EMarketMode::CREATURE_RESOURCE);
|
|
|
offerSlider->setAmount((hero->getStackCount(SlotID(bidTradePanel->highlightedSlot->serial)) - (hero->stacksCount() == 1 && hero->needsLastStack() ? 1 : 0)) / bidQty);
|
|
|
offerSlider->scrollTo(0);
|
|
|
offerSlider->block(false);
|
|
|
@@ -95,4 +96,24 @@ void CFreelancerGuild::highlightingChanged()
|
|
|
deal->block(false);
|
|
|
}
|
|
|
CMarketBase::highlightingChanged();
|
|
|
+ CMarketTraderText::highlightingChanged();
|
|
|
+}
|
|
|
+
|
|
|
+std::string CFreelancerGuild::getTraderText()
|
|
|
+{
|
|
|
+ if(bidTradePanel->isHighlighted() && offerTradePanel->isHighlighted())
|
|
|
+ {
|
|
|
+ return boost::str(boost::format(
|
|
|
+ CGI->generaltexth->allTexts[269]) %
|
|
|
+ offerQty %
|
|
|
+ (offerQty == 1 ? CGI->generaltexth->allTexts[161] : CGI->generaltexth->allTexts[160]) %
|
|
|
+ CGI->generaltexth->restypes[offerTradePanel->getSelectedItemId()] %
|
|
|
+ bidQty %
|
|
|
+ (bidQty == 1 ? CGI->creh->objects[bidTradePanel->getSelectedItemId()]->getNameSingularTranslated() :
|
|
|
+ CGI->creh->objects[bidTradePanel->getSelectedItemId()]->getNamePluralTranslated()));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return madeTransaction ? CGI->generaltexth->allTexts[162] : CGI->generaltexth->allTexts[163];
|
|
|
+ }
|
|
|
}
|