Browse Source

suggested changes

SoundSSGood 1 năm trước cách đây
mục cha
commit
1fcd750774

+ 1 - 1
client/widgets/CArtifactsOfHeroAltar.cpp

@@ -22,7 +22,7 @@
 CArtifactsOfHeroAltar::CArtifactsOfHeroAltar(const Point & position)
 CArtifactsOfHeroAltar::CArtifactsOfHeroAltar(const Point & position)
 {
 {
 	init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
 	init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
-	setClickPrassedArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2));
+	setClickPressedArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::clickPressedArtPlace, this, _1, _2));
 	setShowPopupArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
 	setShowPopupArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
 	enableGesture();
 	enableGesture();
 	// The backpack is in the altar window above and to the right
 	// The backpack is in the altar window above and to the right

+ 2 - 2
client/widgets/CArtifactsOfHeroBackpack.cpp

@@ -40,7 +40,7 @@ CArtifactsOfHeroBackpack::CArtifactsOfHeroBackpack()
 		visibleCapacityMax = visibleCapacityMax > backpackCap ? backpackCap : visibleCapacityMax;
 		visibleCapacityMax = visibleCapacityMax > backpackCap ? backpackCap : visibleCapacityMax;
 
 
 	initAOHbackpack(visibleCapacityMax, backpackCap < 0 || visibleCapacityMax < backpackCap);
 	initAOHbackpack(visibleCapacityMax, backpackCap < 0 || visibleCapacityMax < backpackCap);
-	setClickPrassedArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2));
+	setClickPressedArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::clickPressedArtPlace, this, _1, _2));
 	setShowPopupArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
 	setShowPopupArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
 }
 }
 
 
@@ -173,7 +173,7 @@ void CArtifactsOfHeroQuickBackpack::setHero(const CGHeroInstance * hero)
 		slotsColumnsMax = ceilf(sqrtf(requiredSlots));
 		slotsColumnsMax = ceilf(sqrtf(requiredSlots));
 		slotsRowsMax = calcRows(requiredSlots);
 		slotsRowsMax = calcRows(requiredSlots);
 		initAOHbackpack(requiredSlots, false);
 		initAOHbackpack(requiredSlots, false);
-		setClickPrassedArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2));
+		setClickPressedArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::clickPressedArtPlace, this, _1, _2));
 		auto artPlace = backpack.begin();
 		auto artPlace = backpack.begin();
 		for(auto & art : filteredArts)
 		for(auto & art : filteredArts)
 			setSlotData(*artPlace++, curHero->getArtPos(art.second));
 			setSlotData(*artPlace++, curHero->getArtPos(art.second));

+ 2 - 2
client/widgets/CArtifactsOfHeroBase.cpp

@@ -85,7 +85,7 @@ void CArtifactsOfHeroBase::init(
 	setRedrawParent(true);
 	setRedrawParent(true);
 }
 }
 
 
