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:
@@ -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"};
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user