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.
Doing this for 3.6.1+ games, because in theory older games could have been adjusted specifically to use or counter this behavior.
  • Loading branch information
ivan-mogilko committed Oct 9, 2023
1 parent 1af52f7 commit 11fecda
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Engine/ac/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,10 @@ 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;
const bool clip_borders = loaded_game_file_version >= kGameVersion_361;
// GUI middle space
if (iep->BgImage>0) {
{
// offset the background image and clip it so that it is drawn
Expand All @@ -692,14 +694,22 @@ void draw_button_background(Bitmap *ds, int xx1,int yy1,int xx2,int yy2,GUIMain*
ds->ResetClip();
}
}
// Vertical borders
if (clip_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
}
// Horizontal borders
if (clip_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 11fecda

Please sign in to comment.