Commit 383929c8 authored by Romain Bignon's avatar Romain Bignon

add a border on map preview

parent a429f6fa
......@@ -2299,7 +2299,7 @@ void MenAreAntsApp::LoadGame(EChannel* chan)
try
{
chan->Map()->CreatePreview(300,300, 0);
chan->Map()->CreatePreview(300,300, P_BORDER);
LoadingForm = new TLoadingForm(Video::GetInstance()->Window(), chan);
LoadingForm->SetMutex(mutex);
......
......@@ -240,7 +240,7 @@ int EOSMAPCommand::Exec(PlayerList players, EC_Client *me, ParvList parv)
if(GameInfosForm)
map->CreatePreview(GameInfosForm->PretButton->X() - GameInfosForm->Preview->X() - 30,
GameInfosForm->PretButton->X() - GameInfosForm->Preview->X() - 30,
0);
P_BORDER);
}
catch(TECExcept &e)
{
......@@ -1616,7 +1616,7 @@ TGameInfosForm::TGameInfosForm(ECImage* w, EC_Client* cl, bool _mission)
MapTitle = AddComponent(new TLabel(50 + chat_width + 40, 345, "", white_color, Window()->GetWidth() < 1000 ? Font::GetInstance(Font::Normal) : Font::GetInstance(Font::Big)));
Preview = AddComponent(new TImage(50 + chat_width + 30, 380));
int right_x = Window()->GetWidth() - 200;
int right_x = Window()->GetWidth() - 220;
PretButton = AddComponent(new TButton(right_x,110, 150,50));
PretButton->SetEnabled(false);
......
......@@ -849,7 +849,14 @@ void ECMap::CreatePreview(uint width, uint height, int flags)
else size_y = size_x;
pixel_size = size_y;
SDL_Surface *surf = CreateRGBASurface(x*size_x, y*size_y, SDL_HWSURFACE|SDL_SRCALPHA);
uint dx = 0, dy = 0;
if (flags & P_BORDER)
{
dx = 3;
dy = 3;
}
SDL_Surface *surf = CreateRGBASurface(x*size_x + 2*dx, y*size_y + 2*dy, SDL_HWSURFACE|SDL_SRCALPHA);
SLOCK(surf);
/* Dessine la preview */
......@@ -918,7 +925,7 @@ void ECMap::CreatePreview(uint width, uint height, int flags)
(marge & MARGE_LEFT && _xx == xx) ||
(marge & MARGE_BOTTOM && _yy == yy+size_y-1) ||
(marge & MARGE_RIGHT && _xx == xx+size_x-1)) ? marge_color : color;
putpixel(surf, _xx, _yy, SDL_MapRGB(surf->format,
putpixel(surf, dx +_xx, dy + _yy, SDL_MapRGB(surf->format,
(Brouillard() && c->Showed()<=0) ? (col.GetRed()>60) ? col.GetRed() - 60 : 0 : col.GetRed(),
(Brouillard() && c->Showed()<=0) ? (col.GetGreen()>60) ? col.GetGreen() - 60 : 0 : col.GetGreen(),
(Brouillard() && c->Showed()<=0) ? (col.GetBlue()>60) ? col.GetBlue() - 60 : 0 : col.GetBlue()));
......@@ -940,13 +947,28 @@ void ECMap::CreatePreview(uint width, uint height, int flags)
xx = (*enti)->Case()->X() * size_x;
for(uint _yy = yy; _yy < yy+size_y; _yy++)
for(uint _xx = xx; _xx < xx+size_x; _xx++)
putpixel(surf, _xx, _yy, SDL_MapRGB(surf->format,
putpixel(surf, dx + _xx, dy + _yy, SDL_MapRGB(surf->format,
(col.GetRed()> 100) ? col.GetRed() - 30 : col.GetRed() + 30,
(col.GetGreen()>100) ? col.GetGreen() - 30 : col.GetGreen() + 30,
(col.GetBlue()> 100) ? col.GetBlue() - 30 : col.GetBlue() + 30));
}
}
if(flags & P_BORDER)
{
DrawLine(surf, 0, 0, surf->w-1, 0, SDL_MapRGB(surf->format, 0xff, 0xff, 0xff));
DrawLine(surf, 0, 0, 0, surf->h-1, SDL_MapRGB(surf->format, 0xff, 0xff, 0xff));
DrawLine(surf, 0, surf->h-1, surf->w-1, surf->h-1, SDL_MapRGB(surf->format, 0x00, 0x00, 0x00));
DrawLine(surf, surf->w-1, surf->h-1, surf->w-1, 0, SDL_MapRGB(surf->format, 0x00, 0x00, 0x00));
DrawRect(surf, 1, 1, surf->w-2, surf->h-2, SDL_MapRGB(surf->format, 0x99, 0x99, 0x99));
DrawLine(surf, 2, 2, surf->w-3, 2, SDL_MapRGB(surf->format, 0x00, 0x00, 0x00));
DrawLine(surf, 2, 2, 2, surf->h-3, SDL_MapRGB(surf->format, 0x00, 0x00, 0x00));
DrawLine(surf, 2, surf->h-3, surf->w-3, surf->h-3, SDL_MapRGB(surf->format, 0xff, 0xff, 0xff));
DrawLine(surf, surf->w-3, surf->h-3, surf->w-3, 2, SDL_MapRGB(surf->format, 0xff, 0xff, 0xff));
}
SUNLOCK(surf);
preview.SetImage(surf);
......
......@@ -346,6 +346,7 @@ public:
#define P_FRONTMER 0x001
#define P_ENTITIES 0x002
#define P_BORDER 0x004
void CreatePreview(uint width, uint height, int flags);
virtual ECBCase* CreateCase(uint x, uint y, char type_id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment