1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +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 //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->unlock(); LOCPLINT->pim->lock();
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;
}
} }
else //remove old path and find a new one else //remove old path and find a new one
{ {
int3 bufpos = currentHero->getPosition(false); int3 bufpos = currentHero->getPosition(false);
CPath *& pathForCurhero = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second; CPath *& pathForCurhero = LOCPLINT->adventureInt->heroList.items[LOCPLINT->adventureInt->heroList.selected].second;
if(pathForCurhero) if(pathForCurhero)
delete 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" } //end of hero is selected "case"
} }
@ -605,7 +595,11 @@ void CTerrainRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
void CTerrainRect::hover(bool on) void CTerrainRect::hover(bool on)
{ {
if (!on) if (!on)
{
LOCPLINT->adventureInt->statusbar.clear(); LOCPLINT->adventureInt->statusbar.clear();
CGI->curh->changeGraphic(0,0);
}
Hoverable::hover(on);
} }
void CTerrainRect::showPath(const SDL_Rect * extRect) void CTerrainRect::showPath(const SDL_Rect * extRect)
{ {
@ -1357,11 +1351,6 @@ void CAdvMapInt::fendTurn()
void CAdvMapInt::activate() void CAdvMapInt::activate()
{ {
if(subInt == heroWindow)
{
heroWindow->activate();
return;
}
if(active++) if(active++)
{ {
tlog1 << "Error: advmapint already active...\n"; tlog1 << "Error: advmapint already active...\n";
@ -1390,11 +1379,6 @@ void CAdvMapInt::activate()
} }
void CAdvMapInt::deactivate() void CAdvMapInt::deactivate()
{ {
if(subInt == heroWindow)
{
heroWindow->deactivate();
return;
}
KeyInterested::deactivate(); KeyInterested::deactivate();
hide(); hide();

View File

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

View File

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

View File

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