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

Show artifact description and icon on right click if UI tweaks are on

This commit is contained in:
Ivan Savenko 2023-11-02 15:51:08 +02:00
parent c1c2119f3d
commit d7d8177390
2 changed files with 29 additions and 0 deletions

View File

@ -11,7 +11,9 @@
#include "StdInc.h"
#include "MiscObjects.h"
#include "../ArtifactUtils.h"
#include "../constants/StringConstants.h"
#include "../CConfigHandler.h"
#include "../CGeneralTextHandler.h"
#include "../CSoundBase.h"
#include "../CSkillHandler.h"
@ -776,6 +778,30 @@ std::string CGArtifact::getObjectName() const
return VLC->artifacts()->getById(getArtifact())->getNameTranslated();
}
std::string CGArtifact::getPopupText(PlayerColor player) const
{
if (settings["general"]["enableUiEnhancements"].Bool())
{
std::string description = VLC->artifacts()->getById(getArtifact())->getDescriptionTranslated();
ArtifactUtils::insertScrrollSpellName(description, SpellID::NONE); // erase text placeholder
return description;
}
else
return getObjectName();
}
std::string CGArtifact::getPopupText(const CGHeroInstance * hero) const
{
return getPopupText(hero->getOwner());
}
std::vector<Component> CGArtifact::getPopupComponents(PlayerColor player) const
{
return {
Component(ComponentType::ARTIFACT, getArtifact())
};
}
void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
{
if(!stacksCount())

View File

@ -86,6 +86,9 @@ public:
void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
std::string getObjectName() const override;
std::string getPopupText(PlayerColor player) const override;
std::string getPopupText(const CGHeroInstance * hero) const override;
std::vector<Component> getPopupComponents(PlayerColor player) const override;
void pick( const CGHeroInstance * h ) const;
void initObj(CRandomGenerator & rand) override;