From 7d283335d4e0a84c191314c299af70152eec9a77 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sat, 20 Aug 2011 00:08:49 +0100 Subject: [PATCH] Menu scrolling for 'special' menu --- src/interface.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/interface.c b/src/interface.c index 939699b37..5679a5fee 100644 --- a/src/interface.c +++ b/src/interface.c @@ -92,7 +92,7 @@ void menu_count(void)//puts the number of elements in each section into .itemcou int i=0; msections[SC_LIFE].itemcount = NGOLALT; msections[SC_WALL].itemcount = UI_WALLCOUNT-4; - msections[SC_SPECIAL].itemcount = 4; + msections[SC_SPECIAL].itemcount = 7; for (i=0; i XRES-BARSIZE) { //fancy scrolling + float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE))); + xoff = (int)(overflow / location); + } for (n = UI_WALLSTART; n=x+32 && mx=y && my< y+15) + x -= draw_tool_xy(vid_buf, x-xoff, y, n, wtypes[n-UI_WALLSTART].colour)+5; + if (!bq && mx>=x+32-xoff && mx=y && my< y+15) { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 55, 55, 255); h = n; } - if (!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))) + if (!bq && mx>=x+32-xoff && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))) { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255); h = n; } else if (n==SLALT) { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255); } else if (n==*sl) { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 55, 55, 255); } else if (n==*sr) { - drawrect(vid_buf, x+30, y-1, 29, 17, 55, 55, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 55, 55, 255, 255); } } } @@ -1991,28 +1995,28 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq x = XRES-BARSIZE-18; y += 19; }*/ - x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5; - if (!bq && mx>=x+32 && mx=y && my< y+15) + x -= draw_tool_xy(vid_buf, x-xoff, y, n, ptypes[n].pcolors)+5; + if (!bq && mx>=x+32-xoff && mx=y && my< y+15) { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 55, 55, 255); h = n; } - if (!bq && mx>=x+32 && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))) + if (!bq && mx>=x+32-xoff && mx=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL))) { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255); h = n; } else if (n==SLALT) { - drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255); } else if (n==*sl) { - drawrect(vid_buf, x+30, y-1, 29, 17, 255, 55, 55, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 55, 55, 255); } else if (n==*sr) { - drawrect(vid_buf, x+30, y-1, 29, 17, 55, 55, 255, 255); + drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 55, 55, 255, 255); } } } @@ -5470,7 +5474,7 @@ void catalogue_ui(pixel * vid_buf) int listy = 0, listxc; int listx = 0, listyc; pixel * vid_buf2; - float scrollvel = 0.0f, offsetf = 0.0f; + float scrollvel, offsetf = 0.0f; char savetext[128] = ""; char * last = mystrdup(""); savelist_e *saves, *cssave, *csave; @@ -5687,8 +5691,6 @@ openfin: if(saves) free_saveslist(saves); - free(last); - free(vid_buf2); return; }