frodo-wii/menu.hh

79 lines
1.2 KiB
C++
Raw Normal View History

2009-01-13 18:46:42 +00:00
/*********************************************************************
*
* Copyright (C) 2004, 2008, Simon Kagstrom
*
* Filename: menu.h
* Author: Simon Kagstrom <simon.kagstrom@gmail.com>
* Description:
*
* $Id$
*
********************************************************************/
#ifndef __MENU_H__
#define __MENU_H__
#include <SDL.h>
#include <SDL_ttf.h>
#include <stdint.h>
2009-11-19 17:59:43 +00:00
enum {
KEY_UP,
KEY_DOWN,
KEY_LEFT,
KEY_RIGHT,
KEY_SELECT,
KEY_ESCAPE,
KEY_PAGEDOWN,
KEY_PAGEUP,
KEY_HELP,
};
2009-01-22 20:34:33 +00:00
typedef struct
{
int n_entries;
int index;
int sel;
} submenu_t;
2009-11-19 17:42:02 +00:00
class Menu
{
public:
2009-11-19 17:59:43 +00:00
Menu(TTF_Font *font, SDL_Color clr, int w, int h);
2009-11-19 17:42:02 +00:00
2009-11-19 17:59:43 +00:00
void setText(const char **messages);
2009-11-19 17:42:02 +00:00
void pushEvent(SDL_Event *ev);
void runLogic();
2009-11-19 17:59:43 +00:00
void draw(SDL_Surface *where,
int x, int y);
2009-11-19 17:42:02 +00:00
~Menu();
private:
const char *title;
const char **pp_msgs;
2009-11-19 17:59:43 +00:00
TTF_Font *font;
2009-11-19 17:42:02 +00:00
SDL_Color text_color;
int (*hover_callback)(Menu *me, int index);
int (*selection_callback)(Menu *me, int index);
2009-11-19 17:59:43 +00:00
/* Width and height */
int w, h;
/* Relative to this menu */
int mouse_x, mouse_y;
2009-11-19 17:42:02 +00:00
int n_submenus;
submenu_t *p_submenus;
int cur_sel; /* Main selection */
int start_entry_visible;
int n_entries;
2009-11-19 17:59:43 +00:00
};
2009-02-13 07:58:33 +00:00
2009-01-13 18:46:42 +00:00
#endif /* !__MENU_H__ */