diff --git a/client/widgets/markets/CAltarCreatures.cpp b/client/widgets/markets/CAltarCreatures.cpp index baa6f082d..ba779fdc4 100644 --- a/client/widgets/markets/CAltarCreatures.cpp +++ b/client/widgets/markets/CAltarCreatures.cpp @@ -60,6 +60,11 @@ CAltarCreatures::CAltarCreatures(const IMarket * market, const CGHeroInstance * rightTradePanel->moveTo(pos.topLeft() + Point(334, 110)); rightTradePanel->selectedImage->moveTo(pos.topLeft() + Point(395, 422)); rightTradePanel->selectedSubtitle->moveTo(pos.topLeft() + Point(426, 503)); + rightTradePanel->updateSlotsCallback = [this]() + { + for(const auto & altarSlot : rightTradePanel->slots) + updateAltarSlot(altarSlot); + }; leftTradePanel->deleteSlotsCheck = rightTradePanel->deleteSlotsCheck = std::bind(&CCreaturesSelling::slotDeletingCheck, this, _1); readExpValues(); @@ -69,7 +74,7 @@ CAltarCreatures::CAltarCreatures(const IMarket * market, const CGHeroInstance * void CAltarCreatures::readExpValues() { int bidQty = 0; - for(auto heroSlot : leftTradePanel->slots) + for(const auto & heroSlot : leftTradePanel->slots) { if(heroSlot->id >= 0) market->getOffer(heroSlot->id, 0, bidQty, expPerUnit[heroSlot->serial], EMarketMode::CREATURE_EXP); @@ -138,10 +143,9 @@ void CAltarCreatures::updateSelected() void CAltarCreatures::updateSlots() { - rightTradePanel->deleteSlots(); + rightTradePanel->updateSlots(); CCreaturesSelling::updateSlots(); assert(leftTradePanel->slots.size() == rightTradePanel->slots.size()); - readExpValues(); } void CAltarCreatures::deselect() @@ -211,14 +215,13 @@ void CAltarCreatures::sacrificeAll() if(hRight) offerSlider->scrollTo(unitsOnAltar[hRight->serial]); - for(auto altarSlot : rightTradePanel->slots) - updateAltarSlot(altarSlot); + rightTradePanel->updateSlots(); updateSelected(); deal->block(calcExpAltarForHero() == 0); } -void CAltarCreatures::updateAltarSlot(std::shared_ptr slot) +void CAltarCreatures::updateAltarSlot(const std::shared_ptr & slot) { auto units = unitsOnAltar[slot->serial]; slot->setType(units > 0 ? EType::CREATURE : EType::CREATURE_PLACEHOLDER); diff --git a/client/widgets/markets/CAltarCreatures.h b/client/widgets/markets/CAltarCreatures.h index eb266be97..700309a3a 100644 --- a/client/widgets/markets/CAltarCreatures.h +++ b/client/widgets/markets/CAltarCreatures.h @@ -20,12 +20,12 @@ public: TExpType calcExpAltarForHero() override; void makeDeal() override; void sacrificeAll() override; - void updateAltarSlot(std::shared_ptr slot); private: std::vector unitsOnAltar; std::vector expPerUnit; + void updateAltarSlot(const std::shared_ptr & slot); void readExpValues(); void updateControls(); void updateSelected(); diff --git a/client/widgets/markets/CArtifactsBuying.cpp b/client/widgets/markets/CArtifactsBuying.cpp new file mode 100644 index 000000000..4fb550fc5 --- /dev/null +++ b/client/widgets/markets/CArtifactsBuying.cpp @@ -0,0 +1,120 @@ +/* + * CArtifactsBuying.cpp, 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 + * + */ + +#include "StdInc.h" +#include "CArtifactsBuying.h" + +#include "../../gui/CGuiHandler.h" +#include "../../widgets/Buttons.h" +#include "../../widgets/Slider.h" +#include "../../widgets/TextControls.h" + +#include "../../CGameInfo.h" +#include "../../CPlayerInterface.h" + +#include "../../../CCallback.h" + +#include "../../../lib/CGeneralTextHandler.h" +#include "../../../lib/mapObjects/CGMarket.h" +#include "../../../lib/mapObjects/CGTownInstance.h" + +CArtifactsBuying::CArtifactsBuying(const IMarket * market, const CGHeroInstance * hero) + : CTradeBase(market, hero) + , CMarketMisc([this](){return CArtifactsBuying::getSelectionParams();}) +{ + OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE); + + assert(dynamic_cast(market)); + labels.emplace_back(std::make_shared(299, 27, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, + (*CGI->townh)[dynamic_cast(market)->getFaction()]->town->buildings[BuildingID::ARTIFACT_MERCHANT]->getNameTranslated())); + deal = std::make_shared(Point(270, 520), AnimationPath::builtin("TPMRKB.DEF"), + CGI->generaltexth->zelp[595], [this]() {CArtifactsBuying::makeDeal(); }); + labels.emplace_back(std::make_shared(445, 148, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[168])); + + // Player's resources + assert(leftTradePanel); + std::for_each(leftTradePanel->slots.cbegin(), leftTradePanel->slots.cend(), [this](auto & slot) + { + slot->clickPressedCallback = [this](const std::shared_ptr & heroSlot) + { + CArtifactsBuying::onSlotClickPressed(heroSlot, hLeft); + }; + }); + leftTradePanel->moveTo(pos.topLeft() + Point(39, 182)); + leftTradePanel->selectedImage->moveTo(pos.topLeft() + Point(141, 453)); + + // Artifacts panel + rightTradePanel = std::make_shared([this](const std::shared_ptr & newSlot) + { + CArtifactsBuying::onSlotClickPressed(newSlot, hRight); + + }, [this]() + { + // TODO move to parent + if(hLeft) + for(const auto & slot : rightTradePanel->slots) + { + int h1, h2; //hlp variables for getting offer + this->market->getOffer(hLeft->id, slot->id, h1, h2, EMarketMode::RESOURCE_ARTIFACT); + + rightTradePanel->updateOffer(*slot, h1, h2); + } + else + rightTradePanel->clearSubtitles(); + }, market->availableItemsIds(EMarketMode::RESOURCE_ARTIFACT)); + rightTradePanel->deleteSlotsCheck = [this](const std::shared_ptr & slot) + { + return vstd::contains(this->market->availableItemsIds(EMarketMode::RESOURCE_ARTIFACT), ArtifactID(slot->id)) ? false : true; + }; + rightTradePanel->moveTo(pos.topLeft() + Point(328, 182)); + + CArtifactsBuying::updateSlots(); + CMarketMisc::deselect(); +} + +void CArtifactsBuying::makeDeal() +{ + LOCPLINT->cb->trade(market, EMarketMode::RESOURCE_ARTIFACT, GameResID(hLeft->id), ArtifactID(hRight->id), offerQty, hero); + deselect(); +} + +void CArtifactsBuying::updateSlots() +{ + CResourcesSelling::updateSlots(); + rightTradePanel->updateSlots(); +} + +CMarketMisc::SelectionParams CArtifactsBuying::getSelectionParams() +{ + if(hLeft && hRight) + return std::make_tuple(std::to_string(deal->isBlocked() ? 0 : bidQty), + std::to_string(deal->isBlocked() ? 0 : offerQty), hLeft->id, CGI->artifacts()->getByIndex(hRight->id)->getIconIndex()); + else + return std::nullopt; +} + +void CArtifactsBuying::onSlotClickPressed(const std::shared_ptr & newSlot, std::shared_ptr & hCurSlot) +{ + if(newSlot == hCurSlot) + return; + + CTradeBase::onSlotClickPressed(newSlot, hCurSlot); + if(hLeft) + { + if(hRight) + { + market->getOffer(hLeft->id, hRight->id, bidQty, offerQty, EMarketMode::RESOURCE_ARTIFACT); + deal->block(LOCPLINT->cb->getResourceAmount(GameResID(hLeft->id)) >= bidQty ? false : true); + } + updateSelected(); + rightTradePanel->updateSlots(); + } + redraw(); +} diff --git a/client/widgets/markets/CArtifactsBuying.h b/client/widgets/markets/CArtifactsBuying.h new file mode 100644 index 000000000..477fe1285 --- /dev/null +++ b/client/widgets/markets/CArtifactsBuying.h @@ -0,0 +1,24 @@ +/* + * CArtifactsBuying.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 "CTradeBase.h" + +class CArtifactsBuying : public CResourcesSelling, public CMarketMisc +{ +public: + CArtifactsBuying(const IMarket * market, const CGHeroInstance * hero); + void makeDeal() override; + void updateSlots() override; + +private: + CMarketMisc::SelectionParams getSelectionParams(); + void CArtifactsBuying::onSlotClickPressed(const std::shared_ptr & newSlot, std::shared_ptr & hCurSlot); +}; diff --git a/client/widgets/markets/CFreelancerGuild.cpp b/client/widgets/markets/CFreelancerGuild.cpp index f2d0f6b3c..abdcbb124 100644 --- a/client/widgets/markets/CFreelancerGuild.cpp +++ b/client/widgets/markets/CFreelancerGuild.cpp @@ -29,6 +29,7 @@ CFreelancerGuild::CFreelancerGuild(const IMarket * market, const CGHeroInstance * hero) : CTradeBase(market, hero) , CResourcesBuying([this](){CResourcesBuying::updateSubtitles(EMarketMode::CREATURE_RESOURCE);}) + , CMarketMisc([this](){return CFreelancerGuild::getSelectionParams();}) { OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE); @@ -59,7 +60,6 @@ CFreelancerGuild::CFreelancerGuild(const IMarket * market, const CGHeroInstance // Guild resources panel assert(rightTradePanel); - rightTradePanel->moveBy(Point(327, 181)); std::for_each(rightTradePanel->slots.cbegin(), rightTradePanel->slots.cend(), [this](auto & slot) { slot->clickPressedCallback = [this](const std::shared_ptr & heroSlot) @@ -68,28 +68,7 @@ CFreelancerGuild::CFreelancerGuild(const IMarket * market, const CGHeroInstance }; }); - CFreelancerGuild::deselect(); -} - -void CFreelancerGuild::updateSelected() -{ - std::optional lImageIndex = std::nullopt; - std::optional rImageIndex = std::nullopt; - - if(hLeft && hRight) - { - leftTradePanel->selectedSubtitle->setText(std::to_string(bidQty * offerSlider->getValue())); - rightTradePanel->selectedSubtitle->setText(std::to_string(offerQty * offerSlider->getValue())); - lImageIndex = CGI->creatures()->getByIndex(hLeft->id)->getIconIndex(); - rImageIndex = hRight->id; - } - else - { - leftTradePanel->selectedSubtitle->setText(""); - rightTradePanel->selectedSubtitle->setText(""); - } - leftTradePanel->setSelectedFrameIndex(lImageIndex); - rightTradePanel->setSelectedFrameIndex(rImageIndex); + CMarketMisc::deselect(); } void CFreelancerGuild::makeDeal() @@ -101,10 +80,13 @@ void CFreelancerGuild::makeDeal() } } -void CFreelancerGuild::deselect() +CMarketMisc::SelectionParams CFreelancerGuild::getSelectionParams() { - CResourcesBuying::deselect(); - updateSelected(); + if(hLeft && hRight) + return std::make_tuple(std::to_string(bidQty * offerSlider->getValue()), std::to_string(offerQty * offerSlider->getValue()), + CGI->creatures()->getByIndex(hLeft->id)->getIconIndex(), hRight->id); + else + return std::nullopt; } void CFreelancerGuild::onOfferSliderMoved(int newVal) diff --git a/client/widgets/markets/CFreelancerGuild.h b/client/widgets/markets/CFreelancerGuild.h index 60a5cb50d..7f2bbf8b1 100644 --- a/client/widgets/markets/CFreelancerGuild.h +++ b/client/widgets/markets/CFreelancerGuild.h @@ -11,15 +11,14 @@ #include "CTradeBase.h" -class CFreelancerGuild : public CCreaturesSelling , public CResourcesBuying +class CFreelancerGuild : public CCreaturesSelling , public CResourcesBuying, public CMarketMisc { public: CFreelancerGuild(const IMarket * market, const CGHeroInstance * hero); void makeDeal() override; - void deselect() override; private: - void updateSelected(); + CMarketMisc::SelectionParams getSelectionParams(); void onOfferSliderMoved(int newVal); void onSlotClickPressed(const std::shared_ptr & newSlot, std::shared_ptr & hCurSlot) override; }; diff --git a/client/widgets/markets/CMarketResources.cpp b/client/widgets/markets/CMarketResources.cpp index 0a028cf47..1d0f97d6c 100644 --- a/client/widgets/markets/CMarketResources.cpp +++ b/client/widgets/markets/CMarketResources.cpp @@ -22,12 +22,12 @@ #include "../../../CCallback.h" #include "../../../lib/CGeneralTextHandler.h" -#include "../../../lib/mapObjects/CGHeroInstance.h" #include "../../../lib/mapObjects/CGMarket.h" CMarketResources::CMarketResources(const IMarket * market, const CGHeroInstance * hero) : CTradeBase(market, hero) , CResourcesBuying([this](){CMarketResources::updateSubtitles();}) + , CMarketMisc([this](){return CMarketResources::getSelectionParams();}) { OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE); @@ -54,7 +54,6 @@ CMarketResources::CMarketResources(const IMarket * market, const CGHeroInstance // Market resources panel assert(rightTradePanel); - rightTradePanel->moveTo(pos.topLeft() + Point(327, 181)); std::for_each(rightTradePanel->slots.cbegin(), rightTradePanel->slots.cend(), [this](auto & slot) { slot->clickPressedCallback = [this](const std::shared_ptr & resSlot) @@ -64,7 +63,7 @@ CMarketResources::CMarketResources(const IMarket * market, const CGHeroInstance }); CResourcesSelling::updateSlots(); - CMarketResources::deselect(); + CMarketMisc::deselect(); } void CMarketResources::makeDeal() @@ -76,31 +75,13 @@ void CMarketResources::makeDeal() } } -void CMarketResources::deselect() +CMarketMisc::SelectionParams CMarketResources::getSelectionParams() { - CResourcesBuying::deselect(); - updateSelected(); -} - -void CMarketResources::updateSelected() -{ - std::optional lImageIndex = std::nullopt; - std::optional rImageIndex = std::nullopt; - if(hLeft && hRight && hLeft->id != hRight->id) - { - leftTradePanel->selectedSubtitle->setText(std::to_string(bidQty * offerSlider->getValue())); - rightTradePanel->selectedSubtitle->setText(std::to_string(offerQty * offerSlider->getValue())); - lImageIndex = hLeft->id; - rImageIndex = hRight->id; - } + return std::make_tuple(std::to_string(bidQty * offerSlider->getValue()), + std::to_string(offerQty * offerSlider->getValue()), hLeft->id, hRight->id); else - { - leftTradePanel->selectedSubtitle->setText(""); - rightTradePanel->selectedSubtitle->setText(""); - } - leftTradePanel->setSelectedFrameIndex(lImageIndex); - rightTradePanel->setSelectedFrameIndex(rImageIndex); + return std::nullopt; } void CMarketResources::onOfferSliderMoved(int newVal) diff --git a/client/widgets/markets/CMarketResources.h b/client/widgets/markets/CMarketResources.h index c040195bd..5a14f49cb 100644 --- a/client/widgets/markets/CMarketResources.h +++ b/client/widgets/markets/CMarketResources.h @@ -11,15 +11,14 @@ #include "CTradeBase.h" -class CMarketResources : public CResourcesSelling, public CResourcesBuying +class CMarketResources : public CResourcesSelling, public CResourcesBuying, public CMarketMisc { public: CMarketResources(const IMarket * market, const CGHeroInstance * hero); void makeDeal() override; - void deselect() override; private: - void updateSelected(); + CMarketMisc::SelectionParams getSelectionParams(); void onOfferSliderMoved(int newVal); void onSlotClickPressed(const std::shared_ptr & newSlot, std::shared_ptr & hCurSlot); void updateSubtitles(); diff --git a/client/widgets/markets/CTradeBase.cpp b/client/widgets/markets/CTradeBase.cpp index 1e1ed1c4f..47f0e5f08 100644 --- a/client/widgets/markets/CTradeBase.cpp +++ b/client/widgets/markets/CTradeBase.cpp @@ -121,7 +121,6 @@ void CCreaturesSelling::updateSubtitle() void CCreaturesSelling::updateSlots() { - leftTradePanel->deleteSlots(); leftTradePanel->updateSlots(); } @@ -130,13 +129,12 @@ CResourcesBuying::CResourcesBuying(TradePanelBase::UpdateSlotsFunctor callback) OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE); rightTradePanel = std::make_shared([](const std::shared_ptr&) {}, callback); + rightTradePanel->moveTo(pos.topLeft() + Point(327, 181)); labels.emplace_back(std::make_shared(445, 148, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[168])); } void CResourcesBuying::updateSubtitles(EMarketMode marketMode) { - assert(marketMode == EMarketMode::RESOURCE_RESOURCE || marketMode == EMarketMode::CREATURE_RESOURCE || marketMode == EMarketMode::ARTIFACT_RESOURCE); - if(hLeft) for(const auto & slot : rightTradePanel->slots) { @@ -149,13 +147,6 @@ void CResourcesBuying::updateSubtitles(EMarketMode marketMode) rightTradePanel->clearSubtitles(); }; -void CResourcesBuying::deselect() -{ - CTradeBase::deselect(); - bidQty = 0; - offerQty = 0; -} - CResourcesSelling::CResourcesSelling() { OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE); @@ -172,3 +163,38 @@ void CResourcesSelling::updateSlots() { leftTradePanel->updateSlots(); } + +CMarketMisc::CMarketMisc(SelectionParamsFunctor callback) + : selectionParamsCallback(callback) +{ +} + +void CMarketMisc::deselect() +{ + CTradeBase::deselect(); + bidQty = 0; + offerQty = 0; + updateSelected(); +} + +void CMarketMisc::updateSelected() +{ + std::optional lImageIndex = std::nullopt; + std::optional rImageIndex = std::nullopt; + + assert(selectionParamsCallback); + if(auto params = selectionParamsCallback()) + { + leftTradePanel->selectedSubtitle->setText(std::get<0>(params.value())); + rightTradePanel->selectedSubtitle->setText(std::get<1>(params.value())); + lImageIndex = std::get<2>(params.value()); + rImageIndex = std::get<3>(params.value()); + } + else + { + leftTradePanel->selectedSubtitle->setText(""); + rightTradePanel->selectedSubtitle->setText(""); + } + leftTradePanel->setSelectedFrameIndex(lImageIndex); + rightTradePanel->setSelectedFrameIndex(rImageIndex); +} diff --git a/client/widgets/markets/CTradeBase.h b/client/widgets/markets/CTradeBase.h index a0d59fe6f..75720f730 100644 --- a/client/widgets/markets/CTradeBase.h +++ b/client/widgets/markets/CTradeBase.h @@ -80,11 +80,6 @@ class CResourcesBuying : virtual public CTradeBase, virtual public CIntObject public: CResourcesBuying(TradePanelBase::UpdateSlotsFunctor callback); void updateSubtitles(EMarketMode marketMode); - void deselect() override; - -protected: - int bidQty; - int offerQty; }; class CResourcesSelling : virtual public CTradeBase, virtual public CIntObject @@ -93,3 +88,19 @@ public: CResourcesSelling(); void updateSlots() override; }; + +class CMarketMisc : virtual public CTradeBase, virtual public CIntObject +{ +public: + using SelectionParams = std::optional>; + using SelectionParamsFunctor = std::function; + + CMarketMisc(SelectionParamsFunctor callback); + void deselect() override; + void updateSelected(); + +protected: + int bidQty; + int offerQty; + SelectionParamsFunctor selectionParamsCallback; +}; diff --git a/client/widgets/markets/CTransferResources.cpp b/client/widgets/markets/CTransferResources.cpp index 60789af45..fb1345502 100644 --- a/client/widgets/markets/CTransferResources.cpp +++ b/client/widgets/markets/CTransferResources.cpp @@ -25,6 +25,7 @@ CTransferResources::CTransferResources(const IMarket * market, const CGHeroInstance * hero) : CTradeBase(market, hero) + , CMarketMisc([this](){return CTransferResources::getSelectionParams();}) { OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE); @@ -70,31 +71,13 @@ void CTransferResources::makeDeal() } } -void CTransferResources::deselect() +CMarketMisc::SelectionParams CTransferResources::getSelectionParams() { - CTradeBase::deselect(); - updateSelected(); -} - -void CTransferResources::updateSelected() -{ - std::optional lImageIndex = std::nullopt; - std::optional rImageIndex = std::nullopt; - if(hLeft && hRight) - { - leftTradePanel->selectedSubtitle->setText(std::to_string(offerSlider->getValue())); - rightTradePanel->selectedSubtitle->setText(CGI->generaltexth->capColors[hRight->id]); - lImageIndex = hLeft->id; - rImageIndex = hRight->id; - } + return std::make_tuple(std::to_string(offerSlider->getValue()), + CGI->generaltexth->capColors[hRight->id], hLeft->id, hRight->id); else - { - leftTradePanel->selectedSubtitle->setText(""); - rightTradePanel->selectedSubtitle->setText(""); - } - leftTradePanel->setSelectedFrameIndex(lImageIndex); - rightTradePanel->setSelectedFrameIndex(rImageIndex); + return std::nullopt; } void CTransferResources::onOfferSliderMoved(int newVal) diff --git a/client/widgets/markets/CTransferResources.h b/client/widgets/markets/CTransferResources.h index d21d007f2..8765b8f58 100644 --- a/client/widgets/markets/CTransferResources.h +++ b/client/widgets/markets/CTransferResources.h @@ -11,15 +11,14 @@ #include "CTradeBase.h" -class CTransferResources : public CResourcesSelling +class CTransferResources : public CResourcesSelling, public CMarketMisc { public: CTransferResources(const IMarket * market, const CGHeroInstance * hero); void makeDeal() override; - void deselect() override; private: - void updateSelected(); + CMarketMisc::SelectionParams getSelectionParams(); void onOfferSliderMoved(int newVal); void onSlotClickPressed(const std::shared_ptr & newSlot, std::shared_ptr & hCurSlot); }; diff --git a/client/widgets/markets/TradePanels.cpp b/client/widgets/markets/TradePanels.cpp index 1013f75c8..f6fc2afcb 100644 --- a/client/widgets/markets/TradePanels.cpp +++ b/client/widgets/markets/TradePanels.cpp @@ -273,6 +273,9 @@ void CTradeableItem::setArtInstance(const CArtifactInstance * art) void TradePanelBase::updateSlots() { + if(deleteSlotsCheck) + slots.erase(std::remove_if(slots.begin(), slots.end(), deleteSlotsCheck), slots.end()); + if(updateSlotsCallback) updateSlotsCallback(); } @@ -299,12 +302,6 @@ void TradePanelBase::updateOffer(CTradeableItem & slot, int cost, int qty) } } -void TradePanelBase::deleteSlots() -{ - if(deleteSlotsCheck) - slots.erase(std::remove_if(slots.begin(), slots.end(), deleteSlotsCheck), slots.end()); -} - void TradePanelBase::setSelectedFrameIndex(std::optional index) { if(index.has_value()) @@ -355,6 +352,8 @@ ArtifactsPanel::ArtifactsPanel(CTradeableItem::ClickPressedFunctor clickPressedC } } updateSlotsCallback = updateSubtitles; + selectedImage = std::make_shared(AnimationPath::builtin("artifact"), 0, 0, selectedImagePos.x, selectedImagePos.y); + selectedSubtitle = std::make_shared(selectedSubtitlePos.x, selectedSubtitlePos.y, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE); } PlayersPanel::PlayersPanel(CTradeableItem::ClickPressedFunctor clickPressedCallback) diff --git a/client/widgets/markets/TradePanels.h b/client/widgets/markets/TradePanels.h index 282682c78..9d26c71df 100644 --- a/client/widgets/markets/TradePanels.h +++ b/client/widgets/markets/TradePanels.h @@ -71,7 +71,6 @@ public: virtual void deselect(); virtual void clearSubtitles(); void updateOffer(CTradeableItem & slot, int, int); - void deleteSlots(); void setSelectedFrameIndex(std::optional index); }; @@ -90,7 +89,7 @@ class ResourcesPanel : public TradePanelBase Point(83, 158) }; const Point slotDimension = Point(69, 66); - const Point selectedImagePos = Point(102, 276); + const Point selectedImagePos = Point(101, 276); const Point selectedSubtitlePos = Point(118, 324); public: @@ -101,12 +100,14 @@ class ArtifactsPanel : public TradePanelBase { const std::vector slotsPos = { - Point(0, 0), Point(83, 0), Point(166, 0), - Point(0, 79), Point(83, 79), Point(166, 79), + Point(0, 0), Point(83, 0), Point(165, 0), + Point(0, 79), Point(83, 79), Point(165, 79), Point(83, 158) }; const size_t slotsForTrade = 7; const Point slotDimension = Point(69, 66); + const Point selectedImagePos = Point(96, 266); + const Point selectedSubtitlePos = Point(118, 324); public: ArtifactsPanel(CTradeableItem::ClickPressedFunctor clickPressedCallback, UpdateSlotsFunctor updateSubtitles, diff --git a/client/windows/CMarketWindow.cpp b/client/windows/CMarketWindow.cpp index 6dc02c211..18d786013 100644 --- a/client/windows/CMarketWindow.cpp +++ b/client/windows/CMarketWindow.cpp @@ -59,13 +59,13 @@ CMarketWindow::CMarketWindow(const IMarket * market, const CGHeroInstance * hero void CMarketWindow::artifactsChanged() { - market->artifactsChanged(false); + //market->artifactsChanged(false); + if(artsBuy) + artsBuy->updateSlots(); } void CMarketWindow::updateGarrisons() { - CAltarWindow::updateGarrisons(); - if(guild) guild->updateSlots(); } @@ -169,9 +169,6 @@ void CMarketWindow::createArtifactsBuying(const IMarket * market, const CGHeroIn OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255 - DISPOSE); background = createBg(ImagePath::builtin("TPMRKABS.bmp"), PLAYER_COLORED); - //this->market = std::make_shared(market, hero, []() {}, EMarketMode::RESOURCE_ARTIFACT); - //createInternals(EMarketMode::RESOURCE_ARTIFACT, market, hero); - artsBuy = std::make_shared(market, hero); background->center(); diff --git a/client/windows/CTradeWindow.cpp b/client/windows/CTradeWindow.cpp index e0b86bc54..90f15772f 100644 --- a/client/windows/CTradeWindow.cpp +++ b/client/windows/CTradeWindow.cpp @@ -449,12 +449,6 @@ void CMarketplaceWindow::updateGarrison() void CMarketplaceWindow::artifactsChanged(bool Left) { - assert(!Left); - if(mode != EMarketMode::RESOURCE_ARTIFACT) - return; - - rightTradePanel->deleteSlots(); - redraw(); } std::string CMarketplaceWindow::updateSlotSubtitle(bool Left) const