1 /* 2 * This code is released under the GNU General Public License. See COPYING for 3 * details. Copyright 2003 John Spray: spray_john@users.sourceforge.net 4 */ 5 6 /* 7 * A little documentation is in order. To use this menu, construct it with: 8 * 9 *char* itemlabels[] - a NULL TERMINATED array of strings - {"foo","bar",NULL} 10 *menufunc itemfunctions[] - MENU_QUIT,MENU_FLOAT. You'll get returned whichever of these was selected from Menu::Happen() 11 * and in the case of MENU_FLOAT etc, they tell MenuItems how to behave. 12 *void* itemtargets[] - pointers to the values that will be altered by MENU_FLOAT entries, etc. 13 *Visual* newvisual - a Visual that's had InitGL called. 14 * 15 *Then call Menu::Happen(). Do what you will with the return value (MENU_QUIT,MENU_QUITFULL)... 16 * 17 *Don't forget to set solidbackground - 0 if you're during gameplay, 1 otherwise 18 *You'll need to have created a Visual, and a Game for the visual. Sorry. We really only use the 19 *Visual for resource (texture) management. 20 * 21 * 22 */ 23 24 #ifndef MENU_H 25 #define MENU_H 26 27 #include "Visual.h" 28 #include "SDL_ttf.h" 29 30 31 typedef enum{ 32 MENU_QUITFULL, 33 MENU_QUIT, 34 MENU_CONTINUE, 35 MENU_FLOAT, 36 MENU_FLOATONE, 37 MENU_STRING, 38 MENU_BOOL, 39 MENU_SUB1, 40 MENU_SUB2, 41 MENU_SUB3, 42 MENU_SUB4, 43 MENU_SUB5, 44 MENU_SUB6, 45 MENU_NOSELECT, 46 MENU_NONE 47 } menufunc; 48 49 class MenuItem; 50 51 class Menu{ 52 public: 53 int selection; 54 void Arrange(int width,int height); 55 void Up(); 56 void Down(); 57 void Draw(); 58 void HandleClick(int x,int y); 59 void HandleMotion(int x,int y); 60 void HandleEvents(); 61 void Select(int newselection); 62 menufunc Happen(); 63 Menu(char* itemlabels[],menufunc itemfunctions[],void* itemtargets[],Visual* newvisual); 64 ~Menu(); 65 int solidbackground; 66 TTF_Font* font; 67 Visual* visual; 68 private: 69 int done; 70 int itemcount; 71 MenuItem* item; 72 int viewportx, viewporty; 73 struct {int x;int y;} mouse; 74 75 76 }; 77 78 #endif //MENU_H 79