fixes in scroll logic

This commit is contained in:
p.kosyh 2009-09-05 10:16:33 +00:00
parent 1250ecce0e
commit 3ad2134dd1

View file

@ -1659,6 +1659,28 @@ static void select_ref(int prev)
xref_jump(xref, elem); xref_jump(xref, elem);
} }
static void game_scroll_up(int count)
{
int xm, ym;
struct el *o;
gfx_cursor(&xm, &ym, NULL, NULL);
o = look_obj(xm, ym);
if (o && (o->id == el_scene || o->id == el_inv)) {
scroll_up(o->id, count);
}
}
static void game_scroll_down(int count)
{
int xm, ym;
struct el *o;
gfx_cursor(&xm, &ym, NULL, NULL);
o = look_obj(xm, ym);
if (o && (o->id == el_scene || o->id == el_inv)) {
scroll_down(o->id, count);
}
}
int game_loop(void) int game_loop(void)
{ {
static int alt_pressed = 0; static int alt_pressed = 0;
@ -1692,12 +1714,12 @@ int game_loop(void)
if (menu_shown) { if (menu_shown) {
select_ref(1); select_ref(1);
} else } else
scroll_up(el_scene, 1); game_scroll_up(1);
} else if (!strcmp(ev.sym,"down")) { } else if (!strcmp(ev.sym,"down")) {
if (menu_shown) { if (menu_shown) {
select_ref(0); select_ref(0);
} else } else
scroll_down(el_scene, 1); game_scroll_down(1);
} else if (!strcmp(ev.sym,"left")) { } else if (!strcmp(ev.sym,"left")) {
select_ref(1); select_ref(1);
} else if (!strcmp(ev.sym,"right")) { } else if (!strcmp(ev.sym,"right")) {
@ -1734,21 +1756,9 @@ int game_loop(void)
if (game_click(ev.x, ev.y, 1) == -1) if (game_click(ev.x, ev.y, 1) == -1)
break; break;
} else if (ev.type == MOUSE_WHEEL_UP && !menu_shown) { } else if (ev.type == MOUSE_WHEEL_UP && !menu_shown) {
int xm, ym; game_scroll_up(ev.count);
struct el *o;
gfx_cursor(&xm, &ym, NULL, NULL);
o = look_obj(xm, ym);
if (o && (o->id == el_scene || o->id == el_inv)) {
scroll_up(o->id, ev.count);
}
} else if (ev.type == MOUSE_WHEEL_DOWN && !menu_shown) { } else if (ev.type == MOUSE_WHEEL_DOWN && !menu_shown) {
int xm, ym; game_scroll_down(ev.count);
struct el *o;
gfx_cursor(&xm, &ym, NULL, NULL);
o = look_obj(xm, ym);
if (o && (o->id == el_scene || o->id == el_inv)) {
scroll_down(o->id, ev.count);
}
} else if (ev.type == MOUSE_MOTION) { } else if (ev.type == MOUSE_MOTION) {
if (motion_mode) { if (motion_mode) {
scroll_motion(motion_id, motion_y - ev.y); scroll_motion(motion_id, motion_y - ev.y);