1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

* bug 392 fixed

This commit is contained in:
mateuszb 2011-02-23 18:21:51 +00:00
parent 6d6a1af9ed
commit 5e0b0e49b2
7 changed files with 24 additions and 37 deletions

View File

@ -440,16 +440,9 @@ CTerrainRect::CTerrainRect()
pos.w=ADVOPT.advmapW; pos.w=ADVOPT.advmapW;
pos.h=ADVOPT.advmapH; pos.h=ADVOPT.advmapH;
moveX = moveY = 0; moveX = moveY = 0;
arrows = CDefHandler::giveDef("ADAG.DEF");
for(size_t y=0; y < arrows->ourImages.size(); ++y)
{
CSDL_Ext::alphaTransform(arrows->ourImages[y].bitmap);
}
} }
CTerrainRect::~CTerrainRect() CTerrainRect::~CTerrainRect()
{ {
delete arrows;
} }
void CTerrainRect::activate() void CTerrainRect::activate()
{ {
@ -457,7 +450,7 @@ void CTerrainRect::activate()
activateRClick(); activateRClick();
activateHover(); activateHover();
activateMouseMove(); activateMouseMove();
}; }
void CTerrainRect::deactivate() void CTerrainRect::deactivate()
{ {
deactivateLClick(); deactivateLClick();
@ -465,7 +458,7 @@ void CTerrainRect::deactivate()
deactivateHover(); deactivateHover();
deactivateMouseMove(); deactivateMouseMove();
curHoveredTile = int3(-1,-1,-1); //we lost info about hovered tile when disabling curHoveredTile = int3(-1,-1,-1); //we lost info about hovered tile when disabling
}; }
void CTerrainRect::clickLeft(tribool down, bool previousState) void CTerrainRect::clickLeft(tribool down, bool previousState)
{ {
if ((down==false) || indeterminate(down)) if ((down==false) || indeterminate(down))
@ -782,6 +775,7 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
pn+=25; pn+=25;
if (pn>=0) if (pn>=0)
{ {
CDefEssential * arrows = graphics->heroMoveArrows;
int x = 32*(currentPath->nodes[i].coord.x-adventureInt->position.x)+CGI->mh->offsetX + pos.x, int x = 32*(currentPath->nodes[i].coord.x-adventureInt->position.x)+CGI->mh->offsetX + pos.x,
y = 32*(currentPath->nodes[i].coord.y-adventureInt->position.y)+CGI->mh->offsetY + pos.y; y = 32*(currentPath->nodes[i].coord.y-adventureInt->position.y)+CGI->mh->offsetY + pos.y;
if (x<0 || y<0 || x>pos.w || y>pos.h) if (x<0 || y<0 || x>pos.w || y>pos.h)
@ -856,12 +850,12 @@ void CTerrainRect::show(SDL_Surface * to)
CGI->mh->terrainRect CGI->mh->terrainRect
(adventureInt->position, adventureInt->anim, (adventureInt->position, adventureInt->anim,
&LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim, &LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim,
to, &pos, moveX, moveY, false); to, &pos, moveX, moveY, false, int3());
else else
CGI->mh->terrainRect CGI->mh->terrainRect
(adventureInt->position, adventureInt->anim, (adventureInt->position, adventureInt->anim,
&LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim, &LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim,
to, &pos, 0, 0, false); to, &pos, 0, 0, false, int3());
//SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),screen,&genRect(547,594,7,6)); //SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),screen,&genRect(547,594,7,6));
//SDL_FreeSurface(teren); //SDL_FreeSurface(teren);

View File

@ -81,7 +81,6 @@ public:
int3 curHoveredTile; int3 curHoveredTile;
int moveX, moveY; //shift between actual position of screen and the one we wil blit; ranges from -31 to 31 (in pixels) int moveX, moveY; //shift between actual position of screen and the one we wil blit; ranges from -31 to 31 (in pixels)
CDefHandler * arrows;
CTerrainRect(); CTerrainRect();
~CTerrainRect(); ~CTerrainRect();
CGPath * currentPath; CGPath * currentPath;

View File

@ -5720,9 +5720,6 @@ CShipyardWindow::CShipyardWindow(const std::vector<si32> &cost, int state, int b
CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, float discoveredRatio) CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, float discoveredRatio)
:animCount(0) :animCount(0)
{ {
CDefHandler * arrows = CDefHandler::giveDef("ADAG.DEF");
alphaTransform(arrows->ourImages[0].bitmap);
SDL_Surface * back = BitmapHandler::loadBitmap("PUZZLE.BMP", false); SDL_Surface * back = BitmapHandler::loadBitmap("PUZZLE.BMP", false);
graphics->blueToPlayersAdv(back, LOCPLINT->playerID); graphics->blueToPlayersAdv(back, LOCPLINT->playerID);
//make transparency black //make transparency black
@ -5741,23 +5738,7 @@ CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, float discoveredRatio)
CGI->mh->terrainRect CGI->mh->terrainRect
(grailPos - moveInt, adventureInt->anim, (grailPos - moveInt, adventureInt->anim,
&LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim, &LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim,
background, &mapRect, 0, 0, true); background, &mapRect, 0, 0, true, moveInt);
//printing X sign
{
int x = 32*moveInt.x - 16,
y = 32*moveInt.y + 1;
if (x<0 || y<0 || x>pos.w || y>pos.h)
{
}
else
{
Rect dstRect = genRect(32, 32, x, y);
CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[0].bitmap, NULL, background, &dstRect);
}
}
delete arrows;
int faction = LOCPLINT->cb->getStartInfo()->playerInfos.find(LOCPLINT->playerID)->second.castle; int faction = LOCPLINT->cb->getStartInfo()->playerInfos.find(LOCPLINT->playerID)->second.castle;

View File

@ -319,6 +319,7 @@ Graphics::Graphics()
tasks += GET_DEF_ESS(abils44,"SECSKILL.DEF"); tasks += GET_DEF_ESS(abils44,"SECSKILL.DEF");
tasks += GET_DEF_ESS(abils82,"SECSK82.DEF"); tasks += GET_DEF_ESS(abils82,"SECSK82.DEF");
tasks += GET_DEF_ESS(spellscr,"SPELLSCR.DEF"); tasks += GET_DEF_ESS(spellscr,"SPELLSCR.DEF");
tasks += GET_DEF_ESS(heroMoveArrows,"ADAG.DEF");
std::ifstream ifs(DATA_DIR "/config/cr_bgs.txt"); std::ifstream ifs(DATA_DIR "/config/cr_bgs.txt");
int id; int id;
@ -334,6 +335,11 @@ Graphics::Graphics()
CThreadHelper th(&tasks,std::max((unsigned int)1,boost::thread::hardware_concurrency())); CThreadHelper th(&tasks,std::max((unsigned int)1,boost::thread::hardware_concurrency()));
th.run(); th.run();
for(size_t y=0; y < heroMoveArrows->ourImages.size(); ++y)
{
CSDL_Ext::alphaTransform(heroMoveArrows->ourImages[y].bitmap);
}
//handling 32x32px imgs //handling 32x32px imgs
smi->notFreeImgs = true; smi->notFreeImgs = true;
for (size_t i=0; i<smi->ourImages.size(); ++i) for (size_t i=0; i<smi->ourImages.size(); ++i)

View File

@ -61,6 +61,7 @@ public:
CDefEssential * un44; //many things CDefEssential * un44; //many things
CDefEssential * smallIcons, *resources32; //resources 32x32 CDefEssential * smallIcons, *resources32; //resources 32x32
CDefEssential * flags; CDefEssential * flags;
CDefEssential * heroMoveArrows;
std::vector<CDefEssential *> heroAnims; // [class id: 0 - 17] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing std::vector<CDefEssential *> heroAnims; // [class id: 0 - 17] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
std::vector<CDefEssential *> boatAnims; // [boat type: 0 - 3] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing std::vector<CDefEssential *> boatAnims; // [boat type: 0 - 3] //added group 10: up - left, 11 - left and 12 - left down // 13 - up-left standing; 14 - left standing; 15 - left down standing
std::map<std::string, CDefEssential*> mapObjectDefs; //pointers to loaded defs (key is filename, uppercase) std::map<std::string, CDefEssential*> mapObjectDefs; //pointers to loaded defs (key is filename, uppercase)

View File

@ -421,10 +421,7 @@ void CMapHandler::init()
// top_tile top left tile to draw. Not necessarily visible. // top_tile top left tile to draw. Not necessarily visible.
// extRect, extRect = map window on screen // extRect, extRect = map window on screen
// moveX, moveY: when a hero is in movement indicates how to shift the map. Range is -31 to + 31. // moveX, moveY: when a hero is in movement indicates how to shift the map. Range is -31 to + 31.
void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, void CMapHandler::terrainRect( int3 top_tile, unsigned char anim, const std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, const SDL_Rect * extRect, int moveX, int moveY, bool puzzleMode, int3 grailPosRel ) const
const std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap,
bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, const SDL_Rect * extRect,
int moveX, int moveY, bool puzzleMode) const
{ {
// Width and height of the portion of the map to process. Units in tiles. // Width and height of the portion of the map to process. Units in tiles.
unsigned int dx = tilesW; unsigned int dx = tilesW;
@ -653,6 +650,15 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim,
} }
} }
//objects blitted //objects blitted
//X sign
if(puzzleMode)
{
if(bx == grailPosRel.x && by == grailPosRel.y)
{
CSDL_Ext::blit8bppAlphaTo24bpp(graphics->heroMoveArrows->ourImages[0].bitmap, NULL, extSurf, &sr);
}
}
} }
} }
// terrain printed // terrain printed

View File

@ -118,7 +118,7 @@ public:
void roadsRiverTerrainInit(); void roadsRiverTerrainInit();
void prepareFOWDefs(); void prepareFOWDefs();
void terrainRect(int3 top_tile, unsigned char anim, const std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, const SDL_Rect * extRect, int moveX, int moveY, bool puzzleMode) const; void terrainRect(int3 top_tile, unsigned char anim, const std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, const SDL_Rect * extRect, int moveX, int moveY, bool puzzleMode, int3 grailPosRel) const;
void updateWater(); void updateWater();
unsigned char getHeroFrameNum(unsigned char dir, bool isMoving) const; //terrainRect helper function unsigned char getHeroFrameNum(unsigned char dir, bool isMoving) const; //terrainRect helper function
void validateRectTerr(SDL_Rect * val, const SDL_Rect * ext); //terrainRect helper void validateRectTerr(SDL_Rect * val, const SDL_Rect * ext); //terrainRect helper