-void CArtifactsOfHeroBase::setClickPrassedArtPlacesCallback(const CArtPlace::ClickFunctor & callback) const
+void CArtifactsOfHeroBase::setClickPressedArtPlacesCallback(const CArtPlace::ClickFunctor & callback) const
 {
 {
 	for(const auto & [slot, artPlace] : artWorn)
 	for(const auto & [slot, artPlace] : artWorn)
 		artPlace->setClickPressedCallback(callback);
 		artPlace->setClickPressedCallback(callback);
@@ -101,7 +101,7 @@ void CArtifactsOfHeroBase::setShowPopupArtPlacesCallback(const CArtPlace::ClickF
 		artPlace->setShowPopupCallback(callback);
 		artPlace->setShowPopupCallback(callback);
 }
 }
 
 
-void CArtifactsOfHeroBase::clickPrassedArtPlace(CComponentHolder & artPlace, const Point & cursorPosition)
+void CArtifactsOfHeroBase::clickPressedArtPlace(CComponentHolder & artPlace, const Point & cursorPosition)
 {
 {
 	auto ownedPlace = getArtPlace(cursorPosition);
 	auto ownedPlace = getArtPlace(cursorPosition);
 	assert(ownedPlace != nullptr);
 	assert(ownedPlace != nullptr);

+ 2 - 2
client/widgets/CArtifactsOfHeroBase.h

@@ -33,7 +33,7 @@ public:
 	
 	
 	CArtifactsOfHeroBase();
 	CArtifactsOfHeroBase();
 	virtual void putBackPickedArtifact();
 	virtual void putBackPickedArtifact();
-	virtual void clickPrassedArtPlace(CComponentHolder & artPlace, const Point & cursorPosition);
+	virtual void clickPressedArtPlace(CComponentHolder & artPlace, const Point & cursorPosition);
 	virtual void showPopupArtPlace(CComponentHolder & artPlace, const Point & cursorPosition);
 	virtual void showPopupArtPlace(CComponentHolder & artPlace, const Point & cursorPosition);
 	virtual void gestureArtPlace(CComponentHolder & artPlace, const Point & cursorPosition);
 	virtual void gestureArtPlace(CComponentHolder & artPlace, const Point & cursorPosition);
 	virtual void setHero(const CGHeroInstance * hero);
 	virtual void setHero(const CGHeroInstance * hero);
@@ -50,7 +50,7 @@ public:
 	void enableGesture();
 	void enableGesture();
 	const CArtifactInstance * getArt(const ArtifactPosition & slot) const;
 	const CArtifactInstance * getArt(const ArtifactPosition & slot) const;
 	void enableKeyboardShortcuts();
 	void enableKeyboardShortcuts();
-	void setClickPrassedArtPlacesCallback(const CArtPlace::ClickFunctor & callback) const;
+	void setClickPressedArtPlacesCallback(const CArtPlace::ClickFunctor & callback) const;
 	void setShowPopupArtPlacesCallback(const CArtPlace::ClickFunctor & callback) const;
 	void setShowPopupArtPlacesCallback(const CArtPlace::ClickFunctor & callback) const;
 
 
 	const CGHeroInstance * curHero;
 	const CGHeroInstance * curHero;

+ 2 - 2
client/widgets/CArtifactsOfHeroKingdom.cpp

@@ -30,14 +30,14 @@ CArtifactsOfHeroKingdom::CArtifactsOfHeroKingdom(ArtPlaceMap ArtWorn, std::vecto
 	{
 	{
 		artPlace.second->slot = artPlace.first;
 		artPlace.second->slot = artPlace.first;
 		artPlace.second->setArtifact(ArtifactID(ArtifactID::NONE));
 		artPlace.second->setArtifact(ArtifactID(ArtifactID::NONE));
-		artPlace.second->setClickPressedCallback(std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2));
+		artPlace.second->setClickPressedCallback(std::bind(&CArtifactsOfHeroBase::clickPressedArtPlace, this, _1, _2));
 		artPlace.second->setShowPopupCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
 		artPlace.second->setShowPopupCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
 	}
 	}
 	enableGesture();
 	enableGesture();
 	for(auto artPlace : backpack)
 	for(auto artPlace : backpack)
 	{
 	{
 		artPlace->setArtifact(ArtifactID(ArtifactID::NONE));
 		artPlace->setArtifact(ArtifactID(ArtifactID::NONE));
-		artPlace->setClickPressedCallback(std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2));
+		artPlace->setClickPressedCallback(std::bind(&CArtifactsOfHeroBase::clickPressedArtPlace, this, _1, _2));
 		artPlace->setShowPopupCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
 		artPlace->setShowPopupCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
 	}
 	}
 	leftBackpackRoll->addCallback(std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, -1));
 	leftBackpackRoll->addCallback(std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, -1));

+ 1 - 1
client/widgets/CArtifactsOfHeroMain.cpp

@@ -21,7 +21,7 @@
 CArtifactsOfHeroMain::CArtifactsOfHeroMain(const Point & position)
 CArtifactsOfHeroMain::CArtifactsOfHeroMain(const Point & position)
 {
 {
 	init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
 	init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
-	setClickPrassedArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2));
+	setClickPressedArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::clickPressedArtPlace, this, _1, _2));
 	setShowPopupArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
 	setShowPopupArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
 	enableGesture();
 	enableGesture();
 }
 }

+ 2 - 2
client/widgets/CArtifactsOfHeroMarket.cpp

@@ -15,14 +15,14 @@
 CArtifactsOfHeroMarket::CArtifactsOfHeroMarket(const Point & position, const int selectionWidth)
 CArtifactsOfHeroMarket::CArtifactsOfHeroMarket(const Point & position, const int selectionWidth)
 {
 {
 	init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
 	init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
-	setClickPrassedArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2));
+	setClickPressedArtPlacesCallback(std::bind(&CArtifactsOfHeroBase::clickPressedArtPlace, this, _1, _2));
 	for(const auto & [slot, artPlace] : artWorn)
 	for(const auto & [slot, artPlace] : artWorn)
 		artPlace->setSelectionWidth(selectionWidth);
 		artPlace->setSelectionWidth(selectionWidth);
 	for(auto artPlace : backpack)
 	for(auto artPlace : backpack)
 		artPlace->setSelectionWidth(selectionWidth);
 		artPlace->setSelectionWidth(selectionWidth);
 };
 };
 
 
-void CArtifactsOfHeroMarket::clickPrassedArtPlace(CComponentHolder & artPlace, const Point & cursorPosition)
+void CArtifactsOfHeroMarket::clickPressedArtPlace(CComponentHolder & artPlace, const Point & cursorPosition)
 {
 {
 	auto ownedPlace = getArtPlace(cursorPosition);
 	auto ownedPlace = getArtPlace(cursorPosition);
 	assert(ownedPlace != nullptr);
 	assert(ownedPlace != nullptr);

+ 1 - 1
client/widgets/CArtifactsOfHeroMarket.h

@@ -18,5 +18,5 @@ public:
 	std::function<void()> onClickNotTradableCallback;
 	std::function<void()> onClickNotTradableCallback;
 
 
 	CArtifactsOfHeroMarket(const Point & position, const int selectionWidth);
 	CArtifactsOfHeroMarket(const Point & position, const int selectionWidth);
-	void clickPrassedArtPlace(CComponentHolder & artPlace, const Point & cursorPosition) override;
+	void clickPressedArtPlace(CComponentHolder & artPlace, const Point & cursorPosition) override;
 };
 };

+ 4 - 3
client/widgets/CComponentHolder.cpp

@@ -295,14 +295,15 @@ void CSecSkillPlace::setLevel(const uint8_t level)
 	assert(level <= 3);
 	assert(level <= 3);
 	if(skillId != SecondarySkill::NONE && level > 0)
 	if(skillId != SecondarySkill::NONE && level > 0)
 	{
 	{
-		image->setFrame(skillId.toSkill()->getIconIndex() + level - 1);
+		const auto secSkill = skillId.toSkill();
+		image->setFrame(secSkill->getIconIndex(level - 1));
 		image->enable();
 		image->enable();
 		auto hoverText = MetaString::createFromRawString(CGI->generaltexth->heroscrn[21]);
 		auto hoverText = MetaString::createFromRawString(CGI->generaltexth->heroscrn[21]);
 		hoverText.replaceRawString(CGI->generaltexth->levels[level - 1]);
 		hoverText.replaceRawString(CGI->generaltexth->levels[level - 1]);
-		hoverText.replaceTextID(SecondarySkill(skillId).toSkill()->getNameTextID());
+		hoverText.replaceTextID(secSkill->getNameTextID());
 		this->hoverText = hoverText.toString();
 		this->hoverText = hoverText.toString();
 		component.value = level;
 		component.value = level;
-		text = CGI->skillh->getByIndex(skillId)->getDescriptionTranslated(level);
+		text = secSkill->getDescriptionTranslated(level);
 	}
 	}
 	else
 	else
 	{
 	{

+ 1 - 1
client/windows/CHeroOverview.cpp

@@ -206,7 +206,7 @@ void CHeroOverview::genControls()
     i = 0;
     i = 0;
     for(auto & skill : (*CGI->heroh)[heroIdx]->secSkillsInit)
     for(auto & skill : (*CGI->heroh)[heroIdx]->secSkillsInit)
     {
     {
-        imageSecSkills.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SECSK32"), (*CGI->skillh)[skill.first]->getIconIndex() * 3 + skill.second + 2, 0, 302, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset)));
+        imageSecSkills.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SECSK32"), (*CGI->skillh)[skill.first]->getIconIndex(skill.second + 2), 0, 302, 7 * borderOffset + yOffset + 186 + i * (32 + borderOffset)));
         labelSecSkillsNames.push_back(std::make_shared<CLabel>(334 + 2 * borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) - 5, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->levels[skill.second - 1]));
         labelSecSkillsNames.push_back(std::make_shared<CLabel>(334 + 2 * borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) - 5, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->levels[skill.second - 1]));
         labelSecSkillsNames.push_back(std::make_shared<CLabel>(334 + 2 * borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) + 10, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*CGI->skillh)[skill.first]->getNameTranslated()));
         labelSecSkillsNames.push_back(std::make_shared<CLabel>(334 + 2 * borderOffset, 8 * borderOffset + yOffset + 186 + i * (32 + borderOffset) + 10, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*CGI->skillh)[skill.first]->getNameTranslated()));
         i++;
         i++;

+ 6 - 1
lib/CSkillHandler.cpp

@@ -45,7 +45,12 @@ int32_t CSkill::getIndex() const
 
 
 int32_t CSkill::getIconIndex() const
 int32_t CSkill::getIconIndex() const
 {
 {
-	return getIndex() * 3 + 3; //TODO: actual value with skill level
+	return getIndex() * 3 + 3; // Base master level
+}
+
+int32_t CSkill::getIconIndex(uint8_t skillMasterLevel) const
+{
+	return getIconIndex() + skillMasterLevel;
 }
 }
 
 
 std::string CSkill::getNameTextID() const
 std::string CSkill::getNameTextID() const

+ 2 - 1
lib/CSkillHandler.h

@@ -34,6 +34,7 @@ public:
 private:
 private:
 	std::vector<LevelInfo> levels; // bonuses provided by basic, advanced and expert level
 	std::vector<LevelInfo> levels; // bonuses provided by basic, advanced and expert level
 	void addNewBonus(const std::shared_ptr<Bonus> & b, int level);
 	void addNewBonus(const std::shared_ptr<Bonus> & b, int level);
+	int32_t getIconIndex() const override;
 
 
 	SecondarySkill id;
 	SecondarySkill id;
 	std::string modScope;
 	std::string modScope;
@@ -50,7 +51,7 @@ public:
 	};
 	};
 
 
 	int32_t getIndex() const override;
 	int32_t getIndex() const override;
-	int32_t getIconIndex() const override;
+	int32_t getIconIndex(uint8_t skillMasterLevel) const;
 	std::string getJsonKey() const override;
 	std::string getJsonKey() const override;
 	std::string getModScope() const override;
 	std::string getModScope() const override;
 	void registerIcons(const IconRegistar & cb) const override;
 	void registerIcons(const IconRegistar & cb) const override;