dtmf_dolphin_scene_start.c 3.1 KB

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