flipchess_scene_startscreen.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "../flipchess.h"
  2. #include "../helpers/flipchess_file.h"
  3. #include "../helpers/flipchess_custom_event.h"
  4. #include "../views/flipchess_startscreen.h"
  5. void flipchess_scene_startscreen_callback(FlipChessCustomEvent event, void* context) {
  6. furi_assert(context);
  7. FlipChess* app = context;
  8. view_dispatcher_send_custom_event(app->view_dispatcher, event);
  9. }
  10. void flipchess_scene_startscreen_on_enter(void* context) {
  11. furi_assert(context);
  12. FlipChess* app = context;
  13. if(flipchess_has_file(FlipChessFileBoard, NULL, false)) {
  14. if(flipchess_load_file(app->import_game_text, FlipChessFileBoard, NULL)) {
  15. app->import_game = 1;
  16. }
  17. }
  18. flipchess_startscreen_set_callback(
  19. app->flipchess_startscreen, flipchess_scene_startscreen_callback, app);
  20. view_dispatcher_switch_to_view(app->view_dispatcher, FlipChessViewIdStartscreen);
  21. }
  22. bool flipchess_scene_startscreen_on_event(void* context, SceneManagerEvent event) {
  23. FlipChess* app = context;
  24. bool consumed = false;
  25. if(event.type == SceneManagerEventTypeCustom) {
  26. switch(event.event) {
  27. case FlipChessCustomEventStartscreenLeft:
  28. case FlipChessCustomEventStartscreenRight:
  29. break;
  30. case FlipChessCustomEventStartscreenUp:
  31. case FlipChessCustomEventStartscreenDown:
  32. break;
  33. case FlipChessCustomEventStartscreenOk:
  34. scene_manager_next_scene(app->scene_manager, FlipChessSceneMenu);
  35. consumed = true;
  36. break;
  37. case FlipChessCustomEventStartscreenBack:
  38. notification_message(app->notification, &sequence_reset_red);
  39. notification_message(app->notification, &sequence_reset_green);
  40. notification_message(app->notification, &sequence_reset_blue);
  41. if(!scene_manager_search_and_switch_to_previous_scene(
  42. app->scene_manager, FlipChessSceneStartscreen)) {
  43. scene_manager_stop(app->scene_manager);
  44. view_dispatcher_stop(app->view_dispatcher);
  45. }
  46. consumed = true;
  47. break;
  48. }
  49. }
  50. return consumed;
  51. }
  52. void flipchess_scene_startscreen_on_exit(void* context) {
  53. FlipChess* app = context;
  54. UNUSED(app);
  55. }