summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-08-19 23:08:49 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-08-19 23:08:49 (GMT)
commit7d283335d4e0a84c191314c299af70152eec9a77 (patch)
treebd26ca3ec452f702ef2ba5a2271614eab3418d09 /src
parent2e2694e0fbbad5940f2c0029c89623ecdc68d277 (diff)
downloadpowder-7d283335d4e0a84c191314c299af70152eec9a77.zip
powder-7d283335d4e0a84c191314c299af70152eec9a77.tar.gz
Menu scrolling for 'special' menu
Diffstat (limited to 'src')
-rw-r--r--src/interface.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/interface.c b/src/interface.c
index 939699b..5679a5f 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<PT_NUM; i++)
{
msections[ptypes[i].menusection].itemcount+=ptypes[i].menu;
@@ -1948,6 +1948,10 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int *dae, int b, int bq
}
else if (i==SC_SPECIAL)//special menu
{
+ if (fwidth > 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<UI_WALLSTART+UI_WALLCOUNT; n++)
{
if (n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM||n==SPC_WIND||n==SPC_PGRV||n==SPC_NGRV)
@@ -1957,28 +1961,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, wtypes[n-UI_WALLSTART].colour)+5;
- if (!bq && mx>=x+32 && mx<x+58 && my>=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<x+58-xoff && my>=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<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL)))
+ if (!bq && mx>=x+32-xoff && mx<x+58-xoff && my>=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<x+58 && my>=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<x+58-xoff && my>=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<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_CTRL)))
+ if (!bq && mx>=x+32-xoff && mx<x+58-xoff && my>=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;
}