Advertisement
Nuppiz

Menus.c

Feb 8th, 2022
1,339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.48 KB | None | 0 0
  1. #include "Shared.h"
  2. #include "Menus.h"
  3.  
  4. extern struct GameData g;
  5. extern struct Settings opt;
  6.  
  7. uint8_t story_text[] =
  8.     "I COULD WRITE A FANCY STORY BUT"
  9.     "CAN'T BE ARSED RN LOL";
  10.  
  11. Menu_t* current_menu;
  12.  
  13. Option_t mainmenu_options[] =
  14. {
  15.   {"START",     start_game},
  16.   {"OPTIONS",   menu_options},
  17.   {"HELP!",     menu_help},
  18.   {"STORY",     menu_story},
  19.   {"QUIT",      quit_game}
  20. };
  21.  
  22. Option_t settings_options[] =
  23. {
  24.   {"SOUND",         opt_sfx},
  25.   {"MUSIC",         opt_music},
  26.   {"KEY CONFIG",    menu_kconf}
  27. };
  28.  
  29. Option_t kconf_options[] =
  30. {
  31.   {"UP",      dummy},
  32.   {"LEFT",    dummy},
  33.   {"DOWN",    dummy},
  34.   {"RIGHT",   dummy}
  35. };
  36.  
  37. Option_t basic_options[] =
  38. {
  39.   {"BACK TO MAIN", menu_main}
  40. };
  41.  
  42. Menu_t mainmenu =
  43. {
  44.   "GFX/SPLASH.7UP",
  45.   5,
  46.   0,
  47.   65,
  48.   65,
  49.   105,
  50.   15,
  51.   mainmenu_options
  52. };
  53.  
  54. Menu_t optionsmenu =
  55. {
  56.   "GFX/OPTIONS.7UP",
  57.   3,
  58.   0,
  59.   65,
  60.   65,
  61.   91,
  62.   40,
  63.   settings_options
  64. };
  65.  
  66. Menu_t kconfmenu =
  67. {
  68.   "GFX/KCONF.7UP",
  69.   4,
  70.   0,
  71.   65,
  72.   65,
  73.   80,
  74.   30,
  75.   kconf_options
  76. };
  77.  
  78. Menu_t helpmenu =
  79. {
  80.   "GFX/HELP.7UP",
  81.   1,
  82.   0,
  83.   180,
  84.   180,
  85.   80,
  86.   0,
  87.   basic_options
  88. };
  89.  
  90. Menu_t storymenu =
  91. {
  92.   "GFX/STORY.7UP",
  93.   1,
  94.   0,
  95.   180,
  96.   180,
  97.   80,
  98.   0,
  99.   basic_options
  100. };
  101.  
  102. void menu_main()
  103. {
  104.     current_menu = &mainmenu;
  105.     change_menu(opt);
  106. }
  107.  
  108. void menu_options()
  109. {
  110.     current_menu = &optionsmenu;
  111.     change_menu(opt);
  112. }
  113.  
  114. void menu_kconf()
  115. {
  116.     current_menu = &kconfmenu;
  117.     change_menu(opt);
  118. }
  119.  
  120. void menu_help()
  121. {
  122.     current_menu = &helpmenu;
  123.     change_menu(opt);
  124.     draw_help_contents(g);
  125. }
  126.  
  127. void menu_story()
  128. {
  129.     current_menu = &storymenu;
  130.     change_menu(opt);
  131.     render_text(230, 185, "V.0.0023A", 0);
  132.     typewriter(opt, 4, 52, story_text, 15);
  133. }
  134.  
  135. void start_game()
  136. {
  137.     start_screen(opt);
  138.     delay(2000);
  139.    
  140.     fill_screen(0);
  141.     g.game_state = GAME_INGAME;
  142.     g.level_num = 1;
  143.     g.player_lives = 3;
  144.     level_loader(g);
  145.     music_track_select(g);
  146. }
  147.  
  148. void quit_game()
  149. {
  150.     g.game_running = FALSE;
  151. }
  152.  
  153. void opt_sfx()
  154. {
  155.     if (opt.sfx_on == TRUE)
  156.         opt.sfx_on = FALSE;
  157.     else
  158.         opt.sfx_on = TRUE;
  159.     change_menu(opt); // optimize later
  160. }
  161.  
  162. void opt_music()
  163. {
  164.     if (opt.music_on == TRUE)
  165.         opt.music_on = FALSE;
  166.     else
  167.         opt.music_on = TRUE;
  168.     change_menu(opt); // optimize later
  169. }
  170.  
  171. void dummy()
  172. {
  173.  
  174. }
  175.  
  176. void menu_controller()
  177. {
  178.     current_menu->options[current_menu->cursor_loc].action();
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement