GameMenu.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. #ifndef __GAMEMENU__
  5. #define __GAMEMEMU__
  6. enum MENU_ITEM_TYPE { MI_TRIGGER };
  7. class GameMenu;
  8. struct MenuItem {
  9. MENU_ITEM_TYPE type;
  10. float alpha;
  11. int index;
  12. bool selected;
  13. char *label;
  14. char *action;
  15. bool keysEnabled;
  16. bool keyfocus;
  17. GameMenu *subMenu;
  18. MenuItem *next;
  19. };
  20. typedef void (*GAMEMENU_RENDERFUNCTIONTYPE)(void *data, GameMenu *menu, MenuItem *i );
  21. class GameMenu {
  22. public:
  23. GameMenu( GAMEMENU_RENDERFUNCTIONTYPE renderCallBack,
  24. void *dataToCallbacks,
  25. char *menuTitle = 0 );
  26. virtual ~GameMenu();
  27. const char *run( float frameTime ); // return command string
  28. void render();
  29. // returns whether the click was valid
  30. bool click( int index );
  31. MenuItem* addMenuItem( const char *label, const char *action, MENU_ITEM_TYPE type = MI_TRIGGER );
  32. MenuItem* getItemAt( int index );
  33. void releaseItems();
  34. int getItemCount();
  35. float getLifeTime() { return lifeTime; }
  36. float getDestroyAnimation() { return destroyAnimation; }
  37. bool alreadyClicked() { if (nextReturnAction) return true; else return false; }
  38. void keyControlUp();
  39. void keyControlDown();
  40. void keyControlSelect();
  41. void keyControlEnd();
  42. protected:
  43. int keyControlIndex;
  44. char *nextReturnAction;
  45. float destroyAnimation;
  46. float lifeTime;
  47. char *title;
  48. GAMEMENU_RENDERFUNCTIONTYPE renderFunction;
  49. void *dataToRenderFunction;
  50. MenuItem *itemList;
  51. };
  52. #endif