You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bomberclone/include/menu.h

88 lines
2.5 KiB

/* $Id: menu.h,v 1.5 2004/02/02 23:30:34 patty21 Exp $
* GUI for menuhandling
*/
#ifndef _MENU_H_
#define _MENU_H_
#define MENU_TITLELEN 64
#define MENU_ENTRYNAME 64
#define MENU_BG_SHADE_DARK -64
#define MENU_BG_SHADE_BRIGHT 64
#define MENU_DATASIZE 256
#define MENU_MAXENTRYS 64
#define MENU_BUTTON_FONTSIZE 0
#define MENU_FOCUSVIS_BLINKTO 0.25f
#define MENU_DATAENTRYLEN 128
#define MENUOFFSET_X menu.oldscreenpos.x + menu.images[0]->w
#define MENUOFFSET_Y menu.oldscreenpos.y + menu.images[0]->h
enum _menu_type {
MENU_label = 0,
MENU_button,
MENU_entrytext,
MENU_entryint32,
MENU_entryint16,
MENU_entryfloat,
MENU_bool,
MENU_list
};
struct __menuitem {
SDL_Rect pos;
int type;
int len;
int id;
char changed;
char label[MENU_TITLELEN];
_keybinput keybi;
int state;
char *ptrdata; // pointer to some data
_charlist *list;
struct __menuitem *next;
} typedef _menuitem;
struct {
char title[MENU_TITLELEN];
_menuitem *items;
_menuitem *focus;
SDL_Surface *oldscreen; // hold old screendata
SDL_Rect oldscreenpos;
SDL_Surface *images[9]; // holds the gfx
SDL_Surface *listimages[2][9]; // holds the gfx for the lists
SDL_Surface *buttonimages[3][3]; // holds the images for the buttons
SDL_Surface *entryimages[2][3]; // [PRESSED][Left|Center|Right]
float focusto;
int focusvis;
} typedef _menu;
extern _menu menu;
extern int menu_getlastitem (_menuitem *first);
extern void menu_new (char *title, int x, int y);
extern void menu_delete ();
extern void menu_create_list (char *name, int x, int y, int w, int h, _charlist *data, _charlist **selected, int id);
extern void menu_create_entry (char *name, int x, int y, int w, void *data, int len, int typ, int id);
extern void menu_create_label (char *name, int x, int y, int fontsize);
extern void menu_create_button (char *name, int x, int y, int w, int id);
extern void menu_create_bool (char *name, int x, int y, int w, int *data, int id);
extern int menu_loop ();
extern void menu_draw_border ();
extern void menu_draw_background (SDL_Rect *dest);
extern inline void menu_draw_menuitem (_menuitem *m);
extern void menu_reload ();
extern inline void menu_reload_menuitem (_menuitem *m);
extern void menu_focus_next ();
extern void menu_focus_prev ();
extern void menu_focus_id (int id);
extern void menu_change_focus (_menuitem *newfocus);
extern _menuitem *menu_get_lastid ();
extern _menuitem *menu_get_firstid ();
extern int menu_create_dirlist (char *path, signed char dirflags, _charlist *cl, int maxentry);
extern char *menu_dir_select (char *title, char *path, signed char dirflags);
#endif