|
@@ -891,26 +891,20 @@ CUniversityWindow::CItem::CItem(CUniversityWindow * _parent, int _ID, int X, int
|
|
|
pos.x += X;
|
|
|
pos.y += Y;
|
|
|
|
|
|
- // TODO: restore
|
|
|
- //bars->setCustom("UNIVRED", 0, 0);
|
|
|
- //bars->setCustom("UNIVGOLD", 1, 0);
|
|
|
- //bars->setCustom("UNIVGREN", 2, 0);
|
|
|
-
|
|
|
- topBar = std::make_shared<CPicture>(ImagePath::builtin("UNIVRED"), Point(-28, -22));
|
|
|
- bottomBar = std::make_shared<CPicture>(ImagePath::builtin("UNIVRED"), Point(-28, 48));
|
|
|
-
|
|
|
icon = std::make_shared<CAnimImage>(AnimationPath::builtin("SECSKILL"), _ID * 3 + 3, 0);
|
|
|
|
|
|
- name = std::make_shared<CLabel>(22, -13, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->skillh->getByIndex(ID)->getNameTranslated());
|
|
|
- level = std::make_shared<CLabel>(22, 57, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->levels[0]);
|
|
|
-
|
|
|
pos.h = icon->pos.h;
|
|
|
pos.w = icon->pos.w;
|
|
|
+
|
|
|
+ update();
|
|
|
}
|
|
|
|
|
|
void CUniversityWindow::CItem::clickPressed(const Point & cursorPosition)
|
|
|
{
|
|
|
- if(state() == 2)
|
|
|
+ bool skillKnown = parent->hero->getSecSkillLevel(ID);
|
|
|
+ bool canLearn = parent->hero->canLearnSkill(ID);
|
|
|
+
|
|
|
+ if (!skillKnown && canLearn)
|
|
|
GH.windows().createAndPushWindow<CUnivConfirmWindow>(parent, ID, LOCPLINT->cb->getResourceAmount(EGameResID::GOLD) >= 2000);
|
|
|
}
|
|
|
|
|
@@ -919,21 +913,35 @@ void CUniversityWindow::CItem::showPopupWindow(const Point & cursorPosition)
|
|
|
CRClickPopup::createAndPush(CGI->skillh->getByIndex(ID)->getDescriptionTranslated(1), std::make_shared<CComponent>(ComponentType::SEC_SKILL, ID, 1));
|
|
|
}
|
|
|
|
|
|
-void CUniversityWindow::CItem::hover(bool on)
|
|
|
+void CUniversityWindow::CItem::update()
|
|
|
{
|
|
|
- if(on)
|
|
|
- GH.statusbar()->write(CGI->skillh->getByIndex(ID)->getNameTranslated());
|
|
|
+ bool skillKnown = parent->hero->getSecSkillLevel(ID);
|
|
|
+ bool canLearn = parent->hero->canLearnSkill(ID);
|
|
|
+
|
|
|
+ ImagePath image;
|
|
|
+
|
|
|
+ if (skillKnown)
|
|
|
+ image = ImagePath::builtin("UNIVGOLD");
|
|
|
+ else if (canLearn)
|
|
|
+ image = ImagePath::builtin("UNIVGREN");
|
|
|
else
|
|
|
- GH.statusbar()->clear();
|
|
|
+ image = ImagePath::builtin("UNIVRED");
|
|
|
+
|
|
|
+ OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
|
|
+ topBar = std::make_shared<CPicture>(image, Point(-28, -22));
|
|
|
+ bottomBar = std::make_shared<CPicture>(image, Point(-28, 48));
|
|
|
+
|
|
|
+ // needs to be on top of background bars
|
|
|
+ name = std::make_shared<CLabel>(22, -13, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, ID.toEntity(VLC)->getNameTranslated());
|
|
|
+ level = std::make_shared<CLabel>(22, 57, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->levels[0]);
|
|
|
}
|
|
|
|
|
|
-int CUniversityWindow::CItem::state()
|
|
|
+void CUniversityWindow::CItem::hover(bool on)
|
|
|
{
|
|
|
- if(parent->hero->getSecSkillLevel(SecondarySkill(ID)))//hero know this skill
|
|
|
- return 1;
|
|
|
- if(!parent->hero->canLearnSkill(SecondarySkill(ID)))//can't learn more skills
|
|
|
- return 0;
|
|
|
- return 2;
|
|
|
+ if(on)
|
|
|
+ GH.statusbar()->write(ID.toEntity(VLC)->getNameTranslated());
|
|
|
+ else
|
|
|
+ GH.statusbar()->clear();
|
|
|
}
|
|
|
|
|
|
CUniversityWindow::CUniversityWindow(const CGHeroInstance * _hero, const IMarket * _market, const std::function<void()> & onWindowClosed)
|
|
@@ -987,12 +995,17 @@ void CUniversityWindow::close()
|
|
|
CStatusbarWindow::close();
|
|
|
}
|
|
|
|
|
|
+void CUniversityWindow::updateSecondarySkills()
|
|
|
+{
|
|
|
+ for (auto const & item : items)
|
|
|
+ item->update();
|
|
|
+}
|
|
|
+
|
|
|
void CUniversityWindow::makeDeal(SecondarySkill skill)
|
|
|
{
|
|
|
LOCPLINT->cb->trade(market, EMarketMode::RESOURCE_SKILL, GameResID(GameResID::GOLD), skill, 1, hero);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
CUnivConfirmWindow::CUnivConfirmWindow(CUniversityWindow * owner_, SecondarySkill SKILL, bool available)
|
|
|
: CWindowObject(PLAYER_COLORED, ImagePath::builtin("UNIVERS2.PCX")),
|
|
|
owner(owner_)
|