1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
This commit is contained in:
Michał W. Urbańczyk 2009-11-14 20:14:15 +00:00
parent 4151310be6
commit d18b6c3d5a
6 changed files with 27 additions and 23 deletions

View File

@ -853,7 +853,7 @@ void CTerrainRect::hover(bool on)
}
//Hoverable::hover(on);
}
void CTerrainRect::showPath(const SDL_Rect * extRect)
void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
{
for (size_t i=0; i < currentPath->nodes.size()-1; ++i)
{
@ -1130,60 +1130,60 @@ void CTerrainRect::showPath(const SDL_Rect * extRect)
hvy = (y+arrows->ourImages[pn].bitmap->h)-(pos.y+pos.h);
SDL_Rect prevClip;
SDL_GetClipRect(screen, &prevClip);
SDL_SetClipRect(screen, extRect); //preventing blitting outside of that rect
SDL_GetClipRect(to, &prevClip);
SDL_SetClipRect(to, extRect); //preventing blitting outside of that rect
if(ADVOPT.smoothMove) //version for smooth hero move, with pos shifts
{
if (hvx<0 && hvy<0)
{
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, screen, &genRect(32, 32, x + moveX, y + moveY));
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, to, &genRect(32, 32, x + moveX, y + moveY));
}
else if(hvx<0)
{
CSDL_Ext::blit8bppAlphaTo24bpp
(arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0),
screen, &genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x + moveX, y + moveY));
to, &genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x + moveX, y + moveY));
}
else if (hvy<0)
{
CSDL_Ext::blit8bppAlphaTo24bpp
(arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0),
screen, &genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY));
to, &genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY));
}
else
{
CSDL_Ext::blit8bppAlphaTo24bpp
(arrows->ourImages[pn].bitmap, &genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w-hvx, 0, 0),
screen, &genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY));
to, &genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x + moveX, y + moveY));
}
}
else //standard version
{
if (hvx<0 && hvy<0)
{
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, screen, &genRect(32, 32, x, y));
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, to, &genRect(32, 32, x, y));
}
else if(hvx<0)
{
CSDL_Ext::blit8bppAlphaTo24bpp
(arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, 0, 0),
screen, &genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x, y));
to, &genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w, x, y));
}
else if (hvy<0)
{
CSDL_Ext::blit8bppAlphaTo24bpp
(arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, 0, 0),
screen, &genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x, y));
to, &genRect(arrows->ourImages[pn].bitmap->h, arrows->ourImages[pn].bitmap->w-hvx, x, y));
}
else
{
CSDL_Ext::blit8bppAlphaTo24bpp
(arrows->ourImages[pn].bitmap, &genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w-hvx, 0, 0),
screen, &genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x, y));
to, &genRect(arrows->ourImages[pn].bitmap->h-hvy, arrows->ourImages[pn].bitmap->w-hvx, x, y));
}
}
SDL_SetClipRect(screen, &prevClip);
SDL_SetClipRect(to, &prevClip);
}
} //for (int i=0;i<currentPath->nodes.size()-1;i++)
@ -1205,7 +1205,7 @@ void CTerrainRect::show(SDL_Surface * to)
//SDL_FreeSurface(teren);
if (currentPath && LOCPLINT->adventureInt->position.z==currentPath->startPos().z) //drawing path
{
showPath(&pos);
showPath(&pos, to);
}
}

View File

@ -88,7 +88,7 @@ public:
void hover(bool on);
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
void show(SDL_Surface * to);
void showPath(const SDL_Rect * extRect);
void showPath(const SDL_Rect * extRect, SDL_Surface * to);
int3 whichTileIsIt(const int & x, const int & y); //x,y are cursor position
int3 whichTileIsIt(); //uses current cursor pos
};

View File

@ -1683,8 +1683,9 @@ void CTextInput::keyPressed( const SDL_KeyboardEvent & key )
text.resize(text.size()-1);
break;
default:
char c = key.keysym.unicode;
if(std::isprint(c))
char c = key.keysym.unicode; //TODO 16-/>8
static const std::string forbiddenChars = "<>:\"/\\|?*"; //if we are entering a filename, some special characters won't be allowed
if(!vstd::contains(forbiddenChars,c) && std::isprint(c))
text += c;
break;
}

View File

@ -318,11 +318,16 @@ void CGuiHandler::handleMoveInterested( const SDL_MouseMotionEvent & motion )
void CGuiHandler::fakeMouseMove()
{
SDL_Event evnt;
SDL_MouseMotionEvent sme = {SDL_MOUSEMOTION, 0, 0, 0, 0, 0, 0};
int x, y;
sme.state = SDL_GetMouseState(&x, &y);
sme.x = x;
sme.y = y;
evnt.motion = sme;
current = &evnt;
handleMoveInterested(sme);
}

View File

@ -4777,14 +4777,10 @@ void CCartographer::buyMap (const CGHeroInstance *h, ui32 accept) const
cb->giveResource (h->tempOwner, 6, -1000);
FoWChange fw;
fw.player = h->tempOwner;
int surface = 0;
if (cb->getTile(pos)->tertype == 8) //water
surface = 2;
else
surface = 1;
//reveal apropriate tiles
cb->getAllTiles (fw.tiles, h->tempOwner, pos.z, surface);
//subIDs of different types of cartographers:
//water = 0; land = 1; underground = 2;
cb->getAllTiles (fw.tiles, h->tempOwner, subID - 1, !subID + 1); //reveal appropriate tiles
cb->sendAndApply (&fw);
cb->setObjProperty (id, 10, h->tempOwner);
}

View File

@ -186,6 +186,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<CGObjectInstance&>(*this);
h & players;
}
};
@ -985,6 +986,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version)
{
h & static_cast<CPlayersVisited&>(*this);
h & players;
}