From 4a3d1a22d6acd0e2f371a9fa4339387d10341d56 Mon Sep 17 00:00:00 2001 From: Frank Zago Date: Sun, 25 Sep 2011 18:44:13 +0000 Subject: [PATCH] Only draw the necessary borders for a message window. Fixes #388. --- client/CMessage.cpp | 63 +++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/client/CMessage.cpp b/client/CMessage.cpp index 33e9522f5..58801af19 100644 --- a/client/CMessage.cpp +++ b/client/CMessage.cpp @@ -481,28 +481,53 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player) void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int x, int y) { std::vector &box = piecesOfBox[playerColor]; - //obwodka I-szego rzedu pozioma //border of 1st series, horizontal - for (int i=0; iw; i+=box[6]->w) - { - Rect dstR(x+i, y, box[6]->w, box[6]->h); - CSDL_Ext::blitSurface(box[6], NULL, ret, &dstR); - - int currY = y+h-box[7]->h+1; - dstR=Rect(x+i, currY, box[7]->w, box[7]->h); - CSDL_Ext::blitSurface(box[7], NULL, ret, &dstR); - } - //obwodka I-szego rzedu pionowa //border of 1st series, vertical - for (int i=0; ih; i+=box[4]->h) - { - Rect dstR(x, y+i, box[4]->w, box[4]->h); - CSDL_Ext::blitSurface(box[4], NULL, ret, &dstR); - - int currX = x+w-box[5]->w; - dstR=Rect(currX, y+i, box[5]->w, box[5]->h); + // Note: this code assumes that the corner dimensions are all the same. - CSDL_Ext::blitSurface(box[5], NULL, ret, &dstR); + // Horizontal borders + int start_x = x + box[0]->w; + const int stop_x = x + w - box[1]->w; + const int bottom_y = y+h-box[7]->h+1; + while (start_x < stop_x) { + int cur_w = stop_x - start_x; + if (cur_w > box[6]->w) + cur_w = box[6]->w; + + printf("FZ- cur_w=%d (%d %d %d)\n", cur_w, stop_x - start_x, box[6]->h); + + // Top border + Rect srcR(0, 0, cur_w, box[6]->h); + Rect dstR(start_x, y, 0, 0); + CSDL_Ext::blitSurface(box[6], &srcR, ret, &dstR); + + // Bottom border + dstR.y = bottom_y; + CSDL_Ext::blitSurface(box[7], &srcR, ret, &dstR); + + start_x += cur_w; } + + // Vertical borders + int start_y = y + box[0]->h; + const int stop_y = y + h - box[2]->h+1; + const int right_x = x+w-box[5]->w; + while (start_y < stop_y) { + int cur_h = stop_y - start_y; + if (cur_h > box[4]->h) + cur_h = box[4]->h; + + // Left border + Rect srcR(0, 0, box[4]->w, cur_h); + Rect dstR(x, start_y, 0, 0); + CSDL_Ext::blitSurface(box[4], &srcR, ret, &dstR); + + // Right border + dstR.x = right_x; + CSDL_Ext::blitSurface(box[5], &srcR, ret, &dstR); + + start_y += cur_h; + } + //corners Rect dstR(x, y, box[0]->w, box[0]->h); CSDL_Ext::blitSurface(box[0], NULL, ret, &dstR);