diff --git a/client/CHeroWindow.cpp b/client/CHeroWindow.cpp index 9f9bfec19..400618d50 100644 --- a/client/CHeroWindow.cpp +++ b/client/CHeroWindow.cpp @@ -216,6 +216,10 @@ void CHeroWindow::setHero(const CGHeroInstance *hero) } curHero = hero; + artifs->updateState = true; + artifs->setHero(hero); + artifs->updateState = false; + //pos temporarily switched, restored later pos.x -= 65; pos.y -= 8; @@ -271,9 +275,6 @@ void CHeroWindow::setHero(const CGHeroInstance *hero) sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), hero->name.c_str(), hero->mana, hero->manaLimit()); spellPointsArea->text = std::string(bufor); - artifs->updateState = true; - artifs->setHero(hero); - artifs->updateState = false; //if we have exchange window with this hero open bool noDismiss=false; diff --git a/client/CKingdomInterface.cpp b/client/CKingdomInterface.cpp index e8e9efe46..e1384e81b 100644 --- a/client/CKingdomInterface.cpp +++ b/client/CKingdomInterface.cpp @@ -1049,7 +1049,7 @@ void CKingdomInterface::CHeroItem::CArtPlace::clickLeft(tribool down, bool previ {tlog1<w - 620)/2, (screen->h - 595)/2), hero->hero, LOCPLINT); + CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), hero->hero, LOCPLINT, false); GH.pushInt(spellWindow); } else diff --git a/client/CSpellWindow.cpp b/client/CSpellWindow.cpp index 9612dd214..561c88ead 100644 --- a/client/CSpellWindow.cpp +++ b/client/CSpellWindow.cpp @@ -545,7 +545,12 @@ void CSpellWindow::keyPressed(const SDL_KeyboardEvent & key) { SDLKey hlpKey = key.keysym.sym; if(isNumKey(hlpKey, false)) - hlpKey = numToDigit(hlpKey); + { + if(hlpKey == SDLK_KP_PLUS) + hlpKey = SDLK_EQUALS; + else + hlpKey = numToDigit(hlpKey); + } static const SDLKey spellSelectors[] = {SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_0, SDLK_MINUS, SDLK_EQUALS}; diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index c02d27de2..e1bf0c3fa 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -4530,34 +4530,7 @@ void CArtPlace::select () //ourOwner->curHero->recreateArtBonuses(); // Update the hero bonuses. - CHeroWindow* chw = dynamic_cast(GH.topInt()); - if (chw != NULL) - { - chw->deactivate(); - chw->setHero(ourOwner->curHero); - chw->activate(); - } - else if(CExchangeWindow* cew = dynamic_cast(GH.topInt())) - { - //assert(cew); // Either an exchange- or hero window should be active if an artifact slot is selected. - cew->deactivate(); - for(int g=0; gheroInst); ++g) - { - if(cew->heroInst[g] == ourOwner->curHero) - { - cew->artifs[g]->setHero(ourOwner->curHero); - } - } - - //use our copy of hero to draw window - if(cew->heroInst[0]->id == ourOwner->curHero->id) - cew->heroInst[0] = ourOwner->curHero; - else - cew->heroInst[1] = ourOwner->curHero; - - cew->prepareBackground(); - cew->activate(); - } + ourOwner->updateParentWindow(); if (slotID >= 19) ourOwner->scrollBackpack(backpackCorrection); @@ -4716,7 +4689,7 @@ void CArtifactsOfHero::setHero(const CGHeroInstance * hero) if(curHero != hero) { delete curHero; - curHero = new CGHeroInstance(*hero); + hero = curHero = new CGHeroInstance(*hero); } // Compensate backpack pos if an artifact was insertad before it. @@ -4736,7 +4709,8 @@ void CArtifactsOfHero::setHero(const CGHeroInstance * hero) CGI->arth->unequipArtifact(curHero->artifWorn, commonInfo->srcSlotID); else curHero->artifacts.erase(curHero->artifacts.begin() + (commonInfo->srcSlotID - 19)); - //curHero->recreateArtBonuses(); + + updateParentWindow(); //TODO: evil! but does the thing // Source <- Dest commonInfo->srcArtifact = commonInfo->destArtifact; @@ -4932,6 +4906,46 @@ CArtifactsOfHero::~CArtifactsOfHero() CGI->curh->dragAndDropCursor(NULL); } +void CArtifactsOfHero::updateParentWindow() +{ + if (CHeroWindow* chw = dynamic_cast(GH.topInt())) + { + if(updateState) + chw->curHero = curHero; + else + { + chw->deactivate(); + chw->setHero(curHero); + chw->activate(); + } + } + else if(CExchangeWindow* cew = dynamic_cast(GH.topInt())) + { + + //use our copy of hero to draw window + if(cew->heroInst[0]->id == curHero->id) + cew->heroInst[0] = curHero; + else + cew->heroInst[1] = curHero; + + if(!updateState) + { + cew->deactivate(); + for(int g=0; gheroInst); ++g) + { + if(cew->heroInst[g] == curHero) + { + cew->artifs[g]->setHero(curHero); + } + } + + + cew->prepareBackground(); + cew->activate(); + } + } +} + void CExchangeWindow::close() { GH.popIntTotally(this); diff --git a/client/GUIClasses.h b/client/GUIClasses.h index b1d2145eb..31dd0c4f9 100644 --- a/client/GUIClasses.h +++ b/client/GUIClasses.h @@ -943,7 +943,7 @@ public: CArtifactsOfHero(const Point& position); //c-tor ~CArtifactsOfHero(); //d-tor - + void updateParentWindow(); friend class CArtPlace; }; diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index ef4b892d1..752389795 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -1190,7 +1190,7 @@ void CGHeroInstance::updateSkill(int which, int val) } if (skillVal) //we don't need bonuses of other types here { - Bonus * b = getBonus(Selector::typeSybtype(Bonus::SECONDARY_SKILL_PREMY, which) && Selector::sourceType(Bonus::SECONDARY_SKILL)); + Bonus * b = bonuses.getFirst(Selector::typeSybtype(Bonus::SECONDARY_SKILL_PREMY, which) && Selector::sourceType(Bonus::SECONDARY_SKILL)); if (b) //only local hero bonus { b->val = skillVal;