소스 검색

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

Ivan Savenko 2 년 전
부모
커밋
d7d8177390
2개의 변경된 파일29개의 추가작업 그리고 0개의 파일을 삭제
  1. 26 0
      lib/mapObjects/MiscObjects.cpp
  2. 3 0
      lib/mapObjects/MiscObjects.h

+ 26 - 0
lib/mapObjects/MiscObjects.cpp

@@ -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())

+ 3 - 0
lib/mapObjects/MiscObjects.h

@@ -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;