From 5b9faa39c0ff68bd25bae160cb3cad8d6efc672f Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sat, 12 Nov 2011 04:55:20 +0800 Subject: [PATCH] Fix a few things in stamps browser Incorrect number of stamps per page, pause button visible, and one page too many when stamp_count is an integer multiple of per_page. Using GRID_X/Y since those are the values used in the rest of stamp_ui --- includes/defines.h | 2 -- src/interface.c | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index a4c1555c5..fb1212c48 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -86,8 +86,6 @@ extern unsigned char ZSIZE; #define CATALOGUE_S 6 #define CATALOGUE_Z 3 -#define STAMP_X 4 -#define STAMP_Y 4 #define STAMP_MAX 240 #define NGOL 25 diff --git a/src/interface.c b/src/interface.c index 8311dd9a1..3b89c2ad4 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1429,9 +1429,10 @@ fail: int stamp_ui(pixel *vid_buf) { - int b=1,bq,mx,my,d=-1,i,j,k,x,gx,gy,y,w,h,r=-1,stamp_page=0,per_page=STAMP_X*STAMP_Y,page_count; + int b=1,bq,mx,my,d=-1,i,j,k,x,gx,gy,y,w,h,r=-1,stamp_page=0,per_page=GRID_X*GRID_Y,page_count; char page_info[64]; - page_count = ceil((float)stamp_count/(float)per_page); + // stamp_count-1 to avoid an extra page when there are per_page stamps on each page + page_count = (stamp_count-1)/per_page+1; while (!sdl_poll()) { @@ -1447,7 +1448,7 @@ int stamp_ui(pixel *vid_buf) mx /= sdl_scale; my /= sdl_scale; - clearrect(vid_buf, -1, -1, XRES+1, YRES+MENUSIZE+1); + clearrect(vid_buf, -1, -1, XRES+BARSIZE+1, YRES+MENUSIZE+1); k = stamp_page*per_page;//0; r = -1; d = -1;