the menu cursor can now be moved up and down using the mouse wheel

This commit is contained in:
Bill Currie 2002-01-19 07:19:39 +00:00
parent 29c19ca243
commit b73851d5aa
2 changed files with 49 additions and 6 deletions

View file

@ -31,6 +31,26 @@ void (string text, integer key) quit =
{
};
void () single_player_menu =
{
Menu_Item (54, 32, "", NIL);
};
void () multi_player_menu =
{
Menu_Item (54, 52, "", NIL);
};
void () options_menu =
{
Menu_Item (54, 72, "", NIL);
};
void () help_menu =
{
Menu_Item (54, 92, "", NIL);
};
void () main_menu =
{
Menu_Begin (0, 0, "main");
@ -40,10 +60,10 @@ void () main_menu =
Menu_Cursor (spinner);
//if (do_single_player)
// single_player_menu ();
//multi_player_menu ();
//options_menu ();
//help_menu ();
Menu_Item (54, 132, "", quit);
multi_player_menu ();
options_menu ();
help_menu ();
Menu_Item (54, 112, "", quit);
Menu_End ();
};

View file

@ -53,6 +53,7 @@ typedef struct menu_item_s {
struct menu_item_s **items;
int num_items;
int max_items;
int cur_item;
int x, y;
func_t func;
func_t cursor;
@ -293,10 +294,15 @@ Menu_Draw (void)
{
menu_pic_t *m_pic;
int i;
menu_item_t *item;
if (!menu)
return;
*menu_pr_state.globals.time = *menu_pr_state.time;
item = menu->items[menu->cur_item];
for (m_pic = menu->pics; m_pic; m_pic = m_pic->next) {
qpic_t *pic = Draw_CachePic (m_pic->name, 1);
if (!pic)
@ -310,9 +316,12 @@ Menu_Draw (void)
}
}
if (menu->cursor) {
G_INT (&menu_pr_state, OFS_PARM0) = 0;
G_INT (&menu_pr_state, OFS_PARM1) = 0;
G_INT (&menu_pr_state, OFS_PARM0) = item->x;
G_INT (&menu_pr_state, OFS_PARM1) = item->y;
PR_ExecuteProgram (&menu_pr_state, menu->cursor);
} else {
Draw_Character (item->x, item->y,
12 + ((int) (*con_data.realtime * 4) & 1));
}
if (menu_draw) {
PR_ExecuteProgram (&menu_pr_state, menu_draw);
@ -324,6 +333,20 @@ Menu_KeyEvent (knum_t key, short unicode, qboolean down)
{
if (!menu)
return;
switch (key) {
case QFK_DOWN:
case QFM_WHEEL_DOWN:
menu->cur_item++;
menu->cur_item %= menu->num_items;
break;
case QFK_UP:
case QFM_WHEEL_UP:
menu->cur_item += menu->num_items - 1;
menu->cur_item %= menu->num_items;
break;
default:
break;
}
}
void