From fe2a981ddfd48187491b0782333811d9ce0ba03c Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 20 Jul 2025 16:25:50 +0300 Subject: [PATCH] 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 --- client/widgets/CComponent.cpp | 2 +- client/windows/InfoWindows.cpp | 2 +- lib/mapObjects/CGMarket.cpp | 25 +++++++++++++++++++++++++ lib/mapObjects/CGMarket.h | 2 ++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/client/widgets/CComponent.cpp b/client/widgets/CComponent.cpp index 5b9d84f63..ccd19ce91 100644 --- a/client/widgets/CComponent.cpp +++ b/client/widgets/CComponent.cpp @@ -119,7 +119,7 @@ std::vector CComponent::getFileName() const static const std::array primSkillsArr = {"PSKIL32", "PSKIL32", "PSKIL42", "PSKILL"}; static const std::array secSkillsArr = {"SECSK32", "SECSK32", "SECSKILL", "SECSK82"}; static const std::array resourceArr = {"SMALRES", "RESOURCE", "RESOURCE", "RESOUR82"}; - static const std::array creatureArr = {"CPRSMALL", "CPRSMALL", "CPRSMALL", "TWCRPORT"}; + static const std::array creatureArr = {"CPRSMALL", "CPRSMALL", "TWCRPORT", "TWCRPORT"}; static const std::array artifactArr = {"Artifact", "Artifact", "Artifact", "Artifact"}; static const std::array spellsArr = {"SpellInt", "SpellInt", "SpellInt", "SPELLSCR"}; static const std::array moraleArr = {"IMRL22", "IMRL30", "IMRL42", "imrl82"}; diff --git a/client/windows/InfoWindows.cpp b/client/windows/InfoWindows.cpp index 07b88cb47..98997550e 100644 --- a/client/windows/InfoWindows.cpp +++ b/client/windows/InfoWindows.cpp @@ -233,7 +233,7 @@ void CRClickPopup::createAndPush(const CGObjectInstance * obj, const Point & p, std::vector> guiComponents; for(auto & component : components) - guiComponents.push_back(std::make_shared(component)); + guiComponents.push_back(std::make_shared(component, CComponent::medium)); if(GAME->interface()->localState->getCurrentHero()) CRClickPopup::createAndPush(obj->getPopupText(GAME->interface()->localState->getCurrentHero()), guiComponents); diff --git a/lib/mapObjects/CGMarket.cpp b/lib/mapObjects/CGMarket.cpp index c66d9271f..8fadfdc2f 100644 --- a/lib/mapObjects/CGMarket.cpp +++ b/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 CGUniversity::getPopupComponents(PlayerColor player) const +{ + std::vector result; + + if (!wasVisited(player)) + return result; + + for (auto const & skill : skills) + result.emplace_back(ComponentType::SEC_SKILL, skill.as()); + + return result; +} + VCMI_LIB_NAMESPACE_END diff --git a/lib/mapObjects/CGMarket.h b/lib/mapObjects/CGMarket.h index f52cecb08..2ddd551f4 100644 --- a/lib/mapObjects/CGMarket.h +++ b/lib/mapObjects/CGMarket.h @@ -65,6 +65,8 @@ public: std::vector availableItemsIds(EMarketMode mode) const override; void onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const override; //open window + std::vector getPopupComponents(PlayerColor player) const override; + bool wasVisited (PlayerColor player) const override; template void serialize(Handler &h) {