#ifndef MENU_H
#define MENU_H

#define MAX_MENU_ITEMS 32
#define VG_MAX_MENUS   32

#define MENU_ITEM_TYPE_NORMAL       0
#define MENU_ITEM_TYPE_FLAG         1
#define MENU_ITEM_TYPE_HEADER       2 /* non-selectable */
#define MENU_ITEM_TYPE_VARIABLE     3 /* text or integer variable */
#define MENU_ITEM_TYPE_STRING       4 /* print the pointed string */
#define MENU_ITEM_TYPE_IMAGE        5 /* image item */

#define VG_MENU_MAIN             0
#define VG_MENU_PLAY             1
#define VG_MENU_PLAY_SELECT      2
#define VG_MENU_PLAY_NEW         3
#define VG_MENU_OPTIONS          4

#define MENU_CONTROLS         2
#define MENU_CONTROLS_P       3
#define MENU_GAME_SETTINGS    5
#define MENU_WEAPONS          6
#define MENU_ITEMS            7
#define MENU_WEAPONS_CUSTOM   8
#define MENU_ITEMS_CUSTOM     9
#define MENU_GAME_MODE       10
#define MENU_GAME_PAUSE      11
#define MENU_GAME_REPLAY     12
#define MENU_GAME_SETTINGS_2 13
#define MENU_IP              14
#define MENU_MAIN_SERVER     15
#define MENU_MAIN_CLIENT     16
#define MENU_NETWORK         17
#define MENU_SERVER_CLOSE    18
#define MENU_DISCONNECT      19
#define MENU_NET_PAUSE       20
#define MENU_NET_SETTINGS    21
#define MENU_GAME_SETTINGS_3 22
#define MENU_SERVER_START    23
#define MENU_CONNECT_MAIN    24
#define MENU_SETTINGS_SUB    25
#define MENU_SETTINGS_SUB2   26
#define MENU_SETTINGS_SUB3   27
#define MENU_SETTINGS_SUB4   28
#define MENU_MAIN_MCLIENT    29
#define MENU_PROFILES        30
#define MENU_PROFILES_NEW    31
#define MENU_CONFIRM_DELETE  32
#define MENU_GAME_REPLAY2    33
#define MENU_GAME_PAUSE2     34
#define MENU_SETTINGS_AUDIO  35
#define MENU_SETTINGS_VIDEO  36
#define MENU_SETTINGS_NETWORK 37

//#define MENU_SELECT_IP       25

typedef struct
{
	/* image */
	BITMAP * bp;

	/* offset from location of menu */
	int ox, oy;
	FONT * fp;

	/* item name */
//	char name[128];
	char * name;
	char description[1024];

	/* option pointer (should stay between max and min) */
	int * dp;

	/* option text pointer */
	char ** dp2;
	int type, choice, vis;

	/* procedure for left keypress */
    void(*left_proc)();

    /* procedure for right keypress */
    void(*right_proc)();

    /* procedure for enter keypress */
    void(*enter_proc)();

} VG_MENU_ITEM;

typedef struct
{
	/* menu items */
	VG_MENU_ITEM item[MAX_MENU_ITEMS];
	int items;
	int parent;
	char * title;

	int selected;
	int x, y;

} VG_MENU;

void vg_menu_play(void);
void vg_menu_play_new(void);
void vg_menu_play_new_normal(void);
void vg_menu_play_new_hard(void);
void vg_menu_play_continue(void);
void vg_menu_options(void);
void vg_menu_quit(void);
void select_menu(int num);
void create_menu(VG_MENU * mp, char * title, int x, int y, int parent);
void add_menu_item(VG_MENU * mp, FONT * fp, int ox, int oy, char * name, void(*left_proc)(), void(*right_proc)(), void(*enter_proc)());
void add_menu_flag(VG_MENU * mp, FONT * fp, int ox, int oy, char * name, int * dp, void(*left_proc)(), void(*right_proc)(), void(*enter_proc)());
void add_menu_header(VG_MENU * mp, FONT * fp, int ox, int oy, char * name);
void add_menu_variable(VG_MENU * mp, FONT * fp, int ox, int oy, int * dp, char * dp2[]);
void add_menu_string(VG_MENU * mp, FONT * fp, int ox, int oy, char * string);
void add_menu_image(VG_MENU * mp, FONT * fp, int ox, int oy, BITMAP * bp);
void menu_fix_item(VG_MENU * mp);
void menu_next_item(VG_MENU * mp);
void menu_prev_item(VG_MENU * mp);
void menu_setup(void);
void draw_menu(BITMAP * bp, VG_MENU * mp);

void menu_logic(void);
void menu_render(void);
void menu_draw(void);

#endif
