#ifndef MENU_H_
#define MENU_H_

#include "widget.h"

#define KAT_MENU_MAIN 1
//#define KAT_MENU_SETUP 2
#define KAT_MENU_LAUNCHER 3
#define KAT_MENU_OPTIONS_MACHINE 4
#define KAT_MENU_OPTIONS_VIDEO 5
#define KAT_MENU_OPTIONS_SOUND 6
#define KAT_MENU_OPTIONS_INPUT 7
#define KAT_MENU_OPTIONS_UI 8
#define KAT_MENU_OPTIONS_MISC 9

#define KAT_MENU_OPTIONS_VIDEO_NTSC 10

#define KAT_MENU_OPTIONS_INPUT_P1 11
#define KAT_MENU_OPTIONS_INPUT_P2 12
#define KAT_MENU_OPTIONS_INPUT_P3 13
#define KAT_MENU_OPTIONS_INPUT_P4 14

#define KAT_MENU_OPTIONS_SETUP 15
#define KAT_MENU_OPTIONS_DEBUG 16
#define KAT_MENU_OPTIONS_MEDIA 17
#define KAT_MENU_OPTIONS_INPUT_UI 18
#define KAT_MENU_OPTIONS_INPUT_A800_KEYS 19
#define KAT_MENU_OPTIONS_MEDIA_CREATE 20
#define KAT_MENU_OPTIONS_MEDIA_DISK 21
#define KAT_MENU_OPTIONS_MEDIA_CASSETTE 22
#define KAT_MENU_INPUT_ACTION 23
#define KAT_MENU_OPTIONS_INPUT_JOY_SELECT 24
#define KAT_MENU_LOAD_STATE 25
#define KAT_MENU_SAVE_STATE 26
#define KAT_MENU_OPTIONS_CONFIG 27
#define KAT_MENU_OPTIONS_VIDEO_SHADER 28
#define KAT_MENU_OPTIONS_MACHINE_POKEY_POTS 29
#define KAT_MENU_OPTIONS_PALETTE 30
#define KAT_MENU_OPTIONS_LOG 31

#define KM_ALIGN_H_LEFT   1
#define KM_ALIGN_H_RIGHT  2
#define KM_ALIGN_H_CENTER 4

#define KM_ALIGN_V_UP     8
#define KM_ALIGN_V_BOTTOM 16
#define KM_ALIGN_V_CENTER 32

/* Sizes the shared g_options[] widget array for every menu.  Must stay >=
   SHADER_MAX_PARAMS (menu_shader.c) so large shader bundles (e.g.
   crt-guest-advanced-ntsc, ~170 params) render their full param list. */
#define MAX_OPTIONS 256

struct menu {
    int id;
    int alignment;
    int allow_scroll;
    char title[80];
};

void main_load_rom_from_file(struct option_widget *wgt, void *data);
struct option_widget *menu_find_item(unsigned long long mask);
struct option_widget *menu_find_item_by_label(unsigned long long mask, char *label);
int menu_options_machine(struct option_widget *wid_ary);
int menu_options_machine_pokey_pots(struct option_widget *wid_ary);
char * machine_get_string(struct option_widget *wgt, char *label);
char * machine_get_os_string(struct option_widget *wgt, char *label);
char * machine_get_port_string(struct option_widget *wgt, char *label);
int menu_options_video(struct option_widget *wid_ary);
int menu_options_video_ntsc(struct option_widget *wid_ary);
void menu_video_draw_preview(struct nk_context *ctx, int x, int y, int w, int h);
int menu_options_video_shader(struct option_widget *wid_ary);
void menu_shader_draw_preview(struct nk_context *ctx, int x, int y, int w, int h);
void menu_shader_enter(void);
void menu_shader_exit(void);
float menu_shader_select_value_width(struct nk_context *ctx);
int menu_options_sound(struct option_widget *wid_ary);
int menu_options_input(struct option_widget *wid_ary);
int menu_options_input_player(struct option_widget *wid_ary, int player_num);
int menu_options_input_ui(struct option_widget *wid_ary);
int menu_options_input_a800_keys(struct option_widget *wid_ary);
int menu_input_action(struct option_widget *wid_ary);
void menu_input_action_setup(struct option_widget *wgt, int prev_menu);
const char *menu_input_action_get_title(void);
int menu_options_misc(struct option_widget *wid_ary);
int menu_options_config(struct option_widget *wid_ary);
int menu_options_palette(struct option_widget *wid_ary);
int menu_options_log(struct option_widget *wid_ary);
void menu_log_open(struct option_widget *wgt, void *data);
void menu_log_render(struct nk_context *ctx);
int menu_options_setup(struct option_widget *wid_ary);
int menu_options_media_create(struct option_widget *wid_ary);
int menu_options_media_disk(struct option_widget *wid_ary);
int menu_options_media_cassette(struct option_widget *wid_ary);
int menu_options_input_joy_select(struct option_widget *wid_ary);
int menu_load_state(struct option_widget *wid_ary);
int menu_save_state(struct option_widget *wid_ary);

void menu_options_setup_exit(void);

/* Input capture modal functions */
struct nk_context;  /* Forward declaration */
union SDL_Event;    /* Forward declaration */
void menu_input_capture_show(struct nk_context *ctx, int screen_w, int screen_h);
int menu_input_capture_process_event(union SDL_Event *event);
int menu_input_capture_is_active(void);

//int menu_set(struct nk_context *ctx, struct menu *p_menu, struct option_widget *wid_ary);
//int menu_set(struct nk_context *ctx, struct menu *p_menu, struct option_widget *wid_ary);

#endif
