Subversion Repositories Kolibri OS

Rev

Rev 5235 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include "rsgamemenu.h"
  2.  
  3. #include "rsgame.h"
  4.  
  5. #include "rskos.h"
  6.  
  7. #include "strings.h"
  8.  
  9. //PRSFUNC0 menu_actions[] = {
  10. //    /* a */ &menu_action_start,    
  11. //    /* b */ &menu_action_exit,
  12. //    /* c */ &menu_action_change_window_scale
  13. //};
  14.  
  15. char window_scale_str[] = "c< 2X >";
  16.  
  17. /*
  18.     First char:
  19.     - letter a...z means action (a = 0th, b = 1st, c = 2nd, see menu_actions[] above)
  20.     - number 0...9 means goto menu #0, #1, #2... see menu_titles[] below
  21.     - space ' ' means no action, menu item is unselectable
  22.     - empty string "" is now allowed and can cause segfault
  23.     String from second char is label of menu item
  24.  
  25. */
  26.  
  27.  
  28. char* menu_main_titles[] = {
  29.     "a"L_START,
  30. //    "1"L_SETTINGS,
  31. //    "2"L_ABOUT,
  32. //    "b"L_QUIT,
  33.     0
  34. };
  35.  
  36. char* menu_settings_titles[] = {
  37. //    " "L_WINDOW_SCALE,
  38. //    window_scale_str,
  39. //    " ",
  40. //    "0"L_DONE,
  41.     0
  42. };
  43.  
  44. char* menu_about_titles[] = {
  45. //    " "L_DEVELOPED_BY,
  46. //    " "L_ROMAN_SHUVALOV,
  47. //    " ",
  48. //    "0"L_DONE,
  49.     0
  50. };
  51.  
  52. char **menu_titles[] = {
  53.     /* 0 */ menu_main_titles,
  54.     /* 1 */ menu_settings_titles,
  55.     /* 2 */ menu_about_titles,
  56.     0
  57. };
  58.  
  59.  
  60. void menu_cursor_down() {
  61.     int new_index = game.menu_item_index+1;
  62.     while ( (menu_titles[game.menu_index][new_index]) ) {
  63.         if ((menu_titles[game.menu_index][new_index][0] != ' ')) {
  64.             game.menu_item_index = new_index;
  65.             game_ding(1);
  66.             return;
  67.         };
  68.         new_index++;
  69.     };
  70. };
  71.  
  72. void menu_cursor_up() {
  73.     int new_index = game.menu_item_index-1;
  74.     while ( new_index+1 ) {
  75.         if ((menu_titles[game.menu_index][new_index][0] != ' ')) {
  76.             game.menu_item_index = new_index;
  77.             game_ding(1);
  78.             return;
  79.         };
  80.         new_index--;
  81.     };
  82. };
  83.  
  84. void menu_open(int i) {
  85.    
  86.     game.menu_index = i;
  87.    
  88.     game.menu_item_index = -1;
  89.     // (menu_cursor_down without sound)
  90.     int new_index = game.menu_item_index+1;
  91.     while ( (menu_titles[game.menu_index][new_index]) ) {
  92.         if ((menu_titles[game.menu_index][new_index][0] != ' ')) {
  93.             game.menu_item_index = new_index;
  94.             return;
  95.         };
  96.         new_index++;
  97.     };
  98.    
  99. };
  100.  
  101. void menu_cursor_click() {
  102.    
  103. //
  104.    
  105. };
  106.  
  107. void menu_action_start() {
  108.     game.status = STATUS_PLAYING;
  109.    
  110.     game.tx = GAME_WIDTH/2 - 50;
  111.     game.ty = GAME_HEIGHT/2 - 10;
  112.    
  113. };
  114.  
  115. void menu_action_exit() {
  116.     #ifdef RS_KOS
  117.         GameTerm();
  118.     #endif
  119.     rskos_exit();
  120. };
  121.  
  122.