SoundSSGood пре 1 година
родитељ
комит
cb6fc4a385

+ 7 - 9
client/widgets/CArtifactsOfHeroBackpack.cpp

@@ -43,12 +43,17 @@ CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack()
 }
 
 void CArtifactsOfHeroBackpack::onSliderMoved(int newVal)
+{
+	backpackPos += newVal;
+	updateBackpackSlots();
+}
+
+void CArtifactsOfHeroBackpack::updateBackpackSlots()
 {
 	if(backpackListBox)
 		backpackListBox->resize(getActiveSlotRowsNum());
-	backpackPos += newVal;
 	auto slot = ArtifactPosition::BACKPACK_START + backpackPos;
-	for(auto artPlace : backpack)
+	for(const auto & artPlace : backpack)
 	{
 		setSlotData(artPlace, slot);
 		slot = slot + 1;
@@ -56,13 +61,6 @@ void CArtifactsOfHeroBackpack::onSliderMoved(int newVal)
 	redraw();
 }
 
-void CArtifactsOfHeroBackpack::updateBackpackSlots()
-{
-	if(backpackListBox)
-		backpackListBox->resize(getActiveSlotRowsNum());
-	CArtifactsOfHeroBase::updateBackpackSlots();
-}
-
 size_t CArtifactsOfHeroBackpack::getActiveSlotRowsNum()
 {
 	return (curHero->artifactsInBackpack.size() + slotsColumnsMax - 1) / slotsColumnsMax;

+ 3 - 10
client/widgets/markets/CAltarArtifacts.cpp

@@ -89,18 +89,11 @@ void CAltarArtifacts::update()
 	CMarketBase::update();
 	CExperienceAltar::update();
 	if(const auto art = hero->getArt(ArtifactPosition::TRANSITION_POS))
-	{
-		offerTradePanel->showcaseSlot->setID(art->getTypeId().num);
-		offerTradePanel->highlightedSlot = offerTradePanel->showcaseSlot;
 		offerQty = calcExpCost(art->getTypeId());
-	}
 	else
-	{
-		offerTradePanel->showcaseSlot->clear();
-		offerTradePanel->highlightedSlot.reset();
 		offerQty = 0;
-	}
 	updateShowcases();
+	redraw();
 }
 
 void CAltarArtifacts::makeDeal()
@@ -191,10 +184,10 @@ void CAltarArtifacts::putBackArtifacts()
 
 CMarketBase::MarketShowcasesParams CAltarArtifacts::getShowcasesParams() const
 {
-	if(offerTradePanel->isHighlighted())
+	if(const auto art = hero->getArt(ArtifactPosition::TRANSITION_POS))
 		return std::make_tuple(
 			std::nullopt,
-			ShowcaseParams {std::to_string(offerQty), CGI->artifacts()->getByIndex(offerTradePanel->getSelectedItemId())->getIconIndex()}
+			ShowcaseParams {std::to_string(offerQty), CGI->artifacts()->getByIndex(art->getTypeId())->getIconIndex()}
 	);
 	return std::make_tuple(std::nullopt, std::nullopt);
 }

+ 12 - 4
client/widgets/markets/CArtifactsBuying.cpp

@@ -21,6 +21,7 @@
 #include "../../../CCallback.h"
 
 #include "../../../lib/CGeneralTextHandler.h"
+#include "../../../lib/mapObjects/CGHeroInstance.h"
 #include "../../../lib/mapObjects/CGMarket.h"
 #include "../../../lib/mapObjects/CGTownInstance.h"
 
@@ -71,10 +72,17 @@ void CArtifactsBuying::deselect()
 
 void CArtifactsBuying::makeDeal()
 {
-	LOCPLINT->cb->trade(market, EMarketMode::RESOURCE_ARTIFACT, GameResID(bidTradePanel->getSelectedItemId()),
-		ArtifactID(offerTradePanel->highlightedSlot->id), offerQty, hero);
-	CMarketTraderText::makeDeal();
-	deselect();
+	if(ArtifactID(offerTradePanel->getSelectedItemId()).toArtifact()->canBePutAt(hero))
+	{
+		LOCPLINT->cb->trade(market, EMarketMode::RESOURCE_ARTIFACT, GameResID(bidTradePanel->getSelectedItemId()),
+			ArtifactID(offerTradePanel->getSelectedItemId()), offerQty, hero);
+		CMarketTraderText::makeDeal();
+		deselect();
+	}
+	else
+	{
+		LOCPLINT->showInfoDialog(CGI->generaltexth->translate("core.genrltxt.326"));
+	}
 }
 
 CMarketBase::MarketShowcasesParams CArtifactsBuying::getShowcasesParams() const