소스 검색

Show skill that can be learned in university on right click

As in title. Now if player has already visited university before, game
will show list of skills that can be learned in this university on right
click
Ivan Savenko 3 달 전
부모
커밋
fe2a981ddf
4개의 변경된 파일29개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      client/widgets/CComponent.cpp
  2. 1 1
      client/windows/InfoWindows.cpp
  3. 25 0
      lib/mapObjects/CGMarket.cpp
  4. 2 0
      lib/mapObjects/CGMarket.h

+ 1 - 1
client/widgets/CComponent.cpp

@@ -119,7 +119,7 @@ std::vector<AnimationPath> CComponent::getFileName() const
 	static const std::array<std::string, 4>  primSkillsArr = {"PSKIL32",        "PSKIL32",        "PSKIL42",        "PSKILL"};
 	static const std::array<std::string, 4>  secSkillsArr =  {"SECSK32",        "SECSK32",        "SECSKILL",       "SECSK82"};
 	static const std::array<std::string, 4>  resourceArr =   {"SMALRES",        "RESOURCE",       "RESOURCE",       "RESOUR82"};
-	static const std::array<std::string, 4>  creatureArr =   {"CPRSMALL",       "CPRSMALL",       "CPRSMALL",       "TWCRPORT"};
+	static const std::array<std::string, 4>  creatureArr =   {"CPRSMALL",       "CPRSMALL",       "TWCRPORT",       "TWCRPORT"};
 	static const std::array<std::string, 4>  artifactArr =   {"Artifact",       "Artifact",       "Artifact",       "Artifact"};
 	static const std::array<std::string, 4>  spellsArr =     {"SpellInt",       "SpellInt",       "SpellInt",       "SPELLSCR"};
 	static const std::array<std::string, 4>  moraleArr =     {"IMRL22",         "IMRL30",         "IMRL42",         "imrl82"};

+ 1 - 1
client/windows/InfoWindows.cpp

@@ -233,7 +233,7 @@ void CRClickPopup::createAndPush(const CGObjectInstance * obj, const Point & p,
 
 		std::vector<std::shared_ptr<CComponent>> guiComponents;
 		for(auto & component : components)
-			guiComponents.push_back(std::make_shared<CComponent>(component));
+			guiComponents.push_back(std::make_shared<CComponent>(component, CComponent::medium));
 
 		if(GAME->interface()->localState->getCurrentHero())
 			CRClickPopup::createAndPush(obj->getPopupText(GAME->interface()->localState->getCurrentHero()), guiComponents);

+ 25 - 0
lib/mapObjects/CGMarket.cpp

@@ -23,6 +23,7 @@
 #include "../mapObjectConstructors/CObjectClassesHandler.h"
 #include "../mapObjectConstructors/CommonConstructors.h"
 #include "../networkPacks/PacksForClient.h"
+#include "CPlayerState.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 
@@ -135,7 +136,31 @@ std::string CGUniversity::getSpeechTranslated() const
 
 void CGUniversity::onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const
 {
+	ChangeObjectVisitors cow;
+	cow.object = id;
+	cow.mode = ChangeObjectVisitors::VISITOR_ADD_PLAYER;
+	cow.hero = h->id;
+	gameEvents.sendAndApply(cow);
+
 	gameEvents.showObjectWindow(this, EOpenWindowMode::UNIVERSITY_WINDOW, h, true);
 }
 
+bool CGUniversity::wasVisited (PlayerColor player) const
+{
+	return cb->getPlayerState(player)->visitedObjects.count(id) != 0;
+}
+
+std::vector<Component> CGUniversity::getPopupComponents(PlayerColor player) const
+{
+	std::vector<Component> result;
+
+	if (!wasVisited(player))
+		return result;
+
+	for (auto const & skill : skills)
+		result.emplace_back(ComponentType::SEC_SKILL, skill.as<SecondarySkill>());
+
+	return result;
+}
+
 VCMI_LIB_NAMESPACE_END

+ 2 - 0
lib/mapObjects/CGMarket.h

@@ -65,6 +65,8 @@ public:
 
 	std::vector<TradeItemBuy> availableItemsIds(EMarketMode mode) const override;
 	void onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const override; //open window
+	std::vector<Component> getPopupComponents(PlayerColor player) const override;
+	bool wasVisited (PlayerColor player) const override;
 
 	template <typename Handler> void serialize(Handler &h)
 	{