mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-02 23:07:36 +02:00
Exchanging artifacts between slots should work again nicely. Minor fixes.
This commit is contained in:
parent
a8bb13cbcd
commit
2f996f14ba
@ -216,6 +216,10 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
|
|||||||
}
|
}
|
||||||
curHero = hero;
|
curHero = hero;
|
||||||
|
|
||||||
|
artifs->updateState = true;
|
||||||
|
artifs->setHero(hero);
|
||||||
|
artifs->updateState = false;
|
||||||
|
|
||||||
//pos temporarily switched, restored later
|
//pos temporarily switched, restored later
|
||||||
pos.x -= 65;
|
pos.x -= 65;
|
||||||
pos.y -= 8;
|
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());
|
sprintf(bufor, CGI->generaltexth->allTexts[205].c_str(), hero->name.c_str(), hero->mana, hero->manaLimit());
|
||||||
spellPointsArea->text = std::string(bufor);
|
spellPointsArea->text = std::string(bufor);
|
||||||
|
|
||||||
artifs->updateState = true;
|
|
||||||
artifs->setHero(hero);
|
|
||||||
artifs->updateState = false;
|
|
||||||
|
|
||||||
//if we have exchange window with this hero open
|
//if we have exchange window with this hero open
|
||||||
bool noDismiss=false;
|
bool noDismiss=false;
|
||||||
|
@ -1049,7 +1049,7 @@ void CKingdomInterface::CHeroItem::CArtPlace::clickLeft(tribool down, bool previ
|
|||||||
{tlog1<<type;
|
{tlog1<<type;
|
||||||
if(type == 0)
|
if(type == 0)
|
||||||
{
|
{
|
||||||
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (screen->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);
|
GH.pushInt(spellWindow);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -545,7 +545,12 @@ void CSpellWindow::keyPressed(const SDL_KeyboardEvent & key)
|
|||||||
{
|
{
|
||||||
SDLKey hlpKey = key.keysym.sym;
|
SDLKey hlpKey = key.keysym.sym;
|
||||||
if(isNumKey(hlpKey, false))
|
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};
|
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};
|
||||||
|
|
||||||
|
@ -4530,34 +4530,7 @@ void CArtPlace::select ()
|
|||||||
//ourOwner->curHero->recreateArtBonuses();
|
//ourOwner->curHero->recreateArtBonuses();
|
||||||
|
|
||||||
// Update the hero bonuses.
|
// Update the hero bonuses.
|
||||||
CHeroWindow* chw = dynamic_cast<CHeroWindow*>(GH.topInt());
|
ourOwner->updateParentWindow();
|
||||||
if (chw != NULL)
|
|
||||||
{
|
|
||||||
chw->deactivate();
|
|
||||||
chw->setHero(ourOwner->curHero);
|
|
||||||
chw->activate();
|
|
||||||
}
|
|
||||||
else if(CExchangeWindow* cew = dynamic_cast<CExchangeWindow*>(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; g<ARRAY_COUNT(cew->heroInst); ++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();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (slotID >= 19)
|
if (slotID >= 19)
|
||||||
ourOwner->scrollBackpack(backpackCorrection);
|
ourOwner->scrollBackpack(backpackCorrection);
|
||||||
@ -4716,7 +4689,7 @@ void CArtifactsOfHero::setHero(const CGHeroInstance * hero)
|
|||||||
if(curHero != hero)
|
if(curHero != hero)
|
||||||
{
|
{
|
||||||
delete curHero;
|
delete curHero;
|
||||||
curHero = new CGHeroInstance(*hero);
|
hero = curHero = new CGHeroInstance(*hero);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compensate backpack pos if an artifact was insertad before it.
|
// 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);
|
CGI->arth->unequipArtifact(curHero->artifWorn, commonInfo->srcSlotID);
|
||||||
else
|
else
|
||||||
curHero->artifacts.erase(curHero->artifacts.begin() + (commonInfo->srcSlotID - 19));
|
curHero->artifacts.erase(curHero->artifacts.begin() + (commonInfo->srcSlotID - 19));
|
||||||
//curHero->recreateArtBonuses();
|
|
||||||
|
updateParentWindow(); //TODO: evil! but does the thing
|
||||||
|
|
||||||
// Source <- Dest
|
// Source <- Dest
|
||||||
commonInfo->srcArtifact = commonInfo->destArtifact;
|
commonInfo->srcArtifact = commonInfo->destArtifact;
|
||||||
@ -4932,6 +4906,46 @@ CArtifactsOfHero::~CArtifactsOfHero()
|
|||||||
CGI->curh->dragAndDropCursor(NULL);
|
CGI->curh->dragAndDropCursor(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CArtifactsOfHero::updateParentWindow()
|
||||||
|
{
|
||||||
|
if (CHeroWindow* chw = dynamic_cast<CHeroWindow*>(GH.topInt()))
|
||||||
|
{
|
||||||
|
if(updateState)
|
||||||
|
chw->curHero = curHero;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chw->deactivate();
|
||||||
|
chw->setHero(curHero);
|
||||||
|
chw->activate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(CExchangeWindow* cew = dynamic_cast<CExchangeWindow*>(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; g<ARRAY_COUNT(cew->heroInst); ++g)
|
||||||
|
{
|
||||||
|
if(cew->heroInst[g] == curHero)
|
||||||
|
{
|
||||||
|
cew->artifs[g]->setHero(curHero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cew->prepareBackground();
|
||||||
|
cew->activate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CExchangeWindow::close()
|
void CExchangeWindow::close()
|
||||||
{
|
{
|
||||||
GH.popIntTotally(this);
|
GH.popIntTotally(this);
|
||||||
|
@ -943,7 +943,7 @@ public:
|
|||||||
|
|
||||||
CArtifactsOfHero(const Point& position); //c-tor
|
CArtifactsOfHero(const Point& position); //c-tor
|
||||||
~CArtifactsOfHero(); //d-tor
|
~CArtifactsOfHero(); //d-tor
|
||||||
|
void updateParentWindow();
|
||||||
friend class CArtPlace;
|
friend class CArtPlace;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1190,7 +1190,7 @@ void CGHeroInstance::updateSkill(int which, int val)
|
|||||||
}
|
}
|
||||||
if (skillVal) //we don't need bonuses of other types here
|
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
|
if (b) //only local hero bonus
|
||||||
{
|
{
|
||||||
b->val = skillVal;
|
b->val = skillVal;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user