mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
strange bug while clicking
This commit is contained in:
parent
9ed4f66cb7
commit
b1af2fb829
@ -71,12 +71,22 @@ CHeroWindow::CHeroWindow(int playerColor): artFeet(0), artHead(0), artLHand(0),
|
||||
primSkillAreas[v]->text = CGI->generaltexth->arraytxt[2+v].substr(1, CGI->generaltexth->arraytxt[2+v].size()-2);
|
||||
primSkillAreas[v]->type = v;
|
||||
primSkillAreas[v]->bonus = -1; // to be initilized when hero is being set
|
||||
primSkillAreas[v]->baseType = 0;
|
||||
}
|
||||
expArea = new LRClickableAreaWText();
|
||||
expArea->pos.x = 83;
|
||||
expArea->pos.y = 236;
|
||||
expArea->pos.w = 136;
|
||||
expArea->pos.h = 42;
|
||||
for(int i=0; i<8; ++i)
|
||||
{
|
||||
secSkillAreas.push_back(new LRClickableAreaWTextComp());
|
||||
secSkillAreas[i]->pos.x = (i%2==0) ? (83) : (227);
|
||||
secSkillAreas[i]->pos.y = 284 + 48 * (i/2);
|
||||
secSkillAreas[i]->pos.w = 136;
|
||||
secSkillAreas[i]->pos.h = 42;
|
||||
secSkillAreas[i]->baseType = 1;
|
||||
}
|
||||
}
|
||||
|
||||
CHeroWindow::~CHeroWindow()
|
||||
@ -132,6 +142,10 @@ CHeroWindow::~CHeroWindow()
|
||||
{
|
||||
delete primSkillAreas[v];
|
||||
}
|
||||
for(int v=0; v<secSkillAreas.size(); ++v)
|
||||
{
|
||||
delete secSkillAreas[v];
|
||||
}
|
||||
}
|
||||
|
||||
void CHeroWindow::show(SDL_Surface *to)
|
||||
@ -177,7 +191,7 @@ void CHeroWindow::show(SDL_Surface *to)
|
||||
|
||||
void CHeroWindow::setHero(const CGHeroInstance *hero)
|
||||
{
|
||||
if(!hero) //something strange... no hero? it should happen
|
||||
if(!hero) //something strange... no hero? it shouldn't happen
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -188,6 +202,11 @@ void CHeroWindow::setHero(const CGHeroInstance *hero)
|
||||
{
|
||||
primSkillAreas[g]->bonus = hero->primSkills[g];
|
||||
}
|
||||
for(int g=0; g<secSkillAreas.size(); ++g)
|
||||
{
|
||||
secSkillAreas[g]->type = hero->secSkills[g].first;
|
||||
secSkillAreas[g]->bonus = hero->secSkills[g].second;
|
||||
}
|
||||
|
||||
char * th = new char[200];
|
||||
sprintf(th, CGI->generaltexth->allTexts[2].substr(1, CGI->generaltexth->allTexts[2].size()-2).c_str(), hero->level, CGI->heroh->reqExp(hero->level+1)-hero->exp, hero->exp);
|
||||
@ -390,10 +409,9 @@ void CHeroWindow::activate()
|
||||
{
|
||||
primSkillAreas[v]->activate();
|
||||
}
|
||||
|
||||
for(int g=0; g<heroListMi.size(); ++g)
|
||||
for(int v=0; v<curHero->secSkills.size(); ++v)
|
||||
{
|
||||
heroListMi[g]->activate();
|
||||
secSkillAreas[v]->activate();
|
||||
}
|
||||
redrawCurBack();
|
||||
|
||||
@ -465,10 +483,9 @@ void CHeroWindow::deactivate()
|
||||
{
|
||||
primSkillAreas[v]->deactivate();
|
||||
}
|
||||
|
||||
for(int g=0; g<heroListMi.size(); ++g)
|
||||
for(int v=0; v<secSkillAreas.size(); ++v)
|
||||
{
|
||||
heroListMi[g]->deactivate();
|
||||
secSkillAreas[v]->deactivate();
|
||||
}
|
||||
|
||||
if(artFeet)
|
||||
@ -847,7 +864,7 @@ void LRClickableAreaWTextComp::clickLeft(boost::logic::tribool down)
|
||||
{
|
||||
if(!down)
|
||||
{
|
||||
LOCPLINT->showInfoDialog(text, std::vector<SComponent*>(1, new SComponent(SComponent::Etype::primskill, type, bonus)));
|
||||
LOCPLINT->showInfoDialog(text, std::vector<SComponent*>(1, new SComponent(SComponent::Etype(baseType), type, bonus)));
|
||||
}
|
||||
}
|
||||
void LRClickableAreaWTextComp::clickRight(boost::logic::tribool down)
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
virtual void clickLeft (tribool down);
|
||||
};
|
||||
|
||||
class LRClickableAreaWText: public virtual LClickableArea, public virtual RClickableArea
|
||||
class LRClickableAreaWText: public LClickableArea, public RClickableArea
|
||||
{
|
||||
public:
|
||||
std::string text;
|
||||
@ -43,10 +43,11 @@ public:
|
||||
virtual void clickRight (tribool down);
|
||||
};
|
||||
|
||||
class LRClickableAreaWTextComp: public virtual LClickableArea, public virtual RClickableArea
|
||||
class LRClickableAreaWTextComp: public LClickableArea, public RClickableArea
|
||||
{
|
||||
public:
|
||||
std::string text;
|
||||
int baseType;
|
||||
int bonus, type;
|
||||
virtual void activate();
|
||||
virtual void deactivate();
|
||||
@ -94,6 +95,7 @@ class CHeroWindow: public IActivable, public IShowable, public virtual CIntObjec
|
||||
LRClickableAreaWText * portraitArea;
|
||||
std::vector<LRClickableAreaWTextComp *> primSkillAreas;
|
||||
LRClickableAreaWText * expArea;
|
||||
std::vector<LRClickableAreaWTextComp *> secSkillAreas;
|
||||
public:
|
||||
int player;
|
||||
CHeroWindow(int playerColor); //c-tor
|
||||
|
@ -344,6 +344,9 @@ SDL_Surface * SComponent::getImg()
|
||||
case primskill:
|
||||
return CGI->heroh->pskillsb->ourImages[subtype].bitmap;
|
||||
break;
|
||||
case secskill:
|
||||
return CGI->abilh->abils44->ourImages[subtype*3 + 3 + val].bitmap;
|
||||
break;
|
||||
case resource:
|
||||
return CGI->heroh->resources->ourImages[subtype].bitmap;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user