dtmf_dolphin_scene_start.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. if (index == DTMFDolphinSceneStateDialer) {
  5. view_dispatcher_send_custom_event(
  6. app->view_dispatcher,
  7. DTMFDolphinEventStartDialer
  8. );
  9. } else if (index == DTMFDolphinSceneStateBluebox) {
  10. view_dispatcher_send_custom_event(
  11. app->view_dispatcher,
  12. DTMFDolphinEventStartBluebox
  13. );
  14. }
  15. }
  16. void dtmf_dolphin_scene_start_on_enter(void* context) {
  17. DTMFDolphinApp* app = context;
  18. VariableItemList* var_item_list = app->main_menu_list;
  19. // VariableItem* item;
  20. variable_item_list_set_enter_callback(
  21. var_item_list,
  22. dtmf_dolphin_scene_start_main_menu_enter_callback,
  23. app);
  24. variable_item_list_add(var_item_list, "Dialer", 0, NULL, NULL);
  25. variable_item_list_add(var_item_list, "Bluebox", 0, NULL, NULL);
  26. variable_item_list_set_selected_item(
  27. var_item_list,
  28. scene_manager_get_scene_state(app->scene_manager, DTMFDolphinSceneStart));
  29. view_dispatcher_switch_to_view(
  30. app->view_dispatcher,
  31. DTMFDolphinViewMainMenu);
  32. }
  33. bool dtmf_dolphin_scene_start_on_event(void* context, SceneManagerEvent event) {
  34. DTMFDolphinApp* app = context;
  35. UNUSED(app);
  36. bool consumed = false;
  37. if(event.type == SceneManagerEventTypeCustom) {
  38. if (event.event == DTMFDolphinEventStartDialer) {
  39. scene_manager_set_scene_state(app->scene_manager, DTMFDolphinSceneDialer, DTMFDolphinSceneStateDialer);
  40. scene_manager_next_scene(app->scene_manager, DTMFDolphinSceneDialer);
  41. } else if (event.event == DTMFDolphinEventStartBluebox) {
  42. scene_manager_set_scene_state(app->scene_manager, DTMFDolphinSceneDialer, DTMFDolphinSceneStateBluebox);
  43. scene_manager_next_scene(app->scene_manager, DTMFDolphinSceneDialer);
  44. }
  45. consumed = true;
  46. }
  47. return consumed;
  48. }
  49. void dtmf_dolphin_scene_start_on_exit(void* context) {
  50. DTMFDolphinApp* app = context;
  51. variable_item_list_reset(app->main_menu_list);
  52. }