1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

Fixed exchanging artifacts between heroes. Fixed def visibility issues. Refactored alphaTransform.

This commit is contained in:
Michał W. Urbańczyk 2009-07-27 12:29:10 +00:00
parent 898d266580
commit aad61c8ac8
3 changed files with 10 additions and 54 deletions

@ -403,56 +403,12 @@ Uint32 CSDL_Ext::SDL_GetPixel(SDL_Surface *surface, const int & x, const int & y
void CSDL_Ext::alphaTransform(SDL_Surface *src)
{
Uint32 trans = SDL_MapRGBA(src->format, 0, 255, 255, 255);
SDL_SetColorKey(src, 0, trans);
src->flags|=SDL_SRCALPHA;
assert(src->format->BitsPerPixel == 8);
SDL_Color colors[] = {{0,0,0,255}, {0,0,0,214}, {0,0,0,164}, {0,0,0,82}, {0,0,0,128},
{255,0,0,0}, {255,0,0,0}, {255,0,0,0}, {0,0,0,192}, {0,0,0,192}};
SDL_Color transp;
transp.b = transp.g = transp.r = 0;
transp.unused = 255;
if(src->format->BitsPerPixel == 8)
{
for(int yy=0; yy<src->format->palette->ncolors; ++yy)
{
SDL_Color cur = *(src->format->palette->colors+yy);
//if(cur.r == 255 && cur.b == 255)
if(yy==1 || yy==2 || yy==3 || yy==4 || yy==8 || yy==9)
{
SDL_Color shadow;
shadow.b = shadow.g = shadow.r = 0;
switch(cur.g) //change this values; make diffrerent for objects and shadows (?)
{
case 0:
shadow.unused = 128;
break;
case 50:
shadow.unused = 50+32;
break;
case 100:
shadow.unused = 100+64;
break;
case 125:
shadow.unused = 125+64;
break;
case 128:
shadow.unused = 128+64;
break;
case 150:
shadow.unused = 150+64;
break;
default:
shadow.unused = 255;
break;
}
SDL_SetColors(src, &shadow, yy, 1);
}
if(yy==0 || (cur.r == 255 && cur.g == 0 && cur.b == 0))
{
SDL_SetColors(src, &transp, yy, 1);
}
}
}
SDL_SetColors(src, colors, 0, ARRAY_COUNT(colors));
SDL_SetColorKey(src, SDL_SRCCOLORKEY, SDL_MapRGBA(src->format, 0, 0, 0, 255));
}
// <=>

@ -422,9 +422,9 @@ static void processDef (CGDefInfo* def)
}
void CMapHandler::initHeroDef(CGHeroInstance * h)
{
//h->defInfo->handler = graphics->flags1[0];
//h->defInfo->width = h->defInfo->handler->ourImages[0].bitmap->w/32;
//h->defInfo->height = h->defInfo->handler->ourImages[0].bitmap->h/32;
h->defInfo->handler = graphics->flags1[0];
h->defInfo->width = h->defInfo->handler->ourImages[0].bitmap->w/32;
h->defInfo->height = h->defInfo->handler->ourImages[0].bitmap->h/32;
}
void CMapHandler::init()
{
@ -723,7 +723,7 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, std::vector< st
const CGObjectInstance *obj = objects[h].first;
ui8 color = obj->tempOwner;
//checking if object has non-empty graphic on this tile
if(!obj->coveringAt(obj->pos.x - (top_tile.x + bx), top_tile.y + by - obj->pos.y + 5))
if(obj->ID != HEROI_TYPE && !obj->coveringAt(obj->pos.x - (top_tile.x + bx), top_tile.y + by - obj->pos.y + 5))
continue;
SDL_Rect sr;

@ -2121,7 +2121,7 @@ bool CGameHandler::swapArtifacts( si32 hid1, si32 hid2, ui16 slot1, ui16 slot2 )
sha.hid = hid2;
sha.artifacts = h2->artifacts;
sha.artifWorn = h2->artifWorn;
sha.setArtAtPos(slot2,h1->getArtAtPos(slot1));
sha.setArtAtPos(slot2, a1 ? a1->id : -1);
sendAndApply(&sha);
}