Skip to content

Commit

Permalink
Engine: when drawing TextWindow clip border pieces, fix over corners
Browse files Browse the repository at this point in the history
This fixes vertical or horizontal borders to be drawn under rightmost and bottom corners, which may have transparent parts.
  • Loading branch information
ivan-mogilko committed Oct 9, 2023
1 parent a8b5d9a commit a77393a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Engine/ac/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,9 @@ void draw_button_background(Bitmap *ds, int xx1,int yy1,int xx2,int yy2,GUIMain*
if (iep->BgColor > 0)
ds->FillRect(Rect(xx1,yy1,xx2,yy2), draw_color);

int leftRightWidth = game.SpriteInfos[get_but_pic(iep,4)].Width;
int topBottomHeight = game.SpriteInfos[get_but_pic(iep,6)].Height;
const int leftRightWidth = game.SpriteInfos[get_but_pic(iep,4)].Width;
const int topBottomHeight = game.SpriteInfos[get_but_pic(iep,6)].Height;
// GUI middle space
if (iep->BgImage>0) {
if ((loaded_game_file_version <= kGameVersion_272) // 2.xx
&& (spriteset[iep->BgImage]->GetWidth() == 1)
Expand Down Expand Up @@ -697,15 +698,20 @@ void draw_button_background(Bitmap *ds, int xx1,int yy1,int xx2,int yy2,GUIMain*
ds->ResetClip();
}
}
int uu;
for (uu=yy1;uu <= yy2;uu+= game.SpriteInfos[get_but_pic(iep,4)].Height) {
// Vertical borders
ds->SetClip(Rect(xx1 - leftRightWidth, yy1, xx2 + 1 + leftRightWidth, yy2));
for (int uu=yy1;uu <= yy2;uu+= game.SpriteInfos[get_but_pic(iep,4)].Height) {
do_corner(ds, get_but_pic(iep,4),xx1,uu,-1,0); // left side
do_corner(ds, get_but_pic(iep,5),xx2+1,uu,0,0); // right side
}
for (uu=xx1;uu <= xx2;uu+=game.SpriteInfos[get_but_pic(iep,6)].Width) {
// Horizontal borders
ds->SetClip(Rect(xx1, yy1 - topBottomHeight, xx2, yy2 + 1 + topBottomHeight));
for (int uu=xx1;uu <= xx2;uu+=game.SpriteInfos[get_but_pic(iep,6)].Width) {
do_corner(ds, get_but_pic(iep,6),uu,yy1,0,-1); // top side
do_corner(ds, get_but_pic(iep,7),uu,yy2+1,0,0); // bottom side
}
ds->ResetClip();
// Four corners
do_corner(ds, get_but_pic(iep,0),xx1,yy1,-1,-1); // top left
do_corner(ds, get_but_pic(iep,1),xx1,yy2+1,-1,0); // bottom left
do_corner(ds, get_but_pic(iep,2),xx2+1,yy1,0,-1); // top right
Expand Down

0 comments on commit a77393a

Please sign in to comment.