File: menu.h

package info (click to toggle)
bomberclone 0.11.9-7.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,228 kB
  • sloc: ansic: 14,256; sh: 3,800; makefile: 337
file content (107 lines) | stat: -rw-r--r-- 3,859 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* $Id: menu.h,v 1.13 2004-09-25 10:57:50 stpohle 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(_m_) _m_->oldscreenpos.x + menuimages[0]->w
#define MENUOFFSET_Y(_m_) _m_->oldscreenpos.y + menuimages[0]->h

enum _menu_type {
	MENU_label = 0,
	MENU_none,			/* deleted item */
	MENU_button,
	MENU_entrytext,
	MENU_entryint32,
	MENU_entryint16,
	MENU_entryfloat,
	MENU_bool,
	MENU_list,
	MENU_image
};


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
	SDL_Rect rect;			// only used for images
	_charlist *list;
	void *menu;				// parent menu
	struct __menuitem *next;
} typedef _menuitem;


struct {
	char title[MENU_TITLELEN];
	_menuitem *items;
	_menuitem *focus;
	SDL_Surface *oldscreen; // hold old screendata
	SDL_Rect oldscreenpos;
	int oldkey;
	float focusto;
	int focusvis;
	_menuitem menuitems[MENU_MAXENTRYS];
	int looprunning;
} typedef _menu;


extern SDL_Surface *menuimages[9]; // holds the gfx
extern SDL_Surface *menulistimages[2][9]; // holds the gfx for the lists
extern SDL_Surface *menubuttonimages[3][3]; // holds the images for the buttons 
extern SDL_Surface *menuentryimages[2][3];  // [PRESSED][Left|Center|Right]

extern SDL_Surface *menu_players[MAX_PLAYERS];	// holds playergfx of a single frame
extern SDL_Surface *menu_stones[FT_max];		// hold a frame of every stone type

extern _menu *menu_new (char *title, int x, int y);
extern void menu_delete (_menu *menu);
extern int menu_getlastitem (_menuitem *first);
extern _menuitem *menuitem_findfree (_menu *menu);
extern _menuitem *menu_create_list (_menu *menu, char *name, int x, int y, int w, int h, _charlist *data, _charlist **selected, int id);
extern _menuitem *menu_create_entry (_menu *menu, char *name, int x, int y, int w, void *data, int len, int typ, int id);
extern _menuitem *menu_create_label (_menu *menu, char *name, int x, int y, int fontsize, int fontcolor);
extern void menu_create_text (_menu *menu, char *name, int x, int y, int maxlen, int maxlines, int fontcolor, char *fmt,...);
extern _menuitem *menu_create_button (_menu *menu, char *name, int x, int y, int w, int id);
extern _menuitem *menu_create_bool (_menu *menu, char *name, int x, int y, int w, int *data, int id);
extern _menuitem *menu_create_image (_menu *menu, char *name, int x, int y, int layer, SDL_Surface *img, SDL_Rect *rect);
extern int menu_loop (_menu *menu);
extern int menu_event_loop (_menu *menu, SDL_Event *event, int eventstate);
extern void menu_draw (_menu *menu);
extern void menu_draw_border (_menu *menu);
extern void menu_draw_background (_menu *menu, SDL_Rect *dest);

extern void menu_del_menuitem (_menuitem *m);
extern void menu_reload (_menu *menu);

extern void menu_focus_next (_menu *menu);
extern void menu_focus_prev (_menu *menu);
extern void menu_focus_id (_menu *menu, int id);
extern void menu_change_focus (_menuitem *newfocus);
extern _menuitem *menu_get_lastid (_menu *menu);
extern _menuitem *menu_get_firstid (_menu *menu);
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);

extern void menu_displaymessage (char *title, char *fmt,...);
extern void menu_displaytext (char *title, char *fmt,...);
extern void menu_formattext (char *input, char *out, char **start, int *lines, int *maxlinelen, int max_chars, int max_lines);
extern void menu_drawborder (int x, int y, int w, int h);

#endif