dtmf_dolphin_scene_start.c 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #include "../dtmf_dolphin_i.h"
  2. static void dtmf_dolphin_scene_start_main_menu_enter_callback(void* context, uint32_t index) {
  3. DTMFDolphinApp* app = context;
  4. uint8_t cust_event = 255;
  5. switch (index)
  6. {
  7. case 0:
  8. cust_event = DTMFDolphinEventStartDialer;
  9. break;
  10. case 1:
  11. cust_event = DTMFDolphinEventStartBluebox;
  12. break;
  13. case 2:
  14. cust_event = DTMFDolphinEventStartRedboxUS;
  15. break;
  16. case 3:
  17. cust_event = DTMFDolphinEventStartRedboxUK;
  18. break;
  19. case 4:
  20. cust_event = DTMFDolphinEventStartMisc;
  21. break;
  22. default:
  23. return;
  24. }
  25. view_dispatcher_send_custom_event(
  26. app->view_dispatcher,
  27. cust_event
  28. );
  29. }
  30. void dtmf_dolphin_scene_start_on_enter(void* context) {
  31. DTMFDolphinApp* app = context;
  32. VariableItemList* var_item_list = app->main_menu_list;
  33. // VariableItem* item;
  34. variable_item_list_set_enter_callback(
  35. var_item_list,
  36. dtmf_dolphin_scene_start_main_menu_enter_callback,
  37. app);
  38. variable_item_list_add(var_item_list, "Dialer", 0, NULL, context);
  39. variable_item_list_add(var_item_list, "Bluebox", 0, NULL, context);
  40. variable_item_list_add(var_item_list, "Redbox (US)", 0, NULL, context);
  41. variable_item_list_add(var_item_list, "Redbox (UK)", 0, NULL, context);
  42. variable_item_list_add(var_item_list, "Misc", 0, NULL, context);
  43. variable_item_list_set_selected_item(
  44. var_item_list,
  45. scene_manager_get_scene_state(app->scene_manager, DTMFDolphinSceneStart));
  46. view_dispatcher_switch_to_view(
  47. app->view_dispatcher,
  48. DTMFDolphinViewMainMenu);
  49. }
  50. bool dtmf_dolphin_scene_start_on_event(void* context, SceneManagerEvent event) {
  51. DTMFDolphinApp* app = context;
  52. UNUSED(app);
  53. bool consumed = false;
  54. if(event.type == SceneManagerEventTypeCustom) {
  55. uint8_t sc_state;
  56. switch (event.event)
  57. {
  58. case DTMFDolphinEventStartDialer:
  59. sc_state = DTMFDolphinSceneStateDialer;
  60. break;
  61. case DTMFDolphinEventStartBluebox:
  62. sc_state = DTMFDolphinSceneStateBluebox;
  63. break;
  64. case DTMFDolphinEventStartRedboxUS:
  65. sc_state = DTMFDolphinSceneStateRedboxUS;
  66. break;
  67. case DTMFDolphinEventStartRedboxUK:
  68. sc_state = DTMFDolphinSceneStateRedboxUK;
  69. break;
  70. case DTMFDolphinEventStartMisc:
  71. sc_state = DTMFDolphinSceneStateMisc;
  72. break;
  73. default:
  74. return consumed;
  75. }
  76. scene_manager_set_scene_state(app->scene_manager, DTMFDolphinSceneDialer, sc_state);
  77. scene_manager_next_scene(app->scene_manager, DTMFDolphinSceneDialer);
  78. consumed = true;
  79. }
  80. return consumed;
  81. }
  82. void dtmf_dolphin_scene_start_on_exit(void* context) {
  83. DTMFDolphinApp* app = context;
  84. variable_item_list_reset(app->main_menu_list);
  85. }