pokemon_menu.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #include "../pokemon_app.h"
  2. #include "../pokemon_data.h"
  3. #include "../pokemon_char_encode.h"
  4. #include "pokemon_menu.h"
  5. #include "pokemon_gen.h"
  6. #include "pokemon_select.h"
  7. #include "pokemon_name_input.h"
  8. #include "pokemon_number_input.h"
  9. #include "pokemon_move.h"
  10. #include "pokemon_item.h"
  11. #include "pokemon_type.h"
  12. #include "pokemon_stats.h"
  13. #include "pokemon_shiny.h"
  14. #include "pokemon_gender.h"
  15. #include "pokemon_pokerus.h"
  16. #include "pokemon_trade.h"
  17. #include "pokemon_pins.h"
  18. #include "pokemon_exit_confirm.h"
  19. static void scene_change_from_main_cb(void* context, uint32_t index) {
  20. PokemonFap* pokemon_fap = (PokemonFap*)context;
  21. /* The same trade scene is used for both gen i and ii. Set the real index to
  22. * scene's state.
  23. */
  24. scene_manager_set_scene_state(pokemon_fap->scene_manager, GenITradeScene, index);
  25. /* Set scene state to the current index so we can have that element highlighted when
  26. * we return.
  27. */
  28. scene_manager_set_scene_state(pokemon_fap->scene_manager, MainMenuScene, index);
  29. scene_manager_next_scene(pokemon_fap->scene_manager, index);
  30. }
  31. bool main_menu_back_event_callback(void* context) {
  32. furi_assert(context);
  33. PokemonFap* pokemon_fap = context;
  34. return scene_manager_handle_back_event(pokemon_fap->scene_manager);
  35. }
  36. void main_menu_scene_on_enter(void* context) {
  37. PokemonFap* pokemon_fap = (PokemonFap*)context;
  38. submenu_reset(pokemon_fap->submenu);
  39. submenu_set_header(pokemon_fap->submenu, "Pokemon Trade Tool");
  40. submenu_add_item(
  41. pokemon_fap->submenu,
  42. "Gen I (R/B/Y non-JPN)",
  43. GenITradeScene,
  44. scene_change_from_main_cb,
  45. pokemon_fap);
  46. submenu_add_item(
  47. pokemon_fap->submenu,
  48. "Gen II (G/S/C non-JPN)",
  49. GenIITradeScene,
  50. scene_change_from_main_cb,
  51. pokemon_fap);
  52. submenu_add_item(
  53. pokemon_fap->submenu,
  54. "Select EXT Pinout",
  55. SelectPinsScene,
  56. scene_change_from_main_cb,
  57. pokemon_fap);
  58. submenu_set_selected_item(
  59. pokemon_fap->submenu,
  60. scene_manager_get_scene_state(pokemon_fap->scene_manager, MainMenuScene));
  61. view_dispatcher_set_navigation_event_callback(
  62. pokemon_fap->view_dispatcher, main_menu_back_event_callback);
  63. view_dispatcher_switch_to_view(pokemon_fap->view_dispatcher, AppViewMainMenu);
  64. }
  65. bool null_scene_on_event(void* context, SceneManagerEvent event) {
  66. UNUSED(context);
  67. UNUSED(event);
  68. return false;
  69. }
  70. void null_scene_on_exit(void* context) {
  71. UNUSED(context);
  72. }
  73. void generic_scene_on_exit(void* context) {
  74. PokemonFap* pokemon_fap = (PokemonFap*)context;
  75. view_dispatcher_switch_to_view(pokemon_fap->view_dispatcher, AppViewMainMenu);
  76. view_dispatcher_remove_view(pokemon_fap->view_dispatcher, AppViewOpts);
  77. }
  78. void (*const pokemon_scene_on_enter_handlers[])(void*) = {
  79. main_menu_scene_on_enter, //MainMenuScene,
  80. gen_scene_on_enter, //GenITradeScene,
  81. gen_scene_on_enter, //GenIITradeScene,
  82. select_pokemon_scene_on_enter, //SelectPokemonScene,
  83. select_name_scene_on_enter, //SelectNicknameScene,
  84. select_number_scene_on_enter, //SelectLevelScene,
  85. select_move_scene_on_enter, //SelectMoveScene,
  86. select_move_index_scene_on_enter, //SelectMoveIndexScene,
  87. select_move_set_scene_on_enter, //SelectMoveSetScene,
  88. select_item_scene_on_enter, //SelectItemScene,
  89. select_item_set_scene_on_enter, //SelectItemSetScene,
  90. select_type_scene_on_enter, //SelectTypeScene,
  91. select_stats_scene_on_enter, //SelectStatsScene,
  92. select_shiny_scene_on_enter, //SelectShinyScene,
  93. select_gender_scene_on_enter, //SelectGenderScene,
  94. select_pokerus_scene_on_enter, //SelectPokerusScene,
  95. select_name_scene_on_enter, //SelectUnownFormScene,
  96. select_number_scene_on_enter, //SelectOTIDScene,
  97. select_name_scene_on_enter, //SelectOTNameScene,
  98. trade_scene_on_enter, //TradeScene,
  99. select_pins_scene_on_enter, //SelectPinsScene,
  100. pokemon_exit_confirm_on_enter, //ConfirmExitScene,
  101. };
  102. void (*const pokemon_scene_on_exit_handlers[])(void*) = {
  103. null_scene_on_exit, //MainMenuScene,
  104. null_scene_on_exit, //GenITradeScene,
  105. null_scene_on_exit, //GenIITradeScene,
  106. null_scene_on_exit, //SelectPokemonScene,
  107. generic_scene_on_exit, //SelectNicknameScene,
  108. generic_scene_on_exit, //SelectLevelScene,
  109. null_scene_on_exit, //SelectMoveScene,
  110. null_scene_on_exit, //SelectMoveIndexScene,
  111. null_scene_on_exit, //SelectMoveSetScene,
  112. null_scene_on_exit, //SelectItemScene,
  113. null_scene_on_exit, //SelectItemSetScene,
  114. generic_scene_on_exit, //SelectTypeScene,
  115. null_scene_on_exit, //SelectStatsScene,
  116. null_scene_on_exit, //SelectShinyScene,
  117. null_scene_on_exit, //SelectGenderScene,
  118. generic_scene_on_exit, //SelectPokerusScene,
  119. generic_scene_on_exit, //SelectUnownFormScene,
  120. generic_scene_on_exit, //SelectOTIDScene,
  121. generic_scene_on_exit, //SelectOTNameScene,
  122. null_scene_on_exit, //TradeScene,
  123. generic_scene_on_exit, //SelectPinsScene,
  124. generic_scene_on_exit, //ConfirmExitScene,
  125. };
  126. bool (*const pokemon_scene_on_event_handlers[])(void*, SceneManagerEvent) = {
  127. null_scene_on_event, //MainMenuScene,
  128. null_scene_on_event, //GenITradeScene,
  129. null_scene_on_event, //GenIITradeScene,
  130. null_scene_on_event, //SelectPokemonScene,
  131. null_scene_on_event, //SelectNicknameScene,
  132. null_scene_on_event, //SelectLevelScene,
  133. null_scene_on_event, //SelectMoveScene,
  134. null_scene_on_event, //SelectMoveIndexScene,
  135. null_scene_on_event, //SelectMoveSetScene,
  136. null_scene_on_event, //SelectItemScene,
  137. null_scene_on_event, //SelectItemSetScene,
  138. null_scene_on_event, //SelectTypeScene,
  139. null_scene_on_event, //SelectStatsScene,
  140. null_scene_on_event, //SelectShinyScene,
  141. null_scene_on_event, //SelectGenderScene,
  142. null_scene_on_event, //SelectPokerusScene,
  143. null_scene_on_event, //SelectUnownFormScene,
  144. null_scene_on_event, //SelectOTIDScene,
  145. null_scene_on_event, //SelectOTNameScene,
  146. null_scene_on_event, //TradeScene,
  147. null_scene_on_event, //SelectPinsScene,
  148. pokemon_exit_confirm_on_event, //ConfirmExitScene,
  149. };
  150. const SceneManagerHandlers pokemon_scene_manager_handlers = {
  151. .on_enter_handlers = pokemon_scene_on_enter_handlers,
  152. .on_exit_handlers = pokemon_scene_on_exit_handlers,
  153. .on_event_handlers = pokemon_scene_on_event_handlers,
  154. .scene_num = SceneCount,
  155. };