1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00

suggested changes

This commit is contained in:
SoundSSGood 2024-10-28 14:30:19 +02:00
parent 83279211e6
commit 1fcd750774
12 changed files with 26 additions and 19 deletions

View File

@ -22,7 +22,7 @@
CArtifactsOfHeroAltar::CArtifactsOfHeroAltar(const Point & position)
{
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));
enableGesture();
// The backpack is in the altar window above and to the right

View File

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

View File

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

View File

@ -33,7 +33,7 @@ public:
CArtifactsOfHeroBase();
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 gestureArtPlace(CComponentHolder & artPlace, const Point & cursorPosition);
virtual void setHero(const CGHeroInstance * hero);
@ -50,7 +50,7 @@ public:
void enableGesture();
const CArtifactInstance * getArt(const ArtifactPosition & slot) const;
void enableKeyboardShortcuts();
void setClickPrassedArtPlacesCallback(const CArtPlace::ClickFunctor & callback) const;
void setClickPressedArtPlacesCallback(const CArtPlace::ClickFunctor & callback) const;
void setShowPopupArtPlacesCallback(const CArtPlace::ClickFunctor & callback) const;
const CGHeroInstance * curHero;

View File

@ -30,14 +30,14 @@ CArtifactsOfHeroKingdom::CArtifactsOfHeroKingdom(ArtPlaceMap ArtWorn, std::vecto
{
artPlace.second->slot = artPlace.first;
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));
}
enableGesture();
for(auto artPlace : backpack)
{
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));
}
leftBackpackRoll->addCallback(std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, -1));

View File

@ -21,7 +21,7 @@
CArtifactsOfHeroMain::CArtifactsOfHeroMain(const Point & position)
{
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));
enableGesture();
}

View File

@ -15,14 +15,14 @@
CArtifactsOfHeroMarket::CArtifactsOfHeroMarket(const Point & position, const int selectionWidth)
{
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)
artPlace->setSelectionWidth(selectionWidth);
for(auto artPlace : backpack)
artPlace->setSelectionWidth(selectionWidth);
};
void CArtifactsOfHeroMarket::clickPrassedArtPlace(CComponentHolder & artPlace, const Point & cursorPosition)
void CArtifactsOfHeroMarket::clickPressedArtPlace(CComponentHolder & artPlace, const Point & cursorPosition)
{
auto ownedPlace = getArtPlace(cursorPosition);
assert(ownedPlace != nullptr);

View File

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

View File

@ -295,14 +295,15 @@ void CSecSkillPlace::setLevel(const uint8_t level)
assert(level <= 3);
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();
auto hoverText = MetaString::createFromRawString(CGI->generaltexth->heroscrn[21]);
hoverText.replaceRawString(CGI->generaltexth->levels[level - 1]);
hoverText.replaceTextID(SecondarySkill(skillId).toSkill()->getNameTextID());
hoverText.replaceTextID(secSkill->getNameTextID());
this->hoverText = hoverText.toString();
component.value = level;
text = CGI->skillh->getByIndex(skillId)->getDescriptionTranslated(level);
text = secSkill->getDescriptionTranslated(level);
}
else
{

View File

@ -206,7 +206,7 @@ void CHeroOverview::genControls()
i = 0;
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) + 10, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, (*CGI->skillh)[skill.first]->getNameTranslated()));
i++;

View File

@ -45,7 +45,12 @@ int32_t CSkill::getIndex() 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

View File

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