1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

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
This commit is contained in:
Ivan Savenko
2025-07-20 16:25:50 +03:00
parent 7fcb0246fb
commit fe2a981ddf
4 changed files with 29 additions and 2 deletions

View File

@@ -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> primSkillsArr = {"PSKIL32", "PSKIL32", "PSKIL42", "PSKILL"};
static const std::array<std::string, 4> secSkillsArr = {"SECSK32", "SECSK32", "SECSKILL", "SECSK82"}; 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> 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> artifactArr = {"Artifact", "Artifact", "Artifact", "Artifact"};
static const std::array<std::string, 4> spellsArr = {"SpellInt", "SpellInt", "SpellInt", "SPELLSCR"}; static const std::array<std::string, 4> spellsArr = {"SpellInt", "SpellInt", "SpellInt", "SPELLSCR"};
static const std::array<std::string, 4> moraleArr = {"IMRL22", "IMRL30", "IMRL42", "imrl82"}; static const std::array<std::string, 4> moraleArr = {"IMRL22", "IMRL30", "IMRL42", "imrl82"};

View File

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

View File

@@ -23,6 +23,7 @@
#include "../mapObjectConstructors/CObjectClassesHandler.h" #include "../mapObjectConstructors/CObjectClassesHandler.h"
#include "../mapObjectConstructors/CommonConstructors.h" #include "../mapObjectConstructors/CommonConstructors.h"
#include "../networkPacks/PacksForClient.h" #include "../networkPacks/PacksForClient.h"
#include "CPlayerState.h"
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
@@ -135,7 +136,31 @@ std::string CGUniversity::getSpeechTranslated() const
void CGUniversity::onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) 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); 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 VCMI_LIB_NAMESPACE_END

View File

@@ -65,6 +65,8 @@ public:
std::vector<TradeItemBuy> availableItemsIds(EMarketMode mode) const override; std::vector<TradeItemBuy> availableItemsIds(EMarketMode mode) const override;
void onHeroVisit(IGameEventCallback & gameEvents, const CGHeroInstance * h) const override; //open window 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) template <typename Handler> void serialize(Handler &h)
{ {