1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00
* minor bugfixes
This commit is contained in:
Michał W. Urbańczyk 2007-10-21 18:41:58 +00:00
parent 16642621db
commit 0291bf2d2d
4 changed files with 61 additions and 10 deletions

View File

@ -117,6 +117,7 @@ void AdventureMapButton::deactivate()
if (!active) return; if (!active) return;
active=false; active=false;
ClickableL::deactivate(); ClickableL::deactivate();
ClickableR::deactivate();
Hoverable::deactivate(); Hoverable::deactivate();
KeyInterested::deactivate(); KeyInterested::deactivate();
} }
@ -572,6 +573,35 @@ CMinimap::CMinimap(bool draw)
pos.x=630; pos.x=630;
pos.y=26; pos.y=26;
pos.h=pos.w=144; pos.h=pos.w=144;
int rx = (((float)19)/(CGI->mh->sizes.x))*((float)pos.w),
ry = (((float)18)/(CGI->mh->sizes.y))*((float)pos.h);
radar = newSurface(rx,ry);
temps = newSurface(144,144);
SDL_FillRect(radar,NULL,0x00FFFF);
SDL_SaveBMP(radar,"radar1.bmp");
for (int i=0; i<radar->w; i++)
{
if (i%3)
{
SDL_PutPixel(radar,i,0,255,75,125);
SDL_PutPixel(radar,i,radar->h-1,255,75,125);
}
}
for (int i=0; i<radar->h; i++)
{
if ((i%4) || (i==0))
{
SDL_PutPixel(radar,0,i,255,75,125);
SDL_PutPixel(radar,radar->w-1,i,255,75,125);
}
}
SDL_SaveBMP(radar,"radar2.bmp");
SDL_SetColorKey(radar,SDL_SRCCOLORKEY,SDL_MapRGB(radar->format,0,255,255));
SDL_SaveBMP(radar,"radar3.bmp");
//radar = CGI->spriteh->giveDef("RADAR.DEF"); //radar = CGI->spriteh->giveDef("RADAR.DEF");
std::ifstream is("config/minimap.txt",std::ifstream::in); std::ifstream is("config/minimap.txt",std::ifstream::in);
for (int i=0;i<TERRAIN_TYPES;i++) for (int i=0;i<TERRAIN_TYPES;i++)
@ -604,7 +634,7 @@ CMinimap::CMinimap(bool draw)
void CMinimap::draw() void CMinimap::draw()
{ {
//draw terrain //draw terrain
blitAtWR(map[LOCPLINT->adventureInt->position.z],pos.x,pos.y); blitAt(map[LOCPLINT->adventureInt->position.z],0,0,temps);
//draw heroes //draw heroes
std::vector <const CHeroInstance *> * hh = LOCPLINT->cb->getHeroesInfo(false); std::vector <const CHeroInstance *> * hh = LOCPLINT->cb->getHeroesInfo(false);
@ -619,7 +649,7 @@ void CMinimap::draw()
{ {
for (int jj=0; jj<ho; jj++) for (int jj=0; jj<ho; jj++)
{ {
SDL_PutPixel(ekran,maplgp.x+pos.x+ii,maplgp.y+pos.y+jj,CGI->playerColors[(*hh)[i]->owner].r,CGI->playerColors[(*hh)[i]->owner].g,CGI->playerColors[(*hh)[i]->owner].b); SDL_PutPixel(temps,maplgp.x+ii,maplgp.y+jj,CGI->playerColors[(*hh)[i]->owner].r,CGI->playerColors[(*hh)[i]->owner].g,CGI->playerColors[(*hh)[i]->owner].b);
} }
} }
} }
@ -642,13 +672,18 @@ void CMinimap::draw()
for (int jj=0; jj<ho; jj++) for (int jj=0; jj<ho; jj++)
{ {
if ((i+ii<pos.w-1) && (j+jj<pos.h-1)) if ((i+ii<pos.w-1) && (j+jj<pos.h-1))
SDL_PutPixel(ekran,i+pos.x+ii,j+pos.y+jj,0,0,0); SDL_PutPixel(temps,i+ii,j+jj,0,0,0);
} }
} }
} }
} }
} }
//draw radar
int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)CGI->mh->sizes.x)))*pos.w,
by = (((float)LOCPLINT->adventureInt->position.y)/(((float)CGI->mh->sizes.y)))*pos.h;
blitAt(radar,bx,by,temps);
blitAt(temps,pos.x,pos.y);
} }
void CMinimap::redraw(int level)// (level==-1) => redraw all levels void CMinimap::redraw(int level)// (level==-1) => redraw all levels
{ {
@ -1312,6 +1347,7 @@ void CAdvMapInt::centerOn(int3 on)
LOCPLINT->adventureInt->position.y=on.y; LOCPLINT->adventureInt->position.y=on.y;
LOCPLINT->adventureInt->position.z=on.z; LOCPLINT->adventureInt->position.z=on.z;
LOCPLINT->adventureInt->updateScreen=true; LOCPLINT->adventureInt->updateScreen=true;
updateMinimap=true;
} }
CAdvMapInt::CurrentSelection::CurrentSelection() CAdvMapInt::CurrentSelection::CurrentSelection()
{ {

View File

@ -124,7 +124,8 @@ class CMinimap
: public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject : public ClickableL, public ClickableR, public Hoverable, public MotionInterested, public virtual CIntObject
{ {
public: public:
CDefHandler * radar; //radar.def; TODO: radars for maps with custom dimensions SDL_Surface * radar; //radar.def; TODO: radars for maps with custom dimensions
SDL_Surface * temps;
std::map<int,SDL_Color> colors; std::map<int,SDL_Color> colors;
std::map<int,SDL_Color> colorsBlocked; std::map<int,SDL_Color> colorsBlocked;
std::vector<SDL_Surface *> map; //one bitmap for each level std::vector<SDL_Surface *> map; //one bitmap for each level
@ -205,7 +206,7 @@ public:
bool scrollingRight ; bool scrollingRight ;
bool scrollingUp ; bool scrollingUp ;
bool scrollingDown ; bool scrollingDown ;
bool updateScreen ; bool updateScreen, updateMinimap ;
unsigned char anim, animValHitCount; //animation frame unsigned char anim, animValHitCount; //animation frame
CMinimap minimap; CMinimap minimap;

View File

@ -193,18 +193,23 @@ int CCallback::getDate(int mode)
{ {
case 0: case 0:
return gs->day; return gs->day;
break;
case 1: case 1:
temp = (gs->day)%7; temp = (gs->day)%7;
if (temp) if (temp)
return temp; return temp;
else return 7; else return 7;
break;
case 2: case 2:
temp = ((gs->day-1)/7)+1; temp = ((gs->day-1)/7)+1;
if (temp%4) if (!(temp%4))
return temp; return 4;
else return 4; else
return (temp%4);
break;
case 3: case 3:
return ((gs->day-1)/28)+1; return ((gs->day-1)/28)+1;
break;
} }
} }
bool CCallback::verifyPath(CPath * path, bool blockSea) bool CCallback::verifyPath(CPath * path, bool blockSea)

View File

@ -217,6 +217,7 @@ void CPlayerInterface::yourTurn()
{ {
LOCPLINT->adventureInt->position.x--; LOCPLINT->adventureInt->position.x--;
LOCPLINT->adventureInt->updateScreen = true; LOCPLINT->adventureInt->updateScreen = true;
adventureInt->updateMinimap=true;
} }
} }
if(LOCPLINT->adventureInt->scrollingRight) if(LOCPLINT->adventureInt->scrollingRight)
@ -225,6 +226,7 @@ void CPlayerInterface::yourTurn()
{ {
LOCPLINT->adventureInt->position.x++; LOCPLINT->adventureInt->position.x++;
LOCPLINT->adventureInt->updateScreen = true; LOCPLINT->adventureInt->updateScreen = true;
adventureInt->updateMinimap=true;
} }
} }
if(LOCPLINT->adventureInt->scrollingUp) if(LOCPLINT->adventureInt->scrollingUp)
@ -233,6 +235,7 @@ void CPlayerInterface::yourTurn()
{ {
LOCPLINT->adventureInt->position.y--; LOCPLINT->adventureInt->position.y--;
LOCPLINT->adventureInt->updateScreen = true; LOCPLINT->adventureInt->updateScreen = true;
adventureInt->updateMinimap=true;
} }
} }
if(LOCPLINT->adventureInt->scrollingDown) if(LOCPLINT->adventureInt->scrollingDown)
@ -241,12 +244,18 @@ void CPlayerInterface::yourTurn()
{ {
LOCPLINT->adventureInt->position.y++; LOCPLINT->adventureInt->position.y++;
LOCPLINT->adventureInt->updateScreen = true; LOCPLINT->adventureInt->updateScreen = true;
adventureInt->updateMinimap=true;
} }
} }
if(LOCPLINT->adventureInt->updateScreen) if(LOCPLINT->adventureInt->updateScreen)
{ {
adventureInt->update(); adventureInt->update();
LOCPLINT->adventureInt->updateScreen=false; adventureInt->updateScreen=false;
}
if (LOCPLINT->adventureInt->updateMinimap)
{
adventureInt->minimap.draw();
adventureInt->updateMinimap=false;
} }
for(int i=0;i<objsToBlit.size();i++) for(int i=0;i<objsToBlit.size();i++)
blitAt(objsToBlit[i]->bitmap,objsToBlit[i]->pos.x,objsToBlit[i]->pos.y); blitAt(objsToBlit[i]->bitmap,objsToBlit[i]->pos.x,objsToBlit[i]->pos.y);