1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

* fixed selecting new path

* always restoring default cursor when movng mouse out of the terrain
* fixed herolist scrolling
* fixed picking guarded resources
This commit is contained in:
Michał W. Urbańczyk 2009-05-01 22:08:03 +00:00
parent e10ab66631
commit 1661da2fcb
4 changed files with 30 additions and 42 deletions

View File

@ -477,30 +477,20 @@ void CTerrainRect::clickLeft(tribool down)
}
//still here? we need to move hero if we clicked end of already selected path or calculate a new path otherwise
if (currentPath)
if (currentPath && currentPath->endPos() == mp)//we'll be moving
{
if (currentPath->endPos() == mp) //we'll be moving
{
LOCPLINT->pim->unlock();
LOCPLINT->moveHero(currentHero,*currentPath);
LOCPLINT->pim->lock();
}
else //remove an old path
{
delete currentPath;
currentPath=NULL;
LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.getPosOfHero(LOCPLINT->adventureInt->selection)].second = NULL;
}
LOCPLINT->pim->unlock();
LOCPLINT->moveHero(currentHero,*currentPath);
LOCPLINT->pim->lock();
}
else //remove old path and find a new one
{
int3 bufpos = currentHero->getPosition(false);
CPath *& pathForCurhero = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second;
if(pathForCurhero)
delete pathForCurhero;
currentPath = pathForCurhero = LOCPLINT->cb->getPath(bufpos, mp, currentHero);;
currentPath = pathForCurhero = LOCPLINT->cb->getPath(bufpos, mp, currentHero);
}
} //end of hero is selected "case"
}
@ -605,7 +595,11 @@ void CTerrainRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
void CTerrainRect::hover(bool on)
{
if (!on)
{
LOCPLINT->adventureInt->statusbar.clear();
CGI->curh->changeGraphic(0,0);
}
Hoverable::hover(on);
}
void CTerrainRect::showPath(const SDL_Rect * extRect)
{
@ -1357,11 +1351,6 @@ void CAdvMapInt::fendTurn()
void CAdvMapInt::activate()
{
if(subInt == heroWindow)
{
heroWindow->activate();
return;
}
if(active++)
{
tlog1 << "Error: advmapint already active...\n";
@ -1390,11 +1379,6 @@ void CAdvMapInt::activate()
}
void CAdvMapInt::deactivate()
{
if(subInt == heroWindow)
{
heroWindow->deactivate();
return;
}
KeyInterested::deactivate();
hide();

View File

@ -557,6 +557,7 @@ ComponentsToBlit::ComponentsToBlit(std::vector<SComponent*> & SComps, int maxw,
else
{
curw += toadd;
amax(w,curw);
}
comps[curr].push_back(cur);

View File

@ -2925,7 +2925,7 @@ void CHeroList::clickLeft(tribool down)
from--;
if (from<0)
from=0;
draw(screen2);
draw(screen);
}
}
else if (!pressed) //down
@ -2938,7 +2938,7 @@ void CHeroList::clickLeft(tribool down)
//if (from<items.size()-5)
// from=items.size()-5;
draw(screen2);
draw(screen);
}
}
else
@ -2995,22 +2995,25 @@ void CHeroList::clickRight(tribool down)
{
LOCPLINT->adventureInt->handleRightClick(CGI->generaltexth->zelp[304].second,down,this);
}
//if not buttons then heroes
int hx = LOCPLINT->current->motion.x, hy = LOCPLINT->current->motion.y;
hx-=pos.x;
hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
int ny = hy/32;
if ((ny>SIZE || ny<0) || (from+ny>=items.size()))
else
{
return;
}
//if not buttons then heroes
int hx = LOCPLINT->current->motion.x, hy = LOCPLINT->current->motion.y;
hx-=pos.x;
hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
int ny = hy/32;
if ((ny>SIZE || ny<0) || (from+ny>=items.size()))
{
return;
}
//show popup
CInfoPopup * ip = new CInfoPopup(graphics->heroWins[items[from+ny].first->subID],
LOCPLINT->current->motion.x-graphics->heroWins[items[from+ny].first->subID]->w,
LOCPLINT->current->motion.y-graphics->heroWins[items[from+ny].first->subID]->h,
false);
LOCPLINT->pushInt(ip);
//show popup
CInfoPopup * ip = new CInfoPopup(graphics->heroWins[items[from+ny].first->subID],
LOCPLINT->current->motion.x-graphics->heroWins[items[from+ny].first->subID]->w,
LOCPLINT->current->motion.y-graphics->heroWins[items[from+ny].first->subID]->h,
false);
LOCPLINT->pushInt(ip);
}
}
else
{

View File

@ -1658,7 +1658,7 @@ void CGResource::onHeroVisit( const CGHeroInstance * h ) const
}
else
{
fightForRes(0,h);
fightForRes(1,h);
}
}
